akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,q;
	cin>>a>>b>>q;
	vl s(a),t(b);
	cin>>s>>t;
	rep(i,q){
		ll x; cin>>x;
		int ls=upper_bound(all(s),x)-s.begin()-1;
		int lt=upper_bound(all(t),x)-t.begin()-1;
		int rs=lower_bound(all(s),x)-s.begin();
		int rt=lower_bound(all(t),x)-t.begin();
		ll ans=LINF;
		if(ls>=0 and lt>=0)chmin(ans,x-min(s[ls],t[lt]));
		if(rs<a  and rt<b )chmin(ans,max(s[rs],t[rt])-x);
		if(ls>=0 and rt<b )chmin(ans,min(x-s[ls],t[rt]-x)*2+max(x-s[ls],t[rt]-x));
		if(rs<a  and lt>=0)chmin(ans,min(x-t[lt],s[rs]-x)*2+max(x-t[lt],s[rs]-x));
		puta(ans);
	}
	return 0;
}

Measured memory_bytes: 2944
package main

import (
	"fmt"
)

func main() {
	if Check() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func Check() bool {
	var A int
	var B int
	var S string

	fmt.Scanf("%d %d", &A, &B)
	fmt.Scanf("%s", &S)

	if len(S) != A+B+1 {
		return false
	}

	if S[A] != '-' {
		return false
	}

	for i := 0; i < A+B+1; i++ {
		if i == A {
			continue
		}
		if !IsNum(S[i]) {
			return false
		}
	}

	return true
}

func IsNum(c byte) bool {
	return '0' <= c && c <= '9'
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

typedef struct{
	double x;
	double y;
}vec;
vec make_vec(vec dir,double length){
	double dir_l=sqrt(dir.x*dir.x+dir.y*dir.y);
	dir.x *= length/dir_l;
	dir.y *= length/dir_l;
	return dir;
}
double inner_product(vec a,vec b){
	return a.x*b.x+a.y*b.y;
}


int main(){
	vec p1,p2,p,x;
	ll Q;
	cin >> p1.x >> p1.y >> p2.x >> p2.y >> Q;
	p2.x-=p1.x;
	p2.y-=p1.y;
	FOR(q,0,Q){
		cin >> p.x >> p.y;
		p.x-=p1.x;
		p.y-=p1.y;
		x = make_vec(p2,inner_product(p2,p)/sqrt(p2.x*p2.x+p2.y*p2.y));
		x.x = -2*p.x+2*x.x;
		x.y = -2*p.y+2*x.y;
		cout << fixed;
		cout << setprecision(10) << x.x+p1.x+p.x << " " << x.y+p1.y+p.y << endl;
	}

}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
const ll INF = 1000000007;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int gcd(ll a,ll b){return __gcd(a,b);}

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
		int n;cin>>n;
		int a=n%10;
		if(a==2 || a==4 || a==5 || a==7 || a==9)cout<<"hon";
		else if(a==0 || a==1 || a==6 || a==8)cout<<"pon";
		else cout<<"bon";
	}
	//cout<< "Done in " <<fixed<<setprecision(15)<<(double)clock()/7.33e8<<"sec"<< endl;
    return 0;
}


Measured memory_bytes: 3640
N = gets.to_i
button = gets(p).split.map(&:to_i)
push = Array.new(N, false)

ans = 0
nextb = 1

while true
	if nextb == 2
	  print ans
	  exit
	elsif push[nextb-1] == false
	  push[nextb-1] = true
	  nextb = button[nextb-1]
	  ans += 1
	else
	  print -1
	  exit
	end
end


Measured memory_bytes: 8836
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

char ToLower(char c){
	return tolower(c);
}

void tolower(string &s){
	transform(s.begin(), s.end(), s.begin(), ToLower);
}

