akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    int n, d;
    cin >> n >> d;
    vector<double> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    int ans=0;
    rep(i, n){
        double dis = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(dis<=d) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int r;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    double ans = 0;
    cin>>r;

    ans = 2.0*r*M_PI;

    cout << std::setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = -1;
    if((a < 10) && (b < 10)) ans = (a * b);
    System.out.println(ans);
  }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dy = ty - sy;
	int dx = tx - sx;

	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
	cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
	cout << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int passc[n];
  bool result=true;
  for(int i=0; i<=n-1; i++){
    cin>>passc[i];
    if(passc[i]%2==0){
      if(passc[i]%3!=0&&passc[i]%5!=0){
        result=false;
        break;
      }
      if(!result){
        break;
      }
    }
  }
  if(result){
    cout<<"APPROVED";
  }else{
    cout<<"DENIED";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s;
    scanf("%c",&s);
    if(s=='A')
    {
        printf("T");
    }
    else if(s=='G')
    {
        printf("C");
    }
    else if(s=='C')
    {
        printf("G");
    }
    else if(s=='T')
    {
        printf("A");
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    int dist_a = abs(a-x);
    int dist_b = abs(b-x);

    cout << (dist_a < dist_b ? 'A':'B') << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true) {
        val (m, f, r) = readLine()!!.split(" ").map(String::toInt)

        if (m == -1 && f == -1 && r == -1) break

        val rank = when {
            m == -1 || f == -1 -> "F"
            m + f >= 80 -> "A"
            m + f >= 65 -> "B"
            m + f >= 50 -> "C"
            m + f >= 30 && r >= 50 -> "C"
            m + f >= 30 && r < 50 -> "D"
            else -> "F"
        }

        println(rank)
    }
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER\n";
	}
	else if (a.size() < b.size()) {
		cout << "LESS\n";
	}
	else if(a == b){
		cout << "EQUAL\n";
	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER\n";
				return;
			}
			else if (a[i] < b[i]) {
				cout << "LESS\n";
				return;
			}
		}
	}
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

ll A, B;
int C, D;

template<typename Tint>
Tint gcd(Tint a, Tint b) {
	// O(log max(a,b))
	a = abs(a);
	b = abs(b);
	return b != 0 ? gcd(b, a % b) : a;
}

ll lcm(int a, int b) {
	return (ll)(a / gcd(a, b)) * b;
}

int main() {
	cin >> A >> B >> C >> D;
	ll nc, nd, nl;
	ll l = lcm(C, D);
	nc = B / C - (A - 1) / C;
	nd = B / D - (A - 1) / D;
	nl = B / l - (A - 1) / l;
	ll ans = B - (A - 1) - (nc + nd - nl);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val fiveHandledYenCnt = readLine()!!.toInt()
    val handledYenCnt = readLine()!!.toInt()
    val fiftyYenCnt = readLine()!!.toInt()
    val amount = readLine()!!.toInt()

    var answer = 0
    for (fh in 0..fiveHandledYenCnt) {
        var fhAmount = fh * 500
        if (fhAmount == amount) {
            answer += 1
            break
        }
        if (fhAmount > amount) {
            break
        }
        for(h in 0..handledYenCnt) {
            var hAmount = h * 100
            if (fhAmount + hAmount == amount) {
                answer += 1
                break
            }
            if (fhAmount + hAmount > amount) {
                break
            }
            for (f in 0..fiftyYenCnt) {
                var fAmount = f * 50
                if (fhAmount + hAmount + fAmount == amount) {
                    answer += 1
                    break
                }
            }
        }
    }
    print(answer)
}

