akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N;
    cin >> N;
    string S;
    cin >> S;
    int K;
    cin >> K;
    K--;
    rep(i,N){
        if(S[i] != S[K]) cout << '*';
        else cout << S[K];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    set<int> V;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        V.insert(a);
    }
    if (V.size() == N){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    map<string,int> mp;
    int ans = 0;
    REP(i,N){
        string s; cin >> s;
        mp[s]++;
        if(mp[s] == 1) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 19284
#include<bits/stdc++.h>
using namespace std;
int mat[11][1010];
int n, m, s;
char mm[11][1010];

int isBitSet(int mask, int ind)
{
    mask = mask >> ind;
    return mask & 1;
}

int main()
{
    cin >> n >> m >> s;
    for(int i=0; i<n; i++)
    {
        cin >> mm[i];
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(mm[i-1][j-1] == '1')
            {
                mat[i][j] = 1;
            }
        }
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            mat[i][j] += mat[i][j-1];
        }
    }

    int minDivisons = INT_MAX;
    for(int mask =0; mask < (1<<(n-1)); mask++)
    {
        int curMask = mask | (1<<(n-1));
        int verticalDivisons = __builtin_popcount(curMask) - 1;
        int noOfDivisons = verticalDivisons;
        int prevHorDiv = 0;
        for(int j=0; j<m; j++)
        {
            int curDiv = 0;
            vector<int> divCount(verticalDivisons+1, 0);
            for(int i=0; i<n; i++)
            {
                if(mm[i][j] == '1')
                {
                    divCount[curDiv]++;
                }
                if(isBitSet(curMask, i))
                {
                    curDiv++;
                }
            }

            int flag = 0;
            for(int i=0; i<curDiv; i++)
            {
                if(divCount[i] > s)
                    flag = 1;
            }
            if(flag)
            {
                noOfDivisons = n+ m + 1;
                break;
            }

            // Make Horizontal Divisons
            int sum = 0;
            int flag2 = 0;
            for(int i=0; i<n; i++)
            {
                sum = sum + mat[i+1][j+1] - mat[i+1][prevHorDiv];
                if(sum > s)
                {
                    flag2 = 1;
                }
                if(isBitSet(curMask, i))
                    sum = 0;
            }
            if(flag2)
                prevHorDiv = j, noOfDivisons++;
        }

        minDivisons = min(minDivisons, noOfDivisons);
    }

    cout << minDivisons << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-8;
const int maxn=(int) 2000+20;
const int maxm=(int) 1e6+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

int n,m;
char S[55],T[55];

inline bool check(char *S,char *T)
{
    for(int i=0;T[i];i++) if(S[i]!='?' && S[i]!=T[i]) return 0;
    return 1;
}

void work()
{
    cin >>S >>T;
    n=strlen(S); m=strlen(T);

    for(int i=n-1;~i;i--)
    {
        if(check(S+i,T))
        {
            for(int j=0;T[j];j++) S[i+j]=T[j];
            for(int i=0;S[i];i++) if(S[i]=='?') S[i]='a';
            cout <<S <<endl;
            return ;
        }
    }

    cout <<"UNRESTORABLE" <<endl;
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,q = m()

a = [0 for i in range(n)]

for i in range(q):
	j,k = m()
	a[j-1] += 1
	if k != n:
		a[k] -= 1
co = 0
for i in range(1,n):
	a[i] += a[i-1]
for i in range(n):
	if a[i] == q:
		co += 1

print(co)



Measured memory_bytes: 47788
def f(x):
    if x%4 == 0:
        return x
    if x%4 == 1:
        return 1
    if x%4 == 2:
        return x + 1
    else:
        return 0

A, B = map(int, input().split())

ans = 0
if A == 0:
    ans = f(B)
else:
    ans = f(A - 1) ^ f(B)

print(ans)


Measured memory_bytes: 38256
#include<iostream>
#include<cmath>
using namespace std;

typedef long long ll;
ll N;
ll X;

ll f(ll tmp_X, ll L){
    ll tmp_num = pow(2, L + 1) - 3;
    if(tmp_X == 0) return 0;
    if((L == 0) && (tmp_X > 0)) return 1;
    if(tmp_X <= tmp_num + 1){
        return f(tmp_X - 1, L - 1);
    }else if(tmp_X == tmp_num + 2){
        return pow(2, L);
    }else{
        return pow(2, L) + f(tmp_X - tmp_num - 2, L - 1);
    }
}
int main(){
    cin >> N >> X;
    cout << f(X, N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define pb push_back
#define all(x) (x).begin(),(x).end()

vector<int> child[100010];
int n;

int dfs(int x){
    if(child[x].empty()) return 0;
    vector<int> val;
    val.pb(0);
    for(int y:child[x]) val.pb(dfs(y));
    sort(all(val));
    int s=val.size();
    for(int i=0; i<s; ++i){
        val[i] += min(s-1, s-i);
    }
    return *max_element(all(val));
}

int main()
{
    read(n);
    for(int i=2; i<=n; ++i){
        int x; read(x);
        child[x].pb(i);
    }
    printf("%d\n", dfs(1));
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>

/*
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0584
 * test of c++
 */

class Node {
    private:
        int value;
    public:
        void setValue(int v) {
            value = v;
        }

        int getValue() {
            return value;
        }
};

class Tree {
    private:
        Node root;
        Node left;
        Node right;

    public:
        Tree() {
            // root < left < right
            int inf = 1000010001;
            root.setValue(inf);
            left.setValue(inf);
            right.setValue(inf);
        }

        void push(int value) {
            if (value < root.getValue()) {
                right.setValue(left.getValue());
                left.setValue(root.getValue());
                root.setValue(value);
            } 
            else if (value < left.getValue()) {
                right.setValue(left.getValue());
                left.setValue(value);
            }
            else if (value < right.getValue()) {
                right.setValue(value);
            } 
            // larget than any other data
            else {}
        }

        int get() {
            return right.getValue();
        }

        std::ostream& print(std::ostream& os) {
           return os << root.getValue() << "-" << left.getValue() << "-" << right.getValue() << std::endl;
        }
};


std::ostream& operator<< (std::ostream& os, Tree& obj){
    // Since operator<< is a friend of the Point class, we can access Point's members directly.
    return obj.print(os);
}


int main(int argc, char const *argv[]) {
    std::string input_str;
    std::vector<std::string> input_vec;

    std::getline(std::cin, input_str);
    std::istringstream iss(input_str);
    int arr_size;
    iss >> arr_size;

    for (int i = 0; i < arr_size; i++) {
        std::getline(std::cin, input_str);
        input_vec.push_back(input_str);
    }

    Tree ans;
    for (int i = 0; i < arr_size; i++) {
        for (int j = 0; j < arr_size; j++) {
            if (i == j) {
                continue;
            }
            std::string num_str = input_vec.at(i) + input_vec.at(j);

            // std::stringstream ss(num_str);
            // int num;
            // ss >> num;
            int num = std::atoi(num_str.c_str());
            ans.push(num);
        }
    }
    std::cout << ans.get() << std::endl;

    return 0;
}



Measured memory_bytes: 3572
import java.util.*;
import java.util.Map.*;

class Main{

	static ArrayList<HashMap<Integer,Integer>>g=new ArrayList<>();

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		for(int i=0;i<n;++i)
			g.add(new HashMap<>(1));

		int[]r=new int[n];
		Arrays.fill(r,-1);
		r[0]=0;

		for(int i=0;i<n-1;++i) {
			int a=s.nextInt()-1,b=s.nextInt()-1,w=s.nextInt()%2;
			g.get(a).put(b,w);
			g.get(b).put(a,w);
		}

		f(0,r);
		Arrays.stream(r).forEach(System.out::println);
	}

	private static void f(int i,int[] r){
		for(Entry<Integer,Integer> o:g.get(i).entrySet()) {
			int t=o.getKey();
			if(r[t]<0) {
				r[t]=(r[i]+o.getValue())%2;
				f(t,r);
			}
		}
	}
}

Measured memory_bytes: 123140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI b(n);
    REP(i,n) b[i] = in();
    VI ans(n);
    FORR(x,n,1){
        int c = 0;
        for (int y = 2 * x; y <= n; y += x){
            c ^= ans[y - 1];
        }
        ans[x - 1] = (c ^ b[x - 1]);
    }
    VI v;
    REP(i,n) if (ans[i]) v.push_back(i + 1);
    cout << v.size() << endl;
    for (int x : v) cout << x << " ";
    cout << endl;
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> H(n);
    for (int i = 0; i < n; ++i) {
      cin >> H[i];
    }
    sort(H.begin(), H.end());
    long long ans = 0;
    for (int i = 0; i < n-k; ++i) {
      ans += H[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
import fractions
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,c = MAP()
print(min(a*b,c))

Measured memory_bytes: 65516
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(
                Math.min(a,  b) + " " +
                Math.max(0, a + b - n)
        );
    }
}


Measured memory_bytes: 21460
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

string s, r, c[] = {"maerd", "remaerd", "esare", "resare"};

bool cut(string &s)
{
  bool r = false;
  REP(i, 4)
  {
    if (s.find(c[i]) == 0)
    {
      s = s.substr(c[i].length());
      r = true;
    }
  }
  return r;
}

int main()
{
  cin >> s;
  reverse(ALL(s));

  while (0 < s.length())
  {
    if (!cut(s))
      break;
  }

  r = s.length() == 0 ? "YES" : "NO";

  cout << r << '\n';

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<P> v(n);
    REP(i, n)
    {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    int cnt = 0;
    REP(i, n)
    {
        if (i % 2 != v[i].second % 2)
        {
            cnt++;
        }
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
const int maxn = 101010;
int trie[maxn][2], nd = 1;
void add(char x[]){
    int cur = 0;
    for(int e = 0; x[e]; e++){
        int & v = trie[cur][x[e]-'0'];
        if(v == -1) v = nd++;
        cur = v;
    }
}
long long l;
long long solve(int cur, long long v){
    if(cur == -1){
        if(l >= v) return ((l + 1 - v)&(-(l + 1 - v)));
        return 0;
    }
    return solve(trie[cur][0], v+1)^solve(trie[cur][1], v+1);
}
char d[maxn];
int main(){
    memset(trie, -1, sizeof(trie));
    int n;
    cin >> n >> l;
    for(int e = 0; e < n; e++){
        scanf("%s", d);
        add(d);
    }
    if(solve(0, 0) == 0) cout << "Bob" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
 
using namespace std;
 
int main()
{
    int D, N;
    cin >> D >> N;
 
    int p = 1;
    for (int i = 0; i < D; i++){
        p *= 100;
    }
 
    if (N < 100){
        cout << p * N << endl;
    }else{
        cout << 101 * p<< endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;
typedef long long ll;

void dfs(vi e[], int x, int p[], int h[]) {
    for (int y : e[x]) {
        if (y != p[x]) {
            h[y] = h[x] + 1;
            p[y] = x;
            dfs(e, y, p, h);
        }
    }
}

void dfs2(vi e[], int x, int p, int ps[]) {
    for (int y : e[x]) {
        if (y != p) {
            dfs2(e, y, x, ps);
            ps[x] += ps[y];
        }
    }
}

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

    int n;
    cin >> n;
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    int h[n], p[n];
    h[0] = 0;
    p[0] = -1;
    dfs(e, 0, p, h);

    int lca[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int x = i, y = j;
            if (h[x] < h[y]) {
                swap(x, y);
            }

            while (h[x] > h[y]) {
                x = p[x];
            }

            while (x != y) {
                x = p[x];
                y = p[y];
            }

            lca[i][j] = x;
        }
    }

    int m;
    cin >> m;
    int u[m], v[m];
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i];
        u[i]--, v[i]--;
    }

    ll ans = 0;
    for (int i = 0; i < 1 << m; i++) {
        int ps[n];
        memset(ps, 0, sizeof(ps));

        int bc = 0;
        for (int j = 0; j < m; j++) {
            if (i >> j & 1) {
                ps[u[j]]++;
                ps[v[j]]++;
                ps[lca[u[j]][v[j]]] -= 2;

                bc++;
            }
        }

        dfs2(e, 0, -1, ps);

        ll t = (bc % 2 == 0 ? 1 : -1);
        for (int i = 1; i < n; i++) {
            if (ps[i] == 0) {
                t = t * 2;
            }
        }

        ans += t;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())

IN = list(list(map(int, input().split())) for _ in range(N))
sumw = 0
sumv = 0
for w, v in IN:
    sumw += w
    sumv += v

DP = dict()
DP[sumv] = sumw

def minv(i, v):
    if not DP.get(i):
        DP[i] = v
    else:
        if v < DP[i]:
            DP[i] = v

for w, v in IN:
    DPpre = DP.copy()
    for i in DPpre:
        minv(i-v, DPpre[i]-w)

for v in sorted(DP, reverse=True):
    if DP[v] <= W:
        print(v)
        break


Measured memory_bytes: 98532
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,n;
	cin>>a>>n;;
	if(a+n==15)
	{
		cout<<"+"<<endl;
		return 0;
	}
	if(a*n==15)
	{
		cout<<"*"<<endl;
		return 0;
	}
	cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cmath>
#include<iomanip>
#define fast ios_base::sync_with_stdio(0)
#define fast_in cin.tie(0)
#define fast_out cout.tie(0)
#define ll long long
#define MAX 1000000
#define MAX_MAX 10000000000
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
using namespace std;

int main()
{
  ll n;
  cin>>n;
  ll a[100000],dp[100000];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(ll i=2;i<n;i++)
  {
  	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1792
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}



ll fac[100005];


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    fac[0] = 1;
    for(int i=1;i<=100000;i++)
    	fac[i] = (i * fac[i-1]) % MOD;

    int n;
    cin>>n;

    vector<int> arr;
    ll ans = 1;
    while(n--){
    	int x;
    	cin>>x;
    	if(x < 2*((int)arr.size()+1)-1)
    		ans = (ans * ((int)arr.size()+1)) % MOD;
    	else
    		arr.pb(x);
    }

    ans *= fac[(int)arr.size()];
    ans %= MOD;
    cout<<ans;
    return 0;
}




Measured memory_bytes: 1660
#include<iostream>
using namespace std;
string s,t;
main()
{
    int n,f,l,m;cin>>n;f=0;l=n;
    cout<<0<<endl;
    cin>>s;
    if(s=="Vacant")return 0;
    while(t!="Vacant"){
        m=(f+l)/2;
        cout<<m<<endl;
        cin>>t;
        if(m%2^s==t)f=m;
        else l=m;
    }
}

Measured memory_bytes: 3864
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
int n;
int a[300010] = {0};
int b[300010] = {0};
int c[100010] = {0};

signed main(){
    cin >> n;
    rep(i,3*n){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);
    sort(b+n,b+3*n);

    int l_sum = 0;
    int r_sum = 0;
    rep(i,n){
        l_sum += b[i];
        r_sum += b[i+n];
    }
    //map<int,int> l_low;
    map<int,int> l_high;
    map<int,int> r_low;
    map<int,int> r_high;
    rep(i,n){
        l_high[b[i]]++;
        r_low[b[i+n]]++;
        r_high[b[i+2*n]]++;
    }
    int ans = l_sum -r_sum;

    // for(auto& x:l_high)cerr << x.fi << ":" << x.se << " ";
    // cerr << endl;
    // for(auto& x:r_low)cerr << x.fi << ":" << x.se << " ";
    // cerr << endl;
    // for(auto& x:r_high)cerr << x.fi << ":" << x.se << " ";
    // cerr << endl;

    for(int i = n; i < 2*n;i++){
        auto itr = l_high.lower_bound(0);
        if(itr->fi < a[i]){
            (itr->se)--;
            l_sum -= itr->fi;
            if(itr->se == 0)l_high.erase(itr->fi);
            l_high[a[i]]++;
            l_sum += a[i];
        }

        itr = r_high.lower_bound(0);
        if(itr->fi < a[i]){
            (r_high[a[i]])--;
            if(r_high[a[i]] == 0)r_high.erase(a[i]);
        }else{
            int x = itr->fi;
            r_sum += x;
            (itr->se)--;
            if(itr->se == 0)r_high.erase(itr->fi);
            r_low[x]++;
            (r_low[a[i]])--;
            if(r_low[a[i]] == 0)r_low.erase(a[i]);
            r_sum -= a[i];
        }
        ans = max(ans,l_sum-r_sum);
    }
    cout << ans << endl;


    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 
// rm -r -f test;oj dl http://arc074.contest.atcoder.jp/tasks/arc074_b

Measured memory_bytes: 23680
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll a;cin >> a;
	cout << a + a * a + a * a * a << endl;
}	

Measured memory_bytes: 11000
N,M,C = gets.chomp.split(' ').map{|n| n.to_i}
B = gets.chomp.split(' ').map{|n| n.to_i}
over_zero = 0
N.times.each do |n|
  total = 0
  a = gets.chomp.split(' ').map{|n| n.to_i}
  count = 0
  a.each do |i|
    total += i * B[count]
    count += 1
  end
  over_zero += 1 if (total + C) > 0
end
puts over_zero

Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
int main(){
  int n; cin >>n;
  vector<ll> v;
  vector<ll> m(n+1);
  set<int> s;
  rep(i,n){
    int in; cin >> in;
    m[in] = i;
    v.pb(in);
  }
  s.insert(-1);
  s.insert(n);
  ll ans = 0;
  rep(i,n){
    int next_index = m[i+1];
    auto itr_l = s.lower_bound(next_index);
    int t = *itr_l;
    int b = *(--itr_l);

    s.insert(m[i+1]);
    //SHOW(t,b);
    ans += (i+1)*(t - next_index)*(next_index - b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12784
fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toInt()
    val a = mutableSetOf<String>()
    for (i in s.indices) {
        val b = (i until Math.min(i + k, s.length)).map { s.slice(i..it) }.toSet()
        a += b
    }
    println(a.sorted()[k - 1])
}


Measured memory_bytes: 41228
//この問題も人間舐めてたｗ
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int m, k;

int main() {
	int i;
	
	cin >> m >> k;
	
	if (m == 1) {
		if (k == 0) cout << "0 0 1 1" << endl;
		else cout << -1 << endl;
		return 0;
	}
	
	if (k >= (1 << m)) { cout << -1 << endl; return 0; }
	
	vector<int> ans;
	rep(i, (1 << m)) { if (i != k) ans.push_back(i); }
	ans.push_back(k);
	rrep(i, (1 << m)) { if (i != k) ans.push_back(i); }
	ans.push_back(k);
	
	rep(i, ans.size()) {
		cout << ans[i];
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {

  int s,s1,s2,s3;
  cin >> s;

  s1 = s / 100;
  s2 = (s - s1*100) / 10;
  s3 = (s - s1*100 - s2*10);

  cout << s1 + s2 + s3 << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

string join(vector<int> vec){
    string str;
    for (int i=0;i<vec.size();i++){
        str += vec[i];
    }
    return str;
}

ll gcd(ll x,ll y){
    if (x<y) swap(x,y);
    if (y==0) return x;
    else return gcd(y,x%y);
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    for (int i=0;i<k;i++){
        cin >> d[i];
    }
    for (int i=n;i<100000;i++){
        bool bl = false;
        string str = to_string(i);
        for (char s:str){
            for (int x:d){
                char sx = '0' + x;
                if (s==sx){
                    bl = true;
                    break;
                }
            }
            if (bl) break;
        }
        if (!bl){
            cout << str << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
input()
nums = list(map(int, input().split(' ')))

n = int(input())
for _ in range(n):
    f, m, l = list(map(int, input().split(' ')))
    sb = list(nums[f:l])
    r = (l-m)
    sb = sb[len(sb)-r:] + sb[:len(sb)-r]

    nums = nums[:f] + sb + nums[l:]

print(' '.join(map(str, nums)))




Measured memory_bytes: 5636
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

#gridのindexは入力値のまま扱う(grid=[1,1]~[H,W])
#left<x<rightの間が生存範囲(初めはグリッド全てが生存可能状態)
left=0
right=W+1
up=0
down=H+1

ans="YES"
for s,t in zip(reversed(S),reversed(T)):
    if t=='R':
        left=max(0,left-1)
    elif t=="L":
        right=min(W+1,right+1)
    elif t=="D":
        up = max(0,up-1)
    else:
        down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    #right<=left+1
    if right-left==1 or down-up==1:
        ans="NO"
        break

if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)


Measured memory_bytes: 3888
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	fmt.Fprintf(stdout, "%.10f\n", float64(n-n/2)/float64(n))
}


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

int main() {
  ll n;cin >> n;
  vector<char> s(n);
  ll r = 0,w = 0;
  rep(i,n){
    cin >> s.at(i);
    if( s.at(i) == 'R' ) ++r;
    else ++w;
  }

  ll ans = 0;
  for(ll i=0;i<r;++i){
    if( s.at(i) == 'W' ) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <climits>
#include <cassert>
using namespace std;

int top, S[1000];
void push(int x) {
	//??????????????????????????????????????????
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (cin >> s) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if(s[0]=='-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	cout << pop() << endl;

	return 0;
} 

Measured memory_bytes: 3100
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const double PI = 3.1415926535;

class Dice {
private:
	void roll(int a, int b, int c, int d) {
		swap(x[a], x[b]);
		swap(x[b], x[d]);
		swap(x[c], x[d]);
	}
public:
	int x[6];
	void roll_N() { roll(0, 1, 4, 5); }
	void roll_E() { roll(0, 3, 2, 5); }
	void roll_S() { roll(0, 4, 1, 5); }
	void roll_W() { roll(0, 2, 3, 5); }
};

int main() {
	// 小数点以下12ケタを表示させるためのおまじない
	cout << fixed << setprecision(12);

	Dice die;
	for (int i = 0; i < 6; i++) {
		cin >> die.x[i];
	}
	char ch;
	while (cin >> ch) {
		if (ch == 'N') {
			die.roll_N();
		} else if (ch == 'E') {
			die.roll_E();
		} else if (ch == 'S') {
			die.roll_S();
		} else {
			die.roll_W();
		}
	}
	cout << die.x[0] << endl;
	return 0;
}



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

int main() {
	int n;
	cin >> n;
	long long a[n + 1], b[n + 1];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		cin >> b[i];
	}
	a[n] = 0;
	b[n] = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] > b[i]) a[n] += a[i] - b[i];
		else if (a[i] < b[i]) b[n] += (b[i] - a[i]) / 2;
	}
	cout << (a[n] - b[n] > 0 ? "No" : "Yes") << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=100000;
const string INF="zzzzzzzz";

set<string> ban[5];
string ans=INF;

void dfs(int d, string s)
{
    if(d==4) return;

    rep(i,26)
    {
        char add='a'+i;
        string nx = s+string{add};
        if(!ban[d+1].count(nx))
        {
            if(nx.size()<ans.size()) ans=nx;
            else if(nx.size()==ans.size()) ans=min(ans,nx);
        }
        dfs(d+1,nx);
    }
}

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

    int n;
    cin >>n;
    rep(i,n)
    {
        string s;
        cin >>s;

        int S=s.size();
        for(int j=1; j<=4; ++j)
        {
            rep(k,S-j+1) ban[j].insert(s.substr(k,j));
        }
    }

    dfs(0,"");

    assert(ans!=INF);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42416
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const string button[10] = { 
	"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
};

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	while (n-- ){
		string s = ""; cin >> s;
		int m =  s.length();
		map<int,int> p; p.clear();
		string res = "";

		rep (i, m ){
			if (s[i] != '0' ){
				p[(int)(s[i]-'0')]++;
			}else{
				map<int,int>::iterator it = p.begin();
				if (it == p.end() ) continue;
				int a = (*it).first;
				int b = (*it).second; b--;
				int len = button[a].length();
				res += button[a][b%len];
				p.clear();
			} // end if
		} // end rep
		cout << res << endl;

	} // end while

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  double a, b, ave;

  cin >> a >> b;

  ave = (a + b) / 2;

  if ((int)ave / 1 == ave){
    cout << ave << endl;
  } else {
    cout << (int)ave + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] num = new int[51];
    for (int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      num[a]++;
      num[b]++;
    }
    for (int i = 1; i <= N; i++) {
      System.out.println(num[i]);
    }
  }
}

Measured memory_bytes: 21204
import numpy as np

H, W = (int(i) for i in input().split())

A = [["" for i in range(W)] for j in range(H)]

for i in range(H):
    tmp = list(input())
    for j in range(W):
        A[i][j] = tmp[j]

hlist = []
wlist = []

for i in range(H):
    if "#" not in A[i]:
        hlist.append(i)

for j in range(W):
    tmp = []
    for i in range(H):
        tmp.append(A[i][j])
    if "#" not in tmp:
        wlist.append(j)

# print(hlist)
# print(wlist)

for i in hlist:
    for j in range(W):
        A[i][j] = 0

for j in wlist:
    for i in range(H):
        A[i][j] = 0

for i in range(H):
    while True:
        if 0 in A[i]:
            A[i].remove(0)
        else:
            break

while True:
    if [] in A:
        A.remove([])
    else:
        break

for li in A:
    print("".join(li))

Measured memory_bytes: 12448
#include<stdio.h>

int main(){
	int S, h, m, s;
	scanf("%d", &S);
	h = S/3600;
	m = (S-h*3600)/60;
	s = S-h*3600-m*60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
ss = input()
tt = input()

res = "Yes"
_dict = {chr(x): [] for x in range(97, 123)}
_dict2 = {chr(x): [] for x in range(97, 123)}
for i, j in zip(ss, tt):
    _dict[i].append(j)
for i, j in zip(ss, tt):
    _dict2[j].append(i)

for array in _dict.values():
    if len(set(array)) > 1:
        res = "No"
        break
for array in _dict2.values():
    if len(set(array)) > 1:
        res = "No"
        break
print(res)


Measured memory_bytes: 8240
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), sum(n);
	rep (i, n) cin >> a[i];
	rep (i, n) sum[i] = (i > 0 ? sum[i - 1] : 0) + a[i];
	ll ans = 2020202020LL * 200000LL;
	rep (i, n) chmin(ans, abs(sum[n - 1] - 2 * sum[i]));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3328
#include <complex>
#include <cstdio>

int num[3];

int combi[6][3] = {
  {0, 1, 2},
  {0, 2, 1},
  {1, 0, 2},
  {1, 2, 0},
  {2, 0, 1},
  {2, 1, 0}
};

int calc_cost(int n1, int n2, int n3)
{
  return std::abs(n2 - n1) + std::abs(n3 - n2);
}

int main()
{
  for (int i = 0; i < 3; ++i)
    scanf("%d", &num[i]);

  int cost = 100;

  for (int i = 0; i < 6; ++i)
  {
    int c = calc_cost(num[combi[i][0]], num[combi[i][1]], num[combi[i][2]]);
    if (c < cost)
      cost = c;
  }

  printf("%d\n", cost);

  return 0;
}

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

int gcd(int x,int y){
	if(y == 0)return x;
	return gcd(y,x%y);
}

vector<int> divisors(int n){
	vector<int> ret;
	ret.push_back(1);
	for(int i = 2 ; i*i <= n ; i ++){
		if(n%i == 0){
			int cnt = 0;
			while(n%i == 0){
				n /= i;
				cnt ++;
			}
			int m = ret.size();
			for(int j = 0 ; j < m ; j ++){
				int t = ret[j];
				for(int k = 0 ; k < cnt ; k ++){
					t *= i;
					ret.push_back(t);
				}
			}
		}
	}
	if(n > 1){
		int m = ret.size();
		for(int i = 0 ; i < m ; i ++){
			ret.push_back(ret[i]*n);
		}
	}
	sort(ret.begin(),ret.end());
	return ret;
}

int main(){
	static int n;
	static int a[100010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	if(n == 1){
		cout << 1000000000 << endl;
		return 0;
	}
	
	int ret = 1;
	vector<int> vec = divisors(a[0]);
	for(int i = 0 ; i < vec.size() ; i ++){
		int d = vec[i];
		int cnt = 0;
		for(int j = 1 ; j < n ; j ++){
			if(a[j]%d == 0)cnt ++;
		}
		if(cnt >= n-2)ret = max( ret , d );
	}
	vec = divisors(a[1]);
	for(int i = 0 ; i < vec.size() ; i ++){
		int d = vec[i];
		int cnt = 0;
		for(int j = 0 ; j < n ; j ++){
			if(j == 1)continue;
			if(a[j]%d == 0)cnt ++;
		}
		if(cnt >= n-2)ret = max( ret , d );
	}
	cout << ret << endl;
}

Measured memory_bytes: 640
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (i, ngtkana_is_genius)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n, m;
    std::cin >> n >> m;
    vec<usize> a(m);
    usize odd = 0;
    REP (i, m) {
        usize x;
        std::cin >> x;
        if (x%2) odd++;
        a.at(i) = x;
    }
    if (2<odd) {
        std::cout << "Impossible" << '\n';
        return 0;
    }

    auto ans = [&]() -> vec<usize> {
        if (a.size()==usize{1}) {
            usize x = a.front();
            if (x==1) return {x};
            else return {1, x-1};
        }

        do {
            auto it = std::find_if(ALL(a), [](usize x){ return x%2; });
            if (it==a.end()) break;
            std::swap(a.front(), *it);
            it = std::find_if(a.begin() + 1, a.end(), [](usize x){ return x%2; });
            if (it==a.end()) break;
            std::swap(*it, a.back());
        } while (false);
        DEBUG(a);

        auto b = a;
        b.front()++;
        b.back()--;
        if (b.back()==0) b.pop_back();
        return b;
    }();

    DEBUG(ans);

    for (usize i=0; i<m; i++) std::cout << (i ? " " : "") <<  a.at(i); std::cout << '\n';
    std::cout << ans.size() << '\n';
    for (usize i=0; i<ans.size(); i++) std::cout << (i ? " " : "") << ans.at(i); std::cout << '\n';
}


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

#define FOR( i, m, n )   for( int i = m; i < n; i++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

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

  cout << ( a + b )  / 2 << endl;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define  ref(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
typedef long long ll;

using namespace std;
long long a,b;
double B;

int main()
{
    cin>>a>>B;
    b=B*100+1e-9;
    a*=b;
    a/=100;
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3724