akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
	int n; cin >> n;
	map<string, int> hmap;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		hmap[s]++;
	}
	cout<<"AC x "<<hmap["AC"]<<'\n';
	cout<<"WA x "<<hmap["WA"]<<'\n';
	cout<<"TLE x "<<hmap["TLE"]<<'\n';
	cout<<"RE x "<<hmap["RE"]<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const long long INF = 1e18;
long long dp[N][N];
int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int, int>> all;
	for (int i = 1; i <= n; ++ i) {
		int h, p;
		scanf("%d%d", &h, &p);
		all.push_back({h, p});
	}
	sort(all.begin(), all.end(), [&] (pair<int, int> a, pair<int, int> b) {return a.first + a.second < b.first + b.second;});
	for (int i = 1; i <= n; ++ i) {
		int h, p;
		tie(h, p) = all[i - 1];
		for (int j = 0; j <= i; ++ j) dp[i][j] = INF;
		for (int j = 0; j < i; ++ j) {
			dp[i][j] = min(dp[i - 1][j], dp[i][j]);
			if (dp[i - 1][j] <= h) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + p);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i) if (dp[n][i] < INF) ans = i;
	printf("%d\n", ans);
}


Measured memory_bytes: 194048
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;
lli dp[100][21];
int main(){
	int n;
	cin >> n;
	vector<int> vi(n-1);
	int last;
	for(int i=0; i<n-1; ++i){
		cin >> vi[i];
	}
	cin >> last;
	dp[0][vi[0]]=1;
	for(int i=1; i<n-1; ++i){
		for(int sum=0; sum<=20; ++sum){
			if(sum-vi[i]>= 0){
				dp[i][sum]+=dp[i-1][sum-vi[i]];
			}
			if(sum+vi[i]<=20){
				dp[i][sum]+=dp[i-1][sum+vi[i]];
			}
		}
	}
	cout << dp[n-2][last] << "\n";
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
#define u_set unordered_set
#define u_multiset unordered_multiset
 
/**************************/
/****** INT OVERFLOW ******/
/**************************/
int n;
void solve(){
	cin >> n;
	cout << (1000 - n % 1000) % 1000;
}
	
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 	
 	solve();
	
    return 0; 
}




Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N;
vector<int> X;
llong ANS = 1000000000000000000;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		X.push_back(x);
	}

	for (int P = 1; P <= 100; P++) {
		llong tmp = 0;
		for (int i = 0; i < X.size(); i++) {
			tmp += (X[i] - P) * (X[i] - P);
		}
		ANS = min(ANS, tmp);
	}
	cout << ANS;
}

Measured memory_bytes: 256
gets
n  = gets.split(' ').map{|i| i.to_i}
nl = n.length
ct = 0
nl.times do
  (nl-1).downto(1) do |j|
    if n[j-1] > n[j]
      n[j-1], n[j] = n[j], n[j-1]
      ct += 1
    end
  end
end

puts n.join ' '
puts ct

Measured memory_bytes: 8764
import java.util.*

const val mInf = 1 shl 31
const val inf = mInf - 1
private val sc = Scanner(System.`in`)

fun readWord(): String = sc.next()
fun readLine(): String = sc.nextLine()
fun readInt(): Int = readLine().toInt()

fun readArray(): List<String> = readLine().split(" ").toList()
fun readStringList(size: Int): List<String> = (0 until size).map { readLine() }


fun readMultiRowToStringArray(size: Int, f: (String) -> Unit = {}): Array<String> =
    Array(size) { readLine().apply(f) }

fun readMultiRowToIntArray(size: Int, f: (Int) -> Unit = {}): IntArray =
    IntArray(size) { readLine().toInt().apply(f) }

fun readMultiRowToBooleanArray(size: Int, f: (String) -> Boolean): BooleanArray = BooleanArray(size) { f(readLine()) }

//
fun readRowSplitToStringArray(size: Int, f: (String) -> String = { it }): Array<String> =
    Array(size) { sc.next().apply { f } }

fun readRowSplitToIntArray(size: Int, f: (Int) -> Unit = { }): IntArray =
    IntArray(size) { sc.next().toInt().apply(f) }

