akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define N_MAX 100

int M[N_MAX][N_MAX];
int d[N_MAX];
bool is_belong_to_sssp[N_MAX];

int main(){

  int n;
  scanf("%d", &n);

  //initialize
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      M[i][j] = INT_MAX;
    }
  }

  // read weigts
  for(int i=0; i<n; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    for(int j=0; j<k; j++){
      int v,c;
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  // initialize cost
  d[0] = 0;
  is_belong_to_sssp[0] = false;
  for(int i=1; i<n; i++){
    d[i] = INT_MAX;
    is_belong_to_sssp[i] = false;
  }

  //dijkstra's algorithm
  for(int i=0; i<n; i++){
    // select node u in V-S that has minimum cost
    int min_cost = INT_MAX;
    int u = 1;
    for(int j=0; j<n; j++){
      if(!is_belong_to_sssp[j] && d[j] < min_cost){
        u = j;
        min_cost = d[j];
      }
    }

    // add u to is_belong_to_sssp
    is_belong_to_sssp[u] = true;

    // update node in V-S and adjacent to u
    for(int v=0; v<n; v++){
      if(!is_belong_to_sssp[v] && M[u][v] != INT_MAX){
        if(d[u] + M[u][v] < d[v]){
          d[v] = d[u] + M[u][v];
        }
      }
    }
  }

  // output
  for(int i=0; i<n; i++){
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;

struct POINT
{
	int r, c;
	POINT(int r = 0, int c = 0) :r(r), c(c) {}
};

POINT dir[4] = { POINT(-1, 0), POINT(0, 1), POINT(1, 0), POINT(0, -1) };
string dirc = "URDL";

int main()
{
	int H, W, N; cin >> H >> W >> N;

	POINT sp;
	cin >> sp.r >> sp.c;
	sp.r--; sp.c--;

	string S, T; cin >> S >> T;

	bool flag = true;
	for (int k = 0; k < 4; k++)
	{
		int dist = 0;
		if (k == 0)
		{
			dist = sp.r + 1;
		}
		else if (k == 1)
		{
			dist = W - sp.c;
		}
		else if (k == 2)
		{
			dist = H - sp.r;
		}
		else if (k == 3)
		{
			dist = sp.c + 1;
		}

		for (int i = 0; i < N; i++)
		{
			if (S[i] == dirc[k])dist--;
			if (dist == 0)flag = false;
			if (T[i] == dirc[(k + 2) % 4] && dist < (k % 2 ? W - 1 : H - 1))dist++;
		}
	}

	cout << (flag ? "YES" : "NO") << endl;

	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> jobs(m);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    if(a > m) continue;
    jobs[m-a].push_back(b);
  }

  priority_queue<ll> q;
  ll ans = 0;
  for(ll i = m-1; i >= 0; i--){
    for(ll b : jobs[i]){
      q.push(b);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
# coding: utf-8
import math
N = int(input())


saisho = 10**10
for i in range(1, int(math.sqrt(N)) + 1):
    if N % i == 0:
        fab = max(len(str(i)), len(str(N // i)))
        saisho = min(saisho, fab)

print(saisho)

Measured memory_bytes: 9120
n = input()
n = int(n)
list = [0] * n

list = input().split()

for i in range(n):
    list[i] = int(list[i])
bool = True
count = 0
while(bool):
    for i in range(len(list)):
        if(list[i]%2 == 0):
            list[i] /= 2
        else:
            bool = False
    count += 1

print(count-1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(){
	int Q, i, j, maxr;
	scanf("%d", &Q);
	int *l = (int *)malloc(sizeof(int) * Q);
	int *r = (int *)malloc(sizeof(int) * Q);
	for(i = 0, maxr = 0; i < Q; i++){
		scanf("%d%d", &l[i], &r[i]);
		if(r[i] > maxr){
			maxr = r[i];
		}
	}
	int *is_prime = (int *)malloc(sizeof(int) * (maxr + 1));
	int *is_like_2017 = (int *)malloc(sizeof(int) * (maxr + 1));
	for(i = 0; i <= maxr; i++){
		is_prime[i] = 1;
		is_like_2017[i] = 0;
	}
	is_prime[0] = 0;
	is_prime[1] = 0;
	for(i = 2; i <= maxr; i++){
		if(is_prime[i] == 1){
			for(j = 2; i * j <= maxr; j++){
				is_prime[i * j] = 0;
			}
		}
	}
	for(i = 3; i <= maxr; i++){
		if(is_prime[i] == 1 && is_prime[(i + 1) / 2] == 1){
			is_like_2017[i] = 1;
		}
		is_like_2017[i] += is_like_2017[i - 1];
	}
	for(i = 0; i < Q; i++){
		printf("%d\n", is_like_2017[r[i]] - is_like_2017[l[i] - 1]);
	}
	return 0;
}

Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



pair<int, int> f(int x, int y, int a, int b, int c, int d) {
	return make_pair(a * x + b * y, c * x + d * y);
}

double dist(pair<int, int> p1, pair<int, int> p2) {
	long double d1 = p1.first - p2.first;
	long double d2 = p1.second - p2.second;
	return sqrt(d1 * d1 + d2 * d2);
}

long double area(pair<int, int> p1, pair<int, int> p2, pair<int, int>p3) {
	long double a, b, c;
	a = dist(p1, p2);
	b = dist(p1, p3);
	c = dist(p2, p3);
	long double s = (a + b + c) / 2;
	return sqrt(s * (s - a) * (s - b) * (s - c));
}


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

	long long s;
	cin >> s;

	int a, b, c, d;

	long long lb = 1, ub = 1000000001;
	while (ub-lb>1) {
		auto mid = (lb + ub) / 2;
		if (mid*mid < s) {
			lb = mid;
		}
		else {
			ub = mid;
		}
	}

	a = d = ub;

	b = 0;
	c = 0;
	long long over = (long long)a * d - s;
	for (long long q = 1; q <= over;q++) {
		if (over %q == 0 && over/q <= 1000000000) {
			b = q;
			c = over / q;
			break;
		}
	}



	pair<int, int> p1, p2, p3;
	p1 = f(0, 0, a, b, c, d);
	p2 = f(1, 0, a, b, c, d);
	p3 = f(0, 1, a, b, c, d);

	cout << p1.first << ' ' << p1.second << ' ';
	cout << p2.first << ' ' << p2.second << ' ';
	cout << p3.first << ' ' << p3.second << endl;

	//cerr << area(p1, p2, p3) << endl;


	return 0;
}

Measured memory_bytes: 256
n=gets.to_i;a=gets.split.map &:to_i;c=1;b=[];(n-1).times{|i|a[i]!=a[i+1]?c+=1:(b.push(c);c=1)};b.push(c);s=(m=b.size())<3?n:0;(b.size()-2).times{|i|s=s<(d=b[i]+b[i+1]+b[i+2])?d:s};p s

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

int main()
{
    double d, t, s;
    cin >> d >> t >> s;
    if (d/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3724
# include<bits/stdc++.h>
# define LL long long
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int minn=1e9;
	minn=min(minn,abs(b-a)+abs(b-c));
	minn=min(minn,abs(b-a)+abs(a-c));
	minn=min(minn,abs(c-a)+abs(b-c));
	cout<<minn;
}

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

int main(){
    vi A(9), ans(9);
    rep(i, 9){
        ans[i] = 0;
        int tmp;
        cin >> tmp;
        A[i] = tmp;
    }

    int N;
    cin >> N;

    set<int> b;
    rep(i, N){
        int tmp;
        cin >> tmp;
        b.insert(tmp);
    }

    rep(i, 9){
        if(b.find(A[i]) != b.end()){
            ans[i] = 1;
        }
    }

    bool flg = false;
    if(ans[0]&&ans[1]&&ans[2] || ans[3]&&ans[4]&&ans[5] || ans[6]&&ans[7]&&ans[8]) flg = true;
    if(ans[0]&&ans[3]&&ans[6] || ans[1]&&ans[4]&&ans[7] || ans[2]&&ans[5]&&ans[8]) flg = true;
    if(ans[0]&&ans[4]&&ans[8] || ans[2]&&ans[4]&&ans[6]) flg = true;

    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int a[100];

int main(){
    int n = inp();
    for(int i = 1; i <= n; i++)
        a[i] = inp();
    int ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = i + 1; j <= n; j++)
            ans += a[i] * a[j];
    printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);


		int a=scan.nextInt();
		int b =scan.nextInt();
		int c=scan.nextInt();
		
		if(a<b&&b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26080
#include<bits/stdc++.h>
using namespace std;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree{
    using T = struct { int sum, sz; };
    static T op(T a, T b) { return {a.sum + b.sum, a.sz + b.sz}; }
    static constexpr T e() { return {0, 0}; }
    using U = struct {
        int p, q;
        bool operator==(const auto& r) const { return p == r.p and q == r.q; }
    };
    static void ap(U f, T& a) { a.sum = f.p * a.sum + f.q * a.sz; }
    static void cp(U g, U& f) { f.p *= g.p, f.q = g.p * f.q + g.q; }
    static constexpr U id() { return {1, 0}; }

    const int n;
    V<T> t;
    V<U> u;
    SegmentTree(int _n) : n(1<<__lg(2*_n-1)),t(2*n,e()),u(n,id()) {}
    T& operator[](int i) {return t[i+n]; }
    void build() {for(int i=n-1;i;--i) t[i] = op(t[2*i],t[2*i+1]);}
    void apply(const U& f, int i){
        ap(f,t[i]);
        if(i<n) cp(f,u[i]);
    }

    void push(int i){
        if(u[i]==id()) return ;
        apply(u[i],2*i);
        apply(u[i],2*i+1);
        u[i] = id();
    }

    T acc(int l,int r,int i,int a,int b){
        if(b<=l or r<=a) return e();
        if(l<=a and b<=r) return t[i];
        push(i);
        return op(acc(l,r,2*i,a,a+b>>1),acc(l,r,2*i+1,a+b>>1,b));
    }

    T acc(int l,int r){return acc(l,r,1,0,n);}
    T get(int i) { return acc(i, i + 1); }

    void act(int l,int r,const U& f,int i,int a, int b){
        if(b<=l or r<=a) return ;
        if(l<=a and b<=r){
            apply(f,i);
            return ;
        }
        push(i);
        act(l,r,f,2*i,a,a+b>>1),act(l,r,f,2*i+1,a+b>>1,b);
        t[i] = op(t[2*i],t[2*i+1]);
    }

    void act(int l,int r,const U& f){act(l,r,f,1,0,n);}
};

int main() {
    int n; cin >> n;
    SegmentTree a(n), b(n - 1);
    for (int i = 0; i < n; ++i) {
        char c; cin >> c;
        a[i] = {c - '0', 1};
        if (i) b[i - 1] = {a[i].sum * a[i - 1].sum, 1};
    }
    a.build(), b.build();
    int q; cin >> q;
    while (q--) {
        int l, r, x; cin >> l >> r >> x, --l;
        a.act(l, r, {0, x});
        if (r - l >= 2) b.act(l, r - 1, {0, x});
        if (l) b.act(l - 1, l, {0, a.get(l - 1).sum * a.get(l).sum});
        if (r < n) b.act(r - 1, r, {0, a.get(r - 1).sum * a.get(r).sum});
        cout << a.acc(0, n).sum - b.acc(0, n - 1).sum << '\n';
    }
    return 0;
}


Measured memory_bytes: 8904
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    ll A;
    string B;
    cin >> A >> B;

    ll res = A * (ll) (B[0] - '0');

    ll B_under = 10*(B[2]-'0') + B[3] - '0';
    res += A * B_under/100;
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N-i; j++) {	
				int k = N - i - j;
				if (10000 * i + 5000 * j + 1000 * k == Y && i+j+k == N) {
					System.out.println(i + " " + j + " " + k); 	
					System.exit(0);
				}	
			}	
		}
		System.out.println("-1 " +  "-1 " + "-1");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  
  int n,r;
  cin >> n >> r;
  
  int hosei = max(0,10-n);
  
  cout << r + 100*hosei << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define y1 Emilia
#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;
vector<vector<char>>  three = {{'a', 'a', '.'},
                               {'.', '.', 'a'},
                               {'.', '.', 'a'}};

vector<vector<char>> four = {{'a', 'a', 'b', 'c'},
                             {'d', 'd', 'b', 'c'},
                             {'b', 'c', 'a', 'a'},
                             {'b', 'c', 'd', 'd'}};


vector<vector<char>> five = {{'a', 'a', 'b', 'b', 'a'},
                             {'b', 'c', 'c', '.', 'a'},
                             {'b', '.', '.', 'c', 'b'},
                             {'a', '.', '.', 'c', 'b'},
                             {'a', 'b', 'b', 'a', 'a'}};


vector<vector<char>> six = {{'a', 'a', 'b', 'c', '.', '.'},
                            {'d', 'd', 'b', 'c', '.', '.'},
                            {'.', '.', 'a', 'a', 'b', 'c'},
                            {'.', '.', 'd', 'd', 'b', 'c'},
                            {'b', 'c', '.', '.', 'a', 'a'},
                            {'b', 'c', '.', '.', 'd', 'd'}};


vector<vector<char>> seven = {{'a', 'a', 'b', 'b', 'c', 'c', '.'},
                              {'d', 'd', '.', 'd', 'd', '.', 'a'},
                              {'.', '.', 'd', '.', '.', 'd', 'a'},
                              {'.', '.', 'd', '.', '.', 'd', 'b'},
                              {'d', 'd', '.', 'd', 'd', '.', 'b'},
                              {'.', '.', 'd', '.', '.', 'd', 'c'},
                              {'.', '.', 'd', '.', '.', 'd', 'c'}};


void print(vector<vector<char> > &v) {
    int m = (int)v.size();
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j)
            cout << v[i][j];
        cout << "\n";
    }
}


int main() {
    dracarys
    cin >> n;
    if (n == 2) {
        cout << -1 << "\n";
        return 0;
    }

    if (n == 3) {
        print(three);
        return 0;
    }

    int x = (n - 4) / 4;
    int y = n - 4 * x;

    unordered_map<int, vector<vector<char>>> q = {{4, four},
                                                  {5, five},
                                                  {6, six},
                                                  {7, seven}};

    vector<vector<char>> ans(n, vector<char> (n, '.'));
    for (int i = 0; i < x; ++i) {
        int r = 4 * i, c = 4 * i;
        for (int r1 = r; r1 < r + 4; ++r1)
            for (int c1 = c; c1 < c + 4; ++c1)
                ans[r1][c1] = four[r1 - r][c1 - c];
    }

    int r = 4 * x, c = 4 * x;
    vector<vector<char>> last = q[y];
    for (int r1 = r; r1 < r + y; ++r1)
        for (int c1 = c; c1 < c + y; ++c1)
            ans[r1][c1] = last[r1 - r][c1 - c];

    print(ans);
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

struct UnionFind {
   vector<int> d;
   UnionFind(int n = 0) : d(n, -1) {}
   int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
   }
   bool unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x, y);
      d[x] += d[y];
      d[y] = x;
      return true;
   }
   bool same(int x, int y) { return find(x) == find(y); }
   int size(int x) { return -d[find(x)]; }
};

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

   int n, m;
   cin >> n >> m;
   vector<int> a(m), b(m);
   rep(i, 0, m) {
      cin >> a[i] >> b[i];
      a[i]--, b[i]--;
   }
   int ans = 0;
   rep(i, 0, m) {
      UnionFind uf(n);
      rep(j, 0, m) {
         if (j == i) continue;
         uf.unite(a[j], b[j]);
      }
      rep(j, 0, n) {
         if (!uf.same(0, j)) {
            ans++;
            break;
         }
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x%2 == 1) {
      puts("first");
      return 0;
    }
  }
  puts("second");
}

Measured memory_bytes: 256
k = 34
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(len(B)*2-1)]]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [0] * 100001
for a in A:
    B[a] += 1
C = li(st(nu(B) ** 2))
ans = 0
for i in range(200001)[::-1]:
    a = min(M, C[i])
    M -= a
    ans += a * i
print(ans)

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

int main(){


 int r; cin>>r;

 if(r<=1199)
    cout<<"ABC"<<endl;
 else if(r>= 1200 && r<2800)
   cout<<"ARC"<<endl;
   else
    cout<<"AGC"<<endl;

return 0;
}


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

using namespace std;

typedef long long ll;

struct Node {
    int key;
    Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL, *x = root, *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key)
            x = x->l;
        else
            x = x->r;
    }

    z->p = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->l = z;
        } else {
            y->r = z;
        }
    }
}