Measured memory_bytes: 33572
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int fa[maxn], p[maxn];
int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]);}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &p[i]), fa[i] = i;
	int u, v;
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d%d", &u, &v);
		u = getfa(u), v = getfa(v);
		if(u == v) continue;
		fa[u] = v;
	}
	int cnt = 0;
	for(int i = 1; i <= n; ++i)
		cnt += getfa(i) == getfa(p[i]);
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
	int m, n, i, j;
	while(~scanf("%d %d", &m, &n)) {
		for(i = 1, j = 1; j <= m; j++){
			if(i * 2 < i + n) i = i * 2;
			else i = i + n;
		}
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
struct st {
    double a, b;
    bool operator<(const st& s) { return a < s.a; }
};
ll n;
vector<st> v;
template <typename T>
struct BinaryIndexedTree {
    vector<T> dat;
    size_t n;
    int h;
    BinaryIndexedTree(size_t n) : n(n) {
        h = 1;
        while(h <= n) {
            h <<= 1;
        }
        h >>= 1;
        dat.assign(++n, 0);
    }
    void add(int k, T x) {
        for(++k; k < n; k += k & -k) {
            dat[k] += x;
        }
    }
    T sum(int k) {
        T res = 0;
        for(++k; k > 0; k -= k & -k) {
            res += dat[k];
        }
        return res;
    }
};
bool check(double s, ll lb) {
    vector<pair<double, int>> v2;
    for(int i = 0; i < n; i++) {
        v2.push_back(make_pair(s * v[i].a + v[i].b, i));
    }
    sort(all(v2));
    BinaryIndexedTree<ll> bit(n + 5);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        int id = v2[i].second;
        sum += bit.sum(n) - bit.sum(id);
        bit.add(id, 1);
    }
    return lb <= sum;
}
double solve() {
    double ng = -INF, ok = INF;
    int co = 100;
    ll t = n * (n - 1LL) / 2LL;
    while(co--) {
        double mid = (ok + ng) / 2;
        if(check(mid, t / 2 + t % 2)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}
int main() {
    /*  cin.tie(0);
     ios::sync_with_stdio(false);*/
    cin >> n;
    v.resize(n);
    vector<double> a(n), b(n), c(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        v[i].a = -a[i] / b[i];
        v[i].b = c[i] / b[i];
    }
    sort(all(v));
    reverse(all(v));
    double x = solve();
    for(int i = 0; i < n; i++) {
        v[i].a = b[i] / a[i];
        v[i].b = -c[i] / a[i];
    }
    sort(all(v));
    reverse(all(v));
    double y = solve();
    printf("%.11lf %.11lf\n", x, y);
}


Measured memory_bytes: 3528
S=input()
A=[0]*(len(S)+1)
for i in range(len(S)):
    if S[i]=="<":
        A[i+1]+=A[i]+1
for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        A[i]=max(A[i],A[i+1]+1)
print(sum(A))

Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll s; cin >> s;
    ll ans = 0;

    if(s<600){
        cout << 8 << endl;
    }else if(s>=600 && s<800){
        cout << 7 << endl;
    }else if(s>=700 && s<1000){
        cout << 6 << endl;
    }else if(s>=1000 && s<1200){
        cout << 5 << endl;
    }else if(s>=1200 && s<1400){
        cout << 4 << endl;
    }else if(s>=1400 && s<1600){
        cout << 3 << endl;
    }else if(s>=1600 && s<1800){
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
var
  a,b,i:longint;
  s:string;
begin
  readln(a,b);
  readln(s);
  if s[a+1]<>'-' then begin writeln('No');halt; end;
  delete(s,a+1,1);
  for i:=1 to a+b do
   if s[i]='-' then begin writeln('No');halt; end;
  writeln('Yes');
end.

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    string s,t;
    cin>>s>>t;
    int ans = 0;
    for (int i = 0; i < 3; i++) if (s[i] == t[i]) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main()
{
	int N, sum, dig;
	scanf("%d", &N);
	int num = N;
	while (num) {
		dig = num % 10;
		sum += dig;
		num = num / 10; 
	}
	if (N % sum == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main() {
    lint n, k, c;
    cin >> n >> k >> c;

    string s;
    cin >> s;

    vector<lint> left;
    for(lint i=0; i<n; i++) {
        if(left.size() >= k) break;
        if(s[i] == 'x') continue;
        left.push_back(i);
        i+=c;
    }

    vector<lint> right;
    for(lint i=n-1; i>=0; i--) {
        if(right.size() >= k) break;
        if(s[i] == 'x') continue;
        right.push_back(i);
        i-=c;
    }
    reverse(right.begin(), right.end());

    for(lint i=0; i<left.size(); i++) {
        if(left[i] == right[i]) cout << left[i]+1 << endl;
    }
}

Measured memory_bytes: 5108
from collections import deque
h,w = map(int, input().split())
c = tuple(map(int, input().split()))
d = tuple(map(int, input().split()))
m = ['#' for _ in range(h+2)]
m[0] += '#'*w
m[h+1] += '#'*w
que = deque()
que.append(c)
warp = [[10**12 for _ in range(w+1)] for _ in range(h+1)]
for i in range(1,h+1):  m[i] += input()+'#'
up = lambda x,y: 1 if 0<x-1 and m[x-1][y]=='.' else 0
down = lambda x,y: 1 if x+1<=h and m[x+1][y]=='.' else 0
right = lambda x,y: 1 if y+1<=w and m[x][y+1]=='.' else 0
left = lambda x,y: 1 if 0<y-1 and m[x][y-1]=='.' else 0

def jump(x,y,cost):
  deq = deque()
  for i in range(x-2,x+3):
    if i<=0 or h<i:  continue
    for j in range(y-2,y+3):
      if j<=0 or w<j:  continue
      if m[i][j] == '.' and warp[i][j]==10**12:
        warp[i][j] = cost+1
        deq.append((i,j))
  return deq
  
warp[c[0]][c[1]] = 0
while que:
  q = que.popleft()
  row = q[0]
  col = q[1]
  cost = warp[row][col]
  if up(row,col) and warp[row-1][col]>cost:
    que.appendleft((row-1,col))
    warp[row-1][col] = cost
  if down(row,col) and warp[row+1][col]>cost:
    que.appendleft((row+1,col))
    warp[row+1][col] = cost
  if right(row,col) and warp[row][col+1]>cost:
    que.appendleft((row,col+1))
    warp[row][col+1] = cost
  if left(row,col) and warp[row][col-1]>cost:
    que.appendleft((row,col-1))
    warp[row][col-1] = cost
  que.extend(jump(row,col,cost))

if warp[d[0]][d[1]] != 10**12:  print(warp[d[0]][d[1]])
else:  print(-1)

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

#define int long long
#define pii pair<int, int>
#define pb push_back
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N, R;
    cin >> N >> R;
    cout << R + 100 * (max(0ll, 10 - N));
    
    return 0;
}

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

int main(){
	int a,b,m;
	cin >> a >> b >> m;
	vector<int> r(a);
	vector<int> d(b);
	for(int i=0;i<a;i++){
		cin >> r.at(i);
	}
	for(int i=0;i<b;i++){
		cin >> d.at(i);
	}
	int rm = r.at(0);
	for(int i=1;i<a;i++){
		if(rm > r.at(i)){
			rm = r.at(i);
		}
	}
	int dm = d.at(0);
	for(int i=1;i<b;i++){
		if(dm > d.at(i)){
			dm = d.at(i);
		}
	}
	int min = rm+dm;
	for(int i=0;i<m;i++){
		int x,y,c;
		cin >>x >> y >> c;
		if(min > r.at(x-1) + d.at(y-1) - c){
			min = r.at(x-1) + d.at(y-1) - c;
		}
	}
	cout << min << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int find(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int N;
  cin >> N;
  int res=20000000;
  rep(i,N/2){
    if(res>find(i+1)+find(N-i-1)){res=find(i+1)+find(N-i-1);}
  }
  cout << res << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll mod = 1e9 + 7;
const ld eps = 1e-9;

int dp[110][110][400];
int v[110];
int w[110];

int main() {
	int n, W;	cin >> n >> W;
	rep(i, n)	cin >> w[i] >> v[i];
	rep(i, n){
		if (w[i] <= W)	dp[i + 1][1][w[i] - w[0]] = v[i];
		REP(j, i)	rep(k, 400) {
			if (dp[i][j][k] == 0)	continue;
			dp[i + 1][j][k] = max(dp[i][j][k], dp[i + 1][j][k]);
			if (k + w[i] + j*w[0] <= W) {
				dp[i + 1][j + 1][k + w[i] - w[0]] = max(dp[i + 1][j + 1][k + w[i] - w[0]], dp[i][j][k] + v[i]);
			}
		}
	}
	int ret = 0;
	REP(i, n)	REP(j, n)	rep(k, 400)	ret = max(ret, dp[i][j][k]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    
    int l,r;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>l>>r;
        sum += r-l+1;
    }
    
    cout<< sum <<endl;
}


Measured memory_bytes: 256
// 2011/08/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int te[5];
		cin >> te[0];
		if(te[0]==0)
			break;
		for(int i=1; i<5; i++)
			cin >> te[i];

		int gu = 0;
		int ch = 0;
		int pa = 0;
		for(int i=0; i<5; i++)
			if(te[i]==1)
				gu++;
			else if(te[i]==2)
				ch++;
			else
				pa++;

		if(gu==5||ch==5||pa==5||gu*ch*pa!=0)
			for(int i=0; i<5; i++)
				cout << 3 << endl;
		else if(gu==0)
			for(int i=0; i<5; i++)
				if(te[i]==2)
					cout << 1 << endl;
				else
					cout << 2 << endl;
		else if(ch==0)
			for(int i=0; i<5; i++)
				if(te[i]==3)
					cout << 1 << endl;
				else
					cout << 2 << endl;
		else
			for(int i=0; i<5; i++)
				if(te[i]==1)
					cout << 1 << endl;
				else
					cout << 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=ja
# 最長共通部分文字列
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

# dp[i][j] := Sのi番目までとTのj番目までのLCS
# アルゴリズム的には正しいがTLE
def LCS(S, T):
    n = len(S)
    m = len(T)

    dp = [[0] * (m+1) for _ in range(n+1)]

    for i in range(n):
        S_i = S[i]
        for j in range(m):
            if S_i == T[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    
    return dp[n][m]


def LCS2(S, T):
    L = []
    for t in T:
        t_idx = 0  # 検索開始位置
        for i, cur_idx in enumerate(L):
            chr_idx = S.find(t, t_idx) + 1
            if not chr_idx:
                break
            L[i] = min(cur_idx, chr_idx)
            t_idx = cur_idx
        else:
            chr_idx = S.find(t, t_idx) + 1
            if chr_idx:
                L.append(chr_idx)
    
    return len(L)


def main():
    q = int(readline())
    xy = read().split()

    ans = []
    for X, Y in zip(*[iter(xy)]*2):
        ans.append(LCS2(X, Y))

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


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

using i64 = int64_t;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    int ans = 0;
    for(int i=0;i<=min(n, k);++i){
        for(int j=0;j<=i;++j){
            vector<int> v2;
            int sum = 0;
            for(int l=0;l<j;++l){
                //cerr << l << endl;
                v2.push_back(v[l]);
                sum += v[l];
            }
            for(int l=n-1;l>=n-(i-j);--l){
                //cerr << l << endl;
                v2.push_back(v[l]);
                sum += v[l];
            }
            sort(v2.begin(), v2.end());
            for(int l=0;l<min(k-i,i);++l){
                if(v2[l] < 0)sum -= v2[l];
                else break;
            }
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		scanner.close();
		
		System.out.println(a * b);
		
	}

}


Measured memory_bytes: 27080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.min(a * n, b));
		sc.close();
	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int X, Y;
  cin>>X>>Y;
  cout<<X+Y/2<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      int youso1[] = new int[N];
      //int youso2[] = new int[N];
      
      //数列作成
      for(int i=0; i<N; i++){
        	youso1[i] = sc.nextInt();
      }
      //数列のコピーを作成
      int[] youso2 = youso1.clone();
      
      //昇順に並び替え 
      Arrays.sort(youso2);
      
      /*昇順にした数列の最後は最大値であるため
      元の数列で比較し昇順の数列で出力する*/
      for(int i=0; i<N; i++){
      		if(youso1[i] < youso2[N-1]){
              	System.out.println(youso2[N-1]);
            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2[N-2]);
            }
      }
    }
}

Measured memory_bytes: 62964
#include <stdio.h>

int main(int argc,char* argv[]) {
	char searchfor[11];
	int ringnum;
	int i;
	int count;
	char ring[11];
	char ringbuf[21];
	scanf("%s",searchfor);
	scanf("%d",&ringnum);
	count=0;
	for(i=0;i<ringnum;i++) {
		scanf("%s",ring);
		strcpy(ringbuf,ring);
		strcat(ringbuf,ring);
		if(strstr(ringbuf,searchfor))count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/
vector<vector<string>> v(27);

vector<pair<int, int>> vp;
int main(void)
{
    int N;
    cin >> N;
    vector<int> ans;
    int maxn = 1;
    while (maxn * (maxn + 1) / 2 < N)
        maxn++;
    for (int i = 1; i <= maxn; ++i)
    {
        if (i != (maxn + 1) * maxn / 2 - N)
            printf("%d\n", i);
    }
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL l, n, x[200002], d[200001], s[200002];

LL ID(int l, int r) { return s[r] - s[l]; }
LL CD(int l, int r) { return s[r] - s[l + 1]; }

int main() {
	cin >> l >> n;
	
	x[0] = 0;
	inc1(i, n) { cin >> x[i]; }
	x[n + 1] = l;
	
	n++;
	inc(i, n) { d[i] = x[i + 1] - x[i]; }
	inc(i, n) { s[i + 1] = s[i] + d[i]; }
	
	LL ans = 0, sum = 0;
	inc(i, n) {
		if(i == 0) {
			sum = 0;
		} else {
			if(2 * i - 1 < n) {
				int x = i - 1, y = 2 * i - 1;
				sum +=  2 * ID(0, x);
				sum += -2 * CD(x, y);
				sum +=  2 * CD(y, n);
				sum +=  d[x];
			} else {
				int x = 2 * i - 1 - n, y = i - 1;
				sum += -2 * ID(0, x);
				sum +=  2 * CD(x, y);
				sum += -2 * CD(y, n);
				sum +=  d[y];
			}
		}
		setmax(ans, sum);
	}
	inc(i, n) {
		if(i == 0) {
			sum = ID(1, n);
		} else {
			if(2 * i < n) {
				int x = i, y = 2 * i;
				sum +=  2 * ID(0, x);
				sum += -2 * CD(x, y);
				sum +=  2 * CD(y, n);
				sum += -d[x];
			} else {
				int x = 2 * i - n, y = i;
				sum += -2 * ID(0, x);
				sum +=  2 * CD(x, y);
				sum += -2 * CD(y, n);
				sum += -d[y];
			}
		}
		setmax(ans, sum);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4992
import sys

s = sorted(input())
t = sorted(input(), reverse=True)

for c_s, c_t in zip(s, t):
    if c_s < c_t:
        print('Yes')
        sys.exit()
    elif c_s > c_t:
        print('No')
        sys.exit()

if len(s) < len(t):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
        #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 FORR(i, m, n) for(int i = m;i >= n;i--)
        #define SORT(v, n) sort(v, v+n);
        #define VSORT(v) sort(v.begin(), v.end());
        #define llong long long
        #define pb(a) push_back(a)
        #define INF 1000000000000000000LL
        #define MOD 1000000007
        using namespace std;
        typedef pair<int, int> P;
        typedef pair<llong, llong> LP;
        typedef pair<int, P> PP;
        typedef pair<llong, LP> LPP;
        //vector<tuple<long long, long long, long long>>vec;

        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 dy[]={0, 0, 1, -1, 0};
        int dx[]={1, -1, 0, 0, 0};

            llong gcd(llong a, llong b)
            {
                    return b != 0 ? gcd(b, a % b) : a;
            }
            llong lcm(llong a, llong b)
            {
             llong g=gcd(a,b);
             return a/g*b;
            }

        int main()
        {
            int n;
            cin>>n;
            vector<llong> T(n,0);
            REP(i,n) cin>>T[i];
            sort(T.begin(),T.end());
            llong ans=T[0];
            for(int i=0; i<n-1; i++)
            {
                llong cnt=lcm(T[i],T[i+1]);
                ans=lcm(ans,cnt);
            }
            cout<<ans<<endl;
        }

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

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin>>n;
  string s; cin>>s;
  int cnt=0;
  for (int i=2; i<n; ++i) {
    if (s[i]=='C' && s[i-1]=='B' && s[i-2]=='A') ++cnt;
  }
  cout<<cnt;
  return 0;
}

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

int main() {

      ll n;
      cin>>n;
      ll a[n];
      ll mx = -1;
      for(int i=0; i<n; i++) {
            cin>>a[i];
            mx = max(mx, a[i]);
      }
      sort(a, a+n);
      ll s = 0;
      for(int i=0; i<n-1; i++) {
        s += a[i];
      }
      ///cout<<"mx = "<<mx<<" " <<"s = "<<s<<endl;
      if(mx < s) cout<<"Yes";
      else cout<<"No";

}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> S, P;
    int64_t sum = 0;
    int64_t sump = 0;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        sum += t;
        if (t > 0) {
            sump += t;
        }
        S.push_back(sum);
        P.push_back(sump);
    }

    int64_t m = 0;

    for (int64_t i = 0; i <= N-K; ++i) {
        auto pre = i >= 1 ? P[i-1] : 0;
        auto post = P[N-1] - P[i+K-1];

        auto b = i >= 1 ? S[i+K-1] - S[i-1] : S[K-1];
        m = std::max(m, pre+b+post);
        m = std::max(m, pre+post);
    }
    std::cout << m << std::endl;

    return 0;
}


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

int main(){
	int stack[10];
	int s_num = 0;
	int x;

	while(cin >> x){
		if(x == 0){
			cout << stack[s_num-1] << endl;
			s_num --;
		}else{
			stack[s_num] = x;
			s_num ++;
		}
	}

	return(0);
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
  cin>>n>>m;
  vector<int>v;
  int i,j=0;
  for(i=0;i<n;i++)
  {
int b;
    cin>>b;
    v.push_back(b);
  }
  for(i=0;i<n;i++)
  {
     if(v[i]>=m)
       j++;
  }
cout<<j;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int H,W,A,B; cin >> H >> W >> A >> B;
    int ans[H][W]; REP(i,H)REP(j,W) ans[i][j] = 0;

    REP(i,B)REP(j,A) ans[i][j] = 1;
    FOR(i,B,H)FOR(j,A,W) ans[i][j] = 1;
    REP(i,H){
        REP(j,W) cout << ans[i][j];
        cout << endl;
    }
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

typedef pair<int, int> P;

const int N = 1e6+5;
string s,t = "Yes";
vector<int> v[N];
int n,result;
int a,b;

int main () {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin >> a >> b;
  rep(i,3) {
    if(i+1 != a && i+1 != b) {
      cout << i+1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
#define Fi first
#define Se second
signed main(){
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

string sixdigits(ll num)
{
    string ret = "";
    if (num < 10)
    {
        ret = "00000" + to_string(num);
    }
    else if (num < 100)
    {
        ret = "0000" + to_string(num);
    }
    else if (num < 1000)
    {
        ret = "000" + to_string(num);
    }
    else if (num < 10000)
    {
        ret = "00" + to_string(num);
    }
    else if (num < 100000)
    {
        ret = "0" + to_string(num);
    }
    else
    {
        ret = to_string(num);
    }
    return ret;
}

signed main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> vp(n, vector<pair<int, int>>());
    rep(i, m)
    {
        int p, y;
        cin >> p >> y;
        vp[p - 1].push_back({y, i});
    }
    vector<string> ans(m);
    rep(i, n)
    {
        sort(all(vp[i]));
        rep(j, vp[i].size())
        {
            string s = sixdigits(i + 1) + sixdigits(j + 1);
            ans[vp[i][j].second] = s;
        }
    }
    rep(i, m)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 11744
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n,y,m,d;
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> y >> m >> d;
		int sum = 0;
		while (y < 1000) {
			if (y % 3 != 0 && m % 2 == 0) {
				sum += 20 - d;
				m++;
			}
			else {
				sum += 21 - d;
				m++;
			}
			d = 1;
			if (m > 10) {
				y++; m -= 10;
			}
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    int A[n][m];int b[m];int ans[100]={};
    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin >> A[i][j];}}
    for(int i=0;i<m;i++){cin >> b[i];}
    for(int i=0;i<n;i++){for(int j=0;j<m;j++){ans[i]+=A[i][j]*b[j];}}
    for(int i=0;i<n;i++){cout << ans[i] << endl;}
}


Measured memory_bytes: 3124
# AOJ 1502: War
# Python3 2018.7.13 bal4u

n = int(input())
ans = 1
h = [0]*126
for i in range(n):
	v = int(input())
	if v <= 125: h[v] += 1
	ans += v
s = 0
for i in range(1, 126):
	s += h[i-1]
	if n > s+4*i: ans -= n-(s+4*i)
print(ans)


Measured memory_bytes: 5604
#include<stdio.h>
#include<string.h>

int main(){
	char a[100000];
	int p=0;
	scanf("%s",a);
	int l=strlen(a);
	for(int i=1;i<l-1;i++){
		if(a[i-1]!=a[i+1]){
			p++;
			break;
		}
	}
	if(p==0){
		printf("Second");
	}
	else{
		if(a[0]==a[l-1]){
			if(l%2==0){
				printf("First");
			}
			else{
				printf("Second");
			}
		}
		else{
			if(l%2!=0){
				printf("First");
			}
			else{
				printf("Second");
			}
		}
	}
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  double ans = 0;
  REP(i,n){
    double x;
    string s;
    cin >> x >> s;
    if(s == "JPY") ans += x;
    else ans += 380000 * x;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int a[100][100];
void AdjMatrix(int, int);

int main(){
  int n, u, k, v, i, j;

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

  for(i = 0; i < n; i++){
    scanf(" %d %d", &u, &k);
    for(j  = 0; j < k; j++){
      scanf(" %d", &v);
      AdjMatrix(i, v);
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j == 0) printf("%d", a[i][j]); 
      else printf(" %d", a[i][j]);
    }
    printf("\n");
  }
  return 0;
}

void AdjMatrix(int x, int y){
  a[x][y-1] = 1;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <math.h>


int main(void) {
	int n;
	double xa, ya, ra, xb, yb, rb;
	double d;
	scanf("%d", &n);
	while (n--) {
		scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		d = sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
		if( ra > rb && ra-rb > d)
			printf("2\n");
		else if( rb > ra && rb-ra > d)
			printf("-2\n");
		else if( d <= ra + rb)
			printf("1\n");
		else
			printf("0\n");
	}
	
	return 0;
}

Measured memory_bytes: 620
n, k = map(int, input().split())
H = list(map(int, input().split()))


dp = [float("inf")]*(n+2)
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i+j >= n:
            break
        dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]))

print(dp[n-1])


Measured memory_bytes: 85012
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

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 main() {
    int first; ll N;
    cin >> first >> N;
    ll q[N];
    q[0] = first;
    for (int i = 1; i <= N; i++) {
        cin >> q[i];
    }
    using P = pair<ll, ll>;
    map<ll, ll, greater<ll>> mp;
    mp[q[N]] = 1;
    for (int i = N-1; i >= 0; i--) {
/*        printf("st\n");
        for (auto p: mp) {
            printf("%lld %lld\n", p.first, p.second);
        }
        printf("ed\n");*/
        vector<P> v;
        for (auto p: mp) {
            if (p.first <= q[i]) break;
            v.push_back(P(q[i], (p.first/q[i])*p.second));
            v.push_back(P(p.first%q[i], p.second));
        }
        while (mp.size() and q[i] < mp.begin()->first) {
            mp.erase(mp.begin());
        }
        for (auto p: v) {
            mp[p.first] += p.second;
        }
    }
    ll sm[first];
    fill_n(sm, first, 0);
    for (auto p: mp) {
        sm[p.first-1] += p.second;
    }
    for (int i = first-2; i >= 0; i--) {
        sm[i] += sm[i+1];
    }
    for (int i = 0; i < first; i++) {
        printf("%lld\n", sm[i]);
    }
    return 0;
}

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

#define endl '\n'
#define rep(i,s,n)      for (int i = s ; i < n ; i++)
#define repp(i,s,n)    for (int i = s ; i <= n ;i++)
#define all(a)      a.begin(),a.end()
#define sz(v)    (int)v.size()
#define NumofDigits(n)    ((long long)log10(n)+1)
#define Unique(n)         (n).erase(unique(all(n)), (n).end())
#define test    int s ; cin >> s; while (s--)
#define readArr    int n ; cin >> n ; int arr[n]; rep(i,0,n)cin>>arr[i]
#define isvowel(a)   (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fast     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll ;

void readFromText ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

const double Pi = acos(-1.0);

bool countIF (int a){
    return a%4==0;
}

bool myFun (int i , int j ) {

}

const int MAX = 1e6 ;
int sum [MAX+9];
int freq [MAX+9];

int main()
{
    fast;
//    readFromText();
    int n ; double sum = 0 ; cin >> n ; long long arr[n]; rep(i,0,n)cin>>arr[i],freq[arr[i]]++,sum+=arr[i];
    long long q ; cin >> q ;
    while (q--){
        long long b , c ; cin >> b >> c ;
        sum -= freq[b]*b;
        sum += freq[b]*c;
        freq[c]+=freq[b];
        freq[b]=0;
        cout << fixed << setprecision(0)<< sum << endl ;
    }
    return 0;
}



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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;
const int  INF = 1000000000;
const ll INFL = 1LL << 50;


int main() {
	int n;
	cin >> n;
	VI prime = { 11,31,41,61,71,101,131,151,191,211,241,251,271,311,
				331,401,421,431,461,491,521,541,571,601,641,661,691,701,751,761,811,821,
				881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1301,1321,
				1361,1381,1451,1471,1481,1511,1531,1571 };
	REP(i, n-1) {
		cout << prime[i] << ' ';
	}
	cout << prime[n - 1] << endl;
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




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

	ll n,m,x;
	cin>>m>>n>>x;
	vll A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	auto it = upper_bound(all(A),x);
	cout<<min(A.end()-it,it-A.begin());

		

}


Measured memory_bytes: 3624
n=int(input())
R=set([tuple(map(int,input().split())) for i in range(n)])
B=[tuple(map(int,input().split())) for i in range(n)]
B.sort()
ans=0
for a,b in B:
    x,y=-1,-1
    for c,d in R:
        if c<a and d<b and y<d:
            x,y=c,d
    if x>-1:
        ans+=1
        R.remove((x,y))
print(ans)

Measured memory_bytes: 39024
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int64
    fmt.Scan(&n)
    ans := int64(1)
    mod := int64(1000000007)
    for i:=int64(1);i<=n;i++{
        ans *= i
        ans %= mod
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int X = sc.nextInt();
		sc.close();

		if(X >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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

int main(){
  int h,n;
  cin >> h >> n;
  int su=0,b;
  for(int i=0;i<n;i++){
    cin >> b;
    su+=b;
  }
  cout << (h>su?"No":"Yes") << endl;
  return 0;
}

Measured memory_bytes: 3644
def collatz(n):
    if n % 2 == 0:
        return n/2
    else :
        return 3*n+1

li_a = []
i = 0
s = int(input())
li_a.append(s)
while True:
    temp = collatz(li_a[i])
    if temp in li_a:
        print(i+2)
        break
    else:
        li_a.append(temp)
    i += 1


Measured memory_bytes: 2940