akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <functional>
#include <stdio.h>
#include <map>
using namespace std;

int main()
{
	int N;
	scanf("%d", &N);

	map<int, int> mp;
	int buf;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &buf);
		mp.insert(make_pair(buf, i));
	}

	auto it = mp.begin();
	int ind = 0;
	while (it != mp.end()) {
		if (abs(it->second - ind) % 2 == 1) {
			sum++;
		}
		it++;
		ind++;
	}

	printf("%d\n", sum/2);
	
	return 0;
}

Measured memory_bytes: 4992
// A Dynamic Programming based 
// C# program to find minimum 
// number operations to 
// convert str1 to str2 
using System;
using System.Collections.Generic;
using System.Linq;

class GFG
{
    
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var ans = s + t[t.Length - 1];

        if (ans == t)
        {
            Console.Write("Yes");
        }
        else
            Console.Write("No");
    }

}

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

#define int long long
#define scan(a,n)  for(int i = 0; i < n;i++)cin >> a[i];
#define print(a,n)  for(int i = 0;i < n;i++)cout <<a[i] <<' ';cout<<endl;
#define endl  '\n'
#define vi  vector<int>
#define inf 1e17
// Tushar Goyal : Chalie Shuru karte hai

int dp[401][401];
int sum[401];
// sum[i][j] denotes the sum from index =i to index = j in vector a;
vi a(401);


void preprocess(int n)
{
	sum[0] = a[0];
	for (int i = 1 ; i < n ; i++)
	{
		sum[i] = a[i] + sum[i - 1];
	}
}

void solve()
{
	int n; cin >> n;
	scan(a, n);
	// print(a, n);

	memset(sum, 0, sizeof sum);
	preprocess(n);

	for (int L = n - 1 ; L >= 0 ; L--)
	{
		for (int R = L ; R < n; R++)
		{
			if (L == R)dp[L][R] = 0;
			else
			{
				dp[L][R] = inf;
				int s = sum[R];
				if (L - 1 >= 0)s -= sum[L - 1];
				for (int i = L ; i < R ; i++)
				{
					dp[L][R] = min(dp[L][R] , s + dp[L][i] + dp[i + 1][R] );
				}
			}
		}
	}

	cout << dp[0][n - 1] << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

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

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

	string s, t;
	cin >> s >> t;
	
	int n = s.length();
	int m = t.length();
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (s[i] > s[j]) {
				swap(s[i], s[j]);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = i + 1; j < m; j++) {
			if (t[i] < t[j]) {
				swap(t[i], t[j]);
			}
		}
	}
	if (s.compare(t) < 0) {
		cout << "Yes";
		return 0;
	}
	else {
		cout << "No";
	}
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int M = max(A, max(B, C));
  int S = A + B + C;
  if (M % 2 == S % 2) cout << (3*M - S) / 2 << endl;
  else cout << (3*(M+1) - S) / 2 << endl;
}

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

#define sf scanf
#define MAX 100005
#define FOR(i, x, y) for(int i = int(x); i < int(y); i++)
#define pb push_back
#define ppb pop_back
#define SQR(x) ((x)*(x))
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define ll long long

#ifdef VAMP
    #define debug(...) _f(#__VA_ARGS__, __VA_ARGS__)
    template<typename Arg> void _f(const char *name, Arg&& arg){
        cout<<name<<" = "<<arg<<endl;
    }
    template<typename Arg, typename... Args> void _f(const char *names, Arg&& arg, Args&&... args){
        const char *comma = strchr(names, ',');
        cout.write(names, comma - names)<<" = "<<arg<<" | ";
        _f(comma + 1, args...);
    }
#else
    #define debug(...)
#endif

vector<int> tp[MAX];

struct info{
    int d, t;
    bool operator<(const info &a)const{
        return d > a.d;
    }
}ar[MAX];
bool used[MAX];

struct cmpLesser{
    bool operator () (const info &a, const info &b)const{
        if(a.d==b.d) return a.t < b.t;
        return a.d < b.d;
    }
};

