akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
/* #define debug */
int main(int argv, char *argc[]){
    long n, m, l;
    long i, j, k, row, line;
    unsigned long A[100][100]={0}, B[100][100]={0}, C[100][100]={0};
    
    scanf("%ld %ld %ld\n", &n, &m, &l);
    #ifdef debug
        printf("debug-inputcheck:n=%ld m=%ld l=%ld\n", n, m ,l);
    #endif
    
    for(row=0; n>row; row++){
        for(line=0; m>line; line++){
            scanf("%lu", &A[row][line]);
        }
    }
    #ifdef debug
        printf("debug-Acheck:##########\n");
        for(row=0; n>row; row++){
            for(line=0; m>line; line++){
                printf("%lu ", A[row][line]);
            }
            printf("\n");
        }
        printf("debug-AcheckEnd:###########\n");
    #endif
    
    for(row=0; m>row; row++){
        for(line=0; l>line; line++){
            scanf("%lu", &B[row][line]);
        }
    }
    #ifdef debug
        printf("debug-Bcheck:##########\n");
        for(row=0; m>row; row++){
            for(line=0; l>line; line++){
                printf("%lu ", B[row][line]);
            }
            printf("\n");
        }
        printf("debug-BcheckEnd:###########\n");
    #endif
    
    
    /* 計算パート */
    for(i=0; n>i; i++){
        for(j=0; l>j; j++){
            for(k=0; m>k; k++){
                C[i][j] += A[i][k]*B[k][j];
            }
        }
    }
    
    /* 表示パート */
    for(i=0; n>i; i++){
        for(j=0; l>j; j++){
            printf("%lu", C[i][j]);
            if(l-1 == j) {printf("\n");}
            else printf(" ");
        }
    }
    return 0;
}

Measured memory_bytes: 856
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        long N = sc.nextLong();
        long M = sc.nextLong();

        long ans1 = Math.min(N, M / 2);

        long ans2 = 0;
        if (M - 2 * ans1 > 0) {
            ans2 = (M - 2 * ans1) / 4;
        }

        _out.println(ans1 + ans2);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21460
import heapq
N, M = map(int, input().split())
arubaito = [list(map(int, input().split())) for _ in range(N)]
arubaito.sort()
arubaito2 = [[] for _ in range(M+1)]
for i in range(N):
    if arubaito[i][0] <= M:
        arubaito2[arubaito[i][0]].append(arubaito[i][1])
for i in range(M):
    arubaito2[i].sort(reverse=True)
target = []
ans = 0
heapq.heapify(target)
for i in range(1,M+1):
    for k in arubaito2[i]:
        heapq.heappush(target,k*(-1))
    if len(target) > 0:
        ans += heapq.heappop(target)*(-1)
print(ans)

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

using namespace std;
using ll = long long;
constexpr int INF = 1 << 29;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int pattern = 0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                int sum = 500 * i + 100 * j + 50 * k;
                if (sum == x) {
                    pattern++;
                }
            }
        }
    }
    cout << pattern << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
      printf("%d\n",a+b);
    }
    else if(op=='-'){
      printf("%d\n",a-b);
    }
    else if(op=='*'){
      printf("%d\n",a*b);
    }
    else if(op=='/'){
      printf("%d\n",a/b);
    }
    else if(op=='?') return(0);
  }
    return(0);
}

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

