akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;


ll X, Y, p[MXN], q[MXN], r[MXN], A, B, C;
vector<ll> blah;


int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> X >> Y >> A >> B >> C;
    F0R(i,A){
        cin >> p[i];
    }
    F0R(i,B){
        cin >> q[i];
    }
    F0R(i,C){
        cin >> r[i];
    }
    sort(p,p+A);
    sort(q,q+B);
    sort(r,r+C);
    for(int i = A-1, ind = 0; i >= 0 && ind < X; i--, ind++){
        blah.pb(p[i]);
    }
    for(int i = B-1, ind = 0; i >= 0 && ind < Y; i--, ind++){
        blah.pb(q[i]);
    }
    sort(blah.begin(), blah.end());
    ll sm = 0;
    ll ind = C - 1;
    F0R(i,sz(blah)){
        if (i < C && ind >= 0 && blah[i] < r[ind]){
            sm += r[ind];
            ind--;
        }
        else if (i < C && ind >= 0 && blah[i] >= r[ind]){
            sm += blah[i];
        }
        else if (i >= C){
            sm += blah[i];
        }
    }
    cout << sm << newl;











	return 0;
}


Measured memory_bytes: 5748
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    string s, pre1, pre2;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") return;
    pre1 = s;
    cout << n-1 << endl;
    cin >> s;
    if (s == "Vacant") return;
    pre2 = s;
    int a = 0, b = n-1;
    while (s != "Vacant") {
        int mid = (a + b) / 2;
        cout << mid << endl;
        cin >> s;
        if ((mid - a)%2 == 0 && s != pre1) {
            b = mid;
            pre2 = s;
        } else if ((mid - a)%2 != 0 && s == pre1) {
            b = mid;
            pre2 = s;
        } else if ((b - mid)%2 == 0 && s != pre2) {
            a = mid;
            pre1 = s;
        } else if ((b - mid)%2 != 0 && s == pre2) {
            a = mid;
            pre1 = s;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

int a[22][22],n;
ll dp[(1<<21)];

ll calc(int idx,int msk){
	if(idx == n)return 1;
	ll &ret = dp[msk];
	if(ret != -1)return ret;
	ret = 0;
	for(int i=0;i<n;i++){
		if((msk >> i) & 1 || a[idx][i] == 0)continue;
		ret = (ret + calc(idx+1,msk | (1<<i)))%mod;
	}
	return ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	cout << calc(0,0) << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,s,t,l,k,o;
  vector<string> d,f;
  string j,r,e;
  cin >> a;
  for (int i=0;i<a;i++){
    cin >> j;
    d.push_back(j);
  }
  cin >> s;
    for (int i=0;i<s;i++){
    cin >> j;
    f.push_back(j);
  }
  o=0;
  k=0;
  for(int i=0;i<d.size();i++){
    o=0;
    for(int b=0;b<f.size();b++){
      if(d.at(i) == f.at(b))
        o -= 1;
    }
    for(int b=0;b<d.size();b++){
      if(d.at(i) == d.at(b))
        o += 1;
    }
    if(o > k)
      k = o;
  }
  if(k > 0){
  cout << k << endl;
}else{
    cout << 0 << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
         int n,k;
         cin>>n>>k;
         int p[n];
         for(int i=0;i<n;i++)cin>>p[i];
         int ans=0,mans;
         for(int i=0;i<k;i++)ans+=(p[i]+1);
         mans=ans;
         for(int i=k;i<n;i++){
             ans-=(p[i-k]+1);
             ans+=p[i]+1;
            mans=max(mans,ans);
         }
         long double aa=mans;
         cout << fixed << setprecision(6)<<(aa)/2.0;

        }


Measured memory_bytes: 1792
#include <cstdio>

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  long long a = n / k;
  long long ans = a * a * a;
  if ((k & 1) == 0)
  {
    if (a * k + k / 2 <= n) ++a;
    ans += a * a * a;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
    
    int N,K;
    vector <int> ans;
    int d,A,count = 0;
    
    cin >> N >> K;
    
    ans.assign(N+1,1);
    
    for (int i = 1; i <= K ; i++){
        
        cin >> d;
        
        for(int j = 0 ; j < d ; j++){
            cin >> A;
            ans[A] = 0;
        }
        
    }
    
    for (int i = 1; i <= N ; i++){
        count += ans.at(i);
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <utility>

#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

unsigned long gcd(unsigned long a, unsigned long b){
	unsigned long r = a % b;
	if(r == 0){
		return b;
	}
	else{
		return gcd(b, r);
	}
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif // INPUT_FROM_FILE
	unsigned long a = 0;
	unsigned long b = 0;

#if INPUT_FROM_FILE
	while(ifs >> a >> b){
#else
	while(std::cin >> a >> b){
#endif
		if(a < b){
			std::swap(a, b);
		}
		unsigned long g = gcd(a, b);
		std::cout << g << " " << (a / g) * b  << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
int main(){
  int p, q, r;
  int n1, n2, n3, menor;
  scanf("%d %d %d", &p, &q, &r);
  n1=p+q;
  n2=q+r;
  n3=r+p;

  menor=n1;

  if(n2<menor)
    menor=n2;

  if(n3<menor)
      menor=n3;

  printf("%d\n", menor);
  return 0;
}


Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flag = true;
		Set<String> set = new HashSet<>();
		String s = sc.next();
		char tail = s.charAt(s.length() - 1);
		set.add(s);
		for(int i = 1; i < n; i++) {
			s = sc.next();
			if(tail != s.charAt(0) || set.contains(s)) {
				flag = false;
				break;
			} else {
				tail = s.charAt(s.length() - 1);
				set.add(s);
			}
		}
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 23124
def stack(data):
    s = []
    for i in data:
        if i in "+-*":
            a2 = s.pop()
            a1 = s.pop()
            s.append(str(eval(a1 + i + a2)))
        else:
            s.append(i)
    print(s[0])

if "__main__" == __name__:
    data = input().split()
    stack(data)



Measured memory_bytes: 5572
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n, k;
    cin>>n>>k;
    vl a(n);
    forr(i, n)
    {
        cin>>a[i];
    }
    sort(all(a));
    ll sum=0;
    forr(i, k)
    sum+=a[i];
    cout<<sum;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  ll a[100010];
  rep(i,N){
    cin>>a[i];
  }
  
  if(N==1) cout<<"Yes"<<endl;
  else{
    bool ok=true;
    int count=0;
    rep(i,N-1){
      ll da=a[i]-a[i+1];
      if(count==0){
        if(da<1) continue;
        if(da==1){
          count=1;
          continue;
        }
        if(da>1){
          ok=false;
          break;
        }
      }
      else{
        if(da<0){
          count=0;
          continue;
        }
        if(da==0){
          count=1;
          continue;
        }
        if(da>0){
          ok=false;
          break;
        }
      }
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}
      

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define prique2(T) priority_queue<T>

using P = pair<int, int>;
int n, m, cnt, ans;
P p[100010];
prique2(int)que;
signed main() {
	scanf("%lld %lld", &n, &m);
	rep(i, n) {
		scanf("%lld %lld", &p[i].first, &p[i].second);
	}
	sort(p, p + n);
	for (int i = 1; i <= m; ++i) {
		for(; cnt < n&& p[cnt].first <= i; ++cnt) {
			que.push(p[cnt].second);
		}
		if (que.empty()) continue;
		ans += que.top();
		que.pop();
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2936
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long n; cin >> n;
    if(n == 26){
        cout << 'z' << endl;
        return 0;
    }
    vector<char> c;
    while(0 < n){
        char t = (n%26 == 0)?'z':('a'+n%26-1);
        c.push_back(t);
        n = (n%26 == 0)?(n-26):(n-n%26);
        n /= 26;
    }
    for(int i = c.size()-1; -1 < i; --i) cout << c[i];
    cout << endl;   
    return 0;
}

Measured memory_bytes: 3632
/* ex 5_4
   kanon */

#include <stdio.h>
#include <string.h>
#define SIZE 80

int main(void)
{
    //与えられる値を入れる数を宣言
    char str[SIZE], *ptr;
    int longest_len = 0, temp_len = 0, flag = 0;

    //変数に値を入力する
    scanf("%s", str);

    //文字列内で探索
    ptr = &str[0];

    while (*ptr != '\0')
    {

        if (*ptr == 'A' || *ptr == 'T' || *ptr == 'C' || *ptr == 'G')
        {
            temp_len++;
        }
        else
        {
            if (temp_len > longest_len)
                longest_len = temp_len;

            temp_len = 0;
        }
        ptr++;
    }

    if (temp_len > longest_len)
        longest_len = temp_len;

    //答えを出力
    printf("%d\n", longest_len);
    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vl a(N);
    Rep(i,N){
        Scll(a[i]);
    }

    ll mod = 1000000007;

    ll ans = 0;
    ll t = 1;
    ll cnt;
    Rep(i,61){
        cnt = 0;
        Rep(ai,N) if( t&a[ai] ) cnt++;
        ans += ((cnt)*(N-cnt)%mod)*(t%mod);
        ans %= mod;
        t <<= 1;
    }

    printf ("%lld\n", ans );

    return 0;
}



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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

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

  UnionFind uf(N + M);
  for(int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for(int j = 0; j < K; j++) {
      int L;
      cin >> L;
      uf.unite(--L, M + i);
    }
  }
  int root = uf.find(M);
  for(int i = 0; i < N; i++) {
    if(root != uf.find(M + i)) {
      cout << "NO" << endl;
      return (0);
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,D=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(H)]
Q = int(input())
LR=[list(map(int,input().split())) for i in range(Q)]


dict_map = {}
for ih in range(H):
    for iw in range(W):
        dict_map[A[ih][iw]]=(ih,iw)

memo = [-1]*(H*W+1)
for i in range(1,D+1):
    useMP = 0
    direct = range(i,H*W+1,D)
    memo[i]=0
    for p in range(len(direct)-1):
        x0,y0 = dict_map[direct[p]]
        x1,y1 = dict_map[direct[p+1]]
        dist = abs(x0-x1)+abs(y0-y1)
        useMP += dist
        memo[direct[p+1]]=useMP

for q in range(Q):
    L,R=LR[q]
    print(memo[R]-memo[L])


Measured memory_bytes: 45920
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = [int(readline()) for _ in range(n)]
if a[0] != 0:
    print(-1)
    exit()
ans = 0
for ab, af in zip(a, a[1:]):
    if af - ab > 1:
        print(-1)
        exit()
    if ab >= af:
        ans += af
    else:
        ans += 1
print(ans)


Measured memory_bytes: 12612
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    int x,y,a,b,c,t;
    int tz;
    cin>>x>>y>>a>>b>>c;
    // int ca=0,cb=0;
    vector<pii> app;
    for(int i=0;i<a;i++){
    	cin>>t;
    	app.pb({t,0});
    }

    for(int i=0;i<b;i++){
    	cin>>t;
    	app.pb({t,1});
    }

    for(int i=0;i<c;i++){
    	cin>>t;
    	app.pb({t,3});
    }
    tz=x+y;

    sort(all(app));
    reverse(all(app));

    int tot = 0;
    int ans = 0;
    for(int i=0;tot<tz;i++){
    	auto tp = app[i];

    	if(tp.ss==3)
    	{
    		tot++;
    		ans+=tp.ff;
    	}
    	if(tp.ss==0 and x>0){
    		tot++;
    		x--;
    		ans+=tp.ff;
    	}
    	if(tp.ss==1 and y>0){
    		tot++;
    		y--;
    		ans+=tp.ff;
    	}
    	// cout<<ans<<" "<<tot<<endl;
    }
    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
string s;
  cin>>s;
  if(s[2]==s[3] and s[4]==s[5])
    cout<<"Yes";
  else
    cout<<"No";
return 0;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())

cnt = [0]*n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if x**2 + y**2 + z**2 + x*y + x*z + y*z - 1 < n:
                cnt[x**2 + y**2 + z**2 + x*y + x*z + y*z - 1] += 1
print(*cnt,sep='\n')
        

Measured memory_bytes: 69320
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>x;i--)
typedef long long ll;
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b;
    if (a%2==0 || b%2==0){
        cout<<"Even"<<endl;
    }
    else{
        cout<<"Odd"<<endl;
    }
}


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

int main(){
int N; cin >> N;
long long Y; cin >> Y;
int ok = 1;  
for(int i=0;i<=N;i++){
  for(int j=0;j<=N;j++){
  int k = N - j - i;
  if(k<0)continue;  
  if((10000*i+5000*j+1000*k) == Y){
    cout << i <<" "<< j <<" "<< k << endl;
    ok = 0;
    break;
  }
  }
  if(ok == 0)break;
}
if(ok)cout << -1 <<" "<< -1 <<" "<< -1 << endl;

  
}
  

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

int main() {
    int x, ans;
    for (int i = 1; i <= 5; i++)
    {
        cin >> x;
        if (x == 0) ans = i;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

import qualified Data.ByteString.Char8 as C
 
main = print . solve . map red . C.words =<< C.getContents
    where
        red x = case C.readInt x of Just v -> fst v

solve (n:x:a) = ans where
    sm = sum a
    ans = f n sm a x
    f 1 r _  _  = r
    f c r ar xx = f (c - 1) r2 ar2 (xx + x) where
        ar2 = zipWith min a . drop (n - 1) $ cycle ar 
        r2 = min r (xx + sum ar2)


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

int main(){
    
    int N;
    int pmax = 0;
    int sum = 0;
    int p;

    cin >> N;
    for(int i  = 0; i < N; i++){
        cin >> p;
        if(p > pmax) pmax = p;
        
        sum += p;
    }

    cout << sum - pmax/2 << endl;

}



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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e2 + 20;

struct ED{
	int to, re; ll fl;
	ED(int t, ll f, int r) : to(t), fl(f), re(r) {}
};
vector<ED> Ed[MAX_N];
void add(int fr, int to, ll fl) {
	Ed[fr].emplace_back(to,  fl, SZ(Ed[to]));
	Ed[to].emplace_back(fr, 0ll, SZ(Ed[fr])-1);
}

int N;
int Lv[MAX_N];
int St, En;
bool bfs() {
	for(int i=St; i<=En; i++) Lv[i] = -1;
	queue<int> Q; Q.push(St); Lv[St] = 0;
	while(!Q.empty()) {
		int v = Q.front(); Q.pop();
		for(ED &ed : Ed[v]) if(Lv[ed.to] == -1 && ed.fl > 0) Lv[ed.to] = Lv[v] + 1, Q.push(ed.to);
	}
	return Lv[En] != -1;
}
ll dfs(int v, ll minF) {
	if(v == En) return minF;
	for(int i=0; i<SZ(Ed[v]); i++) {
		ED &ed = Ed[v][i]; ll f;
		if(Lv[ed.to] == Lv[v] + 1 && ed.fl > 0 && (f = dfs(ed.to, min(minF, ed.fl))) > 0) {
			ed.fl -= f;
			Ed[ed.to][ed.re].fl += f;
			return f;
		}
	}
	return 0ll;
}
int main() {
	cin >> N;
	St = 0, En = N+1;
	ll posSum = 0;
	for(int i=1; i<=N; i++) {
		int x; scanf("%d", &x);
		if(x == 0) continue;
		if(x < 0) add(St, i, 1ll * -x); else add(i, En, 1ll * x), posSum += x;
	}
	for(int i=1; i<=N; i++) for(int j=i+i; j<=N; j+=i) add(i, j, LINF);

	ll flow = 0, f;
	while(bfs()) while((f = dfs(St, LINF)) > 0) flow += f;
	printf("%lld\n", posSum - flow);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  int MAX=0,cnt=0;
  for(int i=0;i<N;i++){
    if(i==N-1){chmax(MAX,cnt);}
    else if(H[i]>=H[i+1]){cnt++;}
    else {chmax(MAX,cnt);cnt=0;}
    //cout<<cnt<<endl;
  }
  cout<<MAX<<endl;
  return 0;  
}

Measured memory_bytes: 3664
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    mini = a[0]

    for i in range(1, n):
        if a[i] >= mini:
            mini = a[i]
        else:
            ans += mini-a[i]
    print(ans)
resolve()

Measured memory_bytes: 94252
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,ans;
int a[2005]; 
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	sort(a+1,a+n+1);
//	int d=unique(a+1,a+n+1)-a-1; 
	for(int i=1;i<=n;++i)
	for(int j=i+1;j<=n;++j)
	for(int k=j+1;k<=n;++k)
	if(a[i]+a[j]>a[k])ans++;
	else break;
//	if(ans==0) puts("No triangles can be formed."); 
	printf("%d\n",ans); 
	return 0;
} 

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n,a,b,c;
string s[100001];
vector<char> ans;

bool f(int i,int x,int y,int z) {
    if(i==n)return true;
    if(s[i]=="AB"){
        if(x==0&&y==0)return false;
        if(x>0&&f(i+1,x-1,y+1,z)){
            ans.eb('B');
            return true;
        }
        if(y>0&&f(i+1,x+1,y-1,z)){
            ans.eb('A');
            return true;
        }
        return false;
    }
    if(s[i]=="AC"){
        if(x==0&&z==0)return false;
        if(x>0&&f(i+1,x-1,y,z+1)){
            ans.eb('C');
            return true;
        }
        if(z>0&&f(i+1,x+1,y,z-1)){
            ans.eb('A');
            return true;
        }
        return false;
    }
    if(s[i]=="BC"){
        if(y==0&&z==0)return false;
        if(y>0&&f(i+1,x,y-1,z+1)){
            ans.eb('C');
            return true;
        }
        if(z>0&&f(i+1,x,y+1,z-1)){
            ans.eb('B');
            return true;
        }
        return false;
    }
}

void run(){
    cin>>n>>a>>b>>c;
    rep(i,n)cin>>s[i];
    f(0,a,b,c);
    if(ans.size()==0)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        rev(i,n)cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 13144
using System; using System.Text; using System.Collections.Generic; using System.Linq; using System.Collections; public class Remainder { static public void Main() { var N = int.Parse(Console.ReadLine()); var red = new long[N][]; for(int i = 0;i < N;i++){ var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); red[i] = AB; } Array.Sort(red, StructuralComparisons.StructuralComparer); 
var blue = new List<long[]>(); 
for(int i = 0;i < N;i++){ 
var CD = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
 
 blue.Add(CD);
  }
   blue = blue.OrderBy(a => a[1]).ThenBy(a => a[0]).ToList();
   var ans = 0;
   var bluep = 0; var flag = false; 
   for (int x = N-1; x >= 0; x--) {
        for(int y = 0;y <blue.Count();y++){
             if(red[x][0] < blue[y][0] && red[x][1] < blue[y][1]){ blue.RemoveAt(y); blue = blue.OrderBy(a => a[1]).ThenBy(a => a[0]).ToList();  ans++; break; } } } Console.WriteLine(ans); } public static void PrintValues( IEnumerable myList ) { foreach ( long[] obj in myList ) Console.Write(String.Join(",",obj)+" "); Console.WriteLine(); } } 


Measured memory_bytes: 13652
#include <stdio.h>

int main(void)
{
	int N;
	int i;
	int x[200], y[200];
	int n, d;
	int x_max, x_min;
	int y_max, y_min;
	
	while (1){
		scanf("%d", &N);
		if (N == 0){
			break;
		}
		
		x[0] = 0;
		y[0] = 0;
		
		for (i = 1; i < N; i++){
			scanf("%d%d", &n, &d);
			
		    x[i] = x[n];
		    y[i] = y[n];
			switch (d){
			  case 0:
			    x[i]--;
				break;
			
			  case 1:
			    y[i]++;
				break;

			  case 2:
			    x[i]++;
				break;
			
			  case 3:
			    y[i]--;
				break;
			}
		}

//		for (i = 0; i < N; i++){
//			printf("(%d=%d,%d)", i, x[i], y[i]);
//		}
		x_min = x_max = y_min = y_max = 0;
		for (i = 0; i < N; i++){
			if (x_min > x[i]){
				x_min = x[i];
			}
			if (x_max < x[i]){
				x_max = x[i];
			}
			if (y_min > y[i]){
				y_min = y[i];
			}
			if (y_max < y[i]){
				y_max = y[i];
			}
		}
		
		printf("%d %d\n", x_max - x_min + 1, y_max - y_min + 1);
	}
	return (0);
}

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

int main() {
  string w;
  cin >> w;

  sort(w.begin(), w.end());
  if (w.size() % 2 != 0) {
    cout << "No"
         << "\n";
    return (0);
  }
  else
  {
    for (int i = 0; i < w.size(); i+=2)
    {
      if (w[i] != w[i+1]) {
        cout << "No"
             << "\n";
        return (0);
      }
    }
  }

  cout << "Yes"
        << "\n";

  return (0);
}


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

string s;
int n,k,m;

int main(){
	cin>>n;
	cin>>s;
	cin>>k;
	for(int i = 0;i <= n ;i ++){
		if(s[i - 1] != s[k - 1]){
			s[i - 1] = '*';
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int min(int a, int b){
    return a<b?a:b;
}

int main(int argc, char** argv) {

    int size;
    scanf("%d",&size);
    
    int arr [size];
    int arr2 [size];
    
    if(size == 2){
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d", abs(a-b));
        return (EXIT_SUCCESS);
    }
    
    for (int i = 0; i < size; i++)
        scanf("%d", &arr[i]);
    
    arr2[0] = 0;
    arr2[1] = abs(arr[1] - arr[0]);
    
    for (int i = 2; i < size; i++)
        arr2[i] = min(arr2[i-1]+abs(arr[i]-arr[i-1]),arr2[i-2]+abs(arr[i]-arr[i-2]));
    
    printf("%d",arr2[size-1]);
    
    
    return (EXIT_SUCCESS);
}



Measured memory_bytes: 2436
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int N, a[20];

int rec(int n, int b, int c)
{
  if (n < 0) {
    return abs(b - c);
  }

  return min( rec(n - 1, b + a[n], c),
              rec(n - 1, b, c + a[n]));
}

int main()
{
  while (cin >> N && N) {
    
    // read
    for (int i = 0; i < N; i++) {
      cin >> a[i];
    }

    cout << rec(N - 1, 0, 0) << endl;
  }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> pic(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> pic.at(i).at(j);
		}
	}
	for (int i = 0; i < w + 2; i++) {
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << "#";
		for (int j = 0; j < w; j++) {
			cout << pic.at(i).at(j);
		}
		cout << "#" << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << "#";
	}
	cout << endl;
}

Measured memory_bytes: 256
/**
     **author : _KMS_
     **created : 30-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =3e5+10,MOD=1e9+7;
typedef long long ll;
vector<int>v[M];
bool vis[M];
int dp[M];
void dfs(int i)
{
  vis[i]=1;
  for(int j=0;j<v[i].size();j++)
  {
    int y=v[i][j];
    if(!vis[y])dfs(y);
    dp[i]=max(dp[i],dp[y]+1);
  }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
     int n,m;
     cin>>n>>m;
     for(int i=0;i<m;i++)
     {
       int x,y;
       cin>>x>>y;
       v[x].push_back(y);
     }
     for(int i=1;i<=n;i++)
     {
      if(!vis[i])
      {
        dfs(i);
      }
     }
    sort(dp+1,dp+n+1);
    cout<<dp[n]<<"\n";
    return 0;
}

Measured memory_bytes: 12928
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int i = 1;
	vector<int>a(10000);
	cin >> a[0];
	while (a[i-1] != 0) {
		cin >> a[i];
		i++;
	}
	for (i = 0; a[i] != NULL; i++)
		cout << "Case " << i+1 << ": " << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}




Measured memory_bytes: 2108
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100];

int solve() {
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        for (int j = -1; j <= 1; j++) {
            m[a[i]+j]++;
        }
    }

    int res = -1;
    for (auto v: m) {
        res = max(res, v.second);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
int main(void){
    int W, H, x, y, r, p, q;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    p=x+r;
    q=y+r;
   if(p<=W){
       if(q<=H){
           if(r<=x){
               if(r<=y){
                   printf("Yes\n");
               }
               else{
                   printf("No\n");
               }
           }
           else{
               printf("No\n");
           }
       }
       else{
           printf("No\n");
       }
   }
   else{
       printf("No\n");
   }
    return 0;
    
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
ll expo(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return res%mod;
}

int main() {
    fastio
	ll n,t,i,j,x,k;
    cin>>n;
    
    x=expo(10,n);
    x=(x-expo(9,n)+mod)%mod;
    x=(x-expo(9,n)+mod)%mod;
    x=(x+expo(8,n))%mod;
    
    cout<<x;
    
	return 0;
}

Measured memory_bytes: 3640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
typedef struct {
    ll idx;
    ll num;
    ll lv;
    ll rv;
} Q;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll P[100010];
    rep(i,0,N) cin >> P[i];
    vector<Q> v(100010);
    ll pos[100010] = {};
    rep(i,0,N){
        ll lv = -1, rv = -1;
        if(i != 0) lv = i-1;
        if(i != N-1) rv = i+1;
        v[i] = (Q){i, P[i], lv, rv};
        pos[P[i]] = i; 
    }
    ll ans = 0;
    rep(n,1,N){
        ll lv = -1, rv = -1;
        ll lv2 = -1, rv2 = -1;
        ll cur = pos[n];
        lv = v[cur].lv;
        rv = v[cur].rv;
        if(lv != -1){
            lv2 = v[lv].lv;
        }
        if(rv != -1){
            rv2 = v[rv].rv;
        }
        if(lv == -1 && rv != -1){
            ll left_val = cur+1;
            ll right_val = 0;
            if(rv2 != -1){
                right_val = rv2 - rv;
            }else{
                right_val = N - rv;
            }
            ans += n * left_val * right_val;
        }else if(lv != -1 && rv == -1){
            ll right_val = N - cur;
            ll left_val = 0;
            if(lv2 != -1){
                left_val = lv - lv2;
            }else{
                left_val = lv+1;
            }
            ans += n * left_val * right_val;
        }else{
            ll left_val = 0;
            if(lv2 != -1){
                left_val = lv - lv2;
            }else{
                left_val = lv+1;
            }
            ll right_ok = rv - cur;
            ans += n * left_val * right_ok;

            ll right_val = 0;
            if(rv2 != -1){
                right_val = rv2 - rv;
            }else{
                right_val = N - rv;
            }
            ll left_ok = cur - lv;
            ans += n * right_val * left_ok;
        }
        if(lv != -1){
            v[lv].rv = v[cur].rv;
        }
        if(rv != -1){
            v[rv].lv = v[cur].lv;
        }
    }
    print(ans);
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

long long H, W;
vector<vector<long long>> cost_map(1000+1, vector<long long>(1000+1, 0));

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N, a;
  cin >> N;
  int cnt_two = 0, cnt_four = 0, cnt_other = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    if(a%4 == 0) cnt_four++;
    else if(a%2 == 0) cnt_two++;
    else cnt_other++;
  }

  if(cnt_two == 0) {
    if(cnt_other <= cnt_four + 1) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    if(cnt_other <= cnt_four) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 11488
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			String a = scan.next();
			String b = scan.next();
			if(a.equals("0") && b.equals("0")){
				break;
			}else if(a.equals(b)){
				System.out.println(4 + " " + 0);
				continue;
			}
			int hit = 0;
			int blow = 0;
			for(int i = 0;i < a.length();i++){
				for(int j = 0;j < b.length();j++){
					if(a.charAt(i) == b.charAt(j)){
						if(i == j){
							hit += 1;
						}else{
							blow += 1;
						}
					}
				}
			}
			System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 43400
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD=1e9+7;
vector<int> vec;
vector<int> vec2;
const int INF=9e18;
int n,k,z=0,ans=1;
bool ok()
{
    if(vec.size()>=k)return 1;
    for(int i=0;i<=vec2.size();i+=2){
        if(k>=i&&k<=i+vec.size())return 1;
    }
    return 0;
}
int mod(int a,int b)
{
    a%=MOD;
    b%=MOD;
    return (a*b)%MOD;
}
main()
{
    cin>>n>>k;
    while(n--){
        int a;
        cin>>a;
        if(a==0)z=1;
        else if(a>0)vec.push_back(a);
        else{
            vec2.push_back(-a);
        }
    }
    sort(vec.begin(),vec.end());
    sort(vec2.begin(),vec2.end());
    if(ok()){
        if(k%2){
            k--;
            ans=mod(ans,vec.back());
            vec.pop_back();
        }
        int a=0,b=0;
        while(k>0){k-=2;
            if(!a&&vec.size()>=2){
                a=vec.back();
                vec.pop_back();
                a*=vec.back();
                vec.pop_back();
            }
            if(!b&&vec2.size()>=2){
                b=vec2.back();
                vec2.pop_back();
                b*=vec2.back();
                vec2.pop_back();
            }
            if(a>b){
                ans=mod(ans,a);
                a=0;
            }
            else{
                ans=mod(ans,b);
                b=0;
            }
        }
        cout<<ans<<endl;
    }
    else{
        if(z)cout<<0<<endl;
        else{
            for(int i=0;i<vec2.size();i++)vec.push_back(vec2[i]);
            sort(vec.begin(),vec.end());
            for(int i=0;i<k;i++)ans=mod(ans,vec[i]);
            ans*=-1;
            ans+=MOD;
            ans%=MOD;
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 5984
import re
a=input()
b=re.fullmatch(r"(\d{4})/(\d{2})/(\d{2})",a)
if int(b.group(1))<2019:
    print("Heisei")

elif int(b.group(1))==2019:
    if int(b.group(2))<=4:
        print("Heisei")

    else:
        print("TBD")

else:
    print("TBD")

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

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val K = input.nextInt()
    val p = IntArray(N)
    
    for (i in 0..N-1) {
      p[i] = input.nextInt()
    }
    
    Arrays.sort(p)
    
    var totalPrice = 0;
    for (i in 0..K-1) {
      totalPrice += p[i] 
    }
    
    println(totalPrice)
  }
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        int sum = 0;
        rep(i, 9) sum += in();
        printf("%d\n", n - sum);
    }
    return (0);
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main() {
	int n, x;
	cin >> n >> x;
	int m[n], count = n, min = x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		x -= m[i];
		if (min > m[i]) min = m[i];
	}
	cout << count + x / min << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

int k;
ll a[100005];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif 

    read(k);
    for(int i = 1; i <= k; ++i) read(a[i]);

    ll mn = 2, mx = 2;
    for(int i = k; i >= 1; --i) {

        mx = mx / a[i];
        mn = (mn + a[i] - 1) / a[i];

        mn = mn * a[i];
        mx = mx * a[i] + a[i] - 1;

        if(mn > mx) {
            return puts("-1"), 0;
        }
    }
    printf("%lld %lld\n", mn, mx);

    return 0;
}


Measured memory_bytes: 1024
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int64 tree[1000000];

int64 lmt=1000000;
void update(int64 idx,int64 val)
{
	while(idx<lmt)
	{
		tree[idx]+=val;
		idx+= (idx&(-idx));
	}
}

int64 ret(int64 idx)
{
	int64 ans=0;
	while(idx>0)
	{
		ans+=tree[idx];
		idx-=(idx&(-idx));
	}
	return ans;
}



int main()
{
	IOS;
	int64 T=1;
	//cin>>T;
	while(T--)
	{
		int64 n,i,d,a;
		cin>>n>>d>>a;
		VII64 v(n);
		map<int64,int64> mp;
		set<int64> st;
		int64 cnt=1;
		for(i=0;i<n;i++)
		{
			cin>>v[i].F>>v[i].S;
			st.insert(v[i].F);
			st.insert(v[i].F + 2*d +1);
		}
		for(auto x: st)
		{
			mp[x]=cnt++;
		}
		// for(auto x: mp)
		// 	cout<<x.F<<" "<<x.S<<endl;
		sort(ALL(v));
		int64 ans=0;
		for(i=0;i<n;i++)
		{
			
			int64 dam=ret(mp[v[i].F]);
			int64 val=v[i].S-dam*a;
			if(val>0)
			{
				double dd=val;
				int64 plus=ceil(dd/a);
				ans+=plus;
				update(mp[v[i].F],plus);
				update(mp[v[i].F+ 2*d + 1],-plus);
			}
		}
		cout<<ans;


	}

	return 0;
}

Measured memory_bytes: 53248