multiset<info, cmpLesser> S;

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // VAMP
    int n, k;
    sf("%d %d", &n, &k);
    FOR(i, 0, n){
        int t, d; sf("%d %d", &t, &d); t--;
        tp[t].pb(d);
        ar[i] = {d, t};
    }
    sort(ar, ar+n);
    ll sum = 0, unq = 0, mx = 0;
    FOR(i, 0, k){
        auto now = ar[i];
        if(used[now.t]){
            S.insert({now.d, now.t});
        }
        else{
            unq++;
            used[now.t] = 1;
        }
        sum+=now.d;
    }
    mx = sum + SQR(unq);
    FOR(i, k, n){
        auto now = ar[i];
        if(used[now.t] or S.empty()) continue;

        auto s = S.begin();
        sum-=s->d;
        S.erase(s);

        sum+=now.d;
        unq++;
        used[now.t] = 1;
        mx = max(mx, sum + SQR(unq));
    }
    printf("%lld\n", mx);

    return 0;
}


Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int t,a,b,c,d;
	cin>>a>>b;
	if(a+b==15)cout<<"+"<<endl;
	else if(a*b==15)cout<<"*"<<endl;
	else cout<<"x"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
   char s_cat[200]={},s[100], p[100];
   scanf("%s",s);
    scanf("%s",p);
    strcat(s_cat,s);
    strcat(s_cat,s);
     if ((strstr(s_cat, p)) != NULL) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
   return 0;
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

class RMQ{
	int n,seg,init;
	vector<int> dat;
	public:
	RMQ(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < siz) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = init;
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]);
		}
	}
	int get(int a,int b,int k = 0,int l = 0,int r = -1){
		if(r == -1) r = seg;
		if(b <= l || r <= a) return init;
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r));
	}
};

signed main(){
	int n,q,a,x[200001];
	cin >> n >> q >> a >> x[0]; a--;x[0]--;
	for(int i = 0;i < q;i++){
		cin >> x[i + 1];
		x[i + 1]--;
	}
	vector<RMQ> rmq(2,RMQ(n,INF));
	rmq[0].update(a,a);
	rmq[1].update(a,-a);
	int add = 0;
	for(int i = 1;i <= q;i++){
		int mi = min(rmq[0].get(x[i],n) - x[i],rmq[1].get(0,x[i]) + x[i]) + add;
		add += abs(x[i] - x[i - 1]);
		rmq[0].update(x[i - 1],mi - add + x[i - 1]);
		rmq[1].update(x[i - 1],mi - add - x[i - 1]);
	}
	int mi = INF;
	for(int i = 0;i < n;i++) mi = min(mi,min(rmq[0].get(i,i + 1) - i,rmq[1].get(i,i + 1) + i));
	cout << mi + add << endl;
	return 0;
}

Measured memory_bytes: 14080
<?php

$input = explode(" ", trim(fgets(STDIN)));
$n = (int)$input[0];
$m = (int)$input[1];

$args = [];
$count = 0;
while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	$args[(int)$input[0]][$count] = (int)$input[1];
	++$count;
	if ($count >= $m) {
		break;
	}
}

$result = [];
for ($i=1; $i <= $n; $i++) { 
	if (!empty($args[$i])) {
		$p = $args[$i];
		asort($p);
		$city = 1;
		foreach ($p as $idx => $year) {
			$result[$idx] = str_pad((string)$i, 6, "0" ,STR_PAD_LEFT) . str_pad((string)$city, 6, "0" ,STR_PAD_LEFT);
			++$city;
		}
	}
}
for ($k=0; $k < $m; $k++) { 
	echo $result[$k] . "\n";
}


Measured memory_bytes: 55032
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;


