akhauriyash/Code-Regression huggingface dataset:
using System;

namespace D___Candidates_of_No_Shortest_Paths
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var N = read[0];
            var M = read[1];

            //2次元配列に辺と重さを記録
            var edges = new int[M,3];
            for(int i = 0 ; i < M ; i++)
            {
                read = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
                edges[i,0] = read[0];
                edges[i,1] = read[1];
                edges[i,2] = read[2];
            }

            //2次元配列に各頂点間の最短距離を記録
            var costs = new int[N+1,N+1];
            for(int i = 1 ; i < N+1 ; i++) for(int j = 1 ; j < N+1 ; j++) costs[i,j] = 1000000000;
            for(int i = 1 ; i < N+1 ; i++) costs[i,i] = 0;

            for(int i = 0 ; i < M ; i++)
            {
                costs[edges[i,0],edges[i,1]] = edges[i,2];
                costs[edges[i,1],edges[i,0]] = edges[i,2];
            }

            //Warshall-Floyd法で全ての頂点間の最短距離求める
            for(int via = 1 ; via < N+1 ; via++)
                for(int from = 1 ; from < N+1 ; from++)
                    for(int to = 1 ; to < N+1 ; to++) 
                        costs[from,to] = Math.Min(costs[from,to],costs[from,via]+costs[via,to]);

            //各辺の距離と両端の頂点間の最短距離を比較し、辺の距離のほうが長いものの数を出力
            var result = 0;
            for(int i = 0 ; i < M ; i++) if(costs[edges[i,0],edges[i,1]] != edges[i,2]) result++;

            Console.WriteLine(result);
            

        }
    }
}


