akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  for (size_t i = 0; i < n; i++) {
    cin>>v[i];
  }
  for (size_t i = 0; i < n; i++) {
    cin>>c[i];
  }
  for (size_t i = 0; i < n; i++) {
    cin>>v[i];
  }
  for (size_t i = 0; i < n; i++) {
    v[i]-=c[i];
  }
  int a = 0;
  for (size_t i = 0; i < n; i++) {
    if (v[i]>0) {
      a+=v[i];
    }
  }
  cout<<a;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n+1];
    let mut is_prime = vec![true; n+1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n+1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {

            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}

fn main() {
	input! {
		q: usize,
		lr: [(usize, usize); q],
	}


	// 100000までの素数テーブルを作成
	// r1～rqまでの最大値rmaxを求める
	// 0-rmaxまでの各数が2017似数かどうかを求め、
	// 累積和テーブルsを作る
	// あとは各クエリの答えを出力

	let p = sieve_of_eratosthenes(100000);
	let mut pd = vec![false; 100000];
	for i in 0..p.len() {
		pd[p[i]] = true;
	}

	let mut rmax = 0;
	for i in 0..q {
		rmax = max(rmax, lr[i].1); 
	}

	let mut s = vec![0; rmax+1];	// s[0]=0, s[1]=0
	for i in (3..=rmax).step_by(2) {
		if pd[i] && pd[(i+1)/2] {
			s[i] = s[i-2] + 1;
		}
		else {
			s[i] = s[i-2];
		}
	}

	//println!("{:?}", s);

	for i in 0..q {
		let l;
		if lr[i].0 == 1 {
			l = 0;
		}
		else {
			l = lr[i].0 - 2;
		}
		println!("{}", s[lr[i].1] - s[l]);
	}
}



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

using namespace std;
int main() {
	int N;

	int end_a_count = 0;
	int front_b_count = 0;
	int end_a_front_b_count = 0;

	int mid_ab_count = 0;
	cin >> N;

	for (int i = 0; i < N; i ++) {
		string s;
		cin >> s;
		if (s[0] == 'B') {
			if (s[s.size() -1] == 'A') {
				end_a_front_b_count++;
			} else {
				front_b_count++;
			}
		} else if (s[s.size() - 1] == 'A') {
			end_a_count++;
		}
		for (int j = 0; j < s.size() - 1; j++) {
			if (s[j] == 'A' && s[j+1] == 'B') {
				mid_ab_count++;
			}
		}
	}
/*
	cout << "mid_ab_count:" << mid_ab_count << endl;
	cout << "front_b_count:" << front_b_count << endl;
	cout << "end_a_count:" << end_a_count << endl;
	cout << "end_a_front_b_count:" << end_a_front_b_count << endl;
*/

	int total = mid_ab_count;
	if (end_a_count > 0) {
		if (end_a_front_b_count > 0) {
			end_a_count --;
			total += end_a_front_b_count;
			end_a_front_b_count = 0;
			end_a_count++;
		}
	} else {
		if (end_a_front_b_count > 0) {
			total += end_a_front_b_count - 1;
			end_a_front_b_count = 0;
			end_a_count++;
		}
	}

	total += min(end_a_count, front_b_count);
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, m, x;
    cin >> n >> m >> x;

    vector <int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int ans = 1e9;
    for (int i = 0; i < (1 << n); i++) {
        int cost = 0;
        vector <int> sum(m);
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                cost += c[j];
                for (int k = 0; k < m; k++) {
                    sum[k] += a[j][k];
                }
            }
        }

        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (sum[j] < x) {
                ok = false;
            }
        }

        if (ok) {
            ans = min(ans, cost);
        }
    }

    cout << (ans == 1e9 ? -1 : ans) << "\n";
    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>

