akhauriyash/Code-Regression huggingface dataset:
n, m = gets.split(" ").map(&:to_i)

cities = Array.new(n).fill(0)

m.times do
  a, b = gets.split(" ").map(&:to_i)
  cities[a-1] += 1
  cities[b-1] += 1
end

cities.each do |city|
  puts city
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <math.h>
#include <cmath>
#include <string.h>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#define INF 1000000000
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
typedef long long int ll;
using namespace std;

int main(){

	int n,ans = 0; cin >> n;
	int p[20]; rep(i, n) { cin >> p[i]; }
	for (int i = 1; i < n - 1; i++) {
		int pp[3] = { p[i - 1], p[i] , p[i + 1] };
		sort(pp, pp + 3);
		if (pp[1] == p[i]) { ans++; }
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;

bool isPrime(int x) {
    if (x < 2) return false;
    if (x == 2) return true;
    if (x % 2 == 0) return false;
    for (int i = 3; i * i <= x; i += 2) {
        if (x % i == 0) return false;
    }
    return true;
}

void main() {
    int n = readln.chomp.to!int;
    int cnt = 0;
    foreach (i; 0 .. n) {
        int x = readln.chomp.to!int;
        if (isPrime(x)) ++cnt;
    }
    cnt.writeln;
}


Measured memory_bytes: 2480
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from array import array

def grouping(nums):
    sign = None
    L = array(b'i')
    for s, n in ((i < 0, i) for i in nums):
        if sign is s:
            L[-1] += n
        else:
            sign = s
            L.append(n)

    if len(L) and L[-1] <= 0:
        del L[-1]
    if len(L) and L[0] <= 0:
        del L[0]
    return L

while True:
    n = int(stdin.readline())
    if not n:
        break

    L = array(b'i', (int(stdin.readline()) for _ in xrange(n)))
    val = max(L)
    if val <= 0:
        print(val)
        continue

    ans, temp = 0, 0
    for i in grouping(L):
        temp = max(0, temp+i)
        ans = max(ans, temp)
    print(ans)

Measured memory_bytes: 4420
#include <iostream>
#define N_MAX 300
#define INF (2<<21)
using namespace std;

int N;
int E[N_MAX][N_MAX];
int A[N_MAX][N_MAX];

void warshall_floyd(){
	for (int k=0; k<N; k++){
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				if (E[i][j] > E[i][k] + E[k][j]){
					E[i][j] = E[i][k] + E[k][j];
				}
			}
		}
	}
}

