akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

void solve(int N, int M, vector<string> S)
{
    auto is_valid = [&](int i, int j) {
        return 0 <= i && i < N && 0 <= j && j < M && S.at(i).at(j) == '.';
    };

    mf_graph<int> graph(N * M + 2);
    int s = N * M, t = N * M + 1;
    auto to_id = [&](int i, int j) {
        return i * M + j;
    };

    struct cell
    {
        int i, j;
    };
    auto to_cell = [&](int id) {
        return (cell){id / M, id % M};
    };

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (!is_valid(i, j))
                continue;
            int id = to_id(i, j);

            if ((i + j) % 2 == 0)
            {
                // s -> even
                graph.add_edge(s, id, 1);

                // even -> odd
                for (int v = 0; v < (int)di.size(); v++)
                {
                    if (!is_valid(i + di.at(v), j + dj.at(v)))
                        continue;
                    int id_o = to_id(i + di.at(v), j + dj.at(v));
                    graph.add_edge(id, id_o, 1);
                }
            }
            else
            {
                // odd -> t
                graph.add_edge(id, t, 1);
            }
        }
    }

    cout << graph.flow(s, t) << endl;

    for (auto &&e : graph.edges())
    {
        if (e.from == s || e.to == t || e.flow == 0)
            continue;
        cell even = to_cell(e.from);
        cell odd = to_cell(e.to);
        if (even.i == odd.i)
        {
            if (even.j < odd.j)
            {
                S.at(even.i).at(even.j) = '>';
                S.at(odd.i).at(odd.j) = '<';
            }
            else
            {
                S.at(odd.i).at(odd.j) = '>';
                S.at(even.i).at(even.j) = '<';
            }
        }
        else
        {
            if (even.i < odd.i)
            {
                S.at(even.i).at(even.j) = 'v';
                S.at(odd.i).at(odd.j) = '^';
            }
            else
            {
                S.at(odd.i).at(odd.j) = 'v';
                S.at(even.i).at(even.j) = '^';
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << S.at(i) << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    solve(N, M, move(S));
    return 0;
}


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

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

	long long ans = 0;
	int cnt = 0;
	int state = 0;
	for(int i = 0; i < s.size(); i++)
	{
		if(state == 0){
			switch(s[i]){
			case 'A':
				cnt++;
				state = 1;
				break;
			case 'B':
			case 'C':
				break;
			}
		} else if(state == 1){
			switch(s[i]){
			case 'A':
				cnt++;
				break;
			case 'B':
				state = 2;
				break;
			case 'C':
				cnt = 0;
				state = 0;
				break;
			}
		} else {
			switch(s[i]){
			case 'A':
				cnt = 1;
				state = 1;
				break;
			case 'B':
				cnt = 0;
				state = 0;
				break;
			case 'C':
				ans += cnt;
				state = 1;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
def is_prime(n):
    if n == 2:
        return True
    elif n%2 == 0:
        return False
    i = 3
    while n/i >= i:
        if n%i == 0:
            return False
        i += 2
    return True

primes = []
i = 2
while i < 55555:
    if is_prime(i):
        primes.append(i)
    i += 5

ans = []
n = int(input())
for i in range(n):
    ans.append(str(primes[i]))

print(' '.join(ans))

Measured memory_bytes: 3064
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

pair<vector<int>, int> Scc(const vector<vector<int>>& adj) {
    const int n = adj.size();
    vector<int> num(n, 0), low(n, 0), color(n, 0);
    vector<int> sta;
    vector<bool> inS(n, 0);
    int t = 0, colnum = 0;
    function<void(int)> visit = [&](int cur) {
        low[cur] = num[cur] = ++t;
        sta.emplace_back(cur); inS[cur] = 1;
        for(int nxt : adj[cur]) {
            if(num[nxt] == 0) {
                visit(nxt);
                low[cur] = min(low[cur], low[nxt]);
            } else if(inS[nxt])
              low[cur] = min(low[cur], num[nxt]);
        }
        if(low[cur] == num[cur]) {
            while(true) {
                int nxt = sta.back(); sta.pop_back(); inS[nxt] = false;
                color[nxt] = colnum;
                if(cur == nxt) break;
            }
            ++colnum;
        }
    };
    for(int v : in(n))
      if(num[v] == 0)
        visit(v);
    return make_pair(color, colnum);
}

vector<int> topologicalSort(const vector<vector<int>>& adj) {
    int N = adj.size();
    vector<int> deg(N);//??\?¬???°
    for(int i = 0; i < N; ++i)
      for(int nv : adj[i])
        ++deg[nv];
    vector<int> ord(N, -1);
    int t = 0;
    for(int v = 0; v < N; ++v) 
      if(deg[v] == 0)
        ord[t++] = v;
    for(int h = 0; h < t; ++h) {
        int v = ord[h];
        for(int nv : adj[v]) {
            --deg[nv];
            if(deg[nv] == 0)
              ord[t++] = nv;
        }
    }
    return ord;
}

using i64 = long long;
const i64 MOD = 1e9 + 7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> __adj(n);
    for(int _ : in(m)) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        __adj[u].emplace_back(v);
    }
    vector<int> color; int col;
    tie(color, col) = Scc(__adj);
    vector<vector<int>> radj(col);
    for(int v : in(n))
      for(int u : __adj[v])
        if(color[v] != color[u])
          radj[color[u]].emplace_back(color[v]);
    for(auto& a : radj) {
        sort(a.begin(), a.end());
        a.erase(unique(a.begin(), a.end()), a.end());
    }
    vector<int> ord = topologicalSort(radj);
    vector<i64> dp(col, -1LL);
    i64 ans = 1LL;
    function<i64(int)> dfs = [&](int v) {
        assert(v != -1);
        i64& res = dp[v];
        if(res != -1LL) return res;
        res = 1LL;
        for(int u : radj[v])
          res = res * dfs(u) % MOD;
        return ++res;
    };
    for(int v : ord) {
        if(dp[v] != -1LL) continue;
        ans = ans * dfs(v) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3272
s = input()
t = input()

lens = len(s)
lent = len(t)

# dp = [[None] * lent for _ in range(lens)]
# def dfs(aindex=0, bindex=0):
#     if aindex >= lens:
#         return 0
#     if bindex >= lent:
#         return 0
#
#     if dp[aindex][bindex] is not None:
#         return dp[aindex][bindex]
#
#     if s[aindex] == t[bindex]:
#         r = dfs(aindex + 1, bindex + 1) + 1
#     else:
#         r = max(dfs(aindex + 1, bindex), dfs(aindex, bindex + 1))
#     dp[aindex][bindex] = r
#     return r
#
# print(dfs())

shift = [1 << x for x in range(3000 + 1)]

dp = [[0] * (lent + 1) for _ in range(lens + 1)]
for aindex in range(lens - 1, -1, -1):
    for bindex in range(lent - 1, -1, -1):
        if s[aindex] == t[bindex]:
            r = dp[aindex + 1][bindex + 1] + 1
        else:
            r = max(dp[aindex + 1][bindex], dp[aindex][bindex + 1])
        dp[aindex][bindex] = r

ans = ""
ls = len(s)
lt = len(t)
ls = 0
lt = 0
while ls < lens and lt < lent:
    if dp[ls][lt] == dp[ls + 1][lt]:
        ls += 1
    elif dp[ls][lt] == dp[ls][lt + 1]:
        lt += 1
    else:
        ans += t[lt]
        ls += 1
        lt += 1
print(ans)


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 100100100100100;
    for (int x = 1; x <= 100; x++) {
        ll tmp = 0;
        rep(i, n) {
            tmp += (a[i] - x) * (a[i] - x);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 1;
const int MAXM = 3;
int n, k, r, s, p;
int dp[MAXM][MAXN],cost[MAXM];
char arr[MAXN];

int getCost(int a, int b) {
	if ((a + 1) % MAXM == b) return cost[a];
	else return 0;
}

int getNum(char c) {
	if (c == 'r')return 0;
	else if (c == 's')return 1;
	else return 2;
}

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

	cin >> n >> k;

	for (int i = 0; i < 3; i++) {
		cin >> cost[i];
	}

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

	for (int i = 0; i < n; i++) {
		int tmp = i - k;
		int cur = getNum(arr[i]);

		for (int j = 0; j < 3; j++) {
			if (tmp < 0) {
				dp[j][i] = getCost(j, cur);
			}
			else {
				for (int t = 0; t < 3; t++) {
					if (j == t) continue;
					dp[j][i] = max(dp[j][i], dp[t][i - k] + getCost(j, cur));
				}
			}
		}
	}

	int ans = 0;

	for (int i = n - 1; i >= max(n - k,0) ; i--) {
		int sum = 0;

		for (int j = 0; j < 3; j++) {
			sum = max(sum, dp[j][i]);
		}
		ans += sum;
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    string O = "RUD";
    string E = "LUD";
    string S; cin >> S;
    for(int i=0; i<(int)S.size(); i++){
        bool f = false;
        if(i%2==0){
            for(int j=0; j<3; j++){
                if(S[i]==O[j]) f = true;
            }
        }else{
            for(int j=0; j<3; j++){
                if(S[i]==E[j]) f = true;
            }
        }
        if(!f){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);
	
	string s, t;
	cin >> s >> t;

	int a, b;
	cin >> a >> b;

	string u;
	cin >> u;

	if (u == s) --a;
	else if(u == t) --b;

	cout << a << ' ' << b << '\n';


	return 0;
}

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

int main() {
  long N, K;
  cin >> N >> K;
  long h[N];
  for(long i=0; i<N; i++) cin >> h[i];

  sort(h, h+N);

  long ans = 0;
  for(long i=K-1; i<N; i++){
    long min = h[i-K+1];
    long max = h[i];
    if(i == K-1) ans = max-min;
    ans = std::min(max-min, ans);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, val;
    cin >> n;
    map<int, int> cnt;
    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[val] += 1;
    }
    vector<ll> arr;
    for(auto p: cnt) {
        while(p.second > 1) {
            arr.push_back(p.first);
            p.second -= 2;
        }
    }
    if (arr.size() < 2)
        cout << 0 << endl;
    else
        cout << arr.back() * arr[arr.size()-2] << endl;
    return 0;
}




Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int max1 = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
    for ( int j = 0; j <= n; j++ ) c[0][j] = 0;

    for ( int i = 1; i <= m; i++ ) {
        for (int j = 1; j <= n; j++ ) {
            if ( X[i] == Y[j] ) {
                c[i][j] = c[i - 1][j - 1] + 1;
            } else {
                c[i][j] = max(c[i-1][j], c[i][j - 1]);
            }
            max1 = max(max1, c[i][j]);
        }
    }

    return max1;
}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}


Measured memory_bytes: 7088
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
        else:
            break
    if ind >= N:
        break

print(sum(A))


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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

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

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

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

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

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

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

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

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

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

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

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

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

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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

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

void dfs(string s, vector<ll> &A) {
    A.push_back(stoll(s));
    if (s.size() > 10)return;
    int x = s[s.size() - 1] - '0';
    for (int i = max(0, x - 1); i <= min(9, x + 1); ++i) {
        char c = '0' + i;
        dfs(s + c, A);
    }
}

int main() {
    int k;
    cin >> k;
    vector<ll> A;
    for (int i = 1; i < 10; ++i) {
        char c = '0' + i;
        string s = "";
        dfs(s + c, A);

    }
    sort(A.begin(), A.end());

    cout << A[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 11632
A, B, m = map(int, input().split())
a = []
b = []
p = []

a = list(map(int, input().split()))
b  = list(map(int, input().split()))
ans = min(a) + min(b)

for _ in range(m):
    i, j, k = list(map(int, input().split()))
    p.append(a[i-1] + b[j-1] - k)
ppt = min(p)

if ans > ppt: ans = ppt

print(ans)

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

int dp[3001][3001];
string s, t;

int recurse(int i, int j) {
	int& state = dp[i][j];
	if(state != -1) return state;
  	if(!i or !j) return state = 0;
  	if(s[i - 1] == t[j - 1]) return state = recurse(i - 1, j - 1) + 1;
  	return state = max(
      recurse(i - 1, j),
      recurse(i, j - 1)
    );
}

int main() {
	string lcs = ""; cin >> s >> t;
  	int n = (int)s.length(), m = (int)t.length();
  	memset(dp, -1, sizeof dp);
  	recurse(n, m);
  	int x = n, y = m;
  	while(x > 0 and y > 0) {
    	if(s[x - 1] == t[y - 1]) {
        	lcs = s[x - 1] + lcs;
          	--x, --y;
        } else if(dp[x - 1][y] > dp[x][y - 1]) {
        	--x;
        } else {
        	--y;
        }
    }
  	cout << lcs;
	return 0;
}

Measured memory_bytes: 35968
def read_input():
    s = input()
    a, b, c, d = map(int, [c for c in s])

    return a, b, c, d


def check_formulae(a, b, c, d):
    if a + b + c + d == 7:
        print('{}+{}+{}+{}=7'.format(a,b,c,d))
        return
    if a + b + c - d == 7:
        print('{}+{}+{}-{}=7'.format(a,b,c,d))
        return
    if a + b - c + d == 7:
        print('{}+{}-{}+{}=7'.format(a,b,c,d))
        return
    if a + b - c - d == 7:
        print('{}+{}-{}-{}=7'.format(a,b,c,d))
        return
    if a - b + c + d == 7:
        print('{}-{}+{}+{}=7'.format(a,b,c,d))
        return
    if a - b + c - d == 7:
        print('{}-{}+{}-{}=7'.format(a,b,c,d))
        return
    if a - b - c + d == 7:
        print('{}-{}-{}+{}=7'.format(a,b,c,d))
        return
    if a - b - c - d == 7:
        print('{}-{}-{}-{}=7'.format(a,b,c,d))
        return
    return


def submit():
    a, b, c, d = read_input()
    check_formulae(a, b, c, d)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 3064
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Jan 29 11:07:21 2019
//
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	board := make([][]string, 100)
	for i := range board {
		board[i] = make([]string, 100)
		for j := range board[i] {
			if i < 50 {
				board[i][j] = "#"
			} else {
				board[i][j] = "."
			}
		}
	}

	h := 0
	w := 0
	for i := 0; i < A-1; i++ {
		board[h][w] = "."
		w += 2
		if w >= 100 {
			w = 0
			h += 2
		}
	}

	h = 51
	w = 0
	for i := 0; i < B-1; i++ {
		board[h][w] = "#"
		w += 2
		if w >= 100 {
			w = 0
			h += 2
		}
	}

	fmt.Println(100, 100)
	for i := range board {
		for j := range board[i] {
			fmt.Print(board[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int Q;
  cin >> Q;
  
  vector<bool> IsPrime(100100, true);
  IsPrime.at(0) = false;
  IsPrime.at(1) = false;
  vector<int> Plus(100100, 0);
  for( int i = 2; i <= 100000; i++ ){
    if( IsPrime.at(i) == true ){
      for( int j = 2; i*j <= 100000; j++ ) IsPrime.at(i*j) = false;
      if( IsPrime.at((i+1)/2) == true ) Plus.at(i) = 1;
    }
  }
  
  for( int i = 1; i <= 100000; i++ ){
    Plus.at(i) += Plus.at(i-1);
  }
  
  int l, r;
  for( int i = 0; i < Q; i++ ){
    cin >> l >> r;
    cout << Plus.at(r) - Plus.at(l-1) << endl;
  }
  
  
  
}




Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		long sum = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				sum += d[i] * d[j];
			}
		}
		System.out.println(sum);
	}

}

class MyComparator implements Comparator {
	@Override
	public int compare(Object arg0, Object arg1) {
		long x = (long) arg0;
		long y = (long) arg1;

		if (x < y) {
			return 1;
		} else if (x > y) {
			return -1;
		} else {
			return 0;
		}
	}
}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22356
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{
	int a, b;
	cin >> a;
	cin >> b;
	
	int area = a * b;
	int length = 2 * a + 2 * b;
	
	cout << area << " " << length << endl;
	
	return 0;
}

Measured memory_bytes: 3016
import copy


def resolve():
	src = input()
	ans = 0
	for i in range(1 << len(src)-1):
		s = copy.copy(src)
		trim_size = 1
		for j in range(len(s)-1):
			if (i >> j) & 1 and len(s):
				ans += int(s[:trim_size])
				s = s[trim_size:]
				trim_size = 1
			else:
				trim_size += 1
		if len(s):
			ans += int(s)
	print(ans)
resolve()

Measured memory_bytes: 39408
import copy


class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

    def E(self):
        self.top, self.bottom, self.left, self.right = self.left, self.right, self.bottom, self.top

    def W(self):
        self.left, self.right, self.bottom, self.top = self.top, self.bottom, self.left, self.right

    def spin(self):
        self.left, self.behind, self.right, self.front = self.front, self.left, self.behind, self.right

    def __eq__(self, _dice2):
        dice2 = copy.deepcopy(_dice2)
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.E()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.W()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.S()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        return False

    def _eqaul(self, dice2):
        return self.front == dice2.front and self.behind == dice2.behind and self.left == dice2.left and self.right == dice2.right and self.top == dice2.top and self.bottom == dice2.bottom

    def __repr__(self):
        return ",".join([str(object=i) for i in (self.top, self.front, self.right, self.left, self.behind, self.bottom)])


n=int(input())
dices=[]
flag=False
for i in range(n):
    d=Dice(*[int(i) for i in input().split(" ")])
    for dice in dices:
        if d==dice:
            flag=True
            break
    dices.append(d)
if flag:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 6360
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define reverse(s) reverse(s.begin(), s.end());
#define p pair<int,int>
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;

}
	


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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> vec(H);
    for(int h=0; h<H; h++) {
        cin >> vec[h];
    }
    
    string st="";
    for(int w=-1; w<=W; w++) {
        st += "#";
    }
    cout << st << endl;
    for(int h=0; h<H; h++) {
        cout << "#" << vec[h] << "#" << endl;
    }
    cout << st << endl;


    return 0;
    
}

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

int main() {
	double L;
	vector<double> v(10);
	char ch;

	int v1, v2;
	while (cin >> L) {
		v.at(0) = L;
		double sum = 0;
		sum += L;

		for (int i = 1; i < 10; i++) {
			cin >> ch >> v.at(i);
			sum += v.at(i);
		}
		cin >> ch >> v1 >> ch >> v2;
		/*for (int i = 0; i < 10; i++) {
			cout << v.at(i);
		}
		cout << v1 << ',' << v2 << endl;*/
		//cout << sum << endl;

		double hs = sum / (v1 + v2);
		double dis = v1 * hs;
		//cout << fixed << setprecision(5) << "hs:" << hs << endl;
		//cout << fixed << setprecision(5) << "dis:" << dis << endl;

		double sd = 0;
		for (int i = 0; i < 10; i++) {
			sd += v.at(i);
			if (dis <= sd) {
				cout << i+1 << endl;
				break;
			}
		}
	}
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin>>a>>b>>c;
    int l=0,r=a;
    REP(i,1e5){
        while(c<l) c+=60;
        if(c<=r){
            cout<<c<<endl;
            return 0;
        }else{
            l+=a+b,r+=a+b;
        }
    }
    cout<<-1<<endl;
}


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

using namespace std;

int main(void) {
    vector<int> n;
    vector<int> v{1,4,7,9};
    int tn;

    for (int i=0; i<4; i++) {
        cin >> tn;
        n.push_back(tn);
    }
    sort(n.begin(), n.end());

    if ( n == v ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; ++i)
#define RREP(i,n) for(int i = 0; i >= n; ++i)
typedef priority_queue <int> pi;
typedef priority_queue <int, vector<int>, greater<int>> pg;
typedef unsigned long long int ulli;

int N;
pi a;

int main(){
    cin >> N;
    int temp;
    REP(i,N){
        cin >> temp;
        a.push(temp);
    }
    int Alice = 0, Bob = 0;
    REP(i,N){
        if(i % 2 == 0) Alice += a.top();
        if (i % 2 == 1) Bob += a.top();
        a.pop();
    }
    cout << Alice - Bob << endl;
}

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

using namespace std;

int x, last, flag = 0;
int main() {
	int n, m = 1; scanf("%d", &n);
	scanf("%d", &last);
	for(int i = 1; i < n; ++i) {
		scanf("%d", &x);
		if(x == last) continue;
		if((x > last && flag == -1) || (x < last && flag == 1)) {
			m++; flag = 0;
		} else {
			flag = x > last ? 1 : -1;
		}
		last = x;
	}
	printf("%d\n", m);
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    bool win = false;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (a % 2) {
            win = true;
        }
    }

    cout << (win ? "first" : "second") << endl;
}

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

int main() {
  int n;
  cin >> n;
  if(n%10==3) cout << "bon" << endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3632
const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map{it.toInt()}
    val s = readLine()!!
    val ans = Array(n, {0})

    var cnt = 0
    var f = false
    for ((i, x) in s.withIndex()) {
        if (!f and (x == 'A')) {
            f = true
        } else if (!f) {
            f = false
        } else if (f and (x =='C')) {
            f = false
            cnt += 1
        } else if (f and (x == 'A')) {
            f = true
        } else {
            f = false
        }
        ans[i] = cnt
    }

    for (i in 0 until q) {
        val (l, r) = readLine()!!.split(' ').map{it.toInt()-1}
        println(ans[r] - ans[l])
    }
}


Measured memory_bytes: 67220
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(m), y(m);
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  vector<P> v(n);
  for (int i = 0; i < n; i++) {
    ll red = i == 0;
    ll cnt = 1;
    v[i] = P(red, cnt);
  }

  for (int i = 0; i < m; i++) {
    auto p = v[x[i]];
    ll red = p.first;
    ll cnt = p.second;

    if (cnt > 0) {
      v[y[i]].second++;
      v[x[i]].second--;
      if (red) {
        v[y[i]].first = 1;

        if (cnt == 1) {
          v[x[i]].first = 0;
        }
      }
    }
  }

  ll ans = count_if(all(v), [](P p) {
    ll red = p.first;

    return red > 0;
  });

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
ll const mod = 998244353;
//ll const mod=1e9+7;
const ll MAX = 300000;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }


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


int main() {
    int x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    vi p(101);
    vi used(1005, 0);
    rep(i, n) {
        cin >> p[i];
        used[p[i]] = 1;
    }
    ll ans = 1000;
    int res = 0;
    rep(i, 1000) {
        if (used[i] == 0 && chmin(ans, abs(x - i))) {
            res = i;
        }
    }
    cout << res << endl;
   
    return 0;
}

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

using namespace std;

int power(int a, int n){
  int result = a;
  for(int i = 1; i < n; i++){
    result *= a;
  }
  return result;
}

int main(){
  int n;
  cin >> n;
  vector<bool> result;
  for(int i = 0; i < n; i++){
    vector<int> tri;
    for(int j = 0; j < 3; j++){
      int tmp;
      cin >> tmp;
      tri.push_back(tmp);
    }
    sort(tri.begin(),tri.end());
    if(power(tri[0],2) + power(tri[1],2) == power(tri[2],2)){
      result.push_back(true);
    }else{
      result.push_back(false);
    }
  }
  for(int i = 0; i < n; i++){
    if(result[i]){
      cout << "YES\n";
    }else{
      cout << "NO\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3140
using System;
using static System.Console;
using static System.Math;
using System.Linq;

class Program
{

    static void Main()
    {
        string N = ReadLine();

        int sum = 0;
        for(int i = 0; i < N.Length; i++)
        {
            sum += int.Parse(N[i].ToString());
        }

        if (int.Parse(N) % sum == 0) WriteLine("Yes");
        else WriteLine("No");

    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int n; cin>>n;
    int cnt=0;
    for(int i=1; i<=n; i+=2){
        int yakusu=0;
        for(int j=1; j<=i; j++){
            if(i%j==0) yakusu++;
        }
        if(yakusu==8) cnt++;
    }
    cout<<cnt<<endl;
}

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

#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y) { return x % y == 0 ? y : GCD(y, x % y); }

int main() {
  int N,K;
  scanf("%d%d", &N,&K);
  ll H[N];
  for (int i = 0; i < N;i++){
    scanf("%lld", &H[i]);
  }

  sort(H, H + N);
  ll ans=0;
  for (int i = 0; i < N - K;i++){
    ans += H[i];
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1792
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

template<class T> struct UnionFind {
  vector<ll> par; 
  vector<ll> siz;
  vector<T> diff_weight;
    
  UnionFind(ll sz_, T sum_unity = 0): par(sz_), siz(sz_, 1), diff_weight(sz_, sum_unity) {
    for (ll i = 0; i < sz_; ++i) par[i] = i;

  }
  void init(ll sz_, T sum_unity) {
    par.resize(sz_);
    siz.resize(sz_, 1);
    diff_weight.resize(sz_, sum_unity);
    for (ll i = 0; i < sz_; ++i) par[i] = i;
  }

  ll root(ll x) { 
    if (par[x] == x) {
      return x;
    }
    else {
      ll r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }

  T weight(ll x) {
    root(x);
    return diff_weight[x];
  }

  bool merge(ll x, ll y, T w) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) {
      swap(x, y);
      w = -w;
    }
    siz[x] += siz[y];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return siz[root(x)];
  }

  T diff(ll x, ll y) {
    return weight(y) - weight(x);
  }
};

ll n, m;

void solve() {
  UnionFind<ll> uf(n, 0);
  while (m--) {
    char t;
    cin >> t;

    if (t == '!') {
      ll a, b, w;
      cin >> a >> b >> w;
      a--, b--;

      uf.merge(a, b, w);
    }
    else {
      ll a, b;
      cin >> a >> b;
      a--, b--;

      if (uf.issame(a, b)) cout << uf.diff(a, b) << '\n';
      else cout << "UNKNOWN\n";
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  while (cin >> n >> m, n && m) {
    solve();
  }

  




  
  return 0;
}


Measured memory_bytes: 5228
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String words = sc.next();
        System.out.print(words.charAt(0));
        System.out.print(words.length()-2);
        System.out.println(words.charAt(words.length()-1));
    }
}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;

int main()
{
	int w,d;
	while(scanf("%d%d", &w,&d),(w||d))
	{
		int ret=0,used[21]={0};
		for(int i=0; i<w; i++)
		{
			int t;
			scanf("%d", &t);
			used[t]++;
			ret+=t;
		}
		
		for(int i=0; i<d; i++)
		{
			int t;
			scanf("%d", &t);
			if(used[t]==0) ret+=t;
			else used[t]--;
		}
		
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;

}

LL N, x;
vector<vector<LL> > mi;
vector<LL> line;

int main(){
    cin >> N >> x;
    line.resize(N);
    REP(i, N)cin >> line[i];
    mi.resize(N, vector<LL>(N, INFLL));
    REP(i, N)mi[i][0]=line[i];
    REPA(i, N){
        REP(j, N){
            mi[j][i] = min(mi[j][i-1], line[(j-i+N)%N]);
        }
    }
    LL ans = INFLL;
    REP(i, N){
        LL sum = 0;
        REP(j, N){
            sum += mi[j][i];
        }
        sum += i * x;
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<((n+1)/2)*(n/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N;
	const double PI = 3.141592653589793;
	cin >> N;

	cout << showpoint;
	cout << fixed;
	cout << setprecision(20);
	cout << 2.0*PI*(double)N << endl;


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3760
#include <iostream>

using namespace std;

int main(void)
{
    uint64_t N;
    cin >> N;

    uint64_t p = 1;
    uint64_t d = 1000000000 + 7;
    for(uint64_t n = 1; n <= N; ++n)
    {
        p *= n;
        p %= d;
    }
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	for (int i = k; i <= 1000; i += k) {
		if (a <= i && i <= b) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<int, ll> i_ll;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;
double PI2 = M_PI * 2;

int main() {
	int N, M; cin >> N >> M;
	vector<int> a(M), b(M), c(M);
	rep(i, M) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
	vector<vector<int> > d(N, vector<int>(N, INF));
	rep(u, N) d[u][u] = 0;
	rep(i, M) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	rep(k, N) rep(u, N) rep(v, N)
		d[u][v] = min(d[u][v], d[u][k] + d[k][v]);
	int ans = 0;
	rep(i, M) {
		bool ok = true;
		rep(u, N) rep(v, N)
			if (d[u][v] == d[u][a[i]] + c[i] + d[b[i]][v])
				ok = false;
		if (ok) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  unsigned int n, m;
  int k;
  int a;
  int i, j;
  int items[31] = {};
  int counter = 0;


  scanf("%d %d\n", &n, &m);
  for(i=0; i<n; i++){
    scanf("%d", &k);
    for(j=0;j<k;j++){
      scanf("%d", &a);
      items[a]++;
    }
  }
  for(i=1;i<=m;i++){
    if(items[i] == n){
      counter++;
    }
  }
  printf("%d\n", counter);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, *A = map(int, open(0))
    A.sort()
    ans = 0
    if N % 2 == 1:
        ans += sum(A[N//2:])*2 - sum(A[:N//2])*2
        ans -= A[N//2]+A[N//2+1]
    else:
        ans += sum(A[N//2:])*2 - sum(A[:N//2])*2
        ans -= A[N//2]-A[N//2-1]
    

    ans2 = 0
    if N % 2 == 1:
        ans2 += sum(A[N//2+1:])*2 - sum(A[:N//2+1])*2
        ans2 += A[N//2]+A[N//2-1]
    else:
        ans2 += sum(A[N//2:])*2 - sum(A[:N//2])*2
        ans2 += A[N//2-1]-A[N//2]

    print(max(ans,ans2))

if __name__ == "__main__":
    main()


Measured memory_bytes: 13740