void check(int a, int b, int c, bool flag) {
    if (a < b && b < c) {
        flag = true;
    }
}

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    bool flag = false;
    int A, B, C;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k - i; ++j) {
            A = i;
            B = j;
            C = k - i - j;
            if (a * pow(2, A) < b * pow(2, B) && b * pow(2, B) < c * pow(2, C)) {
                flag = true;
            }
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;

int main() {
	lli n=0, m, p;
	

	cin >> n;
	vector<pair<lli, lli>> vec(n);
	rep0(i, n) {
		cin >> vec[i].first;
		vec[i].second = i;
	}

	sort(rall(vec), cmpf);
	m = vec[0].first;
	p = vec[1].first;
	sort(all(vec), cmps);

	rep0(i, n) {
		if (vec[i].first == m) {
			cout << p << '\n';
		}
		else {
			cout << m << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int max=0,i,n,x[100],y[100];
    double d;
    cin >> n;
    for(i=0;i<n;i++) cin >> x[i];
    for(i=0;i<n;i++) cin >> y[i];
    d=0;
    for(i=0;i<n;i++) d+=abs(x[i]-y[i]);
    cout << fixed << setprecision(6) << d <<endl;
    d=0;
    for(i=0;i<n;i++) d+=pow(x[i]-y[i],2);
    cout << fixed << setprecision(6) << sqrt(d) <<endl;
    d=0;
    for(i=0;i<n;i++) d+=pow(abs(x[i]-y[i]),3);
    cout << fixed << setprecision(6) << pow(d,1.0/3.0) <<endl;
    for(i=0;i<n;i++) if(max<(abs(x[i]-y[i]))) max=abs(x[i]-y[i]);
    cout << fixed << setprecision(6) << double(max)<<endl;
}



Measured memory_bytes: 3468
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

res = B.reduce(:+)

(N-1).times do |i|
  if A[i+1] == A[i]+1

    res += C[A[i]-1]
  end
end
puts res

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main(){
    int n, m, value;
    cin >> n >> m;

    ll total_votes = 0;
    vector<int> myvs;
    for(int i = 0; i < n; i++) {
        cin >> value;
        myvs.push_back(value);
        total_votes += value;
    }
    ll ans = 0;
    for(int i = 0; i < len(myvs); i++) {
        if(4 * m * myvs[i] >= total_votes) ans++;
    }
    if(ans >= m) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    
    return 0;
}

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

int main () {
    int N, Y;
    cin >> N >> Y;
    int a1 = -1, a2 = -1, a3 = -1;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b + a <= N; b++) {
            int c = N - a - b;
            int total = 10000 * a + 5000 * b + 1000 * c;
            if (total == Y) {
                a1 = a;
                a2 = b;
                a3 = c;
            }
        }
    }
    cout << a1 << " " << a2 << " " << a3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }

    cout << "]" << endl;
    
}

void rec(int u, int p) {

    D[u] = p;
    if (T[u].r != NIL)
        rec(T[u].r, p);
    
    if (T[u].l != NIL)
        rec(T[u].l, p+1);
}

int main() {

    int d, v, c, l, r;

    cin >> n;

    for (int i = 0; i < n; i++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for (int i = 0; i < n; i++) {
        cin >> v >> d;
        for (int j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) {
                T[v].l = c;
            } else {
                T[l].r = c;
            }
            l = c;
            T[c].p = v;
        }
    }

    for (int i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

    for (int i = 0; i < n; i++) {
        print(i);
    }
    
    return 0;    
    
}


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

using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  ll win = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'o')
      win++;
  }
  if (15 - S.size() + win >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	if (S.at(K - 1) == 'A') {
		S.at(K - 1) = 'a';
	}

	else if (S.at(K - 1) == 'B') {
		S.at(K - 1) = 'b';
	}
	
	else{
		S.at(K - 1) = 'c';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}



Measured memory_bytes: 1112
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int A = scanner.nextInt();
    int B = scanner.nextInt();

    int T = scanner.nextInt();

    System.out.println((T / A) *  B);

  }
}


Measured memory_bytes: 21972
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in(), q = in();
	queue <pair<string, ll>>que;
	REP(i, n) {
		string name = in<string>();
		ll time = in();
		que.push(make_pair(name, time));
	}
	for (ll time = 0; !que.empty();) {
		auto f = que.front(); que.pop();
		time += min(q, f.second);
		if (f.second > q) {
			f.second -= q;
			que.push(f);
		} else {
			cout << f.first << ' ' << time << endl;
		}
	}
}


Measured memory_bytes: 6248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;
ll mod = 1e9 + 7;

int n, k;
ll h[100100];
ll dp[100100];

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