Measured memory_bytes: 13140
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  
  if(n==m)
    cout << "Yes";
  else
    cout << "No";

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



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int H,W;
    int i=0;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int n=1;n<=H;n++){
            for(int i=1;i<=W;i++){
                if(n==1){
                    cout<<"#";
                }
                 else if(n==H){
                    cout<<"#";
                }
                else{
                    if(i==1){
                        cout<<"#";
                    }
                    else if(i==W){
                        cout<<"#";
                    }
                    else{
                        cout<<".";
                    }
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll k,n;
    cin >> k >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    vector<ll> b(n);
    rep(i,n){
        if(i!=n-1){
            b[i]=a[i+1]-a[i];
        }
        else{
            b[i]=k-a[i]+a[0];
        }
    }
    sort(all(b));
    ll sum=0;
    rep(i,n-1)sum+=b[i];
    cout << sum;


}

/*



 */



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

void solve(int N, std::vector<int> L) 
{
  std::sort(L.begin(), L.end());
  int count = 0;
  for (int i = 0; i < N-2; i++)
  {
    int a = L[i]; 
    for(int j = i+1; j < N-1;j++)
    {
      int b = L[j];
      for (int k = j+1; k < N; k++)
      {
        int c = L[k];
        if(b < c + a && c < a + b)
        {
          count +=1;
        }
      }
    }
  }
  std::cout << count << std::endl;
  
}

int main(void) 
{
  int N;
  std::cin >> N;
  std::vector<int> L(N);
  for(auto i0 = 0; i0 < N; ++i0)
  {
    std::cin >> L[i0];
  }
  solve(N,L);
  return 0;
}

Measured memory_bytes: 384
n = int(input())
for i in range(2**n):
    if i == 0:
        print("0:")
        continue
    else:
        print("{}: ".format(i), end="")
    l = []
    for j in range(n):
        if i & (1 << j) != 0:
            l.append(j)
    print(*l)


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

unsigned long long rec(unsigned long long l)
{
    if (l == 1)
    {
        return 1;
    }
    return 1 + 2 * rec(l/2);
}

int main()
{
    unsigned long long l;
    scanf("%llu", &l);
    printf("%llu\n", rec(l));
    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
enum inf = 10^^9;

void main() {
    int n, k;
    scan(n, k);
    auto a = readln.split.to!(long[]);

    auto ac = new long[](n + 1);
    foreach (i ; 1 .. n + 1) {
        ac[i] = ac[i-1] + a[i-1];
    }

    long[] b;

    foreach (i ; 0 .. n) {
        foreach (j ; i + 1 .. n + 1) {
            b ~= ac[j] - ac[i];
        }
    }

    long ans;

    for (int r = 63; r >= 0; r--) {
        long[] bt, bf;

        foreach (bi ; b) {
            if (bi & (1L<<r)) {
                bt ~= bi;
            }
            else {
                bf ~= bi;
            }
        }

        if (bt.length < k) {
            continue;
        }

        ans += (1L<<r);
        b = bt;
    }

    writeln(ans);
}





























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 24572
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n : u64 = read();
    let mut v = read_vec::<u64>();
    v.sort();
    let ans = v.last().unwrap() -v[0];
    println!("{}",ans );
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 998244353L;
template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline T MaxE(vector<T>& v, ll S, ll E) { T m = v[S]; for (ll i = S; i <= E; i++)chmax(m, v[i]); return m; }//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T>& v, ll S, ll E) { T m = v[S]; for (ll i = S; i <= E; i++)chmin(m, v[i]); return m; }
template<class T> inline T MaxE(vector<T>& v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T>& v, ll N) { return MinE(v, 0, N - 1); } //先頭N個中の最小値
template<class T> inline T MaxE(vector<T>& v) { T m = v[0]; for (T e : v)chmax(m, e); return m; }
template<class T> inline T MinE(vector<T>& v) { T m = v[0]; for (T e : v)chmin(m, e); return m; }


void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}

int main()
{
	ll N, W;
	cin >> N >> W;
	lls w(N), v(N);
	for (ll i = 0; i < N; i++) {
		ll ww, vv;
		cin >> ww >> vv;
		w[i] = ww;
		v[i] = vv;
	}

	//テーブル初期化
	ll i_ = 1;
	ll Vmax = N * 1000;
	std::vector<lls> tblAll(N + i_, lls(Vmax + 1 + 1000, INF));



	tblAll[-1 + i_][0] = 0;
	
	//配るDPで計算
	for (ll i = 0; i < N; i++) { //荷物i
		for (ll vv = 0; vv <= Vmax; vv++) {
			//荷物iを選ばない
			chmin(tblAll[i + i_][vv], tblAll[i - 1 + i_][vv]);
			//荷物iを選ぶ
			chmin(tblAll[i + i_][vv + v[i]], tblAll[i - 1 + i_][vv] + w[i]);
		}
	}

	//結果取り出し
	ll vRet;
	for (ll vv = Vmax; vv >= 0; vv--) {
		if (tblAll[N - 1 + i_][vv] <= W) {
			vRet = vv;
			break;
		}
	}

	cout << vRet << '\n';

	return 0;
}


Measured memory_bytes: 81024
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> S(N),T(M);
    rep(i,N) cin >> S[i];
    rep(i,M) cin >> T[i];

    vector<vector<mint>> dp(N+1, vector<mint>(M+1));
    rep(i,N+1) dp[i][0] = 1;
    rep(i,M+1) dp[0][i] = 1;
    rep(i,N) {
        rep(j,M) {
            if (S[i] == T[j]) {
                dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
            } else {
                dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] - dp[i][j];
            }
        }
    }

    cout << dp[N][M].a << ln;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  int ans = 0;
  for(int i=0; i<N/2; i++){
    ans += (a.at(N-1-2*i) - a.at(N-1-2*i-1));
  }
  if(N % 2 == 1){
    ans += a.at(0);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
m=0
f=0
r=0
while True:
    m,f,r=map(int,input().split())
    s=m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    elif s>=80:
        print("A")
    elif 80>s>=65:
        print("B")
    elif 65>s>=50:
        print("C")
    elif 50>s>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7584
def main():
    n, k, q, *al = map(int, open(0).read().split())
    gl = [0] * n
    for a in al:
        gl[a-1] += 1

    res = '\n'.join(
        'Yes' if g > q-k
        else 'No'
        for g in gl
    )
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int MOD = 1000000007;

ll mod_pow(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b & 1) return (a * mod_pow(a, b - 1, p)) % p;
    ll t = mod_pow(a, b / 2, p);
    return (t * t) % p;
}

ll comb(ll n, ll r, ll p) {
    ll tn = 1, tr = 1;
    for (int i = n; i > n - r; i--) {
        tn *= i;
        tn %= p;
    }
    for (int i = r; i > 0; i--) {
        tr *= i;
        tr %= p;
    }
    return tn * mod_pow(tr, p - 2, p) % p;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = mod_pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD);
    if (ans < 0) ans += MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int ary[50];
int main(void)
{
	int n,m,i,a,b;
	scanf("%d%d",&n,&m);
	FOR(i,0,m){
		scanf("%d%d",&a,&b);
		ary[a-1]++,ary[b-1]++;
	}
	FOR(i,0,n) printf("%d\n",ary[i]);
	return 0;
}
    

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr clear
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define len(s) (s).length()

int main(int argc, char const *argv[])
{
	crap;
	ll n,m;
	cin>>n>>m;

	if (m%n==0)
	{
		cout<<(m/n);
		return 0;
	}
    vi f;

	F(i,1,sqrt(m))
	{
		if (m%i==0)
		{
			f.pb(i);
			if (i*i!=m)
				f.pb(m/i);
		}
	}
	sort(all(f));
	ll tos=ceil(m/n);
	ll id=upper_bound(all(f),tos)-f.begin();
	id--;
	cout<<f[id];

	return 0;
}

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

/**
 * Created by Ayushi on 25 Jul 2020.
 * Problem:
 * Round:
 */

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

        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine(), " ");
        int[] a = new int[n];
        int j = 0;
        while (st.hasMoreTokens()) {
            a[j] = Integer.parseInt(st.nextToken());
            j++;
        }
        br.close();

        for (int i = k; i < n; i++) {
            if (a[i] > a[i-k]) System.out.println("Yes");
            else System.out.println("No");
        }
    }
}


