akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

long long  doWork(vector< vector<long long > > &dp,long long  x,long long  y){

	if(x>=dp.size() || y>=dp[0].size()){
		return 0;
	}

	if(dp[x][y]==-1)
		return 0;

	if(dp[x][y]!=-1 && dp[x][y]!=0){
		return dp[x][y];
	}

	return (dp[x][y] = (doWork(dp,x+1,y)%mod + doWork(dp,x,y+1)%mod)%mod);
}

int  main(){

	long long  n,m;
	cin >> n >> m;

	char temp;

	vector< vector<long long > > dp( n, vector<long long >(m,0) );
	dp[n-1][m-1]=1;

	for(long long  i=0;i<n;i++){
		for(long long  j=0;j<m;j++){
			cin >> temp;
			if(temp=='#'){
				dp[i][j]=-1;
			}

		}
	}

	//doWork(dp,0,0);

	for(int i=n-1;i>=0;i--){
		for(int j=m-1;j>=0;j--){
			if(dp[i][j]==-1)
				continue;
			if(i+1<n && dp[i+1][j]!=-1){
				dp[i][j] = (dp[i][j]%mod + dp[i+1][j]%mod)%mod;
			}
			if(j+1<m && dp[i][j+1]!=-1){
				dp[i][j] = (dp[i][j]%mod + dp[i][j+1]%mod)%mod;
			}
		}
	}

	cout << dp[0][0] << "\n";

	return 0;
}

Measured memory_bytes: 8064
#include<iostream>

using namespace std;

