akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b,c;
    cin>>S>>T;
    n=sz(S);
    rep(i,0,n)
    {
        count+=(S[i]!=T[i]);
    }
    cout<<count;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3804
let list_of_str s =
  let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0

let rec solve = function
  | [] -> "YES"
  (* 1. erase[r] はその場で消費して OK *)
  | 'e'::'r'::'a'::'s'::'e'::'r'::xs
  | 'e'::'r'::'a'::'s'::'e'::xs
  (* 2. dreamer... と来ても実は dream erase[r] かもしれない*)
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::'a'::'s'::'e'::'r'::xs
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::'a'::'s'::'e'::xs
  (* 3. dream[er] *)
  | 'd'::'r'::'e'::'a'::'m'::'e'::'r'::xs
  | 'd'::'r'::'e'::'a'::'m'::xs -> solve xs
  (* 4. NO *)
  | _ -> "NO"

let () = Scanf.scanf "%s" list_of_str |> solve |> print_endline


Measured memory_bytes: 9472
# -*- coding: utf-8 -*-
n = int(input())
s = str(input())
k = int(input())
"""
n = 7
s = "djfsfok"
k = 3
"""
index_num = [n for n, v in enumerate(s) if v == s[k-1]]
ans = list("*"*n)
index_num = list(index_num)
for i in range(0, len(index_num)):
    ans[index_num[i]] = s[k-1]
print("".join(ans))

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

using namespace std;

long long int mod=1e9+7;

long long int arr[200006];

int main(){
	long long n;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i]%mod;
	}
	long long int ans=0;
	for(int i=0;i<n-1;i++){
		sum=(sum-arr[i]+mod)%mod;
		ans+=(arr[i]*(sum))%mod;
	}
	cout<<ans%mod<<endl;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, 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); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }

int lcp(const string &s1, const string &s2) {
	int cnt = 0, n = min(s1.size(), s2.size());
	REP(i, n) {
		if (s1[i] == s2[i]) cnt++;
		else break;
	}
	return cnt;
}

long long CountZeroSubstrings(vector<ll> A) {
    int n = A.size();

    vector<long long> S(n+1, 0);
    for (int i = 0; i < n; i++)
        S[i+1] = S[i] + A[i];

    long long answer = 0;
    unordered_map<long long, int> H;
    for (int i = 0; i <= n; i++) {
        if (H.count(S[i]))
            answer += H[S[i]];
        H[S[i]]++;      
    }

    return answer;
}

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

	int N; cin >> N;
	vector<ll> as(N);
	REP(i, N) cin >> as[i];
/*	vector<ll> ltor(N), rtol(N);
	ll sum = 0;
	REP(i, N) {
		int a; cin >> a;
		sum += a;
		as[i] = a;
		ltor[i] += a; if (i > 0) ltor[i] += ltor[i-1];
		rtol[i] += a; if (i < N - 1) rtol[i] += rtol[i + 1];
	}
*/

	cout << CountZeroSubstrings(as) << endl;
	return 0;
}

Measured memory_bytes: 13256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  xs <- getc $ splitOn ","
  mapM_ print $ solve xs

solve :: [[String]] -> [Int]
solve = map (toInt . head) . filter f
  where
    f [_,sw,sh] = bmi w h >= 25.0
      where
        w = toDbl sw
        h = toDbl sh

bmi :: Double -> Double -> Double
bmi w h = w / (h ^ 2)
  
toInt :: String -> Int
toInt s = read s

toDbl :: String -> Double
toDbl s = read s

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();

		long cnt = 0;
		long min = N;

		long x = N;
		long x_tmp = 0;

		/* check */
		long L = Math.abs(N/K);
		x = x - L*K;
		
		/* check2 */
		for (;;) {
			x_tmp =Math.abs(x - K);
			if (x > x_tmp) {
				x =  Math.abs(x - K);
				cnt = 0;
			} else if(x == x_tmp) {
				cnt++;
				if(cnt > 0);
					break;
			}else {
				break;
			}

		}

		System.out.println(x);
		sc.close();

	}
}

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

double p, e, t;