fun readRowSplitToBooleanArray(size: Int, f: (String) -> Boolean): BooleanArray = BooleanArray(size) { f(sc.next()) }


fun main(args: Array<String>) {
    val (N, K) = readRowSplitToStringArray(2).map { it.toLong() }

    val result1 = if (N > K) N % K else K - N
    val result2 = K - result1

    println(Math.min(result1, result2))
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int c[10][10];

bool can(){
    for(int i=1;i<3;++i){
        int x = c[i][0] - c[0][0];
        for(int j=1;j<3;++j){
            if(c[i][j] - c[0][j] != x){
                return false;
            }
        }
    }

    for(int j=1;j<3;++j){
        int x = c[0][j] - c[0][0];
        for(int i=1;i<3;++i){
            if(c[i][j] - c[i][0] != x){
                return false;
            }
        }
    }

    return true;
}

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

    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            std::cin >> c[i][j];
        }
    }

    const string YESNO[2] = {"No", "Yes"};
    std::cout << YESNO[can()] << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  if((a * b) % 2 == 0 )
    System.out.println("Even");
    else
    System.out.println("Odd");
}
}

Measured memory_bytes: 22996
Var     s: String;
        top,d: Longint;
        stk: Array[0..300] Of Char;

Procedure       Nhap;
Var     i: Longint;
Begin
Readln(i);
Readln(s);
End;

Procedure       XuLy;
Var     i: Longint;
        st,t: String;
Begin
top:=0; st:='('; t:=')'; d:=0;
For i:=1 to Length(s) do
        Case s[i] of
                '(':
                        Begin
                        Inc(top);
                        Stk[top]:=s[i];
                        End;
                ')':
                        If (stk[top]<>'(') or (top=0) Then
                                Inc(d)
                        Else Dec(top);
        End;
While top>0 do
        Begin
        Insert(t,s,Length(s)+1);
        Dec(top);
        End;
While d>0 Do
        Begin
        Insert(st,s,1);
        Dec(d);
        End;
End;

Procedure       Xuat;
Begin
Writeln(s);
End;

