akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

void output(char c, int t){
    REP(i, t) cout << c;
}
// 33-39, 40-49, ..., 120-126
int memory[13] = {30, 40, 50, 60, 70, 80, 90, 100, 110, 120};

int main(){
    output('+', 10);
    output('[', 1);
    for(int i = 0; i < 10; i++){
        output('>', 1);
        output('+', i + 3);
    }
    output('<', 10);
    output('-', 1);
    output(']', 1);
    int curr = -1;

    string s;
    cin >> s;
    for(auto c : s){
        int next = c / 10 - 3;
        int dist = abs(curr - next);
        output((curr < next ? '>' : '<'), dist);
        curr = next;

        dist = abs(memory[curr] - c);
        output((memory[curr] < c ? '+' : '-'), dist);
        memory[curr] = c;

        output('.', 1);
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n;
int dp[1<<21],a[21][21];

int rec(int s,int i) {
    if (dp[s] > -1) return dp[s];
    dp[s] = 0;
    for (int j = 0;j < n;++j) if (((s>>j)&1) && a[i][j]) (dp[s] += rec(s^(1<<j),i-1)) %= mod;
    return dp[s];
}

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

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

using namespace std;
int main(){
    int n;cin>>n;
    map<string,int> m;
    rep(i,n){
        string tmp; cin >> tmp;                                                                                              m[tmp]++;
    }
    long out=0;                                                                                                          for(auto itr=m.begin();itr != m.end();itr++){                                                                            out++;                                                                                                           }
    cout << out << endl;                                                                                                 return 0;
}

Measured memory_bytes: 19040
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int main() {
    fast

    int n;
    cin>>n;

    vector<long long>arr(n);
    set<long long>st;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        st.insert(arr[i]);
    }
    if(n==1)cout<<0<<endl;
    else{
    //long long val=(arr[n-1]+arr[0])/2;
    long long minians=INT_MAX;
    for(int val=0;val<=100;val++){


    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=(val-arr[i])*(val-arr[i]);
    }
    minians=min(ans,minians);
    }
        cout<<minians;

    }



	return 0;
}


Measured memory_bytes: 256
def aaa(x: int) -> bool:
    return x % 2 == 0


def bbb(x: int) -> int:
    return x / 2


n = int(input())
li = list(map(int, input().split()))

flag = True
ans = 0
while(flag):
    li = list(filter(aaa, li))
    li = list(map(bbb, li))
    if(len(li) == n):
        ans += 1
    else:
        flag = False
print(ans)


Measured memory_bytes: 3060
check=True
a,b=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
l.reverse()
point=sum(l)/(4*b)
for i in range(b):
    if l[i]<point:
        check=False
        break
if check:
    print("Yes")
else:
    print("No")

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

int main() {
    long long num;
    long long sum = 0;
    long long tmp;
    cin >> num;

    vector<long long> vec(num + 2);
    vector<long long> vecCost(num + 1);

    for (int i = 1; i <= num; i++) cin >> vec.at(i);
    vec.at(0) = 0;        // Start
    vec.at(num + 1) = 0;  // Goal

    for (int i = 0; i <= num; i++) {
        vecCost.at(i) = abs(vec.at(i + 1) - vec.at(i));
        sum += vecCost.at(i);
    }
    
    for (int i = 1; i <= num; i++) {
        tmp = sum - (vecCost.at(i - 1) + vecCost.at(i)) + abs(vec.at(i + 1) - vec.at(i - 1));
        cout << tmp << endl;
    }
}

Measured memory_bytes: 4844
fn gcd<T>(a: T, b: T) -> T
where
    T: Copy + std::cmp::PartialEq + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if b == T::from(0u8) {
        a
    } else {
        gcd(b, a % b)
    }
}

fn factor(mut n: usize) -> Vec<(usize, usize)> {
    let mut ret = vec![];
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut cnt = 0;
        while n % i == 0 {
            cnt += 1;
            n /= i;
        }
        if cnt != 0 {
            ret.push((i, cnt));
        }
    }
    if n != 1 {
        ret.push((n, 1));
    }
    ret
}

