akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int dp[100001][2];

int counterpart(int p){
    return abs(1 - p);
}

int get_winner(int k, int p, int* a, int n){
    if(dp[k][p] != -1){
        return dp[k][p];
    }
    int winner = counterpart(p);
    rep(i, 0, n){
        if(k==a[i]){ winner = p; }
        else if(k - a[i] > 0){
            if(get_winner(k-a[i], counterpart(p), a, n) == p){
                winner = p;
            }
        }
    }
    dp[k][p] = winner;
    return dp[k][p];
}

int main(){
    int N, K;
    cin >> N >> K;
    int a[101];
    rep(i, 0, N){ cin >> a[i]; }

    rep(i, 0, K+1){
        rep(p, 0, 2){
            dp[i][p] = -1;
        }
    }

    string ans = "First";
    if(get_winner(K, 0, a, N) == 1){ ans = "Second"; }
    cout << ans;
    return 0;
}




Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(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==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);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll N;
	cin >> N;
	array<ll,100001> H;
	FOR(i,0,N)cin >> H[i];
	bool ok = true;

	H[0]--;
	FOR(i,1,N){
		if(H[i-1]<H[i]){
			H[i]--;
		}
		if(H[i-1]>H[i])ok=false;
	}
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdint>
#include<cassert>
using namespace std;

typedef int64_t i64;typedef int32_t i32;
typedef int16_t i16;typedef int8_t i8;
typedef uint64_t ui64;typedef uint32_t ui32;
typedef uint16_t ui16;typedef uint8_t ui8;

typedef i32 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define repeat_eq(i,j,k) for(int__ i=(j);i<=(k);i++)
#define all(v) begin(v),end(v)

const i32 INF=1<<30;//=10E10

vector< vector<i32> > M;
i32 w,h;

void dfs(int y,int x,int id){
  int dx[]={1,0,-1,0,1,-1,1,-1};
  int dy[]={0,1,0,-1,1,1,-1,-1};
  M[y][x]=id;
  rep(i,8){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(0<=nx && nx<w and 0<=ny && ny<h){
	if(M[ny][nx]==1)dfs(ny,nx,id);
      }
  }
}

