akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}


int main() {
	int n, k;
	cin >> n >> k;
	hei(llint) a(n);
	llint sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a);
	reverse(a);
	llint x = 0;
	rep(i, 0, k) {
		if (i >= n)break;
		x += a[i];
	}
	llint ans = sum - x;
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <set>

int main()
{
  auto n = 0;
  std::cin >> n;
  
  auto s = std::set<int>();
  auto d = 0;
  for(auto i = 0; i < n; ++i)
  {
    std::cin >> d;
  	s.insert(d);
  }
  
  std::cout << s.size() << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{
  var x = chunk.split(" ");
  x[0] = Number(x[0])
  x[1] = Number(x[1])
  x[2] = Number(x[2])
  x.sort();
  console.log(x[0] + " " + x[1] + " " + x[2])
}); 

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < N.size(); ++i) {
        if (N[i] == '2') ans++;
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class T>
class SegmentTree {

public:
    /**
     * @param N size
     * @param e identity element
     * @param operation operation for query
     * @param updater operation for update
     */
    SegmentTree(size_t N, T e, function<T(T, T)> operation, function<T(T, T)> updater)
            : e(e), operation(std::move(operation)), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, e);
    }

    /**
     * iの値をxに更新
     * @param i index ( 0-indexed )
     * @param x  value
     */
    void update(int i, T x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス
     * @param i index ( 0-indexed )
     */
    T operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<T> data;
    T e;
    function<T(T, T)> operation;
    function<T(T, T)> updater;

    T query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return e;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        T c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        T c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void Main() {
    int N;
    cin >> N;
    vector<ll> H(N), A(N);
    rep(i, N) cin >> H[i];
    rep(i, N) cin >> A[i];

    SegmentTree<ll> segmentTree(N + 1, 0, [](ll a, ll b) { return max(a, b); }, [](ll a, ll b) { return max(a, b); });
    rep(i, N) {
        ll h = H[i];
        ll a = A[i];
        ll tmp = segmentTree.query(0, h) + a;
        segmentTree.update(h, tmp);
    }
    cout << segmentTree.query(0, N + 1) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 7552
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

template <typename T>
class ConvecHullTrick {
 private:
  // 直線群(配列)
  std::vector<std::pair<T, T>> lines;
  // 最小値(最大値)を求めるxが単調であるか
  bool isMonotonicX;
  // 最小/最大を判断する関数
  std::function<bool(T l, T r)> comp;

 public:
  // コンストラクタ ( クエリが単調であった場合はflag = trueとする )
  ConvecHullTrick(bool flagX = false, std::function<bool(T l, T r)> compFunc = [](T l, T r) { return l >= r; })
      : isMonotonicX(flagX), comp(compFunc) {
    lines.emplace_back(0, 0);
  };

  // 直線l1, l2, l3のうちl2が不必要であるかどうか
  bool check(std::pair<T, T> l1, std::pair<T, T> l2, std::pair<T, T> l3) {
    if (l1 < l3) std::swap(l1, l3);
    return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first);
  }

  // 直線y=ax+bを追加する
  void add(T a, T b) {
    std::pair<T, T> line(a, b);
    while (lines.size() >= 2 && check(*(lines.end() - 2), lines.back(), line))
      lines.pop_back();
    lines.emplace_back(line);
  }

  // i番目の直線f_i(x)に対するxの時の値を返す
  T f(int i, T x) {
    return lines[i].first * x + lines[i].second;
  }

  // i番目の直線f_i(x)に対するxの時の値を返す
  T f(std::pair<T, T> line, T x) {
    return line.first * x + line.second;
  }

  // 直線群の中でxの時に最小(最大)となる値を返す
  T get(T x) {
    // 最小値(最大値)クエリにおけるxが単調
    if (isMonotonicX) {
      static int head = 0;
      while (lines.size() - head >= 2 && comp(f(head, x), f(head + 1, x)))
        ++head;
      return f(head, x);
    } else {
      int low = -1, high = lines.size() - 1;
      while (high - low > 1) {
        int mid = (high + low) / 2;
        (comp(f(mid, x), f(mid + 1, x)) ? low : high) = mid;
      }
      return f(high, x);
    }
  }
};

int main() {
  int N;
  ll C;
  while (cin >> N >> C) {
    vector<ll> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    vector<ll> dp(N, 0);
    ConvecHullTrick<ll> chk(false);
    chk.add(-2 * h[0], h[0] * h[0] + dp[0]);
    for (int i = 1; i < N; i++) {
      dp[i] = C + h[i] * h[i] + chk.get(h[i]);
      chk.add(-2 * h[i], h[i] * h[i] + dp[i]);
    }
    cout << dp[N - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) cin>>p[i];

  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  vector<int> r(d);
  rep(i,d) {
    cin>>r[i];
    r[i]--;
  }

  vector<ll> ans(d+1,0);
  vector<int> last(26,0);
  rep(i,d){
    ans[i+1]=ans[i]+q[i][r[i]];
    last[r[i]]=i+1;
    rep(j,26){
      ans[i+1]-=p[j]*(i+1-last[j]);
    }
  }


  repo(i,d+1){
    cout << ans[i] << endl;
  }

}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < 40; i++) {
    if (pow(K, i) <= N && N < pow (K, i + 1)) {
      cout << i + 1 << endl;
      break;
    }
  }
}

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

