akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	public static int[] stack = new int[1000];
	public static int top = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		String str = sc.nextLine();
		String[] S = str.split(" ");

		for (int i = 0; i < S.length; i++ ) {
			if (S[i].equals("+")) {
				b = pop();
				a = pop();
				push(a + b);
			} else if (S[i].equals("*")) {
				b = pop();
				a = pop();
				push(a * b);
			} else if (S[i].equals("-")) {
				b = pop();
				a = pop();
				push(a - b);
			} else {
				push(Integer.parseInt(S[i]));
			}
		}
		System.out.println(pop());
	}

	public static void push(int x) {
		stack[++top] = x;
		
	}

	public static int pop() {
		top--;
		return stack[top + 1];
	}
}


Measured memory_bytes: 26120
n = gets.chomp.to_i

sums = {}
n.times{|i|
  s = gets.chomp
  sums[s] = 0 if sums[s].nil?
  sums[s] += 1
}

sorted = sums.sort{|a, b| b[1] <=> a[1] }

max = sorted[0][1]

filtered = sorted.take_while{|i|
  i[1] == max
}

filtered.sort{|a, b| a[0] <=> b[0] }.each{|i|
  puts i[0]
}


Measured memory_bytes: 41832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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 np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.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; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n;
  cin >> n;
  
  ll sum = 0;
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];
  sum+=p[i];
  }
  
  ll ans=8000000000000000000;
  ll now=0;
  rep(i,n){
  now+=p[i];
    ans=min(ans,abs(sum-2*now));
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(1){
		cin >> a >> b;
		if(a+b == 0)break;
		if(a>b){
			swap(a,b);
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main()
{
    int N; cin >> N;
    int X = ceil(N * 100.0 / 108);
    int n = floor(X * 108.0 / 100);
    if (n == N) {
        cout << X << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}


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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sz = (1 << n);
    vector<int> a(sz);
    for (int i = 0; i < sz; i++) cin >> a[i];
    a.push_back(0);
    vector<P> dp(sz, P(sz, sz));
    for (int i = 0; i < sz; i++) {
        dp[i].first = i;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < sz; j++) {
            if (j & (1 << i)) {
                int k = (j ^ (1 << i));
                vector<int> v = {dp[j].first, dp[j].second, dp[k].first, dp[k].second};
                sort(v.begin(), v.end(), [&](int i1, int i2){
                    return a[i1] > a[i2];
                });
                dp[j].first = v[0];
                dp[j].second = v[1];
            }
        }
    }

    int ans = a[dp[0].first] + a[dp[0].second];
    for (int i = 1; i < sz; i++) {
        ans = max(ans, a[dp[i].first] + a[dp[i].second]);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<vector<int>> g(N);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        g[a - 1].emplace_back(b - 1);
        g[b - 1].emplace_back(a - 1);
    }
    vector<ll> ans(N, -1), c(N);
    for (auto &&i : c) {
        cin >> i;
    }

    RSORT(c);
    ll sum = accumulate(ALL(c), 0);
    int start;
    sum -= c[0];
    queue<int> que;
    REP(i, N) {
        if (g[i].size() == 1) {
            que.push(i);
            break;
        }
    }
    vector<bool> vis(N, false);
    int now = 0;
    while (!que.empty()) {
        int nxt = que.front();
        que.pop();
        if (!vis[nxt]) {
            ans[nxt] = c[now++];
            vis[nxt] = true;
            REP(i, g[nxt].size()) { que.push(g[nxt][i]); }
        }
    }

    print(sum);
    print(ans);

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int main(){
  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("[^0-9.-]+");

		int N = scan.nextInt();

		for (int i = 0; i < N; i++) {
			Point p1 = Point.input(scan);
			Point p2 = Point.input(scan);
			Point p3 = Point.input(scan);

			double A = p2.d2(p3);
			double B = p3.d2(p1);
			double C = p1.d2(p2);

			Point cc = p1.mul(A * (B + C - A)).add(p2.mul(B * (C + A - B))).add(p3.mul(C * (A + B - C)))
					.mul(1 / (A * (B + C - A) + B * (C + A - B) + C * (A + B - C)));

			System.out.println(cc.toString() + " " + String.format("%.3f", Math.sqrt(cc.d2(p1))));
		}

	}

	static class Point {
		final double x;
		final double y;

		public Point(double x, double y) {
			this.x = x;
			this.y = y;
		}

		public Point mul(double d) {
			return new Point(d * x, d * y);
		}

		public Point add(Point p) {
			return new Point(x + p.x, y + p.y);
		}

		public double d2(Point p) {
			return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y);
		}

		public String toString() {
			return String.format("%.3f %.3f", x, y);
		}

		public static Point input(Scanner scan) {
			return new Point(scan.nextDouble(), scan.nextDouble());
		}
	}
}

Measured memory_bytes: 28576
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N, W; cin >> N >> W;
  vector<ll> v(N);
  vector<ll> w(N);
  rep(i,N) cin >> v[i] >> w[i];

  vector<vector <ll> > dp(2, vector<ll> (W + 1) );
  rep(i,2) rep(j,W + 1) dp[i][j] = -INF;
  dp[0][0] = 0;
  rep(i,N){
    rep(j, W + 1){
      if(j < w[i]) dp[1][j] = dp[0][j];
      else{
        dp[1][j] = max(dp[0][j] , dp[1][j - w[i]] + v[i]);
      }
    }
    rep(j, W + 1) dp[0][j] = dp[1][j];
  }
  ll ans = 0;
  rep(i, W + 1) ans = max(ans , dp[0][i]);
  cout << ans << endl;
}



