akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			A[i] = new int[3]{int.Parse(str[0]),int.Parse(str[1]),0};			
		}
		Array.Sort(A,(x,y)=>x[0]-y[0]);
		for(var i=N/2;i<N;i++){
			A[i][2] = 1;
		}
		int amin = A[0][0];
		int amax = A[0][1];
		int bmin = A[1][0];
		int bmax = A[1][1];
		for(var i=2;i<N;i++){
			int cmin = Math.Max(amin,A[i][0]);
			int cmax = Math.Min(amax,A[i][1]);
			int c1 = Math.Max(0,cmax-cmin+1)+Math.Max(0,bmax-bmin+1);
			int dmin = Math.Max(bmin,A[i][0]);
			int dmax = Math.Min(bmax,A[i][1]);
			int d1 = Math.Max(0,amax-amin+1)+Math.Max(0,dmax-dmin+1);
			int emin = Math.Max(amin,bmin);
			int emax = Math.Min(amax,bmax);
			int e1 = Math.Max(0,emax-emin+1)+Math.Max(0,A[i][1]-A[i][0]+1);
			if(c1>=d1 && c1>=e1){
				amin = cmin;
				amax = cmax;
			} else if(d1>=c1 && d1>=e1){
				bmin = dmin;
				bmax = dmax;
			} else {
				amin = emin;
				amax = emax;
				bmin = A[i][0];
				bmax = A[i][1];
			}
		}
		int ans = Math.Max(0,amax-amin+1)+Math.Max(0,bmax-bmin+1);
		Console.WriteLine(ans);
	}
}

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

const int maxn = 2e5+5;
const ll INF = 1e18;
ll n, x, d;

map<ll,vector<pair<ll,ll>>> mp;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> x >> d;
    if (d < 0) {
        x *= -1;
        d *= -1;
    }
    if (d == 0) {
        if (x == 0) {
            cout << 1 << '\n';
        }
        else {
            cout << n+1 << '\n';
        }
        return 0;
    }
    ll small = 0, big = 0;
    ll ans = 0;
    for (int m = 0; m <= n; m++) {
        //take m elements
        //min sum is x*m + d*(0+...+m-1)
        //max sum is x*m + d*(n-1+n-2+...+) [m elements]
        if (m >= 1) small += m-1;
        if (m >= 1) big += n-m;
        ll mn = x*m + d*small;
        ll mx = x*m + d*big;
        //cout << m << ": " << mn << ' ' << mx << '\n';
        ll mod = (x*m) % d;

        mp[mod].push_back({mn,mx});    
    }
    for (auto p: mp) {
        vector<pair<ll,ll>>& v = p.second;
        sort(v.begin(),v.end(),[](auto a, auto b) {
            return a.first != b.first ? a.first < b.first : a.second < b.second;
                });
        pair<ll,ll> curr = {-INF,-INF};
        for (auto pp: v) {
            if (pp.first > curr.second) {
                if (curr.first != -INF) {
                    ans += (curr.second-curr.first)/d + 1;
                }
                curr = pp;
            }
            else {
                curr.second = max(curr.second,pp.second);
            }
        }
        if (curr.first != -INF) {
            ans += (curr.second-curr.first)/d + 1;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 22144
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>
#include <numeric>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());

  int prev = -1;
  int cnt = 0;
  int ans = 0;

  rep(i, N) {
    if (A[i] != prev) {
      ans += (cnt % 2 != 0);
      prev = A[i];
      cnt = 1;
    } else cnt++;
  }
  ans += (cnt % 2 != 0);

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


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  string s, t;

  cin >> s >> t;

  int ans = t.size();

  for (size_t i = 0; i <= s.size() - t.size(); i++) {
    int rez = 0;
    for (size_t j = 0; j < t.size(); j++) {
      if (s[i+j] != t[j]) {
        rez++;
      }
    }
    if (ans > rez) {
      ans = rez;
    }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 3604
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.charAt(s.length()-1)=='s') System.out.println(s+"es");
    else System.out.println(s+"s");
  }
}

Measured memory_bytes: 38412
# -*- coding: utf-8 -*-

import sys
from collections import deque
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def LDS(A: list):
    L = deque([A[0]])
    for a in A[1:]:
        if a <= L[0]:
            # Lの先頭よりaが小さければ減少部分列を延長する(今回は広義(=を含む))
            L.appendleft(a)
        else:
            # そうでなければ、「a以上の最小要素の手前」をaにする
            # 該当位置は、二分探索で特定できる
            L[bisect_left(L, a)-1] = a
    return len(L)

N=INT()
A=[INT() for i in range(N)]