Measured memory_bytes: 58732
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;
char S[MAX_N];

int main() {
  scanf("%s", S + 1);
  int N = strlen(S + 1), result = 0;

  result = (N + 1) / 2;
  
  for (int i = result + 1; i <= N; ++i) {
    if (S[i] == S[N - i + 1] && S[i] == S[i - 1]) {
      result = i;
    } else {
      break;
    }
  }

  printf("%d\n", result);
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  int a=0;
  for (int i=0;i<3;i++) {
    if(S.at(i)==S.at(i+1)) {
      a++;
    }
  }
  if(a==0) {
    cout << "Good" << endl;
  }
  else if (a > 0) {
    cout << "Bad" << endl;
  }
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
	string s;
	cin >> s;
	rep(i, 0, sz(s)) if (s[i] == ',') s[i] = ' ';
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N], b[N];
int n, w;
ll mem[100][N];
int oo = 0x3f3f3f3f;
ll solve(int i, int rem){
    if(rem <= 0)
        return 0;
    if(i == n)
        return oo;
    ll &ret = mem[i][rem];
    if(~ret)
        return ret;
    return ret = min(solve(i+1, rem), solve(i+1, rem-b[i]) + a[i]);
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n>>w;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i];
    for(int i=1e5; i>=0; i--){
        if(solve(0, i) <= w)
            return cout<<i<<'\n', 0;
    }
}

Measured memory_bytes: 81792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>


using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<tuple<string, int, int>> vec;
	rep(i, 1, n)
	{
		string s;
		int p;
		cin >> s >> p;
		p = -p;
		vec.push_back(tie(s, p, i));
	}
	sort(all(vec));
	rep(i, 0, n - 1)
	{
		cout << get<2>(vec[i]) << endl;
	}
}

Measured memory_bytes: 256
import os
import sys

if os.getenv('LOCAL'):
    sys.stdin = open('_in.txt', 'r')

sys.setrecursionlimit(2147483647)
INF = float('inf')

S = sys.stdin.readline().rstrip()

a = 0
ans = 0
i = 0
while i < len(S):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if i + 1 < len(S) and S[i + 1] == 'C':
            i += 1
            ans += a
        else:
            a = 0
    else:
        a = 0
    i += 1
print(ans)


Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int x,y;cin >> x >> y;
  if((x+y)&1 == 1) cout << (x+y)/2+1 << endl;
  else cout << (x+y)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int w[1000][1000];