int main()
{
    cin >> n >> k;
    rep(i, n) cin >> h[i];
    rep(i, 100100) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            if (j <= i)
            {
                chamin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
            }
        }
    }
    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N, M; cin >> N >> M;
  ll L; cin >> L;

  ll graph[N][N], dist[N][N];

  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (i == j){
        dist[i][j] = 0; graph[i][j] = 0;
      }else{
        dist[i][j] = nmax; graph[i][j] = nmax;
      }
    }
  }
  
  for (int i = 0; i < M; i++){
    int A, B, C; cin >> A >> B >> C;
    A--; B--;
    if (C <= L){
      dist[A][B] = C; dist[B][A] = C;
    }
  }
  
  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (dist[i][j] <= L){
        graph[i][j] = 1;
      }
    }
  }

  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
  
  int Q; cin >> Q;
  int ans[Q];
  for (int i = 0; i < Q; i++){
    int s, t; cin >> s >> t; s--; t--;
    if (graph[s][t] == nmax){
      ans[i] = -1;
    }else{
      ans[i] = graph[s][t] - 1;
    }
  }
  
  for (int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
  





  




  return 0;
}


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
S = list(input().strip())
T = input().strip()
flag = False
for _ in range(len(S)):
    tmp = "" + S[-1]
    for i in range(len(S)-1):
        tmp += S[i]
    if tmp == T:
        flag = True
        break
    S = list(tmp)
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define fi first
#define se second
#define em emplace_back
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
typedef long long ll;
using pii = pair<int,int>;

template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
/*----------------------------------------------------------------------------------*/
int  mod = 1e9 + 7;
int const N = 200100;
typedef long long i64;
i64 INF = 1e18, NIN = -1 * INF;

/******************************/

int add(int a, int b){
  if(a + b >= mod)return a+ b - mod;
  return a + b;
}
int mul(int a, int b){
  return 1LL * a * b  % mod;
}
int power(int a, int b){
  int re = 1;
  while(b){
    if(b&1)re= mul(re, a);
    a = mul(a, a);
    b>>=1;
  }
  return re;
}

int fact[N], inv[N];

int ncr(int a, int b){
  if(a < 0 || b < 0 || a < b)return 0;
  return mul(fact[a], mul(inv[a-b], inv[b]));
}
int ncr(pii a){
  return ncr(a.fi, a.se);
}
void fac(){
  fact[1] = fact[0] = 1;
  for(int x =2; x<N; x++){
    fact[x] = mul(x, fact[x-1]);
  }
  inv[N-1] = power(fact[N-1], mod - 2);
  for(int x = N-2; x>= 0; x--){
    inv[x] = mul(x+1, inv[x+1]);
  }
}

void solve(){
  string s;cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes";
  }
  else cout << "No";
}

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);  int test = 1;
  // cin >> test;
  while(test--)solve();
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
inner = 0
for i in 1.upto(n - 1)
    for j in 0.upto(i - 1)
        if a[j] > a[i] then
            inner += 1
        end
    end
end
a1 = a.sort
lesscount = 0
outer = 0
for i in 1.upto(n - 1)
    if a1[i - 1] < a1[i] then
        lesscount = i
    end
    outer += lesscount
end
puts (k * inner + (k * (k - 1) / 2) * outer) % (1_000_000_000 + 7)


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n;
	cin>>n;
	if(n==0) cout<<2<<"\n";
	else if(n==1) cout<<1<<"\n";
	else{
		ll dp[n+1];
		for(int i=0;i<=n;i++)
			if(i<2)
				dp[i]=2-i;
			else 
				dp[i]=dp[i-1]+dp[i-2];
		cout<<dp[n]<<"\n";
	}




}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
N,K =gets.split.map(&:to_i)
array =[]
N.times do
  array << gets.to_i
end
array.sort!
min = -array[0] + array[-1]
(N+1-K).times do |i|
  d = -array[i]+array[i+K-1]
  min = d if min > d
