akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

map<ll, int> m;
int N;
ll H, W;
ll cnt[11];
int main() {
    cin>>H>>W>>N;
    REP(k,0,N){
        ll a,b;
        cin>>a>>b;
        REP(i,-1,2){
            REP(j,-1,2){
                if(CK(a+i,2,H)&&CK(b+j,2,W))m[W*(a+i)+(b+j)]++;
            }
        }
    }
    cnt[0]=(H-2)*(W-2);
    for(auto mp : m){
        cnt[mp.second]++;
        cnt[0]--;
    }
    REP(i,0,10){
        p(cnt[i]);
    }
    return 0;
}

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

int main() {
  int a, b;
  
  cin >> a >> b;
  
  if ( a>0 && b>0 ){
  	if ( a*b%2 == 0 )
   	  cout << "Even" << endl;
 	else
  	  cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3460
//Abhigyan's Code:
             
    //YOU DON'T DARE TO COPY :) 

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    #define checker cout<<"CHECKED" 
    #define modulo 1000000007
    ll dp[100005][3] ;
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      ll n ;
      cin >> n;

      dp[0][0] =0 ;
      dp[0][1] =0 ;
      dp[0][2] =0 ;

       ll flag = 1;
        
       ll temp = n;

      while(temp--)
      {
          ll a, b , c;
          cin >> a >> b >> c;

          dp[flag][0] = a + max({dp[flag -1][1] , dp[flag - 1][2] } ) ;

          dp[flag][1] = b + max({dp[flag -1][0] , dp[flag - 1][2] } ) ;

          dp[flag][2] = c + max({dp[flag -1][0] , dp[flag - 1][1] } ) ; 

          flag++;

      }


      ll cost = max( {dp[n][0]  , dp[n][1] , dp[n][2] } ) ; 
      cout<< cost;

      return 0 ;

    } 

Measured memory_bytes: 5940
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;
signed main(){
    int k;
    cin>>k;
    queue<int> q;
    for(int i=1;i<10;i++){
        q.push(i);
    }
    int cnt=0;
    int a;
    int b;
    while(cnt<k){
        a=q.front();q.pop();
        cnt++;
        b=a%10;
        if(b!=0) q.push(a*10+b-1);
        q.push(a*10+b);
        if(b!=9) q.push(a*10+b+1);
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>           
    using namespace std;
    #define ll long long
    #define ld long double
    #define inf 100000
    #define io  ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int main()
    {
        io
       ll x,c=0,s=0;
       cin>>x;
      while(x>=500)
      { c++;
         x=x-500;
      }
      while(x>=5 && x<500)
      {
          s++;
        x=x-5;  
      }
      cout<<1000*c+5*s<<endl;
    }
       
     
        

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())

seg_el=1<<((N+1).bit_length()) # Segment treeの台の要素数

SEG=[N-2]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化
SEG2=[N-2]*(2*seg_el)

def getvalue(n,seg_el): # 一点の値を取得
    i=n+seg_el
    ANS=N-2
    
    ANS=min(SEG[i],ANS)
    i>>=1# 子ノードへ
    
    while i!=0:
        ANS=min(SEG[i],ANS)
        i>>=1

    return ANS

def getvalue2(n,seg_el): # 一点の値を取得
    i=n+seg_el
    ANS=N-2
    
    ANS=min(SEG2[i],ANS)
    i>>=1# 子ノードへ
    
    while i!=0:
        ANS=min(SEG2[i],ANS)
        i>>=1

    return ANS

def updates(l,r,x): # 区間[l,r)のminを更新.
    L=l+seg_el
    R=r+seg_el

    while L<R:
        if L & 1:
            SEG[L]=min(x,SEG[L])
            L+=1

        if R & 1:
            R-=1
            SEG[R]=min(x,SEG[R])
        L>>=1
        R>>=1

def updates2(l,r,x): # 区間[l,r)のminを更新.
    L=l+seg_el
    R=r+seg_el

    while L<R:
        if L & 1:
            SEG2[L]=min(x,SEG2[L])
            L+=1

        if R & 1:
            R-=1
            SEG2[R]=min(x,SEG2[R])
        L>>=1
        R>>=1

ANS=(N-2)*(N-2)

MINX=N
MINY=N

for queries in range(Q):
    t,x=map(int,input().split())

    if t==1:
        v=getvalue(x,seg_el)
        ANS-=v
        updates2(1,MINY,x-2)
        MINX=min(MINX,x)

    else:
        v=getvalue2(x,seg_el)
        ANS-=v
        updates(1,MINX,x-2)
        MINY=min(MINY,x)

print(ANS)
        
        

    



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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int a,b,c;
  int ans = 0;
  cin >> a >> b >> c;
  for(int i=a;i<=b;i++){
    if(c%i==0)ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3092
#include <stdio.h>
#define N 25

typedef struct{

  int parent;
  int left;
  int right;

}Node;

int n;
Node in[N];

void init();
int sibling(int);
int depth(int);
int type(int);
int degree(int);
int height(int);
 
int main(){

  int i, id;
  
  init();

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d %d", &in[id].left, &in[id].right);
    
    if(in[id].left == -1 && in[id].right == -1) continue;

    in[in[id].left].parent = id;
    in[in[id].right].parent = id;
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, ", i, in[i].parent, sibling(i));
    printf("degree = %d, depth = %d, height = %d, ", degree(i), depth(i), height(i));

    if(type(i) == 0){
      printf("root\n");
    } else if(type(i) == 1){
      printf("leaf\n");
    } else if(type(i) == 2){
      printf("internal node\n");
    }

  }
  return 0;
}
 
 
void init(){
  int i;
  
  for(i = 0; i < N; i++){
    in[i].parent = -1;
    in[i].left = -1;
    in[i].right = -1;
  }

}


int depth(int num){
   int i;
   
   for(i = 0; in[num].parent != -1; i++){
     num = in[num].parent;
   }

   return i;
}
 

int type(int num){

  if(in[num].parent == -1){
    return 0;
  }
  
  if(in[num].left == -1 && in[num].right == -1){
    return 1;
  }

  return 2;

}


int sibling(int num){

  if(in[num].parent == -1){
    return -1;
  }

  if(in[in[num].parent].left == num){
    return in[in[num].parent].right;
  } else {
    return in[in[num].parent].left;
  }

}


int degree(int num){
  
  if(in[num].left == -1 && in[num].right == -1){
    return 0;
  }

  if(in[num].left == -1 || in[num].right == -1){
     return 1;
  }

   return 2;

}


int height(int num){
  int i;
  int heightLeft = -1, heightRight = -1;

  if(in[num].left != -1){
    heightLeft = height(in[num].left);
  }

  if(in[num].right != -1){
    heightRight = height(in[num].right);
  }
  
  heightLeft++;
  heightRight++;
  
  if(heightLeft > heightRight){
    return heightLeft;
  } else {
    return heightRight;
  }
  
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

const int INF = 1e9 + 10;
string str;
int main(){
	cin>>str;
	int n = str.length();

	int mini = INF;
	for (int i=0;i<n;i++){
		if (str[i] == '0'){
			int cd = max(i, n-(i+1));
			cd = max(cd, min(i+1, n-i));

			mini = min(mini,cd);
		}
	}

	int ans = mini;
	mini = INF;
	for (int i=0;i<n;i++){
		if (str[i] == '1'){
			int cd = max(i, n-(i+1));
			cd = max(cd, min(i+1, n-i));

			mini = min(mini,cd);
		}
	}

	ans = max(ans,mini);

	cout<<min(n,ans)<<endl;
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    N = len(s)
    P = s.count("p")
    print(N//2-P)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val as = Array.fill(n) {
      in.readLine().toCharArray
    }
    val bs = Array.fill(m) {
      in.readLine().toCharArray
    }

    val width = n - m + 1

    @tailrec
    def traverse(ax: Int, ay: Int): Boolean = {
      @tailrec
      def fit(bx: Int, by: Int): Boolean = {
        by == m || as(ax + bx)(ay + by) == bs(bx)(by) && fit((bx + 1) % m, by + (bx + 1) / m)
      }
      ay < width && (fit(0, 0) || traverse((ax + 1) % width, ay + (ax + 1) / width))
    }

    if (traverse(0, 0)) {
      out.println("Yes")
    } else {
      out.println("No")
    }

    out.flush()
  }
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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; }
 
const ll MAX = 200010;

class UnionFind
{
private:
    int par[MAX];
    int rank[MAX];
public:
    UnionFind(int N);
    int find(int x);
    void unite(int x, int y);
    bool same(int x, int y);
};

//コンストラクタ
UnionFind::UnionFind(int N)
{
    for(int i=0; i<N; i++)
    {
        par[i]=i;
        rank[i]=0;
    }
 }

//木の根を求める
int UnionFind::find(int x)
{
    if(par[x]==x)
    {
        return x;
    }
    else
    {
        return par[x]=find(par[x]);
    }
}
//位数の大きい木に統合する
void UnionFind::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]++;
        }
    }
}