Begin
Nhap;
XuLy;
Xuat;
End.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repeat(i, n) for(int (i) = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const double EPS = numeric_limits<double>::epsilon();

int main() {
	string s;
	int K;
	cin >> s;
	cin >> K;

	map<string, int> dic;

	for(int i = 0; i < s.length(); i++) {
		string a = s.substr(i, s.length());
		auto itr = dic.find(a);
		string end;
		int idx = 0;

		for(auto it: dic) {
			if (idx == K-1) {
				end = it.first;
				break;
			}
			idx++;
		}
		if (dic.size() > 5) {
			if (end.compare(a) < 0) continue;
		}
		if (itr != dic.end()) continue;


		for(int j = 1; j <= s.length() - i; j++) {
			string a = s.substr(i, j);
			auto itr = dic.find(a);
			if (dic.size() > 5) {
				if (end.compare(a) < 0) continue;
			}
			if (itr != dic.end()) continue;
			// cout << i << " : " << a << endl;
			dic[a]++;
		}
	}

	int idx = 0;
	for(auto it: dic) {
		if (idx == K-1) {
			cout << it.first << endl;
		}
		idx++;
	}
	return 0;
}


Measured memory_bytes: 166528
from functools import reduce

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b // gcd(a, b)

def lcm_list(a):
    return reduce(lcm, a)


def func(m, a):
    val = 0
    for i in a:
        val += m % i
    return val


def main():
    n = input()
    a = list(map(int, input().split(' ')))
    itrmax = lcm_list(a)

    #max_val = max([func(i, a) for i in range(itrmax)])
    max_val = func(itrmax-1, a)
    print(max_val)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3812
def factorial(x, modp):
    curr = 1
    for i in range(1, x + 1):
        curr *= i
        curr %= modp
    return curr


def power(x, n, modp):
    if n == 0:
        return 1

    k = 1
    while n > 1:
        if n % 2:
            k *= x
            k %= modp
        x *= x
        x %= modp
        n //= 2
    
    return k * x % modp


def submit():
    x, y = map(int, input().split())
    
    # (i, j) -> (i + 1, j + 2)の移動方法をs回
    # (i, j) -> (i + 2, j + 1)の移動方法をt回行なったとする
    # t = Y - 2s, s = (2Y - X) / 3となる
    s = 2*y - x
    if s < 0 or s % 3 != 0: # 移動方法なし
        print(0)
        return
    s //= 3

    t = y - 2*s
    if t < 0: # 移動方法なし
        print(0)
        return

    # 全移動n = s + t中のs移動のパターンを数え上げれば良い
    # n_C_sを求めれば良い
    # n! / s! (n - s)! ≡ n! (s!)^modp-2 ((n - s)!)^modp-2
    n = s + t
    modp = 10**9 + 7
    ans = factorial(n, modp) * power((factorial(s, modp)), modp - 2, modp) * power(factorial(n - s, modp), modp - 2, modp)
    ans %= modp
    print(ans)
    
    
if __name__ == "__main__":
    submit()

Measured memory_bytes: 38512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
int INF=1<<29;

vector<vector<int>>G(10000,vector<int>());
vector<ll> Ans(10000);
priority_queue<ll> c;
vector<bool> used(10000);
ll N;

void dfs(int i){
	if(used[i]==true) return;

	//まだ探索してない
	used[i]=true;
	Ans[i]=c.top();
	c.pop();

	//探す
	for(int j=0;j<G[i].size();j++){
		if(used[G[i][j]]==true) continue;

		//まだ探索してない
		dfs(G[i][j]);
	}
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll sum=0;
	cin>>N;
	fill(used.begin(),used.end(),false);
	for(int i=0;i<N-1;i++){
		ll a,b;
		cin>>a>>b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<N;i++){
		ll tmp;
		cin>>tmp;
		sum+=tmp;
		c.push(tmp);
	}
	sum-=c.top();
	//sort(c.begin(),c.end(),greater<ll>());
	dfs(0);

	cout<<sum<<endl;
	for(int i=0;i<N;i++){
		cout<<Ans[i]<<" ";
	}
}

Measured memory_bytes: 1408
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N,M;
	
	cin >> N >> M;

	int k[M], p[M];

	vector<vector<int> > vs;

	rep(i, M)
	{
		cin >> k[i];
		vector<int> s;
		rep(j, k[i])
		{
			int t_s;
			cin >> t_s;
			s.pb(t_s-1);
		}
		vs.pb(s);
	} 
	rep(i, M)
	{
		//int pp; 
		cin >> p[i];
	}
	int t_n = 0;
	rep(i, 1 << N)
	{
		bool find = true;
		rep(j, M)
		{
			int total = 0;
			rep(m, k[j])
			{
				total += ( (i >>vs[j][m]) & 1);
			}
			//cout << "i = " << i << "; j=" << j << "; total=" <<total << endl;
			if ((total & 1) != p[j])
			{
				find = false;
				break;
			}
		}
		if (find)
		{
			t_n++;
		}
	}

	cout << t_n << endl;

	
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let input: Vec<&str> = buf.trim().split(" ").collect();
    let x = input[0];
    let y = input[1];
    if x < y {
        println!("<");
    } else if x == y {
        println!("=");
    } else {
        println!(">");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
 int hel, dmg;
 int atcknum,sisadarah;
 scanf("%d %d", &hel,&dmg);

atcknum = hel/dmg;
sisadarah = hel%dmg;

sisadarah > 0 ? printf("%d",atcknum +1) :printf("%d",atcknum);
  return 0;
}

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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n, l;
	cin >> n >> l;
	int ans = 0;
	int hoge = inf;
	rep(i, 0, n) {
		ans += l + i;
		if (abs(hoge) > abs(l + i)) {
			hoge = l + i;
		}
	}
	ans -= hoge;
	cout << ans << endl;
	return 0;
}

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

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

let id = identity

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

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

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

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

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

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

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

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

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

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

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

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

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

let n = scan "%d" id