int main(void){
	cin >> N;

	for (int i=0; i<N; i++){
		for (int j=0; j<N; j++){
			cin >> E[i][j];
			A[i][j] = E[i][j];
		}
	}

	for (int k=0; k<N; k++){
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				if(k == i || k == j || i == j || E[i][k] == INF || E[k][j] == INF) continue;
				if (E[i][j] > E[i][k] + E[k][j]){
					cout << "-1" << endl;
					return 0;
				} else if (E[i][j] == E[i][k] + E[k][j]){
					A[i][j] = INF;
				}
			}
		}
	}

	long long int sum = 0;
	for (int i=0; i<N; i++){
		for (int j=0; j<N; j++){
			if (A[i][j] != INF) sum += A[i][j];
		}
	}

	cout << (sum/2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    int a[n];
    rep(i,n)cin >> a[i];
    double sum = 0;
    rep(i,n)sum += a[i];
    ll count = 0;
    rep(i,n){
        if(sum / 4 /m <= a[i])count += 1;
    }
    if(count >= m)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
  string s;
  int k;
  cin >> s >> k;

  int flag = 1;
  for (int i = 1; i < s.size(); i++){
    if (s[i] != s[i-1])
      flag = 0;
  }

  if (flag == 1){
    cout << (s.size()*k)/2 << endl;
    return 0;
  }
  int left = 0, right = 0;
  ll ans = 0;

  vector<int> cntr;
  
  while (left < s.size()){
    while ((right+1 < s.size()) && (s[left] == s[right+1])){
      right++;
    }
    int cntrr = right - left + 1;
    cntr.push_back(cntrr);
    ans = ans + cntrr/2;
    left = right + 1;
    right = left;
  }
  
  ans *= k;

  if ((s[0] == s[s.size()-1]) && (cntr[0]%2 == 1 && cntr.back()%2 == 1) && (cntr.size() != 1))
    ans += (k-1);

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

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

  class Node {

    int val;
    Node next;

    public Node(int val) {
      this.val = val;
      this.next = null;
    }

  }

  class Stack {

    Node top;

    public Stack() {
      this.top = null;
    }

    public List<Integer> toArrayList() {
      List<Integer> l = new ArrayList<Integer>();
      Node curr = this.top;
      while (curr != null) {
        l.add(curr.val);
        curr = curr.next;
      }
      return l;
    }

    public boolean isEmpty() {
      return this.top == null;
    }

    public void push(int val) {
      Node newElem = new Node(val);
      newElem.next = this.top;
      this.top = newElem;
    }

    public Integer peek() {
      Node top = this.top;
      if (this.top == null)
        return null;
      return top.val;
    }

    public Integer pop() {
      Node top = this.top;
      if (this.top == null)
        return null;
      this.top = this.top.next;
      return top.val;
    }

    public Integer sum() {
      Node top = this.top;
      int sum = 0;
      while (top != null) {
        sum += top.val;
        top = top.next;
      }
      return sum;
    }

    public void display() {
      Node curr = this.top;
      StringBuilder s = new StringBuilder("");
      while (curr != null) {
        s.append(curr.val + " -> ");
        curr = curr.next;
      }
      s.append("null");
      System.out.println(s);
    }

  }

  int totalArea = 0;
  Stack areas = new Stack();
  Stack areas_far_left = new Stack();
  String[] gradients;

  public Main(String[] gradients) {
    this.gradients = gradients;
  }

  public void merge(int left, int right) {
    int new_area = right - left;
    while (this.areas_far_left.peek() != null && left < this.areas_far_left.peek()) {
      new_area += this.areas.pop();
      this.areas_far_left.pop();
    }
    this.areas.push(new_area);
    this.areas_far_left.push(left);
  }

  public void handleDown(Stack s, int i) {
    s.push(i);
  }

  public void handleUp(Stack s, int right) {
    Integer left = s.pop();
    if (left != null)
      this.merge(left, right);
  }

  public void calculateFloods() {
    Stack s = new Stack();
    for (int i = 0; i < gradients.length; i++) {
      switch(gradients[i]) {
        case "/":
          handleUp(s, i);
          break;
        case "\\":
          handleDown(s, i);
          break;
        default:
          break;
      }
    }
  }

  public void displayOutput() {
    int totalArea = this.areas.sum();
    List<Integer> areas = this.areas.toArrayList();
    Collections.reverse(areas);
    StringBuilder s = new StringBuilder(Integer.toString(areas.size()));
    for (int area : areas) {
      s.append(" " + area);
    }
    System.out.println(totalArea);
    System.out.println(s);
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String[] gradients = s.nextLine().split("");
    Main x = new Main(gradients);
    x.calculateFloods();
    x.displayOutput();
    s.close();
  }
}



Measured memory_bytes: 32004
// 23:53-
#include <iostream>
#include <numeric>

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

int main() {
  int k, n;
  std::cin >> k >> n;
  int a[n];
  rep(i, n) std::cin >> a[i];

  int max = 0;
  rep(i, n) {
    int d;
    if (i == n - 1)
      d = std::abs(a[0] - a[i]);
    else
      d = a[i + 1] - a[i];
    d = std::min(d, k - d);

    if (d > max)
      max = d;
  }

  std::cout << k - max << '\n';
  return 0;
}


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