using namespace std;

int n, m;

int main(){
	scanf("%d%d", &n, &m);
	
	int res = m;
	
	for(int i = 0; i < n; i++){
		int x, y;
		
		scanf("%d%d", &x, &y);
		m += x;
		m -= y;
		
		res = max(res, m);
		
		if(m < 0) return 0 * printf("0\n");
	}
	
	printf("%d\n", res);
}



Measured memory_bytes: 3208
#include <iostream>

using namespace std;

#define MAX 100000

struct Card
{
	char suit;
	int value;
};

Card quickCards[MAX];
Card mergeCards[MAX];
Card lCards[MAX / 2 + 2];
Card rCards[MAX / 2 + 2];
Card infinity;

int Partition(Card cards[], int p, int r)
{
	Card temp;
	Card x = cards[r];
	int i = p - 1;
	for (int j = p; j < r; ++j)
	{
		if (cards[j].value <= x.value)
		{
			++i;
			temp = cards[i];
			cards[i] = cards[j];
			cards[j] = temp;
		}
	}

	temp = cards[i + 1];
	cards[i + 1] = x;
	cards[r] = temp;

	return i + 1;
}

void QuickSort(Card cards[], int p, int r)
{
	if (p < r)
	{
		int q = Partition(cards, p, r);
		QuickSort(cards, p, q - 1);
		QuickSort(cards, q + 1, r);
	}
}

void Merge(Card cards[], int l, int m, int r)
{
	int ll = m - l;
	int rl = r - m;
	for (int i = 0; i < ll; ++i)
		lCards[i] = cards[l + i];
	for (int i = 0; i < rl; ++i)
		rCards[i] = cards[m + i];
	lCards[ll] = infinity;
	rCards[rl] = infinity;

	int i = 0;
	int j = 0;
	for (int k = l; k < r; ++k)
	{
		if (lCards[i].value <= rCards[j].value)
			cards[k] = lCards[i++];
		else
			cards[k] = rCards[j++];
	}
}

void MergeSort(Card cards[], int l, int r)
{
	if (l + 1 < r)
	{
		int m = (l + r) >> 1;
		MergeSort(cards, l, m);
		MergeSort(cards, m, r);
		Merge(cards, l, m, r);
	}
}

bool IsStable(Card quickCards[], Card mergeCards[], int n)
{
	bool bIsStable = true;
	for (int i = 0; i < n; ++i)
	{
		if (quickCards[i].suit != mergeCards[i].suit
			|| quickCards[i].value != mergeCards[i].value)
		{
			bIsStable = false;
			break;
		}
	}

	return bIsStable;
}