int main(){
	double a[10];
	double now,sum;
	while(cin>>now){
	for(int i=0;i<10;i++)a[i]=0.0;
	a[0]=now;
	sum=a[0];
		for(int i=1;i<10;i++){
			if(i%2==1)a[i]=a[i-1]*2;//??¶??°
			else a[i]=a[i-1]/3;
			sum+=a[i];
		}
		printf("%.15lf\n",sum);
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
const double EPS=1e-10;
typedef complex<double> P;
typedef pair<double,P> PP;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
  }
}
double cross(const P& a, const P& b){return imag(conj(a)*b);}
double dot(const P& a, const P& b){return real(conj(a)*b);}
double D(P a, P b) {
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

int ccw(P a, P b, P c) {
  b-=a;c-=a;
  if(cross(b,c)>EPS)return +1;
  if(cross(b,c)<-EPS)return -1;
  if(dot(b,c)<-EPS)return +2;
  if(norm(b)<norm(c))return -2;
  return 0;
}

vector<P> convex_hull(vector<P> p) {
  int n=p.size(),k=0;
  sort(p.begin(),p.end());
  vector<P> q(2*n);
  for(int i=0;i<n;q[k++]=p[i++])
    while(k>=2&&ccw(q[k-2],q[k-1],p[i])<=0) --k;
  for(int i=n-2,t=k+1;i>=0;q[k++]=p[i--])
    while(k>=t&&ccw(q[k-2],q[k-1],p[i])<=0) --k;
  q.resize(k-1);
  return q;
}

int p[101],r[101];
void init(){for(int i=0;i<101;i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

int main() {
  init();
  int n,m;
  cin >> n >> m;
  vector<P> v;
  priority_queue<PP,vector<PP>,greater<PP> > que;
  double ans=0;
  for(int i=0; i<n; i++) {
    double x,y;
    cin >> x >> y;
    v.push_back(P(x,y));
  }
  for(int i=0; i<m; i++) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    que.push(PP(D(v[x],v[y]),P(x,y)));
  }
  vector<P> g=convex_hull(v);
  vector<int> b;
  for(int i=0; i<g.size(); i++) {
    for(int j=0; j<n; j++) if(g[i]==v[j]) b.push_back(j);
  }
  for(int i=0; i<b.size(); i++) {
    int x=b[i],y=b[(i+1)%b.size()];
    unite(x,y);
    ans+=D(v[x],v[y]);
  }
  while(!que.empty()) {
    PP q=que.top();que.pop();
    int x=q.second.real(),y=q.second.imag();
    if(same(x,y)) continue;
    unite(x,y);
    ans+=q.first;
  }
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 3368
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);


int main(){
    map<string, llong> dict;
    llong N;
    llong maxv=0;
    string S;
    vector<string> ans_list;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> S;
        dict[S] += 1;
    }
    for(auto element:dict){
        maxv = max(element.second, maxv);
    }
    for(auto element:dict){
        if(element.second==maxv){
            ans_list.push_back(element.first);
        }
    }
    sort(ans_list.begin(), ans_list.end());
    for(auto ans : ans_list){
        cout << ans << endl;
    }
}

Measured memory_bytes: 24760
# -*- coding: utf-8 -*-


def main():

    n = input()
    a = sorted(list(map(int, input().split())))
    ai = max(a)
    a.remove(ai)
    aj = float('inf')
    tmp = float('inf')

    for aa in a:
        diff = abs(ai / 2 - aa)

        if diff < tmp:
            tmp = diff
            aj = aa

    print(ai, aj)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int h, w;
int grid[20][20];
int sx, sy, gx, gy;

bool ok(int x, int y)
{
	return x >= 0 && y >= 0 && x < h && y < w;
}

bool search(int d, int x, int y)
{
	if (d == 0){
		return x == gx && y == gy;
	}
	
	for (int dir = 0; dir < 4; dir++){
		int k = 0;
		while (true){
			int nx = x + dx[dir] * k;
			int ny = y + dy[dir] * k;
			int nnx = nx + dx[dir];
			int nny = ny + dy[dir];
			if (!ok(nx, ny)) break;
			if (grid[nx][ny] == 3){
				return true;
			}
			if (!ok(nnx, nny)) break;
			if (grid[nnx][nny] == 1){
				if (k == 0) break;
				grid[nnx][nny] = 0;
				if (search(d - 1, nx, ny)){
					grid[nnx][nny] = 1;
					return true;
				}
				grid[nnx][nny] = 1;
				break;
			}
			k++;
		}
	}
	
	return false;
}

int solve()
{
	for (int d = 1; d <= 10; d++){
		if (search(d, sx, sy)){
			return d;
		}
	}
	return -1;
}

int main()
{
	while (scanf("%d %d", &w, &h), w){
		fill_n(*grid, 20 * 20, 0);
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				scanf("%d", &grid[i][j]);
				if (grid[i][j] == 2){
					sx = i;
					sy = j;
				}
				else if (grid[i][j] == 3){
					gx = i;
					gy = j;
				}
			}
		}
		printf("%d\n", solve());
	}
	
	return 0;
}

Measured memory_bytes: 1188
def main():
    N = int(input())
    S = str(N)
    digit = len(S)
    if digit == 1:
        return print(N)
    if S[1] == '9':
        ans = (S[0] + S[1] + '9'*(digit - 2))
        if int(ans) > N:
            ans = int(ans) - 10**(digit - 1)
            ans = str(ans)
    else:
        ans = (str(int(S[0]) - 1) + '9' + '9'*(digit - 2))

    ans_sum = 0
    for a in ans:
        ans_sum += int(a)
    print(ans_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//


#include <iostream>
//#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;

//const ll MOD = 1e9+7;

int N;
string S[400];
ll ans;

int main() {
    // insert code here...    return 0;
  //////
    // input from txt
    /*
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::ofstream out("output.txt");
    std::cout.rdbuf(out.rdbuf());
   ////
     */
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int A=0;A<N;A++){
        //for(int B=0;B<N;B++){
            bool ok = true;
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    if(S[(i+A)%N][j] != S[(j+A)%N][i])
                    {
                        ok = false;
                        i=N;
                        break;
                    }
                }
            }
            if(ok)
                ans++;
        //}
    }
    ans *= N;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define N 2000000