int main()
{
  while(true){
  
    cin>>w>>h;
    if(!w and !h)break;
    M.clear();
    M.resize(h,vector<i32>(w));
    rep(i,h){
      rep(j,w){
	cin>>M[i][j];
      }
    }
    
    int ans=0;
    rep(i,h)rep(j,w){
      if(M[i][j]==1){
	dfs(i,j,ans++ +2);
      }
    }
    
    cout<<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1484
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
enum{MaxStack = 300};//#define MaxStack = 300;

typedef struct{
    int top;
    int st[MaxStack];
}stack;

stack* init_stack(){
    stack* sp = (stack*) malloc(sizeof(stack));
    sp -> top = -1;
    return sp;
}

int empty(stack *s){
    return (s -> top == -1);
}

void push(stack *s, int n){
    if(s->top == MaxStack - 1){
        printf("Stack Overflow\n");
        exit(1);
    }
    (s->top)++;
    s -> st[s->top] = n;
}

int pop(stack* s){
    if(empty(s)) return -9999;
    int hold = s -> st[s->top];
    (s->top) --;
    return hold;
}

int main(){
    
    /*do{
        scanf("%d", &n);
        push(S, n);
    }while(n != 0);*/
    char formula[1200];
    fgets(formula, sizeof(formula), stdin);
    formula[strlen(formula)-1] = '\0';
   
    /*char *x = strtok(formula, " ");
    printf("%s\n", x);
    char *p;
    while((p=strtok(NULL, " "))){
        printf("%s\n", p);
    }*/

    stack* S = init_stack();
    int n;
    char *x = strtok(formula," ");
    int num1 = atoi(x);
    push(S, num1);
    //for(int i=0; i<strlen(formula); i++){
    char *p;
    while((p=strtok(NULL, " "))){
        
        if(*p == '+'){
            int b = pop(S);
            int a = pop(S);
            push(S, a+b);
        }
        else if(*p == '-'){
            int b = pop(S);
            int a = pop(S);
            push(S, a-b);
        }
        else if(*p == '*'){
            int b = pop(S);
            int a = pop(S);
            push(S, a*b);
        }
        else if(*p == '/'){
            int b = pop(S);
            int a = pop(S);
            push(S, a/b);
        }
        else{
            push(S, atoi(p));
        }
        
    }
    printf("%d\n", pop(S));
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;



int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    unordered_map<string,int> mp;
    int n;
    cin>>n;
    for (int i = 0; i <n ; ++i) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n'
        <<"WA x "<<mp["WA"]<<'\n'
        <<"TLE x "<<mp["TLE"]<<'\n'
        <<"RE x "<<mp["RE"];

    return 0;
}

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

int main()
{
    using namespace std;
    int v1, v2, v3, input;
    v1 = v2 = v3 = 0;
    while (cin >> input) {
        if (v1 < input) {
            v3 = v2; v2 = v1; v1 = input;
        } else if (v2 < input) {
            v3 = v2; v2 = input;
        } else if (v3 < input) {
            v3 = input;
        }
    }
    cout <<
    v1 << endl <<
    v2 << endl <<
    v3 << endl;
}

Measured memory_bytes: 1160
n,x, m = map(int, input().split())
mod = [None for _ in range(m)]
count = x
loop = []
rem = [x]
for i in range(1, n):
    value = (x * x) % m
    rem.append(value)
    x = (x * x) % m
    if mod[value] != None:
        # print(mod)
        s_index = mod[value]
        loop = rem[s_index : -1]
        num = (n - s_index) // len(loop)
        amari = (n - s_index) % len(loop)
        if amari == 0:
            print(sum(rem[:s_index]) + sum(loop) * num) 
        else:
            print(sum(rem[:s_index]) + sum(loop) * num + sum(loop[:amari])) 
        exit()
    else:
        mod[value] = i
        count += value
print(count)


Measured memory_bytes: 73664
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

using ll = long long;

int main(void){
    // Here your code !
    ll n,res = 1000000000;
    
    cin >> n;
    
    // F(a,b) 
    // a * b = n
    // Fの最小値
    
    for(int i = 1; i <= sqrt(n); i++){
        if(n%i == 0){
            res = min(res,(ll)log10(n/i)+1);
        }
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 640
from collections import  deque

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    graph[B-1].append(A-1)
    graph[A-1].append(B-1)

used = [False for _ in range(N)]
INF = int(1e20)
shirube = [0 for _ in range(N-1)]


def bfs(e):
    d = deque()
    used[e] = True
    d.append(e)
    while len(d) != 0:
        ne = d.pop()
        for elm in graph[ne]:
            if not used[elm]:
                shirube[elm-1] = ne
                used[elm] = True
                d.appendleft(elm)


bfs(0)
if all(used):
    print("Yes")
    for el in shirube:
        print(el+1)
else:
    print("No")

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  string a[4]={"remaerd", "maerd", "esare", "resare"};
  bool can2=false;
  for(int i=0;i<s.size();){
    can2=false;
  	for(int j=0;j<4;j++){
    	string d=a[j];
      if(s.substr(i,d.size())==d){
        can2=true;
      i+=d.size();
      }
    }
    if(can2==false){
    break;
    }
  }
  if(can2){cout << "YES" << endl;}
  else{cout << "NO" << endl;}
}



Measured memory_bytes: 3748
s = list(map(int, input().split()))
n=s[0]
dic={}
for i in range(n):
    s=input().split()
    s=s[0]
    if s in dic.keys():
        dic[s]+=1
    else:
        dic[s]=1
m=max(dic.values())
ans=[]
for i in dic:
    if dic[i]==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sort()
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n,m;cin >> n>> m;
  if(n==m)cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b && b < c) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int five = 2;
		int seven = 1;
		for(int i = 0;i <3 ;i++) {
			int moji = scan.nextInt();
			if(moji == 5) {
				five -= 1;
			}else if(moji == 7) {
				seven -= 1;
			}
		}
		if(five == 0 && seven == 0) {
			System.out.print("YES");
		}else {
			System.out.println("NO");
		}
		scan.close();

	}

}


Measured memory_bytes: 20820
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const PI: f64 = std::f64::consts::PI;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: f64 = scan(tokens);
    let b: f64 = scan(tokens);
    let x: f64 = scan(tokens);
    if x < a * a * b / 2.0 {
        println!("{}", (b / 2.0).atan2(x / a / b) / PI * 180.0);
    } else {
        println!("{}", (b - x / a / a).atan2(a / 2.0) / PI * 180.0);
    }
}


Measured memory_bytes: 4604
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    T, A = [int(x) for x in stdin.readline().rstrip().split()]
    Hs = [int(x) for x in stdin.readline().rstrip().split()]
    spam = [(i, abs(A - y)) for i, y in enumerate([T - x * 0.006 for x in Hs])]
    ham = sorted(spam, key=lambda x: x[1])
    print(ham[0][0] + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0;
  set<ll> se[26];
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    cin >> t[i];
    t[i]--;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
 

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int x_div = x2 - x1;
    int y_div = y2 - y1;

    int x3 = x2 - y_div;
    int y3 = y2 + x_div;
    int x4 = x1 - y_div;
    int y4 = y1 + x_div;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


}

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 n;
  cin >> n;
  int a[2][n];
  rep(i,2){
  	rep(j,n){
  		cin >> a[i][j];
  	}
  }
  
  int s[110];
  s[0] = 0;
  rep(i,n){
  	s[i+1] = s[i] + a[0][i];
  }
  
  int t[110];
  t[0] = 0;
  rep(i,n){
  	t[i+1] = t[i] + a[1][i];
  }
  
  int ans = 0;
  rep(i,n){
  	ans = max(s[i+1] + t[n] - t[i], ans);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll  n, m ;cin>>n>>m ;
 vector<P> A(n+m) ;
 rep(i,n){
     int a ; cin>>a ;
     A[i].fi=a ;
     A[i].se=1ll ;
 }
 rep(i,m){
   ll a,b ;cin>>a>>b ;
   A[i+n].fi=b ;
   A[i+n].se=a ; 
 }
 sort(A.rbegin(),A.rend()) ;
 ll k=n ; ll ans=0 ; ll memo =0 ;
 rep(i,n+m){
   ans+= A[i].fi*A[i].se ;
   k-= A[i].se ;
   if(k<=0){
    memo=A[i].fi ;
    break ;
   }
 }
 ans+= k*memo ;
 cout<<ans<<endl ;
 return 0 ; 
}