int main(void)
{
  int n,x;
  int i=0;
  int m[3]={0};

  for(;;){
    scanf("%d %d", &n, &x);
    if(n==0 && x==0) break;
    
    for(m[0]=1;m[0]<n-1;m[0]++){
      for(m[1]=m[0]+1;m[1]<n;m[1]++){
	for(m[2]=m[1]+1;m[2]<n+1;m[2]++){
	  if(m[0]+m[1]+m[2]==x) i++;
	}
      }
    }
    printf("%d\n", i);
    i=0;
  }

  return 0;
}


Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
    int n;
    int cnt1=0,cnt2=0;
    string s1,s2;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s1 >> s2;
        if(s1 > s2){
            cnt1 += 3;
        }
        else if(s1 < s2) {
            cnt2 += 3;
        } else{
            cnt1++;
            cnt2++;
        }
    }
    cout << cnt1 << " " << cnt2 << endl;
}



Measured memory_bytes: 3212
n = int(input())
s = [input().split() for i in range(n)]
b = sum([int(s[i][1]) for i in range(n)])
x = input()
c = 0
for i in range(n):
    c+=int(s[i][1])
    if s[i][0] == x:
        break
print(b-c)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool ok = 1;
  for(int i = 0;i<3;i++){
    if(s[i]==s[i+1]) {
     ok = 0;
      break;
    }
  }
  if(!ok) cout <<"Bad";
  else cout <<"Good";
  return 0;
}

Measured memory_bytes: 256
N = int(input())
Vlist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
sum1 = 0
for i in range(N):
    x = Vlist[i]
    c = Clist[i]
    if x - c > 0:
        sum1 += (x-c)
print(sum1)