int b[1000][1000];
int rt[1001][1001];
int rb[1001][1001];
int lt[1001][1001];
int lb[1001][1001];
int main() {
	ios_base::sync_with_stdio(false);
	int n,k,x[200000],y[200000];
	char c[200000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>c[i];
		x[i]=x[i]%(2*k);
		y[i]=y[i]%(2*k);
		int l=0;
		if(x[i]>=k){
			l++;
		}
		if(y[i]>=k){
			l++;
		}
		x[i]=x[i]%k;
		y[i]=y[i]%k;
		if(l%2==1){
			if(c[i]=='B')
				w[x[i]][y[i]]++;
			else
				b[x[i]][y[i]]++;
		}
		else{
			if(c[i]=='B')
				b[x[i]][y[i]]++;
			else
				w[x[i]][y[i]]++;
		}
	}
	/*for(int i=0;i<k;i++){
		for(int j=0;j<k;j++){
			cout<<b[i][j]<<" ";
		}	
	}*/
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			lb[i][j]=lb[i-1][j]+lb[i][j-1]-lb[i-1][j-1]+b[i-1][j-1];	
		}	
	}
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			rt[k-i][k-j]=rt[k-i+1][k-j]+rt[k-i][k-j+1]-rt[k-i+1][k-j+1]+b[k-i][k-j];	
		}
	}
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			lt[i][k-j]=lt[i-1][k-j]+lt[i][k-j+1]-lt[i-1][k-j+1]+w[i-1][k-j];	
		}
	}
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			rb[k-i][j]=rb[k-i+1][j]+rb[k-i][j-1]-rb[k-i+1][j-1]+w[k-i][j-1];	
		}
	}
	int max=0;
	for(int i=0;i<k;i++){
		for(int j=0;j<k;j++){
			int h=rt[i][j]+rb[i][j]+lt[i][j]+lb[i][j];
			if(h>max){
				max=h;
		//		cout<<"lol"<<max<<" "<<i<<" "<<j<<" "<<rt[i][j]<<" "<<rb[i][j]<<" "<<lt[i][j]<<" "<<lb[i][j]<<endl;
			}
			if(n-h>max){
				max=n-h;
		//		cout<<"kek"<<max<<" "<<i<<" "<<j<<" "<<rt[i][j]<<" "<<rb[i][j]<<" "<<lt[i][j]<<" "<<lb[i][j]<<endl;
			}
		}
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 24576
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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 COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;
  cin>>a>>b;
  ll tmp=GCD(a,b);
  vector<pint> v=prime_factorize(tmp);
  cout<<v.size()+1<<endl;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define N 505
const int dir[4][2] = {{1, 0}, {0, 1}, {0, -1}, {-1, 0}};
int n, a[N * N], v[N * N];
int d[N][N];
bool vis[N][N];
ll ans = 0;
int Idx(int x, int y) { return (x - 1) * n + y; }
void Bfs(int sx, int sy)
{
	int now = v[ Idx(sx, sy) ];
	queue<pii> q;
	q.push( mp(sx, sy) );
	while(!q.empty())
	{
		int x = q.front().first, y = q.front().second; q.pop();
		vis[x][y] = 0;
		for(int i = 0; i < 4; i++)
		{
			int nx = x + dir[i][0], ny = y + dir[i][1];
			if(nx < 1 || nx > n || ny < 1 || ny > n) continue;
			int t = v[ Idx(x, y) ] > now;
			if(d[x][y] + t < d[nx][ny])
			{
				d[nx][ny] = d[x][y] + t;
				if (!vis[nx][ny])
					vis[nx][ny] = 1, q.push( mp(nx, ny) );
			}
		}
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n * n; i++)
		scanf("%d", &a[i]), v[ a[i] ] = i;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			d[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
	for(int i = 1; i <= n * n; i++)
	{
		int x = (a[i] - 1) / n + 1, y = a[i] - (x - 1) * n;
		ans += d[x][y];
		Bfs(x, y);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));
/*
void call(n){
    int i=1;
    CHECK_NUM:
        int x=i;
        if(x%3==0){
            cout << " " << i;
            goto END_CHECK_NUM;
        }
    INCLUDE3:
        if(x%10==3){

        }
}*/

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

    int x=0;
    for(int i=1;i<=n;++i){
        x=i;
        if(x%3==0){
            cout << " " << i;
        }else{
            while(x>0){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x=x/10;
            }
        }
    }cout << endl;
    

    return 0;
}


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


int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              //add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                              new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                              //new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define N ((ll)2e6+10)
#define pb push_back
#define in insert
#define F first
#define S second
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int sv[1000000]={0};
//ll factorialNumInverse[N + 1];
//ll naturalNumInverse[N + 1];
//ll fact[N + 1];
//void InverseofNumber(ll p){naturalNumInverse[0] = naturalNumInverse[1] = 1;for (ll i = 2; i <= N; i++)naturalNumInverse[i]=naturalNumInverse[p % i] * (mod - mod / i) % mod;}
//void InverseofFactorial(ll p){factorialNumInverse[0] = factorialNumInverse[1] = 1;for (ll i = 2; i <= N; i++)factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;}
//void factorial(ll p){fact[0] = 1;for (ll i = 1; i <= N; i++) {fact[i] = (fact[i - 1] * i) % mod;}}
//ll Binomial(ll n, ll R){ll ans = ((fact[n] * factorialNumInverse[R])%mod * (factorialNumInverse[n - R])%mod)% mod;return ans;}
///*TOIENT FUNCTION*/ll phi(ll n){ll ans=n;for(ll i=2;i*i<=n;i++){if(n%i==0){while(n%i==0) n/=i;ans-=ans/i;}}if(n>1) ans-=ans/n;return ans;}
ll mini=1000000000;

using namespace std;

int main(){
    speed
//    InverseofNumber(mod);
//    InverseofFactorial(mod);
//    factorial(mod);
    ll a,b,c,d,e,n;
    cin>>a>>b>>c>>n;
    ll ans=0;
    if(n>=a){
        ans+=(a);
        n-=a;
    }
    else{ ans=n;
        n=0;
    }
    if(n>=b){
        n-=b;
    }
    else{
        n=0;
    }
    if(n>=c){
        ans-=c;
    }
    else{
        ans-=n;
    }
    cout<<ans;
}


Measured memory_bytes: 3648
import heapq as hq
N, K = map(int, input().split())
A = list(map(int,input().split()))
A.sort()
F = list(map(int,input().split()))
F.sort()

if sum(A) <= K:
	print(0)
	exit()
ans = max([A[i]*F[N-1-i] for i in range(N)])

def achievable(score):
	cnt = 0
	for i in range(N):
		a,f = A[i], F[N-1-i]
		if a*f > score:
			n = score // f
			cnt += a-n
			if cnt > K:
				return False
	return True

l,r = 0, ans
while r - l > 1:
	p = (l + r) // 2
	if achievable(p):
		r = p
	else:
		l = p
print(r)

Measured memory_bytes: 119884
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

string s;

int main(){

    cin >> s;

    cout << s[0] << s.length()-2 << s[s.length()-1];




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	int n;
	cin >> n;
	int s = 0;
	rep(i, n) {
		int x;
		cin >> x;
		s += (x-1);
	}
	cout << s << endl;

	return 0;
}

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

int main() {
	string s,k = "Yes";
	cin >> s;
	set<char>d={s.at(0),s.at(1),s.at(2)};
	if(d.size() < 3)
	{
		k = "No";
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()

slist = []
s = ''
for i in range(len(S)):
    if S[i] in 'ATGC':
        s += S[i]
    else:
        slist.append(s)
        s = ''
if S[-1] in 'ATGC':
    slist.append(s)

lenlist = [len(slist[i]) for i in range(len(slist))]
print(max(lenlist))


Measured memory_bytes: 3060
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;cin>>a>>b;
	cout<<a*b<<endl;

	return 0;
} 

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
   int N,X,m[101];
   cin >> N>> X;
   int mi=1001,cnt=0;


   for(int i=0;i<N;i++){
      cin>>m[i];
      X -=m[i];
      mi = min({mi,m[i]});
      cnt++;
   }

   while(X-mi>=0){
      X-=mi;
      cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}
         


Measured memory_bytes: 256
int main(){
  int a,b;
  double f;
 
 

  scanf("%d %d",&a,&b);
  if(a<1 | b>1000000000){
    printf("error\n");
  }
 
  printf("%d %d %f\n",a/b,a%b,1.0*a/b);
  return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

ll n,sum;
ll d[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
		sum += d[i];
	}	

	sum = sum * sum;

	for (int i = 0; i < n; ++i)
		sum -= d[i]*d[i];

	cout <<fixed<< sum/2 << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    auto s = readln.chomp.to!(char[]);

    long ans;

    while (!s.empty) {
        if (s.length == 1) break;
        if (s.front == s.back) {
            s.popFront();
            s.popBack();
        }
        else if (s.front == 'x') {
            ans++;
            s.popFront();
        }
        else if (s.back == 'x') {
            ans++;
            s.popBack();
        }
        else {
            writeln(-1);
            return;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2588
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN =  100 * 1000 + 10;
const int MLOG = 18;
const int NMAX = 20;

struct fen{
	int fn[MAXN];
	
	void add(int idx, int val){
		for (idx++; idx < MAXN; idx += idx & -idx)
			fn[idx] += val;
	}

	void addr(int l, int r, int val = 1){
		add(l, val);
		add(r + 1, -val);
	}

	int ansq(int idx){
		int ans = 0;
		for (idx++; idx > 0; idx -= idx & -idx)
			ans += fn[idx];
		return ans;
	}
}me;

signed main(){
	IO;
	int n, m;
	cin >> n >> m;
	int seg[n][2];
	vector<pair<int, int>> vc[3 * MAXN];
	for(int i = 0; i < n; i++){
   		cin >> seg[i][0] >> seg[i][1];
		vc[seg[i][1] - seg[i][0] + 1].pb({seg[i][0], seg[i][1]});
	}
	int x = 0;
	for(int i = 1; i <= m; i++){
		int ans = 0;
		for(int j = 0; j < sz(vc[i]); j++){
			me.addr(vc[i][j].X, vc[i][j].Y);
			x++;
		}
		for(int j = i; j <= m; j += i){
			ans += me.ansq(j);
		}
		cout << ans + n - x << endl;
	}
}

Measured memory_bytes: 20608
N, M=map(int, input().split())
a=list(map(int, input().split()))
a.sort()

card=[]

for i in range(M):
    b, c=map(int, input().split())
    card.append((c, b))

card.sort(reverse=True)
k=0
for c, b in card:
    while k < N and b > 0:
        if a[k]<c:
            a[k]=c
            b-=1
        k+=1

print(sum(a))

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

int main(){
    double w, h;
    cin >> w >> h;
    double x, y;
    cin >> x >> y;

    int flag = 0;

    double ans = w * h / 2;

    if(x==w/2 && y==h/2) flag = 1;

    printf("%.10lf %d", ans, flag);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll n = 0;
    rep(i,N){
        cin >> vec[i];
        chmax(n,vec[i]);
    }
    ll m = 0,cnt = INF;
    rep(i,N){
        if(abs(vec[i] - n / 2) < cnt && vec[i] != n){
            cnt = abs(vec[i] - n / 2);
            m = vec[i];
        }
    }
    cout << n << " " << m << endl;
}

Measured memory_bytes: 3988
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main() {
	int N,L;
	cin >> N >> L;
	vector<pair<int,int> > PD(N);
	int i;
	for(i=0;i<N;i++)cin >> PD[i].first >> PD[i].second;
	sort(PD.begin(),PD.end());
	vector<int> cntR(N+1),cntL(N+1);
	cntR[0] = cntL[0] = 0;
	for(i=0;i<N;i++) {
		cntR[i+1] = cntR[i] + PD[i].second;
		cntL[i+1] = cntL[i] + 1-PD[N-i-1].second;
	}
	int point = 0;
	for(i=1;i<=N;i++)if(cntR[i]+cntL[N-i] < cntR[point]+cntL[N-point])point = i;
	long long ans = 0;
	for(i=0;i<point;i++)ans += (PD[i].first-i-1)*(PD[i].second == 0?1:-1);
	for(i=N-1;i>=point;i--)ans += (L-(N-i-1)-PD[i].first)*(PD[i].second == 1?1:-1);
	cout << ans << endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;

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

    long long int ans = a[0]+a[n-2];
    for(int i=1; i<n-1; i++){
        ans += min(a[i], a[i-1]);
    }

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
/*===============================================================
*  Filename：d.cpp
*  Author：zhuyutian
*  Date：2017年08月06日
================================================================*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int maxn = 10005;

int h,w,n;
int a[maxn];
int g[105][105];

int main()
{
    //freopen("d.in","r",stdin);
    //freopen("d.out","w",stdout);
 	scanf("%d%d%d",&h,&w,&n);
	for(int i = 1; i <= n; i++) scanf("%d",a + i);
	int r = 1,c = 1;
	int d = 1;
	for(int i = 1; i <= n; i++)
	{
		while(a[i]--)
		{
			g[r][c] = i;
			c += d;
			if(c > w) 
			{
				r++;
				c = w;
				d = -1;
			}
			if(c < 1)
			{
				r++;
				c = 1;
				d = 1;
			}
		}
	}
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
			printf("%d ",g[i][j]);
		printf("\n");
	}
 	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a!=5 && a!=7) cout << "NO" << endl;
    if(a==5){
        if(b==5){
            if(c==7) cout << "YES" << endl;
            else cout << "NO" <<endl;
        }
        if(b==7){
            if(c==5) cout << "YES" << endl;
            else cout << "NO" <<endl; 
        }
        if(b!=5 && b!=7) cout << "NO" << endl;
    }
    if(a==7){
        if(b==5){
            if(c==5) cout << "YES" <<endl;
            else cout << "NO" <<endl;
        }
        else cout << "NO" <<endl;
    }
}


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


signed main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    if(k % 2 == 0){
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v=new int[n];
        for(int i=0;i<n;i++){
          v[i]= sc.nextInt();
        }
        int[] c=new int[n];
        int sum=0;
        for(int i=0;i<n;i++){
          c[i]= v[i]-sc.nextInt();
          sum+=c[i]>=0?c[i]:0;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22740
n, k =map(int, input().split())  #複数数値入力
d = []
a = []
for i in range(k):
    d.append(int(input()))
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)
a = sum(a, [])
a = list(set(a))

aset = list(set(a))

result = 0
for i in range(1,n+1):
    if i in aset:
        continue
    else:
        result += 1

print(result)

Measured memory_bytes: 9200
#include "stdio.h"
#include "math.h"
#include <algorithm>
using namespace std;

#define SUQARE_SIZE  100000

int block[SUQARE_SIZE];
int blockSize;
int n;

void updateArr(int arr[],int left,int num){
    for(int i = left;i < left + blockSize;++i){
        if(i >= n){
            break;
        }
        arr[i] = num;
    }
}

void update(int arr[],int l, int r,int value)
{
    // 左端
    if(l % blockSize != 0 && l != 0 && l < r){
        int blockNumber = l / blockSize;
        if(block[blockNumber] != __INT_MAX__){
            updateArr(arr,blockNumber * blockSize,block[blockNumber]);
            block[blockNumber] = __INT_MAX__;
        }
        do{
            arr[l] = value;
            l++;
        }while(l % blockSize != 0 && l < r);
    }
    // blockに該当する部分
    while ((l + blockSize) <= r)
    {
        block[l / blockSize] = value;
        l += blockSize;
    }
    if(l <= r){
        int blockNumber = r / blockSize;
        if(block[blockNumber] != __INT_MAX__){
            updateArr(arr,blockNumber * blockSize,block[blockNumber]);
            block[blockNumber] = __INT_MAX__;
        }
        // 右端
        do{
            arr[l] = value;
            l++;
        }while(l <= r);
    }
}

int query(int arr[],int index)
{
    int blockNumber = index / blockSize;
    if(block[blockNumber] != __INT_MAX__){
        return block[blockNumber];
    }
    else{
        return arr[index];
    }
}

int main(){
    int q,command;
    scanf("%d %d",&n,&q);
    int a[n];
    blockSize = sqrt(n);
    
    for(int i = 0;i < n;++i){
        a[i] = block[i] = __INT_MAX__;
    }
    
    for(int i = 0;i < q;++i){
        scanf("%d",&command);
        if(command == 0){
            int l,r,value;
            scanf("%d %d %d",&l,&r,&value);
            update(a,l,r,value);
        }else{
            int index;
            scanf("%d",&index);
            printf("%d\n",query(a, index));
        }
    }
}


Measured memory_bytes: 3520
N = gets.to_i
a = gets.split(" ").map(&:to_i)
a = a.sort.reverse
all_sum = a.inject(&:+)
n = 1
a.each do |b|
  all_sum -= b
  if all_sum * 2 >= b
    n += 1
  else
    break
  end
end

puts n


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    LL n,leg;
    cin >> n >> leg;
    if(leg%2){
        cout << "No";
    }
    else{
        leg/=2;
        leg-=n;
        LL x = n - leg;
        if(x>=0 and leg>=0) cout << "Yes";
        else cout << "No";  
    }
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int kousha[4][3][10],n,b,f,r,v,i,j,k;

  for(i=0;i<4;i++)
    for(j=0;j<3;j++)
      for(k=0;k<10;k++)
	kousha[i][j][k]=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);

    if(kousha[b-1][f-1][r-1]==0)kousha[b-1][f-1][r-1]=v;
    else kousha[b-1][f-1][r-1]+=v;

}

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf("%2d",kousha[i][j][k]);
      }
      printf("\n");
    }
    if(i<3)printf("####################\n");
  }

  return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int main()
{
    int a,b;cin>>a>>b;
    for(int i=1;i<10000;i++) {
        float temp = i;
        float one = temp * 0.08;
        float two = temp * 0.10;
        if((int)one == a && (int)two == b) {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256