int main() {
   int n;
   cin >> n;
   vector<int> x(n + 1);
   int min_x = 101, max_x = 0;
   for(int i = 1; i <= n; i++)
   {
     cin >> x[i];
     min_x = min(min_x, x[i]);
     max_x = max(max_x, x[i]);
   }
   int best = 1e9;
   for(int p = min_x; p <= max_x; p++)
   {
      int cur_best = 0;
      for(int i = 1; i <= n; i++)
      {
         cur_best += (x[i] - p) * (x[i] - p);
      }
      best = min(best, cur_best);
   }
  
   cout << best << endl;
   return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    string s;
    cin >> s;
    FOR(i, 0, s.size() - 1) cout << 'x';
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	bool yes=true;
	for(int i=0,ft=0,fx=0,fy=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		int X=abs(x-fx),Y=abs(y-fy),T=abs(t-ft);
		if(T<X+Y||(t-ft)%2!=(X+Y)%2)yes=false;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

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

int main(){
    int N, K,ans(0);
    cin >> N >> K;

    vector<int> count(N + 1, 0);

    for (int i = 0; i < K; ++ i){
        int d; cin >> d;
        for (int k = 0; k < d; ++ k){
            int pep; cin >> pep;
            ++ count[pep];
        }
    }

    for (auto &&x : count) ans += x == 0;
    cout << ans - 1 << endl;

    return 0;
}

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

int main (){
    vector<int> a(3);
    int d;
    cin >> a.at(0) >> a.at(1) >> a.at(2);

    sort(a.begin(), a.end());

    d = (a.at(2) - a.at(1)) + (a.at(2) - a.at(0));
    if ( d % 2 == 0 )
    {
        cout << d/2 << endl;
    }
    else
    {
        cout << d/2 + 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  vi32 A(N); cin >> A;
  i64 ans = 0;
  int sum = 0;
  for (int l = 0, r = 0; l < N; ) {
    while (r < N && sum + A[r] == (sum ^ A[r])) {
      sum += A[r];
      r++;
    }
    ans += r - l;
    sum -= A[l];
    l++;
    if (l >= r) r = l, sum = 0;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1024
/*  ex3_2
    Graku   */
#include <stdio.h>

int main(void) {
    int n; //declaration
    scanf("%d", &n);

    switch (n % 10) { //ones place == n % 10
        case 0 : printf("pon\n"); break;
        case 1 : printf("pon\n"); break;
        case 2 : printf("hon\n"); break;
        case 3 : printf("bon\n"); break;
        case 4 : printf("hon\n"); break;
        case 5 : printf("hon\n"); break;
        case 6 : printf("pon\n"); break;
        case 7 : printf("hon\n"); break;
        case 8 : printf("pon\n"); break;
        case 9 : printf("hon\n"); break;
    }

    return 0;
}

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

# 入力を各変数に格納
a, b = map(int, input().split())

ans = 0
for i in range(a, b+1):

    # 数値→文字列に
    str1 = str(i)
    # 1桁目と5桁目、2桁目と4桁目がそれぞれ同じ
    if str1[0] == str1[4] and str1[1] == str1[3]:
        ans += 1
    
    i += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[10000],N,sum=0,ma=0;cin >>N;
    rep(i,N){
        cin >> A[i];
        if(A[i]>ma){
            ma=A[i];
        }
        sum+=A[i];
    }
    cout << sum-ma/2 << endl;
}

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

int main() {
  int q; cin >> q;
  vector<vector<string>> retsu(150, vector<string>(2));
  rep(i, q) {
    cin >> retsu[i][0] >> retsu[i][1];
//    cout << retsu[i][0] << retsu[i][1] << endl;
  }
  
  rep(i, q) {
    string a_1 = retsu[i][0], a_2 = retsu[i][1];
    int b_1 = (int)a_1.size(), b_2 = (int)a_2.size();
//    cout << b_1 << b_2 << endl;
    
    int dp[b_1 + 1][b_2 + 1];
    memset(dp, 0, sizeof(dp));
    rep(j, b_1) {
      rep(k, b_2) {
        if (a_1[j] == a_2[k]) {
          dp[j+1][k+1] = dp[j][k] + 1;
        }
        else {
          dp[j+1][k+1] = max(dp[j+1][k], dp[j][k+1]);
        }
      }
    }
    
    cout << dp[b_1][b_2] << endl;
    
  }

}


Measured memory_bytes: 7056
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int N, P;
bool flag[102000];
vector<int> v;

int main() {
  REP(i,0,102000) flag[i] = true;
  for(int i = 2; i<102000; i++){
    if(!flag[i]) continue;
    v.push_back(i);
    for(int j = i*2; j<102000; j += i){
      flag[j] = false;
    }
  }

  while(1){
    cin>>N>>P;
    if(N==-1&&P==-1) break;
    int pos;
    REP(i,0,v.size()){
      if(N < v[i]){
        pos = i;
        break;
      }
    }
    vector<int> tv, nums;
    int cnt = 0;
    REP(i,pos,v.size()){
      if(cnt==100) break;
      tv.push_back(v[i]);
      cnt++;
      REP(j,0,tv.size()){
        nums.push_back(v[i]+tv[j]);
      }
    }
    sort(nums.begin(),nums.end());
    cout<<nums[P-1]<<endl;
  }

  return 0;
}

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

int N, A[200000];
int M; long long R;

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> A[i]; A[i] -= i;
  }
  sort(A, A + N); M = A[N / 2];
  for(int i = 0; i < N; ++i) {
    R += abs(M - A[i]);
  }
  cout << R << endl;
  return 0;
}

Measured memory_bytes: 1024
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    vector<int> vals;

    for(int i=0; i<3; i++){
        int v;
        cin >> v;
        vals.push_back(v);
    }

    sort(vals.begin(), vals.end());

    cout << vals[2] * 10 + vals[1] + vals[0] << endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String N = br.readLine();
		
		String[] Ns= new String[3];
		Ns = N.split(" ");
		
		int five  = 0;
		int seven = 0;
		
		if (Ns[0].equals("5") ){
			five++;
		}else if(Ns[0].equals("7")){
			seven++;
		}
		
		if (Ns[1].equals("5") ){
			five++;
		}else if(Ns[1].equals("7") && seven==0){
			seven++;
		}
		
		if (Ns[2].equals("5") && five < 2){
			five++;
		}else if(Ns[2].equals("7") && seven==0){
			seven++;
		}
		
		
		if(five==2 && seven==1){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}	
}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		str = br.readLine().split(" ");
		int a[] = new int[n];

		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
			sum += a[i];
		}

		double m4 = (double) 1 / (4 * m);
		int ans = 0;

		for (int i = 0; i < n; i++) {
			double x = (double) a[i] / sum;
			if (x >= m4) {
				ans++;
			}
			if (ans >= m) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21204
nk = input().split()
res = 0
init_probability = 1 / int(nk[0])

for i in range(int(nk[0])):
    thisRes = init_probability
    deme = i + 1
    while(1):
        if(deme >= int(nk[1])):
            break
        thisRes /= 2
        deme *= 2
    res += thisRes
print(res)


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



int main(){
  ll n; 
  cin >> n;
  vector<ll>a(n);
  for(int i=0; i<n; i++) cin >>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  ll ans=0;
  priority_queue<ll>que;
  que.push(a[1]);
  que.push(a[1]);
  ans+=a[0];
  
  for(int i=2; i<n; i++){
    ll x = que.top();
    que.pop();
    ans+=x;
    que.push(a[i]);
    que.push(a[i]);
  }
  
  cout << ans << endl;
  
}
       
        
      
  
    

Measured memory_bytes: 6936
n, m, x = list(map(int, input().split()))

c = []
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp[1:])
    c.append(tmp[0])

