akhauriyash/Code-Regression huggingface dataset:
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

#DIV = (10**9) + 7
DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    H,W,K = isRaw()
    cs = [sRaw() for i in range(H)]
    ans =0
    for hc in range(0,2**H):
        for wc in range(0,2**W):
            n= 0
            for h in range(H):
                for w in range(W):
                    if (hc&(1<<h)!=0) and (wc&(1<<w)!=0) and cs[h][w]=="#":
                        n+=1
            if n==K:
                ans+=1
    print(ans)
main()


Measured memory_bytes: 68928
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var d = o.a();
  var x = o.m(n);
  var ans = 0;
  for(var i = 0; i < n; i++){
    for(var j = i+1; j < n; j++){
      var z = 0;
      for(var k = 0; k < d; k++){
        var t = x[j][k] - x[i][k];
        z += t*t;
      }
      var u = Math.sqrt(z);
      if(u === Math.floor(u))ans++;
    }
  }
  return ans;
}

Measured memory_bytes: 22080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

u=input().rstrip().split(" ")
a=int(u[0])
b=int(u[2])
if u[1]=="+":
    print(a+b)
else:
    print(a-b)

Measured memory_bytes: 3316
#![allow(non_snake_case, unused_imports)]

// Input
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)*} }; }
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let mut ans = 0;
    for i in 1..S.len(){
        if S[i-1]!=S[i]{
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0m";                        \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;
const int MOD = 1e9 + 7;

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> m(h + 1);
  FOR(i,1,h){
    cin >> m[i];
    m[i] = ' ' + m[i];
  }
  vector<int> cur(w + 1);
  cur[1] = 1;
  FOR(i, 1, h){
    vector<int> nxt(w + 1);
    FOR(j, 1, w){
      if (m[i][j] == '.'){
        nxt[j] = (nxt[j - 1] + cur[j]) % MOD;
      }
    }
    swap(cur, nxt);
  }
  cout << cur[w] << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    
    cin >> S;
    
    //単に代入するだけでは？
    S[0]='2';
     S[1]='0';
     S[2]='1';
      S[3]='8';
    
    cout << S;
    
    
   
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
int main(void){
    while(1){
        int n, k, ans = 0;
        cin >> n >> k;
        if(n == 0 && k == 0) break;//00???????????????????????????
        bool flag = false;//?????¨???????????????0??????????????????????????????????????°
        vector<bool> num(n + 1, false);//?????±??????????????????????????????
        rep(i, k){
            int tmp; scanf("%d", &tmp);
            if(tmp == 0){
                flag = true;
                continue;
            }
            num[tmp] = true;//?????±????????????
        }
        int pre = 0;//???????????£?¶??¢????????????°???????????°?????\????????????
        int cnt = 0;//?????????????????£?¶??¢????????????°???????????°????????????????????????????????¨
        int now;
        int end = 0;//???????????£?¶???¨????¢?????????????????????°????????\????????????
        bool rennketukanouseiflag = false;//??£??\????????£?¶??¢????????????????1?????¨?????????true
        reps(i, 1, n + 1){
            //??°???i????????????
            if(num[i] == true){
                if(i == end + 2) rennketukanouseiflag = true;//???????????£?¶??¢?????????¨?????????1
                cnt++;
            //??°???i???????????¨???
            }else{
                now = cnt;//?????¨??????????????£?¶???¨????¢????????????°???????????°
                //?????¨?????????0????????????????????????????????£??\????????£?¶???¨??????????????°???1???????????¨?????????????????£?¶???¨???????????????????????£????????????
                if(flag == true && rennketukanouseiflag == true) ans = max(ans, pre + now + 1);
                //???????????¶????????????????????¨?????????????????£?¶???¨????¢???????????????§?????§??????????????¢?????°??????
                else ans = max(ans, now);
                
                // ?????????
                cnt = 0;
                rennketukanouseiflag = false;
                pre = now;//?????¢??£?????????
                end = i;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
//#define local
//if you find any bug in my code, please tell me.
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    ll n,a,b,x1,x2,ans=0;
    cin>>n>>a>>b>>x1;
    for(int i=1; i<n; i++)
    {
        scanf("%lld",&x2);
        ans+=min(a*(x2-x1),b);
        x1=x2;
    }
    cout<<ans<<endl;
    return 0;
}


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

vector<pair<int, int> > no;
pair<int, int> pt[360005];
bool in[605][605];
int n, d1, d2, X;

int f(pair<int, int> a)
{
	int x = max(a.first%(2*X), a.second%(2*X));
	if (X == 1000) x = (a.first-n)*(a.first-n)+(a.second-n)*(a.second-n);
	else if (X > 2*n) x = a.first*a.first+a.second*a.second;
	return x;
}

bool slv()
{
	vector<pair<int, int> > ans;
	for (int i = 0;i < 4*n*n;i++)
	{
		auto u = pt[i];
		bool ok = true;
		for (auto v: no)
		{
			if (u.first-v.first >= 0 && u.second-v.second >= 0 && in[u.first-v.first][u.second-v.second]) ok = false;
			if (u.first-v.first >= 0 && u.second+v.second < 2*n && in[u.first-v.first][u.second+v.second]) ok = false;
			if (u.first+v.first < 2*n && u.second-v.second >= 0 && in[u.first+v.first][u.second-v.second]) ok = false;
			if (u.first+v.first < 2*n && u.second+v.second < 2*n && in[u.first+v.first][u.second+v.second]) ok = false;
		}
		if (ok)
		{
			ans.push_back(u);
			in[u.first][u.second] = true;
			if (ans.size() == n*n) break;
		}
	}
	if (ans.size() == n*n)
	{
		for (auto u: ans) printf("%d %d\n", u.first, u.second);
		return true;
	}
	for (int i = 0;i < 2*n;i++) for (int j = 0;j < 2*n;j++) in[i][j] = false;
	return false;
}

int main()
{
	scanf("%d%d%d", &n, &d1, &d2);
	for (int i = 0;i < 2*n;i++) for (int j = 0;j < 2*n;j++) pt[i*2*n+j] = make_pair(i, j);
	for (int i = 0;i < 2*n;i++) for (int j = 0;j < 2*n;j++) if (i*i+j*j == d1 || i*i+j*j == d2) no.emplace_back(i, j);
	while (true)
	{
		X++;
		if (2*X*X >= d1 || 2*X*X >= d2 || X >= 2*n) break;
		bool ok = true;
		for (int i = 0;i < 2*n;i++) for (int j = 0;j < 2*n;j++) if (i%(2*X)<X && j%(2*X)<X) for (auto d: no)
		{
			int I = i+d.first, J = j+d.second;
			if (I >= 0 && I < 2*n && J >= 0 && J < 2*n && I%(2*X)<X && J%(2*X)<X) ok = false;
		}
		if (ok) break;
	}
	if (slv()) goto done;
	sort(pt, pt+4*n*n, [](pair<int, int> a, pair<int, int> b)->bool {
		return f(a) < f(b);
	});
	if (slv()) goto done;
	X = 601;
	sort(pt, pt+4*n*n, [](pair<int, int> a, pair<int, int> b)->bool {
		return f(a) < f(b);
	});
	if (slv()) goto done;
	X = 1;
	while (true)
	{
		sort(pt, pt+4*n*n, [](pair<int, int> a, pair<int, int> b)->bool {
			return f(a) < f(b);
		});
		if (slv()) goto done;
		X++;
	}
	//while (!slv()) random_shuffle(pt, pt+4*n*n);
done:
	/*freopen("vis.txt", "w", stdout);
	for (int i = 0;i < 2*n;i++)
	{
		for (int j = 0;j < 2*n;j++) printf("%c", in[i][j]?'X':' ');
		printf("\n");
	}*/
	return 0;
}


Measured memory_bytes: 5852
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <math.h>

#define M 1046527
#define L 15

char H[M][L];

long long convertToNum(char* str) {
    long long result = 0;
    int i = 0;
    int len = strlen(str);
    for (int i = 0; i < len; ++i) {
        int j = 0;
        switch (str[i]) {
            case 'A':
                j = 1;
                break;
            case 'C':
                j = 2;
                break;
            case 'G':
                j = 3;
                break;
            case 'T':
                j = 4;
                break;
        }
        result += j * pow(5, i);
    }
    return result;
}

int h1(int i) {
    return i % M;
}

int h2(long long i) {
    return 1 + i % (M - 1);
}

int getHash(long long key, int i) {
    return (h1(key) + h2(key) * i) % M;
}

bool find(char* str) {
    int i = 0;
    long long num = convertToNum(str);
    while (int key = getHash(num, i++)) {
        if (strcmp(H[key], str) == 0) {
            return true;
        }
        if (H[key][0] == '\0') break;
    }
    return false;
}

void insert(char* str) {
    int i = 0;
    long long num = convertToNum(str);
    while (int key = getHash(num, i++)) {
        if (strcmp(H[key], str) == 0) break;
        if (H[key][0] == '\0') {
            strcpy(H[key], str);
            break;
        }
    }
    return;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < M; ++i) { H[i][0] = '\0'; }

    for (int i = 0; i < n; ++i) {
        char command[7];
        char c[L];
        scanf("%s %s", command, c);
        if (command[0] == 'i') insert(c);
        if (command[0] == 'f') {
            if (find(c)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 18264
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
use std::usize;
#[allow(unused_imports)]
use std::vec::Vec;

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)*}
    };
}

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)*}
    };
}

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")
    };
}

