akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pl = pair<ll,ll>;

struct TIME{
    ll h,m;
    pl s;
};

void PRINT_T(TIME t){
    printf("%lld %lld %lld %lld\n", t.h, t.m, t.s.fi, t.s.se);
}

const ll INF = 60*60*100*10;

bool big(pl a, pl b){
    return a.fi*b.se < b.fi*a.se;
}

pl norm(pl a){
    ll G = __gcd(a.fi, a.se);
    a.fi /= G;
    a.se /= G;
    return a;
}

int H,x,y,z;

// a から b
pl sub(TIME a, TIME b){
    pl p = a.s;
    p.fi += p.se*60*(60*a.h+a.m);

    pl q = b.s;
    q.fi += q.se*60*(60*b.h+b.m);

    while(big(q,p)) q.fi += H*3600*q.se;
    p = norm(p);
    q = norm(q);

    ll X = q.fi*p.se - p.fi*q.se;
    ll Y = q.se*p.se;
    pl res(X,Y);
    res = norm(res);

    // printf(" DIFF:\n");
    // PRINT_T(a);
    // PRINT_T(b);
    // dbg(res);
    return res;
}

int main(){
    while(cin >>H >>x >>y >>z,H){
        ll T = 60*H;

        TIME base = {x,y,{z,1}};

        pl diff(INF,1);
        TIME ans;

        auto upd = [&](ll p, ll q, int i, int j){
            ll t = 60*i+j;
            if(p>=0 && p/q<60){
                pl s = norm({p,q});
                // printf(" CAND %d %d %lld/%lld :", i,j,s.fi,s.se);

                pl th(60*t*s.se+s.fi, 60*T*s.se);
                pl tm(60*j*s.se+s.fi, 3600*s.se);
                pl ts(s.fi, s.se*60);
                th = norm(th);
                tm = norm(tm);
                ts = norm(ts);

                if( th!=tm && th!=ts && tm!=ts ){
                    TIME tmp = {i,j,s};
                    pl td = sub(base, tmp);
                    if(big(td,diff)){
                        diff = td;
                        ans = tmp;
                    }
                    // printf("OK");
                }
                // printf("\n");
            }
        };

        rep(i,H)rep(j,60){
            ll t = 60*i+j;

            // 1つめ
            ll p = 3600*t - 60*T*j;
            ll q = T - 60;
            upd(p,q,i,j);

            // 2つめ
            p = 3600*t + 60*T*j;
            q = 119*T - 60;
            upd(p,q,i,j);

            // 3つめ
            p = 3600*(T+t) + 60*T*j;
            q = 119*T - 60;
            upd(p,q,i,j);

            // 4つめ
            p = 3600*(t-T) + 60*T*j;
            q = 119*T - 60;
            upd(p,q,i,j);
        }

        PRINT_T(ans);
    }
    return 0;
}



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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e18
using namespace std;
typedef long long ll;

