akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<typename T> struct is_pair : false_type{};
template<typename T1, typename T2> struct is_pair<pair<T1, T2>> : true_type{};
template<typename T> struct is_vector : false_type{};
template<typename T> struct is_vector<vector<T>> : true_type{};

template<typename T1, typename T2>
istream &operator >> (istream &istr, pair<T1, T2> &p) {
  istr >> p.first >> p.second;
  return istr;
} 
template<typename T1, typename T2>
ostream &operator << (ostream &ostr, const pair<T1, T2> &p) {
  ostr << p.first << " " << p.second;
  return ostr;
}
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) return ostr;
  bool vp = is_vector<T>() || is_pair<T>();
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    ostr << (vp ? "\n" : " ") << *itr;
  }
  return ostr;
}

template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int modpow(int a, long long n, int mod = MOD) {
  int ret = 1;
  do {
    if (n & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
  } while (n >>= 1);
  return ret;
}

template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2>
bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) {
  return a.second != b.second ? a.second < b.second : a.first < b.first;
}
template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) return a.first < b.first;
  if (a.first == 0) return a.second >= 0 || b.first > 0;
  if (b.first == 0) return b.second < 0 && a.first < 0;
  return a.second * b.first < a.first * b.second;
}


/* -------- <templates end> -------- */


void solve() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];
  int ans = 1e9;
  rep1(i,100) {
    int cost = 0;
    rep(j,n) {
      cost += (arr[j] - i) * (arr[j] - i);
    }
    chmin(ans, cost);
  }
  cout << ans << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define CLR(array) memset( array, 0, sizeof array )
typedef long long int ll;



int n,k;

int const MAXN = 510000;


long long fac[MAXN], finv[MAXN], inv[MAXN];
long long A[MAXN];

// テーブルを作る前処理
void init_fac(ll MOD){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
    for (int i = 2; i < MAXN; 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 modcomb( int n, int k, ll MOD ){
	if( n < k )	return 0;
	if( n < 0 || k < 0 )	return 0;
	return fac[n] * ( finv[k] * finv[n-k] % MOD ) % MOD;
}

bool cmp_reverse( int a, int b ){
	return a > b;
}



int main(){
	ll const MOD = 1000000007L;
	init_fac(MOD);

	std::cin >> n >> k;

	for( int i = 1; i <= n; i++ )
		std::cin >> A[i];

	

	ll maxsum = 0;
	ll minsum = 0;

	std::sort( A+1, A+1+n );
	for( int i = k; i <= n; i++ ){
		// maxsum = ( maxsum + A[i] * modcomb( i-1, k-1, MOD ) % MOD ) % MOD;
		maxsum = maxsum + ( A[i] * modcomb(i-1,k-1,MOD) ) % MOD;
		maxsum %= MOD;
		// printf("maxsum = %lld\n", maxsum);
	}

	std::sort( A+1, A+1+n, cmp_reverse );
	for( int i = k; i <= n; i++ ){
		// minsum = ( minsum + A[i] * modcomb( i-1, k-1, MOD ) % MOD ) % MOD;
		minsum = minsum + ( A[i] * modcomb(i-1,k-1,MOD) ) % MOD;
		minsum %= MOD;
	}
	
	// printf("maxsum = %lld, minsum = %lld\n", maxsum, minsum );
	// std::cout << (maxsum - minsum + MOD) % MOD << std::endl;
	if( maxsum >= minsum )
		std::cout << (maxsum - minsum) % MOD << std::endl;
	else
		std::cout << maxsum - minsum + MOD << std::endl;

}


Measured memory_bytes: 14976
import numpy as np

H,W = map(int,input().split())
# 周りに壁を、0,1化、壁をTrueで持つ
grid = np.ones((H+2,W+2),dtype=np.bool)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '#')

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = x.T
  x = np.ravel(x) # to 1D array
  
  zero_idx = np.nonzero(x)[0]
  zero_span = np.diff(zero_idx) - 1 # 次の0までにある1の個数
  
  y = np.zeros(x.shape[0],dtype=np.int32)
  y[1:][zero_idx[:-1]] = zero_span # 1の個数の加算の起点
  y[zero_idx[1:]] -= zero_span # 1の個数の反映をやめる
  np.cumsum(y, out = y)
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)

answer = (F(True) + F(False)).max() - 1
print(answer)

