akhauriyash/Code-Regression huggingface dataset:
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");


i64 n,k;
cin>>n>>k;
vi64 v(n);
forn(i,n)cin>>v[i];

sort(all(v));
i64 sum=0;
forn(i,k)sum+=v[i];
cout<<sum;

    return 0;
  }


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x; ll ans=0;
	cin >> x;
	ans += ll(1000) * (x/500);
	x%=500;
	ans += ll(5) * (x/5);
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a[101];
	int n;
  	int b = 0;
  	scanf("%d",&n);
  	for(int i = 0;i <= n;i++){
      	scanf("%d",&a[i]);
    }for(int j = 0;j < n;j++){
		if(a[j]%2 == 0 && a[j]%3 != 0 && a[j]%5 != 0){
          	b = 1;
        }
    }if(b == 0){
      	puts("APPROVED");
    }else{
      	puts("DENIED");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

void solve() {
    int n;
    cin >> n;
    
    ll a, b, x = 0;
    cin >> a >> b;
    for (int i = 2; i < n; ++i) {
        ll temp;
        cin >> temp;
        x ^= temp;
    }
    
    if ((a + b - x) % 2 != 0) {
        cout << "-1\n";
        return;
    }
    
    ll d = (a + b - x) / 2;
    ll ans = d;
    for (int i = 60; i >= 0; --i) {
        int db = (d >> i) & 1, xb = (x >> i) & 1;
        if (db) {
            if (xb) {
                cout << "-1\n";
                return;
            }
        }
        else {
            if (xb) {
                if ((ans | (1LL << i)) <= a)
                    ans |= 1LL << i;
            }
        }
//        err(ans);
    }
    
    if (ans > a || ans == 0)
        cout << "-1\n";
    else
        cout << a - ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

const double bound[10] = {91, 81, 75, 69, 64, 60, 57, 54, 51, 48};
const std::string rank[11]  = {"heavy", "light heavy", "middle", "light middle", "welter", "light welter", "light", "feather", "bantam", "fly", "light fly"};

int output(double weight)
{
	for (int i = 0; i < 10; i++) {
		if (weight > bound[i]) return i;
	}
	return 10;
}

int main()
{
	double weight;
	std::string str;
	while (std::cin >> weight) {
		std::cout << rank[output(weight)] << std::endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define Nmax 3005
using namespace std;

int n;
double p[Nmax], dp[Nmax][Nmax];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
    }

    ///dp[i][j] = probabilitatea de a avea exact i de H aruncând primele j monede

    dp[0][0] = 1;
    for (int j = 1; j <= n; ++j) {
        dp[0][j] = dp[0][j - 1] * (1 - p[j]);
    }

    cout << setprecision(10);
    double sol = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            dp[i][j] = dp[i - 1][j - 1] * p[j] + dp[i][j - 1] * (1 - p[j]);
            //cout << i << " " << j << " " << dp[i][j] << "\n";
        }
        if (i >= (n / 2 + 1)) {
            sol += dp[i][n];
        }
    }

    cout << sol;
    return 0;
}


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

#define int 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; }