double dfs(int k, double x, double lt, double rt){
	if(max(abs(lt - t), abs(rt - t)) <= e){
		return x;
	}
	if(max(lt, rt) <= t - e || min(lt, rt) >= t + e){
		return 0,0;
	}

	double h = 0.5 * (lt + rt);
	if(k > 0){
		double q = (h > t ? 1.0 - p : p);
		double ret = dfs(k - 1, x * q, lt, h) + dfs(k - 1, x * (1.0 - q), h, rt);
		return ret;
	}
	else if(abs(h - t) <= e){
		return x;
	}
	return 0.0;
}

int main(){
	int k, r, l;
	scanf("%d%d%d%lf%lf%lf", &k, &l, &r, &p, &e, &t);
	printf("%f\n", dfs(k, 1.0, l, r));
}

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

int main(){
	int price, amount;
	int price_sum = 0;
	int amount_sum = 0;
	int kind = 0;
	while(~scanf("%d,%d", &price, &amount)){
		kind++;
		price_sum += price * amount;
		amount_sum += amount;
	}
	cout << price_sum << endl;
	cout << (int)((double)amount_sum / (double)kind + 0.5) << endl;

	return 0;
}

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

public class Main {

	public static void main(String[] args) {

		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 try{

			 int x = Integer.parseInt(br.readLine());

			 System.out.printf("%d\n", x*x*x);

		 }catch(IOException e){
			 e.printStackTrace();
		 }
	}
}




Measured memory_bytes: 24596
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = 0, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
unsigned long long int iremono[101];
std::vector<int>listup{}, ans{}, kaku{};

bool okada = false,okada2=false;
std::string output, output2, input, nyahhoi;

int kakunou2[50][50] = {};

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> a;
rep(i, a) {
		cin >> x;
	    listup.push_back(x);

	}
if (a % 2 == 0) {
	rep(j, a) {
		if (j % 2 == 0) {
			ans.push_back(listup[j]);
		}
		else {
			kaku.push_back(listup[j]);
			ans.insert(ans.begin(), kaku.begin(), kaku.end());
			kaku.clear();
		}
	}
}
else {
	rep(j, a) {
		if (j % 2 == 0) {
			kaku.push_back(listup[j]);
			ans.insert(ans.begin(), kaku.begin(), kaku.end());
			kaku.clear();
			
		}
		else {
		ans.push_back(listup[j]);
		}
	}
}
rep(i, a) {
	if (i != a - 1) {
		cout << ans[i] << " ";
	}
	else {
		cout << ans[i];
	}
}
}









Measured memory_bytes: 3828
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000
void Merge(int[MAX],int,int,int);
void MergeSort(int[MAX],int,int);
long long count = 0;
int main(){
	int i, n;
	int A[MAX];
 
	scanf("%d", &n);
	for(i =0; i < n; i++)
		scanf("%d", &A[i]);
	MergeSort(A, 0, n);
	printf("%lld\n",count);
	return 0;
}

void Merge(int A[MAX], int left, int mid, int right){
  int i,j, k;
  int n1,n2;
 
  n1 = mid - left;
  n2 = right - mid; 
  int L[MAX], R[MAX];
  for(i = 0; i < n1; i++)
    L[i] = A[left + i];
  for(i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = INFTY; R[n2] = INFTY;
  i = 0;j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j])
      A[k] = L[i++];
    else{
      A[k] = R[j++];
      count += n1 - i;}
  }
 
}
 
void MergeSort(int A[MAX], int left, int right){
 
  int mid;
  if((left + 1) < right){ 
    mid = (left + right) / 2; 
    MergeSort(A, left, mid);
    MergeSort(A, mid, right); 
    Merge(A, left, mid, right);
 
  }
 
}
 

Measured memory_bytes: 3828
#include <stdio.h>

void make_number_of_combination(long long int now[1001][10]) {
	int a, i, j;
	long long int pre[1001][10] = {{0}};

	for (a = 0; a < 101; a++) {
		now[a][0] = 1;
		for (i = 0; i < 1001; i++) {
			if (i+a > 1000)
				break;
			for (j = 0; j < 9; j++) {
				now[i+a][j+1] += pre[i][j];
			}
		}
		for (i = 0; i < 1001; i++) {
			for (j = 0; j < 10; j++) {
				pre[i][j] = now[i][j];
			}
		}
	}
}