fn main() {
    proconio::input! {
        n: usize,
        a_s: [usize; n],
    }
    let mut gcdval = a_s[0];
    let mut set = std::collections::HashSet::<usize>::new();
    for (item, _num) in factor(a_s[0]) {
        set.insert(item);
    }
    let mut pairwise_coprime = true;
    for &a in a_s[1..].iter() {
        gcdval = gcd(gcdval, a);
        let f = factor(a);
        let mut set_found = false;
        for (item, _num) in f {
            if set.contains(&item) {
                pairwise_coprime = false;
            } else {
                set.insert(item);
            }
        }
    }
    let ans = if pairwise_coprime {
        "pairwise coprime"
    } else if gcdval == 1 {
        "setwise coprime"
    } else {
        "not coprime"
    };
    println!("{}", ans);
}


Measured memory_bytes: 18340
#include<stdio.h>
 
int main(void)
{
  int m,f,r;
  int ad;
 
 
   
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    ad = m+f;
    if(ad == -2 && r == -1){
      break;
    }
    else if((m == -1||f == -1)||(ad <30)){
      printf("F\n");
    }
    else if(ad >=80){
      printf("A\n");
    }
    else if(ad >=65 && ad <80){
      printf("B\n");
    }
    else if((ad >=50 && ad <65)||(r >=50)){
      printf("C\n");
    }
    else if(ad >=30 && ad <50){
      printf("D\n");
    }
  }
  return 0;
}

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

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>=22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<vector>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]


typedef pair<int,int> P;

class Point{
public:
  double x,y;
  
  Point(double x = 0, double y = 0): x(x),y(y){};
  
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(a*x,a*y);}

  double own_dot(){return x*x+y*y;};
  double abs(){return sqrt(own_dot());}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

// 内積 
double dot(Point a, Point b){
  return a.x*b.x+a.y*b.y;
}

// 外積
double cross(Point a, Point b){
  return a.x*b.y-a.y*b.x; 
}


//多角形の面積
double area(vector<Point> P) {
  double A = 0;
  for (int i = 0; i < P.size(); i++) 
    A += cross(curr(P, i), next(P, i));
  return abs(A/2);
}

using namespace std;

int main(){
  int rev = 0;
  int n;
  while(cin >> n && n){
    vector<Point> V;
    rev++;
    while(n--){
      Point p;
      cin >> p.x >> p.y;
      V.push_back(p);
    }
    printf("%d %.1f\n",rev,area(V));
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

const int maxV=114514;
struct edge{int end;int cost;};
typedef pair<int,int> P;
int V;
vector<int> d;
vector<edge> G[maxV];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    for(int i=0;i<maxV;i++){d.push_back(INF);}
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.end]>d[v]+e.cost){
                d[e.end] = d[v]+e.cost;
                que.push(P(d[e.end],e.end));
            }
        }
    }
}