int main()
{
	infinity.value = 2000000000;

	int n; cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> quickCards[i].suit >> quickCards[i].value;
		mergeCards[i].suit = quickCards[i].suit;
		mergeCards[i].value = quickCards[i].value;
	}
	//cout << "--------" << endl;
	MergeSort(mergeCards, 0, n);
	//for (int i = 0; i < n; ++i)
	//	cout << mergeCards[i].suit << " " << mergeCards[i].value << endl;
	//cout << "--------" << endl;
	QuickSort(quickCards, 0, n - 1);

	if (IsStable(quickCards, mergeCards, n))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
	for (int i = 0; i < n; ++i)
		cout << quickCards[i].suit << " " << quickCards[i].value << endl;
	
	return 0;
}


Measured memory_bytes: 5428
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int X,Y,Z,K;
    ArrayList<Long> A,B,C;

    private void solve() {
        X = nextInt();
        Y = nextInt();
        Z = nextInt();
        K = nextInt();

        A = new ArrayList<>();
        B = new ArrayList<>();
        C = new ArrayList<>();

        for(int i = 0;i < X;i++) {
            A.add(nextLong());
        }

        for(int i= 0;i < Y;i++) {
            B.add(nextLong());
        }

        for(int i = 0;i < Z;i++) {
            C.add(nextLong());
        }

        Collections.sort(A, Collections.reverseOrder());
        Collections.sort(B, Collections.reverseOrder());
        Collections.sort(C, Collections.reverseOrder());

        ArrayList<Long> AB = new ArrayList<>();
        for(int i = 0;i < X;i++) {
            for(int j = 0;j < Y;j++) {
                AB.add(A.get(i) + B.get(j));
            }
        }
        Collections.sort(AB, Collections.reverseOrder());

        int size = Math.min(K, AB.size());
        ArrayList<Long> ABC = new ArrayList<>();
        for(int i = 0;i < size;i++) {
            for(int j = 0;j < Z;j++) {
                ABC.add(AB.get(i) + C.get(j));
            }
        }
        Collections.sort(ABC, Collections.reverseOrder());

        for(int i = 0;i < K;i++) {
            out.println(ABC.get(i));
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

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

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

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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


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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> cnt(n);
    for (int _ = 0; _ < m; _++) {
        int nn; cin >> nn;
        for (int __ = 0; __ < nn; __++) {
            int x; cin >> x;
            --x;
            cnt[x]++;
        }
    }
    int res = 0;
    for (int x:cnt) res += x==0;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    unsigned long long int ans = 0;
    rep(i, n){
        cin >> a[i];
        if(i!=0){
            if(a[i-1]>a[i]){
                ans += a[i-1]-a[i];
                a[i] = a[i-1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
// AOJ 0291 Mystery of an Ancient Ruin
// 2018.2.15 bal4u

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int N, K;
char parts[26][12];
char ans[12];
char buf[1002], *p;

int in()
{
	int n = 0;
	while (isdigit(*p)) n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int gcd(int a, int b) {	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}
int lcm(int a, int b) {	return a/gcd(a, b)*b; }

void link(char *a, char *b)
{
	int i;
	char t[12];
	memcpy(t, a, N);
	for (i = 0; i < N; i++) a[i] = t[b[i]];
}

int period(char *a)
{
	int i, x, t, ans;

	ans = 1;
	for (i = 0; i < N; i++) {
		x = a[i], t = 1;
		while (x != i) x = a[x], t++;
		ans = lcm(ans, t);
	}
	return ans;
}

void calc(char *a)
{
	int n;
	char t[12];

	for (n = 0; n < N; n++) a[n] = n;
	while (*p >= ' ') {
		if (isalpha(*p)) link(a, parts[*p++ - 'A']);
		else if (*p == '+') p++;
		else if (*p == ')') break;
		else {
			n = in();
			if (isalpha(*p)) memcpy(t, parts[*p++ - 'A'], N);
			else { p++, calc(t), p++; }
			n %= period(t);
			while (n--) link(a, t);
		}
	}
}
 
int main()
{
	int E, i, j, k, h, g;
	char *t;

	fgets(p=buf, 10, stdin), N = in(), p++, K = in();
	for (i = 0; i < K; i++) {
		fgets(p=buf, 10, stdin);
		t = parts[*p - 'A'], p+= 2, h = in();

		for (j = 0; j < N; j++) t[j] = j;
		for (k = 1; k < h; k++) {
			fgets(p=buf, 30, stdin);
			for (j = 1; j < N; j++, p+=2) if (*p & 1) {
				g = t[j], t[j] = t[j-1], t[j-1] = g;
			}
		}
	}

	fgets(p=buf, 10, stdin), E = in();
	while (E--) {
		fgets(p=buf, 1002, stdin);
		calc(ans);
		printf("%d", ans[0]+1);
		for (j = 1; j < N; j++) printf(" %d", ans[j]+1);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
using namespace std;
typedef long long ll;
ll res = -1, n, m, x[55], y[55];
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < n; i++) cin >> x[i] >> y[i];
    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            for (ll k = 0; k < n; k++) {
                for (ll l = k + 1; l < n; l++) {
                    ll ans = 0;
                    for (ll t = 0; t < n; t++) {
                        if ((x[i] - x[t]) * (x[j] - x[t]) > 0) continue;
                        if ((y[k] - y[t]) * (y[l] - y[t]) > 0) continue;
                        ans++;
                    }
                    if (ans < m) continue;
                    if (res == -1) {
                        res = abs(x[i] - x[j]) * abs(y[k] - y[l]);
                    } else {
                        res = min(res, abs(x[i] - x[j]) * abs(y[k] - y[l]));
                    }
                }
            }
        }
    }
    cout << res << endl;
}


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

using namespace std;

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

void solve() {
    int n;
    cin >> n;
    vt<int> a(n);
    for (int &x : a) cin >> x;
    cout << accumulate(all(a), -n);
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}



Measured memory_bytes: 3624
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] f=br.readLine().split(" ");
        int n=Integer.parseInt(f[0]);
        int m=Integer.parseInt(f[1]);
        int l=Integer.parseInt(f[2]);
        int[] A=new int[n*m];
        int[] B=new int[m*l];
        int h=0;
        for(int i=0;i<n;i++){
        	String[] s=br.readLine().split(" ");
        	for(int j=0;j<m;j++){
        		A[h]=Integer.parseInt(s[j]);
        		h++;
        	}
        }
        for(int j=0;j<m;j++){
        	int bc=j;
        	String[] t=br.readLine().split(" ");
        	for(int k=0;k<l;k++){
        		B[bc]=Integer.parseInt(t[k]);
        		bc+=m;
        	}
        }
    	int ac=0,bc=0,al=0,c=0;
    	long v=0;
    	StringBuilder sb=new StringBuilder();
        while(c<n){
        	v+=A[ac]*B[bc];
        	if(ac<(c*m+(m-1))){
        		ac++;
        	}else{
        		sb.append(v);
        		v=0;
        		if(al<l-1){
        			sb.append(" ");
        			ac-=m-1;
        			al++;
        		}else{
        			sb.append("\n");
        			ac++;
        			al=0;
        			c++;
        		}
        	}
        	if(bc<m*l-1){
        		bc++;
        	}else{
        		bc=0;
        	}
        }
        System.out.print(sb);
	}
}

Measured memory_bytes: 26888
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

g = a[0]
for i in range(n-1):
    g = gcd(g, a[i+1])

print(g)

Measured memory_bytes: 14224
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ll n,ans=0;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  rep(i,n){
    ans+=(lower_bound(ALL(a),b[i])-a.begin())*(c.end()-upper_bound(ALL(c),b[i]));
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << ": " << x << '\n';

int main() {
  cout << fixed << setprecision(15);

  ios::sync_with_stdio(false);
  cin.tie(0);
  double n;
  int ans;
  cin >> n;
  ans = n;
  if (ans % 2 == 0) {
    cout << 0.5000000000 << '\n';
  } else {
    cout << 1 - ((n-1)/2)/n << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const long long INF = 1LL<<60;
using pint = pair<int,int>;
typedef long long ll;
const int dx[4] = {1, 0, -1, 0}; // D, R, U, L
const int dy[4] = {0, 1, 0, -1};
const int dx1[5] = {-2,-1,0,1,2};
const int dy1[5] = {-2,-1,0,1,2};
#define rep(i,n) for(int i=0;i<(int)(n);i++)
bool chmin(long long &a, long long b) {if (a > b) {a = b; return true;} return false;}
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long ch,cw;
    cin>>ch>>cw;
    ch--;
    cw--;
    long long dh,dw;
    cin>>dh>>dw;
    dh--;
    dw--;
    vector<string> meiz(H);
    for(int i=0;i<H;i++){
        cin>>meiz[i];
    }
    long long  seen[H][W];
    rep(i,H)rep(j,W)seen[i][j]=INF;
    seen[ch][cw]=0;
    priority_queue<pair<ll,pint>,vector<pair<ll,pint>>,greater<pair<ll,pint>>> que;
    que.push({0,pint(cw,ch)});
    while(! que.empty()){
        auto cur = que.top();que.pop();
        ll dis = cur.first;
        int x = cur.second.first;
        int y = cur.second.second;
        if(dis>seen[y][x]) continue;
        rep(i,5){
            rep(j,5){
                //if(i==2&&j==2) continue;
                int nx = x+dx1[i];
                int ny = y+dx1[j];
                if(nx<0 || nx>=W || ny<0 || ny>=H||meiz[ny][nx]=='#') continue;
                ll ndis = 1;
                if(i==1&&j==2 ||i==2&&j==1||i==2&&j==3||i==3&&j==2){
                    ndis=0;
                }
                if(chmin(seen[ny][nx],dis+ndis)){
                    que.push({ndis+dis,pint(nx,ny)});
                }
            }
        }
    }
    if(seen[dh][dw]==INF)seen[dh][dw]=-1;
    cout<<seen[dh][dw]<<endl;
}


Measured memory_bytes: 13452
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B;
    cin >> A >> B;
    if(A <= 5){
        cout << 0 << endl;
    }else if(A <= 12){
        cout << B / 2 << endl;
    }else{
        cout << B << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	while(1){
		int n; cin >> n;
		if(!n) break;
		vector<int> a(n);
		int sum = 0;
		rep(i,n) cin >> a[i], sum += a[i];
		int ans = 0;
		rep(i,n){
			if(a[i] * n <= sum) ans++;
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3128
#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 = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){

    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;

  return 0;
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	vector<long long int> v;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	long long int res = 0;
	for (int i = 0; i < n; i++) {
		if (i >= k)
			res += v[i];
	}
	cout << res << endl;
}









Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,cap;
	string s;
	cin>>n;
	cin>>s;
	for(i=0;i<s.size();i++){
		cap=s[i]+n;
		if(cap<=90){
			s[i]=cap;
		}
		else if(cap>90){
			s[i]=cap-26;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
N = int( input() )
h = [int(x) for x in input().split()]

dp    = [0]*( len(h) )
dp[0] = 0
dp[1] = abs( h[0] - h[1] )
for ii in range( 2, len(dp) ):
    from_1 = abs(h[ii] - h[ii-1])
    from_2 = abs(h[ii] - h[ii-2])
    dp[ii] = min( dp[ii-1] + from_1, dp[ii-2] + from_2 )
    
print(dp[-1])

Measured memory_bytes: 20380
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    ll a , b ; cin >> a >> b ;
    if(a < 10 and b < 10) cout << a * b << "\n" ;
    else cout << "-1\n" ;
    return 0 ;
}


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

using namespace std;

struct job {
    int t;
    int limit;
};


int main()
{
    int N;

    vector<int> A;
    vector<int> B;
    vector<job> J;

    cin >> N;

    int ia, ib;
    for ( int i = 0; i < N; i ++ ) {
        cin >> ia >> ib;
        job j;
        j.t = ia;
        j.limit = ib;    
        J.push_back( j );
    }

#ifdef TEST
    for ( int i = 0; i < J.size(); i ++ ) {
        cout << J[i].t << " " << J[i].limit << endl;
    }
#endif

    sort( J.begin(), J.end(), 
        [](const job& lhs, const job& rhs) { return lhs.limit < rhs.limit;} );

#ifdef TEST
    for ( int i = 0; i < J.size(); i ++ ) {
        cout << J[i].t << " " << J[i].limit << endl;
    }
#endif

    int T;

    T = 0;
    for ( int i = 0; i < N; i ++ ) {
        T += J[i].t;
#ifdef TEST
        cout << "T " << T << " " << J[i].t << " " << J[i].limit << endl;
#endif
        if ( T > J[i].limit ) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int a_max = 1000000;
    vector<bool> is_prime(a_max + 1, true);
    for (int i = 2; i <= a_max; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= a_max; j += i) {
                is_prime[j] = false;
            }
        }
    }

    vector<int> prime(0);
    for (int i = 2; i <= a_max; i++) {
        if (is_prime[i]) {
            prime.push_back(i);
        }
    }

    int prime_size = prime.size();

    int mod = 1000000007;

    vector<long long> inv(a_max + 1, 0);
    inv[1] = 1;
    for (int i = 2; i <= a_max; i++) {
        inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
    }

    int n;
    cin >> n;

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

    map<int, long long> lcm;
    for (int i = 0; i < n; i++) {
        map<int, long long> a_prime;
        for (int j = 0, k = a[i]; j < prime_size && k > 1; j++) {
            while (k % prime[j] == 0) {
                k /= prime[j];
                a_prime[prime[j]]++;
            }

            if (prime[j] * prime[j] > k) {
                a_prime[k]++;
                break;
            }
        }

        for (map<int, long long>::iterator j = a_prime.begin(); j != a_prime.end(); j++) {
            lcm[j->first] = max(lcm[j->first], j->second);
        }
    }

    long long lcm_mod = 1;
    for (map<int, long long>::iterator i = lcm.begin(); i != lcm.end(); i++) {
        for (int j = 0; j < i->second; j++) {
            lcm_mod *= i->first;
            lcm_mod %= mod;
        }
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        long long r = lcm_mod;
        r *= inv[a[i]];
        r %= mod;
        res += r;
        res %= mod;
    }

    cout << res << endl;
}


Measured memory_bytes: 9208
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(n,x) for(ll i=0;i<n;i++) cin>>x[i];
#define forr(a,b) for(ll i=a;i<b;i++);
ll gcd(ll x, ll y)
{
	if (x % y == 0) return y;
	else return gcd(y, x % y);
}
// 1or素数だと１を返す
ll prime(ll x)
{
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0) return 0;
	}
	return 1;
}



int main()
{
	ll n, m;
	cin >> n >> m;
	
	priority_queue<ll> a;
	ll p;
	for(ll i=0;i<n;i++)
	{
		cin >> p;
		a.push(p);
	}
  
	ll q;
	for(ll i=0;i<m;i++)
	{
		q = a.top();
		a.pop();
		q /= 2;
		a.push(q);
	}
	ll ans = 0;
	for(ll i=0;i<n;i++)
	{
		ans += a.top();
		a.pop();
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 4312
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        Console.WriteLine("{0} {1} {2:f5}", n[0]/n[1] , n[0] % n[1] , (double)n[0] / n[1]);
    }
}


Measured memory_bytes: 18464
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
#include<set>
#include<iterator>
#define mx 1e6
typedef long long ll;
using namespace std;


int main()
{
    int k,a,b,c;
    cin>>k;
    cin>>a>>b;
    for(c=a;c<=b;c++){
        if(c%k==0){
         cout<<"OK"<<endl;
        return 0;
        }
    }
    cout<<"NG"<<endl;
 return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#define N 100

int main()
{
  int a[N],n,i,j,flag,b;
  int cnt=0;

  scanf("%d",&n);
  for(i=0 ; i<n ;i++)
    {
      scanf("%d",&a[i]);
    }

  flag = 1;
  while(flag == 1)
    {
      flag = 0;
      for(j = n-1 ; j>0 ; j--)
	{
	  if(a[j] < a[j-1])
	    {
	      b=a[j];
	      a[j] = a[j-1];
	      a[j-1] = b;
	      
	      flag = 1;
	      cnt++;
	    }
	}
    }

  for(i=0 ; i<n-1 ; i++)
    {
      printf("%d ",a[i]);
    }
  printf("%d\n%d\n",a[n-1],cnt);
  
  return 0;
}



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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int a, b, c,d;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}



Measured memory_bytes: 764
using System.IO;
using System;

class a158
{

    
    static void Main()
    {
        long ans = 0;
        int n = Convert.ToInt32(Console.ReadLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = i + 1;
        }
        
        for (int i = 0; i < n; i++){
            if (a[i] % 3 != 0 && a[i] % 5 != 0){
                ans += a[i];
            }
        }
        Console.WriteLine(ans);
        
    }
}

Measured memory_bytes: 31416
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    int n = s.size(); 
    for(int i = 0; i < n; i++){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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 T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
map<string, lint> cnt;
string s;
int main() {
	cin >> N;
	cnt["AC"] = 0;
	cnt["WA"] = 0;
	cnt["TLE"] = 0;
	cnt["RE"] = 0;
	REP(i, N) {
		cin >> s;
		cnt[s]++;
	}
	cout << "AC x " << cnt["AC"] << endl;
	cout << "WA x " << cnt["WA"] << endl;
	cout << "TLE x " << cnt["TLE"] << endl;
	cout << "RE x " << cnt["RE"] << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;

    ll N = S.size();
    ll res = 0;
    REP(i, N/2){
    	if(S[i] != S[N-1-i]) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
minuslist = []
ssum = 0
for i in range(N):
    s = int(input())
    ssum += s
    if s % 10 != 0:
        minuslist.append(s)
if len(minuslist) == 0:
    print(0)
elif ssum % 10 != 0:
    print(ssum)
else:
    print(ssum - sorted(minuslist)[0])


Measured memory_bytes: 3060
import math
import numpy as np

a, b, h, m = (int(x) for x in input().split())

hRad = math.radians(30 * h + 0.5 * m)
mRad = math.radians(6 * m)

xH = a * math.cos(hRad)
yH = a * math.sin(hRad)
xM = b * math.cos(mRad)
yM = b * math.sin(mRad)

hH = np.array([xH, yH])
mM = np.array([xM, yM])

print(np.linalg.norm(hH-mM))


Measured memory_bytes: 27272
n=int(input())
s=["".join(sorted(list(input()))) for i in range(n)]
s.sort()
dp=[1]
for i in range(n-1):
  if s[i]==s[i+1]:
    dp[len(dp)-1]+=1
  else:
    dp.append(1)
ans=0
for i in dp:
  ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 11244
#include <cstdio>
int main() {
    int w, h, x, y;
    scanf("%d%d%d%d", &w, &h, &x, &y);
    double area = 0.5 * w * h;
    if ((w & 1) || (h & 1)) {
        printf("%.6f 0\n", area);
    } else if (x == w / 2 && y == h / 2) {
        printf("%.6f 1\n", area);
    } else {
        printf("%.6f 0\n", area);
    }
    return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll n; cin >> n;
  
  string ans = "";
  while(n){
    n--;
    char tmp = 'a';
    tmp += (n%26);
    n /= 26;
    ans = tmp+ans;
  }
  cout << ans << endl;
    
  return 0;
}


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

int main() {
	int N, sum = 0, tmp;
	vector<int> V, C;

	scanf("%d", &N);
	for(int i = 0; i < N; i++) {
		scanf("%d", &tmp);
		V.push_back(tmp);
	}
	for(int i = 0; i < N; i++) {
		scanf("%d", &tmp);
		C.push_back(tmp);
	}
	for(int i = 0; i < N; i++)
		sum += V[i] > C[i] ? V[i] - C[i] : 0;
	printf("%d", sum);
}



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

using namespace std;

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

	int a, b, c;

	cin >> a >> b >> c;

	for (int i = 0; i < 1000; i++) {
		if ((a * (i + 1)) % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String plane = "",str="";
        int row = 0;
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext()){
            str = scan.next();
            plane += str;
            if(row++ > 6){
                row = 0;
                if(plane.matches(".*1111.*"))System.out.println("C");
                else if(plane.matches(".*110000011.*"))System.out.println("G");
                else if(plane.matches(".*1100000011.*"))System.out.println("A");
                else if(plane.matches(".*11000000011.*"))System.out.println("E");
                else if(plane.matches(".*1000000110000001.*"))System.out.println("D");
                else if(plane.matches(".*100000001100000001.*"))System.out.println("F");
                else if(plane.matches(".*1000000010000000100000001.*"))System.out.println("B");
                plane = "";
            }
        }
    }
}



Measured memory_bytes: 28568
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {
	
	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<pair<ll, ll>> a(A + B + C + 1);

	repn(i, A + B + C) {
		ll x;
		cin >> x;
		a[i].first = x;
		if (i <= A) { a[i].second = 1; }
		else if (i <= A + B) { a[i].second = 2; }
		else { a[i].second = 3; }
	}

	sort(++a.begin(), a.end(),greater<pair<ll,ll>>());

	ll ans = 0;

	ll count = 0;
	ll c[4] = {};
	repn(i,A+B+C) {
		if (a[i].second == 1 && c[1] == X) { continue; }
		if (a[i].second == 2 && c[2] == Y) { continue; }
		if (a[i].second == 3 && c[3] == C) { continue; }

		ans += a[i].first;
		c[a[i].second]++;
		count++;

		//cout << a[i].first << a[i].second << c[i]<<endl;

		if (count == X + Y) { break; }
	}

	cout << ans;
	system("PAUSE");
}


Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll N=200005,M=8005,H=4005;
ll Z=2001;
const ll mod=1e9+7;
const ll inv2=5e8+4;
ll n;
ll a[N+5],b[N+5];
ll d[H+5][H+5];
ll fact[M+5],inv[M+5];
void Init(){
    fact[0]=1;
    for(ll i=1;i<M;i++)
        fact[i]=(1ll*fact[i-1]*i)%mod;
    inv[1]=1;
    for(ll i=2;i<M;i++)
        inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    inv[0]=1;
    for(ll i=1;i<M;i++)
        inv[i]=1ll*inv[i]*inv[i-1]%mod;
}
ll C(ll x,ll y){
    return 1ll*fact[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    //freopen("bbq4.in","r",stdin);
    Init();
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        d[Z-a[i]][Z-b[i]]++;
    }
    for(ll i=1;i<H;i++)
        for(ll j=1;j<H;j++)
            d[i][j]=((d[i][j]+d[i][j-1])%mod+d[i-1][j])%mod;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=d[Z+a[i]][Z+b[i]];
        ans%=mod;
        //printf("%lld %lld %lld\n",a[i],b[i],i);
        ans-=C(a[i]*2+b[i]*2,a[i]*2);
        ans=(ans%mod+mod)%mod;
    }
    ans=1ll*ans*inv2%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 129024