akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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 comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

void solve(){
  ll H, N;
  cin >> H >> N;
  rep(i, N){
    ll A;
    cin >> A;
    H -= A;
  }
  if(H <= 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

struct edge{int u, v, cost;};

bool comp(const edge& e1, const edge& e2){return e1.cost < e2.cost;}

int tree[100010];
int root(int x){return tree[x] == x ? x : tree[x] = root(tree[x]);}
void unite(int a , int b){tree[root(a)] = root(b);}

edge es[100010];
int V, E;

int kruskal(){
    sort(es, es + E, comp);
    rep(i, V)tree[i] = i;
    int res = 0;
    rep(i, E){
        edge e = es[i];
        if(root(e.u) != root(e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

signed main(){
    cin >> V >> E;
    rep(i, E)cin >> es[i].u >> es[i].v >> es[i].cost;
    cout << kruskal() << endl;
}

Measured memory_bytes: 4292
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b,c; cin>>a>>b>>c;
  if(a<=c&&c<=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}













Measured memory_bytes: 256
n = int(input())
order = list(map(int, input().split()))
for i in range(n):
    order[i] -= 1
point = list(map(int, input().split()))
bonus = list(map(int, input().split()))

ans = 0
pre = -2 
for i in range(n):
    now = order[i]
    ans += point[now]
    
    if pre == now - 1:
        ans += bonus[pre]
    
    pre = now
    
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#define long long
using namespace std;

int main(){
	int n,sum=0;
	cin>>n;
	int a[2*n];
	for(int i=0;i<2*n;i++){
		cin>>a[i];
	}
	sort(a,a+(2*n));
	for(int i=0;i<2*n;i+=2){
		sum+=a[i];
	}
	cout<<sum;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

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

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

ll gcd(ll x, ll y) {
    if (x < y) {
        x ^= y;
        y ^= x;
        x ^= y;
    }
    return y ? gcd(y, x%y) : x;
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

void solve() {
    ll a, b; cin >> a >> b;
    cout << lcm(a, b);
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] ans = new int[n];
		
		int kizyun = k-q;
		
		for(int i = 0; i < q; i++) {
			int num = sc.nextInt();
			ans[num-1]++;
		}
		
		for(int answer : ans) {
			if(answer+kizyun > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

		

	}
}


Measured memory_bytes: 67080
import java.util.Arrays;
import java.util.Scanner;

class Main{
	private static final int n=1000001;
	static Scanner s=new Scanner(System.in);
	static int gInt() {return Integer.parseInt(s.next());}
	static long gLong() {return Long.parseLong(s.next());}

	public static void main(String[]$){
		boolean[]p=new boolean[n];
		Arrays.fill(p,true);
		p[0]=false;
		p[1]=false;
		for(int i=2;i<n;++i)
			if(p[i])
				for(long j=(long)i*i;j<n;j+=i)
					p[(int)j]=false;

		int[]a=new int[n];
		for(int i=1;i<n;i+=2)
			if(p[i]&&p[(i+1)/2])
				a[i]=1;
		Arrays.parallelPrefix(a,Integer::sum);
		for(int q=gInt();q>0;--q)
			System.out.println(-a[gInt()-1]+a[gInt()]);
	}
}

Measured memory_bytes: 68760
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

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

N, K = list(map(int, input().split()))

cnts = []
for n in range(1, N + 1):
    cnt = 0
    while n * (2 ** cnt) < K:
        cnt += 1
    # cnt 回連続で表なら K を超える
    cnts.append(1 / 2 ** cnt)

print(sum(cnts) / len(cnts))


Measured memory_bytes: 22496
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________
	int n;
	cin >> n;
	if (n % 1000 == 0)
		cout << 0 << en;
	else
		cout << 1000 - n % 1000 << en;

	return 0;
}



Measured memory_bytes: 3652
import sys
from heapq import *

def first_1(x):
  if x:
    i = 0
    while x & 1 == 0:
      x >>= 1
      i += 1
    return i

def sep_single(s):
  if s:
    r = 1 << (s.bit_length()-1)
    i = s.bit_length()-1
    while s:
      if r & s:
        yield -i, r
        s ^= r
      r >>= 1
      i -= 1

def prepare_to_right(g, x):
  x0, y0 = g[-1]
  if x0 < x and y0:
    y0 = 0
    g.append((x0, 0))
  while x0 < x:
    x0 += 1
    g.append((x0, 0))

def prepare_to_left(g, x):
  x0, y0 = g[-1]
  if x+1 < x0 and y0:
    y0 = 0
    g.append((x0, 0))
  while x+1 < x0:
    x0 -= 1
    g.append((x0, 0))

def append_to_right(g, x, y):
  prepare_to_right(g, x)
  x0, y0 = g[-1]
  if y != y0:
    g.append((x, y))
  g.append((x+1, y))

def subloop_tp_group(g):
  x = 0
  while g&1 == 0:
    g >>= 1
    x += 1
  loop = [(x+1, 0)]
  tail = [(x, 0), (x, 1), (x+1, 1)]
  g >>= 1
  x += 1
  while g:
    while g&1==0:
      g >>= 1
      x += 1
    prepare_to_right(loop, x)
    prepare_to_right(tail, x)
    rev = reversed(loop)
    append_to_right(loop, x, 1)
    loop.append((x+1, 0))
    loop.extend(rev)
    loop.extend(tail)
    append_to_right(loop, x, 0)
    append_to_right(tail, x, 1)
    g >>= 1
    x += 1
  loop.extend(reversed(tail))
  return loop

N = int(input())

single = 0
tpg = []
for i in range(1<<N):
  a = int(sys.stdin.read(1))
  if bin(i).count("1") == 1:
    if a == 0:
      single |= i
  else:
    b = i & single
    if i and b | a == 0 and all(p & i != p for n, p in tpg):
      heappush(tpg, (-first_1(i), i))
    elif i | a == 0 or a and (b or any(p & i == p for n, p in tpg)):
      print("Impossible")
      break
else:
  print("Possible")
  loop = []
  for n, g in merge(sep_single(single), nsmallest(len(tpg),tpg)):
    subloop = subloop_tp_group(g)
    if loop:
      prepare_to_left(loop, subloop[0][0])
      if loop[-1] == subloop[0]:
        loop.pop()
    loop.extend(subloop)
  
  if not loop:
    loop.append((0, 0))
  prepare_to_right(loop, loop[0][0])
  
  print(len(loop)-1)
  for p in loop:
    print(*p)


Measured memory_bytes: 4056
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10, mod = 1e9 + 7;

ll add(ll x, ll y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}

ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) {
		x += mod;
	}
	return x;
}

ll mul(ll x, ll y) {
	x *= y;
	return x % mod;
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = mul(res, x);
		}
		x = mul(x, x);
		e /= 2;
	}
	return res;
}

ll x[N], fact[N], finv[N], pref[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
	}
	fact[0] = finv[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fact[i] = mul(i, fact[i - 1]);
		finv[i] = pwr(fact[i], mod - 2);
	}
	for (int i = 2; i <= n; ++i) {
		pref[i] = add(pref[i - 1], mul(fact[i - 2], finv[i]));
		// cout << i << ' ' << pref[i] << endl;
	}
	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		ans = add(ans, mul(x[i], pref[i]));
		ans = add(ans, mul(x[n], mul(fact[i - 1], finv[i])));
		ans = sub(ans, x[i]);
	}
	ans = mul(ans, fact[n - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	int B=0;
    cin>>a>>b>>c;
   for(;b>=a;a++){
	    if(a > b)break;
       if(c%a == 0){
		   B++;
        }
    }
    cout<<B<<endl;
return 0;
}


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

using namespace std;

int main()
{
	bool flag;
	flag = false;
	int array[5];
	int limit, i, j;
	for (i = 0; i < 5; i++)
	{
		cin >> array[i];
	}
	cin >> limit;
	for (i=0;i<4;i++)
	{
		for (j = i + 1; j < 5; j++)
		{
			if (array[j] - array[i] > limit)
				flag = true;
		}
	}
	if (flag == false)
		cout << "Yay!";
	else
		cout << ":(";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string grid[1000];
int h,w,ct;
bool vis[1000][1000];
set<int> adj[1000000];
set<pair<int,int> > co;
void dfs(int i,int j)
{
	if(vis[i][j]||grid[i][j]=='#')	return;
	co.insert(make_pair(i,j));
	vis[i][j]=true;
	if(i)dfs(i-1,j);
	if(i<h-1)dfs(i+1,j);
	if(j)dfs(i,j-1);
	if(j<w-1)dfs(i,j+1);
}
int main() {
	// your code goes here
	//#ifndef ONLINE_JUDGE
	//#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>h>>w;
	int ch,cw;
	cin>>ch>>cw;
	int dh,dw;
	cin>>dh>>dw;
	for(int i=0;i<h;i++)
		cin>>grid[i];
	ct=0;
	memset(vis,false,sizeof(vis));
	map<pair<int,int>,int> gn;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(vis[i][j]||grid[i][j]=='#')	continue;
			dfs(i,j);
			for(set<pair<int,int> >::iterator it=co.begin();it!=co.end();it++)
				{gn[*it]=ct;}//cout<<(*it).first<<" "<<(*it).second<<" "<<ct<<endl;}
			co.clear();
			ct++;
		}
	}
	//cout<<ct<<endl;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			for(int k=max(0,i-2);k<min(i+3,h);k++)
				for(int l=max(0,j-2);l<min(j+3,w);l++)
				{
					if(grid[i][j]=='#'||grid[k][l]=='#')	continue;
					if(gn[make_pair(i,j)]==gn[make_pair(k,l)])	continue;
					adj[gn[make_pair(i,j)]].insert(gn[make_pair(k,l)]);
					adj[gn[make_pair(k,l)]].insert(gn[make_pair(i,j)]);
				}
		}
	//cout<<adj[0].size()<<" "<<adj[1].size();
	int node=gn[make_pair(ch-1,cw-1)];
	int dis[ct+1],d=0;
	queue<int> n1;
	n1.push(node);
	bool v1[ct];
	for(int i=0;i<=ct;i++)
	{
		dis[i]=-1;v1[i]=false;
	}
	dis[node]=0;
	while(n1.size())
	{
		node=n1.front();
		n1.pop();
		//cout<<node<<" "<<d<<endl;
		for(set<int>::iterator it=adj[node].begin();it!=adj[node].end();it++)
		{
			if(v1[*it])	continue;
			v1[*it]=true;
			n1.push(*it);
			dis[*it]=dis[node]+1;
		}
	}
	cout<<dis[gn[make_pair(dh-1,dw-1)]];
	return 0;
}

Measured memory_bytes: 101528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> price(N);
  for (int i = 0; i < N; i++) {
    cin >> price[i];
  }
  sort(price.begin(), price.end());  //小さい順にソート
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += price[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 999999999
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int main() {

	int N;
	cin >> N;
	int v;
	vector<int>vs;

	rep(i, N) {
		cin >> v;
		vs.push_back(v);
	}

	SORT(vs);


	double value = 0;
	double temp = (double)(vs[0]+vs[1])/2;
	value = temp;
	for(int i=2;i<N;i++){
		value = (double)(temp + vs[i]) / 2;
		temp = value;
	}

	cout << value << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.next();
        String t = sc.next();

        char[] sChar = new char[s.length()];
        char[] tChar = new char[t.length()];

        for(int i = 0; i<s.length(); i++){
            sChar[i] = s.charAt(i);
            tChar[i] = t.charAt(i);
        }

        int count = 0;
        for(int j = 0; j<s.length(); j++){
            if(sChar[j] != tChar[j]){
                count++;
            }
        }
        System.out.println(count);

    }
}

Measured memory_bytes: 41592
#include<stdio.h>

int main(void)

{

int i,n;

int number;

long long int sum=0;

int min=0;

int max=0;

 

scanf("%d",&n);

 

for(i=0;i<n;i++)

{

scanf("%d",&number);

 

if(i==0)

{

min = number;

max = number;

}

if(number<min) min = number;

if(number>max) max = number;

 

sum += number;

}

 

printf("%d %d %lld\n",min,max,sum);

 

return 0;

}
 

Measured memory_bytes: 600
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, A;
        cin >> N >> A;
        cout << (N + A - 1) / 2 + 1 << endl;

        return 0;
}


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