end
puts min


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

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

    std::vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        std::cin >> p[i];
    }

    int cnt = 0;
    for(int i = 1; i < n - 1; i++)
    {
        cnt += ((p[i] > p[i - 1] && p[i + 1] > p[i]) || (p[i] > p[i + 1] && p[i - 1] > p[i]));
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
integer N,M,A,B
integer,allocatable,dimension(:)::ISLAND
read*,N,M
allocate(ISLAND(N))
ISLAND=0
do i=1,M
  read*,A,B
  if(B==1.or.B==N)then
    A=xor(A,B)
    B=xor(A,B)
    A=xor(A,B)
  endif
  if(A==1.or.A==N)then
    ISLAND(B)=ISLAND(B)+1
    if(ISLAND(B)==2)then
      print"(A)","POSSIBLE"
      STOP
    endif
  endif
end do
print"(A)","IMPOSSIBLE"
end

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

int main(void) {
    int p, q, r;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> p >> q >> r;
    cout << p + q + r - max(p, max(q, r)) << "\n";
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	v = readline() |> split |> parseMap |> sort
	k = v[1]
	for i in 2:n
		k = (k+v[i])/2
	end
	println(k)
end

main()

Measured memory_bytes: 167468
s = input().split()
n = int(s[0])
m = int(s[1])
l = int(s[2])

A=[]
for i in range(n):
    row = list(map(int,input().split()))
    A.append(row)

B=[]
for i in range(m):
    row = list(map(int,input().split()))
    B.append(row)

#print(A)
#print(B)

result=[[0 for i in range(l)] for j in range(n)] #row:n,column:l
#print(result)

for i in range(n):
    for j in range(l):
        sum=0
        for k in range(m):
            sum+=A[i][k]*B[k][j]
        #print("i:",i,"j",j)
        result[i][j]=sum

#print(result)

for i in range(n):
    for j in range(l-1):
        print(result[i][j]," ",end="",sep="")
    print(result[i][l-1])


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int x,n;
    cin >> x >> n;
    vector<int> p;
    int t;
    REP(i,n){
        cin >> t;
        p.push_back(t);
    }
    int min1 = INF;
    int num = x;
    for(int i=-300;i<=300;i++){
        bool flag = 1;
        for(int x:p){
            if(i==x)flag = 0;
        }
        if(flag){//存在していない
            if(min1>abs(x-i)){
                min1 = abs(x-i);
                num = i;
            }
        }
    }
    COUT(num);
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    vint a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    cout << -a[0]+a[2] << endl;
    return 0;
}


Measured memory_bytes: 256
v, e, r = map(int, input().split())
graph = [[] for _ in range(e)]
std = [list(map(int, input().split())) for _ in range(e)]

def bellman_ford(s):
  dist = [float('inf')]*v 
  dist[s] = 0 
  
  for u in range(v):
    for s, t, d in std:
      if dist[t] > dist[s] + d:
        dist[t] = dist[s] + d 
        if u == v-1:
          return -1
    
  return dist 

dist = bellman_ford(r)
if dist == -1:
  print('NEGATIVE CYCLE')
else:
  for i in range(v):
    if dist[i] == float('inf'):
      print('INF')
      continue 
    print(dist[i])


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

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    int max_n, min_n;
    if (A < B) {
        max_n = A;
    }
    else {
        max_n = B;
    }

    min_n = A + B - N;
    if (min_n < 0) {
        min_n = 0;
    }

    cout << max_n << " " << min_n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();


  int n,k;
  cin>>n>>k;
  cout<<n-k+1;

  return 0;
}

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

using namespace std;

