akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, t;
    cin >> n >> t;
    vector<ll> v(n);
    REP(i, n) cin >> v[i];
    ll res = 0, now = 0;
    for(int i=1; i<n; i++){
        ll diff = v[i] - v[i-1];
        res += min(diff, t);
    }
    cout << res + t << endl;
}

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

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

type Restaurant struct {
	n int
	s string
	p int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	if r[i].s == r[j].s {
		return r[i].p >= r[j].p
	} else {
		if len(r[i].s) <= len(r[j].s) {
			for k := range r[i].s {
				if r[i].s[k] != r[j].s[k] {
					return r[i].s[k] <= r[j].s[k]
				}
			}
			return true
		} else {
			for k := range r[j].s {
				if r[i].s[k] != r[j].s[k] {
					return r[i].s[k] <= r[j].s[k]
				}
			}
			return false
		}
	}
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	var N int
	fmt.Scanln(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	rs := make([]Restaurant, N)
	for i := range rs {
		rs[i].n = i + 1
		sc.Scan()
		rs[i].s = sc.Text()
		sc.Scan()
		rs[i].p, _ = strconv.Atoi(sc.Text())
	}

	sort.Sort(Restaurants(rs))
	for i := range rs {
		fmt.Println(rs[i].n)
	}
}


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

typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  rep(i, s.size()) {
    if (s.at(i) != t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A, B, X;
	cin >> X >> A >> B;
	if (B - A > X) cout << "dangerous" << endl;
	else if(B-A<=0) cout << "delicious" << endl;
	else cout << "safe" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);

  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }

  bitset<1000> vs(false);
  vector<int> as;

  bitset<1000> bs(false);

  // 閉路をひとつ見つける
  F0R(i, N) {

    if (bs.test(i)) continue;

    auto dfs = [&](auto dfs, int v)->int {

      bs.set(v);
      vs.set(v);
      for (auto e : G[v]) {
        if (vs.test(e)) {
          as.push_back(v);
          return e + 1;
        }

        int r = dfs(dfs, e);
        if (r > 0) {
          as.push_back(v);
          return r - 1 == v ? -1 : r;
        }
        if (r < 0) {
          vs.reset(v);
          return r;
        }
      }
      vs.reset(v);
      return 0;
    };
    dfs(dfs, i);

    if (as.size()) break;
  }

  if (as.size() == 0) {
    cout << -1;
    return 0;
  }

  reverse(rng(as));
  //Print(as);

  F0R(i, as.size()) {
    int next = i == as.size() - 1 ? as[0] : as[i + 1];
    for (auto e : G[as[i]]) {
      if (e == next) continue;
      if (vs.test(e)) {

        // ショートカット先の点が出てくるまで点を削除
        ++i;
        if (i == as.size()) {
          i = 0;
        }
        while (as[i] != e) {
          vs.reset(as[i]);
          as.erase(as.begin() + i);
          if (i == as.size()) {
            i = 0;
          }
        }
        i = -1;
        //Print(as);
        break;
      }
    }
  }

  cout << as.size() << newl;
  F0R(i, as.size()) {
    cout << (as[i] + 1) << newl;
  }
}
#endif


Measured memory_bytes: 384
//Airplane

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()


int main (){
    int a,b,c;
    cin >> a >> b >> c ;
    cout << a+b+c-max(a,max(b,c)) << endl;
    return 0;
}

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

using namespace std;
using i64 = int64_t;

