akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
/*
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
*/
#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int n;
int ans;

void solve(){
    ans=0;
    int i2,j2,k2,l2;
    for(int i=0,i2=i*i;i2<=n;i++){
        i2=i*i;
        for(int j=i,j2=j*j;j2<=n-i2;j++){
            j2=j*j;
            for(int k=j,k2=k*k;k2<=n-i2-j2;k++){
                k2=k*k;
                for(int l=k,l2=l*l;l2<=n-i2-j2-k2;l++){
                    l2=l*l;
                    if(i2+j2+k2+l2 == n) ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

    while(cin>>n,n){
        solve();
    }

    return 0;
}


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

using namespace std;

long long n,ans,a[300000];

int main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for (int i=n;i;--i){
		if (a[i]>=i||a[i+1]-1>a[i]){puts("-1"); return 0;}
		if (a[i]!=a[i+1]-1) ans+=a[i];
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        int a,b,sub1,sub2;
        Scanner in= new Scanner(System.in);
        a=in.nextInt(); b=in.nextInt();
        sub1=a+b;
        if(sub1%2==0)
            System.out.println(""+(sub1/2));
        else
            System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 26888
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool d=false;
    for(int i=1;i<=b;i++){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            d=true;
            break;
        }
    }
    if(!d) cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    x = ni()

    print(x // 500 * 1000 + ((x - (x // 500) * 500) // 5) * 5)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

int color[205];
int dist;
int d[205][205];
vector<vector<int>>g;
int n;

bool dfs(int v,int c){
    color[v]=c;
    for(auto x:g[v]){
        if(color[x]==c)return false;
        if(color[x]==0&&!dfs(x,-c))return false;
    }
    return true;
}

//ワーシャルフロイド法、全点対最短路
const int INFTY=100000;

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j){
                //目的地の頂点
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
		}
	}
}


void solve(){
    ll a,b,k;
    cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
            if(a%2)a--;
            b+=a/2;
            a/=2;
        }
        else {
            if(b%2)b--;
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<" "<<b<<endl;
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF 1001001001001001001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>>a(n);
	rep(i, 0, n)cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	double ans = 0.0;
	do {
		rep(i, 1, n)ans += sqrt((a[i].first - a[i - 1].first) * (a[i].first - a[i - 1].first) + (a[i].second - a[i - 1].second) * (a[i].second - a[i - 1].second));
		
	} while (next_permutation(a.begin(), a.end()));
	rep(i, 1, n + 1)ans /= i;
	cout << fixed << setprecision(6) << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    int arr[n];
    int arr1[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        cin>>arr1[i];
    }
    sort(arr,arr+n);
    sort(arr1, arr1+n);

    if(n%2==0){
        cout<<(arr1[n/2-1]+arr1[n/2])- (arr[n/2-1]+arr[n/2])+1<<endl;
    }else{
        cout<<(arr1[(n+1)/2-1])-(arr[(n+1)/2-1])+1<<endl;
    }
}


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

#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class BChristmasEveEve {
public:
    int N;
    ll p[20000];
    ll m = 0;
    ll sum = 0;

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) {
            in >> p[i];
            sum += p[i];
            m = max(p[i], m);
        }
        out << sum - m/2 << endl;
    }
};


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


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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define M 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

template<class T> inline bool chmax(T &a,T b) { if (a<b) { a=b; return true; } return false; }
template<class T> inline bool chmin(T &a,T b) { if (b<a) { a=b; return true; } return false; }

struct uf {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rcount;

