akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int count = 0;
	for (int i = 0; i < n; ++i) {
		if (p[i] != i + 1) {
			count++;
		}
	}
	if (count == 0 || count == 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


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

using namespace std;

int main() {
  int n;cin>>n;
  vector<int> p(n);
  rep(i,n)cin>>p[i];
  sort(p.begin(),p.end());
  int ans=0;
  rep(i,n){
    if(i==n-1)p[i]/=2;
    ans+=p[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[1000][1000];
  for (int i = 0;i < N;++ i) for (int j = 0;j < N - 1;++ j) {
    cin >> A[i][j];
    -- A[i][j];
  }
  int battle[1000], fight[1000];
  for (int i = 0;i < N;++ i) battle[i] = fight[i] = 0;
  int day = 0, match = N * (N - 1);
  do {
    int check = match;
    ++ day;
    for (int i = 0;i < N;++ i) {
      if (battle[i] >= N - 1) {
        fight[i] = day;
        continue;
      }
      int opponent = A[i][battle[i]];
      if (opponent < i && fight[opponent] < day && A[opponent][battle[opponent]] == i) {
        match -= 2;
        ++ battle[i];
        ++ battle[opponent];
        fight[i] = fight[opponent] = day;
      }
    }
    if (check == match) {
      cout << -1 << endl;
      return 0;
    }
  } while(match > 0);
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 4096
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    ll k, a, b;
    cin >> k >> a >> b;

    ll cookie = 1;

    if(b - a > 2){
        cookie = a;
        k -= a - 1;
        cookie += k / 2 * (b - a);
        k %= 2;

        cookie += k;
        
    } else {
        cookie += k;
    }

    cout << cookie << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    ll xor1 = a[0] ^ a[0];
    ll xor2 = a[0];
    rep(i, 1, n) {
        xor1 ^= (a[i] ^ a[i]);
        xor2 ^= a[i];
    }
    if (xor2 == xor1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define AndIamMr_Awesome ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);

using namespace std;

typedef long long int lli;


int main()
{
	AndIamMr_Awesome;
	lli i=1,j,t,d,n,k,x=9999999999,a,b,c,y=0,z,co,sum=0,p=0;
	cin>>n;
	map<string,lli> m;
	m["AC"]=0,m["WA"]=0,m["TLE"]=0,m["RE"]=0;
	
	while(n--)
	{
		string s;
		cin>>s;
		m[s]++;	
	}
	cout<<"AC x "<<m["AC"]<<"\n";
	cout<<"WA x "<<m["WA"]<<"\n";
	cout<<"TLE x "<<m["TLE"]<<"\n";
	cout<<"RE x "<<m["RE"]<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int *v = new int[n];
	int *c = new int[n];
	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];

	int max = 0;
	int x = 0;
	int y = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) {
			x += v[i];
			y += c[i];
		}
	}
	max = x - y;

	cout << max << endl;

	delete v;
	delete c;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	if s == "zyxwvutsrqponmlkjihgfedcba" {
		fmt.Println(-1)
	} else if len(s) < 26 {
		d := make([]bool, 26)
		for _, r := range s {
			d[int(r)-97] = true
		}
		x := -1
		for i := 0; i < 26; i++ {
			if !d[i] {
				x = i
				break
			}
		}
		fmt.Println(s + string(rune(x+97)))
	} else {
		idx := -1
		w := mod
		for j := 0; j < len(s); j++ {
			x := int(rune(s[j])) - 97
			z := mod
			for i := j; i < len(s); i++ {
				y := int(rune(s[i])) - 97
				if x < y && y < z {
					idx = j
					z = y
					w = y
				}
			}
		}
		fmt.Println(s[:idx] + string(rune(w+97)))
	}
}


Measured memory_bytes: 640
#-*- encoding:utf-8 -*-
import math

while 1:
    n = int(input())
    if n == 0:
        break
    max = 0
    min = 9999
    sum = 0
    for i in range(n):
        s = int(input())
        if max < s:
            max = s
        if min > s:
            min = s
        sum = sum + s
    ans = math.floor((sum - min - max) / (n-2))
    print(ans)

Measured memory_bytes: 7560
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
ans = 0
d = 2
while d**2 <= n:
    if n % d != 0:
        d += 1
        continue
    dd = d
    while n % d == 0:
        n //= d
        d *= dd
        ans += 1
    while n % dd == 0:
        n //= dd
    d = dd + 1
    
if n != 1:
    ans += 1
print(ans)



Measured memory_bytes: 27068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
char k[1000005];
int dir=1,hd,tl,q,t;
int main(){
	hd=2e5+5,tl=hd-1;
	cin>>s;
	for(int i=0;i<s.size();i++)k[++tl]=s[i];
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>t;
		if(t==1){
			dir^=1;
		}
		else{
			int f; char c;
			cin>>f>>c;
			if(f==2&&dir==1||f==1&&dir==0)k[++tl]=c;
			else k[--hd]=c;
		}
	}
	if(dir){
		for(int i=hd;i<=tl;i++)cout<<k[i];
	}
	else{
		for(int i=tl;i>=hd;i--)cout<<k[i];
	}
    return 0;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int c = 0, r = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            ++r;
        } else {
            ++c;
        }
    }
    cout << r + min(c, 2 * k);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    string s;
    int c0=0, c1=0;
        cin >> s;
        for(int i=0; i<s.size(); i++){
            if(s[i]-'0') c1 += 1;
            else c0 += 1;
        }
        cout << 2*min(c0, c1) << endl;
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int a[3][3];
int n;

