akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(123456789)
#define LINF (long long int)(123456789012345678)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}

class info{
public:
	ll x;
	ll y;
	ll h;

};

bool cmp(info a, info b){
	if(a.h == 0){
		return false;
	}
	if(b.h == 0){
		return true;
	}
	if(a.x == b.x){
		return a.y < b.y;
	}
	return a.x < b.x;
	
}

//first:base
pair<ll,ll> nibun(ll sum[], int first, int last){
	ll kijun = (sum[last] - sum[first])/2;
	ll base = sum[first];
	ll base2 = sum[last];
	first++;
	int now = (first + last)/2;
	while(last - first > 1){
		if(sum[now] - base > kijun){
			last = now;

		}else{
			first = now;
		}
		now = (first + last)/2;
	}
	pair<ll,ll> retval;
	ll down1 = sum[now] - base;
	ll up1 = base2 - sum[now];
	ll down2 = sum[now+1] - base;
	ll up2 = base2 - sum[now+1];
	if(abs(down1-up1) <= abs(up2-down2)){
		retval.first = down1;
		retval.second = up1;
	}else{
		retval.first = down2;
		retval.second = up2;
	}
	return retval;
}

int main(void){
	int n;
	cin>>n;
	ll a[200003];
	ll sum[200003];
	sum[0] = 0;
	rep(i,n){
		cin>>a[i];
		sum[i+1] = sum[i] + a[i];
	}

	ll ans = LINF;
	for(int i=2; i<=n-2; i++){
		ll b = nibun(sum, 0, i).first;
		ll c = nibun(sum, 0, i).second;
		ll d = nibun(sum, i, n).first;
		ll e = nibun(sum, i, n).second;
		ll minimum = min(b,min(c,min(d,e)));
		ll maximum = max(b,max(c,max(d,e)));
		//cout<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<minimum<<" "<<maximum<<endl;
		ans = min(ans,maximum - minimum);
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	long long N, M, ans;
	cin>>N>>M;
	long long y = (2LL * N + M) / 4LL;
	//cout << y << endl;
	if(2LL * y <= M) {
		ans = y;
	} else {
		ans = M / 2LL;
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;
    rep(i, 19)
    {
        if (s[i] == ',')
            s[i] = ' ';
    }
    OP(s);
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  ss <- replicateM 5 $ readLn :: IO [Int]
  print $ solve ss

solve ss = (sum ups) - maximum diffs
  where
    ups = map roundup ss
    diffs = zipWith (-) ups ss

roundup s = go 0 s
  where
    go t s | t >= s = t
           | otherwise = go (t+10) s

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

int main()
{
  string card[5];
  queue<char> q[5];
  int turn = 0;

  for (int i = 0; i < 3; i++) cin >> card[i];
  for (int i = 0; i < 3; i++){
    int m = card[i].size();
    for (int j = 0; j < m; j++){
      q[i].push(card[i][j]);
    }
  }

  while (1){
    char c = q[turn].front();
    q[turn].pop();
    
    if (c == 'a') turn = 0;
    if (c == 'b')  turn = 1;
    if (c == 'c') turn = 2;

    if (q[turn].empty()){
      if (turn == 0)  cout << "A\n";
      if (turn == 1)  cout << "B\n";
      if (turn == 2)  cout << "C\n";
      break;
    }
  }
}


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

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int x, y, z, k;
ll a[1010];
ll b[1010];
ll c[1010];
vector<ll> v;
vector<ll> v2;

int main () {

	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i ++) cin >> a[i];
	for (int i = 0; i < y; i ++) cin >> b[i];
	for (int i = 0; i < z; i ++) cin >> c[i];
	for (int i = 0; i < x; i ++) {
		for (int j = 0; j < y; j ++) {
			v.push_back(a[i]+b[j]);
		}
	}
	
	sort(v.begin(), v.end(), greater<ll>());
	for (int i = 0; i < min((int)v.size(), k); i ++) {
		for (int j = 0; j < z; j ++) {
			v2.push_back(v[i]+c[j]);
		}
	}
	
	sort(v2.begin(), v2.end(), greater<ll>());
	for (int i = 0; i < k; i ++) cout << v2[i] << endl;

	return 0;
}

Measured memory_bytes: 43364
#!/usr/bin/env python3

import sys
import math

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

lastday = [0] * 26
sat = 0
ans = [0] * D

for i in range(D):
  maxtmpsat = -1000000
  for j in range(26):
    tmpsat = s[i][j] + c[j] * (i+1 - lastday[j]) # その日に何も開催しなかった場合との満足度の差
    if tmpsat > maxtmpsat:
      maxtmpsat = tmpsat
      ans[i] = j+1
  lastday[ans[i]-1] = i+1
  print(ans[i])

Measured memory_bytes: 9516
N, K = list(map(int, input().split()))
Vs = list(map(int, input().split()))
Length = len(Vs)
maxv = 0
for i in range(K + 1):
    count = K - i
    left = count
    right = 0
    for m in range(count + 1):
        if 0 <= left <= Length and 0 <= right <= Length:
            for p in range(i + 1):
                temp = sorted(Vs[:left] + Vs[Length - right:])
                for o in range(p):
                    if temp:
                        temp.pop(0)
                    else:
                        break
                sumv = sum(temp)
                if sumv > maxv:
                    maxv = sumv
            left -= 1
            right += 1

print(maxv)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    bool a=false;
    int cou1=0,cou2=0;
    cin >> s;
    int n=s.size();
    vector <bool> ss(n);
    for(int i=0;i<n;i++)
    {
        ss[i]=s[i]-'0';
        if(ss[i]!=a)cou1++;
        a=!a;
    }
    a=true;
    for(int i=0;i<n;i++)
    {
        if(ss[i]!=a)cou2++;
        a=!a;
    }
    int ans=min(cou1,cou2);
    cout << ans << '\n';
}

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

public class Main {

	public static void main(String[] args) {

		int a;
		int b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		int wa = a + b;
		int sa = a - b;
		int seki = a * b;
		int[] ar = new int[3];
		ar[0] = wa;
		ar[1] = sa;
		ar[2] = seki;

		System.out.println(Arrays.stream(ar).max().getAsInt());

		sc.close();

	}

}


Measured memory_bytes: 27860
#include<iostream>

using namespace std;

int main(){
  int n,t,j,max;
  
  //N列（１以上１００以下の整数）
  cin>> n;
  //a[i][j](1以上１００以下の整数)
  int a[2][n];
  for(j=0;j<n;j++){
    cin>> a[0][j];
  }
  for(j=0;j<n;j++){
    cin>> a[1][j];
  }
    
  int x;
  max=1;
    
 for(t=0;t<n;t++){
    x=0;
  	for(j=0;j<=t;j++){
      x+=a[0][j];
    }
    for(j=t;j<n;j++){
      x+=a[1][j];
    }
    if(max<=x)
      max=x;
  }

  cout<< max <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
  string s,t;
  cin >> s >> t;
  reverse(t.begin(), t.end());
  if(s==t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;    
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

bool getBit(int num, int i){
	return ((num & (1 << i)) != 0);
}

int setBit(int num, int i){
	if(i < 0) return num;
	return num | (1 << i);
}

int toInteger(int r[4][4]){
	int k = 1;
	int res = 0;
	rep(i,4){
		rep(j,4){
			res += r[i][j] * k;
			k *= 10;
		}
	}
	return res;
}

void toRow(int num, int r[4][4]){
	rep(i,4){
		rep(j,4){
			r[i][j] = num % 10;
			num /= 10;
		}
	}
}

const int dy[16] = { 0,-1, 0, 1, 0,-2, 0, 2, 0 };
const int dx[16] = { 1, 0,-1, 0, 2, 0,-2, 0, 0 };

int n;
bool fes[366][4][4];
set<pair<int,pair<int,int>>> m;

bool check(long long& rain, int ty, int tx ,int day){
	int r[4][4] = {{0}};

	toRow(rain, r);
	assert(rain == toInteger(r));

	rep(i,4){//??¨????????´??????+1??????
		rep(j,4){
			r[i][j]++;
		}
	}

	range(i,ty, ty + 2){ //??¨??????????????¨?????????0?????????
		range(j,tx, tx + 2){
			r[i][j] = 0;
			if(fes[day][i][j]) return false; //??¨?????????????????¨?????§??????????????????????????????
		}
	}

	rep(i,4){//???????????§???7??????????????\?????????false
		rep(j,4){
			if(r[i][j] >= 7) return false;
		}
	}

	rain = toInteger(r);
	return true;
}

bool dfs(long long rain, int y, int x, int day){
	if(m.count(make_pair(rain,make_pair(y * 4 + x,day)))) return false;
	m.emplace(make_pair(rain,make_pair(y * 4 + x,day)));

	if(not check(rain, y, x, day)) return false;
	if(day == n){ return true; }

	bool res = false;
	rep(i,9){
		int ny = y + dy[i];
		int nx = x + dx[i];
		if(ny < 0 || ny >= 3 || nx < 0 || nx >= 3) continue;

		res |= dfs(rain, ny, nx, day + 1);
	}
	return res;
}

signed main(){
	while(cin >> n,n){
		m.clear();
		memset(fes, 0, sizeof(fes));
		rep(i,n){
			rep(j,4){
				rep(k,4){
					cin >> fes[i][j][k];
				}
			}
		}
		cout << dfs(0, 1, 1, 0) << endl;
	}
}

Measured memory_bytes: 46040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int>v;
	int a;
	for(int i=0;i<n;i++){
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=v.at(i);
	}
	cout<<sum<<"\n";

	
	
		


	
	return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
    
int main() {
  int a[4], b[4], g, h, i, n, m, hit, blow;
    
  while(scanf("%d", &a[0]) != EOF) {
    for(g = 1; g < 4; g += 1) {
      scanf("%d", &a[g]);
    };
    for(h = 0; h < 4; h += 1) {
      scanf("%d", &b[h]);
    };

    hit = 0;
    blow = 0;

    for(n = 0; n < 4; n += 1) {
      for(m = 0; m < 4; m += 1) {
        if(a[n] == b[m]) {
          if(n == m) {
            hit += 1;
          } else {
            blow += 1;
          };
        };
      };
    };
    printf("%d %d\n", hit, blow);
  };
  return 0; 
}

Measured memory_bytes: 596
A,B,N=map(int, input().split())
answer=0
import math
if N < B:
    print(int(math.modf(N/B)[0]*A))
else:
    apple=min(B,N)
    startnum = B-1 if B>1 else 1
    for i in range(startnum,apple+1):
        newans=math.modf(i/B)[0]*A
        newans//=1
        answer=newans if newans>answer else answer
    print(int(answer))

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

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

  string s;
  double ans = 0;
  double v;

  rep(i,N) {
    cin >> v >> s;
    if(s == "JPY") {
      ans += v;
    } else {
      ans += 380000.0 * v;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    string s,t;
    cin >> s >> t;
    reverse(s.begin(),s.end());
//    cout << s << endl;
//    cout << t << endl;
    if(s == t){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    char x;
    scanf("%d %c %d",&a,&x,&b);
    if(x=='+')
    {
        printf("%d\n",a+b);
    }
    else
    {
        printf("%d\n",a-b);
    }
    return 0;
}


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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#define debarr(a,x,y){}
#define debmat(mat,row,col){}
#endif
#define pr(x) {cout << x << "\n"; return;}
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

#define int              long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define rep(i,n)         for(int i=0;i<n;i++)
#define re(i,n)          for(int i=1;i<=n;i++)
#define fr(i,a,b)        for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
typedef vector<int>      vi;
typedef pair<int, int>   pii;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const int N = 2e5 + 10;


void solve(int tc)
{
	int n; cin >> n;
	int f = 0;
	rep(i, n)
	{
		int x, y; cin >> x >> y;
		if (x == y) f++;
		else f = 0;
		if (f == 3) pr("Yes");
	}
	pr("No");

}




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

	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) solve(i);
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> C(N, 0);
  for(int j = 1; j < N; j++){
    C.at(j) += C.at(j-1);
    if(S[j-1] == 'A' && S[j] == 'C') C.at(j)++;
  }
  for(int i = 0; i < N; i++) cerr << C.at(i) << endl;
  cerr << endl;
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    l--; r--;
    int ans = C.at(r) - C.at(l);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
const int N=1e5+10;
int n,rg,br,gb,r,g,b,ans=1;
char s[N*3];
signed main() {
	scanf("%lld",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)ans=ans*i%mod;
	for(int i=1;i<=3*n;i++){
		if(s[i]=='R'){
			if(gb){ans=ans*gb%mod;gb--;}
			else if(g){ans=ans*g%mod;g--;rg++;}
			else if(b){ans=ans*b%mod;b--;br++;}
			else r++;
		}
		if(s[i]=='G'){
			if(br){ans=ans*br%mod;br--;}
			else if(b){ans=ans*b%mod;b--;gb++;}
			else if(r){ans=ans*r%mod;r--;rg++;}
			else g++;
		}
		if(s[i]=='B'){
			if(rg){ans=ans*rg%mod;rg--;}
			else if(r){ans=ans*r%mod;r--;br++;}
			else if(g){ans=ans*g%mod;g--;gb++;}
			else b++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int a,b,c,sum;//KはくまでX円でNはくする

int main(){

	cin>>a>>b>>c;
	sum=a*100+b*10+c;
	if(sum%4==0)	cout<< "YES"<<endl;
	else cout<<"NO"<<endl;
		return 0;

	}


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

long long digit(long long num) {
    int count=0;
    while(num>0) {
        count++;
        num/=10;
    }
    return count;
}

int main() {
    long long n;
    cin>>n;
    long long ans=1000000;
    for(long long i=1;i*i<=n;i++) {
        if(n%i!=0) continue;
        int sub=max(digit(i),digit(n/i));
        if(ans>sub) ans=sub;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int h,w,n;cin>>h>>w>>n;
    vl a(n);rep(i,n) cin>>a[i];
    vector<vector<int>> g(h,vector<int>(w));
    int rev=0;
    int cur=0;
    rep(j,w){
        if(!rev){
            rep(i,h){
                g[i][j]=cur+1;
                a[cur]--;
                if(a[cur]==0) cur++;
            }
        }
        else{
            drep(i,h){
                g[i][j]=cur+1;
                a[cur]--;
                if(a[cur]==0) cur++;
            }
        }
        rev^=1;
    }
    rep(i,h){
        rep(j,w){
            cout<<g[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  rep(i, N) {
    cin >> x[i] >> y[i];
  }

  vector<int> perm_index(N);
  rep(i, N) perm_index[i] = i;

  double aaa = 0;
  int hoge = 0;
  do {
    double l = 0;
    int sX = x[perm_index[0]];
    int sY = y[perm_index[0]];
    rep(i, N) {
      int X = x[perm_index[i]];
      int Y = y[perm_index[i]];
      l += sqrt((X - sX) * (X - sX) + (Y - sY) * (Y - sY));
    }
    aaa += l;
    ++hoge;
  } while (next_permutation(perm_index.begin(), perm_index.end()));
  printf("%.10f\n", aaa / hoge);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 200005
#define gc getchar
using namespace std;

inline int rd() {
  int x = 0;
  bool f = 0;
  char c = gc();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = gc();
  }
  while (isdigit(c)) {
    x = x * 10 + (c ^ 48);
    c = gc();
  }
  return f ? -x : x;
}

int n, tot, hd[N];

struct edge {int to, nxt;} e[N << 1];

inline void add(int u, int v) {
  e[++tot].to = u; e[tot].nxt = hd[v]; hd[v] = tot;
  e[++tot].to = v; e[tot].nxt = hd[u]; hd[u] = tot;
}

int dfs(int u, int fa) {
  int len = 0;
  for (int i = hd[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != fa) len = len ^ (dfs(v, u) + 1);
  return len;
}

int main() {
  n = rd();
  for (int i = 1; i < n; ++i) add(rd(), rd());
  puts(dfs(1, 0) ? "Alice" : "Bob");
  return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int d = a+b;
		int e = b+c;
		int f = c+a;
		int g = 0;
		
		if(d>=e) {
			g = e;
		}
		else {
			g = d;
		}
		if(g>=f) {
			g = f;
		}
		else {
		}
		
		System.out.println(g);
	}
}


Measured memory_bytes: 21844
def main():
    n, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    ans = 10 ** 12

    for i in range(2 ** n):
        lst = []

        for j in range(n):
            if (i >> j) & 1:
                lst.append(j)

        if len(lst) < k:
            continue

        highest = a_list[0]
        cost = 0

        for j in range(1, n):
            if highest < a_list[j]:
                highest = a_list[j]
            else:
                if j in lst:
                    highest += 1
                    cost += highest - a_list[j]

        ans = min(ans, cost)

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++)
    cin >> p.at(i);
  int c = 0;
  for(int i = 0; i < n-2; i++){
    if(p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2)){
      c ++;
      //cout << p.at(i+1) << endl;
    }
    else if(p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2)){
      c ++;
      //cout << p.at(i+1) << endl;
    }
  }
  cout << c << endl;
}


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

using namespace std;

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

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

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

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

#if 1


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

  int N;
  cin >> N;
  long double d = 0;
  F0R(i, N) {
    long double a;
    cin >> a;
    d += 1 / a;
  }

  cout << std::fixed << std::setprecision(15);
  cout << (1 / d);
}
#endif


Measured memory_bytes: 3720
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    strings=[]
    h,w = map(int,input().split())
    strings=[input().rstrip() for _ in range(h)]
    output=""

    for i in range(h+2):
        if i==0 or i==h+1:
            igeta="#"*(w+2)
            print("{}".format(igeta))
        else:
            output="#"+strings[i-1]+"#"
            print(output)

if __name__=="__main__":
    main()

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final long a = sc.nextLong();
        final long b = sc.nextLong();
        final long c = sc.nextLong();
        final long d = sc.nextLong();
        
        long v = a * c;
        long w = a * d;
        long x = b * c;
        long y = b * d;
        
        System.out.println(Math.max(Math.max(v, w), Math.max(x, y)));
    }
}


Measured memory_bytes: 35824
s = input()
a, b = s[:2], s[2:]
def check(s1, s2):
    if 0 < int(s1) <= 12 and 0 < int(s2) <= 12:
        return 'AMBIGUOUS'
    elif 0 < int(s1) <= 12:
        return 'MMYY'
    elif 0 < int(s2) <= 12:
        return 'YYMM'
    else:
        return 'NA'
print(check(a, b))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
long long ryuka(int x){
  long long a = 2;
  long long b = 1;
  
  if(x == 0){
    return 2;
  }
  else if(x == 1){
    return 1;
  }
  else{
  for(int i = 0; i < x; i++){
    long long d = b;
    b = a + b;
    a = d;
  }
  return a;
  }
}
 
int main() {
  int n;
  cin >> n;
  cout << ryuka(n) << endl;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int check(int a)
{
	if (a==4 || a==6 || a==9 || a==11) {
		return 1;
	} else if (a == 2) {
		return 2;
	} else {
		return 3;
	}
}

int main()
{
	int x, y;
	
	cin >> x >> y;
	
	if (check(x) == check(y)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



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

using namespace std;
typedef long long ll;

int N;

ll dp1[10001][2][2][9];
ll dp2[5001][2][2][2][2][9];

ll dfs1(int pos,int prv,int init,int leftp){
    ll res=0;
    if(pos==N){
        if(leftp==0)return 1;
        return 0;
    }
    else if(dp1[pos][prv][init][leftp]!=-1)return dp1[pos][prv][init][leftp];
    else{
        // テつ催つ。テつ嘉δアテつ甘つつづδィテつ禿つ姪つづδつづδゥテつづつゥテつ甘つつづδィテつ禿つ姪つづδつづδ暗つづつ「テつづつゥ
        if(prv==1||(pos==N-1&&init==1))res+=dfs1(pos+1,0,init,leftp);
        else{
            res+=dfs1(pos+1,0,init,leftp);
            if(leftp>=1)res+=dfs1(pos+1,1,init,leftp-1);
        }
    }
    return dp1[pos][prv][init][leftp]=res;
}
// N/2テつ嘉δアテつ施テつ行テつづつキテつづδゥ
ll dfs2(int pos,int prvUp,int prvDown,int upinit,int downinit,int leftp){
    ll res=0;
    if(pos==N/2){
        if(leftp==0)return 1;
        return 0;
    }
    else if(dp2[pos][prvUp][prvDown][upinit][downinit][leftp]!=-1)
        return dp2[pos][prvUp][prvDown][upinit][downinit][leftp];
    else{
        // テつ催つ。テつ嘉δアテつ甘つつづδィテつ禿つ姪つづδつづδゥテつづつゥテつ甘つつづδィテつ禿つ姪つづδつづδ暗つづつ「テつづつゥテつ、テつづつサテつづつオテつづδつづδつづつソテつづδァテつづδ嘉つ甘つつづδィテつ禿つ姪つづδつづδゥテつづつゥ
        // テつ甘つつづδィテつ禿つ姪つづδつづδ暗つづつオ
        res+=dfs2(pos+1,0,0,upinit,downinit,leftp);
        if(leftp-1>=0){
            for(int i=0;i<2;i++){
                if(i==0&&prvUp==0&&(pos!=(N/2-1)||downinit==0)){
                    res+=dfs2(pos+1,1,0,upinit,downinit,leftp-1);
                }
                else if(i==1&&prvDown==0&&(pos!=(N/2-1)||upinit==0)){
                    res+=dfs2(pos+1,0,1,upinit,downinit,leftp-1);
                }
            }
        }
        return dp2[pos][prvUp][prvDown][upinit][downinit][leftp]=res;
    }
}


int main(){
    while(cin>>N&&N){
        if(N%2==1){
            for(int i=0;i<=N;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<9;l++)dp1[i][j][k][l]=-1;
            ll res=dfs1(1,1,1,7);
            res+=dfs1(1,0,0,8);
            for(int i=1;i<=8;i++)res*=i;
            cout<<res<<endl;
        }
        else{
            for(int i=0;i<=(N/2);i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
                for(int l=0;l<2;l++)for(int m=0;m<2;m++)for(int o=0;o<9;o++)dp2[i][j][k][l][m][o]=-1;
            ll res=dfs2(1,0,0,0,0,8);
            res+=dfs2(1,1,0,1,0,7);
            res+=dfs2(1,0,1,0,1,7);
            for(int i=1;i<=8;i++)res*=i;
            cout<<res<<endl;
        }
    }

    return 0;
}

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

using namespace std;

void solve(int N, vector<int> A) {
  vector<int> B(N + 1, 0);
  int nn = 0;
  for (int i = N; i > 0; i--) {
    int s = 0;
    for (int j = i; j <= N; j += i) {
      s += B[j];
    }
    if (s % 2 != A[i]) {
      B[i] = 1;
      nn += 1;
    }
  }
  printf("%d\n", nn);
  for (int i = 1; i <= N; i++) {
    if (B[i] == 1) {
      printf("%d ", i);
    }
  }
  printf("\n");
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}


Measured memory_bytes: 3200
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! get {
    ($i:ident) => {
        io::stdin().read_line(&mut $i).ok()
    };
}

#[allow(unused_macros)]
macro_rules! to_vec {
    ($s:ident, $t:ty) => {
        $s.split_whitespace().map(|i| i.parse().ok().unwrap()).collect::<Vec<$t>>()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($s:ident, $t:ty) => {
        $s.trim().parse::<$t>().ok().unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_macros)]
macro_rules! min {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_macros)]
macro_rules! sort {
    ($v:ident) => {
        $v.as_mut_slice().sort()
    };
}

fn trace(a: &Vec<i32>, n: i32) {
    for j in 0..n {
        print!("{}", a[j as usize]);
        if j != (n - 1) {
            print!(" ");
        } else {
            println!();
        }
    }
}

#[allow(unused_variables)]
#[allow(unused_mut)]
fn main() {
    let mut s = String::new();
    get!(s);
    let n = parse!(s, i32);
    let mut s = String::new();
    get!(s);
    let mut a = to_vec!(s, i32);
    trace(&a, n);
    for i in 1..n {
        let v = a[i as usize];
        let mut j = i - 1;
        while j >= 0 && a[j as usize] > v {
            a[(j + 1) as usize] = a[j as usize];
            j -= 1;
        }

        a[(j + 1) as usize] = v;
        trace(&a, n);
    }
}


Measured memory_bytes: 5036
N,M =map(int,input().split())
SC = [list(map(int,input().split())) for m in range(M)]

for i in range(1000):
    answer = str(i)
    if len(answer) == N and all( answer[s-1]==str(c) for s,c in SC):
        print(i)
        exit(0)

print(-1)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

j = 0
l = len(A)

while 1:
    count = 0
    for i in A:
        if i % 2 == 0:
            count += 1

    if count == l:
        j += 1
        for i in range(l):
            A[i] = A[i] // 2
    else:
        break

print(j)


Measured memory_bytes: 3060
numeros = [int(x) for x in input().split()]
k = int(input())
index_maior = 0
maior = numeros[0]
for index, value in enumerate(numeros):
    if value > maior:
        maior = value
        index_maior = index
for _ in range(k):
    numeros[index_maior] *= 2
print(sum(numeros))



Measured memory_bytes: 3060
from collections import deque
N, M = map(int, input().split())
Inf = 10000000000
Edge = [[] for i in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    Edge[l-1].append((r-1, d))
    Edge[r-1].append((l-1, -d))
 
Node = [Inf for i in range(N)]
Possible = True
for i in range(N):
    if not Possible:
        break
    elif Node[i] == Inf:
        Node[i] = 0
        Q = deque([i])
        while Q:
            now = Q.popleft()
            for e in Edge[now]:
                if Node[e[0]] == Inf:
                    Node[e[0]] = Node[now] + e[1]
                    Q.append(e[0])
                elif Node[now] + e[1] != Node[e[0]]:
                    Possible = False
                    break
print("Yes" if Possible else "No")

Measured memory_bytes: 66272
#include <iostream>
int main(void){
	int n,a,b,c,d;
	std::cin>>n;
	while(n--){
		std::cin>>a>>b>>c;
		d=a>b?a:b;
		d=c>d?c:d;
		std::cout<<(a*a+b*b+c*c==2*d*d?"YES\n":"NO\n");
	}
}

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

ll m = 998244353;

int main() {

    ll N, K, C;
    cin >> N >> K >> C;

    string S;
    cin >> S;

    vector<ll> L(2e5+9), R(2e5+9);
    ll d;
    ll i;
    d = 0;
    i = 0;
    while(i < K) {
        if (S[d] == 'x') {
            d++;
            continue;
        }
        else {
            L[i] = d;
            i++;
            d += (C+1);
        }
    }

    d = N-1;
    i = K-1;
    while(i >= 0) {
        if (S[d] == 'x') {
            d--;
            continue;
        }
        else {
            R[i] = d;
            i--;
            d -= (C+1);
        }
    }

    for (int i = 0; i < K; ++i) {
        if (L[i] == R[i]) cout << L[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 6696
def z_algo(s):
    """文字列sについて、各iについて「SとS[i:|S|]の最長共通接頭辞の長さ」
    を記録した配列をO(|S|)で構築する
    """
    res = [0] * len(s)
    res[0] = len(s)
    i = 1
    j = 0
    while i < len(s):
        while i + j < len(s) and s[j] == s[i + j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < len(s) and k + res[k] < j:
            res[i + k] = res[k]
            k += 1
        i += k
        j -= k
    return res


n = int(input())
s = input()

ans = 0
for i in range(n):
    res = z_algo(s[i:])
    for i, num in enumerate(res):
        ans = max(ans, min(num, i))
print(ans)

Measured memory_bytes: 53596
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

#define  kak 1000000000000;



int main(){
    ll N;
    ll M;
    ll L;
    ll R;
    cin >> N;
    cin >> M;
    vector<int> ID(N+1,0);
    ID[0] = 0;
    ll oldL = 0;
    ll oldR = N+1;
    int  first = 1;
    for (int i = 0; i < M; ++i) {
        cin >>L;
        cin >> R;
        if(oldL < L)  oldL = L;
        if(oldR >  R) oldR = R;

        //cout <<oldL<<","<<oldR<<endl;
    }

    ll num = oldR - oldL + 1;
    if(num <= 0 ) num = 0;
    cout << num;
    return 0;
}




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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;
ll s(int n)
{
    return (n*(n+1))/2;
}
void  solve()
{
    int n,k;
    cin>>n>>k;
    double arr[n];
    forn(i,n)cin>>arr[i];

    forn(i,n)
    {
        arr[i]=s(arr[i])/arr[i];
    }

    double ans=0,cur=0;
    int p1=0,p2=0;

    while(p2<n)
    {

        if(p2-p1+1>k)
        {
            cur-=arr[p1];
            p1++;
        }
        else
        {
            cur+=arr[p2];
            p2++;
            ans=max(ans,cur);
        }

    }
    cout<<fixed<<setprecision(15)<<ans<<endl;


}


int main()
{
 
    FastIO;
   // init();
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int> > sortl;
  vector<pair<pair<int, int>, int> > sortr;
  int maxint = 0;
  int maxval = -1;
  pair<int, int> orig[n];
  for (int i=0; i<n; i++){
      int l, r;
      cin >> l >> r;
      sortl.emplace_back(make_pair(l, r), i);
      sortr.emplace_back(make_pair(r, l), i);
      if (r-l > maxval){
          maxval = r-l;
          maxint = i;
      }
      orig[i] = {l, r};
  }
  sort(sortl.rbegin(), sortl.rend());
  
  sort(sortr.begin(), sortr.end());
  long long sum = 0;
  int ind1 = sortl[0].second; // biggest l
  int ind2 = sortr[0].second; // smallest r
  if (ind1 == ind2){
      sum = sortl[0].first.second-sortl[0].first.first+1;
      cout << sum+maxval+1;
      return 0;
  }
  
  vector<pair<int, int> > again;
  multiset<int> rs;
  set<int> possl;
  for (int i=0; i<sortl.size(); i++){
      if (sortl[i].second == ind1 || sortl[i].second == ind2){
          continue;
      }
      again.push_back(sortl[i].first);
      rs.insert(sortl[i].first.second);
      possl.insert(sortl[i].first.first);
  }
  sort(again.begin(), again.end());
  int ll = orig[ind2].first;
  int lr = orig[ind2].second;
  int rl = orig[ind1].first;
  int rr = orig[ind1].second;
  int ind = 0;
  int val1 = 0;
  if (ind1 != maxint && ind2 != maxint){
      val1 = maxval+1+max(0, lr-rl+1);
  }
  int curmax;
  if (rs.size() == 0){
      curmax = max(val1, max(lr-ll+1, 0)+max(0, rr-rl+1));
  }else{
      curmax = max(val1, max(lr-ll+1, 0)+max(0, min(rr, *(rs.begin()))-rl+1));
  }
  
  
  for (int i : possl){
      while (ind < again.size() && again[ind].first == i){
          rs.erase(rs.lower_bound(again[ind].second));
          ind++;
      }
      if (rs.size() != 0){
          curmax = max(curmax, max(0, lr-max(ll, i)+1)+max(0, min(rr, *(rs.begin()))-rl+1));
      }else{
          curmax = max(curmax, max(0, lr-max(ll, i)+1)+max(0, rr-rl+1));
      }
      
  }
  cout << curmax;
  return 0; 
}


Measured memory_bytes: 13484
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long c[5][5];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0;i<3;i++){
        int a=c[i][0];
        for(int j=0;j<3;j++){
            c[i][j]-=a;
        }
    }
    for(int i=0;i<3;i++){
        int a=c[0][i];
        for(int j=0;j<3;j++){
            c[j][i]-=a;
        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(c[i][j]!=0){
                cout<<"No"<<endl;
                return(0);
            }
        }
    }
    cout<<"Yes"<<endl;
    return(0);
}

Measured memory_bytes: 3672
def solve(height):
    
    water_count = 0 #水やり回数

    while True:
        index = [i for i, v in enumerate(height) if v >0] #水をやる必要のある花のリスト インデックスが連続した範囲でしか水やりできない
    
        # 花の水やり範囲を決定
        min_index = index[0] #インデックスの最小値
        max_index = index[0] #インデックスの最大値
    
        while True:
            if (max_index+1) in index:
                max_index += 1
            else:
                break
    
        for flower in range(min_index, max_index+1):
            height[flower] -= 1 
        water_count += 1 #水やりカウンタ増やす
        
        if sum(height) == 0: #水やりが終わったら終了
            break
    print(water_count)
    
def solve_zero(height): #元々のリストがすべて０のとき
    print(0)

if __name__ == "__main__":
    N = int(input()) 
    height = list(map(int, input().split())) #入力：花の高さ
    if sum(height) == 0:
        solve_zero(height)
    else:
        solve(height)

Measured memory_bytes: 3064
N,M,K = map(int,input().split())
ans = 'No'
for x in range(M+1):
    if M-2*x == 0:
        if K%N == 0:
            ans = 'Yes'
            break
        else:
            continue
    else:
        if (K-N*x)%(M-2*x) == 0 and 0 <= (K-N*x)/(M-2*x) <= N:
            ans = 'Yes'
            break
        else:
            continue
print(ans)

Measured memory_bytes: 3060
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	int r, g, b;
	cin >> r >> g >> b;
	int val = r*100 + g*10 + b;
	if(val % 4 == 0){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return;
}




Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 998244353
t = []
for _ in range(K):
    l, r = map(int, input().split())
    t.append((l, r))
dp = [0]*(N+1)
dp[1] = 1
dps = [0]*(N+1)
dps[1] = 1
for i in range(2, N+1):
    for j in range(K):
        li = i-t[j][0]
        ri = i-t[j][1]
        if li < 0:
            continue
        ri = max(ri, 1)
        dp[i] += dps[li]-dps[ri-1]
        dp[i] %= MOD
    dps[i] = dps[i-1]+dp[i]
    dps[i] %= MOD
print(dp[N])


Measured memory_bytes: 24496
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        self.link(self.find_set(u), self.find_set(v))

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def link(self, u, v):
        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


uf = UnionFind(n)

sm = n * (n - 1) // 2
ans = [sm]
for a, b in ab[-1:0:-1]:
    a -= 1
    b -= 1
    if not uf.same(a, b):
        sm -= uf.get_size(a) * uf.get_size(b)
        uf.unite(a, b)
    ans.append(sm)

print(*ans[::-1], sep="\n")


Measured memory_bytes: 38132
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
      final var br = new BufferedReader(stdin)) {
      final var a = Integer.parseInt(br.readLine());

      System.out.println(a + a * a + a * a * a);
    }
  }
}


Measured memory_bytes: 32800
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
const int INF = 1e9;
typedef long long ll;
using namespace std;

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


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int max = a;
	if (max < b) {
		max = b;
	}
	if (max < c) {
		max = c;
	}
	
	int ans = 0;
	if ((a + b + c - max) % 2 == 0) {
		ans = ((3 * max) - (a + b + c)) / 2;
	}
	else if ((a + b + c - max) % 2 != 0) {
		ans = ((3 * (max + 1)) - (a + b + c)) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> s(100000);
	vector<int> t(50000);
	int n,q,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s.begin(),s.end());
	cin>>q;
	for(int j=0;j<q;j++){
		cin>>t[j];
	}
	for(int k=0;k<q;k++){
		if(binary_search(s.begin(),s.end(),t[k])){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3372
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >>n;
	int a[55]={0};
		
	for(int i=0;i<n;i++)
		cin >>a[i];
	sort(a,a+n);
	double sum=a[0];
	for(int i=1;i<n;i++)
		sum =(a[i]+sum)/2;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e6)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main() {
	FIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vl v(n);
		for(int i=0;i<n;i++) cin >> v[i];
		sort(v.begin(),v.end());
		if(n == 1){
			cout << "0\n";
			return 0;
		}
		ll cnt = n-2;
		int i = n-2;
		ll ans = v[i+1];
		while(cnt){
			cnt -= 2;
			ans += 2*v[i];
			i--;
			if(cnt == 1){
				ans += v[i];
				break;
			}
		} 
		cout << ans << "\n";
	}


	return 0;
}


Measured memory_bytes: 4752