goal = [x] * (m)

def infer(ans):
    for i in range(m):
        if goal[i] > ans[i]:
            return False
    return True

cost = 10 ** 12
flag = False
for i in range(2**n):
    bag = [0] * (m)
    total = 0
    for j in range(n):  
        if ((i >> j) & 1):
            bag = [bag[k] + a[j][k] for k in range(m)]
            total += c[j]
    
    if infer(bag):
        cost = min(cost, total)
        flag = True
print(cost if flag else -1)

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

int main(){
    int m, n;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i] >> d[i];

    for(int i = 0; i < n; i++){
        long long min = 400000001;
        int ans = 1;
        for(int j = 0; j < m; j++){
            int ab = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(ab < min){
                ans = j + 1;
                min = ab;
            }
        }
        cout << ans << endl;
    }
    return 0; 
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())

A = list(map(int, input().split()))
A.sort()
A = A[::-1]
if N == 1 or M == 1:
    A[0] = A[0]//(2**M)
    print(sum(A))
    exit()



for i in range(N):
    A[i] *= -1

heapq.heapify(A)
m_b = M
for i in range(M):
    a = heapq.heappop(A)
    b = A[0]
    buff = a
    # mai = M-(i+1)
    c = 0
    # flag = True
    for j in range(1,m_b+1):
        c += 1
        # print('-----')
        # print(a)
        a = a / (2**(j))
        a = a*-1
        a = int(a)*-1
        # print(a, j, b)
        if a >= b:
            heapq.heappush(A, a)
            # heapq.heapify(A)
            # print(A)
            # flag = False
            break
    m_b -= c
    if m_b < 1:
        # print(A)
        # print(sum(A))
        print(sum(A)*-1)
        # print(A)
        exit()