Measured memory_bytes: 6428
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	ans := [3]int{-1, -1, -1}

	for i := 0; i <= n; i++ {
		for j := 0; j <= n-i; j++ {
			for k := 0; k <= n-i-j; k++ {
				if i+j+k == n && 10000*i+5000*j+1000*k == y {
					ans[0] = i
					ans[1] = j
					ans[2] = k
					goto Hoge
				}
			}
		}
	}
Hoge:

	fmt.Printf("%d %d %d\n", ans[0], ans[1], ans[2])
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+10;
const ll mod =  998244353;
ll fac[maxn], inv[maxn];
ll qpow(ll a,ll b)
{
	ll r=1,t=a;
	while(b)
	{
		if(b&1)
			r=(r*t)%mod;
		b>>=1;
		t=(t*t)%mod;
	}
	return r;
}
void init()
{
	fac[0] = 1ll;
	for (int i = 1; i < maxn; i++)
		fac[i] = fac[i - 1] * i % mod;
	inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll c(ll n, ll m)
{
	if (n < m) 
		return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c)
		cout<<"Yes\n" ;
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
Y, X = map(int, input().split()) 	

num = X * Y
if X == 1 or Y == 1:
  out =1
elif num % 2 == 0:
  out = int(num / 2)
elif num % 2 == 1:
  out = int((num -1)/2 + 1)
print(out)


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

int main()
{
  int n, q;
  map<int, int> a;
  intmax_t s = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int t;
    cin >> t;
    a[t]++;
    s += t;
  }
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    int b, c;
    cin >> b >> c;
    s += a[b] * (c - b);
    a[c] += a[b];
    a[b] = 0;
    cout << s << endl;
  }
}


Measured memory_bytes: 8052
#include <iostream>

int msum,dsum;
using namespace std;
long long INF=1e17;
class SegT {
	private:
	int nvalue;
	int size_f;
	SegT *left;
	SegT *right;
	public:
	SegT() {
		msum++;
		left=NULL;
		right=NULL;
		size_f=0;
		nvalue=0;
	}
	~SegT() {
		dsum++;
		if(left!=NULL) delete left;
		if(right!=NULL) delete right;
	}
	int size() {
		return size_f;
	}
	void add(long long lfv,long long rgv,long long value) {
		if(lfv>value) return;
		if(rgv<value) return;
		if(lfv==rgv) {
			nvalue++;
			size_f++;
			return;
		}
		long long hf=(lfv+rgv+INF*2)/2-INF;
		if(value>hf) {
			if(right==NULL) {
				right = new SegT;
			}
			(*right).add(hf+1,rgv,value);
		} else {
			if(left==NULL) {
				left = new SegT;
			}
			(*left).add(lfv,hf,value);
		}
		size_f=nvalue;
		if(left!=NULL) size_f+=(*left).size();
		if(right!=NULL) size_f+=(*right).size();
	}
	int calc(long long lfv,long long rgv,long long value) {
		if(lfv>value) return 0;
		if(rgv<=value) return size();
		long long hf=(lfv+rgv+INF*2)/2-INF;
		int ret=0;
		if(left!=NULL) ret+=(*left).calc(lfv,hf,value);
		if(right!=NULL) ret+=(*right).calc(hf+1,rgv,value);
		return ret;
	}
};
int N,K,as[200008],bs[200008];
long long sum[200008];
int main() {
	cin >> N >> K;
	sum[0]=0;
	for(int i=1;i<=N;i++) {
		cin >> as[i];
		bs[i]=as[i]-K;
		sum[i]=sum[i-1]+bs[i];
	}
	SegT *T;
	T = new SegT;
	(*T).add(-INF,INF,0);
	long long sol=0;
	for(int i=1;i<=N;i++) {
		sol+=(*T).calc(-INF,INF,sum[i]);
		(*T).add(-INF,INF,sum[i]);
	}
	cout << sol << endl;
	delete T;
	//cout << msum << " " << dsum << endl;
	return 0;
}