Measured memory_bytes: 3300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll x2 = 0;
  rep(i, n) {
    if(i%2) x2 -= a[i];
    else x2 += a[i];
  }
  vector<int> ans(n);
  ans[0] = x2/2;
  rep(i, n-1) {
    ans[i+1] = a[i] - ans[i];
  }
  rep(i, n) ans[i] *= 2;
  rep(i, n) {
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2048
using System;

class Program
{
    static void Main(string[] args)
    {
        //変数定義
        string[] input;
        double t;
        double x;
        double a;

        //Inputします
        input = Console.ReadLine().Split(' ');
        t = double.Parse(input[0]);
        x = double.Parse(input[1]);
        //処理
        a = t / x;


        //Outputします
        Console.WriteLine(a);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int x, y;
	cin >> x >> y;
	int ans = INF;
	if(y >= x) chmin(ans, y-x);
	if(y >= -x) chmin(ans, 1+y+x);
	if(-y>=x) chmin(ans, 1-y-x);
	if(-y>=-x) chmin(ans, 2-y+x);
	cout << ans << endl;

}

Measured memory_bytes: 256
def solve():
    N = int(input())
    a = [int(input()) for i in range(1, N + 1)]
    # ループしたら終わる
    l = []
    s = a[0]
    l = [0] * N
    c = 1
    l[0]=True
    while(True):
        l[s - 1] = True
        if s == 2:
            print(c)
            return True
        s = a[s - 1]
        if l[s - 1] == True:
            print(-1)
            return False
        c += 1
solve()




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

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<long>H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    long first=H[0],ans=0,count=0;
    for(int i=0;i<N-1;i++){
        if(H[i+1]>H[i]){
            ans=max(ans,i-count);
            count=i+1;
            first=H[i];
        }
        if(i==N-2&&H[i]>=H[i+1]){
            ans=max(ans,i+1-count);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
constexpr int MX = 405;
vector<ll> a(MX);
vector<vector<ll>> dp(MX, vector<ll>(MX, LINF));

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    rep(i,n) cin >> a[i];

    rep(i,n) dp[i][i] = 0;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<n-i;j++) {
            ll sm = 0;
            ll res = LINF;
            for(int k=j;k<j+i;k++) {
                sm += a[k];
                chmin(res, dp[j][k]+dp[k+1][j+i]);
            }
            sm += a[j+i];
            dp[j][j+i] = res+sm;
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 4900
red, green, blue, n = gets.chomp.split(" ").map(&:to_i)
ans = 0

(n+1).times do |r|
    (n+1).times do |g|
        v = r*red + g*green
        ans += 1 if n >= v && (n-v) % blue == 0
    end
end

puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  rep(i, h){
    bool fi = false;
    if(i >= b) fi = true;
    rep(j, w){
      bool fj = false;
      if(j >= a) fj = true;
      bool o = fj ^ fi;
      cout << o;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main() {
	int Cube_x, Cube_y, Cyc_x, Cyc_y, Cyc_r;
	scanf("%d %d", &Cube_x, &Cube_y);
	scanf("%d %d %d", &Cyc_x, &Cyc_y, &Cyc_r);

	int flag = 0;
	if (Cyc_x >= Cyc_r && Cyc_x <= Cube_x - Cyc_r) {
		if (Cyc_y >= Cyc_r&&Cyc_y <= Cube_y - Cyc_r) {
			flag = 1;
		}
	}

	if (flag == 1)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 2688
using System;
using System.Linq;
using System.Collections.Generic;
public class c
{
  public static void Main()
  {
    int[] ABC=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(ABC);
    Console.WriteLine(ABC[0]+ABC[1]+10*ABC[2]);
  }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s,t; cin >> s >> t;
    int a,b;    cin >> a >> b;
    string u;   cin >> u;
    if(u == s){
        printf("%d %d\n", a-1, b);
    }else{
        printf("%d %d\n", a, b-1);
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Shopping
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int N, m;
		N = parseInt(line.substring(0, line.indexOf(' ')));
		m = parseInt(line.substring(line.indexOf(' ') + 1));

		if (m == 0) {
			System.out.println(N + 1);
			return;
		}

		int[] shops = new int[N + 1];

		for (int i = 0; i < m; i++) {
			line = br.readLine();
			int c, d;
			c = parseInt(line.substring(0, line.indexOf(' ')));
			d = parseInt(line.substring(line.indexOf(' ') + 1));
			shops[c]++;
			shops[d]--;
		}

		int zero = 0;

		for (int i = 1; i < shops.length; i++) {
			shops[i] += shops[i - 1];
			if (shops[i] == 0) zero++;
		}

		System.out.println(zero + 1 + (N + 1 - (zero + 1)) * 3);

	}
}

Measured memory_bytes: 24960
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
     int n;
     scanf("%d",&n);
     int a[n],i,sum=0;
  for(i=0;i<n;++i)
  { scanf("%ld",&a[i]);
     sum+=a[i];
  }
  
  
  sort(a,a+n);
   if((sum-a[n-1])>a[n-1])
       printf("Yes");
  
   else
      printf("No");
    
}

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

int main(){
   int n, m;
   cin >> n >> m;
   vector<vector<int>> s(10, vector<int>(10));
   rep(i,m){
       int k;
       cin >> k;
       rep(j,k) {
           int a;
           cin >> a;
           a--;
           s[i][a] = 1;
       }
   }
   vector<int> p(m);
   rep(i,m) cin >> p[i];
   int ans = 0;
   for(int bit = 0; bit < (1<<n); bit++){
       vector<int> S;
       rep(i,n){
           if(bit & (1<<i)){
               S.push_back(i);
           } 
       }
       bool judge = 1;
       rep(i,m){
           int light = 0;
           rep(j,S.size()){
               light ^= s[i][S[j]];
           }
           if(light != p[i]) judge = 0; 
       }
       if(judge) ans++;
   }
   cout << ans << endl;
}

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

int main(){
    int x; cin >> x;
    int c500 = x / 500;
    int c5 = ( x % 500 )/ 5;
    cout << c500*1000 + c5*5 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
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 extended_gcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    ll xx, yy;
    ll res = extended_gcd(b, a%b, xx, yy); x = yy; y = xx - yy * (a / b);
    return res;
}

const ll sz = 1e4 + 5;
vector<ll> fac(sz, 1);

// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }

// * ALways PASS arrays, strings etc to functions BY REFERENCE

// const ll sz = 1e6 + 6;
// vector<bool> p(sz, true);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    // p[0] = p[1] = false;
    // for (ll i = 2; i*i <= sz; i++) if (p[i]) {
    //     for (ll j = i*i; j <= sz; j += i)
    //         p[j] = false;
    // }
    
    int t = 1;
    // cin >> t;

    while(t--) {
        ll n;
        cin >> n;
        
        vector<ll> plus(n), minus(n);
        for (int i = 0; i < n; i++) {
            ll x, y;
            cin >> x >> y;
            plus[i] = x + y;
            minus[i] = x - y;
        }
        
        sort(plus.begin(), plus.end());
        sort(minus.begin(), minus.end());
        
        ll res = plus[n-1] - plus[0];
        res = max(res, minus[n-1] - minus[0]);
        
        cout << res << endl;
    }
    
	return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    char c;cin>>c;
    int a=c+'1';
    c=a-'0';
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1005;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int s,w;
	cin>>s>>w;
	if(s<=w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}

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

int main(){
	ll n,k; cin >> n >> k;
	vector<double> p(n); rep(i,n)cin >> p[i];
	vector<double> ex(n); rep(i,n)ex[i] = (p[i] + 1)/2;
	double ans = 0;
	rep(i,k)ans += ex[i];
	double r = ans;
	rep(i,n-k){
		r = r + ex[i+k] - ex[i];
		ans = max(r,ans);
	}
	cout << fixed << setprecision(7);
	cout << ans << endl;

}

Measured memory_bytes: 3328
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let n = scan!(sc; i32);
  let mut d = scan!(sc => n; i32);
  d.sort();

  let mut k = 0;
  let mut abc = 0;
  let mut idx = 0;
  let mut ans = 0;
  let &k_max = d.iter().last().unwrap();
  loop {
    if k > k_max { break; }
    while idx != d.len() {
      if d[idx] < k {
        abc += 1;
        idx += 1;
      }
      else {
        break;
      }
    }

    if n / 2 == abc { ans += 1; }
    k += 1;
  }
  println!("{}", ans);
}


Measured memory_bytes: 4352
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc173_a.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << (1000 - n % 1000) % 1000 << endl;
}


Measured memory_bytes: 3652
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static long[] MOVE = { 1L << 32, 1, -(1L << 32), -1 };
	static int[] X, Y, head;
	static HashMap<Long, Integer> map;

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			X = new int[2 * N];
			Y = new int[2 * N];
			head = new int[2 * N];
			map = new HashMap<Long, Integer>();
			for (int i = 0; i < N; ++i) {
				X[2 * i] = Integer.parseInt(sc.next()) + 1;
				Y[2 * i] = Integer.parseInt(sc.next()) + 1;
				if (sc.next().equals("x")) {
					X[2 * i + 1] = X[2 * i] + 1;
					Y[2 * i + 1] = Y[2 * i];
				} else {
					X[2 * i + 1] = X[2 * i];
					Y[2 * i + 1] = Y[2 * i] + 1;
				}
				map.put(((long) X[2 * i] << 32) + Y[2 * i], 2 * i);
				map.put(((long) X[2 * i + 1] << 32) + Y[2 * i + 1], 2 * i + 1);
			}
			boolean ok = true;
			for (int i = 0; i < 2 * N; i += 2) {
				if (head[i] != 0) continue;
				if (!check(i, true) && !check(i, false)) {
					ok = false;
					break;
				}
			}
			System.out.println(ok ? "Yes" : "No");
		}
	}

	static boolean check(int pos, boolean isHead) {
		ArrayDeque<Long> q = new ArrayDeque<Long>();
		q.add(pos + ((isHead ? 1L : 0L) << 32));
		while (!q.isEmpty()) {
			long cur = q.poll();
			int cp = (int) (cur & 0xFFFFFFF);
			boolean h = (cur >> 32) != 0;
			if (head[cp] != 0) {
				if ((head[cp] == 1) == h) {
					continue;
				} else {
					revert(pos);
					return false;
				}
			}
			head[cp] = h ? 1 : -1;
			long coord = ((long) X[cp] << 32) + Y[cp];
			for (int i = 0; i < 4; ++i) {
				long nc = coord + MOVE[i];
				if (!map.containsKey(nc)) continue;
				int np = map.get(nc);
				if (cp / 2 == np / 2) {
					q.add(np + ((h ? 0L : 1L) << 32));
				} else {
					q.add(np + ((h ? 1L : 0L) << 32));
				}
			}
		}
		return true;
	}

	static void revert(int pos) {
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(pos);
		while (!q.isEmpty()) {
			int cur = q.poll();
			head[cur] = 0;
			long coord = ((long) X[cur] << 32) + Y[cur];
			for (int i = 0; i < 4; ++i) {
				long nc = coord + MOVE[i];
				if (!map.containsKey(nc)) continue;
				int np = map.get(nc);
				if (head[np] != 0) q.add(np);
			}
		}
	}
}

Measured memory_bytes: 75972
n = int(input())
nums = sorted(list(map(int,input().split())), reverse=True)

res = 1

if 0 in nums:
  print(0)
  exit()
  
for i in range(n):
  res = res * nums[i]
  if res <= 10**18 :
    continue
  else:
    res = -1
    break
print(res)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int best = 0;
    vector<vector<int>> splits;
    splits.push_back(vector<int>());
    for (int i = 0; i < n; ++i) {
        splits[0].push_back(i);
    }
    for (int length = 1; length <= n/2; ++length) {
        vector<vector<int>> new_splits;
        for (auto split : splits) {
            map<char, vector<int>> splitted_split;
            for (int i : split) {
                if (i + length - 1 < n) {
                    splitted_split[s[i + length - 1]].push_back(i);
                }
            }
            for (auto single_split : splitted_split) {
                if (single_split.second.back() - single_split.second.front() >= length) {
                    new_splits.push_back(single_split.second);
                }
            }
        }
        splits = new_splits;
        if (splits.size() > 0) {
            best = length;
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] D = new int[4];
		int[] point = new int[4];
		int ans = 0;
		for( int i=0; i<M; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if( point[a]==0 ){
				D[a] = b;
				point[a] = 1;
			}else{
				if( D[a]!=b ){
					D[a] = -1;
					ans = 1;
				}
			}
		}
		if( point[1]==0 && N>1 ){
			D[1] = 1;          
        }          
		if( point[1]==1 && N>1 && D[1]==0 ){
			ans = 1;
		}
		if( ans==1 ){
			System.out.println(-1);
		}else{
			if( N==1 ){
				System.out.print(D[1]);
			}
			if( N==2 ){
				System.out.print(D[1]);
				System.out.print(D[2]);
			}
			if( N==3 ){
				System.out.print(D[1]);
				System.out.print(D[2]);
				System.out.print(D[3]);
			}
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool can = true;
    if(n%2==1){
        can = false;
    }else{
        rep(i,n/2){
            if(s[i]!=s[i+n/2]) {
                can = false;
                break;
            }
        }
    }
    if (can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N -1

struct tree {int m, l, r;};
struct tree T[10000];
int n;

void preorder(int b){

    if(b == N) return;
    printf(" %d", b); 
    preorder(T[b].l);
    preorder(T[b].r);
}
void inorder(int b){

    if(b == N) return;
    inorder(T[b].l);
    printf(" %d", b); 
    inorder(T[b].r);
}
void postorder(int b){

    if(b == N) return;
    postorder(T[b].l);
    postorder(T[b].r);
    printf(" %d", b); 
}
int main()
{
    int i,  j, l, r, b;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        T[i].m = N;
    }

    for(i = 0; i < n; i++){
        scanf("%d %d %d", &j, &l, &r );
        T[j].l = l;
        T[j].r = r;
        if(l != N) T[l].m = j;
        if(r != N) T[r].m = j;
    }

    for(i = 0; i < n; i++) if(T[i].m == N) b = i;
    printf("Preorder\n");
    preorder(b);
    printf("\n");
    printf("Inorder\n");
    inorder(b);
    printf("\n");
    printf("Postorder\n");
    postorder(b);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N,X; cin>>N>>X;
  int L[N]; rep(i,N) cin>>L[i];
  int ans=1;
  ll D=0;
  rep(i,N){
    D+=L[i];
    if(D<=X) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[1005];
    int str;
    
    char s2[]="es";
    int i;
    scanf("%s",s);
    str=strlen(s);
    if(s[str-1]==115){
        strcat(s,s2);
        printf("%s",s);
        
    }
    else if(s[str-1]!=115){
        s[str]=115;
        for(i=0;i<str+1;i++){
            printf("%c",s[i]); 
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 1708
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] A;
	int[] c;
	
	void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];
		c = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
			c[A[i]]++;
		}
		
		long s = 0;
		for (int i = 0; i < N; i++) {
			s += (long)c[i]*(c[i]-1)/2;
		}
		
		for (int k = 0; k < N; k++)
			System.out.println( s - c[A[k]] + 1 );
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

int main(){
  int a,b;cin>>a>>b;
  if(a<=5)
    cout<<0<<endl;
  else if(a>=6&&a<=12)
    cout<<b/2<<endl;
  else
    cout<<b<<endl;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
n = max(int(b / a), 1)
p = 'NO'
s = set()
r = n * a % b

while r not in s:
    if r == c:
        p = 'YES'
        break
    else:
        s.add(r)
        n += 1
        r = n * a % b
print(p)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H, W;
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");

		}
		sc.close();
	}
}



Measured memory_bytes: 34744
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define out(a) debg(a);
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
// template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long x;
    scanf("%lld",&x);
    if(x==1){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(n  * (n - 1) // 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38328
#include <cstdio>

#define gc getchar
#define pc putchar
#define sp pc(' ')
#define ln pc('\n')

template <class t>
inline void read(t &num) {
    register char c = gc();
    register bool flag = 0;
    num = 0;
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') flag = 1, c = gc();
    while (c >= '0' && c <= '9') num = (num << 1) + (num << 3) + c -'0', c = gc();
    flag && (num = ~(num - 1));
}
template <class t>
inline void print(t num) {
    if (num < 0) pc('-'), num = ~(num - 1);
    if (num >= 10) print(num / 10);
    pc(num % 10 + '0');
}

#include <string>
#include <iostream>

int main() {
    int a;
    std::string s;
    read(a);
    std::cin >> s;
    if (a < 3200) puts("red");
    else std::cout << s, ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int S,W;
  cin >> S >> W;
  if (S>W) cout << "safe" << endl;
  else cout << "unsafe" << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
 
using namespace std;

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

    int N, K;

    cin >> N >> K;

    for(int i = 0; i < N; i++)
    {
        char s;
        cin >> s;
        if(i == K - 1)
        {
            if(s == 'A')
            {
                s = 'a';
            } else 
            if(s == 'B')
            {
                s = 'b';
            } else {
                s = 'c';
            }
        }

        cout << s;
    }
}

Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
int main()
{
	char s[102];
	scanf("%s", s);
	int count[30];
	int i;
	for (i = 0; i < 30; i++)
		count[i] = 0;
	int n = strlen(s);
	for (i = 0; i < n; i++)
		count[s[i] - 'a']++;
	int ans = 100005;
	char t[102], c;
	int m, countt[30], x, y;
	for (c = 'a'; c <= 'z'; c++)
	{
		if (count[c - 'a'] > 0)
		{
			strcpy(t, s);
			m = n;
			x = 0;
			y = 0;
			for (i = 0; i < 30; i++)
				countt[i] = 0;
			for (i = 0; i < m; i++)
				countt[t[i] - 'a']++;
			for (i = 0; i < 30; i++)
				if (countt[i] > 0)
					y++;
			while (y > 1)
			{
				for (i = 0; i < m - 1; i++)
					if (t[i + 1] == c)
						t[i] = c;
				m--;
				y = 0;
				for (i = 0; i < 30; i++)
					countt[i] = 0;
				for (i = 0; i < m; i++)
					countt[t[i] - 'a']++;
				for (i = 0; i < 30; i++)
					if (countt[i] > 0)
						y++;
				x++;
			}
			if (ans > x)
				ans = x;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int t[N+1] = {0};
  int x[N+1] = {0};
  int y[N+1] = {0};
  
  for (int i = 1; i < N+1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  
  int dt;
  int dist;
  string ans = "Yes";
  for (int i = 0; i < N; i++) {
    dt = t[i+1] - t[i];
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if ((dist + dt) % 2 == 0 && dist <= dt) {
      continue;
    } else {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1408
N,A,B = map(int, input().split())
hs = [int(input()) for _ in range(N)]

def f(x):
    """
    xが少ないとfalse
    xが大きいとtrue
    """
    As = [max(0,h-B*x) for h in hs]
    Bs = [-(-a//(A-B)) for a in As]
    
    return sum(Bs) <= x


def  binarySearch(l,r):
    while r - l > 1:
        mid = (l+r)//2
        if f(mid):
            r = mid
        else:
            l = mid
    return r


r = 10**9+1
print(binarySearch(0,r))

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s;
    cin >> s;
    if(n >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define debug printf("\n-------------\n")
using namespace std;
typedef long long ll;
const int INF1=(~0u>>2);
const ll INF2=(~0ull>>2),P1=10007,P2=998244353,P3=1000000007;
bool f[100010];
int n,m,sum=0,a[100010],cnt=0;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		char c1,c2;
		int p;
		scanf("%d %c%c",&p,&c1,&c2);
		if(c1=='A')
		{
			if(!f[p])
			{
				cnt++;
				sum+=a[p];
			}
			f[p]=true;
		}
		else
			a[p]++;
	}
	printf("%d %d",cnt,sum);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
using namespace std;

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}
int binomialCoeff(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
} 
void solve()
{
	int n,m,total=0;
	cin>>n>>m;
	if(n>1)
		total+=binomialCoeff(n,2);
	if(m>1)
		total+=binomialCoeff(m,2);
	cout<<total;
}
signed main()
{
   
   int t=1; 	
   //cin>>t;
   while(t--)
   {
      solve();
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }


Measured memory_bytes: 256
def factorization(n):
    if n==1:
        return [[1,1]]
    temp=n
    ans=[]
    for i in range(2, int(n**0.5+1.01)):
        if temp % i ==0:
            ct=0
            while temp % i == 0:
                temp //= i
                ct += 1
            ans.append([i, ct])
    if temp != 1:
        ans.append([temp, 1])
    return ans

N=int(input())
L=factorization(N)
if N==1:
    print(0)
    exit()
ans=0
for l in L:
    ct=0
    fac=1
    while fac<=l[1]:
        ct+=1
        fac+=ct+1
    ans+=ct
print(ans)

Measured memory_bytes: 63500
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int L;

int next_sequence(int n)
{
	string N, L_, R_;

	N = to_string(n);

	for (int i = N.size(); i < L; i++)
	{
		N += '0';
	}

	L_ = N;
	R_ = N;

	sort(L_.begin(), L_.end());
	sort(R_.begin(), R_.end(), greater<char>());

	return stoi(R_) - stoi(L_);
}

int main()
{
	vector<int> a; int val;

	while (true)
	{
		cin >> val >> L;

		if (val == 0 && L == 0)
		{
			break;
		}
		else
		{
			a.clear();
		}

		a.push_back(val);

		int ptr = 0;

		while (true)
		{
			ptr++;

			a.push_back(next_sequence(a[ptr - 1]));

			for (int i = 0; i < ptr; i++)
			{
				if (a[ptr] == a[i])
				{
					cout << i << ' ' << a[i] << ' ' << ptr - i << endl;

					goto Exit;
				}
			}
		}

	Exit:;
	}

	return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(X: int, Y: int):
    counter = 1
    while(X <= Y):
        X *= 2
        counter += 1
    print(counter-1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 2e5 + 5;

int a, b;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> a >> b;
        if(a == 1) a += 13;
        if(b == 1) b += 13;
        cout << (a == b ? "Draw\n" : a > b ? "Alice\n" : "Bob\n");
    }
}

int main() {

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

    solve();
    
}

Measured memory_bytes: 3580
def main():
    A,B,C,K=map(int,input().split())
    cal=0

    if K<=A:
        cal=K
        print(cal)
        return

    cal+=A
    K-=A
    if K<=B:
        print(cal)
        return

    K-=B
    print(cal-K)
    return


main()


Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    char c1, c2, c3, c4;
    cin >> c1 >> c2 >> c3 >> c4;
    int a = (c1 - '0') * 10 + (c2 - '0');
    int b = (c3 - '0') * 10 + (c4 - '0');
    bool x = (1 <= a && a <= 12);
    bool y = (1 <= b && b <= 12);
    if (x && y)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (!x && y)
    {
        cout << "YYMM" << endl;
    }
    else if (x && !y)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
        ;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
if len(A)==1:
    print(1 if A[0]%M==0 else 0)
    exit()
else:
    for a in A:
        B.append((B[-1]+a)%M)
c = Counter(B)
ans = 0
for v in c.values():
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 16552
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int a;
	ll b, n;
	cin >> a >> b >> n;
	int ans = 0;
	ll i;
	ll j = 1;
	if(b == 1){
		cout << 0 << endl;
		return 0;
	}
	while(1){
		i = b*j - 1;
		if(i > n){
			i = n;
			ll c = floor(a*i/b)-a*floor(i/b);
			if(c > ans){
				ans = c;
			}
			break;
		}
		ll c = floor(a*i/b)-a*floor(i/b);
		if(c > ans){
			ans = c;
		}
		j++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
public static void main(String args[]){
 int t=0;
Scanner obj=new Scanner(System.in);
t=obj.nextInt();
if(t<1)
System.out.println(0);
int arr[][]=new int[t][3];
for(int i=0;i<t;i++){
for(int j=0;j<3;j++){
      arr[i][j]=obj.nextInt();
}
}
int dp[][]=new int[t][3];
dp[0][0]=Math.max(arr[0][1],arr[0][2]);
dp[0][1]=Math.max(arr[0][0],arr[0][2]);
dp[0][2]=Math.max(arr[0][1],arr[0][0]);
for(int i=1;i<t;i++){
           dp[i][0]=Math.max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
            dp[i][1]=Math.max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
              dp[i][2]=Math.max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
}
System.out.println(Math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
}

}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);

    REP(i, N){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    vector<ll> S(N);
    for(ll i=-1; i<=1; i=i+2){
        for(ll j=-1; j<=1; j=j+2){
            for(ll k=-1; k<=1; k=k+2){
                REP(p, N){
                    S[p] = i*x[p] + j*y[p] + k*z[p];
                }
                sort(S.begin(), S.end(), greater<ll>());
                ll temp = 0;
                REP(p, M){
                    temp += S[p];
                }
                ans = max(ans, temp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256