akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	long long a = 1;
	rep(i,N){
		if(a < K){
			a *= 2;
		}else{
			a += K;
		}
	}
	cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dp[200005];
long long int n;
vector<long long int > arr(200005);
long long int mini=1e5;
long long int gen(long long int i)
{
    //for(int i=x;i<n;i++)
      //  dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      long long int ans;
        if(i>=n-1)
            return 0;
        if(dp[i]!=-1)
            return dp[i];

        ans=gen(i+1)+abs(arr[i]-arr[i+1]);
        if(i<n-2)
            ans=min(ans,gen(i+2)+abs(arr[i]-arr[i+2]));

      return dp[i]=ans;
}
int main()
{
   // int n;
    cin>>n;
   // vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    //input part has been done

    long long int mini=1e5;
    memset(dp,-1,sizeof(dp));
    //initialization
    //dp[0]=0;
    //dp[1]=abs(arr[0]-arr[1]);


    cout<<gen(0);
    //cout<<dp[n-1];
}



Measured memory_bytes: 9496
#pragma GCC target("avx")
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <cmath>

template<typename T> void fastscan(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

template<typename T> void fastout(T &n) {
  T N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar_unlocked('0');
    putchar_unlocked('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar_unlocked(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar_unlocked('0');
  putchar_unlocked('\n');
}
 
int main(){    
    int N; fastscan(N);
    int v[N];
    for (int i = 0; i < N; ++i) fastscan(v[i]);
    int sum = 0;
 
    for (int i = 1; i < N; ++i) sum += abs(v[i - 1] - v[i]);
    sum += abs(0 - v[0]) + abs(v[N - 1]);
    int diff[N]; 
    diff[0] = abs(0 - v[0]) + abs(v[0] - v[1]) - abs(0 - v[1]);
    for (int i = 1; i < N - 1; ++i){
        diff[i] = abs(v[i - 1] - v[i]) + abs(v[i] - v[i + 1]) - abs(v[i - 1] - v[i + 1]);
    }
    diff[N - 1] = abs(v[N - 2] - v[N - 1]) + abs(v[N - 1]) - abs(v[N - 2]);
 
    for (int i = 0; i < N; ++i){
        int ans = sum - diff[i];
        fastout(ans);
    }
    return 0;
}


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

using namespace std;

#define int int64_t
#define all(x) begin(x), end(x)

typedef long long ll;

const int inf = 1e9;
const int maxn = 303;

const int mod = 1e9 + 9;

typedef double ftype;
typedef complex<ftype> point;
#define x real
#define y imag

const ftype eps = 1e-6;

template<typename T>
bool eq(T a, T b) {
	return abs(a - b) < eps;
}

ftype dot(point a, point b) {
	return (conj(a) * b).x();
}
ftype cross(point a, point b) {
	return (conj(a) * b).y();
}
bool lex(point a, point b) {
	return make_pair(a.y(), a.x()) < make_pair(b.y(), b.x());
}
bool ang(point a, point b) {
	if(eq(cross(a, b), 0.)) {
		return norm(a) < norm(b);
	} else {
		return cross(a, b) > 0;
	}
}

bool collin(point a, point b) {
	return eq(cross(a, b), 0.);
}

void polar_sort(vector<point> &r) {
	int n = r.size();
	sort(all(r), lex);
	sort(begin(r) + 1, end(r), [&](point a, point b) {
		return ang(a - r[0], b - r[0]);
	});
	int t = n - 1;
	while(t > 0 && collin(r.back() - r[0], r[t] - r[0])) {
		t--;
	}
	reverse(begin(r) + t + 1, end(r));
}

vector<point> convex_hull(vector<point> r) {
	int n = r.size();
	polar_sort(r);
	vector<point> st = {r[0]};
	for(int i = 1; i < n; i++) {
		while(st.size() >= 2 && cross(r[i] - st[st.size() - 1], r[i] - st[st.size() - 2]) > 0) {
			st.pop_back();
		}
		st.push_back(r[i]);
	}
	return st;
}

signed main() {
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	ftype x, y;
	vector<point> r(n);
	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		r[i] = {x, y};
	}
	r = convex_hull(r);
	cout << r.size() << endl;
	for(auto it: r) {
		cout << it.x() << ' ' << it.y() << endl;
	}
}



Measured memory_bytes: 7548
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

[a,b,c,d,e,f]=i2()
w=[]
s=[]
for i in range(f+1):
    for j in range(f+1):
        t=(a*i+b*j)*100
        tt=c*i+d*j
        if t<=f:
           w.append(t)
        if tt<=f:
           s.append(tt)
a=0
g=[]
for i in w:
 for j in s:
     if 0<i+j<=f and j<=i*e/100:
        g.append([j*100/(i+j),i+j,j])
g.sort()
print(g[-1][1],g[-1][2])

Measured memory_bytes: 141868
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
   int n,x;

   while(1){
      int count = 0;
      cin >> n >> x;
      if(n==0 && x==0) break;
      else {
         for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
               for(int k=j+1;k<=n;k++){
                  if(i+j+k==x) count++;
               }
            }
         }
         printf("%d\n",count);
      }
   }
   return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli a, b;
    cin >> a >> b;
    string ans;
    if (a * b <= 0) {
        ans = "Zero";
    } else if (a > 0) {
        ans = "Positive";
    } else {
        if ((b - a) % 2 == 0) {
            ans = "Negative";
        } else
            ans = "Positive";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<int,int> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<P> x;
  int lp=0,rq=1e9+10;
  rep(i,n){
    int l,r;
    cin>>l>>r;
    r++;
    lp=max(l,lp);
    rq=min(r,rq);
    x.push_back(P(l,r));
  }
  int ans=max(0,rq-lp);
  int ma=0;
  rep(i,n){
    ma=max(ma,x[i].se-x[i].fi);
  }
  ans+=ma;
  vector<P> cnt;
  rep(i,n){
    cnt.push_back(P(max(0,x[i].se-lp),min(0,-rq+x[i].fi)));
  }
  sort(begin(cnt),end(cnt));
  int now=1e9+10;
  rep(i,n){
    cnt[i].se*=-1;
    if(i){
      ans=max(ans,now+cnt[i].fi);
    }
    now=min(now,cnt[i].se);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    char[] cs;
    Set<Character> set;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        set = new HashSet<>();
        solve();
    }

    void solve() {
        for (int i = 0; i < cs.length; i++) {
            if (set.contains(cs[i])) {
                System.out.println("no");
                return;
            } else {
                set.add(cs[i]);
            }
        }
        System.out.println("yes");
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
from bisect import bisect_left
mod=10**9+7
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.sort(); B.sort()

def solve(n,m,A,B):
    if len(set(A))!=n or len(set(B))!=m:
        return 0
    if A[-1]!=n*m or B[-1]!=n*m:
        return 0
    ans=1
    for x in range(n*m-1,0,-1):
        A_idx=bisect_left(A,x)
        B_idx=bisect_left(B,x)
        if A[A_idx]==B[B_idx]==x:
            continue
        elif A[A_idx]==x:
            ans*=m-B_idx
            ans%=mod
        elif B[B_idx]==x:
            ans*=n-A_idx
            ans%=mod
        else:
            if (n-A_idx)*(m-B_idx)<=n*m-x:
                return 0
            ans*=(n-A_idx)*(m-B_idx)-(n*m-x)
            ans%=mod
        if A[A_idx]==B[B_idx]==0:
            break
    for i in range(1,x):
        ans*=i
        ans%=mod
    return ans

print(solve(n,m,A,B))

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

int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        string s;
        cin >> s;

        lld first = 0, second = 0;
        for(lld i = 0; i < 2; i++) {
            first = first * 10 + (s[i] - '0');
        }
        for(lld i = 2; i < 4; i++) {
            second = second * 10 + (s[i] - '0');
        }

        if((first > 0 && first <= 12) && (second > 0 && second <= 12)) {
            cout << "AMBIGUOUS\n";
        } else if(first > 12 && second > 12) {
            cout << "NA\n";
        } else {
            if(first > 12 && (second > 0 && second <= 12)) {
                cout << "YYMM\n";
            } else if(second > 12 && ((first > 0 && first <= 12))) {
                cout << "MMYY\n";
            } else {
                if(first == 0 && (second > 0 && second <= 12)) {
                    cout << "YYMM\n";
                } else if((second == 0 && (first > 0 && first <= 12))) {
                    cout << "MMYY\n";
                } else {
                    cout << "NA\n";
                }
            }
        }
    }
}

Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut max_nums = vec![];

    for &i in &a {
        match bin_search(&max_nums, i) {
            MAX => {
                max_nums.insert(0, i);
            }
            0 => {
                if max_nums[0] < i {
                    max_nums[0] = i;
                } else {
                    max_nums.insert(0, i);
                }
            }
            num => {
                max_nums[num] = i;
            }
        }

        //println!("{:?}", max_nums);
    }

    println!("{}", max_nums.len());
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 二分探索 vは単調増加 v[x] <= aとなる最小のxを返す
fn bin_search(v: &[usize], a: usize) -> usize {
    if v.is_empty() || a <= v[0] {
        return MAX;
    }
    let mut min = 0;
    let mut max = v.len();
    while max - min > 1 {
        let mid = (min + max) / 2;
        if v[mid] < a {
            min = mid;
        } else {
            max = mid;
        }
    }
    min
}