signed main(void){
    int N,M;
    int L[114514],R[114514],C[114514];
    int imos[114514]={};
    cin >> N >> M;
    REP(i,M){
        cin >> L[i] >> R[i] >> C[i];
        L[i]--;R[i]--;
    }
    edge h;
    REP(i,M){
        h.end=R[i];
        h.cost=C[i];
        G[L[i]].push_back(h);
        imos[L[i]]+=1;
        imos[R[i]]-=1;
    }
    REP(i,N){
        imos[i+1]+=imos[i];
    }
    REP(i,N){
        if(imos[i]>0){
            h.end=i;
            h.cost=0;
            G[i+1].push_back(h);
        }
    }
    dijkstra(0);
    int Ans=d[N-1];
    if(Ans==INF)Ans=-1;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 13688
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    sort(begin(s), end(s));
    if(s == "abc"){
        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;

int main() 
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    rep(i,n) {
        int x;
        cin >> x;
        que.push(x);
    }

    rep(i,m) {
        int x = que.top(); que.pop();
        que.push(x/2);
    }
    ll ans = 0;
    while (!que.empty()) {
        int x = que.top(); que.pop();
        ans += x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
//AOJ 409 Floor

#include<stdio.h>

#define MIN(a,b) ((a)<=(b)?(a):(b))
#define MAX(a,b) ((a)>=(b)?(a):(b))
typedef struct {int x1,y1,x2,y2;} Rect;
Rect a1,a2,a;
//a1.x1
int main()
{
	int x,y,id;
	
	scanf("%d%d",&x,&y);
	if(x==0&&y==0)puts("1");
	else if(x==1&&y==0)puts("2");
	else{
		a2.x1=a2.x2=1,id=2;
		while(1){
			if((id&1)==0){//北or南
				a.x1=MIN(a1.x1,a2.x1),a.x2=MAX(a1.x2,a2.x2);
				if(id%4==2)//北
				{
					a.y1=a2.y2+1,a.y2=a.y1+a.x2-a.x1;
				}
				else
				{
					a.y2=a2.y1-1,a.y1=a.y2-(a.x2-a.x1);
				}
			}else{
				a.y1=MIN(a1.y1,a2.y1),a.y2=MAX(a1.y2,a2.y2);
				if(id%4==1){//東
					a.x1=a2.x2+1,a.x2=a.x1+a.y2-a.y1;
				}else{
					a.x2=a2.x1-1,a.x1=a.x2-(a.y2-a.y1);
				}
			}
			
			if(a.x1<=x&&x<=a.x2&&a.y1<=y&&y<=a.y2){
				printf("%d\n",id%3+1);
				break;
			}
			
			id++;
			a1=a2,a2=a;
		}
	}
	return 0;
}


Measured memory_bytes: 2752
import numpy as np

n, k = map(int, input().split())
ary = np.array([i for i in range(n+1)])
#print(ary)
cum_1 = np.cumsum(ary)
cum_2 = np.cumsum(ary[::-1])
#print(cum_1, cum_2)

ans = 0
for j in range(k-1,n+1):
    ans += cum_2[j] - cum_1[j] + 1
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 36440
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n, k int

	fmt.Sscan(getNextLine(scanner), &n, &k)
	ww := make([]int, n)
	for i := 0; i < n; i++ {
		ww[i], _ = strconv.Atoi(getNextLine(scanner))
	}

	l := 0
	r := 1000000000
	for l < r {
		p := (l + r) / 2
		w := p + 1
		c := 0
		for i := 0; i < n; i++ {
			if ww[i] > p {
				c = 1000000000
				break
			}
			w += ww[i]
			if w > p {
				c++
				w = ww[i]
			}
		}
		if w > p {
			c++
		}
		if c > k {
			l = p + 1
			continue
		}
		r = p
	}

	fmt.Fprintln(writer, l)

	writer.Flush()
}



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

int main() {
    string s, t;
    int n, cnt = 0;
    cin >> s >> n;
    for(int i=0;i<n;i++){
        cin >> t;
        t += t;
        if(t.find(s) != t.npos) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int h1,m1,h2,m2;
  cin>>h1>>m1>>h2>>m2;
  int k;cin>>k;
  int ans = h2 - h1;
  ans *= 60;
  ans += m2 - m1;
  ans -= k;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3652
from itertools import combinations

n = int(input())

places = [list(map(int, input().split())) for _ in range(n)]


def length(list1, list2):
    return ((list1[0] - list2[0])**2 + (list1[1] - list2[1])**2) ** 0.5

ans = 0

for a, b in combinations(places, 2):
    # print(length(a, b))
    ans += length(a, b)

print(ans * 2 / n)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define vip vector
#define ss second
#define ff first 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 1000000007
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll a,b;
cin>>a>>b;
  cout<<a*b;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ret = 0;
    for(int i=0;i<n;i++){
        if( (i > 0) && (s[i] == s[i-1]) ){
            continue;
        }
        ret++;
    }
    cout << ret;
}

Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))

dp = [-1] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 20588
N = int(input())
MM = input().split()
count1 = 0
for i in range(N):
  count2 = 0
  for j in range(i+1):
    if int(MM[i]) < int(MM[j]):
      count2 +=1
  if count2 == 0:
    count1 +=1
print(count1)

Measured memory_bytes: 9120
while True:
    a,b,c=map(str,raw_input().split())
    a,c=int(a),int(c)
    if b=="?":
        break
    if   b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    else:
        print(a//c)
    

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

using namespace std;

string s1,s2;

int main()
{
    cin >> s1 >> s2;
    if(s1.length() == s2.length())
    {
        for (int i = 0,j = 0; i < s1.length();i ++ ,j ++ )
            printf("%c%c",s1[i],s2[j]);
    }
    else
    {
        for (int i = 0,j = 0; i < s1.length();i ++ ,j ++ )
            if(i != s1.length()-1) printf("%c%c",s1[i],s2[j]);
            else printf("%c",s1[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 384
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N, M = map(int, input().split())
    d = defaultdict(int)
    for _ in range(M):
        a, b = map(int, input().split())
        d[a] += 1
        d[b] += 1
    for k, v in d.items():
        if v % 2 != 0:
            print("NO")
            return
    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9444
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n,trg;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]+l[j]>l[k])trg++;
            }
            
        }
    }
    cout<<trg<<endl;
    return 0;
}

    
    

Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	fmt.Println(pow(n, 3))
}


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