int main(int argc, char *argv[]){
	string W;
	string Ti;
	getline(cin, W);
	tolower(W);
	int count = 0;
	while(1){
		cin >> Ti;
		if(Ti == "END_OF_TEXT")break;
		tolower(Ti);
		if(Ti == W)count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int main(){
   ll k,n;
   cin>>k;
   n=7%k;
   for(ll i=1;i<=10000000;i++){
      if(n==0){
         cout<<i;
         return 0;
      }
      n=(n*10LL+7LL)%k;
   }
   cout<<-1;
   return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
struct node{
	string s;
	int num;
	int ans;
}; 
int cmp(node x,node y){
	if(x.s!=y.s)return x.s<y.s;
	else return x.num>y.num;
}
int main()
{	node a[10001];
	int n;
	cin>> n;
	for(int i=1;i<=n;i++){
		cin>>a[i].s>>a[i].num;
		a[i].ans=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		cout<<a[i].ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#define ll long long
#define rev(a) reverse(a+1,a+n+1)
using namespace std;
const int N=3e5+5,inf=1e9;
int n,i,a[N];
ll s[N],g[N],l[N],r[N],f[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void write(ll x){if (x>9) write(x/10);putchar(x%10+48);}
ll sum(int n){return (ll)n*(n+1)/2;}
int t,q[N];
double cal(int x,int y){return (double)(g[x]-g[y])/(x-y);}
void pop(int x){for (;t>1&&cal(q[t-1],q[t])<=x;t--);}
void push(int x){
	for (;t>1&&cal(q[t-1],q[t])<=cal(q[t],x);t--);q[++t]=x;
}
void init_s(){for (int i=1;i<=n;i++) s[i]=s[i-1]+a[i];}
void init(ll *f){
	int i;q[t=1]=0;init_s();
	for (i=1;i<=n;i++){
		pop(i);f[i]=max(f[i-1],f[q[t]]+sum(i-q[t])-s[i]+s[q[t]]);
		g[i]=f[i]+sum(i-1)+s[i];push(i);
	}
}
ll w[N];
void work(int x,int y){
	if (x==y) return;int i,m=x+y>>1;t=0;
	for (i=x;i<=m;i++) g[i]=l[i]+sum(i-1)+s[i],push(i);
	for (;i<=y;i++) pop(i),
		w[i]=l[q[t]]+r[i+1]+sum(i-q[t])-s[i]+s[q[t]];
	for (f[y]=max(f[y],w[y]),i=y-1;i>m;i--)
		f[i]=max(f[i],w[i]=max(w[i],w[i+1]));
	work(x,m);work(m+1,y);
}
int main(){
	for (n=read(),i=1;i<=n;i++) a[i]=read(),f[i]=-inf;
	init(l);rev(a);init(r);rev(a);rev(r);
	init_s();work(0,n);rev(a);rev(f);rev(l);rev(r);swap(l,r);
	init_s();work(0,n);rev(a);rev(f);rev(l);rev(r);swap(l,r);
	for (i=read();i--;putchar('\n')){
		int x=read(),k=read();
		write(max(l[x-1]+r[x+1],f[x]+a[x]-k));
	}	
}

Measured memory_bytes: 18944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	cout<<(n-1)/2<<endl;
}

Measured memory_bytes: 256
<?php

$num = (int)trim(fgets(STDIN));

$redList = [];
$redSumList = [];
for ($i = 0; $i < $num; $i++)
{
    list($x, $y) = explode(' ', trim(fgets(STDIN)));
    $x = (int)$x;
    $y = (int)$y;
    $redList[] = [$x, $y];
    $redSumList[$i] = $x + $y;
}
// arsort($redSumList);

$blueList = [];
for ($i = 0; $i < $num; $i++)
{
    list($x, $y) = explode(' ', trim(fgets(STDIN)));
    $x = (int)$x;
    $y = (int)$y;
    $blueList[] = [$x, $y];
    $blueSumList[$i] = $x + $y;
}
// arsort($blueSumList);
$sort = [];
foreach ($blueList as $key => $value)
{
    $sort[$key] = $value[0];
}
array_multisort($sort, SORT_ASC, $blueList);

$result = 0;
foreach ($blueList as $blueKey => $blueValue)
{
    $tmp = -1;
    $popKey = -1;

    foreach ($redList as $redKey => $redValue)
    {
        if ($redList[$redKey][0] < $blueList[$blueKey][0] && $redList[$redKey][1] < $blueList[$blueKey][1])
        {
            if ($redValue[1] > $tmp)
            {
                $tmp = $redValue[1];
                $popKey = $redKey;
            }
        }
    }

    if ($tmp >= 0)
    {
        unset($redList[$popKey]);
        $result++;
    }
}

echo $result.PHP_EOL;


Measured memory_bytes: 4604
import math
def is_prime(x):
    if x == 1 or x == 2:
        return True

    for idx in range(2, int(math.sqrt(x))+1):
        if x % idx == 0:
            return False

    return True

def main():
    n = int(input())
    cnt = 0
    for _ in range(n):
        if is_prime(int(input())):
            cnt += 1

    print(cnt)

main()


Measured memory_bytes: 5680
# -*- coding:utf-8 -*-

def solve():
    N, M = map(int, input().split())
    As = list(map(int, input().split()))

    total = sum(As)

    cnt = 0
    for a in As:
        if a >= total/(4*M):
            cnt += 1

    if cnt >= M:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int k; 
  int m;
  long int ans= 0;
 
  scanf("%d",&k);
  
  for(int c = 1;c<=k;c++){    
    for(int b = 1;b<=k;b++){
      for(int a = 1;a<=k;a++){
         int l=0;
        
        if(a<=b && a<=c){
         m = a;
        }
        if(b<=a && b<=c){
          m=b;
        }
        if(c<=a && c<=b){
          m=c;
        }
        
        for(int i=1;i<=m;i++){
          if(a%i==0 && b%i==0){
            if(c%i==0){
            l=i;
            }
          }
        }
        ans+=l;
      }
    }
  }
  printf("%ld",ans);
  return 0;
}
    
    
  

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
int a[N];

int solve (int l, int r) {
	int x = *min_element(a + l, a + r + 1);
	int res = x;
	for (int i = l; i <= r; i ++) a[i] -= x;
	for (int i = l; i <= r; i ++) {
		if (a[i] == 0) continue;
		int j = i;
		while (j + 1 <= r && a[j + 1] != 0) j ++;
		res += solve(i, j);
		i = j;
	}
//	cout << "Solve " << res << '\n';

	return res;
}

int main () {               
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    }
    cout << solve(1, n);
    return Accepted;
}

// Coded By OB

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

int main(){

    int N;
    cin >> N;

    vector<int> d(N);
    rep(i, N)cin >> d[i];
    d.push_back(0);
    sort(all(d));

    vector<int> cnt(24, 0);
    int now = 1;
    rep(i, N + 1){
        if(d[i] == 0 or d[i] == 12)cnt[d[i]]++;
        else {
            if(now == 1)cnt[d[i]]++;
            else cnt[24 - d[i]]++;
            now = 1 - now;
        }
    }

    int ans = 24;
    vector<int> tmp;
    rep(i, 24)rep(j, cnt[i])tmp.push_back(i);
    rep(i, N)chmin(ans, tmp[i + 1] - tmp[i]);
    cout << ans << endl;
    return 0;

}

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, S: str):
    ret = 0
    for i in range(N):
        if S[i:i + 3] == 'ABC':
            ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,s) for(int i=s;i>=0;i--)

using ll = long long;
using namespace std;

const ll INF = 1010101010;
const ll MOD = 1000000007;

int main() {
	ll n, m, ans = 0, A[10101];
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <map>

typedef long long LL;
const int MN = 20;

int N, A[MN];

LL F(int l, int r, int cl, int cr) {
	if (l > r) return 0;
	LL ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = l; i <= r; ++i)
		ans = std::min(ans, F(l, i - 1, cl, cl + cr) + (LL)A[i] * (cl + cr) + F(i + 1, r, cl + cr, cr));
	return ans;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	N -= 2;
	printf("%lld\n", F(1, N, 1, 1) + A[0] + A[N + 1]);
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]  # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)

    def find(self, x):  # xを含む木における根の頂点番号を返す
        if self.v[x] < 0:  # (負)は根
            return x
        else:  # 根の頂点番号
            self.v[x] = self.find(self.v[x])  # uniteでは, 旧根に属する頂点の根が旧根のままなので更新
            return self.v[x]

    def unite(self, x, y):  # 違う根に属していたらrankが低くなるように連結
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:  # size比較, 　(-1) * (連結頂点数 * (-1)), (正)同士の大小比較
            x, y = y, x  # 連結頂点数が少ない方をyにすると, findでの更新回数が減る？
        self.v[x] += self.v[y]  # 連結頂点数の和を取る, 連結頂点数 * (-1)
        self.v[y] = x  # 連結頂点数が少ないy(引数yの根の頂点番号)の根をx(引数xの根の頂点番号)にする

    def root(self, x):
        return self.v[x] < 0  # (負)は根

    def same(self, x, y):
        return self.find(x) == self.find(y)  # 同じ根に属するか

    def size(self, x):
        return -self.v[self.find(x)]  # 連結頂点数を返す


import sys

input = sys.stdin.readline

H, W = map(int, input().split())
s = tuple(input() for _ in range(H))

uf_r = UnionFind(H * W)
for r in range(H - 1):
    for c in range(W):
        if s[r][c] == '.' and s[r + 1][c] == '.':
            uf_r.unite(r * W + c, (r + 1) * W + c)

uf_c = UnionFind(H * W)
for c in range(W - 1):
    for r in range(H):
        if s[r][c] == '.' and s[r][c + 1] == '.':
            uf_c.unite(r * W + c, r * W + (c + 1))

ans = 0
for r in range(H):
    for c in range(W):
        if s[r][c] == '#': continue
        t = uf_r.size(r * W + c) + uf_c.size(r * W + c) - 1
        ans = max(ans, t)
print(ans)


Measured memory_bytes: 209096
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int n;
  cin >> n;
  int ans = 0;
  vi v(n);
  vi c(n);
  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];
  rep(i,n) ans += max(0, v.at(i) - c.at(i));
  cout << ans << endl;
}


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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    double ti=d/(double)s;
    if(ti<=t)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=200005,M=2000005,INF=0X3F3F3F3F;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