Measured memory_bytes: 143380
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define N 50
using namespace std;
int main(){
  int i,j,k,l;
  int a[10000][N+1],b[(N+1)*N/2],n,p;
  a[0][0]=2;
  j=1;
  for(i=3;j<10000;i+=2){
    l=(int)sqrt(i)+1;
    for(k=3;k<l;k+=2){
      if(i%k==0)
	break;
    }
    if(k>=l){
      a[j][0]=i;
      j++;
    }
  }
  for(i=0;i<10000-N;i++){
    for(j=0;j<N;j++){
      a[i][j+1]=a[i][0]+a[i+j][0];
    }
  }
  while(cin>>n>>p&&(n!=-1||p!=-1)){
    for(i=0;a[i][0]<=n;i++);
    l=0;
    for(j=0;j<N;j++){
      for(k=0;k<N-j;k++){
	b[l]=a[i+j][k+1];
	l++;
      }
    }
    sort(b,b+(N+1)*N/2);
    cout<<b[p-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2864
def near(x, X):
    i = bisect_left(X, x)
    if i == 0: return [X[i]-x]
    elif i == len(X): return [X[i-1]-x]
    else: return [X[i]-x, X[i-1]-x]
from bisect import *
from itertools import product
A, B, Q = map(int, input().split())
S, T = [], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    res = 1<<40
    x = int(input())
    for a, b in product(near(x,S), near(x,T)):
            res = min(abs(a)+abs(a-b), abs(b)+abs(b-a), res)
    print(res)

Measured memory_bytes: 88544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    ll ans = stoll(s);
    for(int bit = 1; bit < (1 << (n - 1)); ++bit){
        vector<int> pos;
        pos.push_back(0);
        for(int i = 0; i < n - 1; ++i){
            if((bit >> i) & 1)  pos.push_back(i + 1);
        }
        pos.push_back(n);
        int sz = pos.size();
        for(int i = 0; i < sz - 1; ++i) ans += stoll(s.substr(pos[i], pos[i+1] - pos[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}

int n,k;
int a[105];
ll dp[105][100005];

int main() {
    IO;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    dp[n - 1][0] = 1;
    for (int i = 1; i <= k; i++) {
        dp[n - 1][i] = dp[n - 1][i - 1];
        if (i <= a[n - 1])
            dp[n - 1][i] = (1 + dp[n - 1][i])%MOD;
    }
    for (int i = n - 2; i >= 0; i--) {
        for (int j = 0; j <= k; j++) {
            if (j) {
                dp[i][j] = dp[i][j - 1];
            }
            dp[i][j] = (dp[i][j] + (dp[i + 1][j] - dp[i + 1][max(0,j - a[i] - 1)] + (((j - a[i] - 1) < 0)?dp[i + 1][0]:0))%MOD)%MOD;
        }
    }
    if (dp[0][k] < 0) dp[0][k] += MOD;
    if (k - 1 >= 0 && dp[0][k - 1] < 0) dp[0][k - 1] += MOD;
    cout << (dp[0][k] -(k == 0?0:dp[0][k -1]) + MOD)%MOD;
    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	priority_queue<double> q;
	for (int ii = 0; ii < N; ++ii){
		double tmp;
		cin >> tmp;
		q.push(-tmp);	//マイナスをかけていることに注意
	}

	while(q.size() > 1) {
		double tmp1 = q.top();
		q.pop();
		double tmp2 = q.top();
		q.pop();
		double tmp3 = (tmp1 + tmp2) / 2.0;
		q.push(tmp3);
	}

	cout << fixed << setprecision(10) << -q.top() << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <functional>
using namespace std;
using mylong = unsigned long long;


void MyFunc(mylong N, mylong A, mylong B)
{
  mylong Diff = B - A;
  if (Diff % 2 == 0)
  {
    cout << Diff / 2 << endl;
  }
  else
  {
    if ( Diff == 1 )
    {
      if ( (B - 1) > (N - A) )
      {
        cout << N - A  << endl;
      }
      else
      {
        cout << B - 1 << endl;
      }
    }
    else
    {
      if ( (B - 1) > (N - A) )
      {
        cout << N - B + (Diff - 1) / 2 + 1 << endl;
      }
      else
      {
        cout << A - 1 + (Diff - 1) / 2 + 1 << endl;
      }
    }
  }

}

int main(void)
{
  mylong N, A, B;
  cin >> N >> A >> B;

  function<void(mylong, mylong, mylong)> func = MyFunc;
  func(N, A, B);
  
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int x,a,b;

  cin >> x >> a >> b;

  if( b <= a){
    cout << "delicious" << endl;
  }else if( x+1 <= b-a ){
    cout << "dangerous" << endl;
  }else{
    cout << "safe" << endl;
  }

  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int Add, Sub, Mul;
  
  Add = A + B;
  Sub = A - B;
  Mul = A * B;
  
  int ans;
  ans = max(max(Add, Sub), Mul);
  cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(i % 2 == 0){
            cout << s.at(i);
        }
    }
}
   

Measured memory_bytes: 512
#include <stdio.h>

int main() {

  char O[51];
  char E[51];
  int n, m;
  int i;

  scanf("%s", &O);
  scanf("%s", &E);

  for(n = 0; O[n] != '\0'; n++);
  for(m = 0; E[m] != '\0'; m++);
  
  for(i = 0; i < n-1; i++) {
    printf("%c%c", O[i], E[i]);
  }
  if(n-m == 0) {
    printf("%c%c\n", O[i], E[i]);
  } else {
    printf("%c\n", O[i]);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

bool IsPrimeNumber(ll num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main() {
	ll a, b;
	in(a);
	in(b);
	
	auto p = primeFactor(gcd(a, b));

	outn(p.size()+1);

	return 0;

}


Measured memory_bytes: 256
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

x,a,b = IL()
if abs(a-x) < abs(b-x):
	print("A")
else:
	print("B")

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

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        int ai;
        cin >> ai;
        a.at(ai)++;
    }

    bool ok = true;
    if (n % 2 == 0) {
        rep(i,n) {
            if (i % 2 == 0 && a.at(i) != 0) ok = false;
            if (i % 2 == 1 && a.at(i) != 2) ok = false;
        }
    }
    else {
        if (a.at(0) != 1) ok = false;
        for (int i = 1; i < n; ++i) {
            if (i % 2 == 0 && a.at(i) != 2) ok = false;
            if (i % 2 == 1 && a.at(i) != 0) ok = false;
        }

    }
    ll ans = 1;
    for (int i = 0; i < n/2; ++i) {
        ans *= 2;
        ans %= MOD;
    }
    if (ok) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}

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

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

    string strN = to_string(N);
    for (int i = 0; i < 3; i++) {
        if (strN[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h> 
#include<string.h> 
#include <stdlib.h>



char str[5001];
char substr[25000][6];
char tmp[6];
/*
int compare_str(const void * a, const void * b){
    return strcmp((char*)a, (char*)b);
}*/

int main(void) 
{ 
    int i,j;
  int K;
  scanf("%s",str);
  scanf("%d",&K);

  int substr_num = 0;

  int len = strlen(str);
  for(int n = 1; n <= 5; n++){
      for(int i = 0; i <= len-n; i++){

          strncpy(substr[substr_num], str+i, n);
          substr_num++;
      }
  }
  
  /*int min = 0;
  for(i = 0; i < substr_num; i++){
      if(strcmp(substr[min], substr[i]) > 0) min = i;
  }*/
  
  //qsort(substr,substr_num,sizeof(char*),compare_str);
  
  char order[10][6];

  for(int n = 1; n <= K; n++){
    char min[] = "zzzzz";
    for(i = 0; i < substr_num; i++){
       if(strcmp(min,substr[i]) > 0) strcpy(min,substr[i]);
    }
    strcpy(order[n], min);
    for(i = 0; i < substr_num; i++){
        if(strcmp(order[n],substr[i]) == 0) strcpy(substr[i],"zzzzz");
    }
  }
  printf("%s\n",order[K]);
 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,D,E,K;
  cin >> A >> B >> C >> D >> E >> K;
  if(E - A > K){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    deque<int> q;
    rep(i, n) {
        int id = lower_bound(all(q), a[i]) - q.begin();
        if (id == 0) q.push_front(a[i]);
        else q[id-1] = a[i];
    }

    cout << q.size() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using namespace std::literals::chrono_literals;
using namespace std::literals::string_literals;
using ll = long long;

#define repi(i, s, n) for (long long i {s}, i##_len{n}; i < i##_len; ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) std::begin(x), std::end(x)

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
namespace xmaho
{
inline namespace integer
{
template<typename C>
constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type;
template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept;
}
}
using namespace xmaho;

int main()
{
  auto h {get_value<ll>()};
  const auto n {get_value<ll>()};

  rep(i, n) {
    h -= get_value<ll>();
    if (h <= 0) {
      cout << true << '\n';
      return 0;
    }
  }

  cout << false << '\n';
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}

template<typename C>
constexpr auto xmaho::integer::ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type
{ return c.size(); }

template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t xmaho::integer::ssize(const T (&)[N]) noexcept
{ return N; }


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a[3]={0,0,0},b=0;
	int i,j;

	scanf("%d %d %d",&a[0],&a[1],&a[2]);

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			if(a[i]<a[j]){
				b=a[i];
				a[i]=a[j];
				a[j]=b;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);

	return 0;
}

Measured memory_bytes: 1776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>
#include<utility>
#include<deque>
#include<vector>
#include<locale>
#include<sstream>
#define f(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
int main(){
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){ 
            if(i*10000+j*5000+(n-i-j)*1000==y){ 
                cout<<i<<' '<<j<<' '<<n-i-j<<'\n';
				return 0;
            }
        }
	}
    cout<<"-1 -1 -1\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
const int MM = 3002;

char a[MM], b[MM];
int dp[MM][MM];
vector<char> str;

int main(){
    
    scanf("%s %s", a, b);
    
    int n = strlen(a), m = strlen(b);
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i-1] == b[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    int i = n, j = m;
    while(i > 0 && j > 0){
        assert( i > 0 && j > 0);
        if(dp[i][j] == dp[i-1][j])
            i--;
        else if(dp[i][j] == dp[i][j-1])
            j--;
        else{
            i--, j--;
            str.push_back(a[i]);
        }
    }
    
    for(int i = str.size()-1; i >= 0; i--){
        printf("%c", str[i]);
    }
    
    return 0;
}

Measured memory_bytes: 35584
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

char mp[2020][2020];
ll ans = 0;

ll X[2020][2020];
ll Y[2020][2020];

int main(){
    
    for(ll i = 0; i < 2020; i++){
        for(ll j = 0; j < 2020; j++){
            mp[i][j] = '#';
        }
    }

    ll H, W;
    cin >> H >> W;
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            cin >> mp[y][x];
        }
    }
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            if(mp[y][x] == '#')continue;
            if(mp[y][x - 1] == '#'){
                ll cnt = 0;
                for(ll xx = x; mp[y][xx] == '.'; xx++)cnt++;
                for(ll xx = x; mp[y][xx] == '.'; xx++)X[y][xx] = cnt;
            }
            if(mp[y - 1][x] == '#'){
                ll cnt = 0;
                for(ll yy = y; mp[yy][x] == '.'; yy++)cnt++;
                for(ll yy = y; mp[yy][x] == '.'; yy++)Y[yy][x] = cnt;
            }
        }
    }
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            ans = max(ans, X[y][x] + Y[y][x] - 1LL);
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67968
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


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

	int mi = inf;
	REP(i, n)
		if (abs(mi) > abs(l + i + 1 - 1)) mi = l + i + 1 - 1;

	int all = (l + l + n - 1) * n / 2;

	cout << all - mi << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll ans = 1;
  for(ll i=2;i*i<=N;++i) {
    if(N%i==0) ans = i;
  }
  cout<<ans+N/ans-2<<endl;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char mm[2001] [2001];
int li[5][2001][2001];
int main(){
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	rb(i,1,h){
		rb(j,1,w){
			cin>>mm[i][j];
		}
	}
	rb(i,1,h){
		rb(j,1,w){
			if(mm[i][j]=='#') continue;
			li[1][i][j]=li[1][i-1][j]+1;
		}
	}
	rl(i,h,1){
		rb(j,1,w){
			if(mm[i][j]=='#') continue;
			li[2][i][j]=li[2][i+1][j]+1;
		}
	}
	rb(i,1,h){
		rb(j,1,w){
			if(mm[i][j]=='#') continue;
			li[3][i][j]=li[3][i][j-1]+1;
		}
	}
	rb(i,1,h){
		rl(j,w,1){
			if(mm[i][j]=='#') continue;
			li[4][i][j]=li[4][i][j+1]+1;
		}
	}
	int res=0;
	rb(i,1,h){
		rb(j,1,w){
			res=max(res,li[4][i][j]+li[3][i][j]+li[2][i][j]+li[1][i][j]-3);
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 68096
A,B,C,X = [int(input()) for i in range(4)]
cnt = 0
for a in range(A+1):
    for b in range(B+1):
        abx = X-(a*500+b*100)
        if abx < 0:break
        if abx%50==0 and abx//50 <= C:
            cnt += 1
print(cnt)

Measured memory_bytes: 3060
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var list = nextCharArray();
  var rl = 0;
  var count = 0;
  for(var i = 0; i < N - 1; i++){
    if(list[i] == list[i + 1]){
      count++;
    }else if(list[i] == "R" && list[i + 1] == "L"){
      rl++;
    }
  }
  
  
  myout(Math.min(count + K * 2, N - 1));
}

Measured memory_bytes: 34524
#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s, p;
    cin >> s >> p;
    int frag = 0;
    s += s;
    int sLen = s.length();
    int pLen = p.length();
    for (int i = 0; i < sLen - pLen; i++) {
        if (s.substr(i, pLen) == p) {
            frag = 1;
            break;
        }
    }
    if (frag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  while(1) {
    vector<int> a, b;
    for(int k = 0; k < 2; ++k) {
      int n;
      cin >> n;
      if(n == 0) return 0;
      for(int i = 0; i < n; ++i) {
        int c, d;
        cin >> c >> d;
        a.push_back(c);
        b.push_back(d);
      }
    }
    int n = a.size();
    int dp[n];
    for(int i = 0; i < n; ++i) dp[i] = 1;
    for(int t = 0; t < n; ++t) {
      for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
          if(a[i] < a[j] && b[i] < b[j])
            dp[j] = max(dp[j], dp[i] + 1);
        }
      }
    }
    cout << *max_element(dp, dp+n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = 1;
		int y = 1;

		while((x = sc.nextInt()) != 0){
			System.out.println("Case"+" "+y+++":"+" "+x);
		}
	}
}



Measured memory_bytes: 42604
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,k=MI()
	p=LI()

	for i in range(n):
		p[i]=p[i]/2+0.5
	#print(p)

	ans=sum(p[:k])
	now=sum(p[:k])

	for i in range(n-k):
		now=now-p[i]+p[i+k]
		ans=max(ans,now)
	print(ans)















if __name__ == "__main__":
	main()


Measured memory_bytes: 31848
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
long long n;
long long a[200005];
long long sum=0;
long long ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]-=i;
	}
	long long temp;
	if(n%2==1) temp=(n+1)/2;
	else temp=n/2; 
	sort(a+1,a+n+1);
	ans=a[temp];
	for(int i=1;i<=n;i++)
	{
		sum+=abs(ans-a[i]);
	}
	printf("%lld",sum);
}

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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int H,W,K,O=0;
  cin >> H >> W >> K;
  int C[H][W], T[H][W];
  string s;
  for(int i=0;i<H;i++){
    cin >> s;
    for(int j=0;j<W;j++){
      if(s[j] == '#'){
        C[i][j] = 1;
        T[i][j] = 1;
      }else{
        C[i][j] = 0;
        T[i][j] = 0;
      }
    }
  }
  int A = int(Exp(2,H+W,999999999));  
  int count=0;
  for(int i = 0;i<A;i++){
    for(int j=0;j<H;j++){
      if(i & (1<<j)){
        for(int k=0;k<W;k++){
          T[j][k] = 0;
        }
      }
    }
    
    for(int j=H;j<H+W;j++){
      if(i & (1<<j)){
        for(int k=0;k<H;k++){
          T[k][j-H] = 0;
        }
      }
    }
    
    for(int j=0;j<H;j++){
      for(int k=0;k<W;k++){
        if(T[j][k]==1){
          count++;
        }
        T[j][k]=C[j][k];
      }
    }
    if(count == K){
      O++;
//      cout << i <<endl;
    }
    count =0;
  }
  
  cout << O << endl;
  return 0;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i<n; ++i) {
        cin >> v[i];
    }
    reverse(v.begin(), v.end());
    for (int i=0; i<n; ++i) {
        cout << (i == 0 ? "" : " ") << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1196
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import *

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

class union_find:
  def __init__(self, n, X):
    self.par = [-1] * n
    self.rank = [0] * n
    self._count = [0] * n
    self._sum = list(X)

  def __repr__(self):
    return "union_find({0})".format([self.root(i) for i in range(n)])

  def unite(self, x, y, v):
    x = self.root(x)
    y = self.root(y)
    self._count[x] += 1
    if x == y:      
      return
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
      self._count[y] += self._count[x]
      self._sum[y] += self._sum[x]
    else:
      self.par[y] = x
      self._count[x] += self._count[y]
      self._sum[x] += self._sum[y]
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1

  def reset_count(self, x):
    x = self.root(x)
    self._count[x] = 0

  def root(self, x):
    if self.par[x] == -1:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]

  def count(self, x):
    return self._count[self.root(x)]

  def sum(self, x):
    return self._sum[self.root(x)]

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M = reads()
X = reads()
edges = []
for _ in range(M):
  a, b, y = reads()
  a, b = a-1, b-1
  edges.append((y, a, b))
edges.sort()

uf = union_find(N, X)

ans = 0
for y, a, b in edges:
  uf.unite(a, b, y)
  # print(f"a={a}, b={b}, y={y}, count={uf.count(a)}, sum={uf.sum(a)}")
  if uf.sum(a) >= y:
    # print(f"{uf.count(a)} edges added")
    ans += uf.count(a)
    uf.reset_count(a)
print(M - ans)


Measured memory_bytes: 124952
# from heapq import heappush, heappop, heapify
# from collections import deque, defaultdict, Counter
# import itertools
# from itertools import permutations, combinations, accumulate
import sys
# import bisect
# import string
# import math
# import time
# from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


# YN = ['No', 'Yes']
MOD = 10**9+7
# inf = float('inf')
# IINF = 10**10
# l_alp = string.ascii_lowercase
# u_alp = string.ascii_uppercase
# ts = time.time()
# sys.setrecursionlimit(10**6)
# nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False

# xor
# n + i = n ^ i implies n & i = 0


# def sumXOR(arr,  n):
#     _sum = 0
#     for i in range(0, 64):
#         zc = 0
#         oc = 0

#         # Individual sum at each bit position
#         idsum = 0
#         for j in range(0, n):
#             if (arr[j] % 2 == 0):
#                 zc = zc + 1
#             else:
#                 oc = oc + 1
#             arr[j] = arr[j] >> 1

#         # calculating individual bit sum
#         idsum = oc * zc * (1 << i)
#         print(zc, oc, idsum)

#         # final sum
#         _sum = _sum + idsum
#         _sum %= MOD

#     return _sum


def main():
    N = I()
    A = list(MI())
    BIT = 61
    C = [[0] * BIT for i in range(N+1)]
    pows = [pow(2, i, MOD) for i in range(BIT)]
    ans = 0

    for i in range(N):
        bit = 1
        for j in range(BIT):
            if A[i] & bit:
                C[i+1][j] = C[i][j] + 1
            else:
                C[i+1][j] = C[i][j]
            bit = bit << 1

    for i in range(N):
        bit = 1
        for j in range(BIT):
            oc = C[N][j] - C[i][j]
            # print('b', ans, i, j, bit, oc)
            if A[i] & bit:
                zc = N - i - oc
                ans += pows[j] * zc
            elif oc != 0:
                ans += pows[j] * oc
            ans %= MOD
            bit = bit << 1
            # print('a', ans, i, j, bit, oc)

    print(ans)


if __name__ == '__main__':
    main()


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

struct UnionFind {
    static const int Max = 300001;
    int par[Max];
    int rank[Max];

    void init(int n) {
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind r, l;
    r.init(N+1);
    l.init(N+1);

    rep(i, K) {
        int p, q;
        cin >> p >> q;
        p--, q--;
        r.unite(p, q);
    }

    rep(i, L) {
        int r, s;
        cin >> r >> s;
        r--, s--;
        l.unite(r, s);
    }

    map< pair<int, int>, int> mp;
    rep(i, N) {
        mp[{ r.find(i), l.find(i) }]++;
    }

    rep(i, N) {
        cout << mp[{ r.find(i), l.find(i) }] << " ";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 16000
from collections import deque
s = deque(input())
le = len(s)
cnt = 0
while le>1:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    ll ans=0;
    rep(i,n-1){
        ans+=min((x[i+1]-x[i])*a,b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){

	string c;
	
	cin>>c;
	
	if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
	cout<<"vowel"<<endl;
	}else{
	cout<<"consonant"<<endl;
	}
	
	
return 0;

}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	int[][] map;
	
	int[] dx = {-1,0,1,1,1,0,-1,-1};
	int[] dy = {-1,-1,-1,0,1,1,1,0};
	void rec(int i, int j , int l){
		for(int z = 0; z < 8 ; z++){
			if(map[i+dx[z]][j+dy[z]] == -1){
				map[i+dx[z]][j+dy[z]] = l;
				rec(i+dx[z],j+dy[z],map[i][j]);
			}
		}
	}
	
	void run(){
		for(;;){
			int w = sc.nextInt();
			int h = sc.nextInt();
			map = new int[h+2][w+2];
			if((w|h) == 0){
				break;
			}
		
			for(int i = 1; i < h +1 ;i++){
				for(int j = 1; j < w + 1; j++){
					map[i][j] = - sc.nextInt();
				}
			}
			
			int l = 1;
			for(int i = 1 ; i <h+1 ; i++){
				for(int j = 1 ; j < w +1; j++){
					if(map[i][j] == -1){
						map[i][j] = l++;
						rec(i,j,map[i][j]);
					}
				}
			}
			System.out.println(l-1);
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
using namespace std;

int k[250000][500];

int main(){
	int n,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k[0][i];
	}
	for(int i=0;i<n-1;i++){
		for(int j=n-2;j>=i;j--){
			if(k[sum][j]>k[sum][j+1]){
				sum++;
				for(int l=0;l<n;l++){
					k[sum][l]=k[sum-1][l];
				}
				k[sum][j]=k[sum-1][j+1];
				k[sum][j+1]=k[sum-1][j];
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<k[sum][i];
		if(i<n-1){
			cout<<' ';
		}
		else{cout<<endl;}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<math.h>
int main()
{
	double a,b,m1,n1,m2,n2,t;
	scanf("%lf%lf",&a,&b);
	m2=floor((a+1)/0.08);
	n2=floor((b+1)/0.1);
	m1=ceil((a-1)/0.08);
	n1=ceil((b-1)/0.1);
	//printf("%lf%lf%lf%lf",m1,n1,m2,n2);
	if(m1>n1)
	t=n1;
	else
	t=m1;
	for(t;t<=m2&&t<=n2;t++)
	{
		if(floor(t*0.08)==a&&floor(t*0.1)==b)
		{
			printf("%.0lf",t);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(ll i = 0; i < N; i++)cin>>A[i]>>B[i];
  ll a = A[0],b=B[0];
  for(ll i = 1; i < N;i++){
    ll t = max((a-1)/A[i],(b-1)/B[i]);
    a=A[i]*(t+1);
    b=B[i]*(t+1);
  }
  cout<<a+b<<endl;
}

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

public class Main {
    void run() {
        while (true) {
            int H = readInt();
            int W = readInt();
            if(H == 0 && W == 0) break;
            char[][] board = new char[H][W];
            for (int i = 0; i < H; i++) {
                board[i] = read().toCharArray();
            }
            int[][] left = new int[H][W];
            for (int y = 0; y < H; y++) {
                for (int x = 0; x < W; x++) {
                    if (board[y][x] == '*') {
                        left[y][x] = 0;
                    }
                    else {
                        if (x == 0) left[y][x] = 1;
                        else left[y][x] = left[y][x - 1] + 1;
                    }
                }
//                sysout.printf("left[%d] = %s\n", y, Arrays.toString(left[y]));
            }

            int maxArea = 0;
            for (int x = 0; x < W; x++) {
//                sysout.println("x = " + x);

                int[] L = new int[H];
                int[] R = new int[H];
                Stack<Integer> stk = new Stack<Integer>();
                for (int y = 0; y < H; y++) {
                    while (stk.isEmpty() == false && left[stk.peek()][x] >= left[y][x]) stk.pop();
                    if (stk.isEmpty()) L[y] = 0;
                    else L[y] = stk.peek() + 1;
                    stk.push(y);
                }

                stk.clear();
                for (int y = H - 1; y >= 0; y--) {
                    while (stk.isEmpty() == false && left[stk.peek()][x] >= left[y][x]) stk.pop();
                    if (stk.isEmpty()) R[y] = H;
                    else R[y] = stk.peek();
                    stk.push(y);
                }

                for (int y = 0; y < H; y++) {
//                    sysout.printf("%d: %d <> %d\n", y, L[y], R[y]);
                    maxArea = Math.max(maxArea, left[y][x] * (R[y] - L[y]));
                }
            }

            sysout.println(maxArea);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Measured memory_bytes: 44028