int a,b,c;
int main(){
  std::cin >> a >> b >> c;
  int res = MAX;
  res = min(res, a*b/2);
  res = min(res, b*c/2);
  res = min(res, c*a/2);
  std::cout << res << '\n';
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int> B(N, 0);

	rep(i, Q)
	{
		int a;
		cin >> a;
		a--;

		B[a]++;
	}

	rep(i, N)
	{
		if (Q - B[i] < K)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

const ll INF=1000000000000000;
struct edge{ll from, to, cost;};
vector<edge> es(2000);
vector<ll> d(1000,-INF);
vector<bool> usedV(1000,false),usedE(2000,false);
ll V,E;
bool can=true;

void BellmanFord(ll s){
    d[s]=0;
    ll count=0;
    while (true){
        bool update=true;
        rep(i,E){
            edge e=es[i];
            if (d[e.from]!=-INF&&d[e.to]<d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=false;
                usedV[e.to]=usedV[e.from];
                if (!usedE[i]){
                    usedE[i]=true;
                }
                else {
                    usedV[e.to]=true;
                }
            }
        }
        if (update){
            break;
        }
        else {
            count++;
        }
        if (count==2*E){
            if (usedV[V-1]){
                can=false;
            }
            break;
        }
    }
}

int main(){
    cin >> V >> E;
    rep(i,E){
        ll a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        es[i]=edge{a,b,c};
    }
    BellmanFord(0);
    if (!can){
        cout << "inf" << endl;
    }
    else {
        cout << d[V-1] << endl;
    }
}

Measured memory_bytes: 256
def resolve():
	a, b, c, k = map(int, input().split())
	s = [a, b, c]
	n = [1, 0, -1]
	ans = 0
	for i in range(3):
		if k - s[i] < 0:
			ans += n[i] * k
			print(ans)
			return
		k -= s[i]
		ans += s[i] * n[i]
	print(ans)
resolve()

Measured memory_bytes: 61856
#include<iostream>

using namespace std;

int main(){
  int dice[101][2];
  int n;
  cin >> n;
  for(int i=0;i < n;i++){
    cin >> dice[i][0] >> dice[i][1];
  }
  bool ok = false;
  for(int i=0;i < n-2;i++){
    if(dice[i][0] == dice[i][1] && dice[i+1][0] == dice[i+1][1] && dice[i+2][0] == dice[i+2][1]){
      ok = true;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;cin>>k;
  int tot=0;
  for(int i=1;i<=k;i++)for(int j=1;j<=k;j++){
        int tmp=gcd(i,j);      
        for(int l=1;l<=k;l++){
            tot+=gcd(tmp,l);
        }
  }
  cout<<tot<<endl;
  return 0;
}


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

using namespace std;

string s;
int x[2]; //-8000 ~ 8000
int p[2]; //8000
int v[2][10000]; //0 8000

int main(){
  cin>>s;
  s += 'E';
  cin>>x[0]>>x[1];
  int len = (int)s.length();


  int pp = 0;
  while(s[pp] == 'F') {
    x[0]--;
    pp++;
  }

  int d = 0;
  for(int i=pp;i<len;i++){
    if(s[i] == 'T'){
      d ^= 1;
    } else if(s[i] == 'F'){
      int tmp = 0;
      while(s[i] == 'F') {
        tmp++;
        i++;
      }
      i--;
      v[d][p[d]] = tmp;
      p[d]++;
    }
  }

  bool ans = true;

  for(int i=0;i<2;i++){
    int ma = 0;
    for(int j=0;j<p[i];j++)ma += v[i][j];

    int frip = 0;
    bool cango[2][40010];
    for(int j=0;j<40010;j++)for(int k=0;k<2;k++) cango[k][j] = false;
    int mid = 20005;
    cango[0][mid] = true;

    for(int k=0;k<p[i];k++){
      frip ^= 1;
      for(int j= -ma;j<=ma;j++){
        if(cango[frip^1][j+mid-v[i][k]] || cango[frip^1][j+mid+v[i][k]]) cango[frip][j+mid] = true;
        else cango[frip][j+mid] = false;
      }
      //for(int j= -ma;j<=ma;j++)cout<<cango[frip][j+mid]<<" ";cout<<endl;
    }

    if(!cango[frip][x[i]+mid]) ans = false;

  }

  if(ans){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }

  return 0;
}


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

int main(){
    int n,x,y,a,pi=1;
    scanf("%d %d %d %d",&n,&x,&y,&a);
    double mi=fabs(x-(double)a*0.006-y);
    for(int i=2;i<=n;i++){
        scanf("%d",&a);
        if(fabs(x-(double)a*0.006-y)<mi)mi=fabs(x-(double)a*0.006-y),pi=i;
    }
    printf("%d\n",pi);
    return 0;
}


Measured memory_bytes: 256
S = input()

List = list(S)
N = len(List)
N2 = int((N-1)/2)
ans = 1
arr = []

for i in range(N2):
  if List[i] == List[N-1-i]:
    arr.append(List[i])
  else:
    ans = 0

N3 = len(arr)
N4 = int(N3//2)
for i in range(N4):
  if arr[i] == arr[N3-1-i]:
    continue
  else:
    ans = 0

  
if ans == 1:
  print("Yes")
else:
  print("No")


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

int main(){

    string s;
  
  cin >> s;
  
  if(s[2] == s[3] ){
    if(s[4] == s[5]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int num,check=7,count,temp;
    while(cin>>num,num>=100 && num<1000)
    {
        count=0;
        while(num>0)
        {
        temp=num%10;
            if(temp==check)
            {
                count++;
                if(count!=0)
                {
                cout<<"Yes"<<endl;
                }
                break;
            }
            num/=10;
        }
        if(count==0)
        {
            cout<<"No"<<endl;
            break;
        }
      break;
    }
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
int book[151];
int main()
{
    string s;
    cin>>s;
    int j=0;

    for(int i=0;i<s.size();i++)
    {
        if(book[s[i]]==0)
        {
            book[s[i]]=1;
            j++;
        }
    }
    if(j==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

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


Measured memory_bytes: 3112
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int temp = 0;
		int[] point = new int[n+2];
		point[0] = 0;
		point[n+1] = 0;
		for (int i = 1; i < n+1; i++) {
			int a = sc.nextInt();
			point[i] = a;
			count += Math.abs(point[i] - point[i-1]);
		}
		count += Math.abs(point[n+1] - point[n]);
		
		for (int i = 1; i < n+1; i++) {
			temp = count;
			temp -= Math.abs(point[i] - point[i-1]) + Math.abs(point[i+1] - point[i]) - Math.abs(point[i+1] - point[i-1]);
			System.out.println(temp);
		}
	}
}

Measured memory_bytes: 61480
N = int(input())
hlist = list(map(int, input().split()))
hlist.insert(0, 0)
hlist.append(0)

water = 0
ceros = hlist.count(0)

while ceros!= len(hlist):
  Hlist = []
  cerolist = []
  for i in range(len(hlist)):
    Hlist.append(hlist[i])

  for j in range(ceros):
    p = Hlist.index(0)
    cerolist.append(p)
    Hlist[p] = 'None'

  for k in range(ceros- 1):
    p = cerolist[k]
    q = cerolist[k+ 1]
    if(q- p!= 1): 
      m = min(hlist[p+ 1: q])
      water+= m
      for l in range(p+ 1, q):
        hlist[l]-= m
      
  ceros = hlist.count(0)
print(water)

Measured memory_bytes: 3064
s = gets.chomp
q = gets.to_i
q.times {
	cmd = gets.split( " " )
	a = cmd[1].to_i
	b = cmd[2].to_i
	case cmd[0]
	when "print"
		puts( "#{ s[ a..b ] }" )
	when "reverse"
		s[ a..b ] = s[ a..b ].reverse
	when "replace"
		s[ a..b ] = cmd[3]
	end
}

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

int main(){
    string s, t; cin >> s >> t;
    ll ans = 0;

    for(long long i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    put(ans);
}

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

int main(){
  string s;
  cin >> s;
  int cnt=0;
  rep(i, s.size()/2){
    if(s[i]!=s[s.size()-i-1]){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

const int MAXN=200010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
int par[MAXN], dsu[MAXN];
pll A[MAXN];
int seg[MAXN<<1];
/*
struct CMP{
	bool operator ()(int x, int y){
		return pll(A[x].second*A[y].first, x)<pll(A[y].second*A[x].first, y);
	}
};
set<int, CMP> st;

FUCK C++ 9
FUCK C++ 11
FUCK atcoder
FUCK set
FUCK FUCK FUCK tabee int ke return nakone judgeo mikone :/
*/
int fuck(int x, int y){
	if (!x || !y) return x^y;
	if (A[x].second*A[y].first<A[y].second*A[x].first) return x;
	return y;
}
void Set(int pos, int val){
	seg[pos+=n]=val;
	for (; pos>1; pos>>=1) seg[pos>>1]=fuck(seg[pos], seg[pos^1]);
}

int getpar(int x){
	if (dsu[x]==x) return x;
	return dsu[x]=getpar(dsu[x]);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	iota(dsu, dsu+MAXN, 0);
	cin>>n;
	for (int i=2; i<=n; i++) cin>>par[i];
	for (int i=1; i<=n; i++){
		cin>>x;
		A[i]={x==0, x==1};
	}
	for (int i=2; i<=n; i++) Set(i, i);
	for (int i=1; i<n; i++){
		int v=seg[1], u=getpar(par[v]);
		assert(v);
		Set(u, 0);
		Set(v, 0);
		ans+=A[u].second*A[v].first;
		A[u].first+=A[v].first;
		A[u].second+=A[v].second;
		if (u>1) Set(u, u);
		dsu[v]=u;
	}
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 9836
#include <stdio.h>

int main(){

    int x,a,b;
    scanf("%d %d %d", &x, &a, &b);
    if(a>x){
        if(b>x){
            if((a-x)>(b-x)){
                printf("B\n");
            }
            else if((a-x)<(b-x)){
                printf("A\n");
            }
        }
        else if(b<x){
            if((a-x)>(x-b)){
                printf("B\n");
            }
            else if((a-x)<(x-b)){
                printf("A\n");
            }
        }
    }
    else if(a<x){
        if(b>x){
            if((x-a)>(b-x)){
                printf("B\n");
            }
            else if((a-x)<(b-x)){
                printf("A\n");
            }
        }
        else if(b<x){
            if((x-a)>(x-b)){
                printf("B\n");
            }
            else if((a-x)<(x-b)){
                printf("A\n");
            }
        }
    }



    return 0;
}

Measured memory_bytes: 1660
import sys
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
ban = [[False]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                ban[i][j] = True
na = []
nb = []
for i in range(3):
    if all(ban[i][j] for j in range(3)) or all(ban[k][i] for k in range(3)):
        print("Yes")
        sys.exit()
    na.append(ban[i][i])
    nb.append(ban[i][2-i])
if all(na) or all(nb):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    int Total=0;
    
    Total=H*W-h*W;
    System.out.println(Total-(H-h)*w);
  }
}

Measured memory_bytes: 22604
//
//  main.swift
//  AtCoder
//
//  Created by nakailand on 2020/08/19.
//  Copyright © 2020 nakailand. All rights reserved.
//

import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func prime_factor(n: Int) -> [Int] {
    var ret: [Int] = []
    var k = n
    for i in 2..<Int(sqrt(Double(n)))+1 {
        while k % i == 0 {
            ret.append(i)
            k = Int(floor(Double(k / i)))
        }
    }
    
    if k != 1 {
        ret.append(k)
    }
    
    return ret
}

let N = readInt()
var A = readInts()
var ans = 1000000007
for a in A {
    ans = min(prime_factor(n: a).filter { $0 == 2 }.count, ans)
}

print(ans)


Measured memory_bytes: 13596
n, k = map(int, input().split())
a = list(map(int, input().split()))

d = [0] * n
d[0] = 1
t = a[0]
cnt = 0
r = [1]

while d[t-1] == 0:
    cnt += 1
    d[t-1] = cnt + 1
    if k == cnt:
        print(t)
        exit()
    r.append(t)
    t = a[t-1]

rp = r[d[t-1]-1:]
b = (k-cnt) % len(rp)
print(rp[b-1])

Measured memory_bytes: 32352
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

vector<int>devisor(int n) {
	vector<int>value;
	FOR(i, 1, pow(n, 0.5) + 1) {
		if (n % i == 0) {
			value.push_back(i);
			if (i * i != n) {
				value.push_back(n / i);
			}
		}
	}
	return value;
}
int ans(int& gcd, vector<int>devisor,vector<int>&a) {
	bool flag = true;
	int i = 0;
	while (flag) {
		int count = 0;
		rep(j, a.size()) {
			if (a[j] % devisor[i] != 0) {
				count++;
			}
			if (count >= 2) {
				break;
			}
		}
		if (count <= 1) {
			gcd = max(gcd, devisor[i]);
			flag = false;
		}
		else {
			i++;
		}
	}
	return gcd;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));

	int b = a[0];
	int c = a[1];
	vector<int>div_b,div_c;
	div_b = devisor(b);
	div_c = devisor(c);
	sort(all(div_b));
	reverse(all(div_b));
	sort(all(div_c));
	reverse(all(div_c));
	int gcd = 1;
	int answer = max(ans(gcd, div_c, a), 
		ans(gcd, div_b, a));
	cout << answer << endl;

}


Measured memory_bytes: 640
while True:
    x, op, y = input().split()
    a = int(x)
    b = int(y)
    if op == '?':
        break
    elif op == '+':
        print("{:d}".format(a+b))
    elif op == '-':
        print("{:d}".format(a-b))
    elif op == '*':
        print("{:d}".format(a*b))
    elif op == '/':
        print("{:d}".format(a//b))



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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A, B, C, D, E, K; cin >> A >> B >> C >> D >> E >> K;
	cout << ((E - A > K) ? ":(" : "Yay!") << '\n';

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var ABC = Sarray();
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];
            var ans = 0L;
            var sft = 1L;
            if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0)
            {
                WriteLine(0);
                return;
            }
            for (var i = 0; i < 32; ++i)
            {
                if ((sft & A) == (sft & B) && (sft & B) == (sft & C)) { }
                else { break; }
                sft <<= 1;
                ++ans;
            }
            WriteLine(ans == 32 ? -1 : ans);

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13268
#!/usr/bin/env python3
import sys


def solve(x: int, a: int, b: int):
    if abs(a - x) < abs(b - x):
        ret = 'A'
    else:
        ret = 'B'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(x, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x, y;

    bool operator<(const P &a)const{
              return y>a.y;
    }

};


//vector<P> v[100100];
vector<long long> v;
vector<char> vs[1111];
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[111111];
int l[111111];
//int z1[1000100],z2[1000100];
int j[1];
int e[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=1000000007,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1111];
//stack<int> s;

//set<long long> s;
queue<int> q;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<long long,int> p;
//list<int> l;

string r;
//char r[1100222],r1[1101000];
//deque<int> de;
//srand((int)time(NULL));


bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        scanf("%d %d",&u[t].x,&u[t].y);
    d=((u[1].x+u[1].y)&1);
    for(int t=2;t<=a;t++)
        if(d!=((u[t].x+u[t].y)&1))
    {
        puts("-1");
        return 0;
    }
    if(!d)
    {
        v.push_back(1);
        for(int t=1;t<=a;t++)
            u[t].x++,vs[t].push_back('L');
    }
    long long k=1;
    for(int i=1;i<=33;k*=2,i++)
    {
        v.push_back(k);
        for(int j=1;j<=a;u[j].x/=2,u[j].y/=2,j++)
        if(u[j].x&1)
        {
            if(((u[j].x-1)&2)!=(u[j].y&2))
            {
                u[j].x--;
                vs[j].push_back('R');
            }
            else
            {
                u[j].x++;
                vs[j].push_back('L');
            }
        }
        else
        {
            if(((u[j].y-1)&2)!=(u[j].x&2))
            {
                u[j].y--;
                vs[j].push_back('U');
            }
            else
            {
                u[j].y++;
                vs[j].push_back('D');
            }
        }
    }
    v.push_back(k);
    for(int i=1;i<=a;i++)
    {
        if(u[i].x==-1) vs[i].push_back('L');
        if(u[i].x==1) vs[i].push_back('R');
        if(u[i].y==-1) vs[i].push_back('D');
        if(u[i].y==1) vs[i].push_back('U');
    }
    printf("%d\n",v.size());
    for(int i=0;i<v.size();i++)
        printf("%lld ",v[i]);
    puts("");
    for(int i=1;i<=a;i++)
    {
        for(int j=0;j<vs[i].size();j++)
            printf("%c",vs[i][j]);
        puts("");
    }
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    if (str[pos] != ')') { return error; }
    pos++;
  } else {
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

Measured memory_bytes: 0
/* ITP1_10_C */
#include <stdio.h>
#include <math.h>

/* ?¨???????????????????????????¢??° */
double calc_deviation(short n, short s[]);
/* ??????????????????????????¢??° */
double calc_average(short n, short s[]);
/* ?????£?????????????????¢??° */
double calc_variance(short n, short s[], double m);

int main(void)
{
	short n = 0, ii;
	double deviation = 0.0;
	
	while(1)
	{
		scanf("%hd", &n);
		
		// n???0?????¨?????????
		if( 0 == n )
		{
			break;
		}
		
		short student_points[n];
		for( ii = 0; ii < n; ii++ )
		{
			student_points[ii] = 0;
			scanf("%hd", &student_points[ii]);
		}
		
		deviation = calc_deviation(n, student_points);
		
		printf("%lf\n", deviation);
	}
	
	return 0;
}

/* ?¨???????????????????????????¢??° */
double calc_deviation(short n, short s[])
{
	double ave = calc_average(n, s);
	double dev = sqrt(calc_variance(n, s, ave));
	return dev;
}

/* ??????????????????????????¢??° */
double calc_average(short n, short s[])
{
	short ii;
	long sum = 0;

	for( ii = 0; ii < n; ii++ )
	{
		sum += s[ii];
	}
	
	double ave = (double)sum / n;
	
	return ave;
}

/* ?????£?????????????????¢??° */
double calc_variance(short n, short s[], double m)
{
	double variance = 0.0;
	short ii;
	
	for( ii = 0; ii < n; ii++ )
	{
		variance += ((double)(s[ii] - m) * (double)(s[ii] - m));
	}
	
	return variance / n;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,k,s;
 	cin>>n>>k>>s;
 	ll a[n];
 	ll ans[n];
 	for(ll i=0;i<k;i++)
 	{
 		ans[i]=s;
 	}
 	for(ll i=k;i<n;i++)
 	{
 		if(s!=1000000000)
 		ans[i]=s+1;
 		else
 		ans[i]=s-1;
 	}
 	for(ll i=0;i<n;i++)
 	{
 		cout<<ans[i]<<" ";
 	}cout<<endl;
    return 0;
}

Measured memory_bytes: 2176
grid = []
for i in range(3):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x = 0
result = []
while x < grid[0][0]:
    calc = grid[1][0] - grid[2][x] * 0.006
    result.append(calc)
    x += 1

y = 0
result_comp = []
while y < len(result):
    comp = result[y] - grid[1][1]
    comp = abs(comp)
    result_comp.append(comp)
    y += 1

print(result_comp.index(min(result_comp)) + 1)


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

// 
int main() {
    int N;
    cin >> N;
    int sqrtN = sqrt(N);
    int ans = 0;
    for (int i = 1; i <= sqrtN ; i++) {
        for (int j = i; j < N; j++) {
            if (i * j >= N) break;
            if (i == j) ans++;
            else ans += 2;
        }
    }
    cout << ans;
}


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

#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int sub(int x,int y){
	return add(x,mod-y);
}
int mul(int x,int y){
	return (int)((long long int)x*y%mod);
}

int calc(int n){
	int tot = 0, res = 0;
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		if(x < 0)x +=mod;
		tot = add(tot, x);
		res = add(res, sub(mul(x,i),tot));
	}
	return res;
}

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int A = calc(n);
	int B = calc(m);
	printf("%d\n",mul(A,B));
	return 0;
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            if (n == 0 && x == 0) goto readend;
            var count = 0;
            for (int i = 1; i < n + 1; i++)
                for (int j = i + 1; j < n + 1; j++)
                    for (int k = j + 1; k < n + 1; k++)
                        if (i + j + k == x) count++;
            Console.WriteLine(count);
            count = 0;
        }
        readend:;
    }
}

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

long long INF = (1 << 31) - 1;

class SegmentTree {
private:
	long long Size;
	vector<long long> Node;
public:
	SegmentTree(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.resize(Size * 2, -INF);
	}
	SegmentTree(vector<long long>& V) {
		Size = 1;
		while (Size < V.size()) Size <<= 1;
		Node.resize(Size * 2, -INF);
		for (int i = 0; i < V.size(); i++) {
			Node[Size + i] = V[i];
		}
		for (int i = Size - 1; i > 0; i--) Node[i] = max(Node[i * 2], Node[i * 2 + 1]);
	}
	void Update(long long K, long long X) {
		K += Size;
		Node[K] = X;
		while (K > 1) {
			K >>= 1;
			Node[K] = max(Node[K * 2], Node[K * 2 + 1]);
		}
	}
	long long Query(long long L, long long R) {
		long long NOWS = Size, ANS = -INF;
		while (R > L) {
			if (L & 1) {
				ANS = max(ANS, Node[L + NOWS]);
				L++;
			}
			if (R & 1) {
				ANS = max(ANS, Node[R - 1 + NOWS]);
				R--;
			}
			L >>= 1, R >>= 1, NOWS >>= 1;
		}
		return ANS;
	}
};

int main() {
	long long N, MOD = 998244353;
	cin >> N;
	vector<pair<long long, long long> > VP(N);
	vector<long long> X(N);
	for (int i = 0; i < N; i++) cin >> VP[i].first >> VP[i].second, X[i] = VP[i].first;
	sort(VP.begin(), VP.end()), sort(X.begin(), X.end());
	vector<long long> To(N);
	for (int i = 0; i < N; i++) {
		To[i] = lower_bound(X.begin(), X.end(), VP[i].first + VP[i].second) - X.begin();
	}
	SegmentTree Seg(To);
	for (int i = N - 1; i >= 0; i--) {
		To[i] = Seg.Query(i, To[i]);
		Seg.Update(i, To[i]);
	}
	vector<vector<long long> > DP(N + 1, vector<long long>(2, 0));
	DP[N][0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		DP[i][0] = DP[To[i]][0] + DP[To[i]][1];
		DP[i][1] = DP[i + 1][0] + DP[i + 1][1];
		DP[i][0] %= MOD;
		DP[i][1] %= MOD;
	}
	cout << (DP[0][0] + DP[0][1]) % MOD << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x->left != NIL){
    x = x->left;
  }
  return x;

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if (k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if( x->right != NIL){
    return treeMinimum(x->right);
  }
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if( y->left != NIL){
    x = y->left;
  }
  else x = y->right;

  if(x != NIL ){
    x->parent = y->parent;
  }

  if( y->parent == NIL ){
    root = x;
  }
  else {
    if(y == y->parent->left){
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if( y != z ){
    z->key = y->key;
  }

  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if ( z->key < y->key ){
      y->left = z;
    }else {
      y->right = z;
    }
  }

}

void inorder(Node u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a,b,c,d;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=N%10;
  if(a==b && b==c){
    cout << "Yes" << endl;
  }
  else if (b==c && c==d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Some Sums
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int cnt = 0;
  for (int m = 1; m <= n; m++) {
    int sum = 0;
    for (int k = m; k > 0; k /= 10) sum += k % 10;
    if (a <= sum && sum <= b) cnt += m;
  }

  printf("%d\n", cnt);
  return 0;
}


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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N, W;
  cin >> N >> W;
  
  Vi We(110);
  Vi V(110);
  
  rep(i, N){
    cin >> We[i] >> V[i];
  }
  
  vector<vector<ll>> dp(110, vector<ll>(100100, 0));
  
  rep(i, N){
    rep(sum_w, W+1){
      
     if(sum_w + We[i] <= W){
        dp[i+1][sum_w + We[i]] = dp[i][sum_w] + V[i];
      }
      
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
       
      
    }
  }
  
  cout << dp[N][W] << endl;
  
        
      
}

      
      
       




Measured memory_bytes: 90320
import java.util.*; 
import java.io.*; 

public class Main {
	public static void main(String[] args) throws IOException {
       InputReader in = new InputReader(System.in);
       int n = in.readInt(); 
       HashMap<String ,Integer> map = new HashMap<>(); 
       
       for(int i =0; i<n; i++) {
    	   String s = in.readString();
    	   if(map.containsKey(s)) {
    		    map.put(s, map.get(s) + 1);
    	   }
    	   else  map.put(s, 1);
       }
        
       HashSet<String> votes = new HashSet<>(); 
       
       int max = Integer.MIN_VALUE; 
       for(Map.Entry<String, Integer> entry: map.entrySet()) {
    	   if(max <= entry.getValue()) {
    		   max = entry.getValue();
    	   }
       }
       for(Map.Entry<String , Integer> entry: map.entrySet()) {
    	   if(entry.getValue() == max) {
    		   votes.add(entry.getKey()); 
    	   }
       }
    	 ArrayList<String> list = new ArrayList<>(votes); 
       Collections.sort(list);
       for(String i : list) {
    	   System.out.println(i); 
       }
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 78796
void main() {
	auto M = ri;
	writeln(48 - M);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
s = input()
a = [0]*26
ans = 1
mod = 10**9+7
for i in range(n):
        a[ord(s[i]) - ord("a")] += 1
for i in a:
        ans *= (i+1)
        ans%=mod
print(ans-1)

Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b; cin>>a>>b;
  if(a>12)cout<<b<<endl;
  else cout<<(a>5? b/2 : 0)<<endl;
}


Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int a, b; cin >> a >> b;
	cout << 1LL*(a==1?1:a - 2) * (b==1?1:b - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,n):
        self.d = [-1] * n
    
    def find(self,x):
        if self.d[x] < 0:
            return x
        else:
            return self.find(self.d[x])
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if(-self.d[x] < -self.d[y]):
            x,y = y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

n,m = map(int,input().split())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    uf.unite(a,b)

print(-min(uf.d))

Measured memory_bytes: 14728
#include <stdio.h>

#define N 100

int main(){

  int A[N]={0};
  int length, key;
  int i = 0, j = 0;
  
  scanf("%d", &length);
  while(i < length){
    scanf("%d", &A[i]);
    i++;
  }

  for(j = 0; j < length-1; j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[length-1]);
  
  for(i = 1; i < length; i++){
    key = A[i];
    j = i-1;
    
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    
    A[j+1] = key;
    
    for(j = 0; j < length-1; j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[length-1]);
  }
  
  return 0;
}




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

int main(){
  long int n,a,b;
  cin >> n >> a >> b;
  if((b-a)%2==0){
    cout << (b-a)/2 << endl;
  }else{
    long int m;
    m=min((a+b-1)/2,(2*n-a-b+1)/2);
    cout << m << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 100000;
bool primes[N+1];
int similar[N+1];

int main() {
  for (int i = 2; i <= N; i++) primes[i]=true;
  for (int i = 2; i*i <= N; i++)
    if (primes[i])
      for (int j = i*2; j <= N; j+=i) primes[j]=false;
  for (int i = 1; i <= N; i++)
    if (primes[i] && primes[(i+1)/2]) similar[i]++;
  for (int i = 1; i <= N; i++)
    similar[i] += similar[i-1];
  int q, l, r;
  cin >> q;
  while (q--) {
    cin >> l >> r;
    cout << similar[r] - similar[l-1] << endl;
  }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

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

    int a[N+1],b[N+1],c[N];

    for(int i = 1; i< N+1; i++) cin >> a[i];
    for(int i = 1; i< N+1; i++) cin >> b[i];
    for(int i = 1; i< N; i++) cin >> c[i];

    int sum = 0;
    repr(i,1,N+1){
        sum += b[a[i]];
    }

    repr(i,1,N){
        if(a[i]+1 == a[i+1]){
        sum += c[a[i]];
        }
    }
    cout << sum << endl;

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int h, w, k;
	cin >> h >> w >> k;
	char c[h][w];
	int cnt = 0;

	zip(i, 0, h)
	{
		zip(j, 0, w)
		{
			cin >> c[i][j];
			if (c[i][j] == '#')
				cnt++;
		}
	}
	int ans = 0;
	for (int mask1 = 0; mask1 < (1 << h) ; mask1++)
	{
		for (int mask2 = 0; mask2 < (1 << w) ; mask2++)
		{
			map<int, int>m1, m2;
			int c1 = 0;
			zip(i, 0, h)
			{
				zip(j, 0, w)
				{
					if (!(mask1 & (1 << i)) && !(mask2 & (1 << j)))
					{
						if (c[i][j] == '#')
							c1++;
					}
				}
			}
			// zip(i, 0, h)
			// {
			// 	zip(j, 0, w)
			// 	{
			// 		if (m1[i] == 0  && m1[j] == 0 && c[i][j] == '#')
			// 			c1++;
			// 	}
			// }
			if (c1 == k)
				ans++;
		}
	}
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w, n; cin >> h >> w >> n;
  vector<int> a(n), b(n); REP(i, n) cin >> a[i] >> b[i];
  set<pair<int, int> > st;
  vector<ll> ans(10, 0);
  ans[0] = 1LL * (h - 2) * (w - 2);
  REP(i, n) {
    FOR(sy, max(a[i] - 2, 1), a[i] + 1) FOR(sx, max(b[i] - 2, 1), b[i] + 1) {
      if (sy + 2 <= h && sx + 2 <= w) {
        int cnt = 0;
        REP(y, 3) REP(x, 3) cnt += st.count({sy + y, sx + x});
        REP(j, 10) {
          if (cnt == j) --ans[j];
          if (cnt == j - 1) ++ans[j];
        }
      }
    }
    st.emplace(a[i], b[i]);
  }
  REP(i, 10) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 5760