print(LDS(A))


Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char[] c = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			c[i] = s.charAt(i);
		}
		int count = 0;
		for (int i = 1; i < s.length(); i++) {
			if (c[i] != c[i-1]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26964
s = input()
n = len(s)
first_half = s[:(n - 1) // 2]
last_half = s[(n + 3) // 2 - 1:]

if s == s[::-1] and first_half == first_half[::-1] and last_half == last_half[::-1]:
    print('Yes')
else:
    print('No')


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

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



int main(){
  int n;
  vector<int> cnt('z'-'a'+1, 60);
  cin >> n;
  vector<string> S(n);
  REP(i, n){
    cin >> S[i];
  }
  REP(i, 'z'-'a'+1){
    char x = i + 'a';
    REP(j, n){
      int sum = 0;
      REP(k, S[j].length()){
        if(S[j][k] == x){
          sum++;
        }
      }
      cnt[i] = min(cnt[i], sum);
    }
  }
  string ans;
  REP(i, 'z'-'a'+1){
    REP(j, cnt[i]){
      ans.push_back(i+'a');
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  
  vector<bool> check(26, true);
  int num;
  
  for (int i = 0; i < s.size(); i++) {
    num = s[i] - 'a';
    check[num] = false;
  }
  
  bool fin = false;
  char ans;
  
  for (int i = 0; i < 26; i++) {
    if (check[i]) {
      ans = i + 'a';
      cout << ans;
      fin = true;
      break;
    }
  }
  
  if (!fin)
    cout << "None";
    
}

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


int main(){

  lint N,M,X;
  cin >> N >> M >> X;
  
  vector<lint> C(N);
  vector<vector<lint> > A(N, vector<lint>(M));
  vector<vector<lint> > rikai(pow(2,N), vector<lint>(M));
  vector<lint> price(pow(2,N));
  vector<bool> able(pow(2,N), false);
  
  for(lint i=0; i<N; i++){
    cin >> C[i];
    for(lint j=0; j<M; j++){
      cin >> A[i][j];
    }
  }
  
  // priceとrikaiを計算
  for(lint i=1; i<=pow(2,N); i++){
    lint tmp = i;
    for(lint j=0; j<N; j++){
      
      price[i-1] += (tmp%2)*C[j];
      
      for(lint k=0; k<M; k++){
      rikai[i-1][k] += (tmp%2)*A[j][k];
      }
      
      tmp = tmp / 2;
    }
  }
  
  // able判定
  for(lint i=0; i<pow(2,N); i++){
    sort(rikai[i].begin(), rikai[i].end());
    if(rikai[i][0]>=X) able[i] = true;
  }
  
  vector<lint> price_sort(0);
  
  for(int i=0; i<pow(2,N); i++){
    if(able[i]) price_sort.push_back(price[i]);
  }
  

  if(price_sort.size()==0) cout << "-1" << endl;
  else{
  sort(price_sort.begin(), price_sort.end());
  cout << price_sort[0] << endl;
  }

}
  
    
      

  

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n; cin >> h >> w >> n;
	h = max(h, w);
	cout << (n + h - 1) / h << endl;
	return 0;
}


Measured memory_bytes: 256
import copy
import sys
sys.setrecursionlimit(4100000)

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

counter = 0
for i in reversed(range(n)):
    if b[i] >= a[i+1]:
        counter += a[i+1]
        b[i], a[i+1] = b[i] - a[i+1], 0
        if a[i] >= b[i]:
            counter += b[i]
            a[i] -= b[i]
        else:
            counter += a[i]
            a[i] = 0
    else:
        counter += b[i]
        a[i+1] = a[i+1] - b[i]
print(counter)

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


long long oddsolve(long long a) { return (a+1)/2 % 2; }
long long solve(long long a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}

int main() {

 
  ll A, B;
  cin >> A >> B;
  ll ans = solve(B) ^ solve(A-1);
  cout << ans << endl;
  
}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <map>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
 
int h, w, n, md;
bool g[51][51] = {};
 
void answer() {
    ll res = 0;
    ll base = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) res = (res+base) % md;
            base = 2*base % md;
        }
    }
    cout << "! " << res << endl;
}
 
using T = tuple<int, int, int, int>;
map<T, int> buf;
int que(int ax, int ay, int bx, int by) {
    bx--; by--;
    if (buf.count(T(ax, ay, bx, by))) return buf[T(ax, ay, bx, by)];
    cout << "? " << ay << " " << ax << " " << by << " " << bx << endl;
    int p;
    cin >> p;
    return buf[T(ax, ay, bx, by)] = p;
}


ll rand_int(ll l, ll r) { //[l, r]
    using D = uniform_int_distribution<ll>;
    static random_device rd;
    static mt19937 gen(rd());
    return D(l, r)(gen);
}

int dfs(int y, int l, int r, int nm = -1) {
    if (nm == -1) {
        nm = que(l, y, r, y+1);
    }
    if (nm == 0) return 0;
    if (nm == r-l) {
        for (int i = l; i < r; i++) {
            g[y][i] = true;
        }
        return nm;
    }
    int md = (l+r)/2;
    if (rand_int(0, 1)) {
        int buf = dfs(y, l, md);
        if (nm != buf) dfs(y, md, r, nm-buf);
    } else {
        int buf = dfs(y, md, r);
        if (nm != buf) dfs(y, l, md, nm-buf);
    }
    return nm;
}
 
int main() {
    ios::sync_with_stdio(0);
    cin >> h >> w >> n >> md;
    for (int i = 0; i < h; i++) {
/*        for (int j = 0; j < w; j++) {
            g[i][j] = (que(j, i, j+1, i+1) != 0);
        }*/
        dfs(i, 0, w);
    }
    answer();
    return 0;
}
 

Measured memory_bytes: 852
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n").map(n => Number(n));
    const train = input[0] < input[1] ? input[0] : input[1];
    const bus = input[2] < input[3] ? input[2] : input[3];
    console.log(train + bus);
}

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


Measured memory_bytes: 21064
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int x,y,b,p;
        cin>>x>>y>>b>>p;
        int ans = 0,cnt = 0;
        ans = b*x+p*y;
        b-=5,p-=2;
        b = max(0,b),p = max(0,p);
        cnt+=(x*5+y*2);
        ans = min(ans,(cnt + b*x+p*y)/5*4);
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
using namespace std;
int main(){
	int N;
	cin >> N;
	map<int,int> hist;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (hist.find(tmp) == hist.end()) hist[tmp] = 1;
		else hist[tmp]++;
	}
	int remove_num = 0;
	for (auto itr = hist.begin(); itr != hist.end(); itr++) {
		int tmp = itr->second - itr->first;
		if (tmp < 0) remove_num += itr->second;
		else remove_num += tmp;
	}
	cout << remove_num << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N;
    cin >> N;
    vector<ll> Ls;
    Ls.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Ls));

    sort(begin(Ls), end(Ls));
    ll ans = 0;
    for (ll i = 0; i < N - 2; ++i) {
        for (ll j = i + 1; j < N - 1; ++j) {
            auto a_plus_b = Ls[i] + Ls[j];
            auto it = lower_bound(begin(Ls) + j + 1, end(Ls), a_plus_b);
            ans += distance(begin(Ls) + j + 1, it);
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MAX_N=1000;

int h, w;
typedef pair<int, int> P;
vector<vector<char> > maze(MAX_N, vector<char>(MAX_N));
int answer = 0;

vector<vector<ll> > d(MAX_N, vector<ll>(MAX_N));
vector<vector<ll> > final(MAX_N, vector<ll>(MAX_N));

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

void bfs(){
    queue<P> que;
    // すべての点をINFで初期化
    rep(x, w)
        rep(y, h) d.at(x).at(y) = INF;
    // スタート地点をqueに入れ、その点距離を0とする
    rep(x, w) {
        rep(y, h){
            if(maze.at(x).at(y) == '#'){
                que.push(P(x,y));
                d.at(x).at(y) = 0;
            }
        }
    }

    // queが空になるまでループ
    while(que.size()){
        //　キューの先頭を取り出す
        P p = que.front();
        que.pop();
        //　４方向をループ
        rep(i, 4){
            int nx = p.first + dx.at(i), ny = p.second + dy.at(i);

            //　移動が可能かどうかの判定とすでに訪れたことがあるかどうかの判定
            if(0 <= nx && nx < w && 0 <= ny && ny < h && maze.at(nx).at(ny) != '#' && d.at(nx).at(ny) == INF){
                //　移動可能ならばキューに追加、点の距離を+1して確定させる
                que.push(P(nx,ny));
                d.at(nx).at(ny) = d.at(p.first).at(p.second) + 1;
                answer = max(answer, (int)d.at(nx).at(ny));
            }
        }
    }
    return;
}

int main(){
    //　入力に注意すること!
    //　特に座標を-1することを忘れないこと!
    cin >> h >> w;
    rep(x, w)
        rep(y, h) final.at(x).at(y) = INF;

    rep(y, h){
        rep(x, w){
            cin >> maze.at(x).at(y);
        }
    }
    //rep(y, h){rep(x, w){cout << maze.at(x).at(y);}cout << "\n";}cout << "---\n";
    bfs();
    //rep(y, h){rep(x, w){cout << d.at(x).at(y);}cout << "\n";}cout << "---\n";
    cout << answer << endl;
    //cout << maze.at(gx).at(gy) << endl;
}

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

int main(void)
{
    int A, B;
    cin >> A >> B;
    if (A * B > A + B && A * B > A - B)
    {
        cout << A * B;
    }else if (A + B > A * B && A + B > A - B)
    {
        cout << A + B;
    }
    else
    {
        cout << A - B;
    }
}


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

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n)rep(j,d) cin >> x[i][j];
    int ans = 0;
    auto judge = [&](auto a,auto b) {
        int sum = 0;
        rep(i,d) sum += (a[i]-b[i])*(a[i]-b[i]);
        bool ok = false;
        rep(i,200) if(i*i == sum) ok = true;
        return ok;
    };
    rep(i,n-1) rep2(j,i+1,n) {
        auto a = x[i];
        auto b = x[j];
        if(judge(a,b)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
P = [int(_) - 1 for _ in input().split()]
C = [int(_) for _ in input().split()]

def f(v, K):
    if K == 0:
        return 0
    if max(v) < 0:
        return max(v)

    n = len(v)
    X = [0]
    for i in range(n):
        X.append(X[-1] + v[i])

    ans = -(10 ** 10)
    for i in range(n + 1):
        for j in range(i):
            if i - j > K:
                continue
            ans = max(ans, X[i] - X[j])
    return(ans)

X = [False for _ in range(N)]
ans = -(10 ** 10)

for i in range(N):
    if X[i]:
        continue
    t = i
    v = []
    while X[t] is False:
        X[t] = True
        v.append(C[t])
        t = P[t]

    n = len(v)
    if K > n:
        s = sum(v)
        x = f(v * 2, n)
        if s > 0:
            a = s * (K // n - 1) + max(s + f(v * 2, K % n), x)
        else:
            a = x
    else:
        a = f(v * 2, K)
    ans = max(a, ans)

print(ans)


Measured memory_bytes: 74700
#ifdef CLION
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
//#define int long long

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
#define int ll
template<typename T>
using oset = tree<
        T,
        null_type,
        less<T>,
        rb_tree_tag,
        tree_order_statistics_node_update>;


#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define chkmx(a, b) (a) = max((a), (b))
#define chkmn(a, b) (a) = min((a), (b))

constexpr int MAXN = 3e3;

vector<int> g[MAXN];

int cnt = 0;
int max_deg = 0;
int k;
void dfs(int v, int p, int dep) {
    cnt++;
    if (dep == (k) / 2) return;
    for (auto u : g[v]) {
        if (u != p)
            dfs(u, v, dep + 1);
    }
}

void run() {
    int n;
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        cnt = max_deg = 0;
        if (k % 2) {
            for (int v : g[i]) {
                cnt = max_deg = 0;
                dfs(v, i, 0);
                dfs(i, v, 0);
                ans = min(ans, n - cnt - max_deg);
            }
        } else {
            dfs(i, i, 0);
        }
        ans = min(ans, n - cnt - max_deg);
    }
    cout << ans << '\n';
}


signed main() {

#ifdef CLION
    freopen("input.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    //cin >> t;
    while (t--)
        run();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	int a, b, i;
	bool f, g = false;
	while (cin >> a >> b)
	{
		if (a == 0 && b == 0) break;
		if (g) cout << endl;
		for (i = a, f = false; i <= b; i++)
		{
			if (i%4 == 0)
			{
				if (i%100 == 0 && i%400 != 0) continue;
				cout << i << endl;
				f = true;
			}
		}
		if (!f) cout << "NA" << endl;
		g = true;
	}
}

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

int main() {
    string T;
    cin >> T;
    for (int i = 0; i < T.size(); i++) {
        if (T.at(i) == '?') T.at(i) = 'D';
    }
    cout << T << endl;
    return 0;
}

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

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

#define MAX 100000

int a[MAX];


int main(){

  int n;
  int ans = 0;

  REP( i, MAX){
    a[i] = 0;
  }
  
  cin >> n;
  REP( i, n){
    cin >> a[i];
  }
  
  REP( i, n-1){
    if( a[i] == i+1){
      ++ans;
      a[i+1] = a[i];
    }
  }

  if( a[n-1] == n){
    ++ans;
  }

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


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

using vint = vector<int>;

int main(int argc, char* argv[]){
  int n; cin >> n;
  vint dams(n);
  int a = 0;
  for(int i = 0 ; i < n ; i++){
    cin >> dams[i];
    a += (dams[i]) * pow(-1, i);
  }
  cout << a << " ";
  for(int i = 0; i < n-1 ; i++){
    if(i == 0){
      cout << (dams[i] - a/2) * 2 << " ";
      dams[i] = dams[i] - a/2;
    }
    else{
      cout << (dams[i] - dams[i-1]) * 2 << " ";
      dams[i] = dams[i] - dams[i-1];
    }
  }
  cout << endl;
}


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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<< "Possible"<< endl;
	else cout<<"Impossible"<< endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w;
int fielda[80][80],fieldb[80][80];
bool memo[80][80][13000];
int MIN= 1000000000;

void search(int i,int j,int k){
  memo[i][j][k] = false;
  //cout << i << ' ' << j << ' ' << k << endl;
  int tmpk = abs(fielda[i][j]-fieldb[i][j]);
  if(i==(h-1)&&j==(w-1)){MIN = min(MIN,min(abs(k-tmpk),abs(k+tmpk)));return;} 
  int ni = i+1;
  int nj = j+1;
  //cout << memo[ni][j][k-tmpk] << endl;
  if(ni<h){
    if(memo[ni][j][abs(k-tmpk)])search(ni,j,abs(k-tmpk));
    if(memo[ni][j][k+tmpk])search(ni,j,k+tmpk);
  }
  if(nj<w){
    if(memo[i][nj][abs(k-tmpk)])search(i,nj,abs(k-tmpk));
    if(memo[i][nj][k+tmpk])search(i,nj,k+tmpk);
  }
  return;
}
    

int main(){
  cin >> h >> w;
  //int tmp;
  for(int i=0;i<h;i++){
    //vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> fielda[i][j];
      //vectmp.push_back(tmp);
    }
    //fielda.push_back(vectmp);
  }
  for(int i=0;i<h;i++){
    //vector<int> vectmp;
    for(int j=0; j<w; j++){
      cin >> fieldb[i][j];
      //vectmp.push_back(tmp);
    }
    //fieldb.push_back(vectmp);
  }
  //cout << "hoge" << endl;
  //int k=abs(fielda.at(0).at(0) - fieldb.at(0).at(0));
  memset(memo,true,sizeof(memo));
  search(0,0,0);
  cout << MIN << endl;
}
  

Measured memory_bytes: 81664
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]

ans = [0]*n
for i in range(n):
    time = 0
    for j in range(i, n-1):
        if l[j][1] - time > 0:
            time += l[j][1] - time
        if time % l[j][2] != 0:
            time += l[j][2] - time % l[j][2]
        time += l[j][0]
    ans[i] += time

for i in ans:
    print(i)


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
  char a, b;
  cin >> a >> b;

  bool c = (b == 'H') ? true : false;
  bool d = (a == 'H') ? c : !c;
  if (d) cout << 'H';
  else cout << 'D';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

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

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

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

  int dp[n];
  fill(dp, dp + n, INF_INT);
  dp[0] = b[0];
  for(int i = 1; i < n; i++){
    auto lb = upper_bound(dp, dp + n, b[i]);
    *lb = b[i];
  }

  int ans = 1;
  for(int i = 0; i < n; i++){
    if(dp[i] != INF_INT) ans = i + 1;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
   int N, sum=0;
   cin >> N;
   vector<int> v(N);
   for(int i=0; i<N; i++) cin >> v[i];

   for(int i=0; i<N; i++) {
      for(int j=i+1; j<N; j++) {
         sum += v[i] * v[j];
      }
   }
   cout << sum << endl;
}

Measured memory_bytes: 3580
# SPDX-License-Identifier: X11
# 2020-09-17
# Alter Altar (400pt)

function _main()
  N = parse(Int, readline())
  C = Vector{Char}(undef, 0)
  W, R = 0, 0

  for i ∈ 1:N
    c = read(stdin, Char)
    c == 'R' && (R += 1)
    push!(C, c)
  end

  ans = R
  for c ∈ C
    c == 'R' ? R -= 1 : W += 1
    ans = min(ans, max(W,R))
  end

  println(ans)
end

_main()


Measured memory_bytes: 160724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        a[i + 1] += a[i];
    }
    sort(a.begin(), a.end());

    ll r = 0, b = 1LL << 60, k = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] != b) {
            r += k * (k - 1) / 2;
            b = a[i];
            k = 1;
        } else {
            k++;
        }
    }
    r += k * (k - 1) / 2;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1792
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = 0
    for k, v in digits.items():
        oore += (v % 2) << k

    nums = [0] * N

    for i, a in enumerate(As):
        nums[i] = a ^ oore

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 31444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String T = Console.ReadLine();
            int ans = 0;

            for (int i = 0; i < 3; i++)
            {
                if (S[i] == T[i])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>

int search(int,int);
#define N 1000001
int num_1[N];
int num_2[N];

int main(){

  int n,q;
  int i,j;
  int right,sum=0;

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

  scanf("%d",&q);
  
  for(j=0;j<q;j++){   
    scanf("%d",&num_2[j]);
  }
  right=i;
  
  for(j=0;j<q;j++){
    sum+=search(j,right);
      }

  printf("%d\n",sum);

  return 0;
}

int search(int j,int right){
  
  int i=0;
  int left=0,mid;

  while(left<right){   
    mid=(left+right)/2;
    if(num_1[mid]==num_2[j]){
      return 1;
    }
    else if(num_2[j]<num_1[mid]){
      right=mid;
    }

    else{
      left=mid+1;
    }


  
  }

  return 0;
}
    

Measured memory_bytes: 5088
using System;
using System.Linq;
class program{
  static void Main(){
    int k = int.Parse(Console.ReadLine());
    string s = Console.ReadLine();
    string a = "";
    int len = s.Length;
    if(k>=len){
      Console.Write(s);
    }else{
      for(int i = 0;i<k;i++){
        a += s[i];
      }
      a += "...";
      Console.Write(a);  
    }
  }
}

Measured memory_bytes: 27376
#include<stdio.h>
#define N 1200

int main(){
  char str[1200];
  int i;
  int count=0;
  
  for(i=0; i<N;i++){
    scanf("%c",&str[i]);
    if(str[i]=='\n'){
      break;
    }
    count++;
  }
  
  for(i=0;i<count;i++){
    if('a'<=str[i] && str[i] <='z'){
      str[i]=str[i]+('A'-'a');  
    }else if('A'<=str[i] && str[i] <='Z'){
      str[i]=str[i]+('a'-'A');
    }
  }
    
  for(i=0;i<count;i++){
    printf("%c",str[i]);  
  }
  printf("\n");
  
  return 0;
}

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

string str[100];

int main()
{
  int n, l;
  cin >> n >> l;
  
  for(int i = 0; i < n; i++)
    cin >> str[i];
  
  sort(str, str+n);
  
  for(int i = 0; i < n; i++)
    cout << str[i];

  return 0;
}

Measured memory_bytes: 256
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right


def main():
    N = int(input())
    if N == 1:
        print('Yes')
        print(2)
        print(1, 1)
        print(1, 1)
        exit()
    i = 3
    l = 2
    while i <= 10**5:
        if i == N:
            break
        else:
            l += 1
            i += l
    else:
        print('No')
        exit()

    # 長さl, k = 2N/l個の配列が答え
    ans = [[1, 2], [2, 3], [3, 1]]
    now = 3  # 今使ってる最大の数字
    M = 2  # 今の長さ
    k = 2 * N // l
    while M < l:
        for j in range(M + 1):
            ans[j].append(now + 1 + j)
        ans.append(list(range(now + 1, now + 2 + M)))
        now += M + 1
        M += 1
    print('Yes')
    print(k)
    for i in range(k):
        print(l, *ans[i])


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p.at(i);
  int cnt = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) {
      cnt++;
      continue;
    }
    if (p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

def main():
    n = int(sys.stdin.readline().strip())
    p = [int(i) for i in sys.stdin.readline().strip().split()]
    ret = 0
    for i in range(n - 2):
        s = p[i:i+3]
        ss = sorted(s)
        if ss[1] == s[1]:
            ret += 1
    return ret
    
print(main())

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int n;
double p[3010];
double f[3010][3010];	//f[i][j]表示前i个硬币中有j次正面朝上的概率 
double ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&p[i]);
	}
	f[0][0]=1.0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i+1][j+1]=f[i][j]*p[i+1];
			f[i+1][j]=f[i][j]*(1.0-p[i+1])+f[i][j-1]*p[i+1];	//出锅 
		}
	}
	for(int i=(n+1)/2;i<=n;i++)
	{
		ans+=f[n][i];
	}
	printf("%.10lf",ans);
	return 0;
}








Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++) L[i] = L[i - 2] + L[i - 1];
  cout << L[N];
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var n1 = n.Replace("1", "a");
            var n2 = n1.Replace("9", "1");
            var n3 = n2.Replace("a", "9");
            Console.WriteLine(n3);
        }
    }
}