Measured memory_bytes: 14380
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int MAX_N = 100000;
const ll MOD = 1000000007LL;
ll inv[MAX_N], fac[MAX_N], fiv[MAX_N];
void COMinit() {
    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD; // n!
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
    }
}
ll com(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * fiv[k] % MOD * fiv[n-k] % MOD;
}

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

    ll n, k;
    cin >> n >> k;

    ll red = n - k;

    COMinit();

    for (ll i = 1; i <= k; i++) {
        if (red == 0) {
            ll ans = 0;
            if (i == 1) ans = 1;
            cout << ans << "\n";
            continue;
        }

        ll blue = com(k-1, i-1);

        ll r = 0;
        r = com(red - 1, i - 1) * 2 % MOD;
        r = (r + com(red - 1, i - 2)) % MOD;
        r = (r + com(red - 1, i)) % MOD;

        cout << blue * r % MOD << "\n";
    }

    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for(int i=a; i<=b; i++){
    if( c%i == 0 ) cnt++;
  }
  cout << cnt << endl;
  return 0;
}








// EOF

Measured memory_bytes: 3088
s = input()
t = input()
minCount = len(t)
i = 0
while i < len(s) and i + len(t) <= len(s):
    countSame = 0
    j = 0
    while j < len(t):
        if t[j] == s[i+j]:
            countSame += 1
        j += 1
        minCount = min(len(t) - countSame, minCount)
    i += 1
print(minCount)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

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

  int ans = max({A + B, A - B, A * B});

  cout << ans << endl;
}

Measured memory_bytes: 256
key=list(input())

text=[]

while len(key)>0:
  t = key.pop(0)
  if t=='B' and len(text)<=0:
    pass
  elif t=='B' and len(text)>0:
    text.pop()
  elif t=='0':
    text.append('0')
  elif t=='1':
    text.append('1')
    
print(''.join(text))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1<<endl;
    return 0;
  }
  if(b==0){
    cout<<2<<endl;
    return 0;
  }
  if(c==0){
    cout<<3<<endl;
    return 0;
  }
  if(d==0){
    cout<<4<<endl;
    return 0;
  }
  if(e==0){
    cout<<5<<endl;
    return 0;
  }
}   


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll n,k;cin>>n>>k;
    vl a(n);rep(i,n)cin>>a[i];

    sort(all(a));
    ll high=LINF;
    ll low=-LINF;
    while(high-low>1){
        ll mid=(high+low)/2;
        ll cnt=0;
        rep(i,n){
            if(a[i]==0){
                if(mid>=0)cnt+=n-1;
            }else if(a[i]>0){
                ll x=mid/a[i];
                if(mid<0&&mid%a[i]!=0)x--;
                ll idx=upper_bound(all(a),x)-a.begin();
                cnt+=idx;
                if(i<idx)cnt--;
            }else{
                ll x=mid/a[i];
                if(mid<0&&mid%a[i]!=0)x++;
                ll idx=lower_bound(all(a),x)-a.begin();
                cnt+=n-idx;
                if(i>=idx)cnt--;
            }
        }
        cnt/=2;
        if(cnt<k)low=mid;
        else high=mid;
    }
    cout<<high<<endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    vector<int> ans;
    REP(i, s.size()-1){
        if(s[i] != s[i+1]) ans.pb(max(i+1, (int)s.size()-i-1));
    }
    if(ans.empty()) ans.pb(s.size());
    cout << *min_element(All(ans)) << "\n";
    return 0;
}