//同じ根を持つならtrueを返す
bool UnionFind::same(int x, int y)
{
    return find(x)==find(y);
}

struct edge { int from, to, cost; };

struct point { ll x, y; int no; };


bool comp(const edge& e1, const edge& e2)
{
    return e1.cost < e2.cost;
}


bool pcomp1(const point& p1, const point& p2)
{
    return p1.x < p2.x;
}

bool pcomp2(const point& p1, const point& p2)
{
    return p1.y < p2.y;
}

edge es[MAX];
point p[MAX];

int V, E;

int kruskal()
{
    sort(es, es+E, comp);
    UnionFind *tree = new UnionFind(V);
    int res = 0;
    for(int i=0; i<E; i++)
    {
        edge e = es[i];
        if(!tree->same(e.from, e.to))
        {
            tree->unite(e.from, e.to);
            res+=e.cost;
        }
    }
    return res;
}


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

    int N;
    cin >> N;

    V=N;
    E=2*N-2;

    rep(i, N)
    {
        cin >> p[i].x >> p[i].y;
        p[i].no = i;
    }

    sort(p, p+N, pcomp1);

    

    rep(i, N-1)
    {
        es[i].cost=min(abs(p[i].x-p[i+1].x), abs(p[i].y-p[i+1].y));
        es[i].from=p[i].no;
        es[i].to = p[i+1].no;
    }


    sort(p, p+N, pcomp2);

    for(int i=0; i<N-1; i++)
    {
        int j=i+N-1;
        es[j].cost=min(abs(p[i].x-p[i+1].x), abs(p[i].y-p[i+1].y));
        es[j].from=p[i].no;
        es[j].to = p[i+1].no;

    }

    cout << kruskal() << endl;

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 8192
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int k, int s) {
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - (x + y);
            if (z < 0) break;

            if (z <= k) ans++;
        }
    }
    return ans;
}