int main() {
int n;
cin>>n;
int g=0;int k=0;
for(int i=0;i<n;i++){
	int s;
	cin>>s;
	if(s%2==0){g++;}
	else{k++;}
}
if(g==0 or k%2==0){cout<<"YES"<<endl;}
else{cout<<"NO"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  
  //AとBとを入れ替える
  int a;
  a = X;
  X = Y;
  Y = a;
  
  //AとCとを入れ替える
  a = X;
  X = Z;
  Z = a;
  
  cout << X << " " << Y << " " << Z << endl;
}

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

int main() {
    long long int i, n, c, x[110000]={0}, v[110000]={0}, max_cal=0;
    long long int sum_r[110000]={0}, sum_l[110000]={0}, g[110000]={0};
    cin >> n >> c;
    for(i=1; cin >> x[i] >> v[i]; i++);
    for(i=1; i<=n; i++) {
        sum_r[i] = sum_r[i-1] + v[i];
        sum_l[i] = sum_l[i-1] + v[n-i+1];
    }
    for(i=1; i<=n; i++) {
        sum_r[i] -= x[i];
        sum_l[i] -= c-x[n-i+1];
    }
    
    for(i=1; i<=n; i++) g[i] = max(g[i-1], sum_l[i]);
    // for(i=1; i<=n; i++) cout << sum_r[i] << " - " << x[i] << " + " << g[n-i] << endl;
    for(i=1; i<=n; i++) {
        max_cal = max(max_cal, max(sum_r[i], sum_r[i]-x[i]+g[n-i]));
    }
    
    cout << endl;
    
    g[0] = 0;
    for(i=1; i<=n; i++) g[i] = max(g[i-1], sum_r[i]);
    // for(i=1; i<=n; i++) cout << sum_l[i] << " - " << c-x[n-i+1] << " + " << g[n-i] << endl;
    for(i=1; i<=n; i++) {
        max_cal = max(max_cal, max(sum_l[i], sum_l[i]-(c-x[n-i+1])+g[n-i]));
    }
    cout << max_cal << endl;
}

Measured memory_bytes: 4480
using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string line = Console.ReadLine();
            string[] array = line.Split(' ');
            //モンスターの数
            int n = int.Parse(array[0]);
            //使用可能な必殺技の数
            int k = int.Parse(array[1]);
          
            //HP
            string li = Console.ReadLine();
            string[] ar = li.Split(' ');

            int[] arr = new int[n];
            for (int index = 0; index < n; index++)
            {
                int num = int.Parse(ar[index]);
                arr[index] = num;
            }
            //体力の多い順にソート
            Array.Sort(arr);

            //残りのモンスターHPの合計
            long sum = 0;
            for (int i = 0; i < arr.Length - k; i++)
            {
                sum += arr[i];
            }
            //使った必殺技の数＋残HPの合計
            Console.WriteLine(sum);

        }
    }
}


Measured memory_bytes: 45968
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        long[] inp = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        long N = inp[0];
        long M = inp[1];

        if (N == 1 && M == 1) {
            WriteLine(1);
            return;
        }

        if (N == 1 || M == 1) {
            WriteLine((N * M) - 2);
            return;
        }

        if (N == 2 || M == 2) {
            WriteLine(0);
            return;
        }

        WriteLine((N * M) - (N * 2) - ((M - 2) * 2));
    }
}


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

using namespace std;

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

    vector<int> right(N), left(N);
    right[0] = A[0];
    for(int i = 1; i < N; ++i){
        right[i] = max(right[i-1], A[i]);
    }
    left[N-1] = A[N-1];
    for(int i = N-2; i >= 0; --i){
        left[i] = max(left[i+1], A[i]);
    }

    for(int i = 0; i < N; ++i){
        if(i == 0){
            cout << left[1] << "\n";
        }else if(i == N-1){
            cout << right[N-2] << endl;
        }else{
            cout << max(right[i-1], left[i+1]) << "\n";
        }
    }
    // cout << endl;
    // for(auto i : right){
    //     cout << i << endl;
    // }
    // cout << endl;
    // for(auto i : left){
    //     cout << i << endl;
    // }


    return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