    uf(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%M+M)%M) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= M) x -= M;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += M-a.x) >= M) x -= M;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= M;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime M
    mint inv() const {
        return pow(M-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int main(){
	int n;cin>>n;
	vector<int>x(n);
	rep(i,n)cin>>x[i];
	int ans=10000000;
	rep(j,100){
		int c=0;
		rep(i,n){
			c+=(x[i]-j)*(x[i]-j);
		}
		chmin(ans,c);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
	
int main(){
	int n;
	std::cin>>n;
	
	std::cout<<"ABC";
	std::cout<<n<<std::endl;

	return 0;
	
	
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
list_x = list(map(int,input().split()))
list_y = list(map(int,input().split()))
xmax = max(list_x)
ymin = min(list_y)
for i in range(x+1,y+1):
  if xmax < i and i <= ymin:
    print("No War")
    exit()
print("War")

Measured memory_bytes: 38640
using System;

namespace abc143_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int r = 1;

            for (int i = 0; i < N - 1; i++)
                if (S[i] != S[i + 1]) r++;

            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 11232
import math

def f(a, b, angle):
    if (a * math.tan(math.radians(angle))) <= b:
        return ((a * b) - (a * math.tan(math.radians(angle)) * a / 2.0)) * a
    else:
        return b * b / math.tan(math.radians(angle)) * a / 2.0

a, b, c = map(int, input().split())

l, r = 0, 90
for i in range(1000):
    mid = (l+r) / 2.0
    if f(a, b, mid) < c:
        r = mid
    else:
        l = mid
print(l)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int A[1145],B[1145];
    map<int,int> Ma,Mb;
    cin >> N >> M;
    REP(i,N){
        cin >> A[i];
        Ma[A[i]]+=1;
        if(Ma[A[i]]>=2){
            GOODBYE;
        }
    }
    REP(i,M){
        cin >> B[i];
        Mb[B[i]]+=1;
        if(Mb[B[i]]>=2){
            GOODBYE;
        }
    }
    int Ans=1;
    int Pa=N,Pb=M;
    for(int i=N*M;i>=1;i--){
        int ma=Ma[i],mb=Mb[i];
        if(ma && mb){
            Ans*=1;
        }else if(ma && !mb){
            Ans*=M-Pb;
        }else if(!ma && mb){
            Ans*=N-Pa;
        }else{
            int num=1;
            num*=N-Pa;
            num*=M-Pb;
            num-=N*M-i;
            Ans*=num%MOD;
        }
        Ans%=MOD;
        if(ma){
            Pa--;
        }
        if(mb){
            Pb--;
        }
        //cout << i MM Ans << endl;
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 125312
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
 
int main(){
   int n,r,ans;
   cin>>n>>r;
   if(n>10) ans = r;
   else {
       ans = r+100*(10-n);
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product

H, W, K = map(int, input().split(' '))
maze = [input() for i in range(H)]
ans = 0
cnt = 0
for i in range(pow(2,H+W)):
    cnt += 1
    i = format(i,'0{}b'.format(H+W))
    h = list(i[:H])
    w = list(i[H:])
    tmp = 0
    for j in range(H):
        for k in range(W):

            if h[j] == w[k] == '0' and maze[j][k] == '#':
                tmp += 1
    if tmp == K:
        ans += 1
print(ans)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;

int n,s,k,ans=INF;
int a[100005],b[100005];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>k; s=k;
    for (int i=0;i<n;++i) cin>>a[i];
    for (int i=0,j=0;j<=n;) {
        if (s>0) {
            if (!b[a[j]] && a[j]<=k) --s;
            ++b[a[j]];
            ++j;
        }
        else {
            ans=min(ans,j-i);
            --b[a[i]];
            if (!b[a[i]] && a[i]<=k) ++s;
            ++i;
        }
    }
    cout<<(ans==INF?0:ans)<<'\n';
}


Measured memory_bytes: 4004
N=int(input())
a=list(map(int,input().split()))
x_1=sum(a)
for i in range(1,N,2):
    x_1-=2*(a[i])
x=[x_1]
for j in range(1,N):
    x.append(2*a[j-1]-x[j-1])
print(*x)

Measured memory_bytes: 69732
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	string S;
	cin >> N>>S;
	vector<ll> WN(N + 1);
	WN.at(0) = 0;
	rep(i, N) {
		if (S.at(i) == 'W') {
			WN.at(i + 1) = WN.at(i) + 1;
		}
		else {
			WN.at(i + 1) = WN.at(i);
		}
		
	}
	ll an = 2 * N;
	rep(i, N+1) {
		an = min(an,max(WN.at(i),(N-i-WN.at(N)+WN.at(i))));
		}
	cout << an << endl;
}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  ll min_val = 1e9, max_val = -1e9, sum_val = 0;
  rep(i, 0, n) {
    ll a;
    cin >> a;
    chmin(min_val, a);
    chmax(max_val, a);
    sum_val += a;
  }
  printf("%d %d %lld\n", min_val, max_val, sum_val);
}



Measured memory_bytes: 3248
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    s = input().replace('BC', 'D')

    res, cnt = 0, 0
    for si in s:
        if si == 'A':
            cnt += 1
        if si == 'B' or si == 'C':
            cnt = 0
        if si == 'D':
            res += cnt
    print(res)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 34664
n = int(input())
tree = [0] * n
root = set(range(n))
for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = (left, right)
    root -= {left, right}
root_node = root.pop()


def preorder(i):
    if i == -1:
        return
    (left, right) = tree[i]
    yield i
    yield from preorder(left)
    yield from preorder(right)


def inorder(i):
    if i == -1:
        return
    (left, right) = tree[i]
    yield from inorder(left)
    yield i
    yield from inorder(right)


def postorder(i):
    if i == -1:
        return
    (left, right) = tree[i]
    yield from postorder(left)
    yield from postorder(right)
    yield i

print("Preorder\n ", end="")
print(*preorder(root_node))
print("Inorder\n ", end="")
print(*inorder(root_node))
print("Postorder\n ", end="")
print(*postorder(root_node))

Measured memory_bytes: 7776
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int cnt0,cnt1;
  cnt0 = 0;
  cnt1 = 0;
  for (int i=0; i < n; i++){
    if (s[i]=='0') {
      cnt0++;
    } else {
      cnt1++;
    }
  }
  cout << 2*min(cnt0,cnt1) << endl;
  return 0;
}


Measured memory_bytes: 512
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List
import Data.Ord

readDoubles :: IO [Double]
readDoubles = map (fromIntegral . fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  getLine
  vs <- sortOn Down <$> readDoubles
  let calc a b = (a + b) / 2
  print $ foldr1 calc vs

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

using namespace std;

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

int main()
{
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  long long res = 0;
  if (v[0] > x) {
    res = v[0] - x;
    v[0] = x;
  }
  reps(i, 1, n) {
    if (v[i-1]+v[i] > x) {
      res += v[i-1] + v[i] - x;
      v[i] = x - v[i-1];
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)998244353;

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

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();

        List<Integer>[] lists = new ArrayList[n];

        for (int i=0; i<n; i++) lists[i] = new ArrayList<>();

        int[][] arr = new int[m][2];

        for (int i=0; i<m; i++) {
            int a = sc.nextInt() - 1;
            int num = sc.nextInt();
            lists[a].add(num);
            arr[i][0] = a;
            arr[i][1] = num;
        }

        for (int i=0; i<n; i++) {
            Collections.sort(lists[i]);
        }

//        System.out.println(lists[0]);

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<m; i++) {
            int a = arr[i][0];
            int num = arr[i][1];
            num = lowerbound1(lists[a], num) + 1;
            a += 1;
            StringBuilder str = new StringBuilder();
            str.append(String.format("%06d", a));
            str.append(String.format("%06d", num));
            sb.append(str + "\n");
        }

        System.out.println(sb.toString());


    }

    public static int lowerbound1(List<Integer> list, int value){
        int left = 0;
        int right = list.size();
        while (left<right){
            int mid = (left+right)/2;
            if (list.get(mid)<value){
                left = mid+1;
            }else {
                right = mid;
            }
        }
        return left;
    }
}



Measured memory_bytes: 175984
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100000
int a[N];
int main(){
	int n;
	scanf("%d", &n);
	rep(i, n) scanf("%d", a+i);
	ll res = 0;
	int mn = 0;
	rep(i, n){
		ll t = mn+1;
		ll r = (a[i]-1)/t;
		res += r;
		if(r) a[i] = 1;
		mn = max(mn, a[i]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N, M; cin >> N >> M;
  int count=0;
  for(int i=0;i<M;i++){
    int A; cin >> A;
    count+=A;
  }
  if(count>N){
    cout << -1 << endl;
    return 0;
  }
  else cout << N-count << endl;
  return 0;
}


Measured memory_bytes: 3636
"use strict"

function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);
    var C = parseInt(input[2], 10);

    var result = Math.floor(B/A);

    console.log(result > C ? C : result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0) return b;
  else return gcd(b%a, a);
}

int32_t main(){
  DESYNC;
  int n,m;
  cin >> n >> m;
  vector<int> v(n+1,0);
  for(int i=0; i<m; i++){
    int l,r;
    cin >> l >> r;
    l--, r--;
    v[l] += 1;
    v[r+1] -=1;
  }
  for(int i=1; i<n; i++) v[i] += v[i-1];
  int ans = 0;
  for(int i=0; i<n; i++) if(v[i] == m) ans++;
  cout << ans << endl;
}



Measured memory_bytes: 1024
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = 0
r = max(a)
while r - l > 1:
    # min is in (l, r]
    c = (l + r) // 2
    t = 0
    for ai in a:
        t += (ai + c - 1) // c - 1
    if t <= k:
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 94280
import java.util.*;

class Main {
	//?????¢??¢?´¢?????¬???
	public static int search(int[] A, int n, int key) {
		A[n] = key;
		int i = 0;
		while(A[i] != key)i++;
		if(i == n) {
			return -1;
		} else {
			return i;
		}
	}

	public static void main(String args[]) {

		Scanner scan = new Scanner(System.in);
		int[] arrayS = new int[10001]; //??°???S
		int[] arrayT = new int[501];   //??°???T
		int count = 0;						 //?????°????¨???????????????°

		//????´??????°???????????????ArrayS?????°???S???????????????
		int sNum = scan.nextInt();
		for (int i = 0; i < sNum; i++)
			arrayS[i] = scan.nextInt();

		//????´??????°???????????????ArrayT?????°???T???????????????
		int tNum = scan.nextInt();
		for (int j = 0; j < tNum; j++)
			arrayT[j] = scan.nextInt();

		//??°???T???????´??????°???A????????????????????????????????????
		for (int j = 0; j < tNum; j++)
			if(search(arrayS, sNum, arrayT[j]) >= 0) count++;

		System.out.println(count);
	}
}

Measured memory_bytes: 38632
#coding:utf-8
from statistics import mean
import math
N = int(input())
A = list(map(int, input().split()))
def calc(A,mu):
    return sum([(a-mu)**2 for a in A])
floor = math.floor(mean(A))
ceil = math.ceil(mean(A))
print (min(calc(A,floor),calc(A,ceil)))

Measured memory_bytes: 5272
m,d = map(int,input().split())

ans = 0

for i in range(m+1):
    for j in range(d+1):
        if j //10 >= 1:
            a = j // 10
            b = j % 10
            if i == a * b and a != 1 and i != 0and b != 1:
              ans += 1
                
print(ans)
        

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

typedef long long ll;
const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> blacksum(N+1), whitesum(N+1);
    for (int i=0;i<N;i++){
        if (S[i] == '#'){
            blacksum[i+1]=blacksum[i]+1;
            whitesum[i+1]=whitesum[i];
        }else {
            blacksum[i+1]=blacksum[i];
            whitesum[i+1]=whitesum[i]+1;
        }
    }
    int ans = INF;
    for (int i=0;i<=N;i++){
        int p=blacksum[i];
        int q=whitesum[N]-whitesum[i];
        int r = p+q;
        ans = min(ans, r);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2196
import fractions

def lcm(x,y):
  return x // fractions.gcd(x,y) * y


mod = 10**9+7


N = int(input())

A = list(map(int,input().split()))

B = 0
for i in A:
    B += pow(i,mod-2,mod)
    B %= mod

g = 1

for i in range(N):
    g = lcm(g,A[i])

print (g * B % mod)
    


Measured memory_bytes: 67816
from collections import deque
import sys

n=int(input())
A=deque()
cur=0
for i in range(n):
  S=input()
  if S[0]=='0':
    A.append(S[2:])
  elif S[0]=='1':
    A.rotate(int(S[2:]))
    cur-=int(S[2:])
  elif S[0]=='2':
    A.pop()
A.rotate(cur)
A.reverse()
print(*A, sep="\n")




Measured memory_bytes: 39356
#include <bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> v;
int32_t main(){
	int n;cin>>n;
	v.push_back(1);
	for(int i=2;i<=1000;i++){
		int a=i;
		while((a*=i)<=1000) v.push_back(a);
	}
	sort(v.begin(),v.end());
	auto t = (lower_bound(v.begin(),v.end(),n));
	cout<<*(t-(*t!=n));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.10f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn=  1000000+10;
const int maxm = 1000+10;
//Pretests passed
int in(int &ret)
{
    char c;
    int sgn ;
    if(c=getchar(),c==EOF)return -1;
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    sgn = (c=='-')?-1:1;
    ret = (c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
    ret *=sgn;
    return 1;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL
    int n,m,k;
    sddd(n,m,k);
    r0(i,n+1)r0(j,m+1)
    {
        int check = i * m + j * n  - 2 * i * j ;
        if(check==k)return 0*puts("Yes");
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 2*1e5 + 5;
const int N = 2*1e5 + 5;
const double PI = acos(-1.0);
int cnt[N];
int m, n;

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        mem( cnt, 0 );
        int x;
        for( int i = 1; i < n; i++ ){
            scanf( "%d", &x );
            cnt[x]++;
        }
        for( int i = 1; i <= n; i++ )
            cout << cnt[i] << endl;
        
    }
    return 0;
}


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

int main() {

  int H, N;
  cin >> H >> N;

  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  // i 番目までの魔法からダメージの総和が j になるように選んだときの魔法消費量の総和の最小値
  vector<vector<int>> dp(N + 1, vector<int>(H + 1, 100000000));

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= H; j++) {
      if (j <= A[i]) {
        dp[i+1][j] = min(dp[i][j], B[i]);
      } else {
        dp[i+1][j] = min(dp[i][j], dp[i+1][j - A[i]] + B[i]);
      }
    }
  }

  cout << dp[N][H] << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    ll tmp = INF;
    ll res = 0;
	ll cnt = 0;
    vector<ll> v(N);
	rep(i, N) cin >> v[i];
    rep(i, N){
        res += abs(v[i]);
		if(v[i] < 0) cnt++;
		tmp = min(tmp, abs(v[i]));
    }

	if(cnt % 2) res -= 2*tmp;
	cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
ll n,s,ans=1e15;
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
ll f(ll b,ll n){
	if(n<b) return n;
	return f(b,n/b)+n%b;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();s=read();
	if(n==s){
		printf("%lld",n+1);
		return 0;
	}
	for(ll b=2;b*b<=n;++b){
		if(f(b,n)==s){
			printf("%lld",b);
			return 0;
		}
	}
	for(ll x=1;x*x<=n-s;++x){
		if((n-s)%x) continue;
		ll b=(n-s)/x+1;
		ll y=s-x;
		if(x>=1&&x<b&&y>=0&&y<b) ans=min(ans,b);
	}
	printf("%lld",ans==1e15?-1:ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    for i in range(1, n - 1):
        #print(p[i-1], p[i], p[i+1])
        if min(p[i-1], p[i], p[i+1]) != p[i] and max(p[i-1], p[i], p[i+1]) != p[i]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import numpy as np
N, K = map(int,input().split())
hs = np.zeros(N)
for i in range(N):
    hs[i] = int(input())

# sort
h_sorted = np.sort(hs)
min_delta = np.inf

# hmax-hminを求めていく
for i in range(N-K+1):
    delta = h_sorted[i+K-1] - h_sorted[i]
    if min_delta >= delta:
        min_delta = delta
print(int(min_delta))


Measured memory_bytes: 13944
#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 x, a, b;
    cin >> x >> a >> b;

    cout << x - a - ((x - a) / b) * b << endl;
    return 0;
}



Measured memory_bytes: 764
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]
np_a = np.array(a)

a_idx = np.argsort(np_a)
#print(a_idx)

res = [str(1+int(x)) for x in a_idx.tolist()]
#print(res)

print(' '.join(res))

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

int main(void)
{
    char c;
    std::cin >> c;

    switch (c)
    {
        case 'A'/* constant-expression */:
            cout << 'T';
            /* code */
            break;
        case 'T':
            cout << 'A';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
        default:
            break;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n, d, a;
	cin >> n >> d >> a;
	vector<P> vs(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
	}
	sort(vs.begin(), vs.end());
	map<ll, ll> m;
	ll cache = 0;
	ll sum = 0;
	vector<ll> er;
	rep(i, n) {
		auto loc = vs[i].first;
		auto b = vs[i].second;
		er.clear();
		for(auto e : m) {
			if (e.first < loc) {
				er.push_back(e.first);
				cache -= e.second;
			}
			else break;
		}
		for (auto e : er) {
			m.erase(e);
		}
		ll c = b % a == 0 ? b / a : b / a + 1;
		c -= cache;
		if (c <= 0) continue;
		m[loc + d * 2] += c;
		cache += c;
		sum += c;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int e = 0;
        int w = 0;
        for(int i = 1;i < N;i++)    if(S.charAt(i) == 'E')  e++;
        int ans = e;
        for(int i = 1;i < N;i++){
            if(S.charAt(i) == 'E')  e--;
            if(S.charAt(i-1) == 'W')    w++;
            ans = Math.min(ans, w+e);
        }
        System.out.println(ans);
    }
}

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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    bool bigger = true, before = false;
    REP(s.size()){
        if(s[i] > t[i]){
            cout << "No" << endl;
            return 0;
        } else if(s[i] < t[i]){
            cout << "Yes" << endl;
            return  0;
        }
    }
    cout << (s.size() < t.size() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  cout << (n - 1) * (m - 1) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

h, w = map(int, input().split())
s_list = [list('.' * (w + 2))]
s_list.extend([list('.' + input() + '.') for i in range(h)])
s_list.append(list('.' * (w + 2)))

def check_mine(v):
    if v == '#':
        return 1
    else:
        return 0

for i in range(1, h+1):
    for j in range(1, w+1):
        if s_list[i][j] == '.':
            cnt = 0
            cnt += s_list[i-1][j-1:j+2].count('#')
            cnt += s_list[i][j-1:j+2].count('#')
            cnt += s_list[i+1][j-1:j+2].count('#')
            s_list[i][j] = str(cnt)

for i in s_list[1:-1]:
    print(''.join(i[1:-1]))

Measured memory_bytes: 3444
#include <algorithm>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <iostream>
using namespace std;

class Dice {

private:
	int eyes[6];

public:
	Dice(int tp, int fr, int ri, int lf, int bk, int bt);
	void rotate(int tp, int fr, int bt, int ri, int lf, int bk);
	int showEye(int i);
};

Dice::Dice(int tp, int fr, int ri, int lf, int bk, int bt) {
	eyes[0] = tp; eyes[1] = fr; eyes[2] = ri; eyes[3] = lf; eyes[4] = bk; eyes[5] = bt;
}

void Dice::rotate(int tp, int fr, int ri, int lf, int bk, int bt) {
	int wk[6] = { eyes[tp], eyes[fr], eyes[ri], eyes[lf], eyes[bk], eyes[bt] };
	eyes[0] = wk[0];
	eyes[1] = wk[1];
	eyes[2] = wk[2];
	eyes[3] = wk[3];
	eyes[4] = wk[4];
	eyes[5] = wk[5];
}

int Dice::showEye(int i) {
	return eyes[i];
}

int main()
{
	int tp, fr, bt, ri, lf, bk;
	string op;
	cin >> tp >> fr >> bt >> ri >> lf >> bk;
	Dice dice(tp, fr, bt, ri, lf, bk);
	cin >> op;

	for (int i = 0; i < op.length(); i++) {
		switch (op[i]) {
		case 'N': dice.rotate(1, 5, 2, 3, 0, 4); break;
		case 'S': dice.rotate(4, 0, 2, 3, 5, 1); break;
		case 'E': dice.rotate(3, 1, 0, 5, 4, 2); break;
		case 'W': dice.rotate(2, 1, 5, 0, 4, 3); break;
		}
	}

	cout << dice.showEye(0) << "\n";
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
double dp[301][301][301];
bool vis[301][301][301];
int a[304];
int cnt[4];

double solve(int c3, int c2, int c1){
    double &ans = dp[c3][c2][c1];
    if(!vis[c3][c2][c1]){
        vis[c3][c2][c1] = true;
        int sum = c3+c2+c1;
        ans = 1.0/sum;
        if(sum){
            if(c3)
                ans += 1.0*c3/sum *(solve(c3-1, c2+1, c1));
            if(c2)
                ans += 1.0*c2/sum *(solve(c3, c2-1, c1+1));
            if(c1)
                ans += 1.0*c1/sum *(solve(c3, c2, c1-1));
        }
    }
    return ans;
}

int main(){
    memset(cnt, 0, sizeof cnt);
    memset(vis, false, sizeof vis);
    scanf("%d", &n);
    for(i=0;i<n;++i){
        scanf("%d", a+i);
        cnt[a[i]]++;
    }
    vis[0][0][0] = true;
    dp[0][0][0] = 0;
    printf("%.9lf\n", n*solve(cnt[3], cnt[2], cnt[1]));
    return 0;
}

Measured memory_bytes: 240000
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF 1e18

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}


int n,m,l;
vector<vector<pair<int,int>>> conn;
vector<vector<int>> reach;
vector<vector<int>> ans;

void bfs(int node)
{
	queue<int> q;
	ans[node][node]=-1;
	q.push(node);
	while(q.size())
	{
		int curr=q.front();
		q.pop();
		for(int i:reach[curr])
		{
			if(ans[node][i]==INF)
			{
				q.push(i);
				ans[node][i]=ans[node][curr]+1;
			}
		}
	}
}


signed main()
{
	fio
	cin>>n>>m>>l;
	conn.resize(n);
	reach.resize(n);
	ans.resize(n,vector<int>(n,INF));
	fo(i,m)
	{
		inp(x) inp(y) inp(z);
		x--,y--;
		conn[x].pb({y,z});
		conn[y].pb({x,z});
	}
	fo(node,n)
	{
		int poss[n];
		memset(poss,-1,sizeof(poss));
		priority_queue<pair<int,int>> q;
		q.push({l,node});
		poss[node]=l;
		while(q.size())
		{
			int curr=q.top().S;
			int f=q.top().F;
			q.pop();
			// cout<<curr<<','<<f<<'\n';
			if(poss[curr]!=f)
				continue;
			for(pair<int,int> i:conn[curr])
			{
				if(poss[i.F]<poss[curr]-i.S)
				{
					poss[i.F]=poss[curr]-i.S;
					q.push({poss[curr]-i.S,i.F});
				}
			}
		}
		fo(i,n)
			if(poss[i]!=-1)
				reach[node].pb(i);
		// cout<<node<<':';
		// print(reach[node]);
	}
	fo(i,n)
		bfs(i);
	inp(q)
	while(q--)
	{
		inp(a) inp(b)
		a--,b--;
		if(ans[a][b]==INF)
			cout<<-1<<'\n';
		else
			cout<<ans[a][b]<<'\n';
	}
	printclock;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++)
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);

    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
n = int(input())

#[～][0] =>t [1]=>x [2]=>y
l = [list(map(int,input().split())) for i in range(n)]

judge = 'No'

#初期値
l.insert(0,[0,0,0])
for i in range(n):
    #奇数がT偶数がF
    dt = l[i+1][0]-l[i][0]
    n_j = dt%2
    xy = (l[i+1][1]+l[i+1][2])-(l[i][1]+l[i][2])
    if n_j==xy%2 and dt>=abs(xy):
        judge = 'Yes'
    else:
        judge ='No'
        break

print(judge)

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

using namespace std;

int main () {
	int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 || b % 2 || c % 2) {
		cout << 0;
		return 0;
	}
	if (a == b && b == c) {
		cout << -1;  	
		return 0;
	}
	int ans = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int bb = a / 2 + c / 2, cc = a / 2 + b / 2, aa = b / 2 + c / 2;
		a = aa, b = bb, c = cc;
		ans ++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
string s;
int main()
{
  cin >> s;
  int n = s.size();
  vector<int> vec;
  int cnt=1;
  for(int i=0;i<n-1;++i){
    if(s[i]!=s[i+1]){
      vec.push_back(cnt);
      cnt=1;
    }
    else{
      cnt++;
    }
  }
  vec.push_back(cnt);
  vector<int> res;
  for(int i=0;i<vec.size();++i){
    int x=1,y=1;
    if(vec[i]%2==1){
      x+=(vec[i]-1)/2;
      y+=(vec[i]-1)/2;
    }
    else{
      x+=(vec[i]-1)/2;
      y+=vec[i]/2;
    }
    if(vec[i+1]%2==1){
      x+=(vec[i+1]-1)/2;
      y+=(vec[i+1]-1)/2;
    }
    else{
      x+=vec[i+1]/2;
      y+=(vec[i+1]-1)/2;
    }
    for(int j=0;j<vec[i]-1;++j){
      res.push_back(0);
    }
    res.push_back(x);
    res.push_back(y);
    for(int j=0;j<vec[i+1]-1;++j){
      res.push_back(0);
    }
    i++;
  }
  for(int i=0;i<n;++i){
    cout << res[i] << " ";    
  }
  cout  << "\n";
  return 0;
}


Measured memory_bytes: 1592