fn main() {
    input!{
        n: usize,
        h: [usize; n],
    }
    let mut max = 0;
    let mut current;
    let mut count = 0;
    for i in 0..n {
        current = h[i];
        // eprintln!("{} {}", max, current);
        if max > current {
            count += max - current;
            max = current;
        } else {
            max = current;
        }
    }
    count += max;
    println!("{}", count);
}


Measured memory_bytes: 4352
'use strict'

function main(input) {
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
  const N = input[0][0]
  const T = input[0][1]

  const p = input[1].slice(0, input[1].length)

  let times = [T]
  let total = T

  for (let i = 1; i < N; i++) {
    let tmp = Math.min(T, p[i] - p[i - 1])
    total += tmp
    // console.log(T, tmp)
  }


  console.log(total)

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  string s;
  cin >> s;
  string s1 = string(begin(s), begin(s) + 2);
  string s2 = string(begin(s) + 2, end(s));
  int n1 = stoi(s1);
  int n2 = stoi(s2);
  bool b1 = (n1 >= 1 && n1 <= 12);
  bool b2 = (n2 >= 1 && n2 <= 12);

  string ans;
  if (b1 && b2)
    ans = "AMBIGUOUS";
  else if (b1 && !b2)
    ans = "MMYY";
  else if (!b1 && b2)
    ans = "YYMM";
  else
    ans = "NA";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
long long longpow(int a, int b) {
	int x = 1;
	rep(i, b)x *= a;
	return x;
}
int n, p;
int a[111];
signed main() {
	cin >> n >> p;
	int x=0, y=0;//gu,ki
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2 == 0)x++;
		else y++;
	}
	if (y == 0) {
		if (p == 0)cout << longpow(2ll, n) << endl;
		else cout << 0 << endl;
	}
	else cout << longpow(2ll, n - 1 )<< endl;
	END;
}