//int min = numeric_limits<int>::max();

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

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

    vector<int> b(N, K - Q);
    for (auto x : a) {
        b[x-1]++;
    }

    for (auto x : b) {
        if (x > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
N, Y = map(int, input().split())

cnt_10000 = 0
cnt_5000 = 0
cnt_1000 = 0

for i in range(0, N + 1):
  for j in range(0, N - i + 1):
    if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
      cnt_10000 = i
      cnt_5000 = j
      cnt_1000 = N - i - j
      
    if 10000 * i + 5000 * j + 1000 * (N - i - j) > Y:
      break

if cnt_10000 == 0 and cnt_5000 == 0 and cnt_1000 == 0:
  print('-1 -1 -1')
else:
  print(str(cnt_10000) + ' ' + str(cnt_5000) + ' ' + str(cnt_1000))

Measured memory_bytes: 40976
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;

int main() {
	string s;
	cin >> s;
	int K;
	cin >> K;
	vector<string> v;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= K; j++) {
			if (i + j > s.size()) break;
			v.push_back(s.substr(i, j));
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	cout << v[K - 1] << endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,c=0,n;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i=i+2)
    {
        if(a[i]%2!=0)
            c++;
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define INF 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
        ll n,m,x,ans=1e18;
        cin>>n>>m>>x;
        int c[n],a[n][m];
        for(int i=0;i<n;i++){
        	cin>>c[i];
        	for(int j=0;j<m;j++)cin>>a[i][j];
		}
		for(int i=0;i<(1<<n);i++){
			ll cost=0,skill[m]={0};
			for(int j=0;j<n;j++){
				if(i>>j & 1){
					cost+=c[j];
					for(int k=0;k<m;k++)
						skill[k]+=a[j][k];
				}
			}
			int count=0;
			for(int j=0;j<m;j++)if(skill[j]>=x)count++;
			if(count==m)ans=min(ans,cost);
		}
		if(ans>1e10)ans=-1;
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"fmt"
	"math"
)

func main() {


	var X float64

	fmt.Scan(&X)

	for i:=-1000;i<=1000;i++{

		for j:=-1000;j<=1000;j++{

			if math.Pow(float64(i),5) - math.Pow(float64(j),5)== X{

				fmt.Println(i,j)

				return
			}
		}
	}
}

Measured memory_bytes: 1852
#include<iostream>
using namespace std;
bool T[100000];

int main(void){
int N;
cin >> N ;
int cnt=0;
int k=0;
for (int i=0; i<N; i++){
int j;
cin >>j; 
if (T[j]) k++;
else{T[j]=true; cnt++;}
}
cout << (k%2 == 0 ? cnt : cnt-1) << endl;
return 0 ;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////



int main(){
    double n;
    cin>>n;
    double x = n/3.0;

    double res = x  * x * x;

 PC("%.10lf", res);
 NL;
    return 0;
}

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


int main(){
    int n,m,counter=0;
    scanf("%d %d",&n,&m);
    int A[m+1];
    for(int l=0;l<=m;l++){A[l]=0;}
    vector < vector<int> > input(n,vector<int>(m));
    for(int i=0;i<n;i++){
        int k;
        scanf("%d",&k);
        for(int j=0;j<k;j++){
            scanf(" %d",&input[i][j]);
            A[input[i][j]]++;
        }
    }
    for(int p=0;p<=m;p++){
        if(A[p]==n){counter++;}
    }
    printf("%d\n",counter);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a[200000],b,c;
    long long d=0,e=0;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i;
    }
    
    sort(a,a+n);
    b=a[(n-1)/2];
    c=a[n/2];
    
    for(int i=0;i<n;i++){
        d+=abs(a[i]-b);
        e+=abs(a[i]-c);
    }
    
    cout<<min(d,e)<<endl;
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 10005;

int n, a[N], b[N];
LL sum_a, sum_b;

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(a[i]), sum_a += a[i];
  }
  for (int i = 1; i <= n; ++i) {
    Read(b[i]), sum_b += b[i];
  }
  if (sum_a > sum_b) {
    puts("No");
  } else {
    LL t = sum_b - sum_a, x = 0, y = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] >= b[i]) {
        y += a[i] - b[i];
      } else {
        x += b[i] - a[i] + 1 >> 1;
        y += b[i] - a[i] & 1;
      }
    }
    puts(x <= t && y <= t ? "Yes" : "No");
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

'''
a + b = x -> b = x - a
2*a + 4*b = y
-> 2*a + 4*(x - a) = y
(4*x - y)/2 = a  これが整数か？
'''

a = (4*x - y)/2
b = x - a
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

if (is_integer_num(a) == True) & (a >= 0) & (b >= 0):
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int64_t H,x,y=0,count=0;
  vector<pair<int,int64_t>> A(41);
  for(int i=0;i<41;i++){y+=pow(2,i);A.at(i)=make_pair(i,y);}
  cin>>H;
  x=H;
  while(x>=2){x/=2;count++;}
  cout<<A.at(count).second<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5;