void inorder(Node* u) {
    if (u == NIL) return;
    inorder(u->l);
    cout << " " << u->key;
    inorder(u->r);
}

void preorder(Node* u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preorder(u->l);
    preorder(u->r);
}

int main() {
    int n; cin >> n;
    
    for (int i = 0; i < n; i++) {
        string com; cin >> com;
        if (com == "insert") {
            int x; cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}



Measured memory_bytes: 26484
#include<stdio.h>
#define MAX 100001

int max(int a,int b){
 if(a>b)return a;

return b;
}



void func(int N,int W,int v[],int w[]){
int X[MAX]={0};
int i,j;

for(i=0;i<N;i++){

 for(j=1;j<=W;j++){
   if(j>=w[i])X[j]=max(X[j],X[j-w[i]]+v[i]);
 }

}/*たて*/

printf("%d\n",X[W]);

return;
}

int main(){
int N,W;
int v[MAX];
int w[MAX];
int i;

scanf("%d %d",&N,&W);

for(i=0;i<N;i++)scanf("%d %d",&v[i],&w[i]);

func(N,W,v,w);

return 0;
}


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

const int MAX_N = 100000;

int main() {
	int N, cnt[MAX_N] = {};

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		int a;
		std::cin >> a;
		++cnt[a];
	}

	int ans = 0;
	for(int x = 0; x < MAX_N; ++x) {
		int sum = cnt[x];
		if(x - 1 >= 0) sum += cnt[x - 1];
		if(x + 1 < MAX_N) sum += cnt[x + 1];
		ans = std::max(ans, sum);
	}

	std::cout << ans << std::endl;
}


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

int main() {
    int n;
    cin >> n;
    pair<int, int> a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);
    map<pair<int, int>, int> ct;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ct[{a[j].first - a[i].first, a[j].second - a[i].second}]++;
        }
    }
    pair<int, int> pq;
    int cnt = 0;
    for (auto pp : ct) {
        if (pp.second > cnt) {
            pq = pp.first;
            cnt = pp.second;
        }
    }
    if (n == 1) {
        cout << 1;
    } else {
        cout << n - cnt;
    }
    return 0;
}