int main(){
  string s,b,w;
  int i,c=0,k=0;
  cin>>s;
  for(i=0;b.size()<s.size();i+=2){
    b+="10";
    w+="01";
  }
  for(i=0;i<s.size();i++){
    if(s[i]!=b[i]) c++;
    if(s[i]!=w[i]) k++;
  }
  if(c<k) cout<<c<<endl;
  else cout<<k<<endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>

using namespace std;

struct Union_find{
	vector<int> par;
	vector<int> rank;
	Union_find(int p){
		par = vector<int>(p + 1);
		rank = vector<int>(p + 1);
		for(int i = 1; i <= p; i++){
			par[i] = i;
		}
	}
	int find(int x){
		if(par[x] == x)
			return x;
		else{
			return par[x] = find(par[x]);
		}
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	vector<int> a(m), b(m);
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < m; i++){
		Union_find uf(n);
		for(int j = 0; j < m; j++){
			if(i == j) continue;
			uf.unite(a[j], b[j]);
		}
		int root = uf.find(1);
		for(int j = 2; j <= n; j++){
			if(root != uf.find(j)){
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var a, b, c, d int

func main() {
	tmp := NextIntsLine()
	a, b, c, d = tmp[0], tmp[1], tmp[2], tmp[3]
	if a*b >= c*d {
		fmt.Println(a * b)
	} else {
		fmt.Println(c * d)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int h[5],n[3];

int main(){
	while(cin>>h[0]>>h[1]>>h[2]>>h[3]>>h[4]){
		fill(n,n+3,0);
		for(int i=0;i<5;i++)n[h[i]-1]++;
		if(n[0]==5||n[1]==5||n[2]==5||n[0]&&n[1]&&n[2])cout<<"3\n3\n3\n3\n3\n";
		else{
			if(!n[0])for(int i=0;i<5;i++){
				if(h[i]==2)cout<<"1\n";
				else cout<<"2\n";
			}
			if(!n[1])for(int i=0;i<5;i++){
				if(h[i]==3)cout<<"1\n";
				else cout<<"2\n";
			}
			if(!n[2])for(int i=0;i<5;i++){
				if(h[i]==1)cout<<"1\n";
				else cout<<"2\n";
			}
		}
	}
}

Measured memory_bytes: 0
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};


int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	REP(i, 0, SIZE(s) - 1) {
		if (s[i] == 'a') {
			continue;
		}
		ll tmp = 'z' - s[i] + 1;
		if (tmp <= k) {
			k -= tmp;
			s[i] = 'a';
		}
	}
	if (k > 0) {
		k %= 26;
		ll tmp = s[SIZE(s) - 1] - 'a' + k;
		tmp %= 26;
		s[SIZE(s) - 1] = 'a' + tmp;
	}
	cout << s << endl;
}

Measured memory_bytes: 512
a = input().split()
tg = a[0]
ok_nums = set(str(i) for i in range(10))
ng_nums = set(i for i in input().split())
ok_nums = ok_nums - ng_nums
rt = 0
i = int(tg)
while True:
  if ok_nums >= set(d for d in str(i)):
    print(i)
    break
  else:
    i+=1
 


Measured memory_bytes: 9172
import math
a, b, h, m = map(int, input().split())

time = h * 60 + m
hh = time * (360 / (12 * 60))
mm = time * (360 / 60)
deg = min(abs(hh - mm), 360 - abs(hh - mm))

ans = a * a + b * b - 2 * a * b * math.cos(math.radians(deg))

print(math.sqrt(ans))


Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
LL K;
LL z;
vector<LL> as, bs;

LL Count(LL x) {
  LL ret = z*(N-1)*2 - z*(z-1);
  for (LL a : as) {
    ret += lower_bound(all(as), x/a+1) - as.begin();
    if (a*a <= x) ret--;
  }
  for (LL a : bs) {
    ret += lower_bound(all(bs), x/a+1) - bs.begin();
    if (a*a <= x) ret--;
  }
  assert(ret%2 == 0);
  return ret/2;
}

LL Count2(LL x) {
  LL ret = 0;
  for (LL a : as) {
    ret += bs.end() - lower_bound(all(bs), -x/a+(-x%a != 0));
    //cout << x << "," << a << ": " << ret << endl;
  }
  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N >> K;

  LL p = 0;
  LL q = 0;
  rep(i, N) {
    LL a;
    cin >> a;
    if (a > 0) {
      p++;
      as.eb(a);
    } else if (a < 0) {
      bs.eb(-a);
      q++;
    } else z++;
  }
  sort(all(as));
  sort(all(bs));

  if (p*q < K) {
    LL low = -1;
    LL high = 1000000000000000001;
    while (high - low > 1) {
      LL mid = (high+low)/2;
      if (Count(mid) < K-p*q) low = mid;
      else high = mid;
    }
    cout << low+1 << endl;
  } else {
    LL low = -1000000000000000001;
    LL high = 0;
    while (high - low > 1) {
      LL mid = (high+low)/2;
      if (Count2(mid) < K) low = mid;
      else high = mid;
    }
    cout << low+1 << endl;
  }
}


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

const int SIZE=4*1e5;
using Bit=bitset<SIZE>;
int main(){
    int n,r;
    cin>>n>>r;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin>>p[i],p[i]--;

    map<int,int> mp;
    vector<int> used(n);
    for(int i=0;i<n;i++){
        if(!used[i]){
            used[i]=true;
            int v=p[i];
            int cnt=1;
            while(v!=i){
                used[v]=true;
                v=p[v];
                cnt++;
            }
            mp[cnt]++;
        }
    }

    vector<pair<int,int>> item(mp.begin(),mp.end());
    int sz=item.size();
    vector<Bit> dp(sz+1);

    dp[0][0]=1;
    for(int i=0;i<sz;i++){
        int x=item[i].first;
        int cnt=item[i].second;
        for(int j=0;j<x;j++){
            int piyo=0;
            for(int k=j;k<=n;k+=x){
                if(dp[i][k]) piyo=cnt+1;
                dp[i+1][k]=(dp[i+1][k]||(piyo>0));
                piyo--;
            }
        }
    }
    cout<<(dp[sz][r] ? "Yes" : "No")<<endl;
    
    
    return 0;
}


Measured memory_bytes: 42920
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
from heapq import heappush, heappop, heapify
import sys
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

MOD = 10**9 + 7
memo = {}
banned = {'ACTG', 'TCAG', 'GCAG', 'TACG', 'AACG', 'ACAG', 'GAGC', 'CACG', 'AGC', 'ATCG', 'ACCG', 'CAG', 'GACG', 'CCAG', 'AAGC', 'ACG', 'TAGC'}

def dp(letters, state):
    if state in banned:
        return 0
    if letters == 0:
        return 1
    if (letters, state) in memo:
        return memo[letters, state]
    
    ans = 0
    for c in 'ACGT':
        ans += dp(letters - 1, (state + c)[-4:])
        ans %= MOD
    ans %= MOD
    memo[letters, state] = ans
    return ans

print(dp(rri(), ''))


Measured memory_bytes: 9012
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int N;
void dfs(int n, vvi& es, vi& lb, int num) {
    if (n >= N) return;
    if (lb[n] > 0) return;
    lb[n] = num;
    for (int i : es[n]) {
        dfs(i, es, lb, num);
    }
}


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

    int K, L; cin >> N >> K >> L;
    vi P(K), Q(K);
    REP(i, K) {
        cin >> P[i] >> Q[i];
        P[i]--; Q[i]--;
    }
    vi R(L), S(L);
    REP(i,L) {
        cin >> R[i] >> S[i];
        R[i]--; S[i]--;
    }


    vvi rd(N);
    REP(i,K) {
        rd[P[i]].push_back(Q[i]);
        rd[Q[i]].push_back(P[i]);
    }
    vi lrd(N,0);
    int num = 1;
    REP(i,N) {
        if (lrd[i] > 0) continue;
        dfs(i, rd, lrd, num);
        num++;
    }

    vvi rl(N);
    REP(i,L) {
        rl[R[i]].push_back(S[i]);
        rl[S[i]].push_back(R[i]);
    }
    vi lrl(N,0);
    num = 1;
    REP(i,N) {
        if (lrl[i] > 0) continue;
        dfs(i, rl, lrl, num);
        num++;
    }

    map<pii, int> mp;
    REP(i,N) {
        mp[pii(lrd[i], lrl[i])]++;
    }

    vi ans(N);
    REP(i,N) {
        ans[i] = mp[pii(lrd[i], lrl[i])];
    }

    cout << ans[0];
    FOR(i, 1, N) cout << " " << ans[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 30080
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long long int>v(n+1,0);
    v[0] = 2;
    v[1] = 1;

    for(int i = 2;i <= n;i++){
        v[i] = v[i-2]+v[i-1];
    }

    cout << v[n] << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt(),m=sc.nextInt();
	  List<List<Integer>> lists = new ArrayList<>();
	  for(int i=0;i<n;i++) {
		  List<Integer> l = new ArrayList<>();
		  lists.add(l);
	  }
	  for(int i=0;i<m;i++) {
		  int buff1=sc.nextInt()-1,buff2=sc.nextInt()-1;
		  lists.get(buff1).add(buff2);
		  lists.get(buff2).add(buff1);
	  }
	  int[] dist=new int[n];
	  Arrays.fill(dist, -1);
	  ArrayDeque<Integer> dq = new ArrayDeque<>();
	  dist[0]=0;
	  dq.add(0);
	  while (dq.size() > 0) {
	  	int p = dq.removeFirst();
		for (int i=0; i<lists.get(p).size(); i++) {
			if(dist[lists.get(p).get(i)]!=-1)continue;
			dist[lists.get(p).get(i)]=p+1;
			dq.add(lists.get(p).get(i));
		}
	  }
	  System.out.println("Yes");
	  for(int i=1;i<n;i++) {
	  	System.out.println(dist[i]);
	  }
  }
}

Measured memory_bytes: 74540
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> C;
  REP(i,N){
    ll c;
    cin>>c;
    C.PB(c);
  }
  SORT(C);
  
  ll RUI=1;
  REP(i,N-1){
    RUI*=4;
    RUI%=MOD;
  }
  
  REP(i,N){
    ans+=C[i]*(N-i+1);
    ans%=MOD;
  }
  
  ans*=RUI;
  ans%=MOD;
  co(ans);
  return 0;
}

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



int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    ll cnt=0;
    for (long long i = 0; i < S.length(); i++) {
        if(S[i]!=T[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

string shuffle(string s, int n) {
  return s.substr(n, s.length()-n) + s.substr(0, n);
}

int main(void) {
  while(1) {
    string s;
    cin >> s;

    if(s == "-") break;

    int m;
    cin >> m;

    int h;
    rep(_, m) {
      cin >> h;
      s = shuffle(s, h);
    }

    cout << s << endl;
  }
}



Measured memory_bytes: 3156
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   int N;
   int tai,hua;
   tai=hua=0;
   cin>>N;
   while(N--)
   {
     string a,b;
     cin>>a>>b;
     if(a>b) tai+=3;
     else if(a==b) 
     {
       tai+=1;
       hua+=1;     
     }        
     else hua+=3;       
   }
   cout<<tai<<" "<<hua<<endl;
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <algorithm>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
typedef long long ll;
const int man=100005;
int n,m;
int a[man];
map<int,int> q1;
map<int,int> q2;
int p1[100005];
int p2[100005];
int cnt1,cnt2;
int main()
{
   //freopen("in.txt","r",stdin);
   cin>>n;
   for(int i=1;i<=n;i++)
    cin>>a[i];
   for(int i=1;i<=n;i++)
   {
       if(i%2)
           q1[a[i]]++;
       else
           q2[a[i]]++;
   }
   int ans=0;
   map<int,int> ::iterator it;
   for(it=q1.begin();it!=q1.end();it++ )
   {
      if(ans<it->second)
      {
          cnt1=0;
          ans=it->second;
          p1[cnt1++]=it->first;
      }
      else if(ans==it->second)
      {
          p1[cnt1++]=it->first;
      }
   }
   int ans2=0;
   for(it=q2.begin();it!=q2.end();it++ )
   {
      if(ans2<it->second)
      {
          cnt2=0;
          ans2=it->second;
          p2[cnt2++]=it->first;
      }
      else if(ans2==it->second)
      {
          p2[cnt2++]=it->first;
      }
   }
   for(int i=0;i<cnt1;i++)
    for(int j=0;j<cnt2;j++)
   {
       if(p1[i]!=p2[j])
       {

           cout<<n-ans-ans2<<endl;
           return 0;
       }
   }
   int cc2=0;
   for(it=q2.begin();it!=q2.end();it++ )
   {
       if(ans2!=it->second)
       {
           cc2=max(it->second,cc2);
       }
   }
    int cc1=0;
   for(it=q1.begin();it!=q1.end();it++ )
   {
       if(ans!=it->second)
       {
           cc1=max(it->second,cc1);
       }
   }
   cout<<min(n-cc1-ans2,n-cc2-ans)<<endl;

}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void)
{
int n,S[10000],i,j,q,T[500],t,C;
	scanf("%d",&n);
	for(i=0;i!=n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d",&q);
	for(j=0;j!=q;j++){
		scanf("%d",&T[j]);
	}

	C=0;
	for(i=0;i!=q;i++){
		for(t=0;t!=n;t++){
			if(T[i]==S[t]){
				C=C+1;
				break;
			}
		}
	}
	printf("%d\n",C);
	return 0;
}

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

int main(){
  char *pic;
  int H,W;
  int i,j;
  char *buf;
  
  scanf("%d %d",&H,&W);
  pic=(char *)malloc(sizeof(char)*(H+2)*(W+2));
  buf=(char *)malloc(sizeof(char)*W+1);
  
  if(pic==NULL){
    printf("error");
    exit(0);
  }
  for(i=0;i<(H+2)*(W+2);i++){
    pic[i]='#';
  }
  for(i=1;i<H+1;i++){
    scanf("%s",buf);
    for(j=0;j<W;j++){
      pic[i*(W+2)+j+1]=buf[j];
    }
  }
  /*  for(i=0;i<(H+2)*(W+2);i++){
    printf("pic[%d]=%c\n",i,pic[i]);
    }*/
  for(i=0;i<(H+2)*(W+2);i++){
    printf("%c",pic[i]);
    if(i%(W+2)==W+1){
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int jj=a.size();
  long long p=0;
  vector<long long> d(13);
  vector<long long> ans(13);
  reverse(a.begin(),a.end());
  for(int i = 0;i < jj;i++){
    int s;
    int f = i%6;
    if(f == 0)s=1;
    if(f == 1)s=10;
    if(f == 2)s=9;
    if(f == 3)s=12;
    if(f == 4)s=3;
    if(f == 5)s=4;
    if(a.at(i)=='?'){d.at(s)++;}
    else{p+=(a.at(i)-'0')*s;}
  }
  p %= 13;
  ans.at(p)++;
  for(int i = 0;i < 13;i++){
    for(int j = 0;j < d.at(i);j++){
      vector<long long> kari(13);
      for(int k = 0;k < 13;k++){
        for(int l = 0;l < 10;l++){
          kari.at((k+l*i)%13)+=ans.at(k);
          kari.at((k+l*i)%13)%=1000000007;
          
        }
      }
      for(int k = 0;k < 13;k++){
        ans.at(k) = kari.at(k)%1000000007;}
    }
  }
 cout << ans.at(5) << endl; 
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)
 
int H, W, size;
char map[101][101];
void dfs(int i, int j) {
    char c = map[i][j];
    map[i][j] = '.';
    if(j+1<W && map[i][j+1]==c) dfs(i, j+1);
    if(j>0 && map[i][j-1]==c) dfs(i, j-1);
    if(i+1<H && map[i+1][j]==c) dfs(i+1, j);
    if(i>0 && map[i-1][j]==c) dfs(i-1, j);
}
int main() {
    while(cin >> H >> W && H!=0 && W!=0) {
        rep(i, H) {
            rep(j, W) {
                cin >> map[i][j];
            }
        }
        bool isFinished = false;
        size = 0;
        rep(i, H) {
            rep(j, W) {
                if(map[i][j]!='.') {
                    ++size;
                    dfs(i, j);
                }
            }
        }
        cout << size << endl;
        }
    return 0;
}

Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
using namespace std;

set<int> st;
int n = 0;

void recursive(vector<int> flag, vector<int> arr){
  bool fill = true;
  for(int i=0; i<n; i++){
    if(flag[i] == 0){
      fill = false;
      flag[i] = 1;
      arr.push_back(i);
      recursive(flag, arr);
      flag[i] = 0;
      arr.pop_back();
    }
  }
  if(fill){
    int sum = 0;
    for(int i=0; i<n; i++){
      sum += ((arr[i]+1) * pow(10, n-(i+1)));
    }
    st.insert(sum);
  }
}

        
int main(){
  cin >> n;
  vector<int> first(n);
  vector<int> second(n);
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    first[i] = num;
  }
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    second[i] = num;
  }
  int firstSum = 0;
  for(int i=0; i<n; i++){
    firstSum += (first[i] * pow(10, n-(i+1)));
  }
  int secondSum = 0;
  for(int i=0; i<n; i++){
    secondSum += (second[i] * pow(10, n-(i+1)));
  }
  if(firstSum == secondSum){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<n; i++){
    vector<int> arr;
    vector<int> flag(n, 0);
    flag[i] = 1;
    arr.push_back(i);
    recursive(flag, arr);
  }
  vector<int> vec(st.begin(), st.end());
  int a, b;
  for(int i=0; i<vec.size(); i++){
    if(vec[i] == firstSum) a = i;
    else if(vec[i] == secondSum) b = i;
  }
  cout << abs(a-b) << endl;
  return 0;
}
    
  
  

Measured memory_bytes: 2304
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)
AF = [A[i] * F[i] for i in range(N)]

l = -1
r = max(AF)
while l + 1 < r:
    x = (l + r) // 2
    s = sum([max(A[i] - x//F[i], 0) for i in range(N)])
    if s <= K:
        r = x
    else:
        l = x

print(r)

Measured memory_bytes: 138080
{- PSEUDOCODE:
for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key
-}

main = do
    fs <- getLine
    ss <- getLine
    let a = map (\x -> read x :: Int) $ words ss
    doFor a 1

doFor :: [Int] -> Int -> IO ()
doFor a i = do
    putStrLn $ unwords $ map show a
    if i > (length a - 1)
        then return ()
        else do
            let key = a!!i
            let j = i-1
            let na = doWhile a j key
            doFor na (i+1)

doWhile :: [Int] -> Int -> Int -> [Int]
doWhile a j key
  | j >= 0 && a!!j > key = doWhile (replace a (j+1) (a!!j)) (j-1) key
  | otherwise = replace a (j+1) key

replace :: [Int] -> Int -> Int -> [Int]
replace a idx v = (take idx a) ++ [v] ++ (drop (idx+1) a)



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

// @@ !! LIM(mod)
// --> f:gcd mod
// ---- inserted function gcd from util.cc
// g = eGCD(a, b, s, t)  --->  sa + tb = g
ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

// gcd(0, x) = x, gcd(-x, y) = gcd(x, y)
ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(abs(a), abs(b), dummy1, dummy2);
}
// ---- end gcd
// ---- inserted library file mod.cc

ll MOD = 1e9 + 7;
// ll MOD = 998244353;

struct Fp {
  ll val;

  Fp(ll t = 0) {
    if      (t >= MOD)  val = t % MOD;
    else if (t >= 0)    val = t;
    else if (t >= -MOD) val = t + MOD;
    else {
      ll v = t % MOD;
      if (v == 0) val = 0;
      else        val = v + MOD;
    }
  }

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

class Comb {
  int nMax;
  vector<Fp> vFact;
  vector<Fp> vInvFact;
public:
  Comb(int nm) : nMax(nm), vFact(nm+1), vInvFact(nm+1) {
    vFact.at(0) = 1;
    for (int i = 1; i <= nMax; i++) vFact.at(i) = i * vFact.at(i-1);
    vInvFact.at(nMax) = vFact.at(nMax).inv();
    for (int i = nMax; i >= 1; i--) vInvFact.at(i-1) = i * vInvFact.at(i);
  }
  Fp fact(int n) { return vFact.at(n); }
  Fp comb(int n, int r) {
    return vFact.at(n) * vInvFact.at(r) * vInvFact.at(n-r);
  }
  // The number of permutation extracting r from n.
  Fp perm(int n, int r) {
    return vFact.at(n) * vInvFact.at(n-r);
  }
};

// ---- end mod.cc
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  MOD = 1e9 + 7;  

  Fp ans = 1;
  ll eff = 0;
  ll N; cin >> N;
  for (ll i = 0; i < N; i++) {
    ll x; cin >> x;
    ll k = x / 2;
    if (x % 2 == 0 && eff == k) ans *= Fp(eff + 1);
    else                        eff++;
  }
  for (; eff >= 1; eff--) ans *= Fp(eff);
  cout << ll(ans) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  map<int, int> m;
  m[0] = 1;

  REP(i, N){
    if(i != 0) A[i] += A[i-1];
    m[A[i]]++;
  }

  int ans = 0;
  for(auto p : m) ans += (p.second-1)*p.second/2;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 14336
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    K,A,B = map(int,input().split())
    if B - A >= 2:
        K -= A - 1
        ans = A + (B - A) * (K//2) + K%2
    else:
        ans = K + 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll mod=1000000007;
    ll N,M;
    cin >> N >> M;
    ll dp[N+1];
    ll i,j;
    ll a[M];
    for(j=0;j<M;j++){
        cin >> a[j];
    }
    dp[0]=1;
    j=0;
    if(M>j&&a[j]==1){
        dp[1]=0;
        j++;
    }else dp[1]=1;
    for(i=2;i<=N;i++){
        if(M>j&&a[j]==i){
            dp[i]=0;
            j++;
        }else dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout << dp[N];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main() {
	int N, L;
	cin >> N >> L;
	string str[100];
	REP(i,N)
		cin >> str[i];
	sort(str, str + N);
	REP(i,N)
		cout << str[i];
	cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const ll inf = 1LL << 40;

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

    ll n, s;
    cin >> n >> s;

    ll sqr = (ll) sqrt((double) n);
    ll ret = inf;

    if (s == n) {
        ret = n + 1LL;
    } else if (s < n) {
        // bが√n以下を探す
        for (ll i = 2LL; i <= sqr; i++) {
            ll t = n, ans = 0LL;
            while (t > 0) {
                ans += t % i;
                t /= i;
            }
            if (ans == s) {
                ret = min(ret, i);
            }
        }

        // bが√n以上を探す
        for (ll p = 1LL; p <= sqr && p <= s; p++) {
            ll q = s - p; // p + q = s
            if ((n - s) % p == 0) {
                ll b = (n - s) / p + 1LL; // n = bp + q
                if (b > p && b > q) {
                    ret = min(ret, b);
                }
            }
        }
    }

    if (ret == inf) {
        cout << -1 << endl;
    } else {
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL) {
		h1 = setHeight(T[u].left) + 1;
	}
	if (T[u].right != NIL) {
		h2 = setHeight(T[u].right) + 1;
	}
	return H[u] = (h1 > h2 ? h1 : h2);
}
int getSibling(int u) {
	if (T[u].parent == NIL)return NIL;
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].left != NIL)deg++;
	if (T[u].right != NIL)deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (T[u].parent == NIL) {
		printf("root\n");
	}
	else if (T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	}
	else {
		printf("internal node\n");
	}

}

int main() {
	int v, l, r, root = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)T[i].parent = NIL;

	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL)T[l].parent = v;
		if (r != NIL)T[r].parent = v;
	}

	for (int i = 0; i < n; i++)if (T[i].parent == NIL) root = i;

	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; i++)print(i);

	return 0;
}


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

int main() {
    for(int i=0;i<3000;i++){
        int a,b;
        cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        else{
            cout<<min(a,b)<<" "<<max(a,b)<<endl;
        }

    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    ll maxv=*max_element(v.begin(),v.end());
    ll minv=*min_element(v.begin(),v.end());
    ll sum=accumulate(v.begin(),v.end(),0LL);
    cout<<minv<<" "<<maxv<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll n,m;
    while(sf("%lld %lld",&n,&m)==2)
    {
        if(n==1 && m==1)pf("1\n");
        else
        {
            if(n==1)pf("%lld\n",m-2);
            else if(m==1)pf("%lld\n",n-2);
            else pf("%lld\n",(n*m)-(n*2)-((m-2)*2));
        }
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

ll n, a[200005], ans;

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

  sort(a, a + n, greater<>());

  ans += a[0];
  int m = a[0];
  int mi = 0;
  int c = 2;
  for (int i = 2; i < n; i++) {
    if (c < 2) {
      ans += m;
      c++;
      continue;
    }
    if (c >= 2) {
      mi++;
      m = a[mi];
      c = 1;
      ans += m;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 5192
#include <cstdio>

int main() {
    int a,b,c;
    int n = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a;i <= b; ++i) {
        if(c % i == 0) {
            ++n;
        }
    }
    printf("%d\n",n);
}


Measured memory_bytes: 2720
#include <iostream>
#include <vector>

using namespace std;

void print(vector<int> v) {
  for (vector<int>::iterator itr = v.begin();
       itr != v.end(); itr++) {
    if (itr != v.begin()) {
      cout << ' ';
    }
    cout << *itr;
  }
  cout << endl;
}

int main(int argc, char* argv[]) {
  int N; cin >> N;
  vector<int> arr;
  for (int i = 0; i < N; i++) {
    int n; cin >> n;
    arr.push_back(n);
  }
  
  print(arr);

  for (int i = 1; i < N; i++) {
    int key = arr[i];
    int j;
    for (j = i-1; 0 <= j && arr[j] > key; j--) {
      arr[j+1] = arr[j];
    }
    arr[j+1] = key;
    print(arr);
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    long long int N, A, B;
    cin >> N;
    cin >> A;
    cin >> B;
    long long int P;
    long long int count[3] = {0};
    for(int i = 0; i < N; i++){
        cin >> P;
        if(P <= A){
           count[0] ++;
        }else if(P > A && P <= B){
           count[1] ++;
        }else if(P > B){
           count[2] ++;
        }
    }
    cout << min(count[2], min(count[0], count[1])) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    if (a > b && a > c)
        cout << b * c / 2 << endl;
    else if (b > a && b > c)
        cout << a * c / 2 << endl;
    else 
        cout << a * b / 2 << endl;
    
    return 0;
    

    

}

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

int main(){
    long int H,W;
    
    while(H != 0 && W != 0){
        cin >> H >> W;

        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;    
        }
        if(H != 0 && W != 0){
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>

typedef long long ll;

using namespace std;

int main() {
    int a;

    double ans = 0.0, ans2;

    cin >> a;

    vector<int> data(a);

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

    for (int i = 0; i < a; i++) {
       ans +=  1.0 / data[i];
    }

    ans2 = 1.0 / ans;

    cout << ans2 << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
li = list()
for i in range(N):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

if count >= 3: print('Yes')
else: print('No')

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;string S;
    cin >> S >> N;
    string ans = "";
    ll s = S.size();
    for(ll i = 0;i < s;i += N)ans += S[i];
    cout << ans << endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 1e9 + 7;
const int N = 310000;
int u[N], v[N], sz[N], p[N], c[N], used[N];
int gt(int x){
    if (p[x] == x) return x;
    return p[x] = (gt(p[x]));
}
void unite(int x, int y){
    x = gt(x);
    y = gt(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x, y);
    p[y] = x;
    sz[x] += sz[y];
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 0; i < n; i++){
        p[i] = i;
        sz[i] = 1;
    }
    for (int i = 1; i <= q; i++){
        cin >> u[i] >> v[i] >> c[i];
        if (c[i] == 0){
            unite(u[i], v[i]);
        }
    }
    int t = 0;
    for (int i = 0; i < n; i++){
        if (used[gt(i)]) continue;
        m -= (sz[gt(i)] - 1);
        t++;
        used[gt(i)] = 1;
    }
    set < int > s;
    for (int i = 1; i <= q; i++){
        if (c[i] == 0) continue;
        u[i] = gt(u[i]);
        v[i] = gt(v[i]);
        if (u[i] == v[i]){
            cout << "No";
            return 0;
        }
        s.insert(u[i]);
        s.insert(v[i]);
    }
    if (m < 0){
        cout << "No";
        return 0;
    }
    if (t == 1){
        if (m == 0)
        cout << "Yes"; else cout << "No";
        return 0;
    }
    if (s.size() == 2) s.insert(-1);
    int l = (int)s.size();
    int r = t * (t - 1)/ 2;
    if (m >= l && m <= r) cout << "Yes"; else cout << "No";
}


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

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

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, T;
    cin >> N >> T;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = 1;
    ll p_mx = -L_INF;
    ll v_mn = A[0];
    for (ll i = 1; i < N; i++) {
        ll p = A[i] - v_mn;
        if (p > p_mx) {
            ans = 1;
            p_mx = p;
        }
        else if (p == p_mx) {
            ++ans;
        }

        v_mn = min(v_mn, A[i]);
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1024