Measured memory_bytes: 2940
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut xy: [(i64, i64); n]
    }

    xy.sort();
    let mut ans = 1i128<<100;
    for i in 0..n {
        for j in i+k..n+1 {
            let w = xy[j-1].0 - xy[i].0;
            let mut p = xy[i..j].to_vec();
            p.sort_by_key(|&(_, y)| y);
            for t in 0..p.len()-k+1 {
                let h = p[t+k-1].1 - p[t].1;
                ans = min(ans, w as i128 * h as i128);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int h, w;
char a[500][500];

int main(int argc, char **argv) {
	cin >> h >> w;
	REP(y, h) REP(x, w) cin >> a[x][y];
	REP(y, h) {
		REP(x, w) {
			if (y == 0 || (y != h - 1 && x % 2 == 0)) cout << '#';
			else cout << a[x][y];
		}
		cout << endl;
	}
	cout << endl;
	REP(y, h) {
		REP(x, w) {
			if (y == h - 1 || (y != 0 && x % 2 == 1)) cout << '#';
			else cout << a[x][y];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

int n,m;
int ans;
int a[50],b[50];
int graph[50][50]={0};
int pass[50]={0};
//string s;
void dfs(int p){
	pass[p]=1;
	rep(k,0,n){
		if(graph[p][k]==0) continue;
		if(pass[k]==1) continue;
		dfs(k);
	}
}

signed main(){
	acc_io;
	cin>>n>>m;
	rep(i,0,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=1;
	}
	ans=0;
	rep(i,0,m){
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=0;
		rep(j,0,n) pass[j]=0;
		dfs(0);
		int br=0;
		rep(j,0,n){
			if(pass[j]==0){
				br=1;
				break;
			}
		}
		if(br) ++ans;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

_A = []
for i in range(len(A)):
    _A.append(A[i] - (i + 1))
_A.sort()
median = _A[math.floor(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


Measured memory_bytes: 25964
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int compress( vector< int >& x){
  sort(x.begin(),x.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  return x.size();
}
int calc(vector<vector<int> >& mas,int y, int x, int ny, int nx){
  return mas[ny][nx] + mas[y - 1][x - 1] - mas[y - 1][nx] - mas[ny][x - 1];
}
int main(){
  int n, m;
  vector< int > x, y, cx, cy; //ああ
  const int INF = 1e9 + 1;
  cin >> n >> m;
  x.resize(n + 2), y.resize(n + 2), cx.resize(n), cy.resize(n);
  x[n] = INF, y[n] = INF, x[n + 1] = -INF, y[n + 1] = -INF;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    cx[i] = x[i], cy[i] = y[i];
  }
  static vector< vector< int > > mas( compress(y) + 1, vector< int >( compress(x) + 1, 0));
  for(int i = 0; i < n; i++){
    int yy = lower_bound(y.begin(),y.end(),cy[i])-y.begin();
    int xx = lower_bound(x.begin(),x.end(),cx[i])-x.begin();
    mas[yy][xx]++;
  }
  for(int i = 0; i < mas.size() - 1; i++){
    for(int j = 0; j < mas[i].size() - 1; j++){
      mas[i + 1][j + 1] += mas[i + 1][j] + mas[i][j + 1] - mas[i][j];
    }
  }
  int x1, y1, x2, y2;
  while(m--){
    cin >> x1 >> y1 >> x2 >> y2;
    x1 = lower_bound( x.begin(), x.end(), x1) - x.begin();
    x2 = upper_bound( x.begin(), x.end(), x2) - x.begin() - 1;
    y1 = lower_bound( y.begin(), y.end(), y1) - y.begin();
    y2 = upper_bound( y.begin(), y.end(), y2) - y.begin() - 1;
    cout << calc(mas,y1,x1,y2,x2) << endl;
  }
}

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

using namespace std;

uint64_t gcd(uint64_t one, uint64_t other) {
    uint64_t tmp;
    while (one != 0) {
        if (one > other) swap(one, other);
        tmp = one;
        one = other % one;
        other = tmp;
    }
    return other;
}

uint64_t lcm(uint64_t one, uint64_t other) {
    return one * (other / gcd(one, other));
}

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    int64_t cur;
    vector<int64_t> arr;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

    uint64_t l = arr[0];
    for (int j = 0; j < N; j++) {
        l = lcm(l, arr[j]);
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge{
	int dst;
	ll cost;
	edge(int dst, ll cost){
		this->dst=dst; this->cost=cost;
	}

};

int n;
ll a[55];


int main(){
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	while (1) {
		bool flg = false;
		ll del = 0;

		rep(i, n) {
			if (a[i] / n > 0) {
				del = a[i] / n;
				ans +=del;
				a[i] -= a[i] / n * n;
				rep(j, n) {//
					if (i != j)
						a[j] += del;
				}
			}

		}
		if (del == 0)
			break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
   int H,W;
   while(1){
	   cin>> H >> W;
	   if(W == 0 && H == 0){ break; }
   for (int i=0 ; i<H ; i++){
	   for (int j=0 ; j<W ; j++){
		   if(i==0 || i==H-1 || j == 0 || j==W-1)cout<<"#";
		   else cout <<".";
	   };
	   cout << endl;
   };
   cout << endl;
  }
return 0;
}



Measured memory_bytes: 3076
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  a := make([]int, n)

  max := 0
  cnt := 0
  for i := 0; i < n; i++ {
    sc.Scan()
    a[i], _ = strconv.Atoi(sc.Text())

    if a[i] > max {
      max = a[i]
      cnt = 1
    } else if a[i] == max {
      cnt++
    }
  }

  for i := 0; i < n; i++ {
    if a[i] == max && cnt == 1 {
      tmp := 0
      for j := 0; j < n; j++ {
        if i != j {
          if a[j] > tmp {
            tmp = a[j]
          }
        }
      }
      fmt.Println(tmp)
    } else {
      fmt.Println(max)
    }
  }
}


Measured memory_bytes: 6400
#include <stdio.h>

#define SIZE 2000000

int main() {
  int A[SIZE];
  int H=0;
  int i, key, l, largest, p, tmp;
  char com[20];
  do {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &key);
      A[++H] = key;
      for (i=H,p=i/2; p>0 && A[p]<A[i];i=p,p/=2) {
        tmp = A[p];
        A[p] = A[i];
        A[i] = tmp;
      }
    } else if (com[1]=='x') { // extract
      printf("%d\n", A[1]);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i*2;
        largest = i;
        if (l < H && A[l] > A[i])        largest = l;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (com[2]!='d');
  return 0;
}


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

int main(){
  int n, k, xi;
  int ans = 0;
  cin >> n >> k;

  rep(i, n){
    cin >> xi;
    if(xi < k - xi){
      ans += xi;
    }
    else{
      ans += (k - xi );
    }
  }

  cout << ans * 2 << endl;


}


Measured memory_bytes: 3568
#include<stdio.h>

int main(){
    int m,f,r;
    
    for(;;){
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1)break;
    else if(m==-1||f==-1)printf("F\n");
    else if(m+f>=80)printf("A\n");
    else if(65<=m+f)printf("B\n");
    else if((50<=m+f)||(r>=50))printf("C\n");
    else if(30<=m+f)printf("D\n");
    else printf("F\n");
    }
 
    return 0;
}



Measured memory_bytes: 2056
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;


#[allow(dead_code)]
static INF_I64 :i64 = 9223372036854775807;
#[allow(dead_code)]
static INF_I32 : i32 = 2147483647;
#[allow(dead_code)]
static INF_USIZE : usize = 18446744073709551615;



fn main() {

    input! { 
       n: usize,
       a : [i64;n],
    }

    let mut ans = vec![0_i64;n];

    for i in 0..n{
        ans[(a[i]-1) as usize] = (i) as i64;
    }
    
    
    println!("{}",ans.iter().map(|x|{(x+1).to_string()}).collect::<Vec<_>>().connect(" "));


}


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

int main() {
  int N, l, r, sum, i;
  cin >> N;
  sum = 0;
  for(i=0; i<N; i++){
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextStr()
	switch N {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=10005;
const int mod=1e9+7;
int main()
{
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c)%17==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b});
	return 0;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if r < 0 or n < r:
        return 0
    r = min(r, n - r)
    return fact[n] * fact_inv[r] * fact_inv[n - r] % p


n, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
fact_inv = [1, 1]  # fact_inv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # fact_invの計算用

for i in range(2, n + 1):
    fact.append(fact[-1] * i % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    fact_inv.append(fact_inv[-1] * inv[-1] % p)

i = 0
sum_max = 0
sum_min = 0
while n - i - 1 >= k - 1:
    cnt = cmb(n - i - 1, k - 1, p)
    sum_max += a[i] * cnt
    sum_min += a[n - i - 1] * cnt
    # print(i, a[i] * cnt, a[n - i - 1] * cnt)
    i += 1
ans = (sum_max - sum_min) % p
print(ans)


Measured memory_bytes: 20324
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
int a[1001],m,n;
cin >> n >>m ;
for(int i=1;i<=n;i++){
cin >> a[i];
}
for(int i=1;i<=m;i++){
for(int j=1;j<n;j++){
if(a[j]%i>a[j+1]%i){
swap(a[j],a[j+1]);
}
}
}
for(int i=1;i<=n;i++){
cout << a[i] << endl;
}
return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int ans = 0;
		int y = 0;
		for(int i = 0;i < n - 1;i ++) { //ユークリッド
			y = sc.nextInt();
			if(x > y) {
				while(y != 0) {
					ans = x % y;
					x = y;
					y = ans;
				}
			} else {
				while(x != 0) {
					ans = y % x;
					y = x;
					x = ans;
				}
				x = y;
			}
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 48400
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

void solve() {
    std::vector<int> xs(10);
    for (auto& x : xs) std::cin >> x;
    std::sort(xs.rbegin(), xs.rend());
    std::cout << std::accumulate(xs.begin(), xs.begin() + 3, 0);
}

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

    for (int i = 0; i < 2; ++i) {
        solve();
        std::cout << " \n"[i];
    }

    return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll


int n,k;
vector<int> a,b;

signed main(){
  cin>>n>>k;

  rep(i,n){
    int c;
    cin>>c;
    if(c<0){
      c*=-1;
      a.push_back(c);
    }
    else
      b.push_back(c);
  }

  sort(all(a));

  int ans = INF;
  rep(i,a.size()){
    if(k-i-2<0) break;
    if(k-i-2>=b.size()) continue;
    ans = min(ans,a[i]*2+b[k-i-2]);
    ans = min(ans,a[i]+b[k-i-2]*2);

  }

  if(a.size()>=k){
    ans = min(ans,a[k-1]);
  }
  if(b.size()>=k){
    ans = min(ans,b[k-1]);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <functional>
#include <cmath>
#define REP(i,n) for(lint i{}, i##_len=(n); i<i##_len; ++i)
#define DBLOOP(i, h, j, w) for(lint i{}; i < (lint)(h); ++i)for(lint j{}; j < (lint)(w); ++j)
#define DBLOOP2(i, j, n) for(lint i{}; i < (lint)(n - 1); ++i)for(lint j{i + 1}; j < (lint)(n); ++j)
#define SZ(x) ((lint)(x).size())
using lint = long long; lint N, M, H, W;
using Graph = std::vector<std::vector<lint>>;
using namespace std;
const long long INF{ 1LL << 60 };
const long long inf{ 1LL << 24 };
const long double PI{ 3.1415926535897932 };
const long long NUM97{ 1000000007 };
template<class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return 1; } return 0; }
template<class T> inline bool chmin(T& x, T y) { if (x > y) { x = y; return 1; } return 0; }
std::vector<std::string> field;
std::vector<std::vector<bool>> seen(H, std::vector<bool>(W));
const std::vector<int> dx{ 1, 0, -1, 0 };
const std::vector<int> dy{ 0, 1, 0, -1 };

int main() {
	std::string S, T; std::cin >> S >> T;
	lint NS = S.size(); lint NT = T.size();
	bool flag; lint p = -1;
	for (lint i = 0; i < NS - NT + 1; ++i) { 
		for (lint j = 0; j < NT; ++j) {
			if (S[i + j] != '?' && S[i + j] != T[j]) { break; }
			else if (j == NT - 1) p = i;
		}
	}
	if (p == -1 || NS < NT) { std::cout << "UNRESTORABLE" << std::endl; }
	else {
		for (int i = 0; i < NT; ++i) { S[i + p] = T[i]; }
		for (auto& r : S) if (r == '?') r = 'a';
		std::cout << S << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int k,ans;
int main()
{
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int x=1;x<=k;x++)
			{
				ans+=__gcd(i,__gcd(j,x));
			}
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int k,a,b;
	cin>>k>>a>>b;
	bool ok=false;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			ok=true;
		}
	}
	if(ok)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n ; i++) {
           p[i] = sc.nextInt();
        }
        int min = 1000000;
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            if (p[i] < min) {
                c++;
                min = p[i];
            }
        }

        System.out.println(c);
    }

}


Measured memory_bytes: 88852
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int a[110];
int main() {
	int N;
	std::cin>>N;
	for(int i=0;i<N;i++)std::cin>>a[i];
	int ans=0;
	for(int i=1;i<N;i++){
		if(a[i-1]==a[i]){
			a[i]=-1;
			ans++;
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    int n; cin>>n;
    vector<string> s(n); vi t(n);
    FOR(i, 0, n) {
        cin>>s[i]>>t[i];
    }
    string x; cin>>x;
    int res = 0;
    RFOR(i, n - 1, 0) {
        if(s[i] == x) break;
        res += t[i];
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int num;
	while(scanf("%d",&num) != EOF){
		int o=1,sum=num*num*num;
		while(num*o != 600-num){
			o++;
			sum+=num*o*num*o*num;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
      
      List<Integer> points = new ArrayList<Integer>();
      for(int i=0;i<N;i++){
            points.add(sc.nextInt());
      }
      
      for(int i=K;i<N;i++){
        if(points.get(i-K) < points.get(i)){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }
    }
}

Measured memory_bytes: 65904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define pb          push_back
#define ff          first
#define ss          second
#define ll          int64_t
#define ld          long double
#define mod         1000000007
#define mod2        998244353
#define inf         1000000000000007
#define pi          3.14159265358979323846
#define nl          cout<<"\n"
#define dbg(x)      cerr<<#x<<" = "<<x<<"\n"
#define all(v)      v.begin(),v.end()
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

template<typename T,typename U> static inline void amin(T &x,U y)   {if(y<x)x=y;}
template<typename T,typename U> static inline void amax(T &x,U y)   {if(x<y)x=y;}  

ll lcm(ll a,ll b)       {return (a*b)/__gcd(a,b);} 
ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
string dec_bin_32(ll n) {string s;for(ll i=31;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
string dec_bin_64(ll n) {string s;for(ll i=63;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 

//-------------------------------L_I_Erq34-------------------------------

ll dp[3007][3007];

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	string a,b;
	cin>>a>>b;
	forn(i,1,a.size()+1)
		forn(j,1,b.size()+1)
		{
			if(a[i-1]==b[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	i=a.size();
	j=b.size();
	string ans;
	while(i and j)
	{
		if(a[i-1]==b[j-1])
		{
			ans+=a[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]==dp[i][j])
			i--;
		else
			j--;
	}
	reverse(all(ans));
	cout<<ans<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#define ll long long int
using namespace std ;

const ll maxn = 100+4;

ll n, k ;

ll weight[maxn];
ll price [maxn];
ll dp[maxn][100000+4];

ll min(ll a, ll b)
{
    if (a <= b) return a;
    return b;
}


ll max(ll a, ll b)
{
    if( a > b) return a;
    return b;
}


ll abs(ll x)
{
    if(x<0)
        return (-1*x);
    return x;
}


ll cal( ll pos, ll Wgt )
{

    if( pos > n ) return 0 ;



    if( dp[pos][Wgt]!= -1 ) return dp[pos][Wgt];


    ll nibo = 0, nibona = 0 ;

    nibona = cal(pos+1, Wgt);

    if( Wgt - weight[pos] >= 0 )
    {
        nibo = cal( pos + 1, Wgt - weight[pos] ) + price[pos];
    }

    return dp[pos][Wgt] = max( nibo, nibona );


}


int main()
{

    cin >> n ;
    cin >> k ;

    for(ll i = 1 ; i<= n ; i++)
    {
        cin >> weight[i];
        cin >> price[i];
    }

    for(ll i=1 ; i<=n+2; i++)
    {
        for(ll j=1 ; j<=k+2 ; j++)
        {
            dp[i][j] = -1;
        }
    }

    cout << cal (1, k) <<endl;


    return 0 ;
}


Measured memory_bytes: 80000
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h]
    }

    let mut c: Vec<Vec<char>> = a;

    for i in 0..h {
        let mut cc = c[i].clone();
        cc.push('#');
        cc.reverse();
        cc.push('#');
        cc.reverse();

        c[i] = cc;
    }

    let top_bottom_padding: Vec<char> = vec!['#'; w + 2];
    c.push(top_bottom_padding.clone());
    c.reverse();
    c.push(top_bottom_padding.clone());
    c.reverse();

    let mut dp = vec![vec![0; w + 2]; h + 2];
    dp[1][1] = 1;

    for i in 1..=h {
        for j in 1..=w {
            if (i, j) != (1, 1) {
                if c[i][j] == '#' {
                    dp[i][j] = 0;
                } else {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (10i32.pow(9) + 7);
                }
            }
        }
    }

    println!("{}", dp[h][w]);
}


Measured memory_bytes: 14752
from math import sin,cos,pi
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

R = []
e = 1e-5
for n in range(10**5+1):
    R.append([cos(2*pi*n/10**5),sin(2*pi*n/10**5)])

ans = 0
for Rx,Ry in R:
    X = 0
    Y = 0
    for x,y in xy:
        if Rx*x+Ry*y > 0:
            X += x
            Y += y
    ans = max(ans,(X**2+Y**2)**0.5)

print(ans)

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

using namespace std;


struct Node
{
  int key, lazy;
  Node *l, *r;
} *root = nullptr;

Node pool[2000001];

template< typename T >
struct SkewHeap
{
  bool rev;

  int ptr;

  SkewHeap(bool rev = false) : rev(rev) {}

  Node *propagate(Node *t)
  {
    if(t->lazy != 0) {
      if(t->l) t->l->lazy += t->lazy;
      if(t->r) t->r->lazy += t->lazy;
      t->key += t->lazy;
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y)
  {
    if(!x || !y) return x ? x : y;
    propagate(x), propagate(y);
    if(x->key < y->key) swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key)
  {
    pool[ptr].key = key;
    root = merge(root, &pool[ptr++]);
  }

  T top()
  {
    return propagate(root)->key;
  }

  void pop()
  {
    propagate(root);
    auto *temp = root;
    root = merge(root->l, root->r);
    //  delete temp;
  }

  bool empty() const
  {
    return !root;
  }

  void add(const T &lazy)
  {
    if(root) {
      root->lazy += lazy;
      propagate(root);
    }
  }

};

int main()
{
  char buff[100];
  int key;

  SkewHeap< int > que(true);
  for(;;) {
    scanf("%s", buff);
    if(buff[0] == 'e' && buff[1] == 'n') break;
    if(buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\n", que.top());
      que.pop();
    }
  }
}


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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int A, B;
string S;

signed main() {
    cin >> A >> B >> S;
    if (S.length() == A + B + 1 && S[A] == '-') {
        for (int i = 0; i < S.length(); i++) {
            if (i != A && (S[i] < '0' || S[i] > '9')) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    N = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))

    cnt_a = Counter(a)
    cnt_b = Counter(b)

    acc_a = [0] * 200001
    acc_b = [0] * 200001

    for i in range(1, 200001):
        acc_a[i] = acc_a[i - 1] + cnt_a[i]
        acc_b[i] = acc_b[i - 1] + cnt_b[i]
        if cnt_a[i] + cnt_b[i] > N:
            return print("No")

    ans = 0
    for i in range(200000, 0, -1):
        score = acc_b[i] - acc_a[i - 1]
        ans = max(ans, score)

    print("Yes")

    res = b[ans:] + b[:ans]
    print(*res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 169932
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

int N, A[200005];

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

    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);

    int b = A[N / 2];

    int ans = 0;
    REP(i, N) { ans += abs(A[i] - b); }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector


int n,h[N];
int dp[N];

void solve()
{
    cin>>n;
    forn(i,1,n)cin>>h[i];
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    forn(i,3,n)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n];
    
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

int n, p[300233];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int l = 1, r = 1; l <= n; l = ++r) {
    while (r + 1 <= n && ((p[r] == r) ^ (p[r + 1] == r + 1))) ++r;
    int ml = 0, mr = 0;
    for (int i = l; i <= r; i++) if (p[i] != i) {
      if (p[i] < l || p[i] > r) return puts("No"), 0;
      else if ((p[i] < i ? ml : mr) < p[i]) (p[i] < i ? ml : mr) = p[i];
      else return puts("No"), 0;
    }
  }
  puts("Yes");
}


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

const int N = 105;
int dp[N][N][N];
int a[N];

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

    for (int i=1; i<=n; i++)    cin>>a[i];

    for (int len=1; len<=n; len++) {
        for (int l=1; l+len-1<=n; l++) {
            int r = l+len-1;
            for (int i=1; i<=k; i++) {
                dp[l][r][i] = dp[l][r][i-1];
                dp[l][r][i] = max(dp[l][r][i], dp[l+1][r][i-1]+a[l]);
                dp[l][r][i] = max(dp[l][r][i], dp[l][r-1][i-1]+a[r]);
                if (i>=2)   dp[l][r][i] = max(dp[l][r][i], dp[l+1][r][i-2]);
                if (i>=2)   dp[l][r][i] = max(dp[l][r][i], dp[l][r-1][i-2]);
            }
        }
    }
    cout<<dp[1][n][k]<<endl;
}


Measured memory_bytes: 2944
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	vector<int>data(5);
	for (int i = 0; i < 5; i++) {
		cin >> data[i];
	}
	int k;
	cin >> k;
	sort(data.begin(), data.end());
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (abs(data[i] - data[j]) > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
}

Measured memory_bytes: 256
/*-----rk_98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    //fast();
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for( ll i=0 ; i< n; i++)
    	cin>>arr[i];
    ll dp[n+5][n+5];
    memset(dp, 0 ,sizeof dp);
    for(ll i = n-1;i>=0;i--)
    {
    	ll sum=arr[i];
    	for(ll j = i+1 ; j<n ; j++)
    	{
    		sum+=arr[j];
    		dp[i][j] = 1ll<<60;
    		for(ll k = i ; k<= j ; k++)
    			dp[i][j] = min( dp[i][j], dp[i][k] + dp[k+1][j] );
    		dp[i][j] +=sum;
    	}
    }
    // for(ll i=0;i<n; i++)
    // {
    // 	for( ll j =0 ;j<n ; j++)
    // 		cout<<dp[i][j]<<" ";
    // 	cout<<endl;
    // }
    cout<<dp[0][n-1]<<endl;
}


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

using namespace std;

typedef long long ll;

ll sum[100010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		sum[i + 1] = a[i];
		sum[i + 1] += sum[i];
	}

	int ans = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (sum[i + 1] * 2 >= a[i + 1]) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792