Measured memory_bytes: 384
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};


string s;
vint v;
int ans;

main(){
	cin>>s;
	int t=0;
	rep(i,s.size()){
		if(s[i]=='W'){
			v.pb(t);
			t=0;
		}else{
			t++;
		}
	}
	for(int i=1;i<v.size();i++)v[i]+=v[i-1];
	for(int x:v)ans+=x;
	dans;
}


Measured memory_bytes: 2552
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	int x,y;
	int a[100];
	int b[100];
	cin>>n>>m;
	cin>>x>>y;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	sort(b,b+m);
	if(b[0]>x && b[0]<=y){
		if(b[0]>a[n-1])
			cout<<"No War"<<endl;
		else
			cout<<"War"<<endl;
	}
	else
		cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>

#define MOD (998244353)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;

tup part_value(string &S, ll idx) {
    ll n = 0, m = 0;

    bool next = false;
    
    while(idx < S.length()) {
        if(S[idx] == '>') next = true;
        if(next == true && S[idx] == '<') break;

        if(next) m++;
        else n++;

        idx++;
    }
    // while(S[idx] == '<') {
    //     n++;idx++;
    //     if(idx >= S.length()) {
    //         return make_pair((n*(n+1)/2) + (m*(m+1)/2) - min(n, m), idx);
    //     }
    // }
    // while(S[idx] == '>') {
    //     m++;idx++;
    //     if(idx >= S.length()) {
    //         return make_pair((n*(n+1)/2) + (m*(m+1)/2) - min(n, m), idx);
    //     }
    // }

    return make_pair((n*(n+1)/2) + (m*(m+1)/2) - min(n, m), idx);
}