int n,S,T;
int fa[N],match[N],ans[N][2];
int dep[N],gap[N];
int pp=1,lnk[N],cur[N],nxt[M],to[M],we[M];
void ae(int k1,int k2,int k3){
	to[++pp]=k2,we[pp]=k3,nxt[pp]=lnk[k1],lnk[k1]=pp;
	to[++pp]=k1,we[pp]=0, nxt[pp]=lnk[k2],lnk[k2]=pp;
}
bool bfs(){
	memset(dep,-1,sizeof(dep));
	queue<int>q;
	q.push(S);
	dep[S]=0;
	while(!q.empty()){
		int k1=q.front();
		q.pop();
		for(int i=lnk[k1];i;i=nxt[i])if(we[i]&&dep[to[i]]==-1){
			dep[to[i]]=dep[k1]+1;
			q.push(to[i]);
		}
	}
	return dep[T]!=-1;
}
int dfs(int k1,int k2){
	if(k1==T)return k2;
	int k3=k2;
	for(int&i=cur[k1];i;i=nxt[i])if(we[i]&&dep[to[i]]==dep[k1]+1){
		int f=dfs(to[i],min(we[i],k2));
		k3-=f,we[i]-=f,we[i^1]+=f;
		if(!k3)return k2;
	}
	cur[k1]=lnk[k1];
	return k2-k3;
}
int main(){
	rd(n);
	S=n+n,T=n+n+1;
	rep(i,2,n)ae(S,i,1);
	rep(i,1,n-1){
		int m;
		rd(m);
		rep(j,1,m){
			int k1;
			rd(k1);
			ae(k1,i+n,1);
		}
	}
	rep(i,1,n-1)ae(i+n,T,1);
	int res=0;
	while(bfs()){
		memcpy(cur,lnk,sizeof(cur));
		res+=dfs(S,INF);
	}
	if(res!=n-1){
		puts("-1");
		return 0;
	}
	rep(i,1,n-1){
		for(int j=lnk[i+n];j;j=nxt[j])if(to[j]!=T&&we[j]==1){
			match[i]=to[j];
		}
		assert(match[i]);
	}
	queue<int>q;
	q.push(1),fa[1]=1;
	while(!q.empty()){
		int k1=q.front();
		q.pop();
		for(int i=lnk[k1];i;i=nxt[i]){
			int k2=match[to[i]-n];
			if(!fa[k2]){
				ans[to[i]-n][0]=k1,ans[to[i]-n][1]=k2;
				fa[k2]=k1;
				q.push(k2);
			}
		}
	}
	rep(i,1,n-1){
		printf("%d %d\n",ans[i][0],ans[i][1]);
	}
	return 0;
}