int main(){
  i64 N;
  cin >> N;
  N--;
  i64 X = 26, len = 1;
  while(N >= X){
    N -= X;
    X *= 26;
    len++;
  }
  vector<char> ans;
  for(int i=0;i<len;i++){
    //cerr << N << " " << N % 26 << endl;
    ans.push_back((char)(N % 26) + 'a');
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  for(auto&& c:ans)cout << c;
  cout << endl;
} 

Measured memory_bytes: 3608
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

N, M, = map(int, input().split())
L = [[v for v in input().split()] for _ in range(M)]

a = [[False, 0, 0] for _ in range(N)]
for x, y in L:
    x = int(x) - 1
    if y == "WA" and a[x][0] == False:
        a[x][1] += 1
    elif y == "AC" and a[x][0] == False:
        a[x][0] = True
        a[x][2] += 1

ac = 0
wa = 0
for a, b, c in a:
    if a:
        wa += b
        ac += c

print(ac, wa)

Measured memory_bytes: 36424
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  if (  ( A == B && B != C ) 
     || ( A == C && B != C )
     || ( B == C && A != C ) ){
  	cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


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

int main(void) {
    int i, j, h, n, d, count=0;
    cin >> n >> d;
    int x[n][d];
    for(i=0; i<n; i++) {
        for(j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    for(h=0; h<n-1; h++) {
        for(i=1; h+i<n; i++) {
            int sum=0;
            for(j=0; j<d; j++) {
                sum+=pow((x[h][j]-x[h+i][j]), 2);
            }
            float dis=sqrt(sum);
            if(dis==(int)dis)
                count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    
    let n = s.len();
    let mut ans = vec![0; n];
    
    let mut c = vec![0; 2];
    let mut k = 0;
    for i in 0 .. n {
        if s[i] == b'R' {
            c[k] += 1;
            k = 1 - k;
        } else {
            ans[i-1] += c[1-k];
            ans[i] += c[k];
            k = 0;
            c[0] = 0;
            c[1] = 0;
        }
    }
    
    let mut c = vec![0; 2];
    let mut k = 0;
    for i in 0 .. n {
        let i = (n-1) - i;
        if s[i] == b'L' {
            c[k] += 1;
            k = 1 - k;
        } else {
            ans[i+1] += c[1-k];
            ans[i] += c[k];
            k = 0;
            c[0] = 0;
            c[1] = 0;
        }
    }
    
    
    for i in 0 .. n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, N) for (int i = 0; i < (N); i++)
#define REP(i, a, N) for (int i = a; i < (N); i++)
#define rrep(i, N, k) for (int i = (N); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int Q;
    cin >> Q;
    auto calcParticipants = [&](ll maxValue) {
        maxValue--;
        ll left = 0, right = 3e9 + 100;
        while (right - left > 1) {
            ll mid = left + (right - left) / 2;
            pl idx ={mid / 2, mid / 2 + 1};
            if (mid % 2 == 1) idx = {(mid + 1) / 2, (mid + 1) / 2};
            if (idx.first * idx.second <= maxValue) left = mid;
            else right = mid;
        }
        return left - 1;
    };
    for (int i = 0; i < Q; i++) {
        ll A, B;
        cin >> A >> B;
        auto idx = calcParticipants(A * B);
        if (A == B) cout << (A - 1) * 2 << endl;
        else cout << idx << endl;
    }
}

Measured memory_bytes: 256
import os, sys, re, math

N,L = input().split(' ')
N,L = int(N), int(L)

minv = 1000
for i in range(N):
    if abs(minv) > abs(L+i):
        minv = L+i

s = sum([L+i for i in range(N)])
print(s-minv)


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int C = scan.nextInt();
        List<Program>[] programs = new List[C];
        for (int i = 0; i < C; i++) {
            programs[i] = new ArrayList<>();
        }
        for (int i = 0; i < N; i++) {
            int s = scan.nextInt();
            int t = scan.nextInt();
            int c = scan.nextInt()-1;
            Program p = new Program(s, t);
            programs[c].add(p);
        }
        for (int i = 0; i < C; i++) {
            programs[i].sort(new ProgramComparator());
        }
        for (int i = 0; i < C; i++) {
            int len = programs[i].size();
            for (int j = len-1; 1 <= j; j--) {
                Program prev = programs[i].get(j-1);
                Program current = programs[i].get(j);
                if (prev.end != current.start) {
                    continue;
                }
                prev.end = current.end;
                programs[i].remove(j);
            }
        }
        int[] dp = new int[200002];
        for (int i = 0; i < C; i++) {
            int len = programs[i].size();
            for (int j = 0; j < len; j++) {
                Program p = programs[i].get(j);
                dp[p.start * 2 - 1] += 1;
                dp[p.end * 2] -= 1;
            }
        }
        for (int i = 1; i < 200002; i++) {
            dp[i] += dp[i - 1];
        }
        int ans = 0;
        for (int i = 0; i <= 200001; i++) {
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);
    }
    class Program {
        int start;
        int end;
        Program(int start, int end) {
            this.start = start;
            this.end = end;
        }
    }
    class ProgramComparator implements Comparator<Program> {
        @Override
        public int compare(Program o1, Program o2) {
            return Integer.compare(o1.start, o2.start);
        }
    }
}


Measured memory_bytes: 96888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x=100000, y;
  long A;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    y = 0;
    while (A%2 == 0) {
     A = A/2;
     y++;
   }
  if (x > y) {
    x = y;
   }
  }
  cout << x << endl;     
}
    

Measured memory_bytes: 256
#if 0
2019.12.06

枚举 d ，将 m + 1 个位置每 d 个分为一段，每段的左端点是停车位置。
那么区间 [l, r] 能贡献当且仅当 l - 1 和 r 所在的段不同。
再枚举 l - 1 所在的段，然后查询 l - 1 在该段有多少区间的 r 在这段之后，
用主席树维护区间来支持这个查询即可。
复杂度是个调和级数乘上主席树的复杂度。
#endif
#include <cstdio>
#include <algorithm>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 300005;
int al[maxn], ar[maxn];
std::vector<int> tor[maxn];

struct Tree {
	int lti, rti;
	int val;
};
#define self pool[now]
#define lt pool[self.lti]
#define rt pool[self.rti]
Tree pool[maxn * 20];
int pp;

void lain(int &now, int L, int R, int p) {
	pool[++ pp] = self;
	now = pp;
	++ self.val;
	if(L == R) return;
	int M = (L + R) >> 1;
	if(p <= M) lain(self.lti, L, M, p);
	else lain(self.rti, M + 1, R, p);
}

int query(int now, int L, int R, int l, int r) {
	if(!now or r < L or l > R) return 0;
	if(l <= L and R <= r) return self.val;
	int M = (L + R) >> 1;
	return query(self.lti, L, M, l, r) + query(self.rti, M + 1, R, l, r);
}

int T[maxn];

int main() {
	int n = read, m = read;

	for(int i = 1; i <= n; i ++) {
		read(al[i], ar[i]);
		tor[al[i]].push_back(ar[i]);
	}

	for(int l = 0; l <= m; l ++) {
		if(l) T[l] = T[l - 1];
		for(int r : tor[l])
			lain(T[l], 0, m, r);
	}

	for(int d = 1; d <= m; d ++) {
		int ans = 0;
		for(int t = 0; t <= m / d; t ++) {
			int l = t * d + 1, r = t * d + d;
			/* for(int i = 1; i <= n; i ++) */
			/* 	if(l <= al[i] and al[i] <= r and ar[i] >= r) */
			/* 		++ ans; */
			ans += query(T[r], 0, m, r, m) - query(T[l - 1], 0, m, r, m);
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 77568
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
char a[101][101];
int b[101][101];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int h,w;
void dfs(int x,int y)
{
	int i,j;
	b[x][y]=1;
	for(i=0;i<4;i++)
	{
		int nx,ny;
		nx=x+dx[i];
		ny=y+dy[i];
		if(nx>=0&&nx<h&&ny>=0&&ny<w&&a[nx][ny]==a[x][y]&&!b[nx][ny])
		{	
			dfs(nx,ny);
		}
	}
}
int main()
{
	int i,j;
	while(scanf("%d%d",&h,&w))
	{	
		int ans;
		ans=0;
		if(h==0)
			break;
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
				cin>>a[i][j];
		memset(b,0,sizeof(b));
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
			{
				if(!b[i][j])
				{	
					
					dfs(i,j);
					ans++;
				}
			}

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


Measured memory_bytes: 3808
//#pragma GCC optimize("O3,unroll-loops")
//#pragma loop_opt(on)
#include <bits/stdc++.h>
//#include <bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    int n;
    cin >> n;
    string s;
    map<string, int> mp{};
    Fr(i, 0, n) {
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    vector<string> ans{};
    for(const auto &it: mp) {
        if (mx < it.Sd) { mx = it.Sd; ans.clear(); }
        if (mx == it.Sd) ans.emplace_back(it.Ft);
    }
    sort(ans.begin(), ans.end());
    for(const auto &s: ans) cout << s << endl;

}


Measured memory_bytes: 25584
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>

typedef unsigned long long LL;

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	if (abs(N - M) >= 2) {
		cout << 0 << endl;
	}
	else if(abs(N - M) == 1){
		LL answer=1;
		for (int i = 1; i < N+1; i++) {
			answer = answer * i % 1000000007;
		}
		for (int i = 1; i < M + 1; i++) {
			answer = answer*i % 1000000007;
		}
		cout << answer << endl;
	}
	else {
		LL answer = 1;
		for (int i = 1; i < N + 1; i++) {
			answer = (answer * i) % 1000000007;
		}
		for (int i = 1; i < M + 1; i++) {
			answer = (answer*i) % 1000000007;
		}
		cout << (answer * 2) % 1000000007 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
 int64_t N;
 cin>>N;
 int64_t cnt=1;
 map<int,int>k;
 for(int i=2;i<=N;i++){
   auto p=prime_factorize(i);
   for(auto c:p){
   // cout<<c.first<<" "<<c.second<<endl;
     k[c.first]+=c.second;
   }
 }
 for(auto c:k){
  // cout<<c.first<<" "<<c.second<<endl;
   cnt*=(c.second+1);
   cnt%=1000000007;
 }
 cout<<cnt<<endl;
 return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n < 10){
            r += (10 - n) * 100;
        }
        System.out.println(r);
        sc.close();
    }
}

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	double n, d, ans=0;
	cin >> n >> d;
	while(n--){
		double a, b;
		cin >> a >> b;
		double x = sqrt(a*a + b*b);
		if(x <= d)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using ll = long long;
using namespace std;

int nn, m, d;

struct num {
    ll n;
    num(ll x) {
        n = x;
    }
    bool operator < (const num& b) const {
        int p1 = __builtin_popcountll(n), p2 = __builtin_popcountll(b.n);
        if (n == b.n) {
            return p1 < p2;
        }
        return n < b.n;
    }
};
priority_queue<num> q;
int main()
{
    IOS
    cin >> nn >> m;
    for (int i = 0; i < nn; ++i) {
        cin >> d;
        q.push(num(d));
    }
    while (m--) {
        num tmp = q.top();
        q.pop();
        tmp.n/=2;
        q.push(tmp);
    }
    ll sm = 0;
    while (!q.empty()) {
        sm += q.top().n;
        q.pop();
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll n; cin>>n;
ll ans=0;
for(int i=1; i<=n;i++){
 ans =ans+(n-1)/i; 
}

cout<<ans;
  return 0;
}

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

int ketasum(int N){
  int result = 0;
  while(N != 0){
    result += N % 10;
    N /= 10;
  }
  return result;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int result = 0;
  for(int i = 1; i <= N; i++){
    if(ketasum(i) >= A && ketasum(i) <= B) result += i;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
object Main extends App {
var N = readInt
var get = readLine.split(" ")
var cost = readLine.split(" ")
var sum = 0
for(i <- 0 until N){
if(get(i).toInt - cost(i).toInt > 0)
sum = sum + get(i).toInt - cost(i).toInt
}

println(sum.toInt)
}

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

int main(){
	int N;
	cin >> N;

	int color[9] = { 0 };
	for (int i = 0; i < N; ++i){
		int a;
		cin >> a;
		if (a >= 3200){ a = 3200; }
		color[a / 400]++;
	}

	int colorNum = 0;
	for (int i = 0; i < 8; i++){
		if (color[i]>0){
			colorNum++;
		}
	}
	cout << max(colorNum, 1) << " " << colorNum + color[8] << endl;

	return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as BS8

sol a b c 0 0 = sol (tail a) b c (b !! (head a - 1)) (head a)
sol a b c i j
    | l == 1 && ha == (j+1) = i + ba + ca
    | l == 1                = i + ba
    | ha == (j+1)           = sol ta b c (i + (ba + ca)) ha
    | otherwise             = sol ta b c (i + ba) ha
    where
        l = length a
        ha = head a
        ta = tail a
        ba = b !! (ha-1)
        ca = c !! (ha-2)

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInteger <$> BS8.getLine
    a <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    b <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    c <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

    print $ sol a b c 0 0


Measured memory_bytes: 380
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m,r = map(int,readline().split())

lst1 = [[float("inf")]*n for _ in range(n)]

lst2 = list(map(int,readline().split()))
for i in range(len(lst2)):
    lst2[i] -= 1

for i in range(m):
    x,y,w = map(int,readline().split())
    lst1[x-1][y-1] = w
    lst1[y-1][x-1] = w

def warshall_floyd(d): #隣接行列を入れる
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

lst1 = warshall_floyd(lst1)

ans = 10**10
for i in list(itertools.permutations(lst2)):
    res = 0
    before = i[0]
    for j in i[1:]:
        res += lst1[before][j]
        before = j

    ans = min(res,ans)
print(ans)

Measured memory_bytes: 62044
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    if(k<=a){
        ans = k;
    }
    else if(k<=a+b){
        ans = a;
    }
    else ans = a-(k-(a+b));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main() {
    char s[100];
    int S[1000];
    int a,b,i,temp,top=0;
    while(scanf("%s", s) != EOF) {
        if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
            top--;
            b = S[top];
            top--;
            a = S[top];
            if (s[0] == '+') a = a + b;
            else if (s[0] == '-') a = a - b;
            else if (s[0] == '*') a = a * b;
            S[top] = a;
            top++;
        }
         else {
            temp = s[0] - '0';
            i = 1;
            while(s[i] != '\0') {
                temp *= 10;
                temp += (s[i] - '0');
                i++;
            }
            S[top] = temp;
            top++;
        }
    }

    printf("%d\n", S[0]);
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int count = 0;
  if (S.at(0) == S.at(1) || S.at(2) == S.at(3) ||  S.at(1) == S.at(2))
    count++;
  if (count >= 1)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
      
}


Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int a, b;
    cin >> a >> b;
    cout << ((a*b&1)?"Odd":"Even") << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1001001001;


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

  if(S[2]==S[3] && S[4]==S[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) {
    cin >> c[i];
  }

  int sum = 0;

  rep(biti, 1<<h) {
    rep(bitj, 1<<w) {
      vector<string> d(h);
      d = c;
      rep(i, h) {
        if ((biti>>i)&1) {
          rep(j, w) {
            d[i][j] = '.';
          }
        }
      }
      rep(j,w) {
        if ((bitj>>j)&1) {
          rep(i,h) {
            d[i][j] = '.';
          }
        }
      }
      int cnt = 0;
      rep(i,h) {
        rep(j,w) {
          if (d[i][j] == '#') cnt++;
        }
      }
      if (cnt == k) sum++;
    }
  }

  cout << sum << endl;
}


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

using namespace std;
int main()
{
    int a,b;
    cin>>a;
    if(a < 1200 ){
        cout<<"ABC";
    }
    else if(a < 2800){
        cout<<"ARC";
    }
    else{
        cout<<"AGC";
    }

    return 0;
}


Measured memory_bytes: 3508
N,M,X,Y = map(int,input().split())

x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

c=0
for i in range(X+1,Y+1):
  c =0
  if (i >X and i <=Y) :
    c += 1
  if max(x) < i :
    c += 1
  if min(y) >= i :
    c += 1
  
  if c == 3:
   
    print("No War")
    exit()
  else:
    continue
    
    
print("War")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e17;
const int mod = 1e9 + 7;

signed main() {
    int H, W, D;
    cin >> H >> W >> D;
    unordered_map<string, pair<int, int>> check;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int x;
            cin >> x;
            check[to_string(x)] = {i, j};
        }
    }
    vector<vector<int>> sum(D, vector<int>((H * W) / D + 10, 0));
    for (int i = 1; i <= D; i++) {
        int count = 2;
        for (int j = i + D; j <= H * W; j += D) {
            sum[i % D][count] = sum[i % D][count - 1] + abs(check[to_string(j)].first - check[to_string(j - D)].first)
                    + abs(check[to_string(j)].second- check[to_string(j - D)].second);
            ++count;
        }
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << sum[L % D][R / D + (R % D != 0)] - sum[L % D][L / D + (L % D != 0)] << endl;
    }
}


Measured memory_bytes: 20388
using System;

public class Program
{
	public static void Main()
	{
		int q = int.Parse(Console.ReadLine());
		
		Dice[] d = new Dice[q];
		
		for(int i = 0; i < q; i++ ) {
			d[i] = new Dice(Console.ReadLine().Split(' '));
		}
		
		bool result = true;
		for(int i = 0; i < q; i++ ) {
			for(int j = i+1; j < q; j++ ) {
				result &= !d[i].IsEquals(d[j]);
			}
		}
		
		if(result) Console.WriteLine("Yes");
		else	Console.WriteLine("No");
	}
}

public class Dice
{
	public string Left { get; private set; }
	public string Front { get; private set; }
	public string Right { get; private set; }
	public string Rear { get; private set; }
	public string Top { get; private set; }
	public string Bottom { get; private set; }

	//   4
	// 3 0 2 5
	//   1
	public Dice(string[] faces)
	{
		Front = faces[0];
		Bottom = faces[1];
		Right = faces[2];
		Left = faces[3];
		Top = faces[4];
		Rear = faces[5];
	}

	public void RollX(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Top;
			Top = Front;
			Front = Bottom;
			Bottom = Rear;
			Rear = tmp;
		} else {
			tmp = Top;
			Top = Rear;
			Rear = Bottom;
			Bottom = Front;
			Front = tmp;
		}
	}

	public void RollY(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Top;
			Top = Right;
			Right = Bottom;
			Bottom = Left;
			Left = tmp;
		} else {
			tmp = Top;
			Top = Left;
			Left = Bottom;
			Bottom = Right;
			Right = tmp;
		}
	}

	public void RollZ(bool direction)
	{
		var tmp = "";
		if(direction) {
			tmp = Front;
			Front = Right;
			Right = Rear;
			Rear = Left;
			Left = tmp;
		} else {
			tmp = Front;
			Front = Left;
			Left = Rear;
			Rear = Right;
			Right = tmp;
		}
	}

	public void Roll(char direction)
	{
		var c = char.ToUpper(direction);

		switch(c){
			case 'N':	RollX(true);	break;
			case 'S':	RollX(false);	break;
			case 'W':	RollY(true);	break;
			case 'E':	RollY(false);	break;
			case 'U':	RollZ(true);	break;
			case 'D':	RollZ(false);	break;
		}

		//Console.WriteLine(this.Left + this.Front + this.Right + this.Rear + this.Top + this.Bottom);
	}

	public bool IsEquals(Dice d)
	{
		foreach ( var c in "UUUUNUUUUNUUUUNUUUUEUUUUSSUUUU".ToCharArray()) {
			if(this.Bottom == d.Bottom &&
			   this.Front == d.Front &&
			   this.Left == d.Left &&
			   this.Rear == d.Rear &&
			   this.Right == d.Right &&
			   this.Top == d.Top){
				return true;
			}

			d.Roll(c);
		}

		return false;
	}
}

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
int n, m, k;


int main(int argc, char** argv) {
	bool flag = false;
	
	cin>>n>>m>>k;
	if(k == 0) {
		flag = true;
		goto ed;
	}
	
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=min(i, m);j++) {
			int t = i * (m - j) + (n - i) * j;
			if(t == k) {
				flag = true;
				goto ed;
			}
		}
	}		
	
	for(int j=1;j<=m;j++) {
		for(int i=0;i<=min(n, j);i++) {
			int t = j * (n - i) + (m - j) * i;
			if(t == k) {
				flag = true;
				goto ed;
			}
		}
	}
	ed:
		if(flag)puts("Yes");
		else puts("No");
	return 0;
}

Measured memory_bytes: 256
import io.Source.stdin

object Main{
  def main(args: Array[String]){
    for(line <- stdin.getLines().toList){
      var sum = 0

      for(i <- 0 to line.length - 1){
        sum += line(i).toInt - 48
      }

      if(sum != 0){
        println(sum)
      }
    }
  }
}

Measured memory_bytes: 43996
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = list(S())
t = list(S())

ans = 0
for ss,tt in zip(s,t):
  if ss != tt:
    ans += 1
print(ans)

Measured memory_bytes: 91032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x = 0;
  rep(i, 2) {
    int a;
    cin >> a;
    x += a;
  }
  cout << (x+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int h, w, n;
	cin >> h >> w >> n;
	vector<int> cnt(w);
	vector<vector<int>> by_h(h);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		by_h[x].push_back(y);
		cnt[y]++;
	}
	set<pair<int, int>> s;
	for (int i = 0; i < w; i++) {
		s.insert({cnt[i], i});
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (auto j : by_h[i]) {
			s.erase({cnt[j], j});
			cnt[j]--;
			s.insert({cnt[j], j});
		}
		ans = max(ans, (int)by_h[i].size() + s.rbegin()->first);
		for (auto j : by_h[i]) {
			s.erase({cnt[j], j});
			cnt[j]++;
			s.insert({cnt[j], j});
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 34452
# coding: utf-8
N=int(input())
X=list(map(int,input().split()))
cost=0
for i in range(N):
    cost+=(X[i]-1)**2
for i in range(2,101):
    cost1=0
    for j in range(N):
        cost1+=(X[j]-i)**2
    if cost1<cost:
        cost=cost1
    
print(cost)

Measured memory_bytes: 39152
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

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

  int n; cin >> n;
  int sum = 0;

  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  int target = sum/2;
  if (sum%2 != 0) {
    target++;
  }

  bitset<4000001> bs;
  bitset<4000001> bs2;

  rep(i, n) {
    bs[0] = true;
    bs2 = bs;
    bs2 <<= a[i];
    bs = bs | bs2;
  }
  for(int i=target; i<4000001; i++) {
    if (bs[i]) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] h = sc.nextIntArray(n);
        int ans = 0;
        int now = -1;
        for(int h1 : h){
            if(now <= h1){
                ans++;
                now = h1;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25344
function Main(input) {
  var list = input.split(" ");
  var A = parseInt(list[0]);
  var B = parseInt(list[1]);
  var coin = new Array(2);
  for (i=0;i<2;i++) {
    if ( A >= B){
    coin[i] = A;
    var A = A-1;
    } else {
    coin[i] = B;
      var B = B-1;
      }
  }
  console.log(coin[0] + coin[1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n);
    cin >> a;
    sort(all(a));
    int b = accumulate(a.begin(), a.begin() + n - 1, 0);
    int c = a[n - 1];
    cout << (b > c ? "Yes\n" : "No\n");
}

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

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

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

    sort(b, b + n);

    long long ans = 0;
    for (int i = 0; i < n; i++) ans += abs(b[i] - b[n / 2]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
inline int read() {
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') f=(ch=='-')?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') x=10*x+(ch-'0'),ch=getchar();return x;
}
const int N=1e5+50;
int a[N],n,s0,s1;
int gcd(int x,int y) {return !y?x:gcd(y,x%y);}
bool dfs(int x) {
	int sum=0,flag=0;
	fo(i,1,n) if(a[i]%2) {a[i]--;break;}
	int g=a[1];
	fo(i,2,n) g=gcd(g,a[i]);
	fo(i,1,n)  {
		a[i]/=g;
		if(a[i]%2==0) sum++;
		if(a[i]==1) flag=1;
	}
	if(sum%2) return x^1;
	if(flag||n-sum!=1) return x;
	return dfs(x^1);
}
int main() {
	bool flag=0;
	n=read();
	fo(i,1,n) {
		a[i]=read(),(a[i]%2)?s1++:s0++;
		if(a[i]==1) flag=1;
	}
	if(s0%2) printf("First\n");
	else {
		if(flag||s1!=1) printf("Second\n");
		else if(dfs(1)) printf("First\n");
		else printf("Second\n");
	}
	return 0;
} 

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int h, w, n, m, s, ans = 0, a[100000], num = 0, sum = 0;
int flag = 0;
string str,stt;
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a, a + m);
	cout << max(a[m - 1]*2-n-1,0) << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int a=0;
  int b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C')a=1;
    if(a==1&&s[i]=='F')b=1;
  }
  if(b==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(void){
    int n, ans = 1;
    vector<int> d;
    cin >> n;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        d.push_back(temp);
    }
    sort(d.begin(), d.end());
    for(int i = 1; i < n; i++){
        if(d[i-1] < d[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<string>
#define int long long
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    int minm=INT_MAX;
    int dp[n];
    for(int i=0;i<n;++i)
    {
        dp[i]=INT_MAX;
    }
    for(int i=0;i<min(k,n);++i)
    {
        dp[i]=min(dp[i],abs(arr[i]-arr[0]));
    }
    for(int i=k;i<n;++i)
    {
        for(int j=i-1;j>=i-k;--j)
        {
            dp[i]=min(abs(arr[i]-arr[j])+dp[j],dp[i]);
        }
    }
    //for(int i=0;i<n;++i) cout<<dp[i]<<" ";
    cout<<dp[n-1];
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();

}


Measured memory_bytes: 5180
k = int(input())

r = [[i,i] for i in range(1, 10)]
l = [0]
cnt = len(r)
if k <= cnt:
    print(k)
    exit()

k -= 1
k -= cnt
for _ in range(100):
    nr = []
    x = 10**(_+1)
    for i in l:
        nr.append([x+i, 1])
    for i, start in r:
        for j in range(start-1,start+2):
            if j == 0:
                l.append(i)
            elif 10 > j > 0:
                nr.append([j*x+i, j])

    if len(nr) > k:
        nr.sort()
        print(nr[k][0])
        exit()
    k -= len(nr)
    r = nr


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

int main(){
	vector<int> a(5);
	for(int i=0;i<5;i++)
		scanf("%d", &a[i]);
	vector<pair<int, int> > b(5);
	for(int i=0;i<5;i++){
		b[i]=make_pair(a[i]%10, a[i]);
	}
	sort(b.begin(), b.end());
	int time=0;int j=0;
	while(b[j].first==0){
		time+=b[j].second;
		++j;
	}
	for(int i=4;i>j;i--){
		time+=b[i].second+(10-b[i].first);
	}
	time+=b[j].second;
	cout<<time<<endl;
	return 0;
}

Measured memory_bytes: 256