Measured memory_bytes: 13140
#D

n,w= map(int, input().split())

wlist = []
vlist = []
for i in range(n):
    wk,vk=map(int,input().split())
    wlist.append(wk)
    vlist.append(vk)

dp=[]
for i in range(n+1):
    dp.append([0]*(w+1))


for i in range(1,n+1):
    #このループの中で、wlist[i-1],vlist[i-1]の品物を入れるか判断する
    for j in range(w+1):
        #このループの中で,dp[i][j]の更新を考える
        if j-wlist[i-1] >=0:
            #dp[i-1][j] と dp[i-1][j]+vlist[i-1]のうち大きい方
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wlist[i-1]]+vlist[i-1])
        else:
            dp[i][j] = dp[i-1][j]
#        print(dp)
print(dp[n][w])

Measured memory_bytes: 120556
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val Array(a, b) = readLine().split(" ").map(_.toInt)
    println(if (a >= 13) b
    else if (a >= 6 && a <= 12) b / 2
    else 0)

  }

}

Measured memory_bytes: 25420
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
vector<int> g[212345];
int dp[3][212345];

int main() {
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	fill(dp[0], dp[3], INF);
	dp[0][0] = 1;
	
	REP(i, 2) {
		REP(j, N) if (dp[i][j] != INF) {
			REP(k, g[j].size()) {
				dp[i + 1][g[j][k]] = 1;
			}
		}
	}
	
	puts(dp[2][N - 1] == 1 ? "POSSIBLE" : "IMPOSSIBLE");
	
	return 0;
}