Measured memory_bytes: 24756
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	a := make([]int, n+1)
	b := make([]int, n)
	for i := 0; i < n+1; i++ {
		a[i] = iScan()
	}
	for i := 0; i < n; i++ {
		b[i] = iScan()
	}
	ans := 0
	for i := 0; i < n; i++ {
		if b[i] >= a[i]+a[i+1] {
			ans += a[i] + a[i+1]
			a[i+1] = 0
		} else if b[i] < a[i]+a[i+1] && a[i] <= b[i] {
			ans += b[i]
			a[i+1] = a[i+1] + a[i] - b[i]
		} else {
			ans += b[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5852
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

vector<int> V;
int main() {
	V.resize(3);
	cin >> V[0] >> V[1] >> V[2];
	sort(V.begin(), V.end(), [](int a, int b) {
		return a < b;
	});
	if (V[0] == 5 && V[1] == 5 && V[2] == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b+c <= 21) cout << "win" << endl;
	else cout << "bust" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main()
{
    int n, x, count = 0;
    int i, j;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &x);
        if (x == 2) count++;
        else if (x % 2){
            for (j = 3; j <= sqrt(x); j += 2){
                if (x % j == 0) break;
            }
            if (j > sqrt(x)) count++;
        }
    }
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 596
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

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

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
int W;
ll w , val;
ll dp[maxn];

int32_t main(){
    migmig
    cin >> n >> W;
    for(int i = 1 ; i <= W ; i ++)
        dp[i] = -1e18;
    while(n --){
        cin >> w >> val;
        for(int i = W ; i >= w ; i --){
            dp[i] = max(dp[i] , val + dp[i - w]);
        }
    }
    cout << *max_element(dp , dp + W + 1);
    return(0);
}

Measured memory_bytes: 4392
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

LL n,k;
vector<LL> a;

bool solve(LL y){
    vector<vector<bool>> dp(n+1,vector<bool>(k,false));
    dp[0][0] = true;
    for(int i = 1; i < n+1; i++){
        if(i == y+1){
            for(int j = 0; j < k; j++){
                dp[i][j] = dp[i-1][j];
            }
        }else{
            for(int j = 0; j < k; j++){
                dp[i][j] = dp[i-1][j];
                if(j - a[i-1] >= 0 && dp[i-1][j-a[i-1]]){
                    dp[i][j] = true;
                }
            }
        }
    }
    LL ind = 0;
    for(int i = k-1; i >= 0; i--){
        if(dp[n][i]){
            ind = i;
            break;
        }
    }
    return (ind+a[y] >= k);
}

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

    cin >> n >> k;

    for(int i = 0; i < n; i++){
        LL x;
        cin >> x;
        a.push_back(x);
    }

    sort(a.begin(),a.end());

    LL ng = -1;
    LL ok = n;
    while(abs(ok-ng) > 1){
        LL middle = (ok+ng)/2;
        bool t = solve(middle);
        if(t){
            ok = middle;
        }else{
            ng = middle;
        }
    }

    cout << ng + 1 << endl;

    return 0;
}

Measured memory_bytes: 3692
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        double[] inpt = Reader.ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();

        double ans = Math.Sqrt(Math.Pow(inpt[0] - inpt[2], 2) + Math.Pow(inpt[1] - inpt[3], 2));
        Console.WriteLine(ans.ToString("#0.0#############"));
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"






1.123 0.0 1.123 100.0


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9808
#include <stdio.h>
int main(void){
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
        min=a;
        if(max<a)
        max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int sum = a * b;
	if (sum % 2 == 0) {
		cout << "Even" << endl;
	} else if (sum % 2 == 1) {
		cout << "Odd" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int rest = h*w - n;
    int ans = 3330;
    rep(i,h+1){
        rep(j,w+1){
            if(i*j <= h*w - n){
                ans = min(ans,h+w-i-j);
            }
        }
    }
    cout << ans << endl;
}


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

#define ll long

using namespace std;

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

    ll result = 0;
    vector<ll> v(n);
    ll maxDiff = -1;

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

    for(int i = 1; i < n - 1; i++){
        ll diff = v[i + 1] - v[i];
        maxDiff = max(diff, maxDiff);
    }

    ll diff = k - v[n - 1] + v[0];
    maxDiff = max(diff, maxDiff);
    result = k - maxDiff;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> imos(100010, 0);
    for(int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        imos[l]++;
        imos[r + 1]--;
    }
    for(int i = 1; i < 100010; i++) {
        imos[i] += imos[i - 1];
    }
    for(int i = 1; i < 100010; i++) {
        imos[i] += imos[i - 1];
    }
    cout << imos[100000] << endl;
}

Measured memory_bytes: 3724
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="ABC"){
    printf("ARC\n");
  }
  else{
    printf("ABC\n");
  }
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
  int d[6];
  int temp;
  char c[100];
  for(int i = 0; i < 6; i++)
    {
      scanf("%d", &d[i]);
    }
  scanf("%s", c);
  for(int i = 0; c[i] !='\0'; i++)
    {
      temp = d[0];
      if(c[i] == 'E')
	{
	  d[0] = d[3];
	  d[3] = d[5];
	  d[5] = d[2];
	  d[2] = temp;
	}
      if(c[i] == 'W')
	{
	  d[0] = d[2];
	  d[2] = d[5];
	  d[5] = d[3];
	  d[3] = temp;
	}
      if(c[i] == 'S')
	{
	  d[0] = d[4];
	  d[4] = d[5];
	  d[5] = d[1];
	  d[1] = temp;
	} 
      if(c[i] == 'N')
	{
	  d[0] = d[1];
	  d[1] = d[5];
	  d[5] = d[4];
	  d[4] = temp;
	}
    }
  printf("%d\n", d[0]);
}



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

ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            a = [A[i], A[j], A[k]]
            a = sorted(a)
            if A[i] == A[j] or A[j] == A[k] or A[i] == A[k]:
                continue
            if a[0] + a[1] > a[2]:
                ans += 1