using namespace std;
main () {
	int n, k, b, a[N] = {};
	cin >> n >> k;
	for(int i=0; i<n; i++) {
		cin >> b;
		a[b-1]++;
	}
	sort(a, a+N, greater<int>());
	int ans = 0;
	for(int i=0; i<n; i++) {
		if (k<=i) ans += a[i];
	}
	cout << ans << endl;
}


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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n; i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int n, m, l, i, j, k, A[100][100] = { 0 }, B[100][100] = { 0 };
	long C[100][100] = { 0 };
	scanf("%d %d %d", &n, &m, &l);

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

	for (i = 0; i < m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%d", &B[i][j]);
		}
	}

	for (k = 0; k < n; k++)
	{
		for (i = 0; i < l; i++)
		{
			for (j = 0; j < m; j++)
			{
				C[k][i] += A[k][j] * B[j][i];
			}
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			printf("%ld", C[i][j]);
			if (j + 1<l)
			{
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


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

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = gcd(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int ans = -1;
    int x;
    for(int i = 1; i <= 5; i++) {
        cin >> x;
        if(x == 0) {
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i=0; i<n; i++) {
      cin >> A.at(i);
  }
  for (int i=0; i<n; i++) {
      cout << A.at(n-i-1);
      if (i!=n-1) cout << " ";
      else cout << endl;
  }
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	string s , t ;
	cin >> s >> t ;

	rep(i,n){
		string S = s.substr(i,n-i);
		string T = t.substr(0,n-i);
		if(S==T){
			string ans = s + t.substr(n-i,i);
			cout << ans.size() << endl;
			return 0;
		}
	}
	cout << n * 2 << endl;
}


Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>

using namespace std;

int solve(int n, int m, priority_queue<int> &xs) {
    if (n >= m)
        return 0;

    priority_queue<int> gaps;
    int pre = -INT_MAX;
    while (!xs.empty()) {
        if (pre == -INT_MAX) {
            pre = xs.top();
            xs.pop();
            continue;
        }
        int cur = xs.top();
        xs.pop();
        gaps.push(pre - cur);
        pre = cur;
    }

    for (int i = 0; i < n - 1; i++) {
        gaps.pop();
    }

    int sum = 0;
    while (!gaps.empty()) {
        sum += gaps.top();
        gaps.pop();
    }

    return sum;
}

int main() {
    int n, m;
    priority_queue<int> xs;
    scanf(" %d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int xi;
        scanf(" %d", &xi);
        xs.push(xi);
    }
    printf("%d\n", solve(n, m, xs));
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	char C[3][60] = {}; 
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < N; j++){
		char c; 
		cin >> C[i][j]; 
		}
	}
	long long int ans = 1; 
	long long int P = 1e9 + 7; 
	if(C[0][0] == C[1][0]){
		ans *= 3; 
	}
	else{
		ans *= 6; 
	}
	for(int i = 1; i < N; i++){
		if(C[0][i] != C[1][i] && C[0][i-1] == C[1][i-1]){
			ans = (ans * 2) % P; 
		}
		else if(C[0][i] != C[1][i] && C[0][i-1] != C[1][i-1] && C[0][i] != C[0][i-1]){
			ans = (ans * 3) % P; 
		}
      	else if(C[0][i] == C[1][i] && C[0][i-1] == C[1][i-1]){
			ans = (ans * 2) % P; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char s[3][11];
	scanf("%s %s %s", s[0], s[1], s[2]);
	printf("%c%c%c\n", s[0][0] - 'a' + 'A', s[1][0] - 'a' + 'A', s[2][0] - 'a' + 'A');
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define pii pair<int, int>
#define L first
#define R second
using namespace std;

int N;
int A[200005], B[200005];

int main() {
  ios_base::sync_with_stdio(0);
  scanf("%d", &N);
  for(int i = 1; i <= N; i++) {
    scanf("%d %d", &A[i], &B[i]);
  }
  sort(A + 1, A + N + 1);
  sort(B + 1, B + N + 1);
  if(N & 1) {
    cout << B[N / 2 + 1] - A[N / 2 + 1] + 1<< "\n";
  }else cout << B[N / 2 + 1] - A[N / 2 + 1] + B[N / 2] - A[N / 2] + 1<< "\n";
}


Measured memory_bytes: 5240
import java.util.*

fun main(arr:Array<String>) {
    val txt1 = readLine()!!
    val txt2 = readLine()!!

    val idx1 = txt1.toSet().let { a-> a.map { Pair(it, a.indexOf(it)) }.toMap() }
    val idx2 = txt2.toSet().let { a-> a.map { Pair(it, a.indexOf(it)) }.toMap() }

    val conv1 = txt1.map { idx1[it]!! }.joinToString("")
    val conv2 = txt2.map { idx2[it]!! }.joinToString("")
    println(if (conv1 == conv2) "Yes" else "No")
}

Measured memory_bytes: 44596
import fractions
n = int(input())
a = list(map(int, input().split()))

a.sort()

mini = a.pop(0)
ans = 10**9+1
for i in range(n-1):
  temp = fractions.gcd(mini, a[i])
  if temp < ans:
    ans = temp
  
print(ans)

Measured memory_bytes: 16284
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <map>
using namespace std;
const int maxn = 1e5+55;
#define LL long long

vector<int>G[maxn];
int a[maxn];
int vis[maxn];
vector<int>b;


void dfs(int x)
{
	b.push_back(x);

	vis[x]=1;
	for(int i=0;i<G[x].size();i++){
		if(vis[G[x][i]]) continue;
		dfs(G[x][i]);
	}
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	map<int,int> mp;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			b.clear();
			mp.clear();
			dfs(i);
			for(int j=0;j<b.size();j++){
				mp[a[b[j]]]=1;
			}
			for(int j=0;j<b.size();j++){
				if(mp[b[j]]==1)
					ans++;
			}
		}
	}
	printf("%d\n",ans);




	return 0;
}


Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll LCM = C*D/gcd(C,D);
    ll c1 = (A-1)/C+(A-1)/D - (A-1)/LCM;
    ll c2 = B/C+B/D - B/LCM;
    ll quantity = B - A + 1;
    ll ans = quantity - (c2 - c1);
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <bitset>
using namespace std;
int n,x,sum;
bitset<2000010> f;
int main(){
    scanf("%d",&n);
    f[0]=1;
    int i;
    for(i=1;i<=n;i++){
        scanf("%d",&x);
        f|=f<<x;sum+=x;
    }
    for(i=(sum+1)/2;i<=sum;i++){
        if(f[i]){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 896
import itertools
import math

N = int(input())
C = [list(map(int,input().split())) for _ in range(N)]

def dist(x0,y0,x1,y1):
    return math.sqrt((x0-x1)**2+(y0-y1)**2)

Pt = list(itertools.permutations(range(N)))

distsum = 0
for i in range(len(Pt)):
    for j in range(N-1):
        distsum += dist(C[Pt[i][j]][0],C[Pt[i][j]][1],C[Pt[i][j+1]][0],C[Pt[i][j+1]][1])

print(distsum / len(Pt))


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> cost(N);
    vector<vector<int>> book(N);
    rep(i, N)
    {
        cin >> cost[i];
        rep(j, M)
        {
            int a;
            cin >> a;
            book[i].push_back(a);
        }
    }

    // {0, 1, ..., n-1} の部分集合の全探索
    int minTotal = INT_MAX;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }

        vector<int> st(M);
        rep(i, st.size())
        {
            st[i]=0;
        }
        int total = 0;
        rep(i, S.size())
        {
            total += cost[S[i]];
            rep(j, M)
            {
                st[j]+=book.at(S[i]).at(j);
            }
        }
        
        bool isOk = true;
        rep(i, st.size())
        {
            if(st[i]<X)
            {
                isOk = false;
                break;
            }
        }
        if(isOk)
        {
            minTotal = min(minTotal, total);
        }
    }

    if(minTotal!=INT_MAX)
    {
        cout << minTotal << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3664
#include "stdio.h"
#include"queue"
#include "climits"
using namespace std;

queue<int>Q;

int island;
int query;
int kind;
int start;
int goal;
int connect[101][101] = {};
int price;
int dis[101] = {};

int main() {
	scanf("%d %d", &island, &query);
	while (island != 0) {
		for (int i = 0; i < 101; i++) {
			for (int j = 0; j < 101; j++) {
				connect[i][j] = INT_MAX;
			}
		}
		for (int i = 0; i < query; i++) {
			scanf("%d", &kind);
			if (kind == 1) {
				scanf("%d %d %d", &start, &goal, &price);
				if (connect[start][goal] > price) {
					connect[start][goal] = price;
					connect[goal][start] = price;
				}
			}
			else {
				scanf("%d %d", &start, &goal);
				Q.push(start);
				for (int i = 1; i < 101; i++) {
					dis[i] = INT_MAX;
				}
				dis[start] = 0;
				while (!Q.empty()) {
					for (int i = 1; i <= island; i++) {
						if (connect[Q.front()][i] != INT_MAX) {
							if (dis[i] > dis[Q.front()] + connect[Q.front()][i]) {
								dis[i] = dis[Q.front()] + connect[Q.front()][i];
								Q.push(i);
							}
						}
					}
					Q.pop();
				}
				if (dis[goal] == INT_MAX)printf("-1\n");
				else printf("%d\n", dis[goal]);
			}
		}
		scanf("%d %d", &island, &query);
	}
	return 0;
}

Measured memory_bytes: 1108
#include <iostream>

using namespace std;

int cross[16][16];

void init() {
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j < 16; j++) {
            cross[i][j] = -1;
        }
    }
    cross[0][0] = 1;
}

int main() {
    while (true) {
        int a, b; cin >> a >> b;
        if (a == 0 && b == 0) break;
        int n;    cin >> n;
        init();
    
        int x, y; // blocked x, y;
        while (n--) {
            cin >> x >> y;
            cross[y-1][x-1] = 0;
        }
    
        for (int i = 0; i < b; i++) {
            for (int j = 0; j < a; j++) {
                if (cross[i][j] == -1) {
                    if (1 <= i && 1 <= j) {
                        cross[i][j] = cross[i][j-1] + cross[i-1][j];
                    } else if (1 <= i) {
                        cross[i][j] = cross[i-1][j];
                    } else if (1 <= j) {
                        cross[i][j] = cross[i][j-1];
                    }
                }
            }
        }
    
//        for (int i = 0; i < b; i++) {
//            for (int j = 0; j < a; j++) {
//                cout << cross[i][j] << ' ';
//            }
//            cout << endl;
//        }
    
        cout << cross[b-1][a-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    tmpl, tmpr, tmpd = map(int, input().split())
    G[tmpl].append((tmpr, tmpd))
    G[tmpr].append((tmpl, -tmpd))

field = [None] * (N+1)


def dfs(i):
    q = deque()
    q.append(i)
    field[i] = 0
    while q:
        tmp = q.pop()
        for elem in G[tmp]:
            if field[elem[0]] is not None:
                if field[elem[0]] != field[tmp]+elem[1]:
                    return False
                continue
            else:
                q.append(elem[0])
                field[elem[0]] = field[tmp]+elem[1]
    return True


for i in range(1, N+1):
    if field[i] is None:
        if not dfs(i):
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 66864
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

//const
#define EPS 1e-8
#define EQ (abs((a) - (b)) < EPS)
#define EQP(a, b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

inline int signum(double x) { return (abs(x) < EPS) ? 0 : (x > 0) ? 1 : -1; }

//-----definition-----
typedef complex<double> P;

//-----standard-----
pair<P, P> norm_vec(P a) {
    return make_pair(a * P(0, 1), a * P(0, -1));
}

P unit_vec(P a) { a / abs(a); }

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    int sign = signum(cross(b, c));
    if (sign != 0) return sign;
    if (signum(dot(b, c)) < 0) return 2;//left
    if (abs(b) < abs(c)) return -2;//right
    return 0; //mid
}

//-----line-----
bool is_paral(P a1, P a2, P b1, P b2) {
    return signum(cross(a2 - a1, b2 - b1)) == 0;
}

bool is_orth(P a1, P a2, P b1, P b2) {
    return signum(dot(a2 - a1, b2 - b1)) == 0;
}

bool is_p_on_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return signum(cross(b, c)) == 0;
}

bool is_p_on_li_s(P a, P b, P c) {
    return abs(c - a) + abs(b - c) < abs(b - a) + EPS;
}

double dis_p_li(P a, P b, P c) {
    b -= a;
    c -= a;
    return abs(cross(b, c)) / abs(b);
}

double dis_p_li_ss(P a, P b, P c) {
    P x1 = b - a;
    P y1 = c - a;
    P x2 = a - b;
    P y2 = c - b;
    if (cross(x1, y1) < EPS) return abs(y1);
    if (cross(x2, y2) < EPS) return abs(y2);
    return dis_p_li(a, b, c);
}

bool is_inter_li_ss(P a1, P a2, P b1, P b2) {
    return (ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0) && (ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0);

}

P inter_li_ss(P a1, P a2, P b1, P b2) {
    double d1 = abs(cross(b2 - b1, a1 - b1));
    double d2 = abs(cross(b2 - b1, a2 - b1));
    double t = d1 / (d1 + d2);
    return a1 + (a2 - a1) * t;
}

int main() {

    int Q;
    cin >> Q;

    while (Q--) {

        vector<P> p(4);
        for (int i = 0; i < 4; i++) {
            double x, y;
            cin >> x >> y;
            p[i] = P(x, y);
        }

        P ans = inter_li_ss(p[0], p[1], p[2], p[3]);
        cout << fixed << setprecision(10) << ans.real() << " " << ans.imag() << endl;
    }

}














































Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long int> H(N);
  for (int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  int ans = 0;
  int idou = 0;
  for (int i = 0; i < N-1; i++){
    if(H.at(i) >= H.at(i+1)){
      idou++;
    } else {
      ans = max(ans, idou);
      idou = 0;
    }
  }
  ans = max(ans, idou);
  cout << ans << endl;
  return 0;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,k,x;
        cin>>n>>k>>x;
        int ans = x*((n/k) + ((n%k)>0));
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
using System;
using AtCorder;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine();
            if (input1 == "1")
            {
                if (input2 == "2")
                {
                    Console.WriteLine("3");
                }
                else
                {
                    Console.WriteLine("2");
                }
            }
            else if (input1 == "2")
            {
                if (input2 == "1")
                {
                    Console.WriteLine("3");
                }
                else
                {
                    Console.WriteLine("1");
                }
            }
            else
            {
                if (input2 == "1")
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine("1");
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind
{
    std::vector<std::size_t> par;
    std::vector<std::size_t> _size;

    UnionFind(std::size_t N)
        : par(N)
        , _size(N, 1)
    {
        for (std::size_t i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    std::size_t Root(std::size_t x)
    {
        if (par[x] == x)
        {
            return x;
        }
        return par[x] = Root(par[x]);
    }

    void Unite(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        if (rx != ry)
        {
            if (_size[rx] < _size[ry])
            {
                par[rx] = ry;
                _size[ry] += _size[rx];
            }
            else
            {
                par[ry] = rx;
                _size[rx] += _size[ry];
            }
        }
    }

    size_t Size(std::size_t x)
    {
        return _size[Root(x)];
    }

    bool Same(std::size_t x, std::size_t y)
    {
        auto rx = Root(x);
        auto ry = Root(y);
        return rx == ry;
    }
};

int main()
{
    int64_t n, m;
    cin >> n >> m;
    vector<int64_t> as(m), bs(m);
    for (int i = 0; i < m; i++)
    {
        cin >> as[i] >> bs[i];
        as[i]--;
        bs[i]--;
    }
    vector<int64_t> ans_list;

    UnionFind uf(n);

    int64_t ans = n * (n - 1) / 2;
    ans_list.push_back(ans);
    for (int i = m - 1; i > 0; i--)
    {
        const int64_t sa = uf.Size(as[i]);
        const int64_t sb = uf.Size(bs[i]);
        if (!uf.Same(as[i], bs[i]))
        {
            ans -= uf.Size(as[i]) * uf.Size(bs[i]);
            uf.Unite(as[i], bs[i]);
        }
        ans_list.push_back(ans);
    }
    reverse(ans_list.begin(), ans_list.end());
    for (auto v : ans_list)
    {
        cout << v << endl;
    }
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

const int mx = 1e5+10;

li total = 0;
vector<li> freq(mx,0);

void solve() {
    li b,c;
    cin >> b >> c;
    total = total + (freq[b]*(c-b));
    li temp = freq[b];
    freq[b]=0;
    freq[c]+=temp;
    cout << total << endl;
}

int32_t main()
{
    hyperspeed
    li n;
    cin >> n;
    li a[n];
    for(li i=0;i<n;i++) {
        cin >> a[i];
        total+=a[i];
        freq[a[i]]++;
    }
    li test;
    cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 30) - 1;
const ll LINF = (1LL << 60) - 1;
const double eps = 1e-9;
const ll MOD = 998244353LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int c1 = 0, c2 = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            c1++;
        } else {
            c2++;
        }
    }
    if(c1 > c2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;
 
#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define FILL(v,n) memset(v,n,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep1n(i,n)	for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000000 //10^6

int main(){
	int n, k;
	
	cin>>n;
	k = n/100;
	if(n%100 <= k*5)	cout<<1;
	else				cout<<0;
	
}







Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int H, W, A, B; cin >> H >> W >> A >> B;
	REP(r, H) {
		REP(c, W)
		{
			if (r < B && c < A)
			{
				cout << 0;
			}
			else if (r >= B && c >= A)
			{
				cout << 0;
			}
			else
			{
				cout << 1;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = n*(n + 1) / 2;
	dunk(ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	printf("%lld",llabs(n-2)*llabs(m-2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1e9 + 7;
const int MAX_N = 200005;
int fact[MAX_N];
int fact_inv[MAX_N];
int bin_pow_mod(int x, int y) {
      if (x == 0) return 0;
      int prod=1;
      while(y>0) {
          if (y & 1) prod = (prod * x) % MOD;
          x = (x * x) % MOD;
          y >>= 1;
      }
      return prod % MOD;
}
struct init_fact {
    init_fact() {
        fact[0] = 1, fact_inv[0] = 1;
        for (int i = 1; i < MAX_N; ++i) {
            fact[i] = (fact[i - 1] * i) % MOD;
            fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
        }
    }
} init_fact;
int combination(int n, int r) {
    return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}
map<int, int> factorize(int a) {
    map<int, int> ret;
    for(int i = 2; i * i <= a; i++) {
        int cnt = 0;
        while (a % i == 0) a /= i, cnt++;
        if (cnt != 0) ret[i] = cnt;
    }
    if (a != 1) ret[a] = 1;
    return ret;
}
signed main() {
    int N, M;
    cin >> N >> M;
    auto f = factorize(M);
    int ans = 1;
    FORE(p, f) {
        int c = p.second;
        ans *= combination(N + c - 1, c);
        ans %= MOD;
    }
    cout << ans << endl;
    return (0^_^0);
}



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

int main() {
	int A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
	int swater,sugar;
	float p=0;
	for(int a=0;100*a<=F;a+=A){
		for(int b=0;100*a+100*b<=F;b+=B){
			for(int c=0;100*a+100*b+c<=F;c+=C){
				for(int d=0;100*a+100*b+c+d<=F;d+=D){
					if((c+d+a+b)!=0){
					if((a+b)*E>=(c+d)){
						float x=100*a+100*b;
						float y=c+d;
						if(p<=y/(x+y)){
							p=y/(x+y);
							swater=100*a+100*b+c+d;
							sugar=c+d;
						}
					}
					}

				}
			}
		}
	}
	cout<<swater<<' '<<sugar<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> D(N, 0);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int A;
            cin >> A;
            D[A - 1]++;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (D[i] == 0) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
from collections import defaultdict, deque
input = sys.stdin.readline
N, M = map(int, input().split())
guidepost = [None] * N
distance = [0] + [10**9] * (N - 1)
dd = defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split())
    dd[a].append(b)
    dd[b].append(a)
stack = deque([1])
checked = [False] * N
while len(stack) >= 1:
    i = stack.popleft()
    if checked[i - 1]:
        continue
    checked[i - 1] = True
    for j in dd[i]:
        distance[j - 1] = min(distance[j - 1], distance[i - 1] + 1)
        if guidepost[j - 1] is None:
            guidepost[j - 1] = i
        elif distance[guidepost[j - 1] - 1] > distance[i - 1]:
            guidepost[j - 1] = i
        if not checked[j - 1]:
            stack.append(j)
print('Yes')
# join?
# for i in range(1, N):
#     print(guidepost[i])
print('\n'.join([str(guidepost[i]) for i in range(1, N)]))

Measured memory_bytes: 108980
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int sosu(int n);

int main(){
	// sengen
	int k,x;
	
	// nyuryoku
	cin >> k >> x;
	// keisan
	if(500*k >= x){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

int sosu(int n){
	if(n == 2) return 1;
	else if(n%2 == 0) return 0;

	double a = sqrt(n);
	for(int i = 3;i<=a;i +=2){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}

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

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

#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i))
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(x,v) for(const auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義 #define int long long
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; }
//lambda: [&](int x, int y){return x<y;}

signed main(void){
    int h,w;cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h)rep(j,w)cin>>a[i][j];
    
    rep(i,w+2)cout << "#" ;
    cout << endl;
    rep(i,h){
        cout << "#";
        rep(j,w)cout << a[i][j];
        cout << "#" << endl;
    }
    rep(i,w+2)cout << "#";
    cout << endl;
}


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

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

    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3124