akhauriyash/Code-Regression huggingface dataset:
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val as1 = readLine.split(" ").map(_.toInt)
  val as2 = readLine.split(" ").map(_.toInt)

  val counts = (1 to n).map(i => as1.take(i).sum + as2.drop(i-1).sum)
  val result = counts.max
  println(result)
}

Measured memory_bytes: 54984
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  ll ans = 0;
  int tmp = 0;
  rep(i,n){
    if(a[i] < 0)tmp++;
  }
  if(!(tmp%2)){
    rep(i,n)ans += abs(a[i]);
  }else{
    rep(i,n)a[i] = abs(a[i]);
    sort(all(a));
    ans = SUM(a);
    ans -= a[0]*2;
  }
  print(ans);
  return 0;
} 

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
using namespace std;

int A,B;
int main (){
    cin >> A >> B;
    for(int i=1; i<4; i++){
        if( A * B * i % 2 == 1 ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main()
{
long long n;
int ans=1000;
cin>>n;
for(long long a=1;a*a<=n;a++)
{
if(n%a!=0) continue;
long long b = n/a;
long long res = max(a,b);
int t = 0;
while(res!=0)
{
res/=10;
t++;
}
ans = min(ans,t);
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int K,X; cin >> K >> X;
    cout << ((K*500 >= X) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(char*)a - *(char*)b;
}
int main()
{
    int i, n, p[20],ans=0;
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",p+i);
    }
    for(i=1; i<n-1; i++) {
        if(p[i-1]<p[i] && p[i]<p[i+1]) {
            ans++;
        }
        if(p[i-1]>p[i] && p[i]>p[i+1]) {
            ans++;
        }

    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
// while (clock()<=69*CLOCKS_PER_SEC)
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int main()
{
	_upgrade
  int x;
  cin>>x;
  cout<< 360 / __gcd(x, 360);
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    int n;
    cin >> n;
    vector<int> h(n);
    repeat (i, n) cin >> h[i];
    
    auto allzero = [&](void) -> bool {
        for (int e: h) {
            if (e > 0) return false;
        }
        return true;
    };
    
    int ans = 0;
    bool start = false;
    while (true) {
        if (allzero()) break;
        repeat (i, n) {
            if (h[i] > 0) {
                start = true;
                --h[i];
            }
            else if (h[i] == 0 and start == true) {
                break;
            }
        }
        ++ans;
        //vdump(h);
        start = false;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct node {
    int aoki;
    vector<int> neighbor;

    bool isLeaf() const {
        return neighbor.size() == 1;
    }
};

using graph = vector<node>;

void aoki(int s, graph& g) {
    function<void(int, int)> rec = [&](int v, int bv) {
        for (int u : g[v].neighbor) {
            if (u != bv) {
                g[u].aoki = g[v].aoki + 1;
                rec(u, v);
            }
        }
    };

    g[s].aoki = 0; 
    rec(s, -1);
}

int f(int n) {
    return n - 1;
}

int takahashi(int s, graph& g) {
    function<int(int, int, int)> rec = [&](int v, int bv, int step) {
        int ret = 0;

        if (g[v].isLeaf()) {
            ret = step + f(g[v].aoki - step);
        }
        
        for (int u : g[v].neighbor) {
            if (u != bv && g[u].aoki - step > 0) {
                ret = max(ret, rec(u, v, step + 1));
            }
        }
    
        return ret;
    };

    return rec(s, -1, 0);
}

int main() {
    int n, u, v; cin >> n >> u >> v;
    --u; --v;
    
    graph g(n);

    REP(i, n-1) {
        int a, b; cin >> a >> b;
        --a; --b;
        g[a].neighbor.push_back(b);
        g[b].neighbor.push_back(a);
    }

    aoki(v, g);

    cout << takahashi(u, g) << endl;

    return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
double ret = 0;

void input() {
  IN(N);
  int tmp;
  REP(i, N) {
    IN(tmp);
    ret += 1.0/((double)tmp);
  }
}

void solve() {
  ret = 1.0/ret;
  cout << setprecision(10) << ret << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
    }
    else
    {
        cout<<((n/x)+1)*t;
    }
  	return 0;
}







Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int X=sc.nextInt();
        int Y=sc.nextInt();
        int[] arr_x=new int[N];
        int[] arr_y=new int[M];
        int max_x=X;
        int min_y=Y;
        for(int i=0;i<N;i++){
            arr_x[i]=sc.nextInt();
            if (arr_x[i]>max_x) max_x=arr_x[i];
        }
        for(int i=0;i<M;i++){
            arr_y[i]=sc.nextInt();
            if(arr_y[i]<min_y) min_y=arr_y[i];
        }
        if(max_x<min_y) System.out.println("No War");
        else System.out.println("War");
    }
}


Measured memory_bytes: 23508
///BISMILLAH'IR  RO'HMANIR  ROH'IM
///RIFAT SHARIAR SAKIL
///SOFTWARE ENGINEERING(SUST)

#include<stdio.h>
int main()
{
    int r,i;
    scanf("%d",&r);
    i= r*r;
    printf("%d",i);
    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

int linearsearch(int S[], int n, int key){
  int i = 0;
  int count = 0;
  while( S[i] != key ){
    i++;
    if( i >= n  ){
      count = 1;
      return count;
    }
  }
  return count;
  }

int main(){
  int i, j, n, q, S[10000], T[10000];
  int count = 0, key;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(j = 0; j < q; j++){
    scanf("%d", &T[j]);
  }
 
  for( j = 0; j < q; j++){
    key = T[j];
    if(linearsearch(S, n, key) == 0){
      count++;
    }
  }
    
    printf("%d\n", count);
  
    return 0;
  }

Measured memory_bytes: 644
function Main(input){
  var N = Number(input);
  var check=0;
  a: for(var i=0;i<=N;i++){
    for(var j=0;j<=N;j++){
      if((i*4+j*7)==N){
        console.log('Yes');
        check++;
        break a;
      }
    }
  }
  if(check==0){
    console.log('No');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11340
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include <utility>
#include <algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int n,a[101];
int main(){
    cin>>n;
    double sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    double m=sum/(double)n;
    double b[n];
    rep(i,n){
        b[i]=abs(a[i]-m);
    }
    double min=1<<29;
    rep(i,n){
        if(min>b[i])min=b[i];
    }
    int ans;
    rep(i,n){
        if(min==b[i]){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;scanf("%d",&N);
  int a[N];
  int max=0,min=1e10;
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    if(max<a[i]) max=a[i];
    if(min>a[i]) min=a[i];
  }
  printf("%d",max-min);
  return 0;
}

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

char s[100055];

int main() {
	scanf("%s", s);
	
	int n = strlen(s);
	
	int res = 1;
	
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i - 1]) {
			res++;
		}
	}
	
	printf("%d\n", res - 1);
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int i,j=0;
    char s1[10],s2[10];
    scanf("%s%s",s1,s2);
    for(i=0;i<3;i++)
    {
        if(s1[i]==s2[i])
        {
            j++;
        }
    }
    printf("%d\n",j);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>

using namespace std;
		
int main(void){
	string left,right,str;
	int num,h;
	while(1){
		cin>>str;
		if(str=="-")
			break;
		cin>>num;
		for(int i=0;i<num;i++){
			cin>>h;
			left = str.substr(0,h);
			right = str.substr(h,str.size());
			str = right + left;
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
let () =
  Scanf.scanf "%d %d\n" @@ fun n k ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  for i = k + 1 to n do
    if arr.(i-1) > arr.(i-k-1) then print_endline "Yes"
    else print_endline "No"
  done;

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

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<pair<int, int>> p(M);
    for(int i = 0; i < M; ++i)
        cin >> p[i].second >> p[i].first;
    sort(p.begin(), p.end());
    int tmp = 0;
    for(int i = 0; i < M; ++i) {
        if(tmp < p[i].second) {
            tmp = p[i].first - 1;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	FULL_MATCH,
	ELSE,
};

ll length;
ll num_array[20];
ll dp[20][10000][2][2];

ll getNUM(ll pre_num,ll next){
	return (10*pre_num+next)%10000;
}

bool is_OK(ll number){
	stack<ll> S;
	while(number > 0){
		S.push(number%10);
		number /= 10;
	}
	int index = 0;
	ll work[4];

	while(!S.empty()){
		work[index++] = S.top();
		S.pop();
	}

	return (work[0] == 5 && work[1] == 1 && work[3] == 3);
}

ll recursive(ll pre_num,ll digit,Type type,bool is_completed){

	if(digit == length){
		if(is_completed)return 1;
		else{
			return 0; //G数が成立しないならreturn 0;
		}
	}

	if(dp[digit][pre_num][type][is_completed] != -1){
		return dp[digit][pre_num][type][is_completed]; //計算済ならreturn
	}

	ll ret = 0;
	ll limit;
	if(type == FULL_MATCH){
		limit = num_array[digit]-1;
	}else{
		limit = 9;
	}

	ll tmp;

	for(int next = 0; next <= limit; next++){
		tmp =  getNUM(pre_num,next);
		ret += recursive(tmp,digit+1,ELSE,is_completed||is_OK(tmp));
	}

	if(type == FULL_MATCH){
		tmp = getNUM(pre_num,num_array[digit]);
		ret += recursive(tmp,digit+1,FULL_MATCH,is_completed||is_OK(tmp));
	}

	return dp[digit][pre_num][type][is_completed] = ret;
}


int main(){

	ll N;
	scanf("%lld",&N);

	if(N <= 5102){
		printf("0\n");
		return 0;
	}

	stack<ll> S;

	//Nを桁別に分解する
	while(N > 0){
		S.push(N%10);
		N /= 10;
	}

	ll index = 0;

	while(!S.empty()){
		num_array[index++] = S.top();
		S.pop();
	}

	length = index;

	for(int digit = 0; digit <= length-1; digit++){
		for(int pre_num = 0; pre_num <= 9999; pre_num++){
			for(int p = 0; p <= 1; p++){
				for(int k = 0; k <= 1; k++){
					dp[digit][pre_num][p][k] = -1;
				}
			}
		}
	}

	printf("%lld\n",recursive(0,0,FULL_MATCH,false));

	return 0;
}



Measured memory_bytes: 8840
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define int ll
vector<int> v;
void dfs(int n, int m, int stepNum) 
{ 
    if (stepNum <= m && stepNum >= n) 
        v.push_back(stepNum);

    if (stepNum == 0 || stepNum > m) 
        return ; 

     int lastDigit = stepNum % 10; 


    int stepNumA = stepNum*10 + (lastDigit-1); 
    int stepNumB = stepNum*10 + (lastDigit+1); 
    int stepNumC = stepNum*10 + (lastDigit);


    if (lastDigit == 0) 
        {
            dfs(n, m, stepNumB);
            dfs(n, m, stepNumC);
        } 
    else if(lastDigit == 9) 
        {
            dfs(n, m, stepNumA);
            dfs(n, m, stepNumC);
        } 
    else
    { 
        dfs(n, m, stepNumA); 
        dfs(n, m, stepNumB); 
        dfs(n, m, stepNumC);
    } 
} 


void displaySteppingNumbers(int n, int m) 
{ 

    for (int i = 1 ; i <= 9 ; i++) 
        dfs(n, m, i); 
} 


int32_t main() 
{ 

    int n = 0, m = 3234566667; 

    // Display Stepping Numbers in 
    // the range [n,m] 
    displaySteppingNumbers(n,m);
    int k;
    cin>>k; 
    sort(v.begin(),v.end());

    cout<<v[k-1]<<endl;
    return 0; 
} 


Measured memory_bytes: 1400
#include <iostream>
#include <limits>
using namespace std;
int main()
{
    int n,x;
    cin >> n >> x;
    int min = numeric_limits<int>::max();
    int alltype = 0;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin >> tmp;
        alltype += tmp;
        if(tmp < min)
        {
            min = tmp;
        }
    }
    int sum = n;
    x -= alltype;
    while(x >= min)
    {
        x -= min;
        sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long sum[222222],sum2[222222],f[222222],g[222222];
int a[222222];
int main()
{
	int n,i,tmp;
	long long ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for(i=n;i>=1;i--)
		sum2[i]=sum2[i+1]+a[i];
	tmp=0;
	for(i=1;i<=n;i++)
	{
		while(sum[tmp]*2<sum[i])
			tmp++;
		f[i]=max(sum[tmp-1],sum[i]-sum[tmp]);
//		printf("%d %d\n",i,f[i]);
	}
	tmp=n+1;
	for(i=n;i>=1;i--)
	{
		while(sum2[tmp]*2<sum2[i])
			tmp--;
		g[i]=max(sum2[tmp+1],sum2[i]-sum2[tmp]);
//		printf("%d %d\n",i,g[i]);
	}
	ans=100000000000000007;
	for(i=1;i<n;i++)
	{
//		printf("%d %lld\n",i,ans);
		ans=min(ans,max(max(sum[i]-f[i]-f[i],sum2[i+1]-g[i+1]-g[i+1]),max(-f[i]+(sum2[i+1]-g[i+1]),-g[i+1]+(sum[i]-f[i]))));
	}
	printf("%lld\n",ans); 
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(b%a==0) System.out.println(a+b);
		else System.out.println(Math.abs(b-a));

	}

}


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

using namespace std;

int main()
{
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int k = 0;
	while (true)
	{
		int min_val = min(x - k, x + k);
		int max_val = max(x - k, x + k);
		if (find(p.begin(), p.end(), min_val) == p.end())
		{
			cout << min_val << endl;
			break;
		}
		if (find(p.begin(), p.end(), max_val) == p.end())
		{
			cout << max_val << endl;
			break;
		}
		k++;
	}
	return 0;
}

Measured memory_bytes: 3604
#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(){
  int h,a;
  cin >> h >> a;
  int ans = (h%a)?(h/a+1):h/a;
  cout << ans << endl;
}

Measured memory_bytes: 256
def connected(a, b, last):
    if a <= last:
        return False
    return True
def solve():
    N, M = [int(x) for x in input().split()]
    lst = [[int(x) for x in reversed(input().split())] for i in range(M)]
    lst.sort()
    last = 0
    cnt = 0
    for l in lst:
        b, a = l
        if connected(a, b, last):
            last = b - 1
            cnt += 1
    return cnt

if __name__ == '__main__':
    print(solve())


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

int main() {
    
    int N;
    cin >> N;
    
    int A, B, C;
    
    A = N / 100;
    //cout << A << endl;
    B = (N - (A * 100))/10;
    //cout << B << endl;
    C = N - (A*100) - (B*10);
    //cout << C << endl;
    
    
    if (A == 7 || B == 7 || C == 7){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    //cin >> N;
    
    //cout << N * 3 << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int k=N;
  int sum=0;
  while(k){
    sum+=k%10;
    k/=10;
  }
  if(N%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long

struct datum{
    int x, y, height;
};
bool cmp(datum& x, datum& y){
    return x.height > y.height;
}
int main(){
    int n; cin>>n;
    vector<datum> data;
    rep(i, n){
        int x, y, h; cin>>x>>y>>h;
        data.push_back(datum{x, y, h});
    }
    sort(all(data), cmp);
    rep(i, 101) rep(j, 101){
        int h = data[0].height + abs(data[0].x-i) + abs(data[0].y-j);
        bool ok = true;
        repn(k, n-1){
            int hij = h - abs(data[k].x-i) - abs(data[k].y-j);
            if (hij != data[k].height && (hij > 0 || data[k].height != 0)){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << i << " " << j << " " << h << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 888
X, N = map(int, input().split())
P = list(map(int, input().split()))

if X not in P:
    print(X)
    exit()

count = 1
while True:
    minus = X - count
    if minus not in P:
        print(minus)
        exit()

    plus = X + count
    if plus not in P:
        print(plus)
        exit()

    count += 1


Measured memory_bytes: 9188
#include<iostream>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;

#define MAX 30
#define INF 1000
int wn,hn;
int d[MAX][MAX];
bool w[MAX][MAX]; //w,h ?¨??£?
bool h[MAX][MAX]; //????£?
vector< pair<int, int> > nextlist; //x,y
typedef std::pair<int, int> Pos;

void reset() {
	for (int i = 0; i < wn; i++) {
		for (int j = 0; j < hn; j++) {
			d[i][j] = INF;
		}
	}
}

bool sortRule(Pos left, Pos right) {
	return d[left.first][left.second] < d[right.first][right.second];
}


void maze(Pos pos) {
	nextlist.erase(nextlist.begin());
	//???
	if (pos.second > 0) {
		if (!w[pos.first][pos.second - 1] && d[pos.first][pos.second - 1] > d[pos.first][pos.second] + 1) {
			d[pos.first][pos.second - 1] = d[pos.first][pos.second] + 1;
			Pos tmp(pos.first, pos.second - 1);
			nextlist.push_back(tmp);
		}
	}

	//???
	if (pos.first > 0) {
		if (!h[pos.first - 1][pos.second] && d[pos.first - 1][pos.second] > d[pos.first][pos.second] + 1) {
			d[pos.first - 1][pos.second] = d[pos.first][pos.second] + 1;
			Pos tmp(pos.first - 1, pos.second);
			nextlist.push_back(tmp);
		}
	}

	//???
	if (pos.second < hn-1) {
		if (!w[pos.first][pos.second] && d[pos.first][pos.second + 1] > d[pos.first][pos.second] + 1) {
			d[pos.first][pos.second + 1] = d[pos.first][pos.second] + 1;
			Pos tmp(pos.first, pos.second + 1);
			nextlist.push_back(tmp);
		}
	}

	//???
	if (pos.first < wn -1) {
		if (!h[pos.first][pos.second] && d[pos.first + 1][pos.second] > d[pos.first][pos.second] + 1) {
			d[pos.first + 1][pos.second] = d[pos.first][pos.second] + 1;
			Pos tmp(pos.first + 1, pos.second);
			nextlist.push_back(tmp);
		}
	}

	if (nextlist.size() > 0) {
		sort(nextlist.begin(), nextlist.end(), sortRule);
		maze(nextlist[0]);

	}
}



int main() {
	cin >> wn >> hn;
	while (wn + hn) {
		reset();
		for (int i = 0; i < hn-1; i++) {
			for (int j = 0; j < wn-1; j++) {
				cin >> h[j][i];
			}
			for (int j = 0; j < wn; j++) {
				cin >> w[j][i];
			}
		}
		for (int j = 0; j < wn - 1; j++) {
			cin >> h[j][hn - 1];
		}

		d[0][0] = 1;
		Pos tmp(0, 0);
		nextlist.push_back(tmp);
		maze(nextlist[0]);

		if (d[wn - 1][hn - 1] == INF) {
			cout << 0 << endl;
		}
		else {
			cout << d[wn - 1][hn - 1] << endl;
		}

		cin >> wn >> hn;
	}
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
    return x * x;
}

signed main () {
    int N;
    cin >> N;
    int a;
    multiset<int> A;
    rep(i,N-1) {
     
        cin >> a;
        A.insert(a);
    }
    int ans[N];
    rep(i,N){
        cout << A.count(i+1) << endl;
    }
    return 0;
}



Measured memory_bytes: 12968
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k;
  cin>>n;
  double a[n],ans=0,x,y;
  for(i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      k=n-1;
      while(k==i||k==j) k--;
      x=a[k];k--;
      while(k==i||k==j) k--;
      y=a[k];
      ans=max(ans,(x+y)/(a[j]-a[i]));
    }
  }
  printf("%6lf\n",ans);
  return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#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,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int a,b;
    cin >> a >> b;
    if((a+b)%2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> net(n);
    vector<pair<int, int>> edges;
    REP(i, m){
        int si, ti;
        cin >> si >> ti;
        si--; ti--;
        net.at(si).push_back(ti);
        edges.emplace_back(si, ti);
    }

    double ans = n + 1;
    vector<double> exp(n, 0);
    for(int ng = -1; ng < n - 1; ++ng){
        if(ng != -1 && net.at(ng).size() == 1){
            continue;
        }
        vector<double> exp2(n, 0);
        for(int x = n - 2; x >= 0; x--){
            if(ng != -1 && ng < x){
                exp2.at(x) = exp.at(x);
            }

            double tmp = 0;
            double count = 0;
            double maxval = 0;
            for(int nxt : net.at(x)){
                tmp += exp2.at(nxt) + 1.0;
                maxval = max(maxval, exp2.at(nxt) + 1.0);
                count++;
            }
            if(ng != x){
                exp2.at(x) = tmp / count;
                exp.at(x) = exp2.at(x);
            }else{
                exp2.at(x) = (tmp - maxval) / (count - 1);
            }
        }
        ans = min(ans, exp2.at(0));
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <string>

using namespace std;


int main()
{
	string S;

	cin >> S;

	string judge = "Yes";

	for (int i = 0; i < S.length(); i++) {
		if (((i % 2)+1) == 1) {
			if (S[i] == 'L') judge = "No";
		}
		else {
			if (S[i] == 'R') judge = "No";
		}
	}

	cout << judge << endl;

	return 0;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s1[i]==s2[i])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

N, X = nm()
s = [1]
p = [1]
for i in range(N):
    s.append(s[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    if x <= s[n - 1] + 1:
        return f(n - 1, x - 1)
    else:
        return p[n - 1] + f(n - 1, x - s[n - 1] - 2) + 1

print(f(N, X))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
    
using namespace std;
ll bin(ll a[],ll s,ll e,ll x){
    ll m=(s+e)/2;
if(s==e){if(a[s]<=x) return s;else return s-1;}
else if(m==s){
    if(a[s]<=x&&a[e]<=x) return s+1;
    else if(a[s]<=x&&a[e]>x) return s;
    else return s-1;
}
else if(a[m]<=x) return bin(a,m+1,e,x);
else return bin(a,s,m-1,x);
}  

int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   string s;cin>>s;
   
   for(ll i=0;i<s.size();i++){
       if(s[i]=='?') cout<<"D";
       else cout<<s[i];
       
   }
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
 
    return 0;
}   

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> B(N-1);
    for (int i = 0; i < N-1; i++) {
        cin >> B[i];
    }
    vector<int> A(N, 0);
    A[0] = B[0];
    REP(i, N-1){
       if(B[i] <= A[i]){
           A[i+1] = A[i] = B[i];
       } else if (B[i] > A[i]){
           A[i+1] = B[i];
       }
    }
    int ans = 0;
    REP(i, N){
        ans += A[i];
    }
    pr(ans);
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int n;cin>>n;
  string ans;
  if(n<1200){
    ans="ABC";
  }else if(n<2800){
    ans="ARC";
  }else{
    ans="AGC";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <iomanip>
using namespace std;

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

    double dp[N+1][N+1]={};
    double p[N];

    for (int i = 0; i < N; ++i) { 
        cin >> p[i];
    }
    
    dp[1][0]=1-p[0];
    dp[1][1]=p[0];
    
    for (int i = 2; i < N+1; ++i) { 
        dp[i][0]=dp[i-1][0]*(1-p[i-1]);
        for (int j = 1; j < N+1; ++j) {
             dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
        }
    }

    double ans=0;
    for (int i = (N+1)/2; i < N+1; ++i) { 
        ans+=dp[N][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;

}

Measured memory_bytes: 70528
import java.io.*;
class Main{
	 public static void main(String args[])throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String buf = br.readLine();
	int x = Integer.parseInt(buf);
	
    int y = x/3600;
    int z = (x % 3600) / 60;
    int w = (x % 3600) % 60;
	System.out.println(y + ":" + z + ":" + w);
	}
	}

Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int binomialCoeff(int n, int k) 
{ 
	if (k == 0 || k == n) 
		return 1; 
	return binomialCoeff(n - 1, k - 1) + 
				binomialCoeff(n - 1, k); 
} 
signed main()
{
    SPEED;
    int n,m,sum=0;
    cin>>n>>m;
    if(n>=2)
        sum+=binomialCoeff(n,2);
    if(m>=2)
        sum+=binomialCoeff(m,2);
    cout<<sum;
}

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

int main(){
    char a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    if(a[0]!=a[1] && a[1]!=a[2] && a[2]!=a[0]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
I=lambda:map(int,input().split());n,q=I();s=[0];d=s*n;f=s+[1]*n;e=[[]for _ in d]
while~-n:n-=1;a,b=I();e[a-1]+=b-1,;e[b-1]+=a-1,
while q:q-=1;p,x=I();d[p-1]+=x
while s:
 v=s.pop()
 for w in e[v]:d[w]+=d[v]*f[w];s+=[w]*f[w];f[w]=0
print(*d)

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

using namespace std;

typedef pair<int,int> ii;

const int mod = 1e9 + 7;

int n,m;
vector<ii> upd[311];
bool ok[311][311][311];
int f[311][311][311];

void init()
{
	memset(ok,true,sizeof true);
	for (int i=0;i<=n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=j;k++)
			{
				if (i == j && i) continue;
				if (i == k && i) continue;
				if (j == k && j) continue;
				ok[i][j][k] = true;
				for (int h=0;h<upd[i].size();h++)
				{
					int l = upd[i][h].first;
					int cnt = 1;
					if (j >= l) cnt++;
					if (k >= l) cnt++;
					if (cnt != upd[i][h].second)
					{
						ok[i][j][k] = false;
						break;
					}
				} 
			}
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> m;
	for (int i=1;i<=m;i++)
	{
		int l,r,x;
		cin >> l >> r >> x;
		upd[r].push_back(ii(l,x));	
	}
	init();
	int res = 0;
	f[0][0][0] = 1;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=n;k++)
			{
				int x = i, y = j, z = k;
				if (x < y) swap(x,y); if (x < z) swap(x,z); if (y < z) swap(y,z);
				if (!ok[x][y][z]) continue;
				if (x == n) res = (res + f[i][j][k])%mod;
				f[x+1][j][k] = (f[x+1][j][k] + f[i][j][k])%mod;
				f[i][x+1][k] = (f[i][x+1][k] + f[i][j][k])%mod;
				f[i][j][x+1] = (f[i][j][x+1] + f[i][j][k])%mod;
			}
	cout << res;
}

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

int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    int p[A + 1], q[B + 1], r[C + 1];
    for (int i = 0; i < A; i++) cin >> p[i];
    for (int i = 0; i < B; i++) cin >> q[i];
    for (int i = 0; i < C; i++) cin >> r[i];
    sort(p, p + A), sort(q, q + B);

    vector<int> v;
    for (int i = 0; i < X; i++) v.push_back(p[A - i - 1]);
    for (int i = 0; i < Y; i++) v.push_back(q[B - i - 1]);
    for (int i = 0; i < C; i++) v.push_back(r[i]);
    sort(v.begin(), v.end());

    long long ans = 0;
    for (int i = 0; i < X + Y; i++) ans += v[v.size() - i - 1];
    cout << ans << endl;
}


Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int n;
    int sum = 0;
    int max_num = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x > max_num)
        {
            max_num = x;
        }
        sum += x;
    }

    sum -= max_num;
    sum += max_num / 2;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

A,B,Q=map(int,input().split())

TERA=[]
JINJA=[]
for _ in range(A):
  TERA.append(int(input()))
for _ in range(B):
  JINJA.append(int(input()))
  
TERAJINJAlist=[]
TJlist=[]

JINJAcount=0
for i in range(A):
  while(True):
    if JINJAcount==B-1 or abs(TERA[i]-JINJA[JINJAcount])<abs(TERA[i]-JINJA[JINJAcount+1]):
      break
    JINJAcount+=1
  TERAJINJAlist.append([TERA[i],JINJA[JINJAcount]])
  TJlist.append(TERA[i])
TERAcount=0
for i in range(B):
  while(True):
    if TERAcount==A-1 or abs(JINJA[i]-TERA[TERAcount])<abs(JINJA[i]-TERA[TERAcount+1]):
      break
    TERAcount+=1
  TERAJINJAlist.append([JINJA[i],TERA[TERAcount]])
  TJlist.append(JINJA[i])
TERAJINJAlist.sort()
TJlist.sort()

#print(TERAJINJAlist)
length=len(TJlist)
for i in range(Q):
  x=int(input())
  ind=bisect.bisect_left(TJlist,x)
  #print(ind)
  if ind==0:
    print(TERAJINJAlist[ind][0]-x+abs(TERAJINJAlist[ind][1]-TERAJINJAlist[ind][0]))
  elif ind==length:
    print(x-TERAJINJAlist[ind-1][0]+abs(TERAJINJAlist[ind-1][1]-TERAJINJAlist[ind-1][0]))
  else:
    left=abs(x-TERAJINJAlist[ind-1][0])+abs(TERAJINJAlist[ind-1][1]-TERAJINJAlist[ind-1][0])
    right=abs(x-TERAJINJAlist[ind][0])+abs(TERAJINJAlist[ind][1]-TERAJINJAlist[ind][0])
    print(min(left,right))

Measured memory_bytes: 35940
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cout << fixed << setprecision(6);
    int a, b; cin >> a >>b;
    cout << (double)a / b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll a,b,k;
    cin >> a >> b >> k;
    if(k <= a)cout << a - k << " " << b;
    else if(k <= b + a)cout << 0 << " " << b - k + a;
    else cout << 0 << " " << 0;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100]={0};
bool b[100001]={0};
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<=k;i++){
        bool ans=true;
        for(int j=0;j<n;j++){
            if(a[j]>i){break;}
            ans=ans&&b[i-a[j]];
        }
        ans=!ans;
        b[i]=ans;
    }
    if(b[k]){
        cout<<"First";
    } else{
        cout<<"Second";
    }
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e5 + 5;
const int MOD = 998244353;

int n, a, b, k;
int fac[N], ifac[N];

int fpow(int x,int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = res * x % MOD;
		x = x * x % MOD;
		y >>= 1;
	}
	return res;
}

void prec() {
	fac[0] = 1;
	for (int i = 1;i < N;++i) fac[i] = fac[i - 1] * i % MOD;
	ifac[N - 1] = fpow(fac[N - 1], MOD - 2);
	for (int i = N - 2;i >= 0;--i) ifac[i] = ifac[i + 1] * (i + 1) % MOD;
}

int C(int k,int n) {
	if (n < k || k < 0) return 0;
	return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;
}

signed main() {
	ios_base::sync_with_stdio(false);
	prec();
	cin >> n >> a >> b >> k;
	int res = 0;
	for (int x = 0;x <= n;++x) {
		if ((k - x * a) % b) continue;
		int y = (k - x * a) / b;
		res = (res + C(x, n) * C(y, n)) % MOD;
	}
	cout << res << '\n'
;}

Measured memory_bytes: 4992
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]

input = list(map(int, input().split()))
input_x = int(input[0])
input_y = int(input[1])

exist_group1 = group1.count(input_x) + group1.count(input_y)
exist_group2 = group2.count(input_x) + group2.count(input_y)
exist_group3 = group3.count(input_x) + group3.count(input_y)

if exist_group1 == 2 or exist_group2 == 2 or exist_group3 == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int i;
    int tmp;
    int max = -1000000;
    int min = 1000000;
    long total = 0;
    cin>>i;
    for(int n; n<i; n++){
        cin>>tmp;
        if(max<tmp) max = tmp;
        if(min>tmp) min = tmp;
        total+=tmp;
    }
    cout<<min<<" "<<max<<" "<<total<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    int k;
    int q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for(int i = 0; i < q; i++){
        cin >> a[i];
    }
    vector<int> point(n);
    for(int i = 0; i < n; i++){
        point[i] = k - q;
    }
    for(int i = 0; i < q; i++){
        point[a[i] - 1]++;
    }
    for(int i = 0; i < n; i++){
        if(point[i] > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()
pre1 = a[0]
pre2 = a[k]
for i in range(n-k):
    if pre2 > pre1:
        print('Yes')
    else:
        print('No')
    if i < n-k-1:
        pre1 = a[i+1]
        pre2 = a[i+1+k]


Measured memory_bytes: 98272