Measured memory_bytes: 10620
package main

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

func main() {
	readInt()
	S, Result, Checker := readString(), 0, 0

	for _, c := range strings.Split(S, "") {
		switch c {
		case "A":
			Checker = 1

		case "B":
			if Checker == 1 {
				Checker = 2
			} else {
				Checker = 0
			}

		case "C":
			if Checker == 2 {
				Result++
			}
			Checker = 0
		}
	}

	fmt.Println(Result)
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}


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

int main() {
    int N;    
    cin >> N;
    vector<int> a(N);
    
    for(int i=0; i<N; i++){
	cin >> a[i];
    }
    sort(a.begin(), a.end());

    for(int i=0; i<N-1; i++){
	if(a[i]==a[i+1]){
	    cout << "NO" << endl;
	    return 0;
	}
    }
    cout << "YES" << endl;



}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>

using namespace std;

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b


int main()
{
    int N, M;
    int Am[10000];
    long int sum = 0;
    
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> Am[i];
        sum += Am[i];
    }

    if (N < sum)
    {
        cout << -1 << endl;
    }
    else {
        cout << N - sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
// Reconstruction of tree by pre-order and in-order
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
void reconstruction(int, int);
int n;
std::vector<int> in;
std::queue<int> pre,post;
int main(){
  std::cin>>n;
  for(int i=0, tmp;i<n;i++) std::cin>>tmp, pre.push(tmp);
  for(int i=0, tmp;i<n;i++) std::cin>>tmp, in.push_back(tmp);
  reconstruction(0, n);
  for(int i=0;i<n;i++){
    std::cout<<post.front();
    post.pop();
    std::cout<<(i!=n-1?" ":"\n");
  }
  return 0;
}
void reconstruction(int l, int r){
  if(l >= r) return;
  int c=pre.front();
  pre.pop();
  int m=distance(in.begin(), find(in.begin(), in.end(),c));
  reconstruction(l, m);
  reconstruction(m+1, r);
  post.push(c);
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    int t[100000], x[100000], y[100000];
    REP(i, n) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool flag = true;
    int px = 0, py = 0, pt = 0;
    REP(i, n) {
        int d = abs(px - x[i]) + abs(py - y[i]);
        int dt = t[i] - pt;
        if ( d > dt ) {
            flag = false;
            break;
        }

        if ( d != dt && !(d % 2 == 0 && dt % 2 == 0) && !(d % 2 != 0 && dt % 2 != 0) ){
            flag = false;
            break;
        }


        px = x[i];
        py = y[i];
        pt = t[i];
    }

    if ( flag ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 1408
package main

import "fmt"

func main() {
	var a, b int

	fmt.Scan(&a)
	fmt.Scan(&b)

	fmt.Println(a * b / gcd(a, b))
}

func gcd(n1, n2 int) int {
	if n1%n2 == 0 {
		return n2
	} else {
		return gcd(n2, n1%n2)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
    string res="";
    for(int i=0;i<int(s.size());i++){
        int m=(s[i]-'A'+n)%26;
        int p=m+'A';
        res+=char(p);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define F first
#define S second
#define PB push_back
#define M 998244353
ll k,n,ka[4005],o[4005];
ll pw(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%M;
        x=x*x%M;
        y>>=1;
    }
    return res;
}
ll cm(ll x,ll y){
    if(x==0||y==0)return 1;
    return ka[x]*o[y]%M*o[x-y]%M;
}
vector<ll>ans;
int main(void){
    cin>>k>>n;
    ka[0]=1;
    o[0]=1;
    if(k<=1){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=1;i<=n+k;i++){
        ka[i]=ka[i-1]*i%M;
        o[i]=pw(ka[i],M-2);
    }
    for(ll i=0;i<(k+1)/2;i++){
        ll s=0;
        for(ll j=0;j<=i&&j<=n;j++){
            s=(s+(cm(n+k-i-j-2,n-j)+cm(n+k-i-j-3,n-j-1))%M*cm(i,j)%M)%M;
        }
        ans.PB(s);
    }
    for(int i=0;i<ans.size()-1;i++){
        cout<<ans[i]<<endl<<ans[i]<<endl;
    }
    cout<<ans[ans.size()-1]<<endl;
    if(k%2==0)cout<<ans[ans.size()-1]<<endl<<ans[ans.size()-1]<<endl;
    for(int i=ans.size()-2;i>=0;i--){
        cout<<ans[i]<<endl<<ans[i]<<endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000007
const int maxn=2e5+10;

ll n;

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	vector<ll>a;
	a.clear();
	for(int i=0;i<n;i++){
		ll tmp;
		cin>>tmp;
		a.push_back(tmp);
	}
	ll tmp=a[0];
	for(auto it=a.begin()+1;it!=a.end();it++){
		if(*it==tmp){
			a.erase(it);
			it--;
		}
		tmp=*it;
	}
	ll mon=1000,cnt=0;
	if(a[0]<a[1]){
		cnt+=mon/a[0];
		mon%=a[0];
	}
	int i=1;
	for(;i<a.size()-1;i++){
		if(a[i]>a[i-1]&&a[i]>a[i+1]){
			mon+=a[i]*cnt;
			cnt=0;
		}
		else if(a[i]<a[i+1]&&a[i]<a[i-1]){
			cnt+=mon/a[i];
			mon%=a[i];
		}
	}
	if(a[i]>a[i-1]){
		mon+=a[i]*cnt;
		cnt=0;
	} 
	cout<<mon<<endl;
	return 0; 
}


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

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='F'&&s[i+1]=='E'&&s[i+2]=='S'&&s[i+3]=='T'&&s[i+4]=='I'&&s[i+5]=='V'&&s[i+6]=='A'&&s[i+7]=='L'&&(i+8)==s.size()) break ;
         cout<<s[i];
    }
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge>> Graph;

void DFS(const Graph& g,int v,vi& vis,vi& order)
{
	if(vis[v]) return;
	vis[v]=1;
	for(auto e:g[v]) DFS(g,e.dst,vis,order);
	order.push_back(v);
}

vvi SCC(const Graph& g)
{
	int n=g.size();
	vi vis(n),order;
	rep(i,n) DFS(g,i,vis,order);
	Graph t(n);
	rep(i,n) for(auto e:g[i])
		t[e.dst].emplace_back(e.dst,e.src);
	fill(all(vis),0);
	vvi res;
	per(i,n) if(!vis[order[i]]){
		res.resize(res.size()+1);
		DFS(t,order[i],vis,res.back());
	}
	return res;
}

int calc(const Graph& g,int v)
{
	int res=1;
	for(auto e:g[v])
		res=(ll(res)*calc(g,e.dst))%MOD;
	return res+1;
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		Graph g(n);
		rep(i,m){
			int u,v; cin>>u>>v; u--,v--;
			g[u].emplace_back(u,v);
		}
		
		vvi scc=SCC(g);
		vi f(n);
		rep(i,scc.size()) rep(j,scc[i].size())
			f[scc[i][j]]=i;
		
		Graph g2(scc.size());
		{
			set<pii> ps;
			rep(i,n) for(auto e:g[i]) if(f[e.src]!=f[e.dst])
				ps.insert(mp(f[e.dst],f[e.src]));
			for(auto p:ps)
				g2[p.first].emplace_back(p.first,p.second);
		}
		vi deg(g2.size()); // 入次数
		rep(i,g2.size()) for(auto e:g2[i])
			deg[e.dst]++;
		
		int res=1;
		rep(i,g2.size()) if(deg[i]==0)
			res=(ll(res)*calc(g2,i))%MOD;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;

int power(int n) {
    int res=1;
    for(int i=0;i<n;i++){
        res*=i+1;
    }
    return res;
}

int main(void) {

    int n;
    cin>>n;
    vi seq(n);
    rep(i,n)seq[i] = i;
    double sum = 0;
    vd x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i,power(n)){
        double tmp=0;
        for(int i=0;i<n-1;i++){
            tmp+=sqrt(pow(x[seq[i]]-x[seq[i+1]],2) + pow(y[seq[i]]-y[seq[i+1]],2));
        }
        // cout<<tmp<<endl;
        next_permutation(seq.begin(),seq.end());
        sum+=tmp;
    }
    sum/=power(n);
    printf("%.7f\n",sum);

}


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

int main() {
    int a, b;
    cin >> a >> b;
//    if(a <= 5){
//        cout << 0 << endl;
//    }else if(a <= 12){
//        cout << b / 2 << endl;
//    }else{
//        cout << b << endl;
//    }
    cout << (a >= 6) * ((a > 12) ? b : b / 2) << endl;
    return 0;
}



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


int main(){
    int n ,x;
    cin >> n >> x;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    int count=0;
    for(int i=0;i<n;i++){
        x -= a.at(i);
        if(x<0){
            cout << count << endl;
            return 0;
        }
        count ++;
    }
    if(x > 0){
        cout << count - 1 << endl;
    }else{
        cout << count << endl;
    }
    return 0;
}

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


def solve(r: int):
    print(3 * (r ** 2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)


if __name__ == '__main__':
    main()


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, std::vector<long long> A){

    lli sum=0;
    lli cnt=0;
    REP(i,0,N){
        sum += abs(A[i]);
        if(A[i]<0){
            cnt++;
            A[i]*=-1;
        }
    }

    sort(A.begin(),A.end());

    if(cnt%2)sum-=2*A[0];

    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


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

int main()
{
	int n, d, x;
	int p[10][10];
	int dp[100001];

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			p[i][j] = 0;
		}
	}

	for (int i = 0; i < 100001; i++) {
		dp[i] = 0;
	}

	cin >> n >> d >> x;

	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}

	for (int day = 0; day < d - 1; day++) {
		for (int i = 0; i <= x; i++) {
			dp[i] = i;
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= x; j++) {
				if (j - p[day][i] >= 0) {
					dp[j] = max(dp[j], dp[j - p[day][i]] + p[day + 1][i]);
				}
			}
		}

		int nx = 0;
		for (int i = 0; i <= x; i++) {
			nx = max(nx, dp[i]);
		}

		x = nx;
	}

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
template<typename T> void stmin(T &a,T b){if(a>b)a=b;}
template<typename T> void stmax(T &a,T b){if(a<b)a=b;}
#define mod 1000000007
#define pll pair<ll,ll>
#define f2(n) for(long long int j=0;j<n;j++)
#define p(n) cout<<n<<endl;
#define f(n) for(long long int i=0;i<n;i++)
#define fv(v) for(auto &x:v)
#define io_boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fg cout<<"flag"<<endl;
#define pn cout<<"\n";
#define t(a) f(sizeof(a)/sizeof(a[0]))cin>>a[i];
#define pv(a) for(auto i=a.begin();i!=a.end();i++){cout<<*i<<" ";}pn
#define pa(a) f(sizeof(a)/sizeof(a[0])){cout<<a[i]<<" ";}pn
#define w(x) cout<<(#x)<<" is "<<(x)<<endl;
#define all(v) v.begin() , v.end()
#define ff first
#define ss second
#define pb push_back
ll solve(){
    ll n,d,a;
    cin>>n>>d>>a;
    pll m[n];
    f(n){
        cin>>m[i].ff>>m[i].ss;
    }
    sort(m,m+n);
    ll ans=0,t=0;
    std::vector<pll> v;
    f(n){
        while(v.size()&&v[0].ff<m[i].ff){
            t-=v[0].ss;
            v.erase(v.begin());
        }
        m[i].ss-=t*a;
        if(m[i].ss>0){
            ll t1=(m[i].ss)/a;
            if(t1*a<m[i].ss){
                t1++;
            }
            ans+=t1;
            v.pb({m[i].ff+2*d,t1});
            t+=t1;
        }
    }
    p(ans)
}
int main()
{io_boost
    ll test=1,c=1;
    //cin>>test;
    while(test--)
    {
        //cout<<"Case #"<<c++<<": ";
        solve();
        //cout<<endl;
    }
}

Measured memory_bytes: 5620
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| x; num |] ->
    if num = 0 then
        stdin.ReadLine() |> ignore
        x
    else
        ()
        |> readIntArray
        |> fun a ->
            let max = a |> Array.max
            let min = a |> Array.min
            [| min - 1 .. max + 1 |]
            |> Array.filter (fun z ->
                a
                |> Array.tryFind (fun a -> a = z)
                |> Option.isNone)
            |> Array.sortBy (fun z -> abs (z - x))
            |> Array.head
|> printfn "%d"


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

// https://atcoder.jp/contests/abc090/tasks/abc090_b
bool parindromic(int N){
// stol使う https://ja.cppreference.com/w/cpp/string/basic_string/stol
    int Ncopy,parInt;
    Ncopy = N;
    bool result=true;
    string parStr="";
    while(N > 0){
        int modN;
        modN = N % 10;
        parStr = parStr.append(to_string(modN));
        N = N / 10;
    }
    parInt = stol(parStr);
    // cout << parInt << "=?" << Ncopy << endl;
    if(Ncopy != parInt){
        result = false;
    }
    return result;
}


int solver(int nFr,int nTo){
    int result=0;
    // cout << nFr << " To " << nTo << endl;
    for(int j=nFr;j<= nTo;j++){
        bool pariCheck;
        pariCheck = parindromic(j);
        if(pariCheck){
            // cout << j << " is Parindric" << endl;
            result = result+1;
        }
    }
    return result;
}

int main(void){
    int answer=0;
    int A,B;
    cin >> A >> B ;
    answer  = solver(A,B);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

string s;

int main(){
	while(getline(cin,s),s!="."){
		stack<int> S;
		int ok=1;
		rep(i,s.sz){
			if(s[i]=='(')S.push(0);
			if(s[i]=='[')S.push(1);
			if(s[i]==')'){
				if(!S.sz||S.top()==1){ok=0;break;}
				S.pop();
			}
			if(s[i]==']'){
				if(!S.sz||S.top()==0){ok=0;break;}
				S.pop();
			}
		}
		cout<<(ok&&!S.sz?"yes":"no")<<endl;
	}
}

Measured memory_bytes: 904
#include <stdio.h>
int main(void){
    int n,m,x,i,j,k,check=0;
    long long ans=100000000;
    scanf("%d%d%d",&n,&m,&x);
    int c[n],a[n][m],cnt[m];
    for(i=0;i<n;i++){
        scanf("%d",&c[i]);
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<(1<<n);i++){
        for(j=0;j<m;j++) cnt[j]=0;
        long long cost = 0;
        for(j=0;j<n;j++){
            if(i&(1<<j)){
                cost += c[j];
                for(k=0;k<m;k++) cnt[k]+=a[j][k];
            }
        }
        int f=1;
        for(j=0;j<m;j++){
            if(cnt[j]<x){
                f=0;
                break;
            }
        }
        if(f==1 && ans>cost){
            ans = cost;
            check = 1;
        }
    }
    if(check==0) printf("-1");
    else printf("%lld",ans);
}

Measured memory_bytes: 1692
import math
N=int(input())
#print(N*100/108)
if N * 100 % 108 == 0:
    print(N*100//108)
else:
    kouho=N * 100 // 108
    for i in range(-1,2):
        #print(math.floor((kouho + i) * 1.08))
        if N == math.floor((kouho + i) * 1.08):
            print(kouho + i)
            exit()
    print(":(")
    

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

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

ll A=a*(n-1)+b,B=b*(n-1)+a;
if(B-A+1<0) cout<<0<<endl;
else
cout<<B-A+1<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = x;
    for (int i = 0; i < n; i++) {
        int day = 1;
        ans++;
        while (day + a[i] <= d) {
            ans++;
            day += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5+5)
from collections import defaultdict,deque
input = sys.stdin.readline
class LCA:

    def __init__(self,n):
        self.size = n+1
        self.bitlen = n.bit_length()
        self.lca = [[0]*self.size for i in range(self.bitlen)]
        self.depth = [-1]*self.size
        self.dis = [-1]*self.size
        self.depth[1] = 0
        self.dis[1] = 0
    def make(self,root):
        q = deque([root])
        while q:
            now = q.popleft()
            for nex,c,w in e[now]:
                if self.depth[nex]>= 0:
                    continue
                self.depth[nex] = self.depth[now]+1
                self.dis[nex] = self.dis[now]+w
                self.lca[0][nex] = now
                q.append(nex)
        for i in range(1,self.bitlen):
            for j in range(self.size):
                if self.lca[i-1][j] > 0:
                    self.lca[i][j] = self.lca[i-1][self.lca[i-1][j]]
    
    def search(self,x,y):
        dx = self.depth[x]
        dy = self.depth[y]
        if dx < dy:
            x,y = y,x
            dx,dy = dy,dx
        dif = dx-dy
        while dif:
            s = dif & (-dif)
            x = self.lca[s.bit_length()-1][x]
            dif -= s
        while x != y:
            j = 0
            while self.lca[j][x] != self.lca[j][y]:
                j += 1
            if j == 0:
                return self.lca[0][x]
            x = self.lca[j-1][x]
            y = self.lca[j-1][y]
        return x

n,q = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(n-1):
    a,b,c,d = map(int,input().split())
    e[a].append((b,c,d))
    e[b].append((a,c,d))
    
lca = LCA(n)
lca.make(1)

Q = [[] for i in range(n+1)]
ans = []
for i in range(q):
    x,y,u,v = map(int,input().split())
    a = lca.search(u,v)
    ans.append(lca.dis[u]+lca.dis[v]-2*lca.dis[a])
    Q[u].append((x,y,i,1))
    Q[v].append((x,y,i,1))
    Q[a].append((x,y,i,-2))


count = defaultdict(int)
weight = defaultdict(int)
def dfs1(now,p):
    for x,y,ind,z in Q[now]:
        ans[ind] += z*(y*count[x]-weight[x])
    for nex,c,w in e[now]:
        if nex == p:
            continue
        count[c] += 1
        weight[c] += w
        dfs1(nex,now)
        count[c] -= 1
        weight[c] -= w
    
dfs1(1,0)

for i in ans:
    print(i)

Measured memory_bytes: 765428
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    string s;
    cin >> s;
    string ans = "";
    for(int i = 0; i < s.length(); i++) {
		if(s[i] == '0') ans += '0';
		else if(s[i] == '1') ans += '1';
		else {
			if(ans.length() > 0) ans.erase(ans.end()-1);
		}
	}
	cout << ans << "\n";
 
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

cs = {}
for p, y in PY:
	if not p in cs:
		cs[p] = [y]
	else:
		cs[p] += [y]

csm = {}
for k, v in cs.items():
	v.sort()
	csm[k] = {}
	for i, p in enumerate(v):
		csm[k][p] = i + 1

for p, y in PY:
	print("{:06d}{:06d}".format(p, csm[p][y]))


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

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n;
vector<ld> v;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    v.assign(n, 0);
    F0R(i, n) cin >> v[i];
    priority_queue<ld, vector<ld>, greater<ld>> pq;
    F0R(i, n) pq.push(v[i]);
    ld res = 0;
    while(!pq.empty())
    {
        res = pq.top();
        pq.pop();
        // cout << res << "\n";
        ld a;
        if(!pq.empty())
        {
            a = pq.top();
            pq.pop();
            pq.push((res + a)/2);
        }
        else break;
    }    
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
Q = int(input())
BC = [[int(i) for i in input().split()] for _ in range(Q)]

cnt = Counter(A)
ret = sum(A)
for B, C in BC :
  ret = ret + cnt[B] * (C - B)
  cnt[C] += cnt[B]
  cnt[B] = 0
  print(ret)

Measured memory_bytes: 104120
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextLong()
    val m = sc.nextLong()
    if (n >= 2 && m >= 2) {
        println((n - 2) * (m - 2))
    } else if (n == 1L && m == 1L) {
        println(1)
    } else if (n == 1L) {
        println(m - 2)
    } else {
        println(n - 2)
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31396
W,H,N = map(int,input().split())

L = 0
R = W
D = 0
U = H

for _ in range(N):
  x,y,a = map(int,input().split())
  if a == 1:
    L = max(L,x)
  if a == 2:
    R = min(R,x)
  if a == 3:
    D = max(D,y)
  if a == 4:
    U = min(U,y)

x = max(0,R-L)
y = max(0,U-D)
answer = x*y

print(answer)

Measured memory_bytes: 3064
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import math

X = sorted(MAP())
K = INT()
ans = X[0] + X[1]
ans += X[2] * math.pow(2, K)
print(int(ans))


Measured memory_bytes: 27152
N=int(input())
A=[int(x)-1 for x in input().split()]
B={A[i]:int(x) for i,x in enumerate(input().split())}
C=[int(x) for x in input().split()]
score=B[A[0]]
for i in range(1,N):
    score+=B[A[i]]
    score+=C[A[i-1]] if A[i-1]+1==A[i] else 0
print(score)

Measured memory_bytes: 38256
void main() {
	writefln("%( %d%)", (n => iota(1, n+1).filter!(i => i % 3 == 0 || i.to!string.canFind('3')))(ri));
}

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

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: 2508
a, b, m = map(int, input().split())
al =  list(map(int, input().split()))
bl = list(map(int, input().split()))

a_m = min(al)
b_m = min(bl)
ans = a_m + b_m
for  _  in range(m):
  x, y, c = map(int, input().split())
  t_ans = al[x-1] + bl[y-1] -c
  if t_ans < ans:
    ans = t_ans
print(ans)


Measured memory_bytes: 18736
import java.io.PrintStream;
import java.util.IntSummaryStatistics;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		int N = in.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i += 1) {
			A[i] = in.nextInt();
		}
		IntSummaryStatistics s = IntStream.of(A).summaryStatistics();
		out.println(s.getMax() - s.getMin());
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


Measured memory_bytes: 28884
N,K,S = map(int, input().split())
if N-K+1 <= S:
	tmp = [1]*(N-K+1)
	tmp[-1] = S-(N-K)
	a,b = divmod(N,N-K+1)
	ans = tmp * a
	ans += tmp[:b]
else:
	ans = [S+1] * N
	for i in range(K):
		ans[i] = S

for i in range(N):
	if i == N-1:
		print(ans[i])
	else:
		print(ans[i], end = " ")

Measured memory_bytes: 5488
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

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

	int yen = 0;
	yen = 500 * a;

	if(yen >= b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=1005;
long long d[N];
long long n,sum=0ll;

int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
      scanf("%lld",d+i);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j )continue;
            sum+=d[i]*d[j];
        }
    }
    printf("%lld\n",sum/2);
}

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

typedef long long ll;

int main() {
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;
    int a=0, b=0, d=0;
    string s;
    int ans = 0;
    while (n--){
        cin>>s;
        int len = (int)s.size();
        for (int i=1;i<len;++i){
            if (s[i]=='B' && s[i-1]=='A') ans++; 
        }

        if (s[0] == 'B' && s[len-1] =='A') d++;
        else {
            if (s[0] == 'B') b++;
            else if (s[len-1] == 'A') a++; 
        }
    }
    //cout<<ans<<" "<<a<<" "<<b<<" "<<d<<endl;
    if (a==0 && b==0) ans += d ? (d-1): 0;
    else if (a==0 || b==0) ans += d;
    else {
        if (d>0){
            ans += d-1;
            ans++;
            a--;
            ans++;
            b--;
            ans += min(a, b);
        }
        else{
            ans += min(a, b);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

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

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

int X=0;
  X = X + a + a*a + a*a*a;
cout << X << endl;

}


Measured memory_bytes: 3592
#include<iostream>

using namespace std;

const int MAX = 201;

struct Pos{
  int up;
  int right;
};


Pos square[MAX];
int N;

int main(){

  while(cin >> N && N){
    square[0].up = square[0].right = 0;

    for(int i = 1; i < N; i++){
      int a,b;
      cin >> a >> b;
      square[i] = square[a];
      if(b == 0) square[i].right--;
      if(b == 1) square[i].up--;
      if(b == 2) square[i].right++;
      if(b == 3) square[i].up++;
    }
    int data[4] = {0,0,0,0};

    for(int i = 0; i < N; i++){
      data[0] = max(data[0],square[i].up);
      data[1] = min(data[1],square[i].up);
      data[2] = max(data[2],square[i].right);
      data[3] = min(data[3],square[i].right);
    }
    cout << data[2]-data[3]+1 << " " <<  data[0]-data[1]+1<< endl;
  }
  return 0;
}

Measured memory_bytes: 0