print(ans)


Measured memory_bytes: 9188
#include <cstdio>
#include <vector>
using namespace std;
const int NM = 1e5 + 5;
int n, m, deg[NM], c4, stk[NM], tp, cnt;
vector<int> G[NM];
bool vis[NM];
void DFS(int u) {
	vis[u] = 1, ++cnt;
	for (int v : G[u]) if (!vis[v]) DFS(v);
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
		++deg[u];
		++deg[v];
	}
	for (int i = 1; i <= n; ++i) {
		if (deg[i] & 1) {
			printf("No\n");
			return 0;
		}
		if (deg[i] == 4)
			stk[++c4] = i;
	}
	for (int i = 1; i <= n; ++i) {
		if (deg[i] >= 6) {
			printf("Yes\n");
			return 0;
		}
	}
	if (c4 >= 3) {
		printf("Yes\n");
		return 0;
	} else if (c4 == 2) {
		vis[stk[2]] = 1;
		DFS(stk[1]);
		if (cnt == n - 1)
			printf("No\n");
		else printf("Yes\n");
	} else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 9768
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int a[100005],a1,a2,a3;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0) a[i]=1,a3++; else if(a[i]%2==0)a[i]=0,a2++;
		else a[i]=2,a1++;
	}
//	cout<<a1<<a2<<a3;
	a3-=a1;
	a3-=(a2%2);
	if(a3<-1) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int s,w;
    cin >> s >> w;
    if(w >= s)cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;