Measured memory_bytes: 190208
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll a, b;
  cin>>a>>b;
  if(a*b%2==0){
    print("Even");
  }
  else{
    print("Odd");
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

p_e = [(x+1)/2 for x in p]

ans = sum(p_e[:K])
tmp = ans
i = 0

while 1:
    try:
        ans = max(ans, tmp - p_e[i] + p_e[K + i])
        tmp = tmp - p_e[i] + p_e[K + i]
        i += 1
    except IndexError:
        break

print(ans)

Measured memory_bytes: 24548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int x, y;
	cin >> x >> y;

	int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	if(a[x]==a[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

 int main()
 {
	ll n,sum=0,k; cin>>n;
	ll a[n];
	for(ll i = 0;i<n;i++)cin>>a[i];
	for(ll i = 0;i<n;i++)
	{
		cin>>k;
		sum+=max((ll)0,a[i]-k);
	}
	cout<<sum<<endl;

	return 0;
 }


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

using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    ll D[5] = {0};
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if (S[0] == 'M') D[0]++;
        else if (S[0] == 'A') D[1]++;
        else if (S[0] == 'R') D[2]++;
        else if (S[0] == 'C') D[3]++;
        else if (S[0] == 'H') D[4]++;
    }

    ll comb = 0;
    int P[10]={0,0,0,0,0,0,1,1,1,2}; 
    int Q[10]={1,1,1,2,2,3,2,2,3,3}; 
    int R[10]={2,3,4,3,4,4,3,4,4,4}; 
    for (int i = 0; i < 10; i++) comb += D[P[i]] * D[Q[i]] * D[R[i]];

    cout << comb << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n,x;
int a[MAXN];
int main()
{
	scanf("%d %d",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++)
	{
		if(x>=a[i])
			x-=a[i];
		else
		{
			printf("%d\n",i-1);
			return 0;
		}
	}
	if(a[n]==x)
		printf("%d\n",n);
	else
		printf("%d\n",n-1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define one_peace ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
    one_peace;
    ll n,a,b,h,e;
    cin>>n>>a>>b;
    if((max(a,b)-min(a,b))%2==0)
    {
        cout<<(max(a,b)-min(a,b))/2;
    }
    else
    {
if(a==1 || b==1){
h=max(a,b)-1;
cout<<((h-min(a,b))/2)+1;return 0;


}
if(a==n || b==n){
h=min(a,b)+1;
cout<<((max(a,b)-h)/2)+1;return 0;
}
h=min(n-a,n-b);e=min(a-1,b-1);
e=min(h,e);
cout<<e+1+((max(a,b)-1)-min(a,b))/2;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n] = {0};
    int dif = 0;
    for(int i = 0; i < n; i++){
        int idx;
        cin >> idx;
        a[idx-1]++;
    }
    for(int i = 0; i < n; i++){
        if(a[i] != 0){
            dif++;
        }
    }
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            a[i] = 100000;
        }
    }
    sort(a,a+n);
    int ans = 0;
    for(int i = 0; i < dif - k; i++){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
s = input()

if s[0] == "R":
    if s[1] == "R":
        if s[2] == "R":
            print("3")
        else:
            print("2")
    else:
        print("1")
    exit()
    
if s[1] == "R":
    if s[2] == "R":
        print("2")
    else:
        print("1")
    exit()

if s[2] == "R":
    print("1")
else:
    print("0")

Measured memory_bytes: 8988
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,q = map(int, input().split())
    s = input()
    l = [0]*(n+1)
    for i in range(n):
        if s[i:i+2]=='AC':
            l[i+1]=l[i] + 1
        else:
            l[i+1]=l[i]

    for _ in range(q):
        a, b = map(int, input().split())
        print(l[b-1]-l[a-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 6740
import java.util.*;

// ABC 79-D
// https://beta.atcoder.jp/contests/abc079/tasks/abc079_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int n = N;
		int sum = 0;
		while (n > 0) {
			sum += n % 10;
			n /= 10;
		}
		System.out.println(N % sum == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 21972
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
  
	ll a;
	double b;
	cin >> a >> b;

	ll c = round(b*100);
	cout << a*c/100 << endl;
	
	return 0;

  
}
//Apna Time Aayega :)

Measured memory_bytes: 3752
#include<stdio.h>

int main(){
    int height[10],i,j,cp;
    for(i = 0; i < 10; i++){
        scanf("%d", &height[i]);
    }
    for(i = 0; i < 3; i++){
        for(j = i+1; j < 10; j++){
            if(height[i]<height[j]){
                cp = height[i]; height[i] = height[j]; height[j] = cp;
            }
        }
        printf("%d\n",height[i]);
    }
    return 0;
}

Measured memory_bytes: 600
n = int(input())
score = []
for i in range(n):
    s, p = list(input().split())
    tmp = [s, int(p)]
    tmp.append(i+1)
    score.append(tmp)
score.sort(key = lambda x: (x[0], -x[1]))
for i in range(n):
    print(score[i][2])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define AMAX 10000

int main()
{
  int n,i,j;
  int c[AMAX+1];
  int *A,*B;

  scanf("%d",&n);

  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);

  for(i=0;i<AMAX;i++){
    c[i]=0;
  }

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

  for(i=1;i<=AMAX;i++){
    c[i]=c[i]+c[i-1];
  }

  for(j=1;j<=n;j++){
    B[c[A[j]]]=A[j];
    c[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }

  printf("\n");

  return 0;
}

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

using namespace std;

int main() {
    int N; cin >> N;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i<N; ++i) {
        if( s.substr(i) == t.substr(0, N-i) ) {
            printf("%d\n", N+i);
            return 0;
        }
    }
    printf("%d\n", 2*N);
}


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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0,rep,cnt,sad;
ll R,G,B;
char c;
string s;
vector <ll> V;

int main()
{
    cin >> n;
    cin >> s;
    for (int i=0;i<n;i++){
        c=s[i];
        R=0;
        G=0;
        B=0;
        for (int j=0;j<i;j++){
            if (s[j]=='R') R++;
            if (s[j]=='G') G++;
            if (s[j]=='B') B++;

            if (s[j]!=c){
                if ('R'!=c && 'R'!=s[j]){
                    x=R;
                    if (j-(i-j)>=0 && s[j-(i-j)]=='R') x--;
                    sol+=x;
                }
                if ('G'!=c && 'G'!=s[j]){
                    x=G;
                    if (j-(i-j)>=0 && s[j-(i-j)]=='G') x--;
                    sol+=x;
//                    if (j-(i-j)>=0 && s[i-j]=='G') cout << "noooo ";
//                    cout << x << " " << G << " " << i-j << "\n";
                }
                if ('B'!=c && 'B'!=s[j]){
                    x=B;
                    if (j-(i-j)>=0 && s[j-(i-j)]=='B') x--;
                    sol+=x;
                }
            }
        }
    }
    cout << sol;
}


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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

const int N=200005;
int a[N];

int main()
{
    int n,k;
    LL sum=0;
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    rer(i,0,n-k-1)sum+=a[i];
    cout<<sum<<endl;
    return 0;
}




















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

int main() {
	int n, w, d;
	int p, s;
	int ww, dd, ans, nw, nd;
	int flag;
	
	cin >> n >> w >> d;
	while(n!=0 || w!=0 || d!=0){
		vector<pair<int, int>> v;
		vector<int> squ;
		v.push_back(make_pair(w, d));
		
		for(int i=0; i<n; ++i){
			cin >> p >> s;
			ww=v[p-1].first;
			dd=v[p-1].second;
			while(s/(2*ww+2*dd)>0) s-=2*ww+2*dd;
			
			if((s-ww)<0){
				ans=s;
				nw=ans;
				nd=dd;
				flag=0;
			}
			else if((s-ww-dd)<0){
				ans=s-ww;
				nw=ww;
				nd=ans;
				flag=1;
			}
			else if((s-ww-dd-ww)<0){
				ans=ww-(s-ww-dd);
				nw=ans;
				nd=dd;
				flag=0;
			}
			else{
				ans=dd-(s-ww-dd-ww);
				nw=ww;
				nd=ans;
				flag=1;
			}
			
			v.erase(v.begin()+(p-1));
			if(!flag){
				if(nw*nd <= (ww-nw)*nd){
					v.push_back(make_pair(nw, nd));
					v.push_back(make_pair((ww-nw), nd));
				}
				else{
					v.push_back(make_pair((ww-nw), nd));
					v.push_back(make_pair(nw, nd));
				}
			}
			else{
				if(nw*nd <= nw*(dd-nd)){
					v.push_back(make_pair(nw, nd));
					v.push_back(make_pair(nw, (dd-nd)));
				}
				else{
					v.push_back(make_pair(nw, (dd-nd)));
					v.push_back(make_pair(nw, nd));
				}
			}
		}
		for(int i=0; i<v.size(); ++i) squ.push_back(v[i].first*v[i].second);
		sort(squ.begin(), squ.end());
		for(int i=0; i<squ.size(); ++i){
			cout << squ[i];
			if(i!=squ.size()-1) cout << " ";
		}
		cout << endl;
		
		cin >> n >> w >> d;
	}
	return 0;
}

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

using namespace std;

string s;
int a,b;

bool check() {
    for(int i = 0; i < a; i++) if (!(s[i] >= '0' && s[i] <= '9')) return false;
    if (s[a] != '-') return false;
    for(int i = a + 1; i < s.length(); i++) if (!(s[i] >= '0' && s[i] <= '9')) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    cin >> a >> b;
    cin >> s;
    cout << (check()? "Yes" : "No");
}


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

int main() {
  int n;
  ll S = 0;
  cin >> n;
  vector<ll> A(n), v(200001, 0);
  REP(i, n) {
    cin >> A[i];
    v[A[i]]++;
  }
  REP(i, 200000) S += v[i + 1] * (v[i + 1] - 1) / 2;
  REP(i, n) cout << S - v[A[i]] + 1 << endl;
}

Measured memory_bytes: 6360
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int                     integer;
#define int                     long long
typedef pair<int, int>          pii;
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define rep(i, a, b)            for(int i = a; i < (b); i++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<(x)<<endl
#define p2(x,y)                 out<<(x)<<' '<<(y)<<endl
#define p3(x,y,z)               out<<(x)<<' '<<(y)<<' '<<(z)<<endl
#define p4(x,y,z,w)             out<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<endl
#define p1d(a,n)                for(int ix=0;ix<n-1;ix++) out<<a[ix]<<' '; out<<a[n-1]<<'\n';
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define pl(x)                   out<<(x)
#define pll(x)                  out<<(x)<<' '
#define range(v)                v.begin(),v.end()
#define all(x)                  begin(x), end(x)
#define sz(x)                   (int)(x).size()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

ll iceildiv(const ll a, const ll b){ if(a==0){return 0;} return (1 + ((a - 1)/b));}
bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a, T b, const int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}

void ssolve(std::istream& in, std::ostream& out){
    int n; s(n);
    int ans = 0;
    for(int a = 1; a <= n - 1; a++){
        ans += ((n - 1)/a);
    }
    p(ans);
    return;
}

class CAXBC {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CAXBC solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3616
# from sys import exit
H, W = [int(n) for n in input().split()]
c = [[0 for _ in range(W)] for __ in range(H)]
Bs = []

for i in range(H):
    c[i] = list(str(input()))
    for j in range(W):
        if c[i][j] == "B":
            Bs.append((i, j))


ans = 0
for e0 in Bs:
    for e1 in Bs:
        ans = max(ans, abs(e0[0] - e1[0]) + abs(e0[1] - e1[1]))
print(ans)



Measured memory_bytes: 5608
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] data=new int[101];
        int[] out=new int[101];
        int i=1;
        int p;
        while(sc.hasNextInt()){
            p=sc.nextInt();
            data[p]++;
            out[i]=i;
            i++;
        }
        int temp1;
        int temp2;
        for(int n=1;n<i;n++){
            for(int m=n;m>1;m--){
                if(data[m]>data[m-1]){
                    temp1=data[m];
                    temp2=out[m];
                    data[m]=data[m-1];
                    out[m]=out[m-1];
                    data[m-1]=temp1;
                    out[m-1]=temp2;
                }else{
                    break;
                }
            }
        }
        System.out.println(out[1]);
        for(int n=2;n<i;n++){
            if(data[n-1]==data[n]){
                System.out.println(out[n]);
            }else{
                break;
            }
        }
    }
}

Measured memory_bytes: 16312
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using type = LL;

const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/08/25  Problem: ARC 101 B / Link: http://arc101.contest.atcoder.jp/tasks/arc101_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----

https://yang33-kassa.jp/codeforces/cf496/

----解説ここまで---- */

struct BIT {
	int N;
	int nn;
	vector<type> data;
	BIT(int n) {
		N = n + 1;
		data = vector<type>(n + 1, 0);
		nn = 1;
		while (nn * 2 <= N)nn *= 2;
	}
	void add(int i, type w) {
		for (int x = i; x <= N; x += x & -x) {
			data[x] += w;
		}
	}
	type sum(int i) {
		type ret = 0;
		for (int x = i; x > 0; x -= x & -x) {
			ret += data[x];
		}
		return ret;
	}
	type sum(int l, int r) {
		if (l > r) return 0;
		return sum(r) - sum(l - 1);
	}
};

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

LL solve(const vector<LL>&a, LL M) {
	int N = (int)a.size();
	LL ret = 0; BIT bit(2e5 + 20);
	int cur = 1e5 + 10;
	FOR(i, 0, N) {
		bit.add(cur, 1);
		if (a[i] < M)cur--;
		else cur++;
		ret += bit.sum(cur);
	}
	return ret;
}

int main() {
	LL N;
	cin >> N;
	vector<LL> a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	auto b = a;
	sort(b.begin(), b.end());

	int OK = 0; int NO = N;
	FOR(i, 0, 30) {
		int mid = (OK + NO) / 2;
		if (solve(a, b[mid]) * 4 >= N * (N + 1) ) {
			OK = mid;
		}
		else NO = mid;
	}
	cout << b[OK] << endl;

	return 0;
}


Measured memory_bytes: 3428
import java.util.Scanner;

class Main{
	static int cursor = 0;
	static char[] input;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		input = scan.next().toCharArray();
		System.out.println((check() && cursor==input.length)?"Cat":"Rabbit");
	}

	static boolean check() {
		if(cursor>=input.length) return false;
		if(input[cursor]!='m') return false;
		cursor++;
		if(cursor>=input.length) return false;
		if(!(input[cursor]=='e' || check())) return false;
		cursor++;
		if(cursor>=input.length) return false;
		if(!(input[cursor]=='w' || check())) return false;
		cursor++;
		return true;
	}
}

Measured memory_bytes: 26320
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  char a[10];
  for(int i = 0; i < 9; i++){
    cin >> a[i];
  }
  cout << a[0] << a[4] << a[8] << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]