int a[200010];
signed main(){
	int n;
	cin >> n;

	map<int, int> mp;
	int all = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		all += mp[a[i]];
		mp[a[i]]++;
	}

	for(int i = 0;i < n;i++){
		cout << all - (mp[a[i]]-1) << endl;
	}

	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	
	int n,k;
	cin>>n>>k;
	long long ans=0;
	
	for(int i=1;i<=n;i++)
	{
		ans+=n/i*max(0,i-k)+max(0,n%i-k+1);
		if(k==0)
			ans--;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; string t="Yes"; int u;
  cin>>s;
  vector<char> a(s.size());
  for(int i=0;i<s.size();i++){
   a.at(i)=s.at(i); 
  }
  sort(a.begin(),a.end());
  if(s.size()%2==0) u=1;
  else u=2;
  switch(u){
    case 1: for(int i=0;2*i<a.size()-1;i++){
               if(a.at(2*i)!=a.at(2*i+1))
               t="No";
             } break;
    case 2: t="No"; break;
  }
  cout<<t<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;
const ll mod = pow(10,9) + 7;


int main(){
    ll n, k;
    cin >> n >> k;
    ll ct = 1;

    if (k == n+1) cout << '1' << endl;
    else{
        FOR(i, k, n+1){
            ct = ct + (i*(n-i+1) + 1)%mod;
        } 
        cout << ct%mod << endl;
    }
}


Measured memory_bytes: 3636
#!/usr/bin/perl

my ($h,$w) = map {$_ - 0} split(/\s+/o,<STDIN>);

my $ww = '.' x $w;

my @d = ();
for(my $i=0;$i<$h;$i++){
  ( my $v = <STDIN> ) =~ s/[\x00-\x20]+$//ios;
  next if $v eq $ww;
  push(@d,$v);
}

$h = 1 + $#d;

my $ii = 0;
for(my $i=0;$i<$w;$i++){
  my $j = 0;
  for($j=0;$j<$h;$j++){
    last if substr($d[$j],$ii,1) ne '.';
  }
  if( $j >= $h ){
    for($j=0;$j<$h;$j++){
      substr($d[$j],$ii,1) = '';
    }
  } else {
    $ii ++;
  }
}

for($j=0;$j<$h;$j++){
  print "$d[$j]\n";
}

exit(0);



Measured memory_bytes: 640
int main(int argc, char* argv[])
{
  int a, b;
  char op;
  scanf("%d %c %d", &a, &op, &b);
  while(op != '?'){
    switch(op){
      case '+':
        printf("%d\n", a+b);
        break;
      case '-':
        printf("%d\n", a-b);
        break;
     case '/':
        printf("%d\n", a/b);
        break;
     case '*':
        printf("%d\n", a*b);
        break;
    }
    scanf("%d %c %d", &a, &op, &b);  
  }
  return(0);
}

Measured memory_bytes: 600
#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>;

int main(){
    int r;
    cin >> r;
    cout << pow(r,2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, *a;
    cin >> n;
    a = new int[n];
    int i;
    for (i = 0; i < n; i++) 
        cin >> a[i];
    
    int j;
    for (i = 0; i < n; i++) {
        for (j = n-1; j > i; j--) {
            if (a[j] > a[j-1]) {
                int tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
            }
        }
    }
    int alice = 0, bob = 0;
    for (i = 0; i < n; i += 2)
        alice += a[i];
    for (i = 1; i < n; i += 2)
        bob += a[i];
    cout << alice - bob << endl;
    
    return 0;
}

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

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


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;
	if (S.front() == S.back()) {
		int turn = S.size() - 3;
		if (turn % 2 == 0) printf("Second\n");
		else printf("First\n");
	} else {
		int turn = S.size() - 3;
		if (turn % 2 == 0) printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005],b[100005];
long long inv[100005],c[100005],d[100005],e[100005];
const long long MOD=1000000007;
int C (int n,int m) {
	if (n<m) return 0;
	if (m==0) return 1;
	if (m<0) return 0;
	long long ans=1;
	int i;
	ans=ans*c[n-m]%MOD;
	ans=ans*e[n-m]%MOD;
	/*for (i=n;i>m;i--) {
		ans=ans*i%MOD;
		ans=ans*inv[i-m]%MOD;
	}*/
	return (int)ans;
}
int C1 (int n,int m) {
	if (n<m) return 0;
	if (m==0) return 1;
	if (m<0) return 0;
	long long ans=1;
	int i;
	ans=ans*d[n-m]%MOD;
	ans=ans*e[n-m]%MOD;
	return (int)ans;
}
long long exgcd (long long aa,long long bb,long long &x,long long &y) {
	if (bb==0) {
		x=1;y=0;return aa;
	}
	long long t=exgcd(bb,aa%bb,y,x);
	y-=aa/bb*x;
	return t;
}
long long get_inverse (int t) {
	long long x,y;
	exgcd(t,MOD,x,y);
	return ((x%MOD)+MOD)%MOD;
}
int main ( ) {
	int n,i,j,k,t,tt;
	scanf("%d",&n);
	for (i=1;i<=n+1;i++) {
		scanf("%d",&a[i]);
		if (!b[a[i]]) b[a[i]]=i; else t=i,tt=b[a[i]];
	}
	c[0]=1;d[0]=1;e[0]=1;
	for (i=1;i<=n+1;i++) c[i]=c[i-1]*(n+2-i)%MOD;
	for (i=1;i<=tt-1+n+1-t;i++) d[i]=d[i-1]*(tt-1+n+1-t+1-i)%MOD;
	for (i=1;i<=n+1;i++) inv[i]=get_inverse(i);
	for (i=1;i<=n+1;i++) e[i]=e[i-1]*inv[i]%MOD;
	printf("%d\n",n);
	for (i=2;i<=n;i++) {
		long long ans=(C(n+1,i)+MOD-C1(tt-1+n+1-t,i-1))%MOD;
		printf("%I64d\n",ans);
	}
	puts("1");
	return 0;
}
/*
Sample Input 1
3
1 2 1 3
Sample Output 1
3
5
4
1
Sample Input 2
1
1 1
Sample Output 2
1
1
Sample Input 3
32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9
Sample Output 3
32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1
*/

Measured memory_bytes: 10496
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, h, w;
	cin >> n >> h >> w;
	vl x(n);
	REP(i, n)cin >> x[i];
	vi b(n * w, 0);
	REP(i, n) {
		int j = i * w;
		if (i % 2 == 0)j += x[i];
		else j -= x[i];
		REP(k, w) {
			b[j + k] = 1;
		}
	}
	ll ans = 0;
	REP(i, b.size())if (b[i] == 0)ans++;
	cout << ans * h << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include<map>
using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int A;
    int ans = 0;
    cin >> A;
    ans += A;
    cin >> A;
    ans += A;
    cin >> A;
    ans += A;

    fin((ans >= 22)?"bust":"win");
    return 0;
}

Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main (){
  int a,b,w;
  cin >> w >> a >> b;
  
  if (b >= a && b <= a+w) {cout<<0; return 0;}
  
  if (b >= a + w) cout<<b - (a + w);
  else cout<<a - (b + w);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a, b, c, d; cin  >> a >> b >> c >> d;
	if (a+b> c+d){
		print("Left");
	}else if (a+b< c+d){
		print("Right");
	}else {
		print("Balanced");
	}
}

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

int main() {

  ll N;
  cin >> N;

  ll tmp1, tmp2;
  ll cnt = 0;
  ll max = 0;
  for(int i = 0; i < N; i++){
    cin >> tmp1 >> tmp2;
    if(tmp1 == tmp2){
      cnt++;
      if(cnt > max){
        max = cnt;
      }
    }else{
      cnt = 0;
    }
  }
  if(max >= 3){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

A,B = I()
if A*B%2 == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9988
from collections import defaultdict as dd
import sys
k = int(input())

if k <= 9:
  print(k)
  sys.exit()

matsubi_dic = dd(lambda: [])
for i in range(0, 10):
  nums = [i-1, i, i+1]
  matsubi_dic[i] = [num for num in nums if num >= 0 and num <= 9]
#print(matsubi_dic) 
  
#ketaごとに保存 runrun[keta] -> list
runrun = dd(list)
counter = 0
for keta in range(1, 100000000000):
  if keta == 1:
    runrun[keta] = list(range(1, 10))
    counter += 9
    #print(runrun, counter)
  else:
    for num in runrun[keta - 1]:
      matsubi = int(str(num)[keta-2])
      for new_matsubi in matsubi_dic[matsubi]:
        runrun[keta].append(int(str(num) + str(new_matsubi)))
        counter += 1
        if counter == k:
          print(int(str(num) + str(new_matsubi)))
          sys.exit()
      
    

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	for (int i=0; i<a; i++)
		for (int j=0; j<b; j++) {
			string s; cin>>s;
			if(s=="snuke") {
				cout<<char('A'+j)<<i+1<<"\n";
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
//package beginner164.b;

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int tHealth = in.nextInt();
            int tStrength = in.nextInt();
            int aHealth = in.nextInt();
            int aStrength = in.nextInt();

            // T, A, T, A, T, A...

            double turnsNeededForT = Math.ceil((double)aHealth / tStrength);
            double turnsNeededForA = Math.ceil((double)tHealth / aStrength);

            if (turnsNeededForT <= turnsNeededForA) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

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

using namespace std;

const int MAXN = 2000;
int a[MAXN];

int main()
{
    int n, z, w;
    cin >> n >> z >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    if (n == 1)
        cout << abs(a[0] - w) << endl;
    else
        cout << max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2])) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, t;
    vector<int> health;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> t;
        health.push_back(t);
    }
    sort(begin(health), end(health));
    if(k > n) k = n;
    long long tot = accumulate(begin(health), begin(health) + n - k, (long long)0);
    cout << tot <<endl;
    return 0;
}

Measured memory_bytes: 1400
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBuffet solver = new BBuffet();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBuffet {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            int b[] = new int[n];
            int c[] = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            for (int i = 0; i < n; i++) b[i] = in.nextInt();
            for (int i = 0; i < n - 1; i++) c[i] = in.nextInt();
            int temp = -1;
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += b[a[i] - 1];
                if (a[i] == temp + 1) {
                    ans += c[temp - 1];
                }
                temp = a[i];
            }
            out.println(ans);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
void dfs(vector<ll> vc[],ll i,ll fl[]){
	fl[i]=1;

	ll j;
	for(j=0;j<vc[i].size();j++){
		if(fl[vc[i][j]]==0){
			dfs(vc,vc[i][j],fl);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;

	vector<ll> vc[n+1];
	for(i=1;i<=m;i++){
		cin>>k>>l>>j;
		vc[k].ps(l);
		vc[l].ps(k);
	}
	
	ll fl[n+1]={0},c=0;
	for(i=1;i<=n;i++){
		if(fl[i]==0){
			c++;
			dfs(vc,i,fl);
		}
	}

	cout<<c;
	return 0;
}


Measured memory_bytes: 8576
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e5 + 10;
struct Point
{
	LL x, y;
	Point(LL x = 0, LL y = 0)
	{
		this->x = x;
		this->y = y;
	}
};

LL cross(const Point& p1, const Point& p2)
{
	return (p1.x * p2.y - p1.y * p2.x);
}
bool cmp1(const Point& a, const Point& b)
{
	return cross(a, b) > 0;
}

int Quadrant(const Point& a)
{
	if (a.x > 0 && a.y >= 0)  return 1;
	if (a.x <= 0 && a.y > 0)  return 2;
	if (a.x < 0 && a.y <= 0)  return 3;
	if (a.x >= 0 && a.y < 0)  return 4;
	return 0;
}
bool cmp(const Point& a, const Point& b)  //先按象限从小到大排序 再按极角从小到大排序
{
	if (Quadrant(a) == Quadrant(b))//返回值就是象限
		return cmp1(a, b);
	else return Quadrant(a) < Quadrant(b);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<Point> vp;
	for (int i = 0; i < n; i++)
	{
		LL x, y;
		cin >> x >> y;
		vp.emplace_back(x, y);
	}
	sort(vp.begin(), vp.end(), cmp);
	for (int i = 0; i < n; i++) vp.push_back(vp[i]);
	LL ans = 0;
	for (int i = 0; i < n; i++)
	{
		LL sumx = 0, sumy = 0;
		for (int j = i; j < i + n; j++)
		{
			sumx += vp[j].x;
			sumy += vp[j].y;
			ans = max(ans, sumx * sumx + sumy * sumy);
		}
	}
	printf("%.15f\n", sqrt(ans));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b;
   cin >> a >> b; 
   if(b>=a)
   cout << a << endl;
   else 
   cout << a-1 << endl;
}

Measured memory_bytes: 256
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]


k = int(input())
a,b = NextInts()

ju = False

for i in range(a, b+1):
    if i%k == 0:
        ju = True

if ju:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9144
n = gets.chomp.to_i
a = []
a = gets.chomp.split(" ").map(&:to_i)
a.sort!
a.reverse!
alice = 0
bob = 0
for i in 0...n
    if i % 2 == 0
        alice += a[i]
    else
        bob += a[i]
    end
end
print(alice - bob)

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N, K, mask;

int is_ok(int n){
  int i;
  while(n){
    i = n % 10;
    n /= 10;
    if(mask & 1<<i) return 0;
  }
  return 1;
}

int main(){
  int i, j, k;

  reader(&N,&K);
  while(K--){
    reader(&i);
    mask |= 1<<i;
  }
  while(!is_ok(N)) N++;
  writerLn(N);

  return 0;
}


Measured memory_bytes: 256
n = int(input())
sen = {}
maxsen = 0
for i in range(n):
    s = input()
    if s not in sen:
        sen[s] = 1
        maxsen = max(maxsen,sen[s])
    else:
        sen[s]+=1
        maxsen = max(maxsen,sen[s])
p = []
for key in sen:
    val = sen[key]
    if val ==  maxsen:
        p.append(key)
p = sorted(p)
for x in p:
    print(x)

Measured memory_bytes: 33112
#include <iostream>
using namespace std;
long long N, A, B;
int main() {
  cin >> N >> A >> B;
  cout << (A > B ?
           0 :
           N == 1 ?
           (A == B) : 
           (B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll ct=n/x;
    if(n%x!=0)
    {
        ct++;
    }
    cout<<ct*t<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 10;
string s;
int main()
{
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;cin >> N;
    string s; cin >> s;
    //1 : 羊 , -1 : 狼
    int shoki[4][2] ={{1,1},{1,-1},{-1,1},{-1,-1},};
    int flag = 0;
    for (int i=0;i<4;i++){
        int hype[N+2]; hype[0]= shoki[i][0]; hype[1]= shoki[i][1];
        for (int j=0;j<N;j++){
            if(s[j]=='o') hype[j+2]= hype[j+1]*hype[j];
            else hype[j+2]= -hype[j+1]*hype[j];
        }
        if ((hype[0]==hype[N])&&(hype[1]==hype[N+1])){
            for (int j=0;j<N;j++){
                if (hype[j+1]==1) cout << "S";
                else cout << "W";
                if (j==N-1) cout << "\n";
            }
            flag = 1;
        }
        if (flag) break;
    }
    if (!flag) cout << -1 << "\n";
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;

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

    int ans = 0;
    if (X == 1) {
        cout << 1 << endl;
    }
    else {
        for (int a = 2; a < 32; a++) {
            for (int b = 2; pow(a, b) <= X; b++) {
                int res = pow(a, b);
                ans = max(ans, res);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  ll ans=INF;
  ll m=n;
  while(m!=0){
    if(abs((m%1000)-753)<ans){
      ans=abs((m%1000)-753);
    }
    m /=10;
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
evidences = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x - 1, y))

ans=0
for i in range(2**N):
    flag=True
    for j in range(N):
        if (i>>j)&1==0:
            continue
        for x,y in evidences[j]:
            if (i>>x)&1!=y:
                flag=False
                break
        if not flag:
            break

    if flag:
        ans=max(ans,bin(i)[2:].count('1'))

print(ans)

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

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

using namespace std;

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

  ll suma=0, sumb=0, ap=0, bp=0;
  rep(i,n){
    suma+=a[i];
    sumb+=b[i];
    if(a[i]>b[i])ap+=(a[i]-b[i]);
    if(b[i]>a[i])bp+=(b[i]-a[i]+1)/2.0;
  }

  if(suma>sumb){
    cout<<"No"<<endl;return 0;
  }

  if(max(ap, bp)<=sumb-suma){
//cout<<ap<<' '<<bp<<'|'<<suma<<' '<<sumb<<'|'<<max(ap, bp)<<' '<<sumb-suma<<endl;
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

//cout<<suma<<' '<<sumb<<' '<<bp<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int A, B, C, D, E, F;
    double concentration, ans = 0.0;
    int ans_sugarWater = 0, ans_sugar = 0;
    vector<int> water, sugar;
    cin >> A >> B >> C >> D >> E >> F;

    for(int b = 0; b <= F / (100 * B); b++){
        for(int a = 0; a <= (F - (b * 100 * B)) / (100 * A); a++){
            water.push_back(a * 100 * A + b * 100 * B);
        }
    }

    for(int b = 0; b <= F / D; b++){
        for(int a = 0; a <= (F - b * D) / C; a++){
            sugar.push_back(a * C + b * D);
        }
    }

    for(int x : water){
        for(int y : sugar){
            if(x + y == 0) concentration = 0;
            else concentration = (double)y / (x + y);
            if(x + y <= F && (x / 100.0) * E >= y && concentration >= ans){
                ans = concentration;
                ans_sugarWater = x + y;
                ans_sugar = y;
            }

        }
    }
    cout << ans_sugarWater << " " << ans_sugar << endl;
}

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

map<pair<char, int>, int > var;
map<char, int> arrSize;

char array_name(string& line, int& idx){
	return line[idx++];
}

int number(string& line, int& idx){
	char c = line[idx];
	if(c == '0'){
		idx++;
		return 0;
	}else{
		int ans = 0;
		c = line[idx];
		while('0' <= c && c <= '9'){
			ans = ans * 10 + (c - '0');
			++idx;
			if(idx >= line.size()) break;
			c = line[idx];
		}
		return ans;
	}
}

int expression(string& line, int& idx, bool& correct){
	char c = line[idx];
	correct = true;
	if('0' <= c && c <= '9'){
		return number(line, idx);
	}
	char arr = array_name(line, idx);
	idx++;
	int id = expression(line, idx, correct);
	if(!correct){
		correct = false;
		return 0;
	}
	pair<char, int> key(arr, id);
	if(var.count(key)){
		int ret = var[key];
		idx++;
		return ret;
	}else{
		correct = false;
		return 0;
	}
}

int declaration(string& line, int& idx){
	char name = array_name(line, idx);
	char c;
	c = line[idx++];
	//cout << 1 << endl;
	if(c != '['){
		return false;
	}
	
	//cout << 2 << endl;
	int id = number(line, idx);
	c = line[idx++];
	if(c != ']'){
		return false;
	}
	//cout << 3 << endl;
	if(line.size() != idx) return false;

	//cout << 4 <<  arrSize.count(c) << " " << c << endl;
	if(!arrSize.count(name)){
		arrSize[name] = id;
		return true;
	}else{
		return false;
	}
}

bool assignment(string& line, int& idx){
	char name = array_name(line, idx);
	char c = line[idx++];
	if(c != '['){
		return false;
	}
	bool correct;
	int id = expression(line, idx, correct);
	if(!correct) return false;

	c = line[idx++];
	if(c != ']'){
		return false;
	}
	c = line[idx++];

	if(c != '='){
		return false;
	}
	int val = expression(line, idx, correct);
	if(!correct) return false;
	if(idx != line.size()) return false;
	
	if(arrSize.count(name) && id < arrSize[name]){
		var[pair<char, int>(name, id)] = val;
		return true;
	}else{
		return false;
	}
}

int main(){
	while(true){
		var.clear();
		arrSize.clear();
		string str;
		getline(cin, str);
		if(str == ".") break;
		int line = 1;
		int ans = 0;
		do{
			int idx1= 0;
			int idx2 = 0;
			if(ans == 0 && !declaration(str, idx1) && !assignment(str, idx2)){
				ans = line;
			}
			line++;
		}while(getline(cin, str), str != ".");
		cout << ans << endl;	
	}
}

Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	vector<ll>A(5);
	for (int i = 0; i < 5; ++i)cin >> A[i];
	sort(A.begin(), A.end());
	if (N%A[0] == 0) {
		cout << (N / A[0]) + 4 << endl;
	}
	else {
		cout << (N / A[0]) + 5 << endl;
	}
	return 0;
}



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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

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

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

int n, k, a[N];
ll p[N], s[N], sum[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    forn(i, 1, n)
        cin >> a[i];
    forn(i, 1, n) {
        p[i] = p[i - 1];
        if (a[i] > 0) p[i] += a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for1(i, n, 1) {
        s[i] = s[i + 1];
        if (a[i] > 0) s[i] += a[i];
        //cerr << i << ": " << s[i] << "\n";
    }
    ll ans = 0;
    forn(i, 0, n - k) {
        //cerr << i << ": " << p[i] + sum[i + k] - sum[i] +  s[i + k + 1] << "\n";
        ans = max(ans, p[i] + s[i + k + 1]);
        ans = max(ans, p[i] + sum[i + k] - sum[i] + s[i + k + 1]);
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 11264
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [a, b, c, d, e, f] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    putStrLn $ toStr $ maximumBy (\x y -> compare (dense x) (dense y)) $ solve (a * 100) (b * 100) c d e f
    where
        toStr s = show (fst s) ++ " " ++ show (snd s)
        dense (w, p) = fromIntegral p / fromIntegral w :: Double
        solve a b c d e f = do
            i <- [0..30]
            guard (i * a <= f)
            j <- [0..30]
            let g = i * a + j * b
            guard (g <= f && i + j > 0)
            let h = min ((g * e) `div` 100) (f - g)
            k <- [0..100]
            guard (c * k <= h)
            l <- [0..100]
            let t = c * k + d * l
            guard (t <= h)
            return (g + t, t)


Measured memory_bytes: 25340
#include<queue>
#include<vector>
#include<iostream>
using namespace std;

int main(){
  int k, n;
  while(cin >> n && cin >> k){
    priority_queue<int> q;
    int sum = 0;

    for(int i = 0; i < n; i++){
      int stick;
      cin >> stick;
      q.push(stick);
    }

    for(int i = 0; i < k; i++){
      sum += q.top();
      q.pop();
    }

    cout << sum << endl;
  }

  return 0;
}


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

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);
        int lastAbcIndex = (N - 1)/2;
        int firstArcIndex = (N + 1)/2;
        int lastAbc = d[lastAbcIndex];
        int firstArc = d[firstArcIndex];

        int ans;
        if (lastAbc == firstArc) {
            ans = 0;
        }
        else {
            ans = firstArc - lastAbc;
        }
        System.out.print(ans);
    }

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



Measured memory_bytes: 50572
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, T) = Read3Longs();
            return T / A * B;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    lint n, p;
    cin >> n >> p;
    map<lint, lint> mp;
    for(lint i = 2 ; i * i <= p ; ++i){
        while(p % i == 0){
            ++mp[i];
            p /= i;
        }
    }
    if(p > 1){
        ++mp[p];
    }
    lint ans = 1;
    for(auto x : mp){
        ans *= pow(x.first, x.second / n);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N = 0;
    int x;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        cin >> x;
        A.push_back(x);
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N-1; i++) {
        if (A[i] == A[i+1]){
            cout << "NO" << endl;
            exit(0);
        }
        
    }

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

Measured memory_bytes: 1400
fun main() {
    // 文字列
    var k = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
//    val (n,d) = readLine()!!.split(" ").map(String::toInt)
//    val xys = List(n) {
////        readLine()!!.split(" ").map(String::toLong)
//        readLine()!!.toDouble()
//    }

    var x=7%k
    var count=1

    for (i in 0 until k){
        if (x==0) {
            print(count)
            return
        }
        x=(x*10+7)%k
        count=count+1
    }
    print(-1)
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

LL f(LL x, LL y, LL z)
{
	return y / z - (x - 1) / z;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << b - a + 1 - f(a, b, c) - f(a, b, d) + f(a, b, c * (LL) d / __gcd(c, d));
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

using namespace std;

int n, dp[100001][3], a, b, c;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b >> c;

        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][1], dp[i - 1][0]);
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i * i <= N; i++) {
        ll a = N / i;
        ans += i * a * (a + 1) / 2;
    }
    for (ll i = 1; i < N / i; i++) {
        ll a = N / i;
        ll b = N / (i + 1);
        ans += i * (i + 1) / 2 * (a * (a + 1) / 2 - b * (b + 1) / 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604