akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
const long double PI = 3.14159265359;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
		string t; cin >> t;
	string tmp = t.substr(0,n/2), tmp2 = t.substr(n/2,n/2);
	if (tmp == tmp2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 300005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int a[MN],q[MN],tp,hd,tl,n;
int main()
{
	n=in();hd=tp=1;
	for (int i=1;i<=n;++i) a[i]=in();
	for (int i=1;i<=n;++i)
	if ((a[i]^i)&1) {printf("No");return 0;}
	for (int i=1;i<=n;++i){
		tp=min(tp,i); 
		if((a[i]-tp)&1){if(a[i]!=i){printf("No");return 0;}}
		else if (hd>tl||q[tl]<a[i]) q[++tl]=a[i];
		else if (a[i]==tp) tp+=2;
		else {printf("No");return 0;}
		while (hd<=tl&&q[hd]==tp) tp+=2,++hd;
	}printf("Yes");return 0;
}

Measured memory_bytes: 2560
nn, kk = gets.split.map(&:to_i)
ss = gets.chomp

if nn==1
  puts 0
  exit
end

sum = 0
prev = 'R'
c1 = ss[0]=='R' ? 'R' : 'L'
c2 = ss[0]=='R' ? 'L' : 'R'

# 最後以外カウント
0.upto(nn-2) do |n|
  if ss[n]=='R' && ss[n+1]=='R'
    sum+=1
  elsif ss[n]=='L' && prev=='L'
    sum+=1
  end
  prev = ss[n]
end
# 最後
if ss[-1]=='L' && ss[-2]=='L'
  sum+=1
end

#RLの数
cnt = ss.scan(/#{c1}#{c2}/).size

#補正
edge_cnt = 0
if ss[0]=='R'
  if ss[-1]=='L'
    cnt-=1
    edge_cnt+=1
  end
else #ss[0]=L
  if ss[-1]=='R'
    cnt-=1
    edge_cnt+=1
  end
end
inc = 0

if cnt >= kk
  inc = kk*2
else
  kk -= cnt
  inc = cnt * 2 + [kk,edge_cnt].min
end
puts sum + inc


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

using namespace std;

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

ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    ll r = a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    ll num = 2;
    ll ans = 1;

    while(num*num <= g){
        if(g%num==0){
            ans++;
            while(g%num==0)g/=num;
        }
        num++;
    }
    if(g != 1)ans+=1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0; i<s.length(); i++)
	{
		int x = (int)s[i]-(int)'A';
		x+=n;
		x%=26;
		s[i] = (char)((int)'A'+x);
	}
	cout<<s<<endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	count := 0
	for i := 0; i <= n-3; i++ {
		if str[i:i+3] == "ABC" {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        //入力処理
        int[] input = new int[5];
        for (int i = 0; i < 5; i++)
        {
            input[i] = int.Parse(ReadLine());
        }

        //最小値の位置
        int minIndex = 0;
        //最小値(の候補)
        int min = 10;
        for (int i = 0; i < 5; i++)
        {
            //余り＝1の位を計算
            int amari = input[i] % 10;
            //余りが0の場合は適さない。余りがそれ以外で「暫定最小値」
            //より小さければ最小値候補を更新
            if (amari != 0 && amari < min)
            {
                min = amari;
                minIndex = i;
            }
        }

        //答え用変数
        int result = 0;
        //実際に合計を計算する。
        for (int i = 0; i < 5; i++)
        {
            //最小値の場合、最後にオーダーするので次の10の倍数の
            //時刻を待つ必要はないのでそのまま足す
            if (i == minIndex)
            {
                result += input[i];
            }
            //10で割り切れる数ならば切り上げを行わない
            else if (input[i] % 10 == 0)
            {
                result += input[i];
            }
            //それ以外なら切り上げて足す
            else
            {
                result += input[i] / 10 * 10 + 10;
            }
        }
        //答えの表示
        WriteLine(result);
        //待機(デバッグ用)
        ReadKey();
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




vector<LL> fact;
vector<LL> inver(200001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 
LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}
vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}

vector<LL> pdivi(LL K){
    vector<LL> v;
    for(int i=2;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        while(K%i==0){
            K/=i;
        }
    }
    if(K!=1) v.pb(K);
    return v;
}





int main(){
    set_combi();
    int n,m,k;cin >> n >> m >> k;
    LL ans = 0;
    LL l=0,r=m-1;
    for (int i = 0; i < m; i++) {
        ans=(ans+n*n%mod*((i-l)*(i-l+1)/2+(r-i)*(r-i+1)/2))%mod;

    }
    r=n-1;
    for (int i = 0; i < n; i++) {
        ans=(ans+m*m%mod*((i-l)*(i-l+1)/2+(r-i)*(r-i+1)/2))%mod;
    }
    cout << (ans*inver[2]%mod*combi(n*m-2,k-2))%mod << endl;
    return 0;
}


Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
#include <functional>
#include <map>
#include <cstdio>
#include <stack>
using namespace std;
typedef long long ll;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

class Unionfind{
    public:
    vector<int> par,rank;

    Unionfind(int n){
        par.resize(n);
        rank.resize(n);
        rep(i,n){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    Unionfind uf(n);
    int ans = 0,cnt=0;

    vector<int> p;
    int val;
    rep(i,n){
        cin >> val;
        val--;
        p.push_back(val);
    }

    int x,y;
    rep(i,m){
        cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }

    rep(i,n){
        if(p[i] == i){
            ans++;
        }
    }

    rep(i,n){
        if(uf.same(i,p[i]) && p[i] != i) ans++;
    }

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


Measured memory_bytes: 1660
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int r,D;
    int x;
    int before_x;
    cin >> r >> D >> x;
    before_x = x;
    for (int i = 1;i <= 10; i++){
        before_x = r*before_x - D;
        cout << before_x << endl;
    }
    return 0;
}


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

struct point{
  double x;
  double y;
};

double area(struct point a,struct point b,struct point c){
  double s,z;
  double k,l,m;
  k=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  l=sqrt((a.x-c.x)*(a.x-c.x)+(a.y-c.y)*(a.y-c.y));
  m=sqrt((c.x-b.x)*(c.x-b.x)+(c.y-b.y)*(c.y-b.y));
  z=(k+l+m)/2;
  s=sqrt(z*(z-k)*(z-l)*(z-m));
  return s;
}

int main(void){
  struct point p[30];
  int n=0,i;
  double ans=0;
  while(scanf("%lf,%lf",&p[n].x,&p[n].y)!=EOF){
    n++;
  }
  for(i=2;i<n;i++){
    ans+=area(p[0],p[i-1],p[i]);
  }
  printf("%.6f\n",ans);
  return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(void){
    int N;
    cin >> N;
    cout << N*N*N <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

const int MAX = 1e5 + 5;

vector<pair<ll, ll>> g[MAX];
int ans[MAX];

void dfs(int v, int p = -1)
{
    for (auto to : g[v])
        if (to.first != p)
        {
            ans[to.first] = ans[v] ^ to.second;
            dfs(to.first, v);
        }
}

void solve()
{
    int n;
    cin >> n;
    rep1(i, n)
    {
        int a, b, w;
        cin >> a >> b >> w;
        g[a].push_back({b, w & 1});
        g[b].push_back({a, w & 1});
    }
    dfs(1);
    rep1(i, n + 1)
    {
        cout << ans[i] << endl;
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int x, y, z;
    sc(x) sc(y) sc(z)
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 764
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,k) = scan "%d %d" Tuple2.make

let () =
  let open ModOp in
  ListL.map (k++(succ n)) ~f:(fun i->
      n*i - i*(pred i) + 1
    )|> ListL.fold_left ~init:0 ~f:(+)
  |> Printf.printf "%d\n"


Measured memory_bytes: 14940
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      s: chars,
    }

    const MOD: usize = 998244353;
    let mut ans = 1;

    let mut cnt = vec![0; 3];
    for c in s {
        let idx = match c {
            'R' => 0,
            'G' => 1,
            'B' => 2,
            _  => unreachable!()
        };
        cnt[idx] += 1;

        let mut temp = cnt.clone();
        temp.sort();

        if cnt.iter().all(|&v| v > 0) {
            ans *= temp[1];
            ans %= MOD;
            for i in 0..3 {
                cnt[i] -= 1;
            }
        } else if cnt[idx] == temp[2] {
            // Noop
        } else if cnt[idx] == temp[1] {
            ans *= (temp[2] - temp[1]) + 1;
            ans %= MOD;
        } else {
            unreachable!();
        }
    }

    for i in 0..n {
        ans *= i+1;
        ans %= MOD;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == ',')
            cout << ' ';
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }.sort
b = gets.to_s.split.map{|t| t.to_i }.sort
c = gets.to_s.split.map{|t| t.to_i }.sort

ans = i = j = 0

b.each do |m|
  
  while i < n && a[i] < m
    i += 1
  end
  
  while j < n && c[j] <= m
    j += 1
  end
  
  ans += i * (n-j)
  
end

puts ans

Measured memory_bytes: 24688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll md = 1000000007;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
vl pr;

inline ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

inline ll mul(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	cout << ((n + 1000 - 1)/1000)*1000 - n << "\n";
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  int ans = 0;
  ans += (n / 11)*2;
  n %= 11;
  if(n >= 6){
    ans++;
    n -= 6;
  }
  if(n > 0){
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n, d;
    cin >> n >> d;

    priority_queue<tuple<int,bool,int>, vector<tuple<int,bool,int>>, greater<tuple<int,bool,int>>> que;
    vector<int> x(n), y(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> y[i] >> b[i];
        que.emplace(b[i], false, i);
        que.emplace(b[i] + d, true, i);
    }
    i64 ans = 0;
    multiset<int> sx, sy;
    while(!que.empty()){
        int idx;
        bool is_delete;
        tie(ignore, is_delete, idx) = que.top();
         que.pop();
        if(is_delete){
            sx.erase(sx.find(x[idx]));
            sy.erase(sy.find(y[idx]));
        }
        else{
            sx.insert(x[idx]);
            sy.insert(y[idx]);
        }
        if(!sx.empty()){
            chmax(ans, 1LL * (*sx.rbegin() - *sx.begin()) * (*sy.rbegin() - *sy.begin()));
        }
    }
    cout << ans << endl;

}




Measured memory_bytes: 28576
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    
    string ans = "";
    if(s.front()=='A')s.erase(s.begin());
    if(s.back()=='A')s.pop_back();
    if(s=="KIHBR"||s=="KIHBAR"||s=="KIHABR"||s=="KIHABAR")cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
n,k=map(int,input().split())
x=[]
y=[]
xy=[]
for _ in range(n):
  xx,yy=map(int,input().split())
  xy.append((xx,yy))
  x.append(xx)
  y.append(yy)
xx=sorted(x)
yy=sorted(y)
ans=10**20
for sxi in range(n-1):
  for syi in range(n-1):
    for tyi in range(1,n):
      sx,sy,ty=xx[sxi],yy[syi],yy[tyi]
      ax=sorted([xxx for xxx,yyy in xy if sx<=xxx and sy<=yyy<=ty])
      if len(ax)<k:continue
      tx=ax[k-1]
      ans=min(ans,(tx-sx)*(ty-sy))
print(ans)

Measured memory_bytes: 9148
<?php
	fscanf(STDIN, "%d", $payment);
	fscanf(STDIN, "%d", $coin);
	if($coin === 0 && $payment % 500 !== 0){
		echo 'No';
	}else if($payment % 500 === 0){
		echo 'Yes';
	}else{
		$pay = $payment % 500;
		if(($coin - $pay) >= 0){
			echo 'Yes';
		}else{
			echo 'No';
		}
	}
?>

Measured memory_bytes: 4604
#include <stdio.h>

int main(void){
    int n,x,t,ans;
    scanf("%d %d %d", &n,&x,&t);
    if(n%x == 0) ans = (n/x)*t;
    else ans = (n/x +1)*t;

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


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

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;
const LL mod=1e9+7;

using namespace std;


LL n,k,fact[KL],a[KL];

LL power(LL u,LL v,LL prime)
{
    if(v==0)return 1;
    LL ret=power(u,v/2,prime)%prime;
    ret=(ret*ret)%prime;
    if(v%2==1)ret=(ret*u)%prime;
    return ret;
}

LL mod_inverse(LL u,LL prime)
{
    LL ret=power(u,prime-2,prime);
    return ret;
}

LL division_mod(LL u,LL v,LL prime)
{
    LL ret=mod_inverse(v,prime);
    ret=(ret*u)%prime;
    return ret;
}
LL co(LL u,LL v)
{
    LL y=(fact[v]*fact[u-v])%mod;
    LL x=fact[u];
    return division_mod(x,y,mod);

}

int main()
{
    scl(n);scl(k);fact[0]=1;
    for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%mod;
    LL sum=0;
    for(int i=1;i<=n;i++)
    {
        scl(a[i]);
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        if(i>=k)
        {
            LL ans=(a[i]+mod)%mod;
            ans=(ans*co(i-1,k-1))%mod;
            sum=(sum+ans)%mod;
        }
        if(i<=n-k+1)
        {
            LL ans=(a[i]+mod)%mod;
            ans=(ans*co(n-i,k-1))%mod;
            ans=mod-ans;
            sum=(sum+ans)%mod;
        }
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 5120
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;
int ans, cnt;
ll score;
int main() {
    int D;
    ll G;
    cin >> D >> G;
    vector<int> p(D);
    vector<int> c(D);
    rep(i, D) cin >> p[i] >> c[i];
    ans = INF;
    for (int t = 0; t < (1 << D); ++t) {
        cnt = 0;
        score = 0;
        for (int i = 0; i < D; ++i) {
            if (t & (1 << i)) {
                score += c[i] + (i+1)*p[i]*100;
                cnt += p[i];
            }
        }
        if (score >= G) {
            ans = min(ans, cnt); 
            continue;
        }
        else {
            for (int i = D-1; i >= 0; --i) {
                if (!(t & (1 << i))) {
                    rep(j,p[i]-1) {
                        score += (i+1)*100;
                        ++cnt;
                        if (score >= G) {
                            ans = min(ans, cnt);
                            break;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}























Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	array<int, 3> s = { a,b,c };
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size()-1; i++)
	{
		cout << s.at(i) << " ";
	}
	cout << s.at(s.size() - 1) << "\n";
	return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

int N,A,B,C;
int D[10];

int dfs(int a,int b,int c,int all) {
    if(all == N) {
        if(a == 0 || b == 0 || c == 0) {
            return INF;
        }
      	else {
        	return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
    }
    int ret = INF;
    ret = min(ret,dfs(a + D[all],b,c,all + 1) + 10);
    ret = min(ret,dfs(a,b + D[all],c,all + 1) + 10);
    ret = min(ret,dfs(a,b,c + D[all],all + 1) + 10);
    ret = min(ret,dfs(a,b,c,all + 1));
  	return ret;
}

signed main() {
    cin >> N >> A >> B >> C;
    for(int i = 0;i < N;i++) {
        cin >> D[i];
    }
    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp24
{
    class Program
    {
        static void Main(string[] args)
        {
            bool isShiritori = false;
            string[] cin = Console.ReadLine().Split(' ');
            if (cin[0][cin[0].Length - 1] == cin[1][0] && cin[1][cin[1].Length - 1] == cin[2][0])
            {
                isShiritori = true;
            }

            if (isShiritori)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < (n);++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  int n,k;cin>>n>>k;
  vector<ll> h(n);rep(i,n)cin>>h[i];
  vector<ll> dp(n+100,INF);
  dp[0] = 0;
  for(int i = 0;i < n;++i){
    for(int j = 1;j <= k;++j){
      	dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i + j]));
    }
  }
  
  print(dp[n-1]);
  return 0;
}

Measured memory_bytes: 1792
N,M,*A = `dd`.split.map &:to_i
s = 0
ct = { 0 => 1 }
ans = 0
A.each{ |a|
  s = (s + a) % M
  ans += (ct[s] || 0)
  ct[s] = (ct[s] || 0) + 1
}
p ans

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

int main(void)
{
	int n, x=1, i;
	double t, a, f, h[1000];
	scanf("%d", &n);
	scanf("%lf%lf", &t, &a);
	for (int i = 0; i < n; i++)
	{
		scanf("%lf", &h[i]);
	}

	f = fabs(a-t+h[0]*0.006);
	for (int i = 1; i < n; ++i)
	{
		if (fabs(a-t+h[i]*0.006) < f)
		{
			f = fabs(a-t+h[i]*0.006);
			x = i+1;
		}
	}
	printf("%d\n", x);
	return 0;
}

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

int main(){
   ll h,w;
   cin>>h>>w; 
   if(h==1||w==1){
       cout<<1<<endl;
       return 0;
   }
   cout<<h*w/2+(h%2*w%2)<<endl;
   return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
t = [list(input()) for _ in range(H)]
udlr = [[-1, 0],[ 1, 0],[ 0,-1],[ 0, 1]]
#[print(line) for line in t];print()

exist_F_count = 0
for i in range(H):
    for j in range(W):
        if t[i][j] == "#":
            exist = False
            for x,y in udlr:
                if (0 <= i+x < H) and (0 <= j+y < W):
                    if t[i+x][j+y] == "#":
                        exist = True
                        break
            if exist == False:
                exist_F_count += 1
                print("No")
                exit()
if exist_F_count == 0:
    print("Yes")

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int H, W;
string field[1000];
ll dp[1000][1000];	//頂点(h, w)からのたどり着き方の総数

ll dfs(int h, int w)
{
	if (dp[h][w] != -1) {
		return dp[h][w];
	}
	dp[h][w] = 0;

	//壁か
	if (field[h][w] == '#') {
		return dp[h][w];
	}

	//ゴール地点か
	if (h + 1 == H && w + 1 == W) {
		return dp[h][w] = 1;
	}

	//探索
	if (h + 1 < H) {
		dp[h][w] += dfs(h + 1, w);
	}
	if (w + 1 < W) {
		dp[h][w] += dfs(h, w + 1);
	}

	return dp[h][w] % 1000000007;
}

int main()
{
	cin >> H >> W;
	for (int h = 0; h < H; ++h) {
		cin >> field[h];
	}
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			dp[h][w] = -1;
		}
	}
	ll ans;
	ans = dfs(0, 0);
	cout << ans << endl;
	return 0;
}


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


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

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

	for (int i = 0; i < n; i++) {
		int num = a[i];
		while (num%2==0) {
			count++;
			num /= 2;
			}
	}

	cout << count << endl;

	return 0;
}




Measured memory_bytes: 256
n, m = gets.split(" ").map(&:to_i)
ans = Array.new(n, nil)

m.times do 
  s, c = gets.split(" ").map(&:to_i)
  s -= 1
  if ans[s] && ans[s] != c
    puts -1
    exit
  end
  ans[s] = c
end

if n >= 2 && ans[0].nil?
    ans[0] = 1
end

if n >= 2 && ans[0] == 0
    puts '-1'
    exit
end

ans.each{|a| print a ? a : 0}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7


#define GIRI 0
#define LESS 1

ll dp[100005][2];

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


	dp[0][GIRI] = 1;

	rep(i, L.size()) {
		ll num = L[i] - '0';
		if(num == 1) {
			dp[i+1][GIRI] += 2 * dp[i][GIRI];
			dp[i+1][GIRI] %= DIV;

			dp[i+1][LESS] += dp[i][GIRI];
			dp[i+1][LESS] %= DIV;

			dp[i+1][LESS] += 3 * dp[i][LESS];
			dp[i+1][LESS] %= DIV;

		} else {
			dp[i+1][GIRI] += dp[i][GIRI];
			dp[i+1][GIRI] %= DIV;

			dp[i+1][LESS] += 3 * dp[i][LESS];
			dp[i+1][LESS] %= DIV;
		}
	}
	cout << (dp[L.size()][0] + dp[L.size()][1])%DIV << endl;


}


Measured memory_bytes: 5296
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

int col(int r)	{
	if(r>=3200)	return -1;
	if(r>=2800)	return 1;
	if(r>=2400)	return 2;
	if(r>=2000)	return 3;
	if(r>=1600)	return 4;
	if(r>=1200)	return 5;
	if(r>=800)	return 6;
	if(r>=400)	return 7;
	if(r>=1)	return 8;
	return 0;
}

void solve()	{
	int n;
	cin >> n;
	set<int> min;
	set<int> max;
	int f=0;
	for(int i=0; i<n; i++)	{
		int x;
		cin >> x;
		int c=col(x);
		if(c==-1)	max.insert(i+1000);
		else {
			f=1;
			max.insert(c);
			min.insert(c);
		}
	}
	if(f)	cout << min.size() << " " << max.size() << endl;
	else cout << 1 << " " << max.size() << endl;
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    long ans = 0, d = 0;
    for (int i = 1; i <= n; i++){
        ans += (i % k == 0);
        if (k % 2 == 0){
            if (i % (k / 2) == 0 && i % k != 0) d++;
        }
    }
    cout << ans * ans * ans + d * d * d << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (n < 2 || m < 2) {
            if (n == 1 && m == 1) {
                System.out.println(1);
            } else {
                long l = Math.max(n, m);
                System.out.println(l - 2);
            }
        } else {
            System.out.println((n - 2) * (m - 2));
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <deque>

using namespace std;

int main() {
	int N;
	vector<int> v;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	deque<int> d;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			d.push_back(v[i]);
		}
		else {
			d.push_front(v[i]);
		}
	}
	if (N % 2 == 0) {
		cout << d[0];
		for (int i = 1; i < N; i++) {
			cout << " " << d[i];
		}
		cout << endl;
	}
	else {
		cout << d[N-1];
		for (int i = N-2; i >= 0; i--) {
			cout << " " << d[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

struct UnionFind {
    vector<ll> parent;

    UnionFind(ll n) {
        parent.resize(n, -1);
    }

    ll find(ll x) {
        // 自身が根っこの場合
        if (parent[x] == -1) {
            return x;
        }
        return parent[x] = find(parent[x]);
    }

    void unite(ll x, ll y) {
        ll root_x = find(x);
        ll root_y = find(y);
        // 同じ素集合にいたら何もしない
        if (root_x == root_y) return;
        parent[root_x] = root_y;
    }
};

int main() {
    ll n, m; cin >> n >> m;
    vector<vector<ll>> G(n);
    ll a, b;

    UnionFind uf(n);

    for (int i = 0; i < m; ++i) {
        cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        uf.unite(a, b);
    }

    map<ll, ll> mp;
    for (int i = 0; i < n; ++i) {
        ll parent = uf.find(i);
        if (mp.count(parent) == 0) mp[parent] = 0;
        mp[parent]++;
    }

    ll ans = 0;
    for (auto i: mp) {
        ans = max(ans, i.second);
    }
    cout << ans << endl;
}

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

int main() {
	long long N;
	std::cin >> N;

	std::vector<long long> cost(5);
	for(int i = 0; i < cost.size(); i++) {
		std::cin >> cost[i];
		if(i != 0) {
			// Example: 52413 -> 52211
			if(cost[i - 1] < cost[i]) {
				cost[i] = cost[i - 1];
			}
		}
	}

	long long result = N / cost.back();
	if(N % cost.back() != 0) {
		result++;
	}
	result += 4;

	std::cout << result << std::endl;

	return 0;
}


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

#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

const int inf = 100001;

int main(void) {
	int n, m, r;
	cin >> n >> m >> r;

	vector<vector<long long int>> dist(n, vector<long long int>(n, 1e9));
	vector<int> rs(r);

	rep(i, r) {
	  cin >> rs[i];
		rs[i]--;
	}

	rep(i, m) {
	  int a,b,c;
		cin >> a >> b >> c;
		a--; b--; //0-index
		dist[a][b] = c;
		dist[b][a] = c;
	}

	rep(i,n) dist[i][i] = 0;

	rep(k, n) rep(i, n) rep(j, n) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	}

	long long int ans = 1e9;

	sort(rs.begin(),rs.end());
	do {
		long long int tans = 0;
		rep(i, r - 1) {
			tans += dist[rs[i]][rs[i + 1]];
		}
		ans = min(tans, ans);
	} while (next_permutation(rs.begin(), rs.end()));

	cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

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

	int r = 0;
	int i = L;
	while(i != 1) {
		i /= 2;
		r += 1;
	}

	int N = r + 1;
	vector<vector<int>> result;
	vector<int> hen(3, 0);
	for(int i = 1; i < N; i++) {
		hen[0] = i; hen[1] = i + 1; hen[2] = 0;
		result.push_back(hen);
		hen[2] = (int)pow(2, (double)i-1);
		result.push_back(hen);
	}

	for(int i = r; i > 0; i--) {
		if(L - pow(2, (double)r) >= pow(2, (double)i-1)){
			L -= pow(2, (double)i-1);
			hen[0] = i; hen[1] = N; hen[2] = L;
			result.push_back(hen);
		}
	}

	cout << N << " " << result.size() << endl;
	for(int i = 0; i < result.size(); i++)
		cout << result[i][0] << " " << result[i][1] << " " << result[i][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll n,c;
    cin >> n >> c;
    vector<ll> x(n+1),v(n+1);
    reps(i,1,n+1){
        cin >> x[i] >> v[i];
    }
    ll ans = 0;

    ll cal = 0;
    ll tmp_cal_max = 0;
    vector<ll> cal_max(n+1);
    reps(i,1,n+1){
        cal += (v[i]-(x[i]-x[i-1]));
        if(cal > tmp_cal_max){
            tmp_cal_max = cal;
        }
        cal_max[i] = tmp_cal_max;
    }
    ans = max(ans,cal_max[n]);

    ll reverse_cal = 0;
    repr(i,n,1){
        if(i==n){
            reverse_cal = v[n]-2*(c-x[n]);
        }else{
            reverse_cal += v[i]-2*(x[i+1]-x[i]);
        }
        ll tmp_ans = reverse_cal +cal_max[i-1];
        ans = max(ans,tmp_ans);
    }

    cal = 0;
    tmp_cal_max = 0;
    cal_max.assign(n+1,0);
    repr(i,n,0){
        if(i==n){
            cal += v[n]-(c-x[n]);
        }else{
            cal += (v[i]-(x[i+1]-x[i]));
        }
        if(cal > tmp_cal_max){
            tmp_cal_max = cal;
        }
        cal_max[i] = tmp_cal_max;
    }
    ans = max(ans,cal_max[1]);

    reverse_cal = 0;
    reps(i,1,n){
        reverse_cal += v[i]-2*(x[i]-x[i-1]);
        ll tmp_ans = reverse_cal +cal_max[i+1];
        ans = max(ans,tmp_ans);
    }
    

    cout << ans;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    sort(A.rbegin(),A.rend());
    ll ans = 0;
    for (int i=0;i<N;i++){
        if (i==0) continue;
        if (i==1) ans += A[0];
        if (i>1) ans += A[i/2];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4784
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
a_list_2 = a_list + a_list
first_count = 0
p = 10**9 + 7
for i in range(n-1):
  for j in range(i+1,n):
     if  a_list[j] < a_list[i]:
      first_count += 1
second_count = 0    
for a in a_list:
  for i in range(n):
    if a > a_list[i]:
      second_count += 1
ans = first_count * k  +  (k-1) * k * second_count //2
print(ans % p)
    

  


Measured memory_bytes: 3188
a, b, c, x = [int(input()) for _ in range(4)]

count = 0
for i in range(a, -1, -1):
    i_tmp = i * 500
    if i_tmp > x:
        continue
    for j in range(b, -1, -1):
        j_tmp = j * 100 + i_tmp
        if j_tmp > x:
            continue
        for k in range(c, -1, -1):
            sum = k * 50 + j_tmp
            if sum == x:
                count += 1

print(count)

Measured memory_bytes: 3064
import sys
from heapq import heappush, heappop

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    heap = []
    for i, a in enumerate(A, start=1):
        heappush(heap, (a, i))
    
    ans = []
    while heap:
        _, a = heappop(heap)
        ans.append(a)

    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 23204
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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 main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	int mx = (n - 1) * (n - 2) / 2;
	if (k > mx) {
		cout << -1 << endl;
		return 0;
	}

	int add = mx - k;
	vector<P> ans;
	for (int i = 1; i <= n - 1; i++) {
		ans.push_back(P(i, n));
	}
	vector<P> edge;
	for (int i = 1; i <= n - 1; i++) {
		for (int j = i + 1; j <= n - 1; j++) {
			edge.push_back(P(i, j));
		}
	}
	for (int i = 0; i < add; i++) {
		ans.push_back(edge[i]);
	}
	cout << ans.size() << endl;
	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool dfs(int id,vector<vector<int> >& g,vector<bool>& vis,int& e,int& o){
  vis[id]=true;
  for(int i=0;i<g[id].size();i++){
       if(!vis[g[id][i]]){
           int e1=0;
           int o1=0;
           bool is=dfs(g[id][i],g,vis,e1,o1);
           if(is)
              return true;
           if(e>0){
              if(e1>0){
                 return true;
              }
           }
           if(o>0){
             if(o1>0){
                return true;
             }
           }
           o+=e1;
           e+=o1;
       }
  }
  if((o==0)&&(e==0)){
       e++;
  }
  return false;
}
void dfs1(int id,vector<vector<int> >& g,vector<bool>& vis,vector<int>& p){
  vis[id]=true;
  for(int i=0;i<g[id].size();i++){
    if(!vis[g[id][i]]){
        p[g[id][i]]=id;
        dfs1(g[id][i],g,vis,p);
    }
  }
}
int main(){
FASTIO
int n;
cin>>n;
string s;
cin>>s;
vector<int> v1(n);
vector<int> v2(n);
vector<int> v3(n);
int l1=0,l2=0,l3=0;
for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='R')
       l1++;
    if(s[i]=='G')
       l2++;
    if(s[i]=='B')
       l3++;
   v1[i]=l1;
   v2[i]=l2;
   v3[i]=l3;        
}
ll ans=0;
for(int i=0;i<n-2;i++){
  for(int j=i+1;j<n-1;j++){
       if(s[i]=='R'){
          if(s[j]=='G'){
             ans+=(ll)(v3[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='B'){
                 ans--;
               }
             }
          } 
          if(s[j]=='B'){
             ans+=(ll)(v2[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='G'){
                 ans--;
               }
             }
          }
       }
       if(s[i]=='G'){
          if(s[j]=='R'){
             ans+=(ll)(v3[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='B'){
                 ans--;
               }
             }
          }
          if(s[j]=='B'){
             ans+=(ll)(v1[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='R'){
                 ans--;
               }
             }
          }
       }
       if(s[i]=='B'){
          if(s[j]=='G'){
              ans+=(ll)(v1[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='R'){
                 ans--;
               }
             }
          }
          if(s[j]=='R'){
             ans+=(ll)(v2[j+1]);
             int j1=j+(j-i);
             if(j1<n){
               if(s[j1]=='G'){
                 ans--;
               }
             }
          }
       }
  }
}
cout<<ans;
return 0;
}


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

int main() {
  int N, K, count;
  cin >> N >> K;
  
  for(int i; i < N; i++) {
    int h = 0;
  	cin >> h;
    if(h >= K)
      count++;
  }
  cout << count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
int main () {
    long long int n,a,b,x,y,c,d,d1,w,x1;cin>>n>>a>>b;
    x=max(a,b);
    y=min(a,b);
    c=x-y;
    if (c%2==0) {
        cout<<c/2<<endl;
    }
    else {
        d=n-y;
        x1=x-1;
        if (x1>d) {
            d1=n-x;
            w=y+d1+1;
            cout<<d1+1+(n-w)/2<<endl;
        }
        else {
            d1=y-1;
            w=x-d1-1;
            cout<<d1+1+(w-1)/2<<endl;
        }
    }

}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	double a, b, c, d, e, f;

	for ( ; scanf( "%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f ) == 6; printf( "%.3f %.3f\n", ( c * e - b * f ) / ( a * e - b * d ) + 0.000001, ( -c * d + a * f ) / ( a * e - b * d ) + 0.000001 ) ) ;

	return 0;
}

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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2,
                 1, 5, 1, 2, 1, 14, 1, 5, 1, 5,
                 2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
                 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256