const string YES = "Yes";
const string NO = "No";
using ll = long long;

void solve(long long N, std::vector<std::vector<long long>> D){
    for(int i = 0;i < N - 2;i++){
        if(D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] && D[i + 2][0] == D[i + 2][1]){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 2 ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 

double calc(ll n, vector<ll> &p) {
  double ret = 0;
  rep(i, 1, p[n]+1) {
    ret += (double)i / p[n];
  }
  return ret;
}


int main(void) {
  ll n, k; cin >> n >> k;
  vector<ll> p(n);  
  rep(i, 0, n) {
    cin >> p[i];
  }

  ll max = 0;
  ll curr = 0;
  ll ind = 0;
  rep(i, 0, p.size()) {
    if (i >= k) {
      curr -= p[i - k];
    }
    curr += p[i];
    if (curr > max) {max = curr; ind = i-k+1;}
  }

  double ans = 0.0;
  rep(i, ind, ind+k) {
      ans += calc(i, p);
  }

  printf("%lf\n", ans);
}


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

#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
#define ll long long
#define fi first
#define se second
#define FOR(i,a,b) for(ll int i = a;i<b;i++)
#define FORR(i,a,b) for(ll int i = a;i>=b;i--)

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef pair<int, int> pii;


bool compare(int a, int b){
    return(a>b);
}
ll N;
int mini = 0, val=0;
vector<bool> check;

int main(){
    #ifdef LOCAL_DEFINE
        freopen("input.txt","rt", stdin);
    #endif
        ll n;
        
        cin>>n;
        n--;
        ll ans = ((n+1)%2)?((n/2)*(n+1)):(((n+1)/2)*n);
        cout<<ans;
    #ifdef LOCAL_DEFINE
        cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s";
    #endif

    return 0;
}





Measured memory_bytes: 256
import sys
s=input()
n=len(s)
x,y=map(int,input().split())
lst=list(s.split("T"))
if len(lst)==1:
    if x==len(s) and y==0:
        print("Yes")
    else:
        print("No")
    sys.exit()
v=[0]*(2*n+1)
u=[0]*(2*n+1)
a=len(lst[0])
b=len(lst[1])
v[n+a]=1
u[n+b]=1
u[n-b]=1
for i in range(2,len(lst)):
    l=len(lst[i])
    if i%2==0:
        h=[0]*(2*n+1)
        for i in range(2*n+1):
            if i-l>=0:
                if v[i-l]==1:
                    h[i]=1
            if i+l<=2*n:
                if v[i+l]==1:
                    h[i]=1
        v=h
    else:
        h=[0]*(2*n+1)
        for i in range(2*n+1):
            if i-l>=0:
                if u[i-l]==1:
                    h[i]=1
            if i+l<=2*n:
                if u[i+l]==1:
                    h[i]=1
        u=h
if v[n+x]==1 and u[n+y]==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 119388
#include<bits/stdc++.h>
using namespace std;
int d;
int main(){
  scanf("%d",&d);
  if(d==25)puts("Christmas");
  else if(d==24)puts("Christmas Eve");
  else if(d==23)puts("Christmas Eve Eve");
  else if(d==22)puts("Christmas Eve Eve Eve");
  return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a,b = a - a//2, b + a//2
    else:
        if b % 2 == 1:
            b -= 1
        a, b = a + b//2, b - b//2
print(a,b)

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

int main(){
   while(1){
     int h,w;
     cin>>h>>w;
     if(h == 0&&w == 0) break;
     for(int i=0;i < h;i++){
        for(int j=0;j < w;j++){
          if(i == 0||i == h-1||j == 0||j == w-1) cout<<"#";
          else cout<<".";
        }
        cout<<endl;
     }

   cout<<endl;
   }

   return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a[100000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	long long sum = 0, mn = 0;
	for(int i = 0; i < n; i++){
		sum += a[i];
		if(i % 2 == 0 && sum <= 0) mn += 1 - sum, sum = 1;
		else if(i % 2 == 1 && sum >= 0) mn += 1 + sum, sum = -1;
	}
	sum = 0;
	long long cnt = 0;
	for(int i = 0; i < n; i++){
		sum += a[i];
		if(i % 2 == 0 && sum >= 0) cnt += 1 + sum, sum = -1;
		else if(i % 2 == 1 && sum <= 0) cnt += 1 - sum, sum = 1;
	}
	mn = min(mn, cnt);
	cout << mn << "\n";
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a,b,c,d,e;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  for(int i=0; i<a; i++){
    scanf("%d",&e);
    if(c<e){c=e;}
  }
  for(int i=0; i<b; i++){
    scanf("%d",&e);
    if(e<d){d=e;}
  }
  printf(c<d?"No War":"War");
  return 0;}

Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int len = s.length();
  if(len == 2) cout << s << endl;
  else{
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<int,int>
const int maxn=1e6+5;
signed main() { 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    for(int i=1;i<=5;i++)
    {
    	cin>>t;
    	if(t==0)
    	{
    		cout<<i;
    		return 0;
    	}
    }
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    priority_queue<long> A;
    for (int n = 0; n < N; n++)
    {
        long a;
        cin >> a;
        A.push(a);
    }

    long ans = A.top();
    A.pop();
    int num = 2;
    while(num<N){
        ans += A.top();
        num++;
        if(num%2==0){
            A.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5352
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

const int N = 1e6 + 10;
int64 F[N], G[N];

int main() {
  F[0] = G[0] = 1;
  for (int i = 1; i < N; ++i) {
    F[i] = F[i - 1] * i % MOD;
    G[i] = power_mod(F[i], MOD - 2);
  }
  int x, y;
  scanf("%d%d", &x, &y);
  if ((x + y) % 3) {
    puts("0");
    return 0;
  }
  int n = (x + y) / 3;
  int u = x - n, v = y - n;
  if (u < 0 || v < 0) {
    // trace(u, v);
    puts("0");
    return 0;
  }
  int64 ret = F[n] * G[u] % MOD * G[v] % MOD;
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 15872
def partition(ary, p, r)
  x = ary[r][1]
  i = p-1
  (p...r).each{ |j|
    if ary[j][1] <= x
      i = i+1
      tmp = ary[i]
      ary[i] = ary[j]
      ary[j] = tmp
    end
  }
  tmp = ary[i+1]
  ary[i+1] = ary[r]
  ary[r] = tmp
  i+1
end

def quicksort(ary, p, r)
  if p < r
    q = partition(ary, p, r)
    quicksort(ary, p, q-1)
    quicksort(ary, q+1, r)
  end
end

def stable?(in_ary, out, n)
  (0...n).each{ |i|
    (i...n).each { |j|
      if in_ary[i][1] == out[j][1]
        (i+1...n).each { |a|
          if out[j] == in_ary[a]
            (j+1...n).each { |b|
               if in_ary[i] == out[b]
                return false
              end
            }
          end
        }
      end
    }
  }
  true
end

# main
n = gets.to_i
ary = []
(0...n).each{ |n|
  c, n = gets.split(' ')
  ary << [c, n.to_i]
}

org_ary = ary.dup

quicksort(ary, 0, ary.size-1)

if stable?(org_ary, ary, n)
  puts "Stable"
else
  puts "Not stable"
end

(0...n).each{ |n|
  puts "#{ary[n][0]} #{ary[n][1]}"
}

Measured memory_bytes: 22232
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printl(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}

signed main (){
    string s;cin>>s;
   int w=0;
    int ans=0;
rep(i,0,s.size()){
    if(s[i]=='W'){
        w++;
        ans+=w-i-1;
    }
}
cout<<-ans<<endl;
}

/*

*/

Measured memory_bytes: 640
// (a*b) + (c*d) + (e*f) = h*w
// max(a*b,c*d,e*f) - min(a*b,c*d,e*f)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll max(ll a, ll b, ll c)
{
    return max(max(a, b), c);
}

ll min(ll a, ll b, ll c)
{
    return min(min(a, b), c);
}

int main()
{
    ll h, w;
    cin >> h >> w;

    ll ans = 1e12;

    for (int i = 1; i <= h; i++) {
        ll x = i * w;
        ll y = ((h - i) / 2) * w;
        ll z = ((h - i + 1) / 2) * w;
        ll res = max(x, y, z) - min(x, y, z);
        ans = min(ans, res);
    }

    for (int i = 1; i <= h; i++) {
        ll x = i * w;
        ll y = (w / 2) * (h - i);
        ll z = ((w + 1) / 2) * (h - i);
        ll res = max(x, y, z) - min(x, y, z);
        ans = min(ans, res);
    }

    for (int i = 1; i <= w; i++) {
        ll x = i * h;
        ll y = ((w - i) / 2) * h;
        ll z = ((w - i + 1) / 2) * h;
        ll res = max(x, y, z) - min(x, y, z);
        ans = min(ans, res);
    }

    for (int i = 1; i <= w; i++) {
        ll x = i * h;
        ll y = (w - i) * (h / 2);
        ll z = (w - i) * ((h + 1) / 2);
        ll res = max(x, y, z) - min(x, y, z);
        ans = min(ans, res);
    }

    cout << ans << endl;

    return 0;
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define PB push_back
#define PPB pop_back
#define PF push_front
#define PPF pop_front
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); ++i)
#define f1(i, n) for (i = 1; i <= (n); ++i)
#define fab(i, a, b) for (i = (a); i <= (b); ++i)
#define fr(i, b, a) for (i = (b); i >= (a); --i)
#define endl "\n"
#define ln length

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
#define int long int

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
//typedef tuple<ll, ll, ll> tll

//* utility function
inline bool compare(ll i, ll j)
{
    return i > j;
}
//*/

//* function prototypes
template< typename T>
T modpow(T number, T power, T mod_value);
void seive(ll maximum_number);
//*/

//int row, column;
//int dx[8] = { 0,   1,  1,  1,  0,  -1, -1, -1};
//int dy[8] = {-1,  -1,  0,  1,  1,   1,  0, -1};
//              N   NE   E  SE   S   SW   W   NW
//int dx[4] = { 0,       1,      0,      -1    };
//int dy[4] = {-1,       0,      1,       0    };

const ll maxN = 1e7+10; const ll INF = 1e14;
const ll maxA = 1e6+10; const ll maxB = 320;


#ifdef DEBUG
#endif // DEBUG
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ###################################################################################################################
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
map<ll, string>res = {{0, "No"}, {1, "Yes"}};
ll nod[maxN+10];
void seive(ll n)
{
    ll i, j;
    f1(i, n) nod[i] = 2; nod[1] = 1;

    for (i = 2; i*i <= n; i++)
    {
        for (j = i*i; j <= n; j += i) nod[j] += 2; nod[i*i] -= 1;
    }
}

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //seive(maxN);
    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    	ll i, j, k, m, n, query_type, q;// ll a, b, x, y;

    	cin >> n;
    	seive(n);

    	ll ans = 0;
    	f1(i, n) ans += i*nod[i];
    	cout << ans << endl;
    }
    return 0;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ###################################################################################################################
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Measured memory_bytes: 81768
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,a,r = 0,l = 0;
    bool flag = 1;
    cin >> n >> k;
    --k;
    rep(i,n){
        cin >> a;
        if (a == 1) flag = 0;
        else if (flag) l++;
        else r++;
    }
    if (l != 0) l = (l-1)/k+1;
    if (r != 0) r = (r-1)/k+1;
    PRINT(min(l+r,(n-2)/k+1));
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq


def solve(H: int, N: int, A: "List[int]", B: "List[int]"):
    dp = [10**16]*(H+1)
    dp[0] = 0
    positions = [0]
    for i in range(len(dp)):
        c = dp[i]
        for j in range(N):
            ni = min(H, i+A[j])
            dp[ni] = min(dp[ni], c+B[j])
    print(dp[-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(H, N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] t = new long[N];

        for (int i = 0; i < N; i++) {
            t[i] = sc.nextLong();
        }

        if (N == 1) {
            System.out.println(t[0]);
            return;
        }

        long ans = lcm(t[0], t[1]);
        for (int i = 2; i < N; i++) {
            ans = lcm(ans, t[i]);
        }
        System.out.println(ans);
    }

    static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    static long gcd(long a, long b) {
        if (a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }

        long r = -1;
        while (r != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}


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



int main(){
    int N;
    cin >> N;
    vector<long long>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    bool A = true;
    for(int i=0;i<N-1;i++){
        if(vec.at(i) == vec.at(i+1)){
            A = false;
            break;
        }
    }
    if(A == true){
        cout <<"YES" <<endl;
    }
    else{
        cout <<"NO" << endl;
    }

}

Measured memory_bytes: 1792
N = int(input())
A = []
B = []

for i in range(N):
  a = int(input())
  A.append(a)

i = 0
judge = 1
count = 0
B.append(1)

while((judge == 1)and(len(B)<=len(A))):
  if(count == 0):
    i = A[0]
    count += 1
    B.append(i)
  else:
    i = A[i-1]
    B.append(i)
    count += 1
  #print(count,i)
  #print(B)
  if(i == 2):
    print(count)
    judge = 0

if(judge == 1):
  print(-1)

Measured memory_bytes: 7860
#include<iostream>
#include<deque>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main() {
	int n, sum = 0;
	cin >> n;
	deque<int>d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		sum += (d[i] - 1);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<String, Long> map = new HashMap<>();
		long total = 0;
		for ( int i = 0; i < n; i++ ) {
			char[] s = in.next().toCharArray();
			Arrays.sort(s);
			String key = new String(s);
			Long cnt = (map.containsKey(key) ? map.get(key) + 1 : 1);
			map.put(key, cnt);
			total += cnt - 1;
		}

//		for ( Entry<String, Long> en : map.entrySet() ) {
//			Long v = en.getValue();
//			total += v * (v - 1) / 2;
//		}

		System.out.println(total);
		in.close();
	}
}

Measured memory_bytes: 54468
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n,x,t; cin >> n >> x >> t;
  long long val=(long long)ceil((n*1.0)/(x*1.0));
  cout << val*t << endl;
}



Measured memory_bytes: 3728
N = int(input())


def gcd(a, b):
    result = a
    k = 0
    n = b

    while True:
        k = result % n
        result = n
        n = k
        if k == 0:
            break

    return result


def lcm(a, b):
    g = gcd(a, b)

    return a * (b // g)


def main():
    ans = 1

    for i in range(N):
        ans = lcm(ans, int(input()))

    print(ans)
    return


main()


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

string longestCommonSubsequence(string &s1, string &s2){

    int n = s1.size(), m = s2.size();
    // When building the answer, use the DP table itself
    // For each state check from which state we have arrived to the current state
    // If arrived from a diagonal state that means we need to include the
    // current character
    int dp[n+1][m+1];
    for(int i=0; i<=n; i++)
        dp[i][0] = 0;
    for(int j=0; j<=m; j++)
        dp[0][j] = 0;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++){
            if(s1[i-1] == s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }

    // Now we need to build the actual answer
    // Start from last cell
    // and check from which cell we reached that cell

    string ans;
    int i = n, j = m;
    while(i>0 and j>0){
        if(dp[i][j] == dp[i-1][j])
            i--;
        else if(dp[i][j] == dp[i][j-1])
            j--;
        else{
            // That means we have reached here from diagonally so include the
            // current character (and also the current characters of both strings must be equal)
            ans.push_back(s1[i-1]);
            i--;
            j--;
        }
    }

    reverse(ans.begin(), ans.end());
    return ans;
}

int main()
{
 string s1, s2;
 cin>>s1>>s2;
 string ans = longestCommonSubsequence(s1, s2);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 38812
n = int(input())
x = [list(map(int, input().split())) for i in range (n)]

grid = [list([0,0]) for i in range(n)]

for i in range(n):
    grid[i][0] = x[i][0] - x[i][1]
    grid[i][1] = x[i][0] + x[i][1]

new_grid = sorted(grid,key=lambda x:x[1])

cnt = 1
a = new_grid[0][1]

for i in range(n):
    if a <= new_grid[i][0]:
        cnt += 1
        a = new_grid[i][1]
print(cnt)

Measured memory_bytes: 43388
n,m = map(int,input().split())
li = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
 
li.sort()
bc.sort(key=lambda x:x[1],reverse=True)
l = []
l_len = 0
for b,c in bc:
    l += [c]*b
    l_len += b
    if l_len>n:
        break
    
ans = 0
for i in range(n):
    if i>=l_len:ans += li[i]
    else:ans += max(li[i],l[i])
print(ans)

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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()


signed main(){
    string st;
    cin>>st;
    bool f[26]={};
    for(int i=0;i<st.length();i++){
        f[st[i]-'a']=true;
    }
    for(int i=0;i<26;i++){
        if(!f[i]){
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512