cntd = Counter(D)
cntt = Counter(T)

for t in cntt:
    if cntt[t] > cntd[t]:
        print("NO")
        exit(0)
print("YES")


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

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

#define all(x) x.begin(), x.end()
#define imie(x) cout << "[" << #x " = " << x << "] "
#define nl cout << "\n"

bool valid(ll a, ll b, ll c) {
	if(a == b || b == c || a == c) {
		return false;
	}
	if((a + b > c) && (a + c > b) && (b + c > a)) {
		return true;
	}
	return false;
}

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	for(int& a: v) {
		cin >> a;
	}
	
	//set<vector<int>> s;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			for(int k = j+1; k < n; k++) {
				if(valid(v[i], v[j], v[k])) {
					ans++;
				}
			}
		}
	}
	cout << ans;
	
}
int main(void) {
    
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
  
    //int t;
    //cin >> t;

	//for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	//}

	return 0;
}


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

int main(){
  int N, M;
  uint64_t  sum = 0;
  cin >> N >> M;

  priority_queue<int> pq;

  for(int i = 0; i < N; i++){
    int cost;
    cin >> cost;
    pq.push(cost);
  }

  for(int i = 0; i < M; i++){
    pq.push(pq.top() / 2);
    pq.pop();
  }

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

  cout << sum << endl;
  return 0;

}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[7];
int main(){
  for(int i=0;i<7;i++)cin >> a[i];
  long long int ans=0,ans2=0;
  if(a[0]>=2){
    if(a[0]%2==0)ans+=a[0];
    else ans+=(a[0]-1);
  }
  if(a[3]>=2){
    if(a[3]%2==0)ans+=a[3];
    else ans+=(a[3]-1);
  }
  if(a[4]>=2){
    if(a[4]%2==0)ans+=a[4];
    else ans+=(a[4]-1);
  }
  ans+=a[1];
  
  if(a[0]>=1 && a[3]>=1 && a[4]>=1){ans2+=3;a[0]--;a[3]--;a[4]--;}
   if(a[0]>=2){
    if(a[0]%2==0)ans2+=a[0];
    else ans2+=(a[0]-1);
  }
  if(a[3]>=2){
    if(a[3]%2==0)ans2+=a[3];
    else ans2+=(a[3]-1);
  }
  if(a[4]>=2){
    if(a[4]%2==0)ans2+=a[4];
    else ans2+=(a[4]-1);
  }
  ans2+=a[1];
  cout << max(ans,ans2) << endl;
  return 0;
}


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