struct st{
	int num;
	int cnt;
	
	st(int num, int cnt) : num(num), cnt(cnt) {}
	bool operator<(const st &s)const{
		return (*this).cnt == s.cnt ? (*this).num > s.num : (*this).cnt < s.cnt;
	}
};

bool solve(){
	
	int n, q;
	cin>> n>> q;
	if(!(n|q)) return false;

	int M = 110;
	vector<st> day;
	for(int i=0;i<M;i++){
		day.push_back(st(i+1,0));
	}
	for(int i=0;i<n;i++){
		int m;
		cin>> m;
		for(int j=0;j<m;j++){
			int in;
			cin>> in;
			day[in-1].cnt++;
		}
	}
	sort(day.rbegin(), day.rend());
	
	if(day[0].cnt >= q){
		cout<< day[0].num<< endl;
	}else{
		cout<< 0<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1200
import math
M = 104729
lst = list(range(M+1))

for i in range(0, M+1, 2):
    lst[i] = 0

lst[1] = 0
lst[2] = 2

for i in range(3, math.ceil(math.sqrt(M+1)), 2):
    if lst[i]:
        for j in range(i**2, M+1, i):
            lst[j] = 0

anslst = [i for i in lst if i != 0]

while True:
    n = int(input())
    if n == 0 :
        break

    print(sum(anslst[:n]))


Measured memory_bytes: 9740
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 2000000
#define INF 1<<21
void insert(int);
int H,A[MAX+1];
void maxHeapify(int);
void heapIncreasekey(int, int);
int main(void)
{
	int key;
	char com[20];
	
	while(1){
		scanf("%s",com);
		if(com[0]== 'e' && com[1] == 'n'){
			break;
		}
		if(com[0] == 'e' && com[1] == 'x'){
			
			printf("%d\n",extract());
		}
		if(com[0] == 'i'){
			scanf("%d",&key);
			insert(key);
		}
		
	}
	return 0;
}

void insert(int key){
	H++;
	A[H]=-INF;
	heapIncreasekey(H, key);//A[H]にkeyを設定する
}

void heapIncreasekey(int i,int key){
	if(key < A[i]){
		return;
	}
	A[i] = key;
	int tmp;
	while(i>1 && A[i/2]<A[i]){
		tmp = A[i/2];
		A[i/2] = A[i];
		A[i] = tmp;
		i= i/2;
	}
}
int extract(){
	int maxkey;
	if( H< 1 ) return -INF;
	maxkey = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxkey;
}
void maxHeapify(int i){
	  int tmp;
    int max;
    if(i*2<H+1 && A[i] < A[i*2]){
        max = i*2;
        //printf("left is largest\n");
    }
     
    else {
        max = i;
    //  printf("i is largest\n");
    }
    if(i*2+1 < H+1 && A[max] < A[i*2+1]){
        max = i*2+1;
    //  printf("right is largest\n");
    }
     
    if(max != i ){
        tmp  = A[max];
        A[max] = A[i];
        A[i] = tmp; 
        maxHeapify(max);
    }
}




Measured memory_bytes: 5628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;
const int mod=1e9+7;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline void gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline void gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc());
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;

const int N=610;
int id[N][N];
VI e[N*N];
PR st[N*N];
vector<PR>v;
int n,top;
int col[N*N];
int siz[3];
void work() {
	int d;gi(d);
	for (int i=-sqrt(d);i*i<=d;i++) {
		int j=sqrt(d-i*i);
		if (i*i+j*j==d)
			v.pb(mp(i,j));
	}
}
void dfs(int k,int t) {
	if (col[k]) return;
	col[k]=t;++siz[t];
	for (int x:e[k])
		dfs(x,3-t);
}
void solve() {
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			id[i][j]=-1;
	for (int i=0;i<top;i++)
		id[st[i].fi][st[i].se]=i,e[i].clear(),col[i]=0;
	v.clear();
	work();
	for (int i=0;i<top;i++)
		for (PR &t:v) {
			int x=st[i].fi+t.fi;
			int y=st[i].se+t.se;
			if (x>=0&&x<n&&y>=0&&y<n&&id[x][y]!=-1)
				e[i].pb(id[x][y]),e[id[x][y]].pb(i);
		}
	siz[1]=siz[2]=0;
	for (int i=0;i<top;i++)
		if (!col[i])
			dfs(i,1);
	int to=siz[1]>siz[2]?1:2;
	int all=top;top=0;
	for (int i=0;i<all;i++)
		if (col[i]==to)
			st[top++]=st[i];
}
int main()
{
	int i,j;
	gi(n);n<<=1;
	for (i=0;i<n;i++)
		for (j=0;j<n;j++)
			st[top++]=mp(i,j);
	solve();
	solve();
	for (int i=0;i<n*n/4;i++)
		print(st[i].fi),putc(' '),print(st[i].se),putc('\n');
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n, x;
  	cin >> n >> x;
	vi l(n);
  	rep(i,n) cin >> l[i];
	int d = 0;
  	int cnt = 1;
  	rep(i,n) {
      	d += l[i];
    	if(d>x) {
        	break;
        }else{
        	cnt++;
        }
    }
  
  	cout << cnt << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string a,b,c;
    cin >> a >> b >> c;
    cout << (a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)?"YES":"NO") << endl;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;

	cout << (a*b*c)/(2*max(a,max(b,c)));

	return 0;
}


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