Measured memory_bytes: 504
#include <iostream>

using namespace std;

int main(){

int n;
  cin >> n;
int h;
int height=0,counts=0;
  
  for(int i=0;i<n;i++){
   cin >> h;
    
    if(h>=height){
     counts++;
    }
    
   height=max(height,h);
  }
  cout << counts; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//
		while(true){
		//??£?¨??????????????????????
		long sum = 0;
		//1??????????????????
		String line = sc.nextLine();
		//?????£?????\???????????????1???
		
			//?????£?????\????????????1??????0?????£?????´????????????
			if(line.equals("0")){
				break;
				}
			
			//
			for(int i=0;i<line.length();i++){
				sum += Integer.parseInt(String.valueOf(line.charAt(i)));
			}
			//
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26916
def input_from_console():
    n = int(input().rstrip())

    s_list = []
    for i in range(1, n+1):
        s, p = input().split()
        p = int(p)
        s_list.append((i, s, p))
    return n, s_list


def solve(n, s_list):

    final_order = []
    city_list = set([item[1] for item in s_list])
    city_list_sorted = sorted(city_list)
    for city in city_list_sorted:
        ranked_list = [item for item in s_list if item[1] == city]
        final_order.extend([item[0] for item in sorted(ranked_list, key=lambda x: x[2], reverse=True)])
    return '\n'.join(map(str, final_order))


def main():
    n, s_list = input_from_console()
    print(solve(n, s_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
int main()
{IOS;int n;
	cin>>n;
	vector<int>v(n);
	for(int i=0;i<n;++i)
		cin>>v[i];
	sort(all(v));cout<<v[n-1]-v[0]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=16,INF=0x7f7f7f7f,MINF=-2139062144;
int dis[N][N];
int ans=0;
int inter[1<<N];
int f[N][1<<N],lnode[N][1<<N],g[1<<N];
int vec[N];
int main(){
	int n=ni,sum=0,ts=1<<n;
	memset(dis,0,sizeof(dis));
	for(int tot=ni,u,v;tot--;u=ni,v=ni,sum+=dis[u][v]=dis[v][u]=ni);
	for(int s=0;s<ts;s++){
		inter[s]=0;
		for(int i=0;i<n;i++){
			if((s>>i)&1){
				for(int j=0;j<i;j++){
					if((s>>j)&1){
						inter[s]+=dis[i+1][j+1];
					}
				}
			}
		}
	}
	memset(f,128,sizeof(f));
	assert(f[1][1]==MINF);
	f[1][1]=0;
	int ans=0;
	for(int s=0;s<ts;s++){
		for(int i=1;i<=n;i++){
			if((s>>(i-1))&1){
				for(int j=1;j<=n;j++){
					if(((s>>(j-1))&1)&&dis[i][j]&&f[j][s^(1<<(i-1))]>MINF){
						int tmp=f[j][s^(1<<(i-1))]+dis[i][j];
						if(tmp>f[i][s]){
							f[i][s]=tmp;
							lnode[i][s]=j;
						}
					}
				}
			}
		}
		if(f[n][s]>MINF){
			int vs=0;
			int curs=s;
			for(int x=n;x!=1;curs^=1<<(x-1),x=lnode[x][curs^(1<<(x-1))]){
				vec[vs++]=x;
			}
			vec[vs++]=1;
			reverse(vec,vec+vs);
			for(int trans=(ts-1)^s,s2=trans;s2;s2=trans&(s2-1)){
				g[s2]=MINF;
			}
			g[0]=0;
			for(int i=0;i<vs;i++){//dp
				for(int trans=(ts-1)^s,s2=trans;s2;s2=trans&(s2-1)){
					int tmp=s2|(1<<(vec[i]-1));
					for(int s3=s2;s3;s3=s2&(s3-1)){
						if(g[s3]>MINF){
							apmax(g[s2],g[s3]+inter[tmp^s3]);
						}
					}
					if(g[0]>MINF){
						apmax(g[s2],g[0]+inter[tmp]);
					}
				}
			}
			apmax(ans,g[(ts-1)^s]+f[n][s]);
		}
	}
	printf("%d\n",sum-ans);
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n,i,j,ans = 1000,stocks = 0;
	cin >> n;
	vector< ll >v(n);
	for(i = 0; i < n; i++)cin>>v[i];
	rep(i,1,n){
		if(v[i] > v[i-1]){
			stocks = ans / v[i-1];
			ans = ans % v[i-1];
			ans += (stocks * v[i]);
			stocks = 0;
		}
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
    	//cout <<"Case #"<<i<<':'<<nl;
        doit();
    }
}


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

using namespace std;

int main() {
  int n, p;
  for(;;) {
    cin >> n >> p;
    if ((n|p) == 0) {
      break;
    }
    vector<int> m(n);
    int own = p;
    int ite = 0;
    for (;;) {
      if (own > 0) {
        m[ite]++;
        own--;
      } else {
        own = m[ite];
        m[ite] = 0;
      }

      if (m[ite] == p) {
        break;
      }
      ++ite;
      ite %= n;
    }
    cout << ite << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n=1,i;
   string s;
   cin >> s;
   for(i=0;i<3;i++){
    if(s[i+1]==s[i]){
        n++;
        if(n==3){
           break;
        }
    }
    else{
        n=1;
    }
   }
   if(n==3){
    printf("Yes\n");
   }
   else{
    printf("No\n");
   }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}//#########################################

bool isPrime(ll n){
    for(ll i = 2; i <= n / i; ++i)
        if(n % i == 0)
            return 0;
    return n > 1;
}


vector<ll> getDivisors(ll n){
    vector<ll> ret;
    for(int i = 1; i <= n / i; ++i){
        if(n % i == 0){
            ret.push_back(i);
            if(n / i != i)
                ret.push_back(n / i);
        }
    }
    return ret;
}



ll GCD(ll a, ll b){
    return b ? GCD(b, a % b) : a;
}

ll LCM(ll a, ll b){
    return a / GCD(a, b) * b;
}

vector<ll> ret;

vector<ll> getFactors(ll n){
    // vector<ll> ret;
    for(ll i = 2; i <= n / i; ++i)
        while(n % i == 0){
            ret.push_back(i);
            n /= i;
        }

    if(n != 1){
        ret.push_back(n);
    }
    return ret;
}
const int N = 1e6 + 5;
int vst[N], cnt[N];
vector<int> primes;
void seive(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        primes.push_back(i);
        for(ll j = 1LL * i * i; j < N; j +=i)
            vst[j] = 1;
    }
}

// Modified sieve for number of divisors
int cnt1[N];
void modSeive(){
    for(int i = 1; i < N; ++i){
        for(int j = i; j < N; j += i)
            ++cnt1[j];
    }
}

// Modified sieve for number of prime factors
int cnt2[N];
void mod2Sieve(){
    for(int i = 2; i < N; ++i){
        if(vst[i])
            continue;
        for(ll j = i; j < N; j +=i){
            vst[j] = 1;
            int cntP = 0;// calculate the power of i exists in j
            int curr = j;
            while (curr % i == 0) {
                ++cntP;
                curr /= i;
            }
            cnt2[j] += cntP;
        }
    }
}
//####################################################################################################

int main() {
    //  freopen("", "r", stdin);
    // freopen(" ","w",stdout);
int a=D(),b=D();
int cnt=0;
for(int i=a;i<=b;i++){
    if( (i%10==(i/10000)%10)&& ((i/10)%10==(i/1000)%10)) cnt++;


}
cout<<cnt;



}



Measured memory_bytes: 2304
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<vector>
#include<queue>
using namespace std;
int main(){
	int N,out=0;
	cin>>N;
	string siritori[150];
	for(int i=0;i<N;i++){
		cin>>siritori[i];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i!=j&&siritori[i]==siritori[j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for(int i=1;i<N;i++){
		if(siritori[i-1].at(siritori[i-1].size()-1)!=siritori[i].at(0)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long;

#define REP(i,n) for(ll i=0; (i)<(n); ++(i))
#define P M_PI/3

typedef struct dot{
  double x; double y;
}T;

void kohho(T a, T b, ll n){
  if(n == 0){
    cout << b.x << " " << b.y << "\n";
    return;
  }
  T c, d, e;
  c.x = (2*a.x+b.x)/3, c.y = (2*a.y+b.y)/3;
  d.x = (2*b.x+a.x)/3, d.y = (2*b.y+a.y)/3;
  e.x = c.x + cos(P)*(d.x-c.x) - sin(P)*(d.y-c.y);
  e.y = c.y + sin(P)*(d.x-c.x) + cos(P)*(d.y-c.y);
  kohho(a, c, n-1);
  kohho(c, e, n-1);
  kohho(e, d, n-1);
  kohho(d, b, n-1);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(8);
  
  T a = {0, 0}, b = {100, 0};
  ll n; cin >> n;
  cout << a.x << " " << a.y << "\n";
  kohho(a, b, n);
  return 0;
}


Measured memory_bytes: 3264
#include <stdio.h>
#define N 100000
int main(){

    int n,m,c;
    long int h[N];
    int i;
    int good[N];
    int u,v,f;

    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%ld",&h[i]);
        good[i]=1;  //いい展望台flag
    }



    for(i=0;i<m;i++){
        scanf("%d %d",&u,&v);
        u--;
        v--;
        if(h[u]==h[v]) {
            good[v]=0;
            good[u]=0;
        } else if(h[u]>h[v])
            good[v]=0;
        else
            good[u]=0;

    }       

    c=0;
    for(i=0;i<n;i++)
        if (good[i]) c++;
    printf("%d",c);
    
}

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

using namespace std;

int main(){
  string S;
  bool f = true;
  cin >> S;
  for (int i=1; i<S.size(); i++){
	if (S[i] == S[i - 1]){
      f = false;
      break;
    }
  }
  cout << (f ? "Good" : "Bad") << endl;
  return 0;
}


Measured memory_bytes: 256
# x無視したやつが回文なってればいいんじゃね？
# 真ん中にしたい(x以外の)文字が決まれば、もとのsにインデックスを適応して、左右のxの数の差をとればいい
# と思ったけど差をとっただけだと駄目だな xaaxxxbxxcxxxxbxaxxaxx はこの考えだと3だけど実際は7だし
# もうしかたねぇから無理やりsplitした（アホか？）
# これでいけると思いきや駄目 abxxxbaとかでエラーになる
# 趣向を変えて、両脇から比較していくことにしてみる

s = input()
# めんどくさいけどここで確実になるときのやつと回文にならんときのやつを判定すっか
if len(s) == 1:
    print(0)
    exit()
t = ""
for sv in s:
    if sv != "x":
        t += sv
if t != t[::-1]:
    print(-1)
    exit()

l, r = 0, len(s) - 1
ls, rs = "", ""
ans = 0
x = False
while l < r:
    if s[l] == s[r]:
        ls += s[l]
        rs += s[r]
        l += 1
        r -= 1
    else:
        if s[l] == "x":
            while l < r and s[l] != s[r]:
                l += 1
                ans += 1
        else:
            while l < r and s[r] != s[l]:
                r -= 1
                ans += 1
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=-INF,ans2=0,cnt=0;
string s,S,t;
int main() {
  cin >> n;
REP(i,n){
  cin >> a >> b;
  if(a==b){
    cnt++;
    ans = max(cnt, ans);
  }else{
  cnt=0;
  }
}
if(ans>=3){
  cout << "Yes";
}else{
  cout << "No";
}
}

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

int main(void){
  vector<int> arr(3);
  cin >> arr[0] >> arr[1] >> arr[2];
  int c = arr[2];
  sort(arr.begin(),arr.end());
  if(arr[1] == c)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
function main(input) {
	const str = input.trim();
  	let cnt = 0;
  	for (const char of str) {
    	if (char === "x") {
        	cnt++;
        }
    }
  	let result = "YES";
  	if (8 <= cnt) {
    	result = "NO";
    }
	console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    S = input()
    Q = int(input())
    head = ""
    tail = ""
    is_vert_normal = True
    for _ in range(Q):
        query = input().split()
        T = int(query[0])
        if T == 1:
            is_vert_normal = not is_vert_normal
        else:
            F = int(query[1])
            C = query[2]
            if F == 1:
                if is_vert_normal:
                    head += C
                else:
                    tail += C
            else:
                if not is_vert_normal:
                    head += C
                else:
                    tail += C
    if is_vert_normal:
        print(head[::-1] + S + tail)
    else:
        print(tail[::-1] + S[::-1] + head)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6652
a, b = map(int, input().split())
s = list(input())
c = [str(i) for i in range(10)]

for i in range(a+b+1):
    if a == i:
        if s[i] == "-": 
            continue
        else:
            print("No")
            break
    if s[i] not in c:
        print("No")
        break
else:
    print("Yes")
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll A, B, C;
	cin >> A >> B >> C;

	cout << max(C - (A - B), 0);

	system("PAUSE");
}

Measured memory_bytes: 504
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::cmp::*;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let w: i64 = sc.ne();
    let item: Vec<(i64, i64)> = (0..n).map(|_| (sc.ne(), sc.ne())).collect();
    let wmax = n * 3 + 10;
    let mut dp = vec![vec![-1;wmax + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        let mut dpn = dp.clone();
        let cost = (item[i].0 - item[0].0) as usize;
        for j in 0..i + 1 {
            for k in 0..wmax - cost + 1 {
                if dp[j][k] < 0 {
                    continue;
                }
                dpn[j + 1][k + cost] = max(dpn[j + 1][k + cost], dp[j][k] + item[i].1);
            }
        }
        dp = dpn;
    }
    let mut ans = 0;
    for i in 0..n + 1 {
        for j in 0..wmax {
            let wsum = item[0].0 * (i as i64) + j as i64;
            if wsum <= w {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r])
                  .ok()
                  .unwrap()
                  .parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

using namespace std;

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

    if((a==5&&b==5&&c==7)||(b==5&&c==5&&a==7)||(a==5&&c==5&&b==7))
        cout<<"YES";
    else
        cout<<"NO";
}


Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

l = many_int()
K=one_int()

M=max(l)

l.remove(M)

print(M*(2**K)+sum(l))

Measured memory_bytes: 38384
x,y = map(int,input().split())

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod
 
    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

if (x+y)%3!=0:
    print(0)
else:
    a = (2*x - y) // 3
    b = (2*y - x) // 3

    mod = 10 ** 9 + 7
    mc = ModComb(1000000, mod=mod) 

    print(mc.nCk(a + b, a) % mod)

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

int main()
{
	string str;
	string left;
	string right;
	int m,i,h;

	while(1)
	{
		cin >> str ;

		if(str=="-") break;
		
		cin >> m ;

		for(i=0;i<m;i++)
		{
			cin >> h ;

			left = str.substr(0, h);
			right = str.substr(h,str.size());

			str = right + left ;

		}

		cout << str << endl ;

	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	int sum = a + b + c;
	sum -= max(a, max(b,c));
	if(sum == max(a,max(b,c)))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	return 0;
}

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
string s;
int size;
bool vis(int u){
	int i;
	map<string,int> m1;
	for(i=1;i<=size-u+1;i++){
		string temp;
		int j;
		temp=s.substr(i-1,u);
		if(m1[temp]){
		if(i-m1[temp]>=u)
		return true;
		}
		else 
		m1[temp]=i;
	}
	return false;
}
int main(){
    cin>>size>>s;
    int i,j;
    int l=0,r=size/2;
    while(l<r){
    	int mid=l+r+1>>1;
    	if(vis(mid))
    	l=mid;
    	else
    	r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 6668
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    if(n<105){
        printf("0");
    }else if(n<135){
        printf("1");
    }else if(n<165){
        printf("2");
    }else if(n<189){
        printf("3");
    }else if(n<195){
        printf("4");
    }else{
        printf("5");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<int>>adj(200010);
int vis[300050];
int n;

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {

        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll ans=-1e18;
        ans=max(ans,a*c);
        ans=max(ans,a*d);
        ans=max(ans,b*d);
    ans=max(ans,b*c);
        cout<<ans<<endl;
    }

}



Measured memory_bytes: 7900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int turn=1;
    while(a>0&&c>0)
    {
        if(turn==1)
        {
            c=c-b;
            turn=0;
        }
        else
        {
            a=a-d;
            turn=1;
        }
    }
    if(a<=0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
  int S;
  int s1,s2,s3;
  
  cin >> S;
  s1 = S / 100;
  s2 = (S / 10) & 1;
  s3 = S & 1;
  cout << s1 + s2 + s3 << endl;
}


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

int main()
{
  int N;
  std::cin >> N;
  
  int maxH = 0;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    int h;
    std::cin >> h;
    
    if (h >= maxH)
    {
      count++;
    } 
    
    maxH = h > maxH ? h : maxH;
  }
  
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct node
{
  unsigned int key;
  node *prev;
  node *next;
};

class linkedList
{
private:
  node *dummy;

public:
  linkedList()
  {
    dummy = (node *)malloc(sizeof(node));
    dummy->next = dummy;
    dummy->prev = dummy;
  }
  void insert(int x)
  {
    node *nd = (node *)malloc(sizeof(node));
    nd->key = x;
    nd->prev = dummy;
    nd->next = dummy->next;
    dummy->next->prev = nd;
    dummy->next = nd;
  }
  void del(int x)
  {
    node *tmp = dummy->next;
    while (tmp != dummy)
    {
      if (tmp->key == x)
      {
        tmp->prev->next = tmp->next;
        tmp->next->prev = tmp->prev;
        free(tmp);
        break;
      }
      tmp = tmp->next;
    }
  }
  void deleteFirst()
  {
    node *nd = dummy->next;
    dummy->next->next->prev = dummy;
    dummy->next = dummy->next->next;
    free(nd);
  }
  void deleteLast()
  {
    node *nd = dummy->prev;
    dummy->prev->prev->next = dummy;
    dummy->prev = dummy->prev->prev;
    free(nd);
  }
  void print()
  {
    node *tmp = dummy->next;
    printf("%d", tmp->key);
    tmp = tmp->next;
    while (tmp != dummy)
    {
      printf(" %d", tmp->key);
      tmp = tmp->next;
    }
    printf("\n");
  }
};

int main()
{
  int n;
  scanf("%d", &n);
  linkedList ll;
  for (int i = 0; i < n; ++i)
  {
    char command[12];
    scanf("%s", command);
    if (command[0] == 'i')
    {
      int val;
      scanf("%d", &val);
      ll.insert(val);
    }
    else
    {
      if (command[6] == 'F')
      {
        ll.deleteFirst();
      }
      else if (command[6] == 'L')
      {
        ll.deleteLast();
      }
      else
      {
        int val;
        scanf("%d", &val);
        ll.del(val);
      }
    }
  }
  ll.print();

  return 0;
}



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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int X, A, B; cin >> X >> A >> B;

	cout << (X-A)%B << endl;


	return 0;

}


Measured memory_bytes: 256
n = int(input())
H = list(map(int,input().split()))
dp = [0]*(len(H))
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,n):dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n, k, result;

    scanf( "%d %d", &n, &k );

    if( k == 1 )
        printf("0\n");
    else
    {
        result = n - k; //全員に1つずつ配る
        printf("%d\n", result);
    }
        
    return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define INVSORT(c) sort((c).begin(), (c).end(), greater<pair<int, int>>());

int main()
{
    int n,m;
    cin>>n>>m;
    cout<<n*n-m<<endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define vp vector<pair<ll,ll>>
#define mod 1000000007
#define M_PI 3.14159265358979323846
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,b,a) for(ll i=b; i>=a ;--i)
#define vin(a) for(auto &i:a) cin>>i
#define mms(a,n) memset(a,n,sizeof(a))
#define fill(a,value) fill(a.begin(),a.end(),value)
#define all(a) a.begin(),a.end()
#define n_ones(x) __builtin_popcountll(x)
#define n_trailzero(x) __builtin_ctzll(x)
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define see(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
template <typename T, typename U>inline void min_self(T &x, U y){if (y < x)x = y;}
template <typename T, typename U>inline void max_self(T &x, U y){if (x < y)x = y;}
template<class T1, class T2>ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<"["<<v.first<<", "<<v.second<<"]"; return out<<")"; }
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

// cout << fixed << setprecision(10) << pi <<" "<<npi<<endl; 
// INT64_MAX
// transform(all(s), s.begin(), ::tolower);

ll XX[4] = {-1,0,1,0};
ll YY[4] = {0,-1,0,1};


void solve(){
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    vi b = a;
    rep(i,1,n-1){
    	b[i] = max(b[i],b[i-1]);
    }
    ll res = 0;
    rep(i,0,n-1){
    	res += b[i]-a[i];
    }
    
    cout<<res<<endl;
    
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 6364