bool mar[3][3];
map<int,pair<int,int> > m;

int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    for(int i=0;i<3;i++)
    	for(int j=0;j<3;j++)
    	{
    		cin>>a[i][j];
    		m[a[i][j]]=mp(i,j);
		}
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(m.count(x))
		{
			mar[m[x].FF][m[x].SS]=1;
		}
	}
	bool flag=false;
	for(int i=0;i<3;i++)
	{
		if(mar[i][0]&&mar[i][1]&&mar[i][2])
		{
			flag=true;
			break;
		}
	}
	for(int i=0;i<3;i++)
	{
		if(mar[0][i]&&mar[1][i]&&mar[2][i])
		{
			flag=true;
			break;
		}
	}
	if(mar[0][0]&&mar[1][1]&&mar[2][2])
		flag=true;
	if(mar[0][2]&&mar[1][1]&&mar[2][0])
		flag=true;
	cout<<(flag?"Yes":"No")<<endl;
    /* end code */
	return 0;
}

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

int main() {
  int N, top;
  cin >> N >> top;
  
  int count = 1;
  for (int i = 1; i < N; ++i) {
    int H;
    cin >> H;
    if (top <= H) {
      count++;
      top = H;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
n = list(map(int, input().split(' ')))
sum = n[1]
cnt = 1
if n[1]==1:
    cnt = 0
else:
    for i in range(1,40):
        sum = sum - n[0]
        if sum <= 0 :
            break
        else:
            sum += 1
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a;
    string st;
    cin>>a>>st;
    if(a>=3200){
        cout<<st<<endl;
    }else{
        cout<<"red"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

#if 1
int main()
{
	int n;
	cin >> n;

	vector <int> x(n);
	vector <int> y(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> x[i] >> y[i];
	}

	const int DIV = 5000000;
	const double r = 1e12;

	vector <int> freq(n);

	vector <double> distfromCenter(n);
	for (int i = 0; i<n; ++i)
	{
		distfromCenter[i] = SQ(x[i]) + SQ(y[i]);
	}


	for (int i=0;i<DIV;++i)
	{
		double ang = (double)i * 2.0 * PI / DIV;
		double ax = r * cos(ang);
		double ay = r * sin(ang);

		double minDist = DBL_MAX;
		int minID = NG;

		for (int k=0;k<n;k++)
		{
//			double dist = SQ(ax - x[k]) + SQ(ay - y[k]);
			double dist = -2.0*(ax*x[k] + ay*y[k]) + distfromCenter[k];
			// BEGIN CUT HERE
//			cerr << " k=" << k << " dist=" << dist << endl;
			// END CUT HERE

			if (dist < minDist)
			{
				minDist = dist;
				minID = k;
			}
		}
		freq[minID]++;
	}

	for (int i = 0; i < n; ++i)
	{
		printf("%.16f\n", (double)freq[i]/DIV);
	}

	return 0;
}

#else


int sum(ll n)
{
	int ret = 0;
	while(n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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


	int ans = sum(n);

	ll base = 1;
	for (ll d=0;;d++)
	{
		ll now = n * base;
		if (now == 0)
		{
			break;
		}
		amax(ans, sum(now));
		if (now >= 2)
		{
			amax(ans, sum(now - 1));
		}

		base *= 10;
		n /= 10;
	}

	cout << ans << endl;

	return 0;
}

#endif

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val hs = readLongList()
    val dp = Array(n) { 10000000000 }
    dp[0] = 0
    for (i in 0 until n) {
        for (j in 1..k) {
            if (i + j < n) dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(hs[i + j] - hs[i]))
        }
    }
    println(dp[n - 1])
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 121332
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<usize>();
    let _=read::<usize>();
    let mut s=(0..n).map(|_|read::<String>()).collect::<Vec<String>>();
    s.sort();
    for t in s{print!("{}",t)}
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int n,a[MAXN];
ll dp[MAXN];
int main()
{
	si(n);
	for(int i=1;i<=n;++i)si(a[i]);
	dp[1]=0;dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;++i)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%lld\n",dp[n]);
 } 

Measured memory_bytes: 1408
lst0 = [1, 3, 5, 7, 8, 10, 12]
lst1 = [4, 6, 9, 11]
x, y = map(int, input().split())

if (x in lst0 and y in lst0) or (x in lst1 and y in lst1):
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3060
H, W = map(int, input().split())
M = [list(map(int, input().split())) for _ in range(H)]

s = []
for i in range(H):
  for j in range(W-1):
    if M[i][j] & 1:
      s.append("{} {} {} {}".format(i+1, j+1, i+1, j+2))
      M[i][j+1] += 1
for i in range(H-1):
  if M[i][W-1] & 1:
    s.append("{} {} {} {}".format(i+1, W, i+2, W))
    M[i+1][W-1] += 1
print(len(s))
print("\n".join(s))


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

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

    std::vector<bool> a(1000000001, false);
    int index, i = 0;
    while(std::cin >> index){
        if(!a.at(index)){
            a.at(index) = true;
        }else{
            break;
        }
        ++i;
        
//        std::cout << i << std::endl;
    }

    std::string ans = "YES";
    if(i != n){
        ans = "NO";
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, ms, tp, ct = 0;
    queue<pair<string, int>> cola;
    string np;
    cin >> n >> ms;
    while (n--) {
        cin >> np >> tp;
        cola.push(make_pair(np, tp));
    }
    while (!cola.empty()) {
        if (cola.front().second <= ms) {
            ct += cola.front().second;
            cout << cola.front().first << " " << ct << "\n";
            cola.pop();
        } else {
            ct += ms;
            cola.front().second -= ms;
            cola.push(cola.front());
            cola.pop();
        }
    }
    return 0;
}



Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b);




}

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

int main(){
  int step = 0, aflag = 0, len = 0;
  char s[51];
  scanf("%s", s);
  
  while(s[len]){
    if(step == 0){
      if(aflag == 0 && s[len] == 'A'){
        aflag = 1;
      } else if(s[len] == 'K'){
        step++;
        aflag = 0;
      } else {
        break;
      }
    } else if(step == 1){
      if(s[len] == 'I'){
        step++;
      } else {
        break;
      }
    } else if(step == 2){
      if(s[len] == 'H'){
        step++;
      } else {
        break;
      }
    } else if(step == 3){
      if(aflag == 0 && s[len] == 'A'){
        aflag = 1;
      } else if(s[len] == 'B'){
        step++;
        aflag = 0;
      } else {
        break;
      }
    } else if(step == 4){
      if(aflag == 0 && s[len] == 'A'){
        aflag = 1;
      } else if(s[len] == 'R'){
        step++;
        aflag = 0;
      } else {
        break;
      }
    } else if(step == 5){
      if(s[len] != 'A' || aflag == 1){
        step++;
      } else if(aflag == 0 && s[len] == 'A'){
        aflag = 1;
      }
    }
    len++;
  }
  
  if(step == 5){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  
  return 0;
}

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

int main() {
	int n,a,b,c,d; string s;
	cin>>n>>a>>b>>c>>d>>s;
	if(c<d) cout<<(s.substr(a-1,d-a+1).find("##")==-1?"Yes":"No")<<"\n";
	else cout<<((s.substr(b-2,d-b+3).find("...")!=-1&&s.substr(a-1,c-a+1).find("##")==-1)?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 772
#include<stdio.h>

int main(){
     
     int panjang,lebar,luas,keliling;
     scanf("%d %d",&panjang,&lebar);
     luas=panjang*lebar;
     keliling=(panjang*2)+(lebar*2);
     printf("%d %d\n",luas,keliling);
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1872
program step
  implicit none
  integer :: n, i
  integer(8) :: a(200000) = 0, x = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 2, n
    if (a(i) >= a(i - 1)) cycle
    x = x + a(i - 1) - a(i)
    a(i) = a(i - 1)
  end do
  write(*,'(i0)') x
end program step

Measured memory_bytes: 4620
#include<stdio.h>
#include<string.h>
int main(){
  char s[1001];
  int i;
  fgets(s,1000,stdin);
  for(i=0;s[i]!='\0';i++){
    s[i]=toupper(s[i]);
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
auto dp = make_v<int>(101, 101);
auto s = make_v<char>(101, 101);

int H, W, ans = 0;
char first, end;
int solve(int i, int j)
{
    int c1 = 100000, c2 = 100000;
    if (i == H - 1 and j == W - 1)
    {
        return 0;
    }
    if (i >= H or j >= W)
    {
        return 1000000;
    }
    if (dp[i][j] != -1)
    {
        return dp[i][j];
    }
    if (i + 1 < H)
    {
        if (s[i][j] != first and s[i + 1][j] == first)
        {
            c1 = 0;
        }
        else if (s[i + 1][j] != s[i][j])
        {
            c1 = 1;
        }
        else
        {
            c1 = 0;
        }
    }
    if (j + 1 < W)
    {
        if (s[i][j] != first and s[i][j + 1] == first)
        {
            c2 = 0;
        }
        else if (s[i][j + 1] != s[i][j])
        {
            c2 = 1;
        }
        else
        {
            c2 = 0;
        }
    }
    dp[i][j] = min(solve(i + 1, j) + c1, solve(i, j + 1) + c2);
    /*    else if (i + 1 < H and j + 1 >= W)
    {
        dp[i][j] = solve(i + 1, j) + c1;
    }
    else if (i + 1 >= H and j + 1 < W)
    {
        dp[i][j] = solve(i, j + 1) + c2;
    }
    else
    {
        dp[i][j] = 100000;
    }*/

    return dp[i][j];
}
int main()
{

    cin >> H >> W;
    fill_v(dp, -1);
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> s[i][j];
        }
    }
    first = s[0][0];

    ans = solve(0, 0);
    if (s[0][0] == '#' and s[H - 1][W - 1] == '#')
    {
        ans++;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t, flag) int tc = 1; if(flag) cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n;
string str;
int dp[3005][3005];


int32_t main(){
    fastio;
    w(t, false){
        cin >> n;
        cin >> str;
        dp[1][1] = 1;
        for(int pos = 2; pos <= n; ++pos){
            int sums[3005];
            for(int i = 1; i < pos; ++i)
                sums[i] = (sums[i-1] + dp[pos-1][i])%mod;
            
            for(int b = 1; b <= pos; ++b){
                int L, R;
                if(str[pos-2] == '<')
                    L = 1, R = b-1;
                else 
                    L = b, R = pos-1;

                if(L <= R)
                    dp[pos][b] = (dp[pos][b] + (sums[R] - sums[L-1] + mod))%mod;

            }
        }
        int ans = 0;
        for(int b = 1; b <= n; ++b)
            ans = (ans + dp[n][b])%mod;

        cout << ans << endl;
    }
}

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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		rep(j, n) {
			ll tmp = ans;
			tmp += s[i][j];
			rep(k, n) {
				if(j == k) continue;
				tmp -= c[k] * (i+1-last[k]);
			}
			if(mx < tmp) {
				mx = tmp;
				now = j;
			}
		}
		ans = mx;
		last[now] = i;
		t[i] = now+1;
	}
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp((1 << V), vector<int>(V, -1));
	function<int(int, int)>tsp = [&](int S, int v) {
		if (dp[S][v] != -1)return dp[S][v];
		if (S == (1 << V) - 1 && v == 0)return dp[S][v] = 0;
		int ret(INF);
		rep(i, 0, V) {
			if (!(S&(1 << i)))chmin(ret, tsp(S | (1 << i), i)+G[v][i]);
		}
		return dp[S][v] = ret;
	};
	int ans = tsp(0, 0);
	cout << (ans == INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 6176
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000; // 十分大きな値

int main(){
    int n;
    cin >> n;
    vector<int> p(n,0),q(n,0);
    vector<int> a(n,0);
    
    rep(i,n) {
        cin >> p[i];
    }
    rep(i,n) cin >> q[i];
    rep(i,n)  a[i] = i+1;

    int i=0;
    int ans = 0;
    
    do{
        //入力の順列が何番目の縦列にマッチするか試す
        int j;
        for(j = 0;j < n;++j){
            if(p[j] != a[j]) break;
        }
         if(j == n) ans += i;//j == n:マッチした a
         //qについても同様に
         for(j = 0;j < n;j++){
             if(q[j] != a[j]) break;
         }
         if(j == n) ans -= i;// b
         i++;
        //ansに+= ,-=することでa-bを計算していることと同じになる
    }while(next_permutation(a.begin(),a.end()));

    cout << abs(ans) << endl;
}

Measured memory_bytes: 256
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

ll gcd (ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
ll lcm (ll a, ll b) {
    return (a/gcd(a, b))*b; 
}

ll n, m, aa, ans, locm=1, maxi, cons;

pls give {
    AC;
    cin >> n >> m;
    for (int i=0; i<n; i++) {
        cin >> aa;
        locm = lcm(locm, aa);
        int j=0;
        while (aa%2 == 0) {
            aa /= 2;
            j++;
        }
        if (i == 0) cons = j;
        else if (j != cons) {
            cout << 0;
            return 0;
        }
    }

    ans = (2*m)/locm;
    ans = ceil(ans/((double)2));
    
    cout << ans-maxi;
}

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}

int dp[3001][3001];

int func(int i,int j,int n,int a[]){
    if(i>j) return 0;
    if(dp[i][j]!=-1) return dp[i][j];

    int op1=a[i]+min(func(i+2,j,n,a),func(i+1,j-1,n,a));
    int op2=a[j]+min(func(i+1,j-1,n,a),func(i,j-2,n,a));
    return dp[i][j]=max(op1,op2);
}

void solve(){
	int n;
    cin>>n;
    int a[n];
    memset(dp,-1,sizeof(dp));
    int s=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        s+=a[i];
    }
    int e=func(0,n-1,n,a);
    int w=s-e;
    cout<<e-w;
}
    

int32_t main()
{
   // FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}


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

int main() {
	int n,k,i,j,ans,cur,res;
	cin >> n;
	vector<int> x(n);
	for(i=0; i<n; i++){
		cin >> x[i];
	}
	
	ans=100000000;
	for(cur=1; cur<=100; cur++){
		res=0;
		for(i=0; i<n; i++){
			res+=(x[i]-cur)*(x[i]-cur);
		}
		ans=min(ans,res);
	}
	cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

t = input()
ans = t

for p in range(1, 50):
    S = 2 * sum(3 ** i for i in range(p)) - 1
    if S > t:
        break
    num = 2 * p - 1
    rem = t - S
    for i in range(p):
        num += rem % 3
        rem /= 3
    num += rem
    ans = min(ans, num)
print ans


Measured memory_bytes: 6176
N, K = map(int, input().split())
Nm = N % K
ans = Nm
A = [Nm]
while 1:
    if ans == 0:
        break
    elif abs(Nm-K) in A:
        break
    else:
        if abs(Nm-K) < ans:
            ans = abs(Nm-K)
        A.append(abs(Nm-K))
        Nm = abs(Nm-K)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ull budget = 1000;
    int N;
    cin >> N;
    vector<int> A(N+1);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    ull kabu = 0;
    if (A[0] < A[1]) {
        kabu = budget / A[0];
        budget = budget - kabu * A[0];
    }
    for (int i=1; i<N-1; i++) {
        if (A[i] > A[i-1]) {
            budget = budget + kabu * A[i];
            kabu = 0;
            if (A[i+1] > A[i]) {
                kabu = budget / A[i];
                budget = budget - kabu * A[i];
            }
        }
        else if (A[i+1] > A[i]) {
            kabu = budget / A[i];
            budget = budget - kabu * A[i];
        }
    }
    budget = budget + kabu * A[N-1];
    cout << budget << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d; cin>>a>>b>>c>>d;
  while(1){
    c-=b; if(c<1) break;
    a-=d; if(a<1) break;
  }
  cout<<(c<1?"Yes":"No");
}

Measured memory_bytes: 3468
#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>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>

using namespace std;

const double PI = 3.14159265358979;

struct Node {
	int parent = -1;
	int left = -1, right = -1;
	int depth = 0, height = 0;

};

void setDepth(Node *tree, int id, int deep) {

	tree[id].depth = deep;

	if (tree[id].right != -1)
		setDepth(tree, tree[id].right, deep + 1);
	if (tree[id].left != -1)
		setDepth(tree, tree[id].left, deep + 1);
}

int setHeight(Node *tree, int id) {

	int lh = 0, rh = 0;
	if (tree[id].left != -1)
		lh = setHeight(tree, tree[id].left) + 1;
	if (tree[id].right != -1)
		rh = setHeight(tree, tree[id].right) + 1;
	tree[id].height = max(lh, rh);
	return tree[id].height;
}

void preorder(Node* tree, int root) {

	if (root != -1) {
		printf(" %d", root);
		preorder(tree, tree[root].left);
		preorder(tree, tree[root].right);
	}
}

void inorder(Node* tree, int root) {

	if (root != -1) {
		inorder(tree, tree[root].left);
		printf(" %d", root);
		inorder(tree, tree[root].right);
	}
}

void postorder(Node* tree, int root) {

	if (root != -1) {
		postorder(tree, tree[root].left);
		postorder(tree, tree[root].right);
		printf(" %d", root);
	}
}

int main() {

	int n; cin >> n;

	Node* tree = new Node[n];

	int root = -1;
	for (int i = 0; i < n; i++) {
		int id, left, right; 
		scanf("%d%d%d", &id, &left, &right);
		tree[id].left = left;
		tree[id].right = right;
		tree[left].parent = id;
		tree[right].parent = id;
	}
	for (int i = 0; i < n; i++) {
		if (tree[i].parent == -1) {
			root = i;
			break;
		}
	}

	printf("Preorder\n");
	preorder(tree, root);
	printf("\nInorder\n");
	inorder(tree, root);
	printf("\nPostorder\n");
	postorder(tree, root);
	printf("\n");

	
	return 0;
}



Measured memory_bytes: 3200
import math


class Triangle:
    def __init__(self, x1, y1, x2, y2, x3, y3):
        self.x1 = x1
        self.x2 = x2
        self.x3 = x3
        self.y1 = y1
        self.y2 = y2
        self.y3 = y3
        self.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2)
        self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2)
        self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2)

    def get_acos_a(self):
        val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c)
        return math.acos(val)


while(1):

    try:
        x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
        t1 = Triangle(x1, y1, x2, y2, xp, yp)
        t2 = Triangle(x2, y2, x3, y3, xp, yp)
        t3 = Triangle(x3, y3, x1, y1, xp, yp)

        if 6.28318530 <= t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a() <= 6.28318531:
            print("YES")
        else:
            print("NO")

    except:
        break

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

// a > b
int gcd(int a, int b)
{
        int r;
        while(1){
                r = a%b;
                if( !r ){ return b; }
                else{ a = b; b = r; }
        } 
}


int main()
{
        int a, b;
        cin >> a >> b;
        cout << gcd(a, b) << endl;
        return 0;
}

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


int main(void)
{
	long int i, j;
	long int n, q;
	long int max;
	long int count;
	long int work;
	long int v[50];
	double sum;
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &v[i]);
	}
	
	for(i = 0; i < n - 1; i++) { 
		for(j = 0; j < n - 1 - i; j++) {
			if(v[j] > v[j + 1]) {
				work = v[j];
				v[j] = v[j + 1];
				v[j + 1] = work;
			}
		}
	}
	sum = (double)v[0];
	for(i = 1; i < n; i++) {
		sum = (sum + v[i]) / 2;
	}
	
	printf("%lf\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.regex.Pattern;

public class Main {
	 
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		String str=cin.nextLine();
		List<Character> res=new ArrayList<>();
		Pattern B=Pattern.compile("^[A-Z]+$");
		Pattern S=Pattern.compile("^[a-z]+$");
		
		for(int i=0;i<str.length();i++) {
			char c=str.charAt(i);
			if(c>=65 && c<=90) {
				res.add((char)(c+32));
			}
			else if(c>=97 && c<=122) {
				res.add((char)(c-32));
			}
			else res.add(c);
		}
		
		for(int i=0;i<res.size();i++)System.out.print(res.get(i));
		System.out.println();
	}
	
}


Measured memory_bytes: 27012
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 1e5 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}
vector < int > v[100];