let () =
  let d = n mod 10 in
  (match d with
   | 2 | 4 | 5 | 7 | 9 -> "hon"
   | 0 | 1 | 6 | 8 -> "pon"
   | _ -> "bon")
  |> Printf.printf "%s\n"


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

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

using namespace std;

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

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}

  mint operator-() const { return mint(-x); }

  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }

  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }

  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }

  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }

  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }

  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod - 2);
  }

  mint &operator/=(const mint a) {
    return (*this) *= a.inv();
  }

  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

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

  mint result = mint(1);
  for (int i = 1; i <= n; i++) {
    result *= i;
  }
  cout << result.x << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000000
#define MAX_N 200
#define MAX_V MAX_N

// 割ってない状態を S , 割った状態を T として
// S-Tグラフを構築し最小カットを求める

ll N;

// 辺を表す構造体(行先、容量、G[i]における逆辺のインデックス)
struct edge {ll to, cap, rev; };

vector<edge> G[MAX_V];  // グラフの隣接リスト表現 (index: ノード番号)
bool used[MAX_V];       // DFS で既に調べたかのグラフ

// from から to へ向かう容量 cap の辺をグラフに追加する
void add_edge(ll from, ll to, ll cap) {
    G[from].push_back((edge){to, cap, static_cast<ll>(G[to].size())});
    G[to].push_back((edge){from, 0, static_cast<ll>(G[from].size() - 1)});
}