int main(void){
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==2){
        if(y==2){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        if(y==4||y==6||y==9||y==11){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int MOD = 1e9+7;

int H, W;
int mat[50][50];
const int dh[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dw[] = {-1, 0, 1, -1, 1, -1, 0, 1};

void dfs(int h, int w) {
	mat[h][w] = 0;
	rep(i, 8) {
		int nh = h+dh[i], nw = w+dw[i];
		if (nh>=0 && nh<H && nw>=0 && nw<W && mat[nh][nw]==1) dfs(nh, nw);
	}
}

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

	while (true) {
		cin >> W >> H;
		if (W+H == 0) break;
		
		memset(mat, 0, sizeof(mat));

		rep(i, H) {
			rep(j, W) cin >> mat[i][j];
		}

		int cnt = 0;
		rep(i, H) rep(j, W) {
			if (mat[i][j]==1) {
				dfs(i, j);
				cnt++;
			}
		}

		cout << cnt << endl;
	}
}


Measured memory_bytes: 3128
n=int(input())
p=[i for i in range(3,n+1,2)]
p=[2]+p
prime=[2]
std=[True]*(n+1)
for i in p:
  if std[i]:
    if i%prime[-1]!=0:
      prime.append(i)
      for j in range(n//i+1):
        std[i*j]=False
  else:
    continue
if n in prime:
  print(n)
else:
  for i in range(n):
    t=n+i
    for j in prime:
      if t%j==0:
        break
    else:
      print(n+i)
      break

Measured memory_bytes: 5904
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int a[200000];
int pos[200000];

int main(){
  ll N;
  cin >> N;
  rep(i, N) cin >> a[i];
  rep(i, N){
    pos[a[i] - 1] = i;
  }

  int i = 0;
  int posCurr;
  int posPrev = pos[i];
  int ans = 1;
  int length = 1;
  while(1){
    i++;
    if(i == N) break;
    posCurr = pos[i];
    //printf("[%d %d]", i + 1, posCurr);
    if(posCurr - posPrev > 0){
      length++;
      ans = max(ans, length);
    }else{
      length = 1;
    }
    posPrev = posCurr;
  }
  ans = N - ans;

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


Measured memory_bytes: 1792
def resolve():
    ks = input().split(" ")
    k = int(ks[0])
    s = int(ks[1])

    n = 0

    for zz in range(k+1):
        for yy in range (k+1):
                if (0 <= s-(yy+zz) <= k):
                    n += 1

    print(n)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 67616
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let x: i64 = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    if a[0] > x {
        ans = a[0] - x;
        a[0] = x;
    }

    for i in 0..n - 1 {
        if a[i] + a[i + 1] > x {
            ans += a[i + 1] + a[i] - x;
            a[i + 1] -= a[i + 1] + a[i] - x;
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  FOR(i,0,N)cin >> A[i];
  FOR(i,0,N)A[i] -= i+1;
  sort(ALL(A));
  ll ans = 0;
  ll base = A[N/2];
  FOR(i,0,N)ans += abs(A[i]-base);
  cout << ans << endl;
}


Measured memory_bytes: 1024
import itertools
import math
N = int(input())
As = list(map(int,input().split(" ")))
ans = []
off = 0
if N%2 == 1:
    off = 1

for i in range(N-1,-1,-2):
    ans.append(As[i])
for i in range(off,N,2):
    ans.append(As[i])
ans = list(map(str,ans))
print(" ".join(ans))

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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int n;cin >> n; n %= 10;
	cout << ((!(n == 1 || n == 8 || n == 6 || n == 0)) ? ((n == 3) ? 'b' : 'h') : 'p') << "on";
}

//Coded by LoliThief

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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n + 1), b(n);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;
  int64_t ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= b[i]) {
      ans += b[i];
    } else {
      ans += a[i];
      b[i] -= a[i];
      if (a[i + 1] >= b[i]) {
        ans += b[i];
        a[i + 1] -= b[i];
      } else {
        ans += a[i + 1];
        a[i + 1] = 0;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n,s;
  cin>>n;
  vector<int> a(1000000);
  for(int i=0;i<n;i++){
    cin>>s;
    if (s!=0){
      a.at(s-1)++;
    }
    a.at(s)++;
    a.at(s+1)++;
  }
  sort(a.begin(),a.end(),greater<int>());
  cout<<a.at(0);    
}


Measured memory_bytes: 4096
#include <iostream>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

typedef long long int lli;

typedef pair<lli, lli> pii;
typedef vector<lli> vi;
typedef set<lli> si;
typedef unordered_map<lli, lli> umii;
typedef unordered_set<lli> usi;

lli mod = 1000000007;

void dispvec(vi arr)
{
    vi::iterator itr = arr.begin();
    while (itr != arr.end())
    {
        cout << *itr << " ";
        itr++;
    }
    cout << endl;
}

struct CustomCompare
{
    //stable sort by first then second both in increasing
    bool operator()(const pii &i, const pii &j)
    {
        if (i.first == j.first)
            return i.first < j.first;
        return i.second < j.second;
    }
};

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

void solve()
{
    int n;
    cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vi dp(n, 0);
    if (n == 2)
    {
        cout << abs(arr[0] - arr[1]);
        return;
    }
    dp[1] = abs(arr[0] - arr[1]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
    }
    // dispvec(dp);
    cout << dp[n - 1] << endl;
}

int main()
{
  
    int t = 1;
    // cin >> t;
    int i = 1;
    while (i <= t)
    {
        solve();
        i++;
    }

    return 0;
}

Measured memory_bytes: 4704
#include <stdio.h>

int main() {

    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);

    int arr[k * 2];

    int cnt = 0;
    int maxdata = a + k;

    int counter = (b - a + 1 <= k ? b - a + 1 : k);

    for (int i = 0; i < counter; i++) {
        //printf("%d\n", a + i);
        arr[i] = a + i;
        cnt++;
    }
    //printf("%d %d\n", maxdata, b - k + 1);

    if (maxdata <= b - k + 1) {
        maxdata = b - k + 1;
    }
    
    //printf("%d\n",maxdata);

    for (int j = maxdata; j <= b; j++) {
        //if (j >= a) {
            //printf("%d\n", j);
            arr[cnt] = j;
            cnt++;
        //}
    }

    for (int k = 0; k < cnt; k++) {
        printf("%d\n", arr[k]);
    }

    return 0;
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
 class Program
 {

     static void Main(string[] args)
     {
         int data0 = 0, data1 = 0, data2 = 0;

         String nyuryoku;
         string[] data;
         string pattern1, pattern2;

         nyuryoku = Console.ReadLine();
         data0 = int.Parse(nyuryoku);
         nyuryoku = Console.ReadLine();
         data = new string[data0];
         data = nyuryoku.Split(' ');
         for (int i = data0 -1 ; i >= 0; i--)
         {
             Console.Write(data[i]);
             if (i != 0)
                 Console.Write(" ");

         }
         Console.Write("\n");
      }
 }



Measured memory_bytes: 17972
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long H=sc.nextLong();
		long[][] katana=new long[N][2];
		long max=0;
		for(int i=0; i<N; i++) {
			katana[i][0]=sc.nextLong();
			max=Math.max(katana[i][0],max);
			katana[i][1]=sc.nextLong();
		}
		int cnt=0;
		for(int i=0; i<N; i++) {
			if(katana[i][1]>max) {
				cnt++;
			}
		}
		if(cnt>0) {
			int tmp=0;
			long[][] nage=new long[cnt][2];
			for(int i=0; i<N; i++) {
				if(katana[i][1]>max) {
					nage[tmp][0]=katana[i][1];
					nage[tmp][1]=0;
					tmp++;
				}
			}
			quick_sort(nage,0,tmp-1);
			long[][] cp=new long[tmp][2];
			cp[0][0]=nage[tmp-1][0];
			cp[0][1]=nage[tmp-1][0];
			for(int i=1; i<tmp; i++) {
				cp[i][0]=nage[tmp-1-i][0];
				cp[i][1]=cp[i-1][1]+cp[i][0];
			}

			if(H>=cp[tmp-1][1]) {
				//System.out.println(cp[tmp-1][1]);
				H-=cp[tmp-1][1];
				long kaisu=(H+max-1)/max;
				System.out.println(kaisu+tmp);
			}
			else {
				long[] sm=new long[tmp];
				for(int i=0; i<tmp; i++) {
					sm[i]=cp[i][1];
				}
				long kaisu=lowerBound(sm,H);
				System.out.println(kaisu+1);
			}
		}
		else {
			System.out.println((H+max-1)/max);
		}

	}
	static void quick_sort(long[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		long p = d[(left+right)/2][0];
		int l = left, r = right;
		long tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
	public static final int lowerBound(final long[] arr, final long value) {
		int low = 0;
		int high = arr.length;
		int mid;
		while (low < high) {
			mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
			if (arr[mid] < value) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}
		if(low<arr.length) {
			return low;
		}
		else {
			return -1;
		}
	}
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int enum_divisors(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    return res.size();
}

int main(){
    bool ans[200];
    rep(i,200){
        if(i%2==0){
            if(enum_divisors(i+1)==8)
                ans[i] = true;
            else
                ans[i] = false;
        }else{
            ans[i] = false;
        }
    }

    int n;  cin >> n;
    int a(0);
    for(int i=0;i<n;i++)
        if(ans[i])  a++;

    cout << a << endl;

    return 0;
}

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



int main() {
    set<char> a;
    string s;
    cin >> s ;
    for(char x: s)
    {
        a.insert(x);
    }
    if (size(s) == size(a))
        cout << "yes" << endl;
    else
        cout << "no" << endl;
    
    return 0;
}


Measured memory_bytes: 3608
X, Y, A, B, C = map(int, input().split())
p_array = list(map(int, input().split()))
q_array = list(map(int, input().split()))
r_array = list(map(int, input().split()))

p_array.sort(reverse=True)
q_array.sort(reverse=True)
r_array.sort(reverse=True)

ans = 0
pq_array = []
for p in p_array[:X]:
    ans += p
    pq_array.append(p)

for q in q_array[:Y]:
    ans += q
    pq_array.append(q)

pq_array.sort()

# print(pq_array)
for i, pq in enumerate(pq_array):
    if i != C and pq < r_array[i]:
        ans -= pq
        ans += r_array[i]
    else:
        break
print(ans)


Measured memory_bytes: 110828
// C - Different Strokes
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vector<ll> V(N);
	ll ans = 0;
	rpz(i, N){
		ll a,b; cin>>a>>b;
		V[i] = a + b;
		ans -= b;
	}
	sort(allr(V));
	for(int i=0; i<N; i+=2) ans += V[i];
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int n, l, b = 0;
    cin >> n >> l;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int mx = a[0] + a[1];

    rep(i, n - 1) if (a[i] + a[i + 1] > mx)
    {
        b = i;
        mx = a[i] + a[i + 1];
    }

    if (mx < l)
        cout << "Impossible" << endl;
    else
    {
        cout << "Possible" << endl;
        for (int i = 1; i < b + 1; i++)
            cout << i << endl;
        for (int i = n - 1; i > b; i--)
            cout << i << endl;
    }


    return 0;
}


Measured memory_bytes: 1280
iN = int(input())
iT,iA = [int(_) for _ in input().split()]
aH = list(map(lambda x: abs(iT-x*0.006 -iA) , [int(_) for _ in input().split()]))
iMin = min(aH)
for i in range(iN):
    if aH[i] == iMin :
        print(i+1)
        exit()


Measured memory_bytes: 3060
N, Y = map(int, input().split())
x = -1
y = -1
z = -1
for i in reversed(range(N + 1)):
	cnt = Y - 10000*i
	if cnt < 0:
		continue
	else:
		for j in range(N + 1 - i):
			ans = cnt - 5000*j - 1000*(N - i - j)
			if ans == 0:
				x = i
				y = j
				z = N - i - j
				break
			elif ans < 0:
				break
print(x, y, z)


Measured memory_bytes: 3064
three_num = input()
three_num = [int(i) for i in three_num.split(" ")]

a = three_num[0]
b = three_num[1]
c = three_num[2]

cnt = 0

for i in range(a, b + 1):
    if c % i == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 7680
#include <iostream>
#include <vector>
using namespace std;
#define MAX 50

int c[MAX][MAX];

void dfs(int w, int h, int x, int y);
int main(int argc, char const *argv[]){
    int w, h, ans;

    while (cin>>w>>h, w || h){
        ans = 0;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                cin>>c[i][j];
            }
        }
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (c[i][j] == 1){
                    dfs(w, h, j, i);
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

void dfs(int w, int h, int x, int y){
    int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
    int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
    c[y][x] = 0;

    for (int i = 0; i < 8; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (0 <= nx && nx < w && 0 <= ny && ny < h && c[ny][nx] == 1){
            dfs(w, h, nx, ny);
        }
    }
    return;
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<ll> a(n);
    rep(i, n) a[i] = i + 1;
    ll cnt = 0;
    ll pidx = -1, qidx = -1;
    do {
        if (pidx == -1) {
            bool f = true;
            rep(i, n) {
                if (p[i] != a[i]) {
                    f = false;
                    break;
                }
            }
            if (f) pidx = cnt;
        }
        if (qidx == -1) {
            bool f = true;
            rep(i, n) {
                if (q[i] != a[i]) {
                    f = false;
                    break;
                }
            }
            if (f) qidx = cnt;
        }
        cnt++;
    }
    while(next_permutation(all(a)));
    cout << abs(pidx - qidx) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
string s;
int ok,i;
int main()
{
    cin>>s;ok=0;
    for(i=0;i<s.size()-1;i++)
        if(s[i]=='A'&&s[i+1]=='C')
         ok=1;
    if(ok) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2019-02-03
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll power(ll a, ll r) {
    ll sum = 1;
    while (r > 0) {
        if ((r & 1) == 1) {
            sum *= a;
        }
        a *= a;
        r >>= 1;
    }
    return sum;
}

ll solve(ll N, ll X){
    ll len_n_1 = 4 * power(2, N-2) - 3;
    if(N == 1 && X == 1) return 1;
    if(X <= 1) return 0;
    else if(X <= len_n_1 + 1) return solve(N-1, X-1);
    else if(X == len_n_1 + 2) return 1 + 2 * power(2, N-2) - 1;
    else if(X <= 2 * len_n_1 + 2) return 1 + 2 * power(2, N-2) - 1 + solve(N-1, X-len_n_1-2);
    else return 2 * power(2, N-1) - 1;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N; cin >> N;
    ll K; cin >> K;

    cout << solve(N+1, K) << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int a= sc.nextInt();
        int b = sc.nextInt();
        System.out.println((h-a)*(w-b));
    }
}


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

int main(){
    string s;
    cin>>s;
    map<int,int> m;
    for(int i = 0 ; i < s.size() ; i++)
        m[s[i]-'a']++;

    bool exist = false;
    for(int i = 0 ; i < 26 ; i++){
        if(m[i] == 0){
            cout<<char(i+'a');
            exist = true;
            break;
        }
    }
    if(!exist)
        cout<<"None";
}

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

int main()
{
    double a , b ;
    while(scanf("%lf",&a)!=EOF)
    {
       a=a/9.8 ;
       a=4.9*a*a ;
       a=((a+5)/5.0) ;
       a=ceil(a) ;
       printf("%.0lf\n",a) ;
    }
    return 0 ;
}

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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
const int N=10001;
int fac[N],inv[N];
int32_t main()
{
    fast
    fac[0]=1;
    f(i,1,N-1)
        fac[i]=(fac[i-1]*i)%mod;
    f(i,0,N-1)  inv[i]=power(fac[i],mod-2,mod);
    int n,ans=0;  cin>>n;
    f(i,1,n){
        int x=n-i*3;
        if(x<0) break;
        int temp=fac[x+i-1];
        temp=(temp*inv[x])%mod;
        temp=(temp*inv[i-1])%mod;
        ans=(ans+temp)%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 3812
nums = list(map(int, input().split()))
orders = list(map(int, input().split()))
su1 = list(map(int, input().split()))
su2 = list(map(int, input().split()))

total = 0
lastmeal = 0
for i, num in enumerate(orders):
    if i==0:
        total += su1[num-1]
    else:
        if 1 == num - lastmeal and lastmeal != len(su2)+1:
            total += su1[num-1] + su2[lastmeal-1]
        else:
            total += su1[num-1]
    lastmeal = num
print (total)


Measured memory_bytes: 3064