Measured memory_bytes: 14704
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
    
    char s[200000];
    int n;
    int b[200000]={},w[200000]={};
    cin>>n>>s;
    
    int i,cnt=0;
    for(i=0;i<n;i++){
        if(s[i]=='#'){
            cnt++;
        }
        b[i]=cnt;
    }
    cnt=0;
    for(i=n-1;i>=0;i--){
        if(s[i]=='.'){
            cnt++;
        }
        w[i]=cnt;
    }
    int ans=200000;
    int tmp;
    for(i=0;i<n;i++){
        tmp=b[i]+w[i]-1;
        if(tmp<ans){
            ans=tmp;
        }
    }
    cout<<ans<<endl;
    
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);

//int dxy[5] = {0, 1, 0, -1, 0};
int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[8] = {1, 0, -1, 1, -1, 1, 0, -1};
// assign

string comp(string a, string b);

signed main()
{
    int n, m;
    while (cin >> n >> m, n) {
        vector<string> donut(n);
        rep(i, n) {
            cin >> donut[i];
        }
        set<string> can;
        string ans = "z";
        rep(i, n) {
            rep(j, m) {
                rep(k, 8) {
                    vvb used(n, vb(m, false));
                    string spell;
                    int x = i, y = j;
                    while (!used[x][y]) {
                        spell.pb(donut[x][y]);
                        used[x][y] = true;
                        if (can.find(spell) != can.end()) {
                            ans = comp(ans, spell);
                        } else {
                            can.insert(spell);
                        }
                        x = (x + dx[k] + n) % n; y = (y + dy[k] + m) % m;
                    }
                }
            }
        }
        cout << ((ans.length() > 1) ? ans : "0") << endl;
    }
    return 0;
}