// 増加パスを DFS で探す
ll dfs(ll v, ll t, ll f) {
    if (v == t) { return f; }
    used[v] = true;
    for(ll i = 0; i < G[v].size(); ++i) {
        edge &e = G[v][i];  // v から延びるエッジ i
        if(!used[e.to] && e.cap > 0) {
            ll d = dfs(e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// s から t への最大流を求める
ll max_flow(ll s, ll t) {
    ll flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        ll f = dfs(s, t, INF);
        if(f == 0) { return flow; }
        flow += f;
    }
}

int main()
{
    // s を 0, t を N+1 とする
    ll ans = 0;
    cin >> N;
    for(ll i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        if(a > 0) {
            add_edge(i, N+1, a);
            //add_edge(0, i, 0);
            ans += a;
        } else {
            //add_edge(i, N+1, 0);
            add_edge(0, i, abs(a));
        }
    }
    for(ll i = 1; i <= N; ++i) {
        ll mul = 2;
        ll to = i * mul;
        while(to <= N) {
            add_edge(i, to, INF);
            mul++;
            to = i * mul;
        }
    }
    printf("%lld\n", ans - max_flow(0, N+1));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

int a,b,c;

while(1){

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

if(a==0&&b==0)

break;

if(a>b){

c=a;

a=b;

b=c;

}

printf("%d %d\n",a,b);

}

return 0;

}

Measured memory_bytes: 596
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()
	k := scanInt() - 1

	cnt := make([]int, w+1)
	for i := 1; i <= w; i++ {
		bitExhaustiveSearch(i, func(arr []bool) {
			f := true
			for j := 0; j < i-1; j++ {
				if arr[j] && arr[j+1] {
					f = false
				}
			}
			if f {
				cnt[i]++
			}
		})
	}

	cnt[0] = 1

	memo := make([][]int, h+1)
	for i := 0; i < h+1; i++ {
		memo[i] = make([]int, w)
		for j := 0; j < w; j++ {
			memo[i][j] = -1
		}
	}
	for i := 0; i < w; i++ {
		memo[h][i] = 0
	}
	memo[h][k] = 1

	var dfs func(y, x int) int
	dfs = func(y, x int) int {
		if memo[y][x] != -1 {
			return memo[y][x]
		}
		res := 0
		res += dfs(y+1, x) * (cnt[max(0, x-1)] * cnt[max(0, w-2-x)] % mod) % mod
		if x > 0 {
			res += dfs(y+1, x-1) * (cnt[max(0, x-2)] * cnt[max(0, w-2-x)] % mod) % mod
		}
		if x < w-1 {
			res += dfs(y+1, x+1) * (cnt[max(0, x-1)] * cnt[max(0, w-3-x)] % mod) % mod
		}
		res %= mod
		memo[y][x] = res
		return res
	}

	fmt.Fprintln(wr, dfs(0, 0))
}

const mod = 1000000007

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i>>uint(j)&1 == 1 {
				a[j] = true
			} else {
				a[j] = false
			}
		}
		fn(a)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string> 
using namespace std;
int main(){
  long long y,m,d,b,ka,t,w,ki;
  int i,j,k,p;
  long long day,base=0,ba=1872000;
  int mo[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  string str;
  cin>> str;
  while(str[0]!='#'){
    y=0;m=0;d=0;i=0;day=0;p=0;
    while(str[i]!='\0'){
      if(str[i]=='.') p++;
      i++;
    }
    if(p==2){
      i=0;
      while(str[i]!='.') i++;
      for(j=0;j<i;j++){
	y*=10;
	y+=str[j]-'0';
      }
      i++;
      k=i;
      while(str[i]!='.') i++;
      for(j=k;j<i;j++){
	m*=10;
	m+=str[j]-'0';
      } 
      i++;
      k=i;
      while(str[i]!='\0') i++;
      for(j=k;j<i;j++){
	d*=10;
	d+=str[j]-'0';
      }
      //cout << y << " " << m << " " << d << endl;
      if(y==2012) {
	day=d-21;
      }else{
	day=10;
	for(i=2013;i<y;i++)
	  if((i%4==0&&i%100!=0)||i%400==0) day+=366;
	  else day+=365;
	for(i=1;i<m;i++) day+=mo[i];
	if(2<m&&((y%4==0&&y%100!=0)||y%400==0)) day++;
	day+=d;
      }
      while(ba<day) day-=ba;
      b=day%(13*20*20*18*20)/(20*20*18*20);
      ka=day%(20*20*18*20)/(20*18*20);
      t=day%(20*18*20)/(18*20);
      w=day%(18*20)/20;
      ki=day%(20);
      cout << b << "." << ka << "." << t << "." << w << "." << ki << endl;
    }else{
      i=0;b=0;ka=0;t=0;w=0;ki=0;
      while(str[i]!='.') i++;
      for(j=0;j<i;j++){
	b*=10;
	b+=str[j]-'0';
      }
      i++;
      k=i;
      while(str[i]!='.') i++;
      for(j=k;j<i;j++){
	ka*=10;
	ka+=str[j]-'0';
      } 
      i++;
      k=i;
      while(str[i]!='.') i++;
      for(j=k;j<i;j++){
	t*=10;
	t+=str[j]-'0';
      }
      i++;
      k=i;
      while(str[i]!='.') i++;
      for(j=k;j<i;j++){
	w*=10;
	w+=str[j]-'0';
      } 
      i++;
      k=i;
      while(str[i]!='\0') i++;
      for(j=k;j<i;j++){
	ki*=10;
	ki+=str[j]-'0';
      }
      //cout << b << "." << ka << "." << t << "." << w << "." << ki << endl;
      day =b*20*20*18*20+ka*20*18*20+t*18*20+w*20+ki;
      
      y=2012;m=12;d=21;
      if(day<=10) d+=day;
      else{
	day-=10;
	y=2013;
	int f1=0;
	while(day>365&&f1==0){
	  if((y%4==0&&y%100!=0)||y%400==0) 
	    if(day==366) f1=1;
	    else day-=366;
	  else day-=365;
	  if(f1==0)y++;
	}
	m=1;int flag=0;
	//cout << day << endl;
	while(day>mo[m]&&flag==0){
	  if(m==2&&((y%4==0&&y%100!=0)||y%400==0)) {
	    if(day>29) {
	      day-=29;
	      m++;
	      
	    }else{
	      flag=1;
	    }
	  }else{
	    day-=mo[m];
	    m++;
	  }
	}
	//cout << day << endl;
	d=day;
      }
      cout << y << "." << m << "." << d << endl;
    }
    cin >> str;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A==B) {
        cout << C << endl;
    } else if(B==C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (var i = 1; i < N; i++)
            {
                if (H[i] > H[i - 1]) H[i]--;
                if (H[i] < H[i - 1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 28124
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
ll a[N],b[N];
ll cmp(ll a,ll b)
{
    return a>b;
}
ll n,m,v,p;
bool judge(ll mid)
{
    if(mid<=p)
    {
        return 1;
    }
    if(a[mid]+m<a[p])
    {
        return 0;
    }
    if(v<=p-1&&a[mid]+m>=a[p])
        return true;
    for(int i=1;i<=n;i++)
    {
        b[i]=a[i];
    }
    ll temp=0;
    for(int i=1;i<p;i++)
    {
        b[i]+=m;
        temp+=m;
    }
    ll inx=n,cnt=v-p+1;
    while(inx>mid&&cnt>1)
    {
        temp+=m;
        inx--;
        cnt--;
        b[inx]+=m;
    }
    temp+=m;
    ll now=a[mid]+m;
    ll res=m*v-temp;
    //中间还能被填多少
    for(int i=p;i<mid;i++){
        ll add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
    }
    return now>=b[p]&&res<=0;
}
int main()
{
    cin>>n>>m>>v>>p;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n,cmp);
    int l=1,r=n;
    ll ans=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(judge(mid))
        {
            ans=mid;
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5192
/*
Author: yww
Language: C++
Mail: weeerrr720@qq.com
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
const int inf=0x3fffffff;
int s[5];
int ans=inf;
int n;
int a[10];
int A,B,C;
void dfs(int x,int w)
{
	if(x>n)
	{
		if(!s[1]||!s[2]||!s[3])
			return;
		int temp=0;
		temp+=abs(A-s[1]);
		temp+=abs(B-s[2]);
		temp+=abs(C-s[3]);
		if(temp+w<200)
			int xxx=1;
		ans=min(ans,temp+w);
		return;
	}
	for(int i=1;i<=4;i++)
	{
		int w2=w;
		if(s[i]&&i!=4)
			w2+=10;
		s[i]+=a[x];
		dfs(x+1,w2);
		s[i]-=a[x];
	}
}
int main()
{
	scanf("%d%d%d%d",&n,&A,&B,&C);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

N, M = MI()
ans = 0
if N >= 2:
    ans += N*(N-1) / 2
if M >= 2:
    ans += M*(M-1) / 2
print(int(ans))

Measured memory_bytes: 3060
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf")]*n
dp[0] = 0

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

print(dp[-1])

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int a,b,c;
	cin >> a >> b >> c;
	
	if(a == b && b != c)
		cout << "Yes";
	else if(a == c && c != b)
		cout << "Yes";
	else if(b == c && a != b)
		cout << "Yes";
	else
		cout << "No";
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int N;
ll x;

int main(int argc, char const *argv[]) {
	cin >> N >> x;
	ll past, cur;
	ll res = 0;
	cin >> past;
	for (int i = 1; i < N; i++) {
		cin >> cur;
		if (past + cur > x) {
			res += past + cur - x;
			cur = max(x - past, (ll)0);
		}
		past = cur;
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000000000000000;

main(){
    int n;
    cin>>n;
    ll a[n];
    ll prod = 1;
    for(int i =0;i<n;i++){
        cin>>a[i];
        if(a[i] == 0){
            cout<<"0";
            exit(0);
        }
    }    
    for(int i=0;i<n;i++){
        if(a[i]<= mod/prod)
        prod*= a[i];
        else{
            cout<<"-1";
            exit(0);
        }
    }
    cout<<prod<<"\n";
}

Measured memory_bytes: 4428
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int m = 0, f = 0, r = 0, i, n = 0;
    char score[100];
    for( i = 0 ; ; i++ ){
        scanf("%d %d %d",&m,&f,&r);
        if( m == -1 && f == -1 && r == -1 ){
            break;
        }
        else if( m == -1 || f == -1 ){
            score[i] = 'F';
            n++;
        }
        else if(m+f>=80){
            score[i] = 'A';
            n++;
        }
        else if(m+f>=65){
            score[i] = 'B';
            n++;
        }
        else if(m+f>=50){
            score[i] = 'C';
            n++;
        }
        else if(m+f>=30 && r>=50){
            score[i] = 'C';
            n++;
        }
        else if(m+f>=30){
            score[i] = 'D';
            n++;
        }
        else{
            score[i] = 'F';
            n++;
        }
    }
    
    for( i = 0 ; i < n ; i++ ){
        printf("%c\n",score[i]);
    }
    
    return 0;
}

Measured memory_bytes: 600
package main

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

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	ab := sc.readInt()
	bc := sc.readInt()
	_ = sc.readInt()
	fmt.Println(ab * bc / 2)
}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] array = new int[n];
        final int[] sortedArray = new int[n];

        for (int i = 0; i < n; i++) {
            final int tmp = scanner.nextInt();
            array[i] = tmp;
            sortedArray[i] = tmp;
        }

        Arrays.sort(sortedArray);
        final int formerMedian = sortedArray[(n - 1) / 2];
        final int latterMedian = sortedArray[n / 2];
        
        for (final int value : array) {
            if (value <= formerMedian) {
                System.out.println(latterMedian);
            } else {
                System.out.println(formerMedian);
            }
        }
    }
}


Measured memory_bytes: 94044
from fractions import gcd
from functools import reduce
from operator import floordiv


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    *a, = map(floordiv, a, (2,) * n)
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (m + 1 if _a % c or not _a // c % 2 else _a for _a in a))
    return str(max(((m // l + 1) // 2, 0)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[105],n,b[105];
int ex[25][25];
int main(){
	cin>>n; repn(i,n) a[i] = INF;
	rep(i,n-1){
		cin >> b[i];
		a[i+1] = min(a[i+1],b[i]);
		a[i+2] = min(a[i+2],b[i]);
	}
	ll ans = 0;
	repn(i,n) ans+=a[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m;
  cin >> n >> m;
  vi pos(n, -1), s(m), c(m);
  for(int i = 0; i < m; i++){
    cin >> s[i] >> c[i];
    s[i]--;
    if(pos[s[i]] != -1 && pos[s[i]] != c[i]) return cout << -1, 0;
    pos[s[i]] = c[i];
  }
  if(n > 1 && pos[0] == 0) return cout << -1, 0; // leading 0
  if(pos[0] == -1 && n > 1) pos[0] = 1;
  else if(pos[0] == -1 && n == 1) pos[0] = 0;
  for(int i = 1; i < n; i++){
    if(pos[i] == -1) pos[i] = 0;
  }
  for(int x : pos) cout << x;
}

Measured memory_bytes: 256
N =int(input())
data = []
for i in range(N):
    data.append(int(input()))

data.sort()

small = data[:len(data)//2]
large = data[len(data)//2:]

if N>4:
    large = [large[0]]+large[2:]+[large[1]]

ndata = []
pos = 0
if N%2==0:
    while pos < len(small):
        ndata.append(large[pos])
        ndata.append(small[pos])
        pos += 1
else:
    while pos < len(small):
        ndata.append(large[pos])
        ndata.append(small[pos])
        pos += 1
    ndata.append(large[pos])

summ1 = 0
for i in range(N-1):
    summ1 += abs(ndata[i]-ndata[i+1])

if N%2 == 0:
    summ2 = summ1
else:
    small = data[:len(data)//2+1]
    large = data[len(data)//2+1:]
    if N>4:
        small = [small[-1]]+small[:-2]+[small[-2]]
    ndata = []
    pos = 0
    while pos < len(large):
        ndata.append(small[pos])
        ndata.append(large[pos])
        pos += 1
    ndata.append(small[pos])
    summ2 = 0
    for i in range(N-1):
        summ2 += abs(ndata[i]-ndata[i+1])

print(max(summ1,summ2))

Measured memory_bytes: 9712
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

int main()
{

	double a = 1, b = 0, c = 100, d = 0, e = 0, maxy = 0, min = 0, ans = 1, count = 0;

	int yoko = 0, tate = 0;
	int array[1001] = { 0 };
	std::string output, output2, output3, input = {};
	bool okada = false;


	cin >> a >> b >> c;
	
	for (int i = 1; i <= a; i++) {
		cin >> array[i];
		ans=std::abs(c-(b - 0.006*array[i]));
		//cout << ans << endl;
		if (i == 1) {
			min = ans;
			count = i;
		}
		else if (min>ans) {
			min = ans;
			count = i;
		}
	}
	cout << count << endl;

}






Measured memory_bytes: 256
n, m = (int(x) for x in input().split())
l = 0
r = n + 1
for i in range(m):
  ll, rr = (int(x) for x in input().split())
  l = max(l, ll)
  r = min(r, rr)
if r - l + 1 > 0:
  print(r - l + 1)
else:
  print(0)
  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void fc(vector<int> &imos, int index, int a){
  int l = index - a;
  int r = index + a + 1;
  if(l < 0) l = 0;
  imos.at(l)++;
  if(imos.size() <= r) return ;
  imos.at(r)--;
  return ;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  rep(_, k){
    vector<int> imos(n, 0);
    bool fin = true;
    rep(i, n){
      fc(imos, i, a.at(i));
    }
    int co = 0;
    rep(i, n){
      co += imos.at(i);
      a.at(i) = co;
      if(a.at(i) != n) fin = false;
    }
    if(fin == true) break;
  }
  rep(i, n){
    if(i != 0) cout << " ";
    cout << a.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4732
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, K;
ll p[201010];
ll sum[201010];

int main()
{
    cin >> N >> K;
    repe(i, 1, N)
    {
        cin >> p[i];
        sum[i] = sum[i - 1] + p[i];
    }
    ll ans = 0;
    repe(i, 1, N - K + 1)
    {
        ans = max(ans, sum[i + K - 1] - sum[i - 1]);
    }
    double ansd = ans;
    double Kd = K;
    cout << fixed;
    cout << setprecision(20) << (ansd + K) / 2.0 << endl;
}


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

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

	rep1(i, n/7)
	{
		rep1(j, n / 4)
		{
			if (i*7 + j*4 == n)
			{
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
a=[0]*m
for _ in [0]*n:
    for i in [int(x)-1 for x in input().split()][1:]:
        a[i]+=1
ans=0
for i in range(m):
    if a[i]==n:
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
	char s[12];
	int i,c=0;
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		if((i%2==0)&&(s[i]!='h')) c=1;
		else if((i%2==1)&&(s[i]!='i')) c=1;
	}
	if(i%2==1) c=1;
	printf(c==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    string s;
    cin >> s;
    rep(i,1<<3) {
        int now = s[0]-'0';
        string ns = "";
        ns += s[0];
        rep(j,3) {
            if(i>>j&1) {
                now += s[j+1]-'0';
                ns += "+";
            } else {
                now -= s[j+1]-'0';
                ns += "-";
            }
            ns += s[j+1];
        }
        if(now == 7) {
            cout << ns << "=7" << endl;
            return 0;
        }
    }
}


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

int main()
{
    int N,M,count=0;
    cin>>N>>M;
    vector<int>A(N);
    for(int i=0;i<M;i++){
        cin>>A.at(i);
        count+=A.at(i);
    }
    if(N>=count){
        cout<<N-count<<endl;
    }else{
        cout<<-1<<endl;
    }
}


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

int main(){
  int a[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<3;i++){
    a[1][i] -= a[0][i];
    a[2][i] -= a[0][i];
    a[0][i] = 0;
  }
  for(int i=0;i<3;i++){
    a[i][1] -= a[i][0];
    a[i][2] -= a[i][0];
    a[i][0] = 0;
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(a[i][j] != 0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a , b , c , d , e , k;
    cin>> a ;
    cin>> b ;
    cin>> c ;
    cin>> d ;
    cin>> e ;
    cin>> k ;
    if (e-a <= k) {
        if (d-a <= k) {
            if (c-a <= k) {
                if (b-a <= k) {
                    if (e-b <= k) {
                        if (d-b <= k) {
                            if (c-b <= k) {
                                if (e-c <= k) {
                                    if (d-c <= k) {
                                        if (e-d <= k) {
                                            cout<< "Yay!";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    else {
        cout<< ":(";
    }
    return 0;
}


Measured memory_bytes: 3640