ll dd(int i,int j)
{
    ll ret = 0;
    for(int x = 0; x < v[i].size(); x++){
        ret += (v[i][x] - v[j][x]) * (v[i][x] - v[j][x]);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;
    cin >> n;
    vector < ll > ans(n+1), dam(n+1);
    ll tot = 0;
    for(int i = 1; i <= n; i++){
        cin >> dam[i] ;
        tot += dam[i] ;
    }
    tot /= 2;
    ans[n] = tot;
    for(int i = 1; i < n; i+= 2){
        ans[n] -= dam[i] ;
    }

    for(int i = n - 1; i >= 1; i--){
        ans[i] = dam[i] - ans[i+1];
    }
    for(int i = 1; i <= n; i++)
        cout << ans[i] * 2 << ' ';
    cout << endl;
    return 0;

}

Measured memory_bytes: 2944
r, c = map(int,input().split())

# 入力する全体
ans = []

# 最後の列
last_raw = []

tmpmax = 0
# 横のやつ appendする
sum = 0
for i in range(r):
    ans.append(list(map(int,input().split())))

# 横
for i in range(r):
    sum = 0
    for j in range(c):
        sum += ans[i][j]
    ans[i].append(sum)
    tmpmax+=sum

lastsum=0
for j in range(c):
    lastsum=0
    for i in range(r):
        lastsum+=ans[i][j]
    last_raw.append(lastsum)
    tmpmax+=lastsum 

last_raw.append(int(tmpmax/2))
# 表示
for i in range(r):
    print(' '.join(map(str,ans[i])))
print(' '.join(map(str,last_raw)))


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  string s;
  string t;
  cin>>s;
  cin>>t;
  int n=s.size();
  vector<int> image(26,-1);
  vector<int> domain(26,-1);
  int temps,tempt;
  bool flag = true;
  REP(i,n){
    temps = s[i]-'a';
    tempt = t[i]-'a';
    if(image[temps]==-1 && domain[tempt]==-1){
      image[temps]=tempt;
      domain[tempt]=temps;
    }else if(image[temps]==tempt && domain[tempt]==temps){
      continue;
    }else{
      flag = false;
    }
  }
  
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 776
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

fn dfs(a: &mut Vec<usize>, i: usize, k: &mut usize, is_zero: bool) {
    if i == a.len() {
        if *k == 1 {
            let mut tmp = 0u64;
            for j in 0..a.len() {
                tmp *= 10;
                tmp += a[j] as u64;
            }
            println!("{}", tmp);
        }
        if *k != 0 {
            *k -= 1;
        }
    } else {
        if is_zero {
            for j in 0..=9 {
                a[i] = j;
                dfs(a, i + 1, k, j == 0);
            }
        } else {
            if a[i - 1] != 0 {
                a[i] = a[i - 1] - 1;
                dfs(a, i + 1, k, false);
            }
            a[i] = a[i - 1];
            dfs(a, i + 1, k, false);
            if a[i - 1] != 9 {
                a[i] = a[i - 1] + 1;
                dfs(a, i + 1, k, false);
            }
        }
    }
}

//#[proconio::fastout]
fn main() {
    input! {
        mut k: usize,
    }

    let mut a = vec![0; 11];
    k += 1;
    dfs(&mut a, 1, &mut k, true);
}


Measured memory_bytes: 2136
#include<cstdio>
#include<cstring>

int n,t[10],a[500001],po,la,x,ans;
char s[1000001];

int main()
{	
	scanf("%s",s); n=strlen(s);
	a[n-1]=n-1; s[n]='9'+1; ans=0; a[n]=n;
	for (int i=n-2; i>=0; i--)
		if (s[i]==s[i+1]) a[i]=a[i+1]; else a[i]=i;
	for (int i=0; i<n; i++)
	{
		po=a[i]; la=i; ans++;
		while (po<n&&s[po+1]>s[po]) la=po+1,po=a[po+1];
		if (po==n) {printf("%d\n",ans); return 0;}
		x=n-1;
		while (s[x]=='9') x--;
		if (x==po) {printf("%d\n",ans); return 0;}
		i=la; s[x]++; 
		for (int j=x+1; j<n; j++) s[j]='0',a[j]=n-1;
		a[x]=x; po=x;
		while (po>=1&&a[po-1]==x) a[po-1]--,po--;
		po=x;
		while (po>=1&&s[po-1]==s[x]) a[po-1]=x,po--;
	}
	return 0;
}

Measured memory_bytes: 2560