akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

const int MAX_A = 100;
const int MAX_B = 1000;

int main() {
  int a, b;

  scanf("%d %d", &a, &b);
  // printf("%d %d ", a, b);
  if ((0 <= a) && (a <= 5)) {
    printf("0\n");
  } else if ((6 <= a) && (a <= 12)) {
    printf("%d\n", b/2);
  } else {
    printf("%d\n", b);
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define ji -
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
char s[150],a[150];
int n,ans;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);ans=n;
	fo(c,'a','z'){
		fo(i,1,n) a[i]=s[i];
		fd(l,n,1){
			bool ok=1;
			fo(j,1,l) if (a[j]!=c){
				ok=0;
				break;
			}
			if (ok){
				if (n-l<ans) ans=n-l;
				break;
			}
			fo(j,1,l-1) if (a[j+1]==c) a[j]=c;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<climits>

int main(){
    int N;
    scanf("%d%*c", &N);
    std::vector<int> array(N);
    std::vector<int> min_array(N); // min_array[i] : array[i]を含む以前にある最小値
    int min_val = INT_MAX;
    for(int i = 0; i < N; i++){
        scanf("%d%*c", &array[i]);
        if(min_val > array[i]){
            min_val = array[i];
        }
        min_array[i] = min_val;
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
        if(min_array[i] == array[i]) sum++;
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 1792
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.fold_left (fun (count, offset, s) a ->
    (*
     * s全体にaを加える代わり，offsetにaを加える
     * sの中身の真の値はoffsetを足したもの
     *)
    count + (try IntMap.find (~- offset) s with Not_found -> 0),
    offset + a,
    IntMap.add (~- offset) (1 + try IntMap.find (~- offset) s with Not_found -> 0) s) (0, 0, IntMap.empty) as_
  |> (fun (count, offset, s) -> 
      count + (try IntMap.find (~- offset) s with Not_found -> 0))
  |> Printf.printf "%d\n"



Measured memory_bytes: 16896
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>


int main() {
  int N, L;
  std::cin >> N >> L;
  
  std::vector<std::string> a;
  for (int i = 0; i < N; i++) {
    std::string tmp;
    std::cin >> tmp;
    a.push_back(tmp);
  }

  std::sort(a.begin(), a.end());

  std::string result("");
  for (int i = 0; i < N; i++) {
    result += a[i];
  }
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 2e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[MAX_N];
ll b[MAX_N];
ll cnt[MAX_N][4];

int main(){
    fastio;
    ll a,b,c,d;
  	cin>>a>>b>>c>>d;
  	ll j = 0;
  	while(1){
    	if(j%2==0){
        	c-=b;
          	if(c<=0) break;
        }
      	else{
          	a-=d;
          	if(a<=0) break;
        }
      j++;
    }
  	if(j%2==0) cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;

    
} 


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

int main(){
    int N,sum=0;
    cin >> N;
    int L[N*2];
    for(int i=0; i<N*2; ++i) cin >> L[i];
    sort(L,L+N*2);
    for(int i=0; i<N*2; i+=2) sum += L[i];
    cout << sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)









int main(){
    ll n;
    cin >> n;
    ll c = 1;
    REP(i, n){
        ll a;
        cin >> a;
        if(c == a){
            c++;
        }
    }
    cout << ((c != 1)? n - (c - 1) : -1) << endl;
}

Measured memory_bytes: 256
def main():
    # S = input()
    N = input()
    # S = list(map(int, input().split(' ')))
    # print(S, W)
    a = int(N[-1])
    
    A = [2,4,5,7,9]
    B = [0,1,6,8]
    C = [3]
    
    if a in A:
        print('hon')
    elif a in B:
        print('pon')
    elif a in C:
        print('bon')
    
    
    

main()

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

const double INF = 1E+9; 

struct cake {
    int w, d;
    int area() const { return w * d; }
    bool operator<(const cake& other) const {
        return area() < other.area();
    }
};


int main() {
    int n, w, d;
    while (cin >> n >> w >> d, n || w || d) {
        vector<cake> cs = {cake{w, d}};
        rep(i, n) {
            int p, s;
            cin >> p >> s;
            p--;
            cake c = cs[p], c1, c2;
            s %= (c.w + c.d);
            if (s < c.w) {
                c1 = cake{c.w - s, c.d};
                c2 = cake{s, c.d};
            } else {
                s -= c.w;
                c1 = cake{c.w, c.d -s};
                c2 = cake{c.w, s};
            }
            if (c1.area() > c2.area()) swap(c1, c2);
            cs.push_back(c1), cs.push_back(c2);
            cs.erase(cs.begin() + p);
        }
        sort(cs.begin(), cs.end());
        
        rep(i, cs.size()) {
            cout << cs[i].area();
            if (i != cs.size() -1) cout << " ";
        }
        cout << endl;
    }


    return 0;
}




Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
 
    double sum = 0.0;
    for (int i = 0; i < K; ++i) {
        sum += (p[i] + 1) / 2.;
    }
    double m = sum;
    for (int i = 0; i + K < N; ++i) {
        sum = sum - (p[i] + 1) / 2. + (p[i+K] + 1) / 2.;
        m = max(m, sum);
    }
    printf("%.9lf\n", m);
}

Measured memory_bytes: 1024
import java.util.*;                                                                                  

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] l = line.split(" ");
        double x1 = Double.parseDouble(l[0]);
        double y1 = Double.parseDouble(l[1]);
        double x2 = Double.parseDouble(l[2]);
        double y2 = Double.parseDouble(l[3]);

        double x = (double)x1 - x2; 
        double y = (double)y1 - y2; 

        double z = (double)Math.pow(x, 2) + Math.pow(y, 2); 
        double z2 = (double)Math.sqrt(z);

        System.out.println(z2);
    }   
}

Measured memory_bytes: 26200
#include <algorithm>
#include <math.h>
#include <map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Remaining_Balls(void) {

	string S, T;
	cin >> S >> T;

	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;

	if (S.compare(U) == 0)	A--;
	else					B--;

	cout << A << " " << B;
	return;
}

void B_I_Miss_You(void) {

	string S;
	cin >> S;

	for (int loop = 0; loop < S.size(); loop++) cout << "x";
	cout << flush;
	return;
}

void C_Distinct_or_Not(void) {

	int N;
	cin >> N;

	vector<int> A(N);
	for (int& loop : A) cin >> loop;
	sort(A.begin(), A.end());

	for (int loop1 = 0; loop1 < N - 1; loop1++) {
		if (A[loop1] == A[loop1 + 1]) {
			cout << "NO" << flush;
			return;
		}
	}
	cout << "YES" << flush;
	return;
}

void D_Dice_in_Line(void) {

	int N, K;
	cin >> N >> K;

	vector<int> p(N);
	for (int& it : p) cin >> it;

	int sum = 0;
	for (int loop = 0; loop < K; loop++) sum += p[loop];

	int sumMax = sum;
	for (int loop = 0; loop < N - K; loop++) {
		sum -= p[loop];
		sum += p[(loop + K)];
		sumMax = max(sum, sumMax);
	}

	cout << ((double)sumMax + (double)K) * 0.5 << flush;
	return;
}

void E_Almost_Everywhere_Zero(void) {

	string N;
	cin >> N;
	int K;
	cin >> K;

	int re = 0;
	int length = N.size();
	if (length > K) {

		switch (K) {
		case 1:
			re = length - 1;
			break;
		case 2:
			re = (length - 1) * (length - 2) / 2;
			break;
		case 3:
			re = length * (length - 1) * (length - 2);
			break;
		}
	}
	else {

		cout << 0 << flush;
		return;
	}
}

int main(void) {

	//A_Remaining_Balls();
	//B_I_Miss_You();
	C_Distinct_or_Not();
	//D_Dice_in_Line();
	return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

def calc(main,sub):
    if main%3==1:
        a=main//3
    else:
        a=main//3+1
    b=sub//2
    temp=[a*sub,(main-a)*b,(main-a)*(sub-b)]
    
    return max(temp)-min(temp)
        

if H%3==0 or W%3==0:
    print(0)
else:
    print(min(calc(H,W),calc(W,H),H,W))
    


Measured memory_bytes: 3060
n,a,b = map(int,input().split())
s = input()
y = 0
bn = 1
for i in range(n):
  if s[i] == "a" and y < a + b:
    print("Yes")
    y += 1
  elif s[i] == "b" and y < a + b and bn <= b:
    print("Yes")
    y += 1
    bn += 1
  else:
    print("No")

Measured memory_bytes: 9284
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
    return 0;
}



Measured memory_bytes: 2040
#include<iostream>
#include<cmath>
using namespace std;
#define int long long int
int32_t main()
{
	int x;
	cin>>x;
	if(x==0)
	{
		cout<<1<<" "<<1<<endl;
	}
	else
	{
		int j;
		for(j=1;j<=200;j++)
		{
			int val=pow(j,5);
			int need=val-x;
			bool result=false;
			if(need<0)
			{
				result=true;
				need*=-1;
			}
			bool found=false;
			int i;
			for(i=0;i<=200;i++)
			{
				int here=pow(i,5);
				if(here==need)
				{
					found=true;
					break;
				}
			}
			if(found)
			{
				if(result)
				{
					i*=-1;
				}
				cout<<j<<" "<<i<<endl;
				return 0;
			}
			
		}
	}
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <string>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;

	float  ans = n / 1.08;

	float  integral_part = 0;
	float fractional_part = std::modf(ans, &integral_part);

	if (fractional_part == 0.0) {
		cout << ans;
	}
	else {
		integral_part++;
		if ((int)(integral_part*1.08) == n) {
			cout << integral_part;
		}
		else {
			cout << ":(";
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC103C
{
    class ABC103C
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');

            var a = new List<int>();
            int max = 0;
            for (int i = 0; i < n; ++i)
            {
                max += int.Parse(input[i]) - 1;
            }
            
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n;
ll x[100100];
ll seg[100100*4];
void build(int cr,int s,int e)
{
    if(s==e)
    {
        seg[cr]=x[s];
        return;
    }
    build(cr*2,s,(s+e)/2);
    build(cr*2+1,(s+e)/2+1,e);
    seg[cr]=__gcd(seg[cr*2],seg[cr*2+1]);
}
int l;
ll get(int cr,int s,int e)
{
    if(l>e||l<s)
        return seg[cr];
    if(s==e)
        return 0;
    return __gcd(get(cr*2,s,(s+e)/2),
                 get(cr*2+1,(s+e)/2+1,e) );
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%lld",&x[i]);
        ll mx=0;
        build(1,1,n);
    for(int i=1;i<=n;i++)
    {
        l=i;

        mx=max(mx,get(1,1,n));
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <cstring>
#include <algorithm>

int table[1001][1001];

int lcs(char *x, char *y){
    int i, j, lx, ly;
    lx = strlen(x+1);
    ly = strlen(y+1);
    for(i=1;i<=lx;i++){
        for(j=1;j<=ly;j++){
            if(x[i]==y[j])table[i][j] = table[i-1][j-1] + 1;
            else table[i][j] = std::max(table[i][j-1],table[i-1][j]);
        }
    }
    return table[lx][ly];
}

int main(){
    int i, j, q;
    char x[1002],y[1002];
    scanf("%d",&q);
    for(i=0;i<1001;i++){
        table[i][0] = 0;
    }
    for(j=0;j<1001;j++){
        table[0][j] = 0;
    }
    for(i=0;i<q;i++){
        scanf("%s %s",x+1,y+1);
        printf("%d\n",lcs(x,y));
    }
    return 0;
}



Measured memory_bytes: 6652
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	if(n%2==0):
		print(n)
	else:
		print(2*n)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 63852
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

// dp[i] TRUE if the first player  wins if there are i stones remaining

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i= 0; i< n; ++i)
    {
        cin >> v[i];
    }

    vector<bool> dp(k+1);

    for(int stones = 0; stones <= k; ++stones)
    {
        for(int x : v)
        {
            if(stones >= x && !dp[stones-x])
     
            {
                dp[stones] = true;
            }
        }

    }

    puts(dp[k] ? "First" : "Second");
 

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define N 200050
#define INF 1000000007LL
#define ri register int
using namespace std;
int n,m,w[N];
int siz[N],vis[N];
int f[N];
vector<int> to[N],len[N];

struct edge{
  int u,v;
	long long l;
  bool operator < (const edge &rhs) const {
	  return l<rhs.l;
	}
} e[N*50];

int findrt(int x) {
  if (f[x]==x) return x;
	return f[x]=findrt(f[x]);
}

void findroot(int x,int ff,int &rt,int &rts,int tot) {
  int curs=0;
	siz[x]=1;
	for (ri i=0,l=to[x].size();i<l;i++) if (to[x][i]!=ff && !vis[to[x][i]]) {
	  findroot(to[x][i],x,rt,rts,tot);
		siz[x]+=siz[to[x][i]];
	  if (siz[to[x][i]]>curs) curs=siz[to[x][i]];
	}
	if (tot-siz[x]>curs) curs=tot-siz[x];
	if (curs<rts) rts=curs,rt=x;
}

void findP(int x,int ff,int &P,long long &pd,long long pred) {
  if (pred+w[x]<pd) pd=pred+w[x],P=x;
	for (ri i=0,l=to[x].size();i<l;i++) if (to[x][i]!=ff && !vis[to[x][i]]) {
	  findP(to[x][i],x,P,pd,pred+len[x][i]);
  }
}

void link(int x,int ff,int P,long long pred) {
  e[++m]=(edge){x,P,pred+w[x]};
	for (ri i=0,l=to[x].size();i<l;i++) if (to[x][i]!=ff && !vis[to[x][i]]) {
	  link(to[x][i],x,P,pred+len[x][i]);
	}
}

void tonji(int x,int ff,int &tot){
  tot++;
	for (ri i=0,l=to[x].size();i<l;i++) if (to[x][i]!=ff && !vis[to[x][i]]) tonji(to[x][i],x,tot);
}

void solve(int x){
  vis[x]=1;
	int p=-1;
	long long pd=INF*INF;
	findP(x,-1,p,pd,0LL);
	link(x,-1,p,pd);
	for (ri i=0,l=to[x].size();i<l;i++) if (!vis[to[x][i]]) {
		int tot=0;
		tonji(to[x][i],x,tot);
	  int rt=-1,rts=tot;
		findroot(to[x][i],x,rt,rts,tot);
		solve(rt);
	}
}

int main() {
	int a,b,c;
  scanf("%d",&n);
	for (ri i=1;i<=n;i++) scanf("%d",&w[i]);
	for (ri i=1;i<n;i++) {
		scanf("%d %d %d",&a,&b,&c);
		to[a].push_back(b); len[a].push_back(c);
		to[b].push_back(a); len[b].push_back(c);
	};
	int rt=-1,rts=n;
	findroot(1,-1,rt,rts,n);
	solve(rt);
	sort(e+1,e+m+1);
	long long ans=0;
	for (ri i=1;i<=n;i++) f[i]=i;
	for (ri i=1;i<=m;i++) {
	  int r1=findrt(e[i].u),r2=findrt(e[i].v);
		if (r1==r2) continue;
		ans+=e[i].l;
		f[r1]=r2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 97920
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long X;
	cin >> X;
	long long i,j;
	for(i = 0;i < 100;i++)
	{
		for(j = 0;j < 100;j++)
		{
			if(i*i*i*i*i+j*j*j*j*j == X)
			{
				cout << i << ' ' << -j << endl;
				return 0;
			}
		}
	}
	for(i = 0;i < 10000;i++)
	{
		for(j = 0;j < 10000;j++)
		{
			if(i*i*i*i*i-j*j*j*j*j ==X)
			cout << i << ' ' << j << endl;
		}
	}
	return 0;
}
			

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

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

  map<int, int> mp;
  rep(i,0,N-1) {
    int a;
    cin >> a;
    mp[a]++;
  }

  int ans = 0;
  for (auto p : mp) {
    if (p.first <= p.second) ans += p.second - p.first;
    else ans += p.second;
  }

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


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

#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
    int n,m,c;
    cin >> n >> m >> c;

    vector<int> b(m);
    int tmp;
    rep(i, m) {
        cin >> tmp;
        b[i] = tmp;
    }

    int a;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            cin >> a;
            sum += a * b[j];
        }
        sum += c;
        if (sum > 0) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll    long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

ll dp[500][500];

ll sum1(ll	a[], ll x, ll b) {

	ll s = 0;
	for (ll i = x; i <= b; i++) {
		s += a[i];
	}
	return s;
}


ll solve1(ll a[], ll i, ll j) {

	if (i > j) {
		return 0;
	}

	if (dp[i][j] != -1) {
		return dp[i][j];
	}
	if (i == j) {
		return dp[i][j] = 0;
	}

	ll mn = inf;
	for (ll k = i; k <= j - 1; k++) {

		ll temp = solve1(a, i, k) + solve1(a, k + 1, j) + sum1(a, i, j);
		mn = min(mn, temp);
	}

	return dp[i][j] = mn;
}
void solve() {

	ll n;
	cin >> n;
	ll a[n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve1(a, 0, n - 1);


}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int maxm = 2e5 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;
int n;
int s[107];
int ans ;
int sum ;
int main(int argc, char const *argv[])
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &s[i]);
    for(int i=1;i<=100000;i++)
    {

        random_shuffle(s + 1, s + 1 + n);
        sum = 0;
        for (int i = 1; i <= n; i++)
        {
            sum += s[i];
            if (sum % 10 == 0)
                continue;
            ans = max(ans, sum);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

#define ll long long
#define ld long double
#define MOD (1000000000+7)
using namespace std;

ll fact(ll a)
{
    ll answ = 1;
    for (ll i = 1; i <= a; i++)
        answ = (answ * i) % MOD;
    return answ;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;
    cin >> n >> m;
    if (n < m) swap(n,m);
    if (abs(m-n) >= 2)
    {
        cout << 0 << endl;
        return 0;
    }
//    ll c = fact(n)/(fact(m)*fact(n-m)) % MOD;
    if (n != m) cout << (fact(n)*fact(m)) % MOD << endl;
    else
        cout <<(2*fact(n)*fact(m)) % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val s = readLine()

  println(if (s == "ABC") "ARC" else "ABC")
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 54496
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    ll n; int ga, sa, ba, gb, sb, bb;
    cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
    
    int w[] = {ga, sa, ba, gb, sb, bb}, v[] = {gb - ga, sb - sa, bb - ba, ga - gb, sa - sb, ba - bb};
    vector<vector<ll>> dp1(4, vector<ll>(n + 1, -INF));
    dp1[0][0] = 0;
    rep(i, 3) rep(j, n + 1) {
        if (dp1[i][j] == -INF) continue;
        chmax(dp1[i + 1][j], dp1[i][j]);
        if (j < n) chmax(dp1[i][j + 1], dp1[i][j]);
        if (j + w[i] <= n) chmax(dp1[i][j + w[i]], dp1[i][j] + v[i]);
    }
    n += dp1[3][n];
    vector<vector<ll>> dp2(4, vector<ll>(n + 1, -INF));
    dp2[0][0] = 0;
    rep(i, 3) rep(j, n + 1) {
        if (dp2[i][j] == -INF) continue;
        chmax(dp2[i + 1][j], dp2[i][j]);
        if (j < n) chmax(dp2[i][j + 1], dp2[i][j]);
        if (j + w[i + 3] <= n) chmax(dp2[i][j + w[i + 3]], dp2[i][j] + v[i + 3]);
    }
    n += dp2[3][n];
    
    cout << n << "\n";
    return 0;
}


Measured memory_bytes: 979940
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

lint mod = 998244353;
lint pow(lint a, lint n){
    lint res = 1;
    lint base = a;
    while(n > 0){
        if (n%2) res = res*base%mod;
        base = base*base%mod;
        n = n/2;
    }
    return res;
}

lint rev(lint a){
    return pow(a, mod-2);
}

lint comb(lint n, lint m, vl &la, vl &rela){
    return (la[n] * rela[m] % mod) * rela[n-m] % mod;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    lint n,m,k;
    cin>>n>>m>>k;

    vl la(n+1, 1);
    for (int i=1; i<=n; ++i) la[i] = la[i-1]*i%mod;

    vl rela(n+1);
    rela[n] = rev(la[n]);
    for (int i=n; i>=1; --i) rela[i-1] = rela[i] * i % mod;

    lint res = 0;

    for (int i = 0; i<=k; ++i){
        res = (res + (comb(n-1, i, la, rela) * m % mod) *  pow(m-1, n-1-i))%mod;
    }

    cout<<res;

}


Measured memory_bytes: 6272
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
l=[]
for i in range(n-1):
  l.append(list(map(int,input().split())))
l2=[]
for i in range(q):
  l2.append(list(map(int,input().split())))
connection=[]
for i in range(n):
  connection.append([])
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
 
L4=[0]*n
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
distance=[0]*n
distance[0]=L4[0]

L=[0]
L2=[]
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    for k in range(len(connection[L[j]])):
      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]
      L3.append(connection[L[j]][k])
    L2.append(L[j])
  L=L3
  L3=[]
for i in range(len(distance)):
  distance[i]=str(distance[i])
print(' '.join(distance))

Measured memory_bytes: 148924
#include <cstdio>
struct data
{
	double t, v; 
} que[500005]; 
int main()
{
	// freopen("ARC072-F.in", "r", stdin); 
	int n, lim, he = 1, ta = 0; 
	double sum_v = 0, sum_t = 0; 
	scanf("%d%d", &n, &lim); 
	for (int i = 0; i < n; i++)
	{
		data x; 
		scanf("%lf%lf", &x.t, &x.v); 
		sum_v += x.v; 
		sum_t += x.v * x.t; 
		while (lim < sum_v)
		{
			if (sum_v - lim >= que[he].v)
			{
				sum_t -= que[he].v * que[he].t;
				sum_v -= que[he++].v; 
			}
			else
			{
				sum_t -= que[he].t * (sum_v - lim); 
				que[he].v -= sum_v - lim; 
				sum_v = lim; 
			}
		}
		printf("%.8lf\n", sum_t / sum_v);
		while (he <= ta && que[ta].t >= x.t)
		{
			x.t = (que[ta].t * que[ta].v + x.t * x.v) / (que[ta].v + x.v); 
			x.v += que[ta].v; 
			ta--; 
		}
		que[++ta] = x; 
	}
	return 0; 
}


Measured memory_bytes: 17280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //  //   freopen("output.txt", "w", stdout);
    //  //  freopen("error.txt", "w", stderr);
    // #endif
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int a = 0;
    rep(i, 0, n)
    {
        if (s[i] != t[i])
            a++;
    }
    cout << a << endl;
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  set<string> mp;
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep (i, n) {
    vector<string> add;
    if (mp.count(s.substr(i, 1)) == 0) add.push_back(s.substr(i, 1));
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
      string t = *itr;
      if (t.size() == 3) continue;
      t += s[i];
      if (mp.count(t) == 0) add.push_back(t);
    }
    rep (i, add.size()) mp.insert(add[i]);
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    string t = *itr;
    if (t.size() == 3) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
const double PI = 3.141592653589793238460;
  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}
int main()
{
   
  c_p_c();

  string s,t;
  cin>>s>>t;int cnt=0;
  for(int i=0;i<s.length();i++)
    {
      if(s[i]!=t[i])
        cnt++;
    }
    cout<<cnt<<endl;
 
 
 
 





  



  

  return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010
ll n,a,b,h[M],p[M];
vll g[M];
void dfs(ll u,ll p=-1){
	ll t=0;
	for(auto v:g[u]){
		if(v==p or h[v]!=-1)continue;
		dfs(v,u);
		t=max(t,h[v]+1);
	}
	h[u]=t;
}
int main(){
	IOS;
	cin>>n>>a>>b;
	rep(i,0,n)h[i]=-1,p[i]=i;
	a--,b--;
	rep(i,0,n-1){
		ll u,v;cin>>u>>v;u--,v--;
		g[u].pb(v),g[v].pb(u);
	}
	dfs(b);
	queue<ll>q;
	q.push(b);
	while(!q.empty()){
		ll u=q.front();q.pop();
		for(auto v:g[u]){
			if(p[v]==v){
				p[v]=u;
				if(v==a)break;
				q.push(v);
			}
		}
	}
	vll path;
	ll u=a;
	while(u!=b)path.pb(u),u=p[u];
	path.pb(b);
	ll t=0,i=0,j=sz(path)-1,dif;
	while(1){
		if(i+1<j-1)i++,j--,t++;
		else {
			dif=(j-i);
			break;
		}
	}
	ll ht=h[path[i]];
	if(dif==1)t+=(ht);
	else t+=(ht+1);
	cout<<t;
	return 0;
} 


Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 2
acp
ae
)");
#define cin input
#endif

// Recursive function to return gcd of a and b  
ll gcd(ll a, ll b)  
{  
    // Everything divides 0  
    if (a == 0 || b == 0)  
        return 0;  
  
    // Base case     
    if (a == b)  
        return a;  
  
    // a is greater  
    if (a > b)  
        return gcd(a-b, b);  
    return gcd(a, b-a);  
}  
  
int main()
{
	ll n, m;
	cin >> n >> m;

	string s, t;
	cin >> s >> t;

	ll d = gcd(n, m);

	ll r = n * m / d;

	for (ll i = 0; i < d; ++i)
		if (s[i * n / d] != t[i * m / d])
			r = -1;

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 888
# 2019-11-25 06:26:24(JST)
import sys

def main():
    s, k = sys.stdin.read().split()
    k = int(k)

    if len(s) == 1:
        print(k // 2)
        sys.exit()
    
    if s.count(s[0]) == len(s):
        if len(s) % 2 == 0:
            ans = len(s) // 2 * k
        else:
            # if k % 2 == 0:
            ans = len(s) * k // 2
            # else:
            #     ans = len(s) // 2 * (k // 2 + 1) + (len(s) // 2 + 1) * k // 2
        print(ans)
        sys.exit()

    count = 0
    same = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            same += 1
        else:
            if count == 0:
                first_same = same
            count += same // 2
            same = 1
    
    bl = False
    if s[-1] == s[0]:
        if same % 2 == 1 and first_same % 2 == 1:
            count += same // 2 + 1
            bl = True
        else:
            count += same // 2
    else:
        count += same // 2

    ans = count * k
    if bl:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] == i + 1) {
      res++;
      i++;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MP(a, b)  make_pair(a, b)

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

int main(){
    int n , m;
    cin >> n >> m;
    ll a = max(n, m), b = min(n, m);
    ll res = 0;
    if(a == 1 && b == 1)res = 1;
    else if (b == 1)res = max(res, a - 2);
    else if (b >= 2){
        res = a * b - 2 * a - 2 *(b - 2);
    }
    cout << res << endl;
    return 0;
}

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

int main() {

    int N,i,max,total=0;
    int p[11];

    cin >> N;
    for(i=1;i<=N;i++){
        cin >> p[i];
    }

    max=p[1];

    for(i=1;i<=N;i++){
        if(max<p[i]){
            max=p[i];
        }
    total=total + p[i];    
    }

    total = total - max/2;

    cout << total << endl;



}


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

int main(){
	string str;
	int q, l;
	deque<char> de;
	deque<char> :: iterator it;
	cin >> str >> q;
	l = str.size();
	for(int i = 0; i < l; i++)
		de.push_back(str[i]);

	bool f = false;
	int t, c;
	char s;
	for(int i = 0; i < q; i++){
		scanf("%d",&t);
		if(t == 1) f = !f;
		else if(t == 2){
			scanf("%d %c", &c, &s);
			if(!f){
				if(c == 1) de.push_front(s);
				else if(c == 2) de.push_back(s);
			}
			else {
				if(c == 2) de.push_front(s);
				else if(c == 1) de.push_back(s);				
			}
		}
	}
	if(!f){
		for(it = de.begin(); it != de.end(); it++)
			printf("%c", *it);		
	}
	else{
		for(it = de.end() - 1; it != de.begin() - 1; it--)
			printf("%c", *it);			
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W, N;
int a[100010], b[100010];
map<pii, int> mp;
int cnt[10];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    for (int y = 0; y < 3 && a[i]+y < H; y++) {
      for (int x = 0; x < 3 && b[i]+x < W; x++) {
        mp[pii(a[i]+y, b[i]+x)]++;
      }
    }
  }
  for (auto p : mp) {
    if (p.first.first >= 2 && p.first.second >= 2) {
      cnt[p.second]++;
    }
  }
  int sum = accumulate(cnt+1, cnt+10, 0);
  cout << (ll)(H-2)*(W-2) - sum << endl;
  for (int i = 1; i < 10; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 57344
#![allow(dead_code, unused_imports, deprecated)]
 
use std::collections::HashMap;
use std::cmp::Reverse;
 
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

use maplit::*;

#[fastout]
fn main() {
  input!{
    n: Bytes,
  };

  if n.iter().any(|&c| c == b'7') {
    println!("Yes");
  } else {
    println!("No");
  }
}

Measured memory_bytes: 2152
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
int main() {
	int n, q;
	cin >> n >> q;
	dsu d(n);
	for (int i = 0; i < q; i++) {
		int s, t, u;
		cin >> s >> t >> u;
		if (s == 0)
			d.merge(t, u);
		else {
			if (d.same(t, u))
				cout << 1 << endl;
			else
				cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4048
def main():
    N = int(input())
    A = [int(n) for n in input().split()]

    A = sorted(A, reverse=True)
    Alice = 0
    Bob = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            Alice += a
        else:
            Bob += a
    print(Alice - Bob)


main()


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,x,sum=0;
	cin >> n >> m;
	for(i=0;i<m;i++)
	{
		cin >> x;
		sum += x;
	}
	if((n-sum)<0)
		cout << -1;
	else
		cout << n-sum;
	cout  << endl;
	return 0;
}

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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
VI a;





int main()
{

	cin >> N;
	a.resize(3*N);
	REP(i,3*N){
		cin >> a[i];
	}

	sort(a.begin(),a.end(),greater<int>());

	long long ans = 0;

	for(int i=0;i<N*2;i+=2)
		ans += (long long) a[i+1];

	cout << ans << endl;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{ int to, cost;};
typedef pair<int,int> P;
int n;
int v[22],c[22];
signed main(){
	cin>>n;
	int ans=0;
	rep(i,n)cin>>v[i];
	rep(i,n)cin>>c[i];
	
	rep(i,n)if(v[i]>c[i])ans+=v[i]-c[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
MOD = 924844033

def pow_mod(a, n)
  ret = 1
  while n != 0 do
    if n % 2 == 1 then
      ret = ret * a % MOD
    end
    a = a * a % MOD
    n /= 2
  end
  ret
end

def list_to_int(data, first, last)
  if last - first == 1 then
    data[first]
  else
    middle = (first + last) / 2
    sub_first = list_to_int(data, first, middle)
    sub_last = list_to_int(data, middle, last)
    sub_first + (sub_last << (middle - first) * 80)
  end
end

def int_to_list(data, first, last, ret)
  if first < ret.length then
    if last - first == 1 then
      ret[first] = data
    else
      middle = (first + last) / 2
      first_width = (middle - first) * 80
      sub_first = int_to_list(data & ((1 << first_width) - 1), first, middle, ret)
      sub_last = int_to_list(data >> first_width, middle, last, ret)
    end
  end
end

def get_graph()
  input_array = STDIN.read.split
  n = input_array[0].to_i
  graph = Array.new(n){[]}
  for i in 1..(n - 1)
    a = input_array[i * 2 - 1].to_i - 1
    b = input_array[i * 2].to_i - 1
    graph[a] << b
    graph[b] << a
  end
  [n, graph]
end

def get_size_dist()
  n, graph = get_graph()

  size_table = [1] * n
  ret = 0
  stack = [nil, 0, 0]

  while stack.length > 1 do
    node = stack[-1]
    index = stack[-2]
    size_table[node] += ret
    if index < graph[node].length then
      dtr = graph[node][index]
      stack[-2] += 1
      if dtr != stack[-3] then
        stack.push(0, dtr)
      end
      ret = 0
    else
      stack.pop(2)
      ret = size_table[node]
    end
  end

  size_dist = [0] * n
  size_table.each{|s|
    if s != n then
      size_dist[s - 1] += 1
      size_dist[n - s - 1] += 1
    end
  }
  [n, size_dist]
end


n, answer = get_size_dist()

$fac = [0] * (n + 1)
$fac[0] = 1
for i in 1..n
  $fac[i] = $fac[i - 1] * i % MOD
end

$ifac = [0] * (n + 1)
$ifac[n] = pow_mod($fac[n], MOD - 2)
n.downto(1).each{|i|
  $ifac[i - 1] = $ifac[i] * i % MOD
}

def comb(x, y)
  $fac[x] * $ifac[y] % MOD * $ifac[x - y] % MOD
end

for i in 0..(n - 1)
  answer[i] = answer[i] * $fac[i + 1] % MOD
end
answer.reverse!

ifac_int = list_to_int($ifac.slice(0, n), 0, n)
answer_int = list_to_int(answer, 0, n)
answer_int *= ifac_int
int_to_list(answer_int, 0, n + 1, answer)

answer.reverse!
for i in 0..(n - 1)
  a = n * comb(n, i + 1)
  b = answer[i] * $ifac[i + 1]
  answer[i] = (a - b) % MOD
end

puts answer.join("\n")


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

int main(){
  long a, b;
  long ca, cb, tmp;
  long gcd, lcm;

  while(cin >> a){
    cin >> b;
    ca=a; cb=b;

    if(ca<cb){
      tmp=ca; ca=cb; cb=tmp;
    }

    while(cb!=0){
      ca%=cb;
      if(ca==0){
        ca=cb;
        break;
      }
      cb%=ca;
    }
    gcd=ca;
    lcm=a/gcd*b;

    printf("%ld %ld\n", gcd, lcm);
  }

  return 0;
}

Measured memory_bytes: 0