int n,pa[333333],v[333333],w[333333],ans[333333],x,y,cur[333333];
int cv[33],cw[33],cnt,sumv[11111],sumw[11111],fun[333333],q;
bool con[333333];
vector<pair<int,int> > que[333333];
void proq(int x)
{
	int xx=x;
	if (que[x].empty()) return;
	cnt=0;bool flg=0;
	while(x)
	{
		if (con[x]) 
		{
			flg=1;
			break;
		}
		cv[cnt]=v[x];cw[cnt]=w[x];
		cnt++;
		x=pa[x];
	}
	x=xx;
	int id,ww,mx;
	for (int i=1;i<(1<<cnt);i++)
	{
		int cp=fun[i&(-i)],msk=i^(i&(-i));
		sumv[i]=sumv[msk]+cv[cp];
		sumw[i]=sumw[msk]+cw[cp];
	}
	if (!flg)
	{
		for (int i=0;i<que[x].size();i++)
		{
			ww=que[x][i].first;id=que[x][i].second;mx=0;
			for (int j=0;j<(1<<cnt);j++)
			{
				if (sumw[j]<=ww) mx=max(mx,sumv[j]);
			}
			ans[id]=mx;
		}
	}
	else
	{
		for (int i=0;i<que[x].size();i++)
		{
			ww=que[x][i].first;id=que[x][i].second;mx=0;
			for (int j=0;j<(1<<cnt);j++)
			{
				if (sumw[j]<=ww) mx=max(mx,sumv[j]+cur[ww-sumw[j]]);
			}
			ans[id]=mx;
		}
	}
}
void upd(int x)
{
	con[x]=1;
	cnt=0;
	while(x)
	{
		cv[cnt]=v[x];cw[cnt]=w[x];
		cnt++;
		x=pa[x];
	}
	memset(cur,0,sizeof(cur));
	for (int i=1;i<(1<<cnt);i++)
	{
		int cp=fun[i&(-i)],msk=i^(i&(-i));
		sumv[i]=sumv[msk]+cv[cp];
		sumw[i]=sumw[msk]+cw[cp];
	}
	for (int i=0;i<(1<<cnt);i++) 
	{
		if (sumw[i]<=maxn) cur[sumw[i]]=max(cur[sumw[i]],sumv[i]);	
	}
	for (int i=1;i<=maxn;i++) cur[i]=max(cur[i],cur[i-1]);
}
void dfs(int i,int dep)
{
	proq(i);
	if (dep==10) upd(i);
	if (i*2<=n) dfs(i*2,dep+1);
	if (i*2+1<=n) dfs(i*2+1,dep+1);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) pa[i]=i>>1;
	for (int i=0;i<=18;i++) fun[1<<i]=i;
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&v[i],&w[i]);
	}
	scanf("%d",&q);
	for (int i=1;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		que[x].push_back(make_pair(y,i));
	}
	dfs(1,1);
	for (int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 19544
X, N = map(int, input().split())
P = list(map(int, input().split()))

d = 10**10
v = 10**10
for i in range(0, 102):
    if i in P:
        continue
    _d = abs(X - i)
    # print('d, _d', d, _d)
    if _d < d:
        d = _d
        v = i
    if _d == d:
        v = min(i, v)
print(v)


Measured memory_bytes: 9184
from math import sqrt,cos,atan2

class Ufo:
	def __init__(self,px,py,d,vd,ui):
		self.pd=sqrt(px**2+py**2)
		self.px=float(px)
		self.py=float(py)
		self.fpd=self.pd
		self.fpx=self.px
		self.fpy=self.py
		self.ex=self.fpx/self.fpd
		self.ey=self.fpy/self.fpd
		self.d=float(d)
		self.vd=float(vd)
		self.vx=-self.vd*self.ex
		self.vy=-self.vd*self.ey
		self.i=ui
	def move(self):
		self.pd -= self.vd
		self.px += self.vx
		self.py += self.vy



while True:
	R,ul=tuple(map(int,raw_input().split()))
	if(R==0 and ul==0): break
	us=[]
	for ui in xrange(ul):
		px,py,d,vd = tuple(map(int,raw_input().split()))
		u = Ufo(px,py,d,vd,ui)
		us.append(u)

	re=0
	while True:
		for u in us: u.move()
		us.sort(key=lambda u: u.pd)

		for u in us[:]:
			if u.pd<=R:
				re+=1
				us.remove(u)
				#print u.i, "due to invade"
				continue
			else:
				break
		if len(us)==0: break

		neu=us.pop(0)
		#print "focus",neu.i
		#print neu.i,"due to hit"

		for u in us[:]:
			d = u.pd*abs(neu.ex*u.ey-neu.ey*u.ex)	#u kara laser ni orosita suisen no nagasa
			if d<u.d:
				if u.pd*cos(atan2(u.fpy,u.fpx)-atan2(neu.fpy,neu.fpx)) + sqrt(u.d**2-d**2) > R:
					us.remove(u)
					#print u.i, "due to hit"
		if len(us)==0: break

	print re

Measured memory_bytes: 4688
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  
  cin >>  k;
  string s;cin>>s;
  string ans;
  if (k<s.length()){
    for(ll i=0;i<k;i++){
      ans+=s[i];
    }
    ans+="...";

    cout<<ans<<endl;
    return 0;
  }else{
    cout<<s<<endl;
    return 0;
  }

}

Measured memory_bytes: 3628
n=int(input())
a=[int(i) for i in input().split()]
ans=[]
for i in range(0,n,2):
	ans.append(a[i])