string comp(string a, string b)
{
    if (a.length() < b.length()) {
        return b;
    } else if (a.length() > b.length()) {
        return a;
    } else {
        rep(i, a.length()) {
            if (a[i] < b[i]) {
                return a;
            } else if (a[i] > b[i]) {
                return b;
            }
        }
    }
    return a;
}

Measured memory_bytes: 35676
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100

int n,cnt;
int dist[MAXN+3];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&dist[i]);
	sort(dist+1,dist+n+1);
	int last=dist[1];
	for(int i=2;i<=n;i++)
		if(dist[i]>last+1) {
			printf("Impossible\n");return 0;
		}
		else last=dist[i];
	int up=(dist[n]+1)/2;
	for(cnt=1;dist[cnt+1]==dist[cnt];cnt++);
	if((cnt==1&&dist[n]!=2*dist[1])||(cnt==2&&dist[n]!=2*dist[1]-1)||cnt>2) {
		printf("Impossible\n");return 0;
	}
	if(up<dist[1]) {
		printf("Impossible\n");return 0;
	}
	if(dist[n]!=dist[n-1]) {
		printf("Impossible\n");return 0;
	}
	printf("Possible\n");
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = 1e8;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<int> a(m), b(m), c(m);
	vector<vector<int> > dist(n + 1, vector<int>(n + 1, inf));
	for(int i = 1; i <= n; i++){
		dist[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		cin>>a[i]>>b[i]>>c[i];
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < m; i++){
		bool flg = false;
		for(int u = 1; u <= n; u++){
			for(int v = 1; v <= n; v++){
				if(dist[u][a[i]] + c[i] +  dist[b[i]][v] == dist[u][v]){
					flg = true;
					break;
				}
			}
			if(flg)break;
		}
		if(!flg)ans++;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <cmath>
#include<string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int k;
    int s;
    cin >> k;
    cin >> s;
    int count = 0;
    for (int x=0;x<=k;x++) {
        for (int y=0;y<=k;y++) {
            if((s-x-y <= k) && (s-x-y >= 0)){
                count++;
            }
        }
    }
    cout << count << endl;
}

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

using namespace std;


/*void print_list(const vector<vector<int> >& v_list)
{
	for (vector<vector<int> >::const_iterator p = v_list.begin(); p != v_list.end(); ++p) {
		for (vector<int>::const_iterator q = p->begin(); q != p->end(); ++q)
			cout << *q << " ";
		cout << endl;
	}
}*/


int dpcalc(int hp,int N, vector<vector<int> >magic, vector<int> dp) {
	int min=100000001;
	dp[0] = 0;
	sort(magic.begin(), magic.end());
	for (int i = 1; i < magic.at(0).at(0); i++)
		dp[i] = 100000001;
	//print_list(magic);
	for (int i = magic.at(0).at(0); i < hp + 10000; i++,min=100000001) {
		for (int j = 0; j < N; j++) {
			if (i - magic.at(j).at(0) >= 0) {
				if (min > dp[i-magic.at(j).at(0)] + magic.at(j).at(1)) {
					//cout << "proc" << endl;
					min = dp[i-magic.at(j).at(0)] + magic.at(j).at(1);
					//{ { { { {cout << "dp[" << i << "]=" << min << "" << endl; }}}}}
				}
			}
			else { break; }
		}
		dp[i] = min;
		//{ { { { {cout << "dp["<<i<<"]="<<min<<"" << endl; }}}}}
	}
	sort(dp.begin() + hp, dp.end());
	return dp[hp];
}

int main(void) {
	int hp,N,ans;
	cin >> hp;
	cin >> N;
	vector< vector<int> > magic(N,vector<int>(2));//0:atk,1:mp
	vector<int> dp(hp + 10000,0);
	for (int i = 0; i < N; i++) {
		cin >> magic.at(i).at(0);
		cin >> magic.at(i).at(1);
	}
	ans = dpcalc(hp,N,magic,dp);
	cout << ans << endl;
	return 0;
}

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

#define TRUE 1
#define FALSE 0

bool maxor(int x, int y, int z)
{
	return (x < y) ? ((y < z) ? TRUE : FALSE) : FALSE;
}

int main()
{
	int x = 0, y = 0, z = 0;
	cin >> x >> y >> z;
	if (maxor(x, y, z)){
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 1124
package main

import (
	"fmt"
)

type Node int

type UnionFindTree struct {
	parent []Node
	rank   []Node
}

func NewUnionFindTree(order int) *UnionFindTree {
	uf := &UnionFindTree{
		parent: make([]Node, order),
		rank:   make([]Node, order),
	}
	for i := range uf.parent {
		uf.parent[i] = Node(i)
	}
	return uf
}

func (uf *UnionFindTree) Unite(x Node, y Node) {
	xParent := uf.Find(x)
	yParent := uf.Find(y)
	if xParent == yParent {
		return
	}

	if uf.rank[xParent] < uf.rank[yParent] {
		uf.parent[xParent] = yParent
	} else {
		uf.parent[yParent] = xParent

		if uf.rank[xParent] == uf.rank[yParent] {
			uf.rank[xParent]++
		}
	}
}

func (uf *UnionFindTree) Find(node Node) Node {
	if uf.parent[node] != node {
		uf.parent[node] = uf.Find(uf.parent[node])
	}
	return uf.parent[node]
}

func (uf *UnionFindTree) Same(x Node, y Node) bool {
	return uf.Find(x) == uf.Find(y)
}

func main() {
	var n, q int
	fmt.Scanf("%d %d", &n, &q)
	uf := NewUnionFindTree(n)
	for i := 0; i < q; i++ {
		var com int
		var x, y Node
		fmt.Scanf("%d %d %d", &com, &x, &y)
		switch com {
		case 0: // unite
			uf.Unite(x, y)
		case 1: // same
			if uf.Same(x, y) {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		}
	}
}



Measured memory_bytes: 5896
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    while(n!=0){
        int i;
        double s[1000]={},sum=0,a=0;
        for(i=0;i<n;i++){
            cin >>s[i];
            sum+=s[i];
        }
        for(i=0;i<n;i++){
            a+=(s[i]-(sum/n))*(s[i]-(sum/n))/n;
        }
        printf("%.5f\n",sqrt(a));
        cin >>n;
    }
    return 0;
    
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sx = in.nextInt();
		int sy = in.nextInt();
		int tx = in.nextInt();
		int ty = in.nextInt();
		in.close();
		int X = tx - sx;
		int Y = ty - sy;
		StringBuilder sb = new StringBuilder();

		//一回目のs→t
		for (int i = 0; i < Y; i++) {
			sb.append('U');
		}
		for (int i = 0; i < X; i++) {
			sb.append('R');
		}
		//一回目のt→s
		for (int i = 0; i < Y; i++) {
			sb.append('D');
		}
		for (int i = 0; i < X; i++) {
			sb.append('L');
		}

		//2回目のs→t
		sb.append('L');
		for (int i = 0; i < Y + 1; i++) {
			sb.append('U');
		}
		for (int i = 0; i < X + 1; i++) {
			sb.append('R');
		}
		sb.append('D');
		//2回目のt→s
		sb.append('R');
		for (int i = 0; i < Y + 1; i++) {
			sb.append('D');
		}
		for (int i = 0; i < X + 1; i++) {
			sb.append('L');
		}
		sb.append('U');

		System.out.println(sb);
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
int countDistinct(int arr[], int n) 
{ 
    // First sort the array so that all 
    // occurrences become consecutive 
    sort(arr, arr + n); 
  
    // Traverse the sorted array 
    int res = 0; 
    for (int i = 0; i < n; i++) { 
  
        // Move the index ahead while 
        // there are duplicates 
        while (i < n - 1 && arr[i] == arr[i + 1]) 
            i++; 
  
        res++; 
    } 
  
    return res; 
} 
//--main function
int main(){
	int n;
	cin>>n;
	int a[n];
	REP(i,0,n-1)cin>>a[i];
	cout<<countDistinct(a,n); 
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256