int main(){
    string s; cin >> s;
    map<char,int> mp;

    for(char c : s){
        mp[c]++;
        if(mp[c] > 1){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << 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 N; cin >> N;
    vector<pair<int,int>> A(N);

    rep(i,N){
        int a , b;
        cin >> a >> b;
        A[i] = make_pair(b,a);
    }

    sort(A.begin(), A.end());
    int time=0;
    bool jud = true;

    rep(i,N){
        time += A[i].second;
        if(time > A[i].first){
            jud = false;
        }
    }

    if(jud){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int x;
	cin >> x;
	cout << !x << endl;
}


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

using namespace std;

typedef long long ll;

const double PI = acos(-1);

double toRadian(double alpha)
{
    return 2.0 * PI * alpha / 180.0;
}

namespace Geometry2D
{
    typedef double T;

    const double Eps = 1e-10;

    bool isZero(double x)
    {
        return abs(x) < Eps;
    }

    struct Point
    {
        T x, y;

        Point() : Point(0.0, 0.0) {}
        Point(T x, T y) : x(x), y(y) {}
        Point(double alpha) : Point(cos(alpha), sin(alpha)) {}

        Point operator + (const Point& p)   {   return Point(x + p.x, y + p.y); }
        Point operator - (const Point& p)   {   return Point(x - p.x, y - p.y); }
        Point operator * (const T& d)       {   return Point(d * x, d * y); }
        Point operator * (const Point& p)   {   return Point(x * p.x - y * p.y, x * p.y + y * p.x); }
    };

    ostream& operator << (ostream& os, Point p)
    {
        os << "(" << p.x << ", " << p.y << ")";
    }

    T square(Point p)
    {
        return p.x * p.x + p.y * p.y;
    }

    double abs(Point p)
    {
        return hypot(p.x, p.y);
    }

    double arg(Point p)
    {
        return atan2(p.y, p.x);
    }

    Point Polar(double r = 1.0, double alpha = 0.0)
    {
        return Point(alpha) * r;
    }

    Point translate(Point p, Point v)
    {
        return p + v;
    }

    Point scale(Point p, Point c, double factor)
    {
        return c + (p - c) * factor;
    }

    Point rotate(Point p, Point c, double alpha)
    {
        return c + (p - c) * Point(alpha);
    }

    T dot(Point v1, Point v2)
    {
        return v1.x * v2.x + v1.y * v2.y;
    }

    bool isPerp(Point v1, Point v2)
    {
        return isZero(dot(v1, v2));
    }

    T cross(Point v1, Point v2) /// positive if v2 is to the left of v1, negative if v2 is to the right of v1, otherwise zero
    {
        return v1.x * v2.y - v1.y * v2.x;
    }
}

using namespace Geometry2D;

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

    int A, B, H, M;
    cin >> A >> B >> H >> M;

    Point Va = Point(0.0, A);
    Point Vb = Point(0.0, B);

    Va = rotate(Va, Point(), -(H + M / 60.0) * (2.0 * PI / 12.0));
    Vb = rotate(Vb, Point(), -M * (2.0 * PI / 60.0));

    Point Mid = Va - Vb;

    double Ans = abs(Mid);

    printf("%.10f\n", Ans);
}


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

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 55;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a = n * (n - 1) / 2;
    int b = m * (m - 1) / 2;
    cout << a + b << '\n';
    return 0;
}


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

using namespace std;

int main(){

    int h, w;

    cin >> h >> w;

    vector<string> v(h);

    for (auto &x : v){
        cin >> x;
    }

    vector<int> n(26);

    for (auto &x : v){
        for(auto &y: x){
            n[y - 'a']++;
        }
    }

    int c = 0;
    for (auto &x : n){
        if(x & 1){
            c++;
            x--;
        }
    }
    if(w & 1 && h & 1){
        if(c != 1){
            cout << "No" << endl;
            return 0;
        }
    }else{
        if(c != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    c = 0;

    int n2 = 0, n4 = 0;

    for (auto &x : n){
        if(x % 4 == 2)
            n2++;
        n4 += x / 4;
    }

    if (h & 1 || w & 1){

        int r = (h / 2) * (w & 1) + (w / 2) * (h & 1);

        if(n2 > r){
            cout << "No" << endl;
            return 0;
        }

        if(n2 < r){
            if((r - n2) & 1){
                cout << "No" << endl;
                return 0;
            }
            n4 -= (r - n2) / 2;
        }
    }

    if(n4 != (w / 2) * (h / 2)){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int, input().split()))

def main():
    tri = 0
    L.sort()
    for i in range(N-1,-1,-1): #range(初期値,終了条件,変化量)
        mn = 0
        sl = i-1
        while(mn<sl):
            if (L[mn] + L[sl]) > L[i]:
                tri += sl - mn
                sl -= 1
            else:
                mn += 1
    print(tri)
    
main()

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

typedef pair<int, int> P;

int wall_x[31][31];
int wall_y[31][31];
int d[31][31];
int main(void){
    int w, h;
    while(cin >> w >> h && w) {
        rep(i, 31) rep(j, 31) wall_x[i][j] = wall_y[i][j] = -1;
        rep(line, 2*h-1) {
            if(line%2==0) {
                rep(i, w-1) cin >> wall_x[line/2][i];
            } else {
                rep(i, w) cin >> wall_y[line/2][i];
            }
        }
        rep(i, 31) rep(j, 31) d[i][j] = 0;
        queue<P> que;
        que.push(P(0, 0));
        d[0][0] = 1;
        while(!que.empty()) {
            P p = que.front(); que.pop();
            int cy = p.first, cx = p.second;
            if(cy == h-1 && cx == w-1) break;

            if(cx>0 && wall_x[cy][cx-1]==0 && d[cy][cx-1]==0) {
                d[cy][cx-1] = d[cy][cx]+1;
                que.push(P(cy, cx-1));
            }
            if(cx<w-1 && wall_x[cy][cx]==0 && d[cy][cx+1]==0) {
                d[cy][cx+1] = d[cy][cx]+1;
                que.push(P(cy, cx+1));
            }
            if(cy>0 && wall_y[cy-1][cx]==0 && d[cy-1][cx]==0) {
                d[cy-1][cx] = d[cy][cx]+1;
                que.push(P(cy-1, cx));
            }
            if(cy<h-1 && wall_y[cy][cx]==0 && d[cy+1][cx]==0) {
                d[cy+1][cx] = d[cy][cx]+1;
                que.push(P(cy+1, cx));
            }
        }
        cout << d[h-1][w-1] << endl;
    }
} 

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
int main(void){
   ll x;
   ll k;
   ll d;
   ll c;
   cin>>x>>k>>d;
   x=abs(x);
   c=x/d;
   if(c==k){
       cout<<x-d*k<<endl;
   }else if(c>k){
       cout<<x-d*k<<endl;
   }else{
       x=x-d*c;
       k=k-c;
       if(k%2==0){
           cout<<x<<endl;
       }else{
           cout<<abs(x-d)<<endl;
       }
   }
}


Measured memory_bytes: 3544