ans.reverse()
for i in range(1,n,2):
	ans.append(a[i])
#print(ans)
if(n%2==0):
	for i in range(n):
		print(ans[n-i-1],end="")
		if(not i==n-1):
			print(" ",end="")
else:
	for i in range(n):
		print(ans[i],end="")
		if(not i==n-1):
			print(" ",end="")

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

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

    vector<int> a(n);
    rep(i, n)
        cin >> a.at(i);

    int m = 0;
    rep(i, n) {
        if (i != n - 1)
            m = max(m, a.at(i + 1) - a.at(i));
        else
            m = max(m, (k - a.at(i)) + a.at(0));
    }

    cout << (k - m) << endl;
}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 200100;

int n;
ll a[N],cum[N],mod=1e9+7,ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    cum[n] = a[n];
    for(int i=n-1;i>=1;i--)
        cum[i] = ( cum[i+1] + a[i] ) %mod;

    for(int i=1;i<=n;i++)
        ans = ( ans + cum[i+1]*a[i]%mod )%mod;

    printf("%lld\n",ans);
}


Measured memory_bytes: 6892
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int a, b;
    cin >> a >> b;
    int cnt = 0;

    cnt = (b - 1 + a - 2) / (a - 1);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# A × B を求めてください。

# 制約
# 1 ≤ A ≤ 100
# 1 ≤ B ≤ 100
# 入力は全て整数である。

# 標準入力からA、Bを取得する
a, b = map(int, input().split())

# A x B を計算し、出力する
result = a * b

print(result)


Measured memory_bytes: 8992
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	vi h(n); rep(i, n) cin >> h[i];
	int dp0 = 0, dp1 = abs(h[0] - h[1]);
	function<int(int)> solve = [&](int n) {
		repF(i, 2, n - 1) {
			int dpt = min(dp1 + abs(h[i - 1] - h[i]), dp0 + abs(h[i - 2] - h[i]));
			dp0 = dp1;
			dp1 = dpt;
		}
		return dp1;
	};
	cout << solve(n) << endl;
	return 0;
}

Measured memory_bytes: 3732
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int main()
{
	string s, t;
	cin >> s >> t;
	int n, m;
	n = s.size();
	m = t.size();
	int best = 1e9;
	for(int i = 0; i+m-1< n; i++)
	{
		int nab = 0;
		for(int j = 0; j< m; j++)
		{
			if(t[j] != s[i+j]) nab++;
		}
		best = min(best, nab);
	}
	printf("%d\n", best);
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
string s,t;
int sal[26];
int tal[26];
int snums[200005];
int tnums[200005];
int schain[200005];
int tchain[200005];
int cnt=0;
int main(int argc,char const* argv[])
{
  cin >> s >> t;
  memset(sal,0,sizeof(sal));
  memset(tal,0,sizeof(tal));
  memset(snums,0,sizeof(snums));
  memset(tnums,0,sizeof(tnums));
  memset(schain,0,sizeof(schain));
  memset(tchain,0,sizeof(tchain));

  for(int j=0;j<26;j++)
    {
      int nowschain=1;
      int nowtchain=1;
      for(int i=0;i<s.size();i++)
	{
	  char prechars;
	  char prechart;
	  if(j==0)
	    {
	      if(i==0)
		{
		  prechars=s[i];
		  prechart=t[i];
		}
	      else if(i>=1)
		{
		  if(s[i]==prechars)
		    {
		      nowschain++;
		    }
		  if(t[i]==prechart)
		    {
		      nowtchain++;
		    }
		  if(s[i]!=prechars || t[i]!=prechart)
		    {
		      if(nowschain!=nowtchain)
			{
			  cout << "No" << endl;
			  return 0;
			}
		      nowschain=1;
		      nowtchain=1;
		      prechars=s[i];
		      prechart=t[i];
		    }
		}
	    }
	  char check='a'+j;
	  if(s[i]!=t[i])
	    {
	      if(s[i]==check) sal[j]++;
	      if(t[i]==check) tal[j]++;
	    }
	}
    }
  for(int i=0;i<26;i++)
    {
      snums[sal[i]]++;
      tnums[tal[i]]++;
      if(sal[i]!=0) cnt++;
    }
  for(int i=1;i<=200000;i++)
    {
      if(snums[i]!=tnums[i])
	{
	  cout << "No" << endl;
	  return 0;
	}
    }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3848
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    int n=read(), k=read();
    ll ans=0, mi=0, mx=0;
    for(int i=0; i<=n; ++i) {
        mi+=i, mx+=n-i;
        if(i>=k-1) ans+=mx-mi+1;
    }
    cout<<ans%mod<<endl;
}

Measured memory_bytes: 3636
N, T = (int(i) for i in input().split())
t = [int(i) for i in input().split()]

tt = [0 for i in range(len(t)-1)]
for i in range(len(tt)):
    tt[i] = t[i+1] - t[i]

time = T
for i in tt:
    if i < T:
        time += i
    else:
        time += T

print(time)

Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e3+5;
int n;
ll k,a[N],p[N],cnt[N]={0},sum[N][N]={0};
ll dfs(ll i){
    ll u=i,num=1,pos=1;
    while(p[i]!=u){
        num++;
        i=p[i];
        sum[u][pos]=sum[u][pos-1]+a[i];
      pos++;
    }
    sum[u][pos]=sum[u][pos-1]+a[u];
    return num;
}

int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++) cin>>a[i];
    ll ans=-1e18;
    for(int i=1;i<=n;i++){
        cnt[i]=dfs(i);
        ll mx1=-1e18,mx2=-1e18;
        for(int j=1;j<=cnt[i];j++){
            mx1=max(mx1,sum[i][j]);
        }
        for(int j=1;j<=(k%cnt[i]?k%cnt[i]:cnt[i]);j++){
            mx2=max(mx2,sum[i][j]);
        }
        if(k>cnt[i]){
            ll num=(k%cnt[i])?k/cnt[i]:k/cnt[i]-1;
            ans=max(ans,max(mx1,num*sum[i][cnt[i]]+mx2));
        }
        else ans=max(ans,mx2);
    }
    cout<<ans;
}