void main() {
    auto ks = readints;
    int k = ks[0], s = ks[1];
    writeln(calc(k, s));
}


Measured memory_bytes: 256
inf = 1e9
n,m = map(int,raw_input().split())
edge = [map(int,raw_input().split()) for i in range(m)]
d = [inf]*n
d[0] = 0
while 1:
	update = 0
	for i in range(m):
		a,b,c = edge[i]
		if d[a] != inf and d[b] > d[a] - c:
			d[b] = d[a] - c
			update = 1
	if update == 0: break
print abs(d[n-1])

Measured memory_bytes: 4300
package main

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

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

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return string(str)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func main() {
	defer out.Flush()
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	sum := 0
	for i := 0; i < m; i++ {
		sum += nextInt()
	}
	res := -1
	if n-sum >= 0 {
		res = n - sum
	}

	fmt.Fprintln(out, fmt.Sprintln(res))
}


Measured memory_bytes: 1812
#include <stdio.h>

int main() {
  int n;
  scanf("%d",&n);
  if(n == 1) {
    printf("Hello World");
  }else if(n == 2) {
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    printf("%d",a+b);
  }
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: str, K: int):
    M = len(N)
    DP = [[[0]*2 for __ in range(K+1)] for _ in range(M+1)]
    Nstr = N

    DP[0][0][False] = 1

    for i in range(M):
        DP[i+1][0][True] = 1
        DP[i+1][0][False] = 0
        for k in range(K):
            DP[i+1][k+1][True] = DP[i][k][True]*9 + DP[i][k+1][True]*1
            if int(Nstr[i]) != 0:
                DP[i+1][k+1][True] += DP[i][k+1][False]
                DP[i+1][k+1][True] += DP[i][k][False]*(int(Nstr[i])-1)
            if int(Nstr[i]) == 0:
                DP[i+1][k+1][False] = DP[i][k+1][False]
            else:
                DP[i+1][k+1][False] = DP[i][k][False]
    print(DP[M][K][True]+DP[M][K][False])
    # print(*DP, sep="\n")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = str(next(tokens))  #
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38448
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int MOD=1e9+7;
//ll a[N];
//ll sum;
//ll ans[N];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin >>n;
    if(n%2==0)  cout <<n<<endl;
    else    cout <<n*2<<endl;


    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AABCARC {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int x;
    cin >> x;
    cout << (x >= 1200? "ARC":"ABC") <<endl;
}
};