using namespace std;

struct Card {
    char suit, value;
};

void bubble(Card a[], int n) {
    for (int i = 0; i < n-1; ++i) {
        for (int j = n-1; j >= i+1; --j) {
            if (a[j].value < a[j-1].value) {
                Card t = a[j]; a[j] = a[j-1]; a[j-1] = t;
            }
        }
    }
}

void selection(Card a[], int n) {
    for (int i = 0; i < n-1; ++i) {
        int min_j = i;
        for (int j = i+1; j < n; ++j) {
            if (a[j].value < a[min_j].value) min_j = j;
        }
        if (min_j != i) { Card t = a[i]; a[i] = a[min_j]; a[min_j] = t; }
    }
}

void print(Card a[], int n) {
    for (int i = 0; i < n; ++i) {
       if (i) cout << " ";
       cout << a[i].suit << a[i].value;
    }
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    Card a[40], b[40];
    for (int i = 0; i < N; ++i) {
        cin >> a[i].suit >> a[i].value;
    }
    for (int i = 0; i < N; ++i) b[i] = a[i];
    bubble(a, N);
    print(a, N);
    cout << "Stable" << endl;
    selection(b, N);
    print(b, N);
    bool stable = true;
    for (int i = 0; i < N; ++i)
        if (a[i].suit != b[i].suit) stable = false;
    if (stable) cout << "Stable";
    else cout << "Not stable";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;

  ull ans{};
  for(ui k = 1; k <= N; k += 2)
  {
    ull res{};
    for(ui i = 1; i <= k; ++i)
    {
      if(k % i == 0) ++res;
    }
    if(res == 8) ++ans;
  }

  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
int dp[102][5][2];
int n,k;
vector<int> v;

int solve(int id , int tot , int ok)
{
	if(tot > k) return 0;
	if(id == n) return (tot == k);
	
	int ans = dp[id][tot][ok];
	if(ans != -1)
		return ans;
		
	ans = 0;
	int l = 0;
	int r = 9;
	
	if(ok) r = v[id];
	
	for(int i=l ; i<=r ; i++)
	{
		if(ok && i == v[id])
		{
			ans += solve(id + 1 , tot + (i != 0) , 1);
		}
		else
			ans += solve(id + 1 , tot + (i != 0) , 0);
	}

	dp[id][tot][ok] = ans;
	return ans;
}
int32_t main(){
	fast;
	memset(dp , -1 , sizeof(dp));
	
	string s;
	cin >> s;
	
	 n = s.length();
	v.resize(n);
	
	f(i,0,n)    v[i] = s[i] - '0';
	
	cin >> k;
	
	cout << solve(0,0,1);
}



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 A[100010];
ll S[100010];

void Main()
{
	int N, M; cin >> N >> M;
	rep(i,N) cin >> A[i];
	S[0] = 0;
	map<int, ll> mp;
	mp[0] = 1;
	rep(i,N) {
		S[i + 1] = S[i] + A[i];
		mp[S[i + 1] % M]++;
	}
	ll res = 0;
	for (auto p : mp) {
		res += (p.second * (p.second - 1)) / 2;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;
typedef long long ll;
const int maxn=1e9+5;
const int inf=0x3f3f3f3f;
int dp[3005][3005];

int main()
{
	ios::sync_with_stdio(false);
	string a,b;
	while(cin>>a>>b){
		int n=a.length(),m=b.length();
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(a[i-1]==b[j-1]){
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		string ans;
		int row=n,col=m;
		while(row&&col){
			if(dp[row][col]==dp[row-1][col]){
				row--;
				continue;
			}
			if(dp[row][col]==dp[row][col-1]){
				col--;
				continue;
			}
			if(dp[row][col]==dp[row-1][col-1]+1){
				ans+=a[row-1];
				row--,col--;
			}
		}
		reverse(ans.begin(),ans.end());
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 35584