Measured memory_bytes: 720
n, k = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
a = [0] * (n + 1)
p.each_with_index do |x, i|
  a[i + 1] = a[i] + x
end
max = 0
(n - k + 1).times do |i|
  max = a[i + k] - a[i] if max < a[i + k] - a[i]
end
puts (max + k) / 2.0

Measured memory_bytes: 28360
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

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

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll x[100005];
ll y[100005];

ll g(ll a, ll b)
{
	if (a < b)
	{
		swap(a, b);
	}
	ll c = a%b;
	if (c == 0)return b;
	return g(b, c);
}

int main()
{
	ll N, X;
	cin >> N >> X;
	REP(i, N)
	{
		cin >> x[i];
		y[i] = abs(x[i] - X);
	}

	ll ans = y[0];
	REP(i, N)
	{
		ans = g(ans, y[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(sc.nextInt())(sc.nextLong())
  val (_, sum) = xs.foldLeft((x, 0L)) {
    case ((l, acc), r) => (l.max(r), acc + (l - r).max(0L))
  }
  println(sum)
}


Measured memory_bytes: 69360
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,ans=INF;
    cin>>n;
    vi x(n);
    rep(i,n) cin>>x[i];
    rep(i,100){
        lli now=0;
        rep(j,n){
            now+=pow(x[j]-i,2);
        }
        ans=min(ans,now);
    }
    out(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4893435
using namespace std;
char a[p];
int main()
{
	scanf("%s",a+1);
	int len=strlen(a+1);
	int ans=0,ss=0;
	for(fint i=1;i<=len;i++)
	{
		if(a[i]=='R')
		ss++;
		if(a[i]=='S')
		ans=max(ans,ss),ss=0;
	}
	ans=max(ans,ss);
	cout<<ans;
	return 0;
} 

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

int main() {
	string s;
	cin >>s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
		cout <<"Yes";
	}
	else{
		cout <<"No";
	}
	
}

Measured memory_bytes: 256
n = int(input())
L = [int(x) for x in input().split()]
L.sort()
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if L[i] != L[j] != L[k]:
                if L[i] + L[j] > L[k]:
                    ans += 1

print(ans)


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

using namespace std;

int main() {
  int n;
  double x[40],sum = 0;
  string u[40];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> x[i] >> u[i];

  for(int i = 0; i < n; i++) {
    if(u[i] == "JPY") sum += x[i];
    else sum += (380000.0 * x[i]);
  }

  cout << sum << endl;
}

Measured memory_bytes: 3828
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (X == 500 * i + 100 * j + 50 * k):
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> g(3*N);
    Rep (i, M) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        g[3*u].push_back(3*v+1);
        g[3*u+1].push_back(3*v+2);
        g[3*u+2].push_back(3*v);
    }
    ll S, T;
    cin >> S >> T;
    S--; T--;

    vector<ll> dist(3*N, -1);
    dist[3*S] = 0;
    queue<ll> q;
    q.push(3*S);
    while (!q.empty()) {
        ll now = q.front();
        q.pop();
        for (ll e : g[now]) {
            if (dist[e] > -1) continue;
            dist[e] = dist[now] + 1;
            q.push(e);
        }
    }

    if (dist[3*T] == -1) dist[3*T] *= 3;

    cout << dist[3*T] / 3 << "\n";
}

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

using namespace std;

using ll = long long;
typedef vector<vector<ll> > Matrix; //隣接行列

const ll INF = 1e15;

Matrix dist;

//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

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

    dist.resize(n, vector<ll>(n, INF));
    for (int i = 0; i < m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }

    warshall_floyd(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (dist[i][j] > L) dist[i][j] = INF;
            else dist[i][j] = 1;
        }
    }

    warshall_floyd(n);
    
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (dist[s][t] >= INF ? -1 : dist[s][t] - 1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;

int main() {
long long A;
cin>>A;
float B;
cin>>B;
B=B*(100);
//cout<<B<<" B\n";
long long C=(long long)round(B);
//cout<<C<<" C\n";
long long ans=(A)*C;
//cout<<ans<<endl;
ans=ans/100;
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,i,now;
signed main() {
    scanf("%d",&n);
    while(i<=10000000)
    {
        i++;
        now=(now*10+7)%n;
        if(now==0)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int D;
	cin >> D;
	cout << "Christmas";
	int N = 25 - D;
	REP(i, N) {
		cout << " Eve";
	}
	cout << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 896
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,N,X;

    long double x;

    string S,T;

    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;

    vector<ll> aa, bb, hh, ff;

    cin >>S>>T;

    rep(i,S.length()){
        if(S[i]!=T[i]){
            cout<<"No"<<endl;
        return 0;
        }
    }



    cout<<"Yes"<<endl;


    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

struct Dice
{
  int c[6];
  void rot(int type){
    char newc[6];
    if( type == 0 ){ // front
      newc[2]=c[2];newc[3]=c[3];
      newc[0]=c[1];newc[1]=c[5];newc[4]=c[0];newc[5]=c[4];
    }
    if( type == 1 ){ // right
      newc[1]=c[1];newc[4]=c[4];
      newc[0]=c[3];newc[2]=c[0];newc[3]=c[5];newc[5]=c[2];
    }
    if( type == 2 ){ // hor
      newc[0]=c[0];newc[5]=c[5];
      newc[1]=c[2];newc[2]=c[4];newc[3]=c[1];newc[4]=c[3];
    }
    for(int i = 0; i < 6; ++i)c[i]=newc[i];
  }
  bool samePattern(Dice d)const{
    const int rots[] = {0,0,0,1,1,1, 1};
    for(int i = 0; i < sizeof(rots)/sizeof(*rots);++i){
      for(int j = 0; j < 4; ++j){
	if( same(d) ) return true;
	d.rot(2);
      }
      d.rot( rots[i] );
    }
    return false;
  }
  bool same(const Dice &d)const{
    for(int i = 0; i < 6; ++i){
      if( c[i] != d.c[i] ) return false;
    }
    return true;
  }
};
int main()
{
  while(true){
    int n;
    int ans = 0;
    cin >> n;
    if( n == 0 )break;
    Dice dice[n];
    bool inv[n];
    fill(inv,inv+n,false);
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < 6; ++j){
	string s;
	cin >> s;
	if( s == "Cyan" )    dice[i].c[j]=0;
	if( s == "Yellow" )  dice[i].c[j]=1;
	if( s == "Red" )     dice[i].c[j]=2;
	if( s == "Magenta" ) dice[i].c[j]=3;
	if( s == "Green" )   dice[i].c[j]=4;
	if( s == "Blue" )    dice[i].c[j]=5;
      }
    }
   

    for(int i = 0; i < n; ++i){
      if( !inv[i] ){
	for(int j = i+1; j < n; ++j){
	  if( !inv[j] ){
	    if( dice[i].samePattern( dice[j] ) ){
	      inv[j]=true;
	    }
	  }
	}
      }
    }
    for(int i = 0; i < n; ++i){
      if( inv[i] ){
	++ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
  int b;
  int c;
  int d;
  int r;
  int l;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  l = a + b;
  r = c + d;
 if (r > l ) { cout << "Right" << endl;}
  if (r < l ) { cout << "Left" << endl; }
  if ( r == l ) { cout << "Balanced" << endl; }
} 

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int taka = (c + b - 1)/b;
    int aoki = (a + d - 1)/d;
    if(taka <= aoki) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

Measured memory_bytes: 3636
// ABC175B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i +1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L[i] != L[j] &&
				    L[j] != L[k] &&
				    L[k] < L[i] + L[j]) {
					++ans;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_V (105)
#define INF (1LL << 32)

int V, E;
ll G[MAX_V][MAX_V];

int main()
{
    scanf("%d %d", &V, &E);

    // ??£??\??????????????????
    for ( int i = 0; i < V; i++ ) {
	for ( int j = 0; j < V; j++ ) {
	    G[i][j] = (i == j) ? 0 : INF;
	}
    }

    for ( int i = 0; i < E; i++ ) {
	int s, t, d;
	scanf("%d %d %d", &s, &t, &d);
	G[s][t] = d;
    }

    for ( int k = 0; k < V; k++ ) {
	for ( int i = 0; i < V; i++ ) {
	    if ( G[i][k] == INF ) continue;
	    for ( int j = 0; j < V; j++ ) {
		if ( G[k][j] == INF ) continue;
		G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
	    }
	}
    }

    for ( int i = 0; i < V; i++ ) {
	if ( G[i][i] < 0 ) {
	    printf("NEGATIVE CYCLE\n");
	    return 0;
	}
    }

    for ( int i = 0; i < V; i++ ) { 
	for ( int j = 0; j < V; j++ ) {
	    if ( G[i][j] == INF ) {
		printf("INF%c", (j == V-1) ? '\n' : ' ');
	    }
	    else {
		printf("%lld%c", G[i][j], (j == V-1) ? '\n' : ' ');
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    int hoge = x - (k-1);
    rep(i,0,k*2-2){
        cout<<hoge<<" ";
        hoge++;
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,s;
int main()
{
   cin>>a>>b;
   s=1;
   for(int i=a; i<=b; i++)
   {
		if(i==0)
		{
			cout<<"Zero"<<endl;
			return 0;
		}
		if(i<0)
			s*=-1;
   }
   if(s==1)
		cout<<"Positive"<<endl;
    else
		cout<<"Negative"<<endl; 
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <random>

using namespace std; 

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int n = b * 10 + c;
	if (n % 4 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

struct SegTree{
    int n; vector<ll> dat;
    //初期化
    SegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,INF);
    }
    //k番目(0-indexed)の値をaに変更
    void update(int k, ll a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }
    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return INF;

        if(a<=l && r<=b) return dat[k];

        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
    //[a,b)の最大値を求める
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};


ll calc(const vector<ll> &a){
    int n = a.size();

    vector<ll> suf(n+1);
    for(int i=n-1; i>=0; --i) suf[i] = suf[i+1] + a[i];

    SegTree st(n+4);

    int ev = 0;
    rep(i,n){
        st.update(i,suf[i+1]+ev);
        if(a[i]%2==0) ++ev;
    }

    dbg(a);

    ll ret = INF;

    ll pre = 0;
    ll sub = 0;
    rep(i,n){
        ll mv = st.query(i,n+1);

        printf("%d: %lld + %lld - %lld\n",i,mv,pre,sub);
        ret = min(ret, mv+pre-sub);

        pre += a[i];
        if(a[i]%2==0) ++sub;
    }

    return ret;
}

int main(){
    int n;
    cin >>n;
    vector<ll> a(n);
    rep(i,n) cin >>a[i];

    vector<ll> e(n+1);
    rep(i,n){
        if(a[i]==0) e[i] = 2;
        else if(a[i]%2==1) e[i] = 1;
    }
    rep(i,n) e[i+1] += e[i];

    auto EV = [&](int r){
        if(r==0) return 0LL;
        return e[r-1];
    };

    vector<ll> o(n+1);
    rep(i,n){
        if(a[i]%2==0) o[i]++;
    }
    rep(i,n) o[i+1] += o[i];

    auto OD = [&](int r){
        if(r==0) return 0LL;
        return o[r-1];
    };

    vector<ll> dp(n+1,0);
    ll s = 0;
    rep(i,n){
        s += a[i];
        dp[i+1] = s;
    }
    // dbg(dp);

    // ev | od
    vector<ll> nx(n+1,INF);
    ll val = INF;
    rep(i,n+1){
        val = min(val, dp[i]-EV(i));
        nx[i] = min(nx[i], val+EV(i));
    }
    dp = nx;
    // dbg(dp);

    // od | ev
    nx = vector<ll>(n+1,INF);
    val = INF;
    rep(i,n+1){
        val = min(val, dp[i]-OD(i));
        nx[i] = min(nx[i], val+OD(i));
    }
    dp = nx;

    // ev | od
    nx = vector<ll>(n+1,INF);
    val = INF;
    rep(i,n+1){
        val = min(val, dp[i]-EV(i));
        nx[i] = min(nx[i], val+EV(i));
    }
    dp = nx;

    ll ans = INF;
    s = 0;
    for(int i=n; i>=0; --i){
        ans = min(ans, dp[i]+s);
        if(i>0) s += a[i-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600