Measured memory_bytes: 199212
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int N, Q;
  scanf("%d %d", &N, &Q);
  vector<llint> q(Q);
  REP(i, Q) scanf("%lld", &q[i]);
  q.insert(q.begin(), N);
  Q++;

  llint whole = 1;
  map<llint, llint> prefs;
  prefs[0]++;

  for (int i = Q - 1; i > 0; --i) {
    prefs[q[i]] += whole;

    whole = 0;
    auto it = prefs.end();
    --it;
    vector<pair<llint, llint>> v;
    while (it->first >= q[i - 1] && it->first > 0) {
      v.push_back(*it);
      it--;
    }

    for (auto p : v) {
      whole += (p.first / q[i - 1]) * p.second;
      prefs[p.first % q[i - 1]] += p.second;
      prefs.erase(p.first);
    }
  }

  vector<llint> f(N + 1);
  f[N] += whole;
  for (auto& it : prefs) {
    f[it.first] += it.second;
  }

  vector<llint> ans(N + 1);
  llint cur = 0;
  for (llint i = N; i > 0; --i) {
    cur += f[i];
    ans[i] = cur;
  }

  FOR(i, 1, N + 1) printf("%lld\n", ans[i]);
  return 0;
}


Measured memory_bytes: 10524
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
    ll n,ans=-1;
    cin >> n;
    for(double i=1.0;i<=50000.0;i++){
        if((int)(i*1.08)==n) ans=i;
    }
    if(ans==-1) cout << ":(\n";
    else Cout(ans);
    return 0;
}


Measured memory_bytes: 256
import Debug.Trace
import Data.Char
import Data.List

wordlist::String->[String]
wordlist "" = []
wordlist sent = [w] ++ (wordlist $ drop (length w) sent)
    where 
        w
            | (take 5 sent)=="apple"  = "peach"
            | (take 5 sent)=="peach"  = "apple"
            | otherwise               = [head sent]

solve::String->String
solve str = concat $ wordlist str

main::IO ()
main = do
    str<-getLine::IO String
    putStrLn $ solve str

Measured memory_bytes: 3760
#include <stdio.h>


int main(void){
	int nyuryoku[100000]={0};
	int n,num,a;
	
	scanf("%d",&n);
	
	for (int i=0;i<n;i++){
		scanf("%d",&nyuryoku[i]);
	} 
	
	for(int i=0;i<n;i++){
		if(nyuryoku[i]%2==1) a++;
	}
	if(a%2==0) printf("YES\n");
	else printf("NO\n"); 
	return 0;
}

Measured memory_bytes: 640