int main() {
    string S;
    cin >> S;

    ll sum = 0;
    ll idx = 0;

    // for(int i = 0 ; i < 500000; i++) {
    //     S += "<>";
    // }
    //S =  string("<>") ; //+ string(50000, '<') ;

    while(idx < S.length() ) {
        //cout << idx << endl;
        tup t = part_value(S, idx);
        sum += get<0>(t);
        idx = get<1>(t);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	string s;
	cin >> s;
	vi w(n, 0), e(n, 0);
	if (s[0] == 'W') {
		w[0] = 1;
	}
	else {
		e[0] = 1;
	}
	repr(i,1, n) {
		if (s[i] == 'W') {
			w[i] = w[i - 1] + 1;
			e[i] = e[i - 1];
		}
		else {
			w[i] = w[i - 1];
			e[i] = e[i - 1] + 1;
		}
	}

	int ans = INF;
	rep(i, n) {
		int t = INF;
		if (i == 0) {
			t = e[n - 1];
		} 
		else if (i == n - 1) {
			t = w[n - 1];
		}
		else {
			int a = w[i];
			int b = e[s.size() - 1] - e[i];
			t = a + b;
			//cout << a << ' ' << b << endl;
		}

		ans = min(ans, t);
	}

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B;
  cin >> A >> B;

  int sum = 0;
  for (int i = A; i <= B; i++) {
    string s = std::to_string(i);
    if (s[0] == s[4] && s[1] == s[3]) {
      sum++;
    }
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
  int N;
    cin >> N;
  int a = N / 1000;
  int b = (N - a * 1000) / 100;
  int c = (N - a * 1000 - b * 100) / 10;
  int d = (N - a * 1000 - b * 100 - c * 10);
  if ( a == b && b ==c){
    cout << "Yes" << endl;
  }
  else if ( b ==c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>
 
int main(){
  char b[10000];
  int c[26]={};
  int n,i=0;
   
  while(1){
    b[i]=getchar();
    if(b[i]==EOF)
      break;
    i++;
  }
  n=strlen(b);
 
  for(i=0;i<n;i++){
    b[i]=tolower(b[i]);
    c[b[i]-'a']++;
  }
 
  for(i=0;i<26;i++)
    printf("%c : %d\n",'a'+i,c[i]);
 
  return 0;
}

Measured memory_bytes: 524
N=int(input())
Array = list(map(int, input().strip().split()))
array=list(set(Array))
array.sort()
n=len(array)
f=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for w in range(j+1,n):
            if array[i]+array[j]>array[w]:
                f+=Array.count(array[i])*Array.count(array[j])*Array.count(array[w])
print(f)
            


Measured memory_bytes: 67876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
int main() {
    int S,W; cin >> S >> W;
    if (S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int cp = 0, cr = 0;
            int[] cpAr = new int[n];
            if (s.charAt(0) == '.')
                cpAr[0] = 1;
            for (int i = 0; i < n; i++) {
                if (i > 0) {
                    if (s.charAt(i) == '.')
                        cpAr[i] = cpAr[i - 1] + 1;
                    else
                        cpAr[i] = cpAr[i - 1];
                }
                if (s.charAt(i) == '.')
                    cp++;
                else
                    cr++;
            }
            int[] crAr = new int[n];
            if (s.charAt(n - 1) == '#')
                crAr[n - 1] = 1;
            for (int i = n - 2; i >= 0; i--)
                if (s.charAt(i) == '#')
                    crAr[i] = crAr[i + 1] + 1;
                else
                    crAr[i] = crAr[i + 1];
            if (cr == 0)
                out.println(0);
            else {
                int min1 = Math.min(cp, cr);
                int min = Integer.MAX_VALUE;
                for (int i = 0; i < n; i++) {
                    int pLeft = cpAr[i];
                    int leftLen = i + 1;
                    int rRight = 0, rightLen = 0;
                    if (i + 1 < n) {
                        rRight = crAr[i + 1];
                        rightLen = n - (i + 1);
                    }
                    int cur = (leftLen - pLeft) + (rightLen - rRight);
                    min = Math.min(cur, min);
                }
                out.println(Math.min(min1, min));
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 27092
//
// Created by yamunaku on 2019/11/09.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n), b(n);
    vector<pi> v(n),w(n);
    vector<int> nxt(n, -1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n){
        v[i] = {a[i], i};
        w[i] = {b[i], i};
    }
    sort(all(v));
    sort(all(w));
    rep(i, n){
        if(v[i].first > w[i].first){
            CNO;
            return 0;
        }
    }
    set<int> st;
    rep(i, n){
        if(i > 0){
            if(v[i].first <= w[i - 1].first){
                CYES;
                return 0;
            }
        }
        nxt[v[i].second] = w[i].second;
    }
    int now = 0;
    vi visited(n, false);
    while(!visited[now]){
        visited[now] = true;
        now = nxt[now];
    }
    if(now==0){
        rep(i,n){
            if(!visited[i]){
                CYES;
                return 0;
            }
        }
        CNO;
    }else{
        CYES;
    }
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
    int n,m,ans=0;
    double sum=0;
    scanf("%d %d",&n,&m);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=0; i<n; i++){
        if(a[i]>=sum/(4*m))
            ans++;
    }
    if(ans>=m)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var arg string

	fmt.Scan(&arg)
	qnum, _ := strconv.Atoi(arg)

	if qnum%2 == 0 {
		ans := qnum
		fmt.Printf("%d\n", ans)
	} else {
		ans := 2 * qnum
		fmt.Printf("%d\n", ans)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <bitset>
#include <ctime>
 
using namespace std;
 
typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

struct Segment {
	int s, e;
};
struct ByStartDesc {
	bool operator()(const Segment &a, const Segment &b) {
		return a.s != b.s ? a.s > b.s : a.e > b.e;
	}
};
struct ByEndAsc {
	bool operator()(const Segment &a, const Segment &b) {
		return a.e != b.e ? a.e < b.e : a.s < b.s;
	}
};

template<typename S1, typename S2>
Long go(multiset<Segment, S1> S, multiset<Segment, S2> E) {
	int p = 0;
	Long tot = 0;
	auto moveTo = [&](Segment s) {
		if (p < s.s) {
			tot += s.s - p;
			p = s.s;
		}
		if (p > s.e) {
			tot += p - s.e;
			p = s.e;
		}
	};
	for (int i = 0; S.size() > 0 ; ++i) {
		Segment s;
		if (i%2 == 0) {
			s = *S.begin();
		} else {
			s = *E.begin();
		}
		moveTo(s);
		S.erase(S.lower_bound(s));
		E.erase(E.lower_bound(s));
	}
	return tot + abs(p);
}

int main(int argc, char *argv[]) {
	
	int N;
	cin >> N;
	multiset<Segment, ByStartDesc> S;
	multiset<Segment, ByEndAsc> E;
	for (int i = 0; i < N; ++i) {
		Segment s;
		cin >> s.s >> s.e;
		S.insert(s);
		E.insert(s);
	}
	cout << max(go(S, E), go(E,S)) << endl;
	
}


Measured memory_bytes: 18944
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}





int main() {
	int n;
	cin >> n;
	
	vector< string > S(n);
	for_(i,0,n) cin >> S[i];
	
	vector< vector< int > > cnt(n, vector< int >(26, 0));
	for_(i,0,n) for_(j,0,(int)S[i].size()) ++cnt[i][S[i][j] - 'a'];
	
	vector< int > num(26, 100);
	for_(i,0,n) for_(j,0,26) minUpdate(num[j], cnt[i][j]);
	
	string ans = "";
	for_(i,0,26) for_(j,0,num[i]) ans += char('a' + i);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vi a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    int d = 1;
    vvi c(h, vi(w));
    int y = 0;
    int x = 0;
    int col = 1;
    int hw = h * w;
    while (hw--)
    {
        while (a[col - 1] == 0)
        {
            col++;
        }
        c[y][x] = col;
        a[col - 1]--;
        if ((x == 0 && d < 0) || (x == w - 1 && d > 0))
        {
            y++;
            d = -d;
            x = x - d;
        }
        x = x + d;
    }
    rep(y, h)
    {
        rep(x, w - 1)
        {
            cout << c[y][x] << " ";
        }
        cout << c[y][w-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] XY = ria();
        int X = XY[0];
        int Y = XY[1];

        string ans = "No";
        for (int i = 0; i <= X ; i++)
        {
            int crane = X - i;
            if(2 * i + 4 * crane == Y) ans = "Yes";
        }

        // Console.WriteLine("No");

        // string ans = "No";
        
        // if(Y / 2 == Y / 2.0) {
        //     if(2 * X - Y / 2 >= 0) ans = "Yes";
        // }

        Console.WriteLine(ans);
        Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2*60+m2) - (h1*60+m1) - k << endl;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

string S, T;

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

	cin >> S >> T;

	int ti = -1;
	rep(i, 0, SZ(S))
	{
		rep(j, 0, SZ(T))
		{
			if (S[i + j] != '?'&&S[i + j] != T[j])
			{
				break;
			}
			if (j == SZ(T) - 1)
			{
				ti = i;
			}
		}
	}

	if (ti == -1)
	{
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	rrep(i, 0, SZ(S))
	{
		if (S[i] == '?')
		{
			S[i] = 'a';
		}
	}

	rep(i, 0, SZ(T))
	{
		S[ti + i] = T[i];
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = 0;;i++){
        for(int j = 0;;j++){
            if(a >= b){
                int k = a;
                a = b;
                b = k;
            }
            else if(b >= c){
                int l = b;
                b = c;
                c = l;
            }
            else{
                a = a;
                b = b;
                c = c;
            }
            break;
        }
        if(a <= b && b <=c){
            break;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h> 
// for vector 
#define ll long long
using namespace std; 

int main () 
{ 
   ll n,d;
   cin>>n>>d;
   ll ans=0;
   for(int i=0;i<n;i++){
	   ll a,b;
	   cin>>a>>b;
	   if(sqrt(a*a+b*b)<=d)
	     ans++;
   }
   cout<<ans;
	return 0; 
} 

Measured memory_bytes: 3676
import java.io.*;

class Calc{
    public static int gcd(int a, int b, int c)  {
        int r;
        while (b > 0) {
            r = a % b;
            a = b;
            b = r;
        }
        while (c > 0) {
            r = a % c;
            a = c;
            c = r;
        }
        return a;
    }
}

class Main{

    public static void main(String args[])
    {
        String buf;
        int num;
        int ans;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            buf = br.readLine();
            num = Integer.parseInt(buf);
            ans = 0;
            for(int i = 1; i <= num; i++){
                for(int j = 1; j <= num; j++){
                    for(int k = 1; k <= num; k++){    
                        ans += Calc.gcd(i,j,k);
                    }
                }
            }
            
            System.out.println(Integer.toString(ans));
        } catch(Exception e) {}
  }
}

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

# ランレングス符号化
# (1 0 1 0 ... 0 1)の数を数える
count = []

if S[0] == 0 :
    count.append(0)

index = 0

while index < N :
    now = S[index]
    end = index + 1  # 異なる値の左端のインデックス
    while end < N :
        if S[end] != now :
            break
        end += 1
    count.append(end - index)
    index = end

if S[-1] == 0 :
    count.append(0)

L = len(count)

sub = sum(count[0 : 2 * K + 1])
ans = sub

i = 2
while (i + 2*K) < L :
    sub = sub - count[i-1] - count[i-2] + count[i+2*K] + count[i+2*K - 1]
    if sub > ans :
        ans = sub
    i += 2

print(ans)

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

int main() {
    int h,w;
    cin >> h >> w;
    string s[50];

    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }

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

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(s[i][j]=='#') continue;

            int ans = 0;
            for (int k = 0; k < 8; k++)
            {
                int ny = i+dy[k];
                int nx = j+dx[k];

                if(ny<0 or h<=ny) continue;
                if(nx<0 or w<=nx) continue;

                if(s[ny][nx]=='#') ans++;
            }

            s[i][j] = char(ans+'0');
        }
    }
    
    for (int i = 0; i < h; i++) cout << s[i] << endl;
    return 0;
}

Measured memory_bytes: 3644