#undef int
int main() {
	AABCARC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define mp make_pair
typedef long long ll;
using namespace std;
int n; ll  a,b,c,d;
int main(){
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for (int i=0; i<=n; i++){
		ll L=a-d*i+c*(n-i-1),R=a-c*i+d*(n-i-1);
		if (L<=b && b<=R){
			puts("YES");
			return 0;	
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int F[10000];

/*フィボナッチ＠動的計画法*/
int Dynamic_Fibonacci(int n) {
    int i;
    
    F[0] = F[1] = 1;
    
    for(i = 2 ; i <= n ; i++)
        F[i] = F[i - 1] + F[i - 2];
    
    return F[n];
}
/*フィボナッチ＠メモ化*/
int Memorize_Fibonacch(int n) {
    
    if(n == 0 || n == 1) {
        /*メモ*/
        F[n] = 1;
        return F[n];
    }
    /*メモを利用してメモをし、また使えるようにして返す*/
    F[n] = F[n - 1] + F[n - 2];
    /*終わったらメモごと返す(nに達すればそのまま帰る)*/
    return F[n];
}

int main(void)
{
    int n;
    scanf("%d" , &n);
    printf("%d\n" , Dynamic_Fibonacci(n));
    
    return 0;
}



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

int main(void)
{
    long long  a,b;
    cin>>a>>b;
    if(a==1&&b==1)
    {
        cout <<1<<endl;
    }
    else if(a==1&&b>1)
    {
        cout <<b-2<<endl;
    }
    else if(a>1&&b==1)
    {
        cout <<a-2<<endl;
    }
    else
    {
        cout <<(a-2)*(b-2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

n = sys.stdin.readline().rstrip()
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]
if int(n[-1]) in hon:
    print('hon') 
elif int(n[-1]) in pon:
    print('pon')
elif int(n[-1]) in bon:
    print('bon')

Measured memory_bytes: 9136
# https://atcoder.jp/contests/abc133/tasks/abc133_c

MOD = 2019

L, R = gets.split.map(&:to_i)

if R - L >= MOD
  puts 0
  exit
end

ans = 2019
(L...R).each do |i|
  ((i + 1)..R).each do |j|
    m = (i * j) % MOD
    if m == 0
      puts 0
      exit
    end
    ans = m if m < ans
  end
end

puts ans

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
struct node{
	int to,nxt;
	int w;
}e[maxn];
int head[maxn];
int ans[maxn];
int cnt;
void add(int u,int v,int w){
	e[++cnt]=(node){v,head[u],w};
	head[u]=cnt;
}
void dfs(int u,int fa){
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa)
			continue;
		if(e[i].w%2)
			ans[v]=ans[u]^1;
		else ans[v]=ans[u];
		dfs(v,u);
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i,u,v,w;i<n-1;i++){
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
		add(v,u,w);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}

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

int main(){
    int cnt[26]={};
    char ch;
    
    while(cin>>ch){
        ch=tolower(ch);
        if(isalpha(ch)) cnt[ch-'a']++;
    }
    
    for(int i=0; i<=25; i++){
        cout<<(char)(i+'a')<<" : "<<cnt[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            par[x] = root(par[x]);
            return par[x];
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};

int main(){

    int n, k, l;
    cin >> n >> k >> l;

    unionFind road, railway;
    road.init(n);
    railway.init(n);

    rep(i, k){
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        road.unite(p, q);
    }
    rep(i, l){
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        railway.unite(r, s);
    }

    vector< pair<int, int> > v(n);
    map< pair<int, int>, int > mp;
    rep(i, n){
        v[i].first = road.root(i);
        v[i].second = railway.root(i);
        mp[v[i]]++;
    }
    rep(i, n){
        cout << mp[v[i]];
        if(i < n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }

    return 0;

}

Measured memory_bytes: 16640
#include "bits/stdc++.h"
using namespace std;

int main() {
	string O,E;
	cin >> O >> E;
	string ans;
	for (int i = 0;i<E.size();++i) {
		ans += O[i];
		ans += E[i];
	}
	if (O.size() !=E.size()) {
		ans += O[O.size() - 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
const int maxn=105;
int main(){
    int a,b,k;
    while (scanf("%d%d%d",&a,&b,&k)==3) {
        int head=a;int tail=b;
        for (int i=0; i<k&&head<=tail; ++i) {
            printf("%d\n",head);
            head++;
        }
        int i=tail-k+1;
        if (i<head) {
            i=head;
        }
        for (; i<=tail; ++i) {
            printf("%d\n",i);
        }
    }
    return 0;
}


Measured memory_bytes: 256
a= list(input().split())
b={}
for w in a:
    if not(w in b):
        b[w]=1
    else:
        b[w]+=1

max_word=" "
max_num= a[0]

for w in b:
    if len(max_word)< len(w):
        max_word= w
    if b[w]> b[max_num]:
        max_num= w
print(max_num,max_word)


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

bool p[1000003] = {false};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s;
    cin >> s;
    p[s] = true;
    int cnt = 1;
    while(1) {
        cnt++;
        if(s & 1) s = 3 * s + 1;
        else s /= 2;
        if(p[s]) {
            cout << cnt << endl;
            return 0;
        }
        p[s] = true;
    }
}

Measured memory_bytes: 3648
p Hash[2912,53,2023,112,1000030,20624,1935,291,11,2,22,2,1900,992,7,-1,20054,11,20050,29,21,-1,1000095,2152,1000079,-1,10,5,24,3,20085,40,26,-1,2892,48,1000016,15458,1910,-1,1971,8,2067,85,10101,76726,1840,-1,20019,21,20020,53,2823,76,1923,-1,25,-1,2011,88,1000093,-1,23,3][gets.split.map(&:to_i).sum]

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

using namespace std;
typedef long long ll;

const int N = 200'010;
int n, a[N];

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; i++) cout << a[i] << "\n";
}


Measured memory_bytes: 4356
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  bool same(int x, int y) {
    x = find(x), y = find(y);
    return (x == y);
    }
};


int N,M;
vector<int> P;
vector<int> x,y;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        int _p;
        cin >> _p;
        _p--;
        P.push_back(_p);
    }

    for (int i = 0; i < M; i++)
    {
        int _x,_y;
        cin >> _x >> _y;
        _x--;
        _y--;
        x.push_back(_x);
        y.push_back(_y);
    }
    
    
}

int solve(){
    UnionFind uf(N);
    for (int i = 0; i < M; i++)
    {
        uf.unite(x[i],y[i]);
    }
    int ans=0;
    for (int i = 0; i < N; i++)
    {
        ans += uf.same(i,P[i]);
    }
    cout << ans << endl;   
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1912
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
   string s, t;
   cin >> s >> t;
   sort(s.begin(), s.end());
   sort(t.begin(), t.end());
   reverse(t.begin(), t.end());
   if (s < t) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////
ll fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}

// 二項係数計算
long long COM(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;
}

int main() {
	COMinit();

	ll N, K;
	cin >> N >> K;
	ll A[MAX];
	repn(i, N) cin >> A[i];

	sort(A + 1, A + N + 1);

	ll ans = 0;

	repn(i, N) { ans += A[i] * COM(i - 1, K - 1); ans %= MOD; }
	repn(i, N) { ans -= A[i] * COM(N - i, K - 1); ans %= MOD; }
	if (ans < 0) { ans += MOD; }
	cout << ans;

	system("PAUSE");


}


Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
int main(){
int x;
cin>>x;
if(x>=0 && x<=1){
    if(x==0){
        cout<<"1"<<endl;
    }
    else if(x==1)
    {
      cout<<"0"<<endl;
    }
}
 return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    int a[10][10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                a[j][k] = std::min(a[j][k], a[j][i] + a[i][k]);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            if (x >= 0) {
                res += a[x][1];
            }
        }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int stage[128][128];
bool mem[128][128];
int xg,yg;
int w,h;
void dfs(int x,int y,int col){
    if(x < 1 || y < 1 || x > w || y > h)return ;
    if(mem[y][x])return ;
    if(stage[y][x] != col)return ;
    mem[y][x] = true;
    rep(i,4){
        if(col == stage[y+dy[i]][x+dx[i]]){
            dfs(x + dx[i], y + dy[i], col);
        }
    }
    return ;
}
int main(){
    while(scanf("%d%d",&w,&h),w|h){
        memset(stage,0,sizeof(stage));
        rep(i,128)rep(j,128)mem[i][j] = false;
        int xs,ys;
        scanf("%d%d",&xs,&ys);
        scanf("%d%d",&xg,&yg);
         
        int n;
        scanf("%d",&n);
 
        rep(q,n){
            int c,d,x,y;
            scanf("%d%d%d%d",&c,&d,&x,&y);
            if(d == 0){
                reps(i,x,x+4){
                    reps(j,y,y+2){
                        stage[j][i] = c;
                    }
                }
            }
            else{
                reps(i,x,x+2){
                    reps(j,y,y+4){
                        stage[j][i] = c;
                    }
                }
            }
        }
        dfs(xs,ys,stage[ys][xs]);
        bool f = mem[yg][xg];
        (f) ? puts("OK") : puts("NG");
    }
    return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<string>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  auto calc = [](auto&& f, std::string s)->int64_t {
    if(s.size()==1) return s[0]-'0';
    int64_t res = std::atol(s.c_str());
    for(int i = 1; i < s.size(); ++i) {
      std::string l=s.substr(0, i), r=s.substr(i);
      res += std::atol(l.c_str()) << r.size()-1;
      res += f(f, r);
    }
    return res;
  };
  fin(calc(calc,S));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N; cin >> N;
    int i = 0;
    int answer = 0;
    if (N / 100 > (N - N / 100 * 100) / 10) answer = N / 100;
    else if (N / 100 < (N - N / 100 * 100) / 10) answer = N / 100 + 1;
    else if ((N - N / 100 * 100) / 10 >= N % 10) answer = N / 100;
    else answer = N / 100 + 1;
    cout << answer << answer << answer << endl;
}

Measured memory_bytes: 3592
N,M=gets.split.map &:to_i
G=Array.new(N){Array.new(N)}
M.times do
  a,b=gets.split.map &:to_i
  a-=1
  b-=1
  G[a][b] = G[b][a] = true
end
ans=0
(1...N).to_a.permutation do |p|
  ok=true
  ([0]+p).each_cons(2) do |u,v|
    ok=false unless G[u][v]
  end
  ans+=1 if ok
end
p ans


Measured memory_bytes: 1916
from collections import deque

r, c = map(int, input().split())
mp = [input() for _ in range(r)]
R, U, L, D = 0, 1, 2, 3
vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
dic = {}
dic[(0, 0, R, 0)] = True
que = deque()
que.append((0, 0, R, 0))

while que:
  x, y, direct, mem = que.popleft()
  com = mp[y][x]
  if com == "?":
    for d in (R, U, L, D):
      dx, dy = vec[d]
      nx, ny = (x + dx) % c, (y + dy) % r
      if (nx, ny, d, mem) not in dic:
        dic[(nx, ny, d, mem)] = True
        que.append((nx, ny, d, mem))
    continue
  elif com == "@":
    print("YES")
    break
  elif com == "<":
    direct = L
  elif com == ">":
    direct = R
  elif com == "^":
    direct = U
  elif com == "v":
    direct = D
  elif com == "_":
    direct = R if mem == 0 else L
  elif com == "|":
    direct = D if mem == 0 else U
  elif com == ".":
    pass
  elif "0" <= com <= "9":
    mem = int(com)
  elif com == "+":
    mem = (mem + 1) % 16
  elif com == "-":
    mem = (mem - 1) % 16
  dx, dy = vec[direct]
  nx, ny = (x + dx) % c, (y + dy) % r
  if (nx, ny, direct, mem) not in dic:
    dic[(nx, ny, direct, mem)] = True
    que.append((nx, ny, direct, mem))
else:
  print("NO")


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

int main()
{
	int n; cin >> n;
	
	vector<int> b(n);
	for (int i = 1; i <= n - 1; i++) cin >> b[i];
	
	int ans = 0;
	ans += b[1]; // a[1]
	for (int i = 2; i <= n -1; i++) {
		ans += min(b[i - 1], b[i]);
	}
	ans += b[n - 1];
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> p(4), t(4);
    REP(i, 4) cin >> p[i];
    REP(i, 4) cin >> t[i];
    
    ll ans = LINF;

    REP(i, 101) {
        ll inum = i * t[0];
        REP(j, 101) {
            ll ijnum = inum + j * t[1];
            REP(k, 101) {
                ll ijknum = ijnum + k * t[2];
                REP(l, 101) {
                    ll ijklnum = ijknum + l * t[3];
                    if (ijklnum >= n) {
                        chmin(ans, i * p[0] + j * p[1] + k * p[2] + l * p[3]);
                    }
                    if (ijklnum > n) break;
                }
                if (ijknum > n) break;
            }
            if (ijnum > n) break;
        }
        if (inum > n) break;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))

int n, a[222222] = {}, b;

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

Measured memory_bytes: 2516
import sys

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


def main():
    x1, y1, x2, y2 = map(int, readline().split())
    
    dx = x2 - x1
    dy = y2 - y1
    
    x3, y3 = x2 - dy, y2 + dx
    x4, y4 = x1 - dy, y1 + dx
    
    print(x3, y3, x4, y4)
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

int main() {
  intmax_t N, M;
  scanf("%jd %jd", &N, &M);

  if (N > M) std::swap(N, M);

  if (N == 1) {
    if (M == 1) {
      printf("1\n");
    } else {
      printf("%jd\n", M-2);
    }
  } else {
    printf("%jd\n", (N-2)*(M-2));
  }
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int red=n-k;
        for(int i=1;i<=k;i++){
            if(red+1>=i){
                System.out.println((((long)combination(red+1,i,1000000007))*combination(k-1,i-1,1000000007))%1000000007);
            }
            else System.out.println(0);
        }
    }
  public static long factorial(int a, int p) {
		long ans = 1;
		for (int i = 1; i <= a; i++) {
			ans = (p == 0) ? ans * i : (ans * i) % p;
		}
		return ans;
	}

	//順列
	public static long permutation(int a, int b, int p) {
		long ans = 1;
		if (a > b) {
			int c = a;
			a = b;
			b = c;
		}
		for (int i = b; i > b - a; i--) {
			ans = (p == 0) ? ans * i : (ans * i) % p;
		}
		return ans;
	}

	//pがint範囲内のみ正常に動く(pは素数もしくは0)
	public static long combination(int a, int b, int p) {
		long c = permutation(a, b, p);
		long c2 = factorial(b, p);
		c = (p == 0) ? c / c2 : (p == 1) ? 0 : c * pow((int) c2, p - 2,p);
		return (p == 0) ? (int) c : (int) (c % p);
	}public static int pow(int a, int b, int p) {
		if (b == 0) {
			return 1;
		} else if (b % 2 == 0) {
			long c = (p == 0) ? (long) a * a : ((long) a * a) % p;
			return pow((int) c, b / 2, p);
		} else {
			long c = (p == 0) ? (long) a * pow(a, b - 1, p) : ((long) a * pow(a, b - 1, p)) % p;
			return (int) c;
		}
	}
}


Measured memory_bytes: 23636
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

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

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
int main() {

  int N ;
  cin >> N;
  
  if (N / 100 == 7 ||(N / 10) % 10 == 7 ||N % 10 == 7 ) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}


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

#define x first
#define y second
#define mp make_pair
#define pub push_back
#define all(a) a.begin(), a.end()
#define ll long long
#define db double

using namespace std;

ll n, m;

int main(){
	//freopen("input.txt", "r", stdin);
	cin >> n >> m;
	ll a = n - m;
	ll b = m;
	db ans = 0;
	db kk = (db)1 / pow(2, m);
	db hhh = 1 - (db)1 / pow(2, m);
	for (int it = 1; it <= 1000000; it++){
		//cout << kk << endl;
		ans += (a * (db)100 + b * (db)1900) * (db)it * (db)kk;
		kk *= (db)hhh;
		//cout << ans << endl;
	}
	cout << (ll)(ans + 0.5);
}

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

int main(){
  int a,b,c,k;
  cin >> a>>b>>c>>k;
  if(a>=k){
    cout << k << endl;
  }else if(a+b>=k){
    cout << a <<endl;
  }else{
    cout << a - (k-(a+b))<<endl;
  }
  
}


Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 10005

const int INF = 1e9+7;

int main(){

    int n,k;
    cin >> n >> k;
    vector<int> x(n,0),y(n,0),c(n,0);

    for(int i = 0;i < n;i++){
        char ch;
        cin >> x[i] >> y[i] >> ch;
        x[i] %= 2*k;
        y[i] %= 2*k;
        if(ch == 'W'){
            c[i] = 1;
        }
    }

    int white[k][k];//マス(x,y)を右上とした長方形に含まれている(白マスの数-黒マスの数)
    for(int i = 0;i < k;i++){
        for(int j = 0;j < k;j++){
            white[i][j] = 0;
        }
    }

    int black = 0;//黒マス指定のマスの数
    //白マスに+1をして、黒マスに-1をする

    for(int i = 0;i < n;i++){
    
        c[i] += x[i]/k + y[i]/k;
        c[i] %= 2;
        x[i] %= k;
        y[i] %= k;
        if(c[i] == 1){
            //白
            white[x[i]][y[i]]++;
        }else{
            //黒
            white[x[i]][y[i]]--;
        }
        if(c[i] == 0){
            black++;
        }
    }

    //二次元いもす（横方向）
    for(int i = 0;i < k;i++){
        for(int j = 1;j < k;j++){
            white[i][j] += white[i][j-1];
        }
    }
    
    //二次元いもす(縦方向)
    for(int i = 1;i < k;i++){
        for(int j = 0;j < k;j++){
            white[i][j] += white[i-1][j];
        }
    }

    int ans = 0;
    for(int i = 0;i < k;i++){
        for(int j = 0;j < k;j++){
            //座標(i.j)を右上とした長方形を白く塗る場合の満たす希望の数
            int w = white[k-1][k-1] - white[i][k-1] - white[k-1][j] + white[i][j]*2 + black;
            ans = max(ans,max(w,n-w));//色を反転させた(右上を黒)条件と比較して大きい方を取る
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 5376
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
uf = WeightedUnionFind(N)

for _ in range(M):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    if uf.same(l, r):
        diff = uf.diff(l, r)
        if diff != d:
            print("No")
            exit()
    else:
        uf.union(l, r, d)

print("Yes")

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

using namespace std;

typedef vector<int> vi;

#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define all(a) a.begin(),a.end()

int P[1001];

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

	int N, M;
	
	while (cin >> N >> M, N || M) {
		rep1(i, N) cin >> P[i];

		vi A;

		rep(i, N + 1) rep(j, i + 1) if (P[i] + P[j] <= M) A.PB(P[i] + P[j]);

		sort(all(A));

		int ma = 0;

		int l = 0, r = A.size() - 1;

		while (l < r) {
			while (A[l] + A[r] > M) r--;
			ma = max(ma, A[l] + A[r]);
			l++;
		}

		cout << ma << endl;
	}
}

Measured memory_bytes: 5048