int main(void) {
	int n, s;
	long long int ans[1001][10] = {{0}};

	make_number_of_combination(ans);

	while (1) {
		scanf("%d %d", &n, &s);
		if (n == 0 && s == 0)
			break;
		printf("%lld\n", ans[s][n-1]);
	}
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int MAX=5010;
const int INF=1e18;



int main(){
	int N;
	cin>>N;
	int oh[MAX], op[MAX];
	rep(i,N)cin>>oh[i]>>op[i];
	
	set<P> st;
	rep(i,N) st.insert(make_pair(oh[i]+op[i], i));
	
	int A[MAX], B[MAX];
	int ind=0;
	for(auto it=st.begin(); it!=st.end(); it++){
		P p=*it;
		A[ind]=oh[p.second];
		B[ind]=op[p.second];
		ind++;
	}
	ll dp[MAX][MAX];
	rep(i,N+1)dp[i][0]=0;
	rep1(j,N)dp[0][j]=INF;
	rep1(i,N)rep1(j,N){
		dp[i][j]=dp[i-1][j];
		if(dp[i-1][j-1]<=(ll)A[i-1])dp[i][j]=min(dp[i][j], dp[i-1][j-1]+(ll)B[i-1]);
	}
	int ans=0;
	rep1(j,N){
		if(dp[N][j]<INF)ans=j;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 196608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

ll money(ll x)
{
    if (x == 3) {
        return 100000;
    } else if (x == 2) {
        return 200000;
    } else if (x == 1) {
        return 300000;
    } else {
        return 0;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    if (x == 1 && y == 1) {
        ans += 400000;
    }
    cout << ans + money(x) + money(y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N = 100005;
const int mod = 1000000007;

int n,dp[N][2],a,b;
vector<int>v[N];
bool visit[N];

int dpf(int i,int j,int p){
	//cout<<i<<" "<<j<<" "<<p<<endl;
	if(dp[i][j]!=-1) return dp[i][j];
	dp[i][j]=0;
	ll ans1=1,ans2=1;
	for(auto k:v[i]){
		if(k!=p){
			if(j==0){
				ans1*=dpf(k,0,i);
				ans1%=mod;
				ans2*=dpf(k,1,i);
				ans2%=mod;
			}
			else ans1*=dpf(k,0,i),ans1%=mod;
		}
	}
	if(j==0) return dp[i][j]=(ans1+ans2)%mod;
	else return dp[i][j]=ans1;
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	memset(dp,-1,sizeof(dp));
	cout<<dpf(1,0,0);
return 0;
}

Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        int cnt = 0;
        while(a >= b) {
            b *= 2;
            cnt++;
        }

        while(b >= c) {
            c *= 2;
            cnt++;
        }

        if(k >= cnt) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35704
n, m, x = gets.split.map &:to_i
books = n.times.map { gets.split.map &:to_i }

min_c = 1000000000000
(2**n).times do |b|
  u = [0] * m
  c = 0
  n.times do |i|
    if b[i] != 0
      m.times { |j| u[j] += books[i][j+1] }
      c += books[i][0]
    end
  end
  if u.all? { |v| v >= x }
    min_c = c if min_c > c
  end
end

min_c = -1 if min_c === 1000000000000

p min_c

Measured memory_bytes: 14332
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

int k;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%d", &k);

  int ans = 1, a = 7;
  while(ans < 5000000) {
    while(a < k) {
      a = a * 10 + 7;
      ans += 1;
    }
    if (a % k == 0) {
      break;
    }
    a %= k;
  }
  if (ans == 5000000) {
    ans = -1;
  } 
  printf("%d\n", ans);


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3816
#include<iostream>

int main()
{
    int a, b;
    std::cin>>a;
    std::cin>>b;
    for(int i=1;i<4;i++)
    {
        if(a*b%2==0)
        {
            std::cout<<"No"<<"\n";
            break;
        }
        else
        {
            std::cout<<"Yes"<<"\n";
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<string.h> 
using namespace std;
#define ll long long
#define MOD 10000000
ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return w*x;
}//快读算法
const long N = 200000;//这相当与存了200000个素数
long prime[N] = {0},num_prime = 0;//假设都是素数
int isNotPrime[N] = {1, 1};//先将0，1排除   不是素数
void SE(){
	for(long i = 2 ; i < N ; i ++){
        if(! isNotPrime[i])//isNotPrime==0
            prime[num_prime ++]=i;//自己在前面打好了标记。 //关键处1           /*i为合数时也要参与循环*/
		for(long j = 0 ; j < num_prime/*小于已经求出的质数个数*/ && i * prime[j]/*乘以其它质数，且质数比自己小或者是自己（已经求出来了），所以不可能重复*/ <  N ; j ++){
                isNotPrime[i * prime[j]] = 1;//乘以其它素数得到的一定是合数，之所以不重复是因为质数间不等
            if( !(i % prime[j] ) )  //关键处2 i%prime==0  根据“关键处2”的定义，当p1==prime[j] 的时候，
            //筛除就终止了(从最小质数开始所以本句话成立），
                break;
        }
    }
}//这是欧拉筛的算法，其中 prime[N]中储存的是前  N  个素数

int QuickPow(int x,int N){
    int res = x;
    int ans = 1;
    while(N){
        if(N&1){
            ans = ans * res;
        }
        res = res*res;
        N = N>>1;
    }
    return ans;
}//快速求解  x^n  的值---快速幂
const int M=2;
struct Ma{
    int a[M][M];
    Ma(){
        memset(a,0,sizeof(a));
    }
    void unit(){
        a[0][0]=a[1][1]=1;
        a[0][1]=a[1][0]=1;
    }
    Ma operator *(const Ma &B)const{
        Ma ans;
        for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
                for(int k=0;k<M;k++){
                    ans.a[i][j]+=a[i][k]*B.a[k][j];
                }
            }
        }
        return ans;
    }
    Ma operator^(int n) const{
        Ma ans;ans.unit();
        Ma A=*this;
        while(n){
            if(n&1){
                ans=ans*A;
                A=A*A;
                n>>1;
            }
        }
        return ans;
    }
    void show(){
        cout<<"矩阵"<<endl;
        for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
    }
};
int main(){
    long long N,M;
    cin>>N>>M;//总共N个题目,M次提交
   	int wa[105000];
	bool ac[105000];
	int rwa=0;
	int rac=0;
	for(int i=0;i<M;i++){
		wa[i]=0;
		ac[i]=false;
	} 
	int a;
	string b;
	for(int i=0;i<M;i++){
		cin>>a>>b;
		if(ac[a]) continue;
		else {
			if(b=="AC"){
				ac[a]=true;
				rac++;
				rwa+=wa[a];
			}else{
				wa[a]++;
			}
		}
	}
	cout<<rac<<" "<<rwa<<endl;
	return 0;
}
















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

using namespace std;

int main(void) {
  int n, k;
  cin >> n >> k;

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += 2 * min(x[i], k - x[i]);
  }

  cout << ans << endl;

  return 0;
}

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

void print(const vector<int>& v)
{
	for (const auto& item : v) {
		cout << item << " ";
	}
}

int main()
{
	string s;
	cin >> s;
	int n = s.size();

	vector<int> ans(n);
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') count++;
		else {
			ans[i] += count / 2;
			ans[i - 1] += (count + 1) / 2;
			count = 0;
		}
	}

	reverse(ans.begin(), ans.end());
	reverse(s.begin(), s.end());

	count = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'L') count++;
		else {
			ans[i] += count / 2;
			ans[i - 1] += (count + 1) / 2;
			count = 0;
		}
	}

	reverse(ans.begin(), ans.end());
	reverse(s.begin(), s.end());

	for (int i = 0; i < n; i++) {
		printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 1024
s = input()

if s[0]=='A' and s.count('C',2,-1)==1:
    #print(s[1:2]+s[2:-2].replace('C','')+s[-2:])
    if (s[1:2]+s[2:-1].replace('C','')+s[-1:]).islower():
        print('AC')
    else:
        print('WA')
else:
    print('WA')

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

using namespace std;

char s[1000];

int main()
{
    cin >> s;
    int len = strlen(s), q, a, b;
    cin >> q;
    while(q--)
    {
        string com;
        cin >> com >> a >> b;
        if(com == "replace")
        {
            string rep;
            cin >> rep;
            for(int i = a;i <= b;i++)
            {
                s[i] = rep[i - a];
            }
        }
        if(com == "reverse")
        {
            while(a <= b)
            {
                swap(s[a], s[b]);
                a++;b--;
            }
        }
        if(com == "print")
        {
            for(int i = a;i <= b;i++)
                cout << s[i];
            cout << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <memory>
#include <string>
#include <cmath>
using namespace std;

int main()
{
  int N, T;
  cin >> N >> T;

  int ci, ti;
  int min_c = 1001;
  for(int i = 0; i < N; ++i) {
    cin >> ci >> ti;
    if(ti <= T) {
      if(ci < min_c) {
	min_c = ci;
      }
    }
  }

  if(min_c == 1001) {
    cout << "TLE" << endl;
  }
  else {
    cout << min_c << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
  dp[i][i] = a[i-1]
for w in range(1,n):
  for i in range(1,n-w+1):
    j = i+w
    dp[i][j] = max(a[i-1]-dp[i+1][j],a[j-1]-dp[i][j-1])
print(dp[1][n])

Measured memory_bytes: 119984
N = int(input())
P = list(map(int, input().split()))


ans = 0

for i in range(N):
    if P[0] == 1:
        ans += 1
        P[0], P[1] = P[1], P[0]
    elif i != N-1:
        if P[i] == i+1:
            ans += 1
            P[i+1], P[i] = P[i], P[i+1]
    elif i == N-1:
        if P[i] == i+1:
            ans += 1

print(ans)

Measured memory_bytes: 14008
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct Node{
  int key;
  struct Node *right,*left,*parent;
};
 
void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
 
 
struct Node *root,*NIL;
 
int main(){
 
  int n,i,x;
  char com[10];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
 
void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
   
  z=((struct Node *)malloc(sizeof(struct Node)));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
 
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}
 
void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 24040
#include <iostream>
using namespace std;
int main(){
	while(1){
		int m,f,r;
		cin >> m >> f >> r;
		if(m+f+r==-3) return 0;
		char s;
		if(m==-1 or f==-1) s = 'F';
		else if(m+f>=80) s = 'A';
		else if(m+f>=65) s = 'B';
		else if(m+f>=50) s = 'C';
		else if(m+f>=30){
			if(r>=50) s = 'C';
			else s = 'D';
		}
		else s = 'F';
		cout << s << endl;
	}
}

Measured memory_bytes: 1152
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
void lcs(string X,string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 

   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   int index = L[m][n]; 
  
   char lcs[index+1]; 
   lcs[index] = '\0'; 
  

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; 
          i--; j--; index--;    
      } 
  
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
     cout<<lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string str1,str2;
  cin>>str1>>str2;
  int m =str1.size(); 
  int n =str2.size(); 
  lcs(str1,str2, m, n); 
  return 0; 
} 

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

int main() {

	int n; cin >> n;
	int cnt4 = 0;
	int cnt2 = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a % 4 == 0) cnt4++;
		else if (a % 2 == 0) cnt2++;
		else cnt++;
	}
	string ans = "No";
	int tmp = 0;
	if (cnt2 % 2 != 0) {
		tmp = cnt2 - 1;
	}
	else {
		tmp = cnt2;
	}
	n -= tmp;
	if (n % 2 != 0) {
		if (n / 2 <= cnt4 + 1) {
			ans = "Yes";
		}
	}
	else { // n % 2 == 0
		if (n / 2 <= cnt4) {
			ans = "Yes";
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
ss = list(map(int, input().split()))

cnt = 0
ans = 0

for i, s in enumerate(ss):
    cnt += 1
    flg = True
    if i+1 < len(ss):
        if ss[i] != ss[i+1]:
            ans += (cnt // 2)
            cnt = 0

            flg = False

if(flg):
    ans = (cnt // 2) + ans


print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool isPalindrome(string s) {
    string sub;
    int HALF = s.length()/2;
    for(int i=0;i<HALF;i++) {
        if(s[i] != s[s.length()-1-i]) {
            return false;
        }
    }
    sub = s.substr(0,(s.length()-1)/2);
    HALF = sub.length()/2;
    for(int i=0;i<HALF;i++) {
        if(sub[i] != sub[sub.length()-1-i]) {
            return false;
        }
    }
    sub = s.substr((s.length()+3)/2-1);
    for(int i=0;i<HALF;i++) {
        if(sub[i] != sub[sub.length()-1-i]) {
            return false;
        }
    }
    return true;
}
int main () {
    ios_base::sync_with_stdio(false);
    string S;
    cin>>S;
    if(isPalindrome(S)) {
        cout<<"Yes"<<"\n";
    }
    else {
        cout<<"No"<<"\n";
    }
    return 0; 
}

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


#define ll long long
#define MOD 1000000007



int main(){
    ll n;
    cin>>n;
    vector<ll> ta(100001,0);
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        ta.at(a)++;
    }
    ll sum=0;
    for(int i=0;i<ta.size();i++){
        sum += ta.at(i)*i;
    }

    ll q;
    cin>>q;
    ll b,c;
    for(int i=0;i<q;i++){
        cin>>b>>c;
        sum -= ta.at(b)*b;
        sum += ta.at(b)*c;
        ta.at(c) += ta.at(b);
        ta.at(b) = 0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 4052
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
  
from fractions import gcd
a, b = map(int, input().split())

x = gcd(a, b)
y = prime_factorize(x)

print(len(y)+1)

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

int main() {
	int a, b;
	cin >> a >> b;
	string S1, S2;
	for (int i = 0; i < b; i++) {
		S1 += to_string(a);
	}
	for (int i = 0; i < a; i++) {
		S2 += to_string(b);
	}

	if (S1 < S2) cout << S1 << endl;
	else cout << S2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, x, mx, sum;
int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> x;
    mx = max(mx, x);
    sum += x;
  }
  cout << sum - mx / 2;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    long ans = pow(N, 3);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=1e5+5;
int n,cou=0;
string s;
vector<string> title;
vector<int>tim;

int32_t main(){
	IOS;
	
	//code
	cin>>n;
	title.resize(n);
	tim.resize(n);
	for(int i=0;i<n;i++){
		cin>>title[i]>>tim[i];
	}
	string x;
	cin>>x;
	int ind=-1, sum=0;
	for(int i=0;i<n;i++){
		if(title[i]==x)
			ind=i+1;
	}
	for(int i=ind;i<n;i++)
		sum+=tim[i];
	cout<<sum<<endl;

	//code
	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inv(x) Power(x, mod - 2)
#define N 3005

using namespace std;
typedef long long ll;

int n, mod;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }

inline int Power(int x, int y, int M = mod) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % M;
		x = (ll) x * x % M, y >>= 1;
	} return res;
}

int fac[N], ifac[N];
void init(int n) {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (ll) fac[i - 1] * i % mod;
	ifac[n] = inv(fac[n]);
	for (int i = n - 1; i; --i) ifac[i] = (ll) ifac[i + 1] * (i + 1) % mod;
}

int C(int x, int y) {
	if (x < y || y < 0) return 0;
	return (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}

int g[N][N];
int f[N];

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> mod, init(n);
	
	for (int i = 0; i <= n; ++i) {
		g[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			g[i][j] = add(g[i - 1][j - 1], (ll) g[i - 1][j] * (j + 1) % mod);
	}
	
	for (int i = 0; i <= n; ++i) {
		ll tmp = Power(2, Power(2, n - i, mod - 1)), tmpb = Power(2, n - i);
		for (int j = 0, Pow = 1; j <= i; ++j, Pow = tmpb * Pow % mod)
			inc(f[i], (ll) Pow * g[i][j] % mod);
		f[i] = (ll) f[i] * tmp % mod;
	}
		
	
	ll ans = 0;
	for (int i = 0, flag = 1; i <= n; ++i, flag ^= 1) {
		ll c = C(n, i);
		if (!flag) c = mod - c;
		ans += c * f[i] % mod;
	}
	
	printf("%lld\n", ans % mod);
	return 0;
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 34304
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, c = map(int, readline().split())

    if b - a == c - b:
        print('YES')
    else:
        print('NO')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8972
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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 ll INF=1e9+7;

int main(){
    string n;
    cin >> n;
    ll m=n.length();
    ll tot=0;
    rep(i,m){
        ll v=n[i]-'0';
        tot+=v;
        tot%=9;
    }
    if(tot==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3720
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vector<string> data(N);
    for (int i = 0; i < N; i++) {
        cin >> data[i];
    }
    for (int i = 0; i < N - 1; i++) {
        if (data[i][data[i].size() - 1] != data[i + 1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    sort(data.begin(), data.end());
    for (int i = 0; i < N - 1; i++) {
        if (data[i] == data[i + 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  string in1, in2;
  cin >> in1 >> in2;
  if(in1[0] == in2[2] &&
     in1[1] == in2[1] &&
     in1[2] == in2[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (t * s >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<stdlib.h>

int comp(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void)
{
	int N, i, ml, mu;
	int X[200001], Y[200001];

	scanf("%d", &N);
	for(i=0;i<N;i++)
	{
		scanf("%d", &X[i]);
		Y[i] = X[i];
	}

	qsort(Y, N, sizeof(int), comp);

	mu = Y[N/2-1];
	ml = Y[N/2];

	//printf("ml = %d,  mu = %d\n", ml, mu);

	for(i=0;i<N;i++)
	{
		if(X[i] >= mu) printf("%d\n", ml);
		else printf("%d\n", mu);
	}

	return 0;
}

Measured memory_bytes: 3704
N = int(input())
H = list(map(int, input().split()))
ans = 0
temp = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    temp += 1
  else:
    if temp > ans:
      ans = temp
    temp = 0
if temp > ans:
  ans = temp
  
print(ans)

Measured memory_bytes: 85364
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];

        long na = 0;
        long nb = 0;

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int gap = sc.nextInt() - a[i];
            if (gap < 0) {
                nb += -gap;
            } else {
                na += gap / 2;
            }
        }

        System.out.println(na >= nb ? "Yes" : "No");
    }
}

Measured memory_bytes: 43616
import sys
Input = sys.stdin.readline
#Input = input

N, M, X = map(int, Input().split()) 
A = list(map(int, Input().split()))

l = [0 if i not in A else 1 for i in range(N+1)]
print(min(sum(l[X+1:-1]), sum(l[1:X])))

Measured memory_bytes: 3060
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn digit_count(n: u64) -> u64 {
    if n == 0 {
        return 1;
    }
    for i in 0..20u32 {
        if n < 10u64.pow(i) {
            return i as u64;
        }
    }
    20u64
}

fn digits(n: u64) -> Vec<u64> {
    let mut m = n;
    let mut vec: Vec<u64> = Vec::new();
    let mut i = digit_count(m) as u32 - 1;
    loop {
        let l = m / 10u64.pow(i);
        vec.push(l);
        m -= l * 10u64.pow(i);
        if i == 0 {
            break;
        }
        i -= 1;
    }
    vec
}

fn main() {
    let (a, b) = input_tuple();
    let mut count = 0;
    for i in a..(b+1) {
        let d = digits(i);
        let mut flag = true;
        let n = digit_count(i) as usize;
        for i in 0..n/2 {
            if d[i] != d[n - i - 1] {
                flag = false;
            }
        }
        if flag {
            count += 1;
        }
    }
    println!("{}", count);
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===


int main()
{
  int n;
  cin >> n;
  Vi a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  int tmp = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i - 1] >= a[i]) ++tmp;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  
  cout << ans << endl;
  
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> ss;
    int maxi = 0;
    rep(i, n) {
        string s;
        cin >> s;
        ss[s]++;
        maxi = max(maxi, ss[s]);
    }
    for (auto s : ss) {
        if (s.second == maxi) {
            cout << s.first << endl;
        }
    }
}

Measured memory_bytes: 26496
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a := getInt()
		m[a]++
	}

	first, second := 0, 0
	for a, num := range m {
		for num >= 2 {
			if a > first {
				second = first
				first = a
			} else if a > second {
				second = a
			} else {
				break
			}

			num -= 2
		}
	}

	ans := first * second
	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

const int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int H,W;
int dist[410][410];
bool visit[410][410];

void bfs(vector<string> &s, int y, int x, LLI &cnt, LLI &cnt_b){
  visit[y][x] = true;
  cnt++;
  if(s[y][x] == '#') cnt_b++;

  REP(k,4){
    int ny = y + dir4[k][0];
    int nx = x + dir4[k][1];

    if(ny>=0 && ny<H && nx>=0 && nx<W && !visit[ny][nx]){
      if(s[y][x] != s[ny][nx]){
	bfs(s,ny,nx,cnt,cnt_b);
      }
    }
  }
}

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

  cin >> H >> W;
  vector<string> s(H); cin >> s;

  LLI ans = 0;
  
  REP(i,H){
    REP(j,W){
      if(!visit[i][j]){
	LLI cnt_all=0;
	LLI cnt_black=0;
	bfs(s,i,j,cnt_all,cnt_black);
	LLI cnt_white = cnt_all - cnt_black;
	LLI t = cnt_black*cnt_white;
	
	ans += t;
      }
    }
  }  
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 20608
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
String ans;
  if(b-a<=0) {
    ans="delicious";
  }
  else if(b-a-x>0) {
    ans="dangerous";	
  }
  else {
	ans="safe";  
  }
       

System.out.println(ans);
 }
}
  

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

int main() {
  int x;
  int a[1000],b[1000],c[1000];

  cin >> x;
  for(int i=0;i<x;i++) {
    cin >> a[i] >> b[i] >> c[i];
    if ((a[i] * a[i] == b[i] * b[i] + c[i] * c[i]) || (b[i] * b[i] == a[i] * a[i] + c[i] * c[i]) || (c[i] * c[i] == a[i] * a[i] + b[i] * b[i]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0, sum;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				sum = 500 * i + 100 * j + 50 * k;
				if (sum == X) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

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

int main(){

    string s;
    ll k;

    cin >> s >> k;

    ll t=0;

    for(t=0;t<s.size();t++){
        if(s[t]!='1'){
            break;
        }
    }
    if(t>=k){
        cout << s[t-1] << endl;
    }else{
        cout << s[t] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cstdio>
#define LIMIT 10000
using namespace std;
bool ck(vector<int>&v){
	for(int i=0;i<v.size();i++)if(v[i]!=i+1)return false;
	return true;
}
main(){
	int n,i,j,s,x,l;
	vector<int>tri;
	for(i=1;i<1999;i++)tri.push_back(i*(i+1)/2);
	for(;scanf("%d",&n),n;){
		vector<int>v;
		for(s=i=0;i<n;i++){
			scanf("%d",&x);
			s+=x;
			v.push_back(x);
		}
		vector<int>::iterator idx=find(tri.begin(),tri.end(),s);
		i=LIMIT+1;
		if(idx!=tri.end()){
			for(i=0;i<=LIMIT&&!ck(v);i++){
				l=v.size();
				for(j=0;j<l;j++)v[j]--;
				v.erase(remove(v.begin(),v.end(),0),v.end());
				v.push_back(l);
			}
		}
		printf("%d\n",i>LIMIT?-1:i);
	}
}

Measured memory_bytes: 1076
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

const int INF = 1e9;

signed main()
{
    Start();
    int n, x, y;
    cin >> n >> x >> y, --x, --y;
    vector <vector <int>> g(n);
    for (int i = 0; i + 1 < n; ++i)
        g[i].pb(i + 1), g[i + 1].pb(i);
    g[x].pb(y), g[y].pb(x);
    vector <int> ans(n - 1);
    for (int s = 0; s < n; ++s)
    {
        vector <int> d(n, INF);
        d[s] = 0;
        queue <int> q;
        q.emplace(s);
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            for (auto &to : g[v])
            {
                if (d[to] > d[v] + 1)
                {
                    d[to] = d[v] + 1;
                    q.emplace(to);
                }
            }
        }
        for (int to = s + 1; to < n; ++to)
            ans[d[to] - 1]++;
    }
    for (auto &i : ans)
        cout << i << endl;
    return 0;
}



Measured memory_bytes: 384
//  299143BT
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >AC
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

vll v,vsum;

void pre(){

}

void solve(){
   ll n=0;
   cin>>n;
   rep(i,n){
      ll x=0;
      cin>>x;
      v.pb(x);
   }
   vsum.assign(n,0);
   ll ans=0;
   vsum[n-1]=v[n-1];
   repD(i,n-2,0)
       vsum[i]=(vsum[i+1]+v[i])%MOD;
   rep(i,n-1){
       ans=(ans+((v[i]*vsum[i+1])%MOD))%MOD;
   }
   cout<<ans;
}

int main(){

    pre();
    solve();
    return 0;
}

Measured memory_bytes: 6320