akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int i,n,x[100];
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	for(i=n;i>0;i--){
		if(i==1){
			cout << x[1] << endl;
		}else{
			cout << x[i] << ' ';
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <math.h>

double round_d(double x) {
    if ( x >= 0.0 ) {
        return floor(x + 0.5);
    } else {
        return -1.0 * floor(fabs(x) + 0.5);
    }
}

int main(){
double num1[10000],num2[10000],num3[10000],num4[10000],num5[10000],num6[10000],x=0.0,y=0.0;
int i,count=0;
for(i=0;i<10000;i++){
if(scanf("%lf %lf %lf %lf %lf %lf",&num1[i],&num2[i],&num3[i],&num4[i],&num5[i],&num6[i])==EOF)break;
count++;
}
for(i=0;i<count;i++){
if((num1[i]==0.0&&num4[i]==0.0)==1||(num2[i]==0.0&&num5[i]==0.0)==1||(num1[i]==0.0&&num2[i]==0.0)==1||(num4[i]==0.0&&num5[i]==0.0)==1||(num2[i]*num4[i]-num1[i]*num5[i])==0.0){}
else{
x=(num2[i]*num6[i]-num3[i]*num5[i])/(num2[i]*num4[i]-num1[i]*num5[i]);
x=round_d(x*1000.0)/1000.0;
y=(num1[i]*num6[i]-num3[i]*num4[i])/(num1[i]*num5[i]-num2[i]*num4[i]);
y=round_d(y*1000.0)/1000.0;
printf("%.3f %.3f\n",x,y);
}
}
return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
    ll n;cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    ll an=2;
    for(ll i=2;i*i<=n;i++){
        ll N=n;
        if(N%i!=0)continue;
        while(N%i==0){
            N/=i;
        }
        if(N%i==1)an++;
    }
    for(ll i=2;i*i<=n-1;i++){
        if((n-1)%i==0){
            if(i*i==n-1)an++;
            else an+=2;
        }
    }
    cout<<an<<endl;
}

    









Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int d[110];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];
    sort(d, d + n,greater<int>());
    int ans = 1;
    for(int i = 1;i < n; i++)
        if(d[i-1] != d[i])
            ans ++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))
c = 1
while K:
  if K & 1:
    c = A[c]
  A = [A[A[i]] for i in range(len(A))]
  K >>= 1
print(c)

Measured memory_bytes: 31364
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>

#define ll long long
#define ld long double
#define mp make_pair
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
 
    int n, t;
    cin>>n>>t;
    vector<pair<int, int>> a(n);
    for (int i = 0; i<n; i++) cin>>a[i].first>>a[i].second;
    sort(a.begin(), a.end());
    vector<int> dp(t+1);
    dp[0] = 0;
    int best = 0;
    for (int i = 0; i<n; i++)
    {
        best = max(best, dp[t-1]+a[i].second);
        for (int j = t-1; j>=a[i].first; j--) dp[j] = max(dp[j], dp[j-a[i].first] + a[i].second);
    }
    cout<<best;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n,m;
	cin>>n>>m;
	if(n%2==1||n/2-m+1>(n+2)/4){
		fo(i,n/2-m+1,n/2+1)cout<<i<<' '<<n/2*2+1-i<<endl;
		return 0;
	}
	fo(i,n/2-m+1,(n+2)/4+1)cout<<i<<' '<<n+2-i<<endl;
	fo(i,(n+2)/4+1,n/2+1)cout<<i<<' '<<n+1-i<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

int main() {
  int A,B,C,D,E,F;
  cin >>A>>B>>C>>D>>E>>F;
  int minw=3000,mins=3000;
  double max=0;
  fw(31){
  fx(31){
  for(int y=0;y*C<=3000;y++){
  for(int z=0;z*D<=3000;z++){
       if(w==0&&x==0){continue;}
  	if(100*w*A+100*B*x+C*y+D*z<=F){
  	if((A*w+B*x)*E>=C*y+D*z){
  	if(((double)C*y+D*z)*100/(100*w*A+100*B*x+C*y+D*z)>max){
  		minw=100*w*A+100*B*x;
  		mins=C*y+D*z;
  		max=((double)C*y+D*z)*100/(100*w*A+100*B*x+C*y+D*z);
  	}
  	}
  	}else{
        z=3000;
       }
  

  }}}}
if(max==0){
cout <<100*A<<' '<<0<<endl;
}else{
  cout <<minw+mins<<' '<<mins<<endl;
}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
#define rep(i,N) for(int i = 0; i<N,i++)
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, A, B, C, D;
char S[200010];


int main() {
	cin >> N >> A >> B >> C >> D;
	for (int i = 1; i <= N; i++) {
		cin >> S[i];
	}

	bool ISHI = false;
	bool ABLE = true;

	for (int i = A; i <= C; i++) {
		if (ISHI && S[i] == '#') {
			ABLE = false;
			break;
		}

		if (S[i] == '#') ISHI = true;

		if (S[i] == '.') {
			ISHI = false;
		}
	}

	ISHI = false;

	for (int i = B; i <= D; i++) {
		if (ISHI && S[i] == '#') {
			ABLE = false;
			break;
		}

		if (S[i] == '#') ISHI = true;

		if (S[i] == '.') {
			ISHI = false;
		}
	}

	if (D < C) {
		int K = 0;
		bool SANREN = false;
		for (int i = B - 1; i <= D + 1; i++) {
			if (S[i] == '.') K++;
			else K = 0;

			if (K == 3) {
				SANREN = true;
				break;
			}
		}

		ABLE = SANREN;
	}

	if (ABLE) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 384
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    max_A = max(A)
    idx = A.index(max_A)
    diff = 1 << 60
    ans = 0
    if max_A % 2 == 0:
        for i, a in enumerate(A):
            if i == idx:
                continue
            if abs(max_A//2 - a) < diff:
                diff = abs(max_A//2 - a)
                ans = a
    else:
        for i, a in enumerate(A):
            if i == idx:
                continue
            if abs(max_A//2-a) < diff:
                diff = abs(max_A//2 - a)
                ans = a
            elif abs((max_A//2)+1 - a) < diff:
                diff = abs((max_A//2)+1 - a)
                ans = a

    print(max_A, ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62704
#include<iostream>
#include<set>
#include<vector>

using namespace std;

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

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

int main() {
  int h, w;
  while (true) {
    set<string> s;
    vector<string> vs;
    string res;
    cin >> h >> w;
    if (h == 0 && w == 0) break;
    rep (i, h) {
      string str;
      cin >> str;
      vs.push_back(str);
    }
    rep (i, h) rep (j, w) rep (d, 8) {
      int x = j, y = i;
      string str;
      do {
	str += vs[y][x];
	//cout << i << " " << j << " " << d << " " << str << endl;
	x = (x + w + dx[d]) % w;
	y = (y + h + dy[d]) % h;
	if (str.size() > 1u) {
	  if (s.count(str) > 0) {
	    if (res.size() < str.size()) {
	      res = str;
	    } else if (res.size() == str.size() && res > str) {
	      res = str;
	    }
	  } else {
	    s.insert(str);
	  }
	}
      } while (y != i || x != j);
    }
    if (res == "") {
      cout << 0 << endl;
    } else {
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 33768
import sys
input = lambda: sys.stdin.readline().rstrip()
tdlist = lambda i, j, value=0: [[value] * j for _ in range(i)]

n = int(input())
s = input()

dp = tdlist(n+1, n+1)
for i in range(1, n+1):
    for j in range(1, n+1):
        if s[i-1] == s[j-1]: dp[i][j] = dp[i-1][j-1] + 1

ans = 0
for i in range(n+1):
    for j in range(n+1):
        ans = max(ans, min(abs(i-j), dp[i][j]))

print(ans)


Measured memory_bytes: 232584
#include <iostream>

using namespace std;

int main(void) {
	int H,W;
	cin >> H >> W;

	char c;
	int count = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			if (c == '#') {
				++count;
			}
		}
	}

	if (count == H+W-1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}


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

int main(int argc, char *argv[]) {
    int input_k = 0;
	int input_s = 0;
	int result = 0;

	std::cin >> input_k;
	std::cin >> input_s;

	for (int x = 0; x <= input_k; x++) {
		for (int y = 0; y <= input_k; y++) {
			int z = input_s - x - y;
			if (z >= 0 && z <= input_k) {
				result++;
			}
		}
	}

	std::cout << result << std::endl;
	return 0;
}


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

int main(void)
{
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == t[i]) count++;
    }
    cout << count << endl;
    

}

Measured memory_bytes: 256
import itertools
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsで順列を生成できる！
permutations = list(itertools.permutations([i for i in range(1, N+1)]))
 
a, b = 0, 0
for i, R in enumerate(permutations):
  if R == P: a = i
  if R == Q: b = i

print(abs(a-b))

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	cout<<b[0]+a[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int a,b;
  string s;
  cin >> a >> b >> s;
  for(int i = 0; i < a + b + 1; i++)
  {
    if(i != a){
      if(s.at(i) >= '0' && s.at(i) <= '9'){
      }else{
        cout << "No" << endl;
        return 0;
      }
    }else if(i == a && s.at(i) != '-'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    // cout<<"&&&"<<x<<endl;
    cout<<floor((a*x)/b)-(a*floor(x/b))<<endl;


return 0;
}


Measured memory_bytes: 3828
import math

def main():

    test = int(input())
    inp = input().split(' ')
    inp = sorted(inp)
    p=1;
    for x in inp:
        p = p*int(x)
        if p> 10**18 or p==0:
            break;
    
    if(p>10**18):
        print(-1);
    else:
        print(p);

        
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 19660
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    if len(S) % 2 != 0:
        return 'No'
    if S == 'hi' * (len(S) // 2):
        return 'Yes'
    return 'No'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

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

    while (N >= 1000) {
        N -= 1000;
    }
    N = 1000 - N;
    if (N == 1000) {
        N = 0;
    }
    cout << N << endl;

    return 0;
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        final long a = scanner.nextLong();
        final long b = scanner.nextLong();
        final long c = scanner.nextLong();
        final long d = scanner.nextLong();

        final long gcdVal = gcd(c, d);
        final long cd = c * d / gcdVal;

        System.out.println(b - b / c - b / d + b / cd - (a - 1) + (a - 1) / c + (a - 1) / d - (a - 1) / cd);
    }

    private static long gcd(long a, long b) {
        if (a < b) {
            return gcd(b, a);
        }

        if (b == 0) return a;

        return gcd(b, a % b);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

int func(int N, const vector<pair<int,int>> &y, const vector<pair<int, int>> &z) {
	vector<int> A(N), B(N), C(N + 1);

	C[0] = 0;
	for(int i = 0; i < N; ++i) {
		A[i] = y[i].second - y[i].first;
		B[i] = z[i].second - z[i].first;

		if(i > 0) {
			A[i] += A[i - 1] + y[i - 1].first;
			B[i] += B[i - 1] + z[i - 1].first;
		}
		C[i + 1] = max(C[i], B[i]);
	}

	int res = 0;
	for(int i = 0; i < N; ++i) {
		res = max(res, A[i]);

		int t = A[i] - y[i].first + C[N - i - 1];
		res = max(res, t);
	}
	return res;
}

signed main(){
	int N, C;
	cin >> N >> C;
	vector<int> x(N), v(N);
	vector<pair<int,int>> y(N), z(N);
	for(int i = 0; i < N; ++i) {
		cin >> x[i] >> v[i];
		y[i] = make_pair(x[i], v[i]);
		z[i] = make_pair(C - x[i], v[i]);
	}
	reverse(ALL(z));
	int res = max(func(N, y, z), func(N, z, y));
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 7296
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 998244353; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

class lazySegTree(object):
	def __init__(self, N):
		self.N = N
		self.LV = (N - 1).bit_length()
		self.N0 = 2 ** self.LV
		self.data = [0] * (2 * self.N0)
		self.lazy = [0] * (2 * self.N0)
		self.size = [1] * (2 * self.N0)
		for i in range(self.N):
			self.size[self.N0 - 1 + i] = pow(10, self.N - i - 1 , mod)
		for i in range(self.N0 - 2, -1, -1):
			self.size[i] = (self.size[2 * i + 1] + self.size[2 * i + 2]) % mod

	# 遅延セグ木の初期化
	def initialize(self):
		for i in range(self.N):
			self.data[self.N0 - 1 + i] = pow(10, self.N - i - 1, mod)
		for i in range(self.N0 - 2, -1, -1):
			self.data[i] = (self.data[2 * i + 1] + self.data[2 * i + 2]) % mod

	# 遅延伝播を行うindexを生成
	def gindex(self, l, r):
		L = (l + self.N0) >> 1; R = (r + self.N0) >> 1
		lc = 0 if l & 1 else (L & -L).bit_length()
		rc = 0 if r & 1 else (R & -R).bit_length()
		for i in range(self.LV):
			if rc <= i:
				yield R
			if L < R and lc <= i:
				yield L
			L >>= 1; R >>= 1

	# 遅延伝搬処理
	def propagates(self, *ids):
		for i in reversed(ids):
			v = self.lazy[i - 1]
			if not v:
				continue
			self.lazy[2 * i - 1] = v; self.lazy[2 * i] = v
			self.data[2 * i - 1] = v * self.size[2 * i - 1]
			self.data[2 * i] = v * self.size[2 * i]
			self.lazy[i - 1] = 0

	def update(self, l, r, x):
		*ids, = self.gindex(l, r + 1)
		self.propagates(*ids)

		L = self.N0 + l; R = self.N0 + r + 1
		while L < R:
			if R & 1:
				R -= 1
				self.lazy[R - 1] = x; self.data[R - 1] = x * self.size[R - 1]
			if L & 1:
				self.lazy[L - 1] = x; self.data[L - 1] = x * self.size[L - 1]
				L += 1
			L >>= 1; R >>= 1
		for i in ids:
			self.data[i - 1] = (self.data[2 * i - 1] + self.data[2 * i]) % mod

	# 区間[l, r]内の和を求める
	def query(self, l, r):
		self.propagates(*self.gindex(l, r + 1))
		L = self.N0 + l; R = self.N0 + r + 1
		s = 0
		while L < R:
			if R & 1:
				R -= 1
				s += self.data[R - 1]
			if L & 1:
				s += self.data[L - 1]
				L += 1
			L >>= 1; R >>= 1
			s %= mod
		return s

	# デバッグ用
	def debug(self):
		ids = [i for i in range(self.N0 - 1, 0, -1)]
		self.propagates(*ids)
		print(self.data[self.N0 - 1:])

def main():
	N, Q = getlist()
	lSeg = lazySegTree(N)
	lSeg.initialize()
	# lSeg.debug()
	for i in range(Q):
		L, R, D = getlist()
		L -= 1; R -= 1
		lSeg.update(L, R, D)
		ans = lSeg.query(0, N - 1)
		print(ans)





if __name__ == '__main__':
	main()

Measured memory_bytes: 125444
n=int(input())
a=list(map(int,input().split()))
c=0#負数の数
ab=10**10#絶対値の最小
s=0#絶対値の総和
for i in range(n):
    if a[i]<0:
        c+=1
    if ab>abs(a[i]):
        ab=abs(a[i])
    s+=abs(a[i])
if c%2==0:
    print(s)
else:
    print(s-2*ab)


Measured memory_bytes: 20076
#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, long long M){

    if(N==1 && M==1){
        cout<<1<<endl;
    }
    else if(N==1 || M==1){
        cout<<max(N,M)-2<<endl;
    }
    else{
        cout<<N*M - (N-1)*2 -(M-1)*2<<endl;
    }

}

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

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    func(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5, Mod = 1e9 + 7;
typedef ll arr[Maxn];
ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, k;
arr fac, inv, invfac;
ll ans;
struct str
{
	int cnt, pos;
	bool operator<(str A) const { return cnt < A.cnt || (cnt == A.cnt && pos < A.pos); }
} a[Maxn];
ll C(int x, int y) { return fac[x] * invfac[y] % Mod * invfac[x - y] % Mod; }
int main()
{
	fac[0] = inv[1] = invfac[0] = 1;
	for (int i = 1; i <= 100000; i++)
	{
		fac[i] = fac[i - 1] * i % Mod;
		if (i > 1)
			inv[i] = (Mod - Mod / i) * inv[Mod % i] % Mod;
		invfac[i] = invfac[i - 1] * inv[i] % Mod;
	}
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		a[i] = {read(), i};
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n - k + 1; i++)
		ans = Add(ans, -(a[i].cnt * C(n - i, k - 1) % Mod));
	for (int i = k; i <= n; i++)
		ans = Add(ans, (a[i].cnt * C(i - 1, k - 1) % Mod));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3328
import bisect

N = int(input())
X = [int(x) for x in input().split()]

X2 = sorted(X)

for i in range(0, N):
    # idx = X2.index(X[i])
    idx = bisect.bisect_left(X2, X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])


Measured memory_bytes: 25556
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
#define SEG_LEN (1 << 20)
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n;
  cin >> n;
  vector<pair<ll,ll>>v(n);
  map<pair<ll,ll>,ll>m;
  rep(i,n)cin >> v[i].first >> v[i].second;
  sort(all(v));
  int ans = n;
  rep(i,n)rep(j,i){
    if(i == j)continue;
    int p = v[i].first - v[j].first,q = v[i].second - v[j].second;
    m[{p,q}]++;
  }
  for(auto i : m)ans = min((ll)ans,n - i.second);
  cout << ans << endl;
  return 0;
}
 

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

int main() {
  double x;
  cin >> x;
  
  int res = 0;
  double a = 100;
    
  while(a < x){
      ++res;
      a *= 1.01;
      a = floor(a);
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> btnTarget(N);
    for(int i=0;i<N;++i){
        int target;
        cin>>target;
        btnTarget[i]=target-1;
    }

    // ループフラグ
    vector<bool> btnReached(N,false);
    btnReached[0]=true;
    int cur=0;
    int elapsed=0;
    while(true){
        cur=btnTarget[cur];
        ++elapsed;
        
        if(cur==1)break;
        if(btnReached[cur])break;
        
        btnReached[cur]=true;
    }
    cout<<(cur==1?elapsed:-1)<<endl;
}

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

int main(){
    string s, ans="Good"; cin >> s;
    if(s[0]==s[1]) ans="Bad";
    if(s[1]==s[2]) ans="Bad";
    if(s[2]==s[3]) ans="Bad";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function warshall(){
   for(var k=0;k<nm[1];k++){
      for(var i=0;i<nm[1];i++){
         for(var j=0;j<nm[1];j++){
            C[i][j]=Math.min(C[i][j], C[i][k]+C[k][j]);
            T[i][j]=Math.min(T[i][j], T[i][k]+T[k][j]);
         }
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nm=(Arr.shift()).split(" ").map(Number);
   if(nm[0]==0 && nm[1]==0)break;
   var C=[];
   var T=[];
   for(var i=0;i<nm[1];i++){
      C[i]=[];
      T[i]=[];
      for(var j=0;j<nm[1];j++){
         C[i][j]=(i===j)?0:Infinity;
         T[i][j]=(i===j)?0:Infinity;
      }
   }
   for(var i=0;i<nm[0];i++){
      var A=(Arr.shift()).split(" ").map(Number);
      C[A[0]-1][A[1]-1]=C[A[1]-1][A[0]-1]=Math.min(A[2],C[A[0]-1][A[1]-1]);
      T[A[0]-1][A[1]-1]=T[A[1]-1][A[0]-1]=Math.min(A[3],T[A[0]-1][A[1]-1]);
   }
   warshall();
   var k=Arr.shift()-0;
   for(var i=0;i<k;i++){
      var B=(Arr.shift()).split(" ").map(Number);
      if(B[2]==0)console.log(C[B[0]-1][B[1]-1]);
      if(B[2]==1)console.log(T[B[0]-1][B[1]-1]);
   }
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int r; cin >> r;
	long long int sum = 0;
	sum = r * r;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	map<string, int>dict;
	int N;
	cin >> N;
	for (string x; N--; dict[x]++) {
		cin >> x;
	}
	int max = 0;
	for (auto i = dict.begin(); i != dict.end(); ++i) {
		if (i->second > max)
			max = i->second;
	}
	for (auto i = dict.begin(); i != dict.end(); ++i) {
		if (max == i->second)
			println(i->first);
	}
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <string.h>

int main() {
  char S[2000];
  int w;

  scanf("%2000s", S);
  scanf("%d", &w);

  for (int i = 0; i < strlen(S); i += w) {
    printf("%c", S[i]);
  }
  printf("\n");
}


Measured memory_bytes: 128
N = int(input())

adj = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    adj[-a].append((b, c))
    adj[-b].append((a, c))

Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for i in range(Q)]

# dist[-i]:頂点Kから頂点iまでの距離
dist = [-1 for i in range(N)]
dist[-K] = 0

# 深さ優先探索（スタック）
from collections import deque
stack = deque()
stack.append(K)

while stack:
    v = stack.pop()
    for nxt, c in adj[-v]:
        if dist[-nxt] == -1:
            dist[-nxt] = dist[-v] + c
            stack.append(nxt)

for x, y in query:
    print(dist[-x] + dist[-y])


Measured memory_bytes: 57204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100010];
    int ans,len;
    scanf("%s",s);len=strlen(s);
    if (s[0]==s[len-1])
    {
        if (len & 1) ans=2;
        else ans=1;
    }
    else
    {
        if (len & 1) ans=1;
        else ans=2;
    }
    if (ans==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    int ma = (int)log2(l);
    int su = l - pow(2, ma);

    //cout << ma << " " << su << endl;

    int su1 = 0;
    int su2 = su;
    while (su2 > 0)
    {
        su1 += su2 % 2;
        su2 /= 2;
    }

    int n = ma + 1;
    int m = ma * 2 + su1;

    cout << n << " " << m << endl;

    int cnt = 1;
    l--;
    for (int i = 1; i <= ma; i++)
    {
        cout << i << " " << i + 1 << " " << 0 << endl;

        cout << i << " " << i + 1 << " " << cnt << endl;

        if (su % 2 == 1)
        {
            l -= pow(2, i - 1) - 1;

            cout << i << " " << ma + 1 << " " << l << endl;

            l--;
        }

        su /= 2;

        cnt *= 2;
    }

    return 0;
}

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

int bs()
{
    int n;
    n = 10;
    int lo=0,hi=n;
    int key;
    key = 100;
    int arr[n] = {9,24,56,99,102,244,654,765,999,1002};
    while(lo < hi)
    {
        int md = (hi+lo)/2;//lo+(hi-lo)/2; lo+(hi-lo+1)/2;
        if(arr[md] > key)
        {
            hi = md-1;
        }
        else if(arr[md] < key)
        {
            lo = md+1;
        }
        else
        {
            return cout<<md<<endl,0;
            //hi = md;
            //lo = md;
        }
    }
}
int main()
{
    int n,m,a;
    cin>>n>>m;
    priority_queue<int>pq;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        pq.push(a);
    }
    while(m--)
    {
        pq.push(pq.top()/2);
        pq.pop();
    }
    long long sum = 0;
    while(!pq.empty())
    {
        sum = sum + (long long)pq.top();
        pq.pop();
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main(void){
    int input[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    ios :: sync_with_stdio(false);
    cin.tie(0);
    cin >> k;
    cout << input[k-1];

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
        char a, b;

        scanf("%c", &b);

        if(b == 'A') {
                a = 'T';
        } else if(b == 'T') {
                a = 'A';
        } else if(b == 'C') {
                a = 'G';
        } else if(b == 'G') {
                a = 'C';
        }

        printf("%c", a);
        return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int r = sc.nextInt();
		
		// 計算
		int result = 0;
		if(n >= 10) {
		    result = r;
		}else{
		    result = r + 100*(10-n);
		}
		
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 1;
    int bns = 1;
    rep(i, N) {
        ans *= 3;
        int A;
        cin >> A;
        if (A % 2 == 0) bns *= 2;
    }
    cout << ans - bns << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

vector<ll> ans;
vector<ll> num;

void plusOne(){
    ll c = 1;
    
    ll idx = num.size() - 1;
    
    while(c != 0){
        num[idx] ++;
        c = num[idx] / 10;
        num[idx] %= 10;
        idx --;
    }
}
bool chk(){
    ll idx = 0;
    rep(i, num.size()){
        if(num[i] != 0){
            idx = i;
            break;
        }
    }
    for(ll i = idx+1; i < num.size(); i++){
        if( abs(num[i] - num[i - 1]) > 1)  return false;
    }

    return true;
}

void addNum(){
    ll ret = 0;
    rep(i, num.size()){
        ret *= 10;
        ret += num[i];
    }
    ans.pb(ret);
}

void nxtNum(){
    ll idx = 0 ;
    rep(i, num.size()){
        if(num[i] != 0){
            idx = i;
            break;
        }
    }
    for(int i = idx; i < num.size() - 1; i++){
        if(abs(num[i] - num[i + 1]) > 1) {
            idx = i;
            break;
        }
    }
    
    // 12[3]5 -> 12[4]3
    if(num[idx] < num[idx + 1]){
        num[idx] ++;
    }
    // 12[3]5 ->12[4]3
    // 12[3]1 -> 12[3]2
    for(int i = idx + 1; i < num.size() ; i++){
        num[i] = max(0LL, num[i-1] - 1);
    }
}

void cal(){
    while(ans.size()!= 100000){
        if(chk()){
            addNum();
            plusOne();
        }else{
            nxtNum();
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i, 11) num.pb(0); plusOne();
    
    ll K ;
    
    cin >> K;
    cal();

    cout << ans[K-1] << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
namespace io{
    const int L = (1 << 20) + 1;
     
    char buf[L], *S , *T, c;
      
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
     
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
         
        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
         
        if(x)
            *--outs = x;
         
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};
  
using io :: print;
using io :: inp;
using io :: inp_ll;
const int INF = 1e9 ;
const int maxN = 1e2 + 10; 
const int MOD = 1e9 + 7;
ll f[maxN][maxN];
int h,w,k;
int s[20];
void cal(int x)
{
	int len = 1; 
	while(len<=w-1)
	{
		s[len] = x%2;
		x/=2;
		len++;
	}
}
int main()
{
	h = inp();
	w = inp();
	k = inp();
	f[0][1] = 1;
	int cnt = 1<<(w-1);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			for(int p=0;p<cnt;p++)
			{
				cal(p);
				int flag = 0;
				for(int g=1;g<=w-2;g++)
				{
					if(s[g]==1&& s[g+1] == 1)
						flag = 1;
				}
				if(flag) continue;
				if(s[j] == 1)
				{
					f[i][j+1] += f[i-1][j];
					f[i][j+1] %= MOD;
				}
				else if(j-1>=1 && s[j-1]==1)
				{
					f[i][j-1] += f[i-1][j];
					f[i][j-1] %= MOD;
				}
				else
				{
					f[i][j] += f[i-1][j];
					f[i][j] %= MOD;
				}
			} 
		}
	}
	
	printf("%lld\n",f[h][k]);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<int>> d(h,vector<int>(w,0));
    rep(i,h)
    {
        string s;
        cin >> s;
        rep(j,w)
            if(s[j]=='#') d[i][j] = 1;
    }

    vector<vector<int>> sw(h,vector<int>(w,0));
    vector<vector<int>> sh(h,vector<int>(w,0));

    rep(i,h)
    {
        for(int j=0;j<w;)
        {
            if(d[i][j])
                j++;
            else
            {
                int k = j+1;
                for(;k<w;++k)
                    if(d[i][k]) break;
                int cnt = k-j;
                rep2(l,j,k) sw[i][l] = cnt;
                j = k;
            }
        }
    }

    rep(j,w)
    {
        for(int i=0;i<h;)
        {
            if(d[i][j])
                i++;
            else
            {
                int k = i+1;
                for(;k<h;++k)
                    if(d[k][j]) break;
                int cnt = k-i;
                rep2(l,i,k) sh[l][j] = cnt;
                i = k;
            }
        }
    }

    int ans = 1;
    rep(i,h)
        rep(j,w)
            ans = max(ans, max(0,sw[i][j]+sh[i][j]-1));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 49408
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	int TC;
	TC=1;
	//cin>>TC;
	while(TC--)
	{
		ll a,b,c;
		cin>>a>>b>>c;
		cout<<c<<" "<<a<<" "<<b<<endl;
		
		
	}
	return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

vector<int>v;
class DHandstand {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, k;
        cin >> n >> k;
        string s;
        cin >> s;
        v.clear();
        int now = 1;
        int time = 0;
        for(int i = 0; i < n; ++i){
            if(now + '0' == s[i])time++;
            else {
                v.push_back(time);
                now = 1 - now;
                time = 1;
            }
        }
        if(time)v.push_back(time);
        if(v.size()%2 == 0)v.push_back(0);
        // for(int i = 0; i < v.size(); ++i)cout << v[i] << " ";
        // cout << endl;
        int len = 2*k + 1;
        int res = 0, tmp = 0;
        int sz = 0;
        for(int i = 0; i < v.size(); i++){
            sz ++;
            tmp += v[i];
            if(sz > len){tmp -= v[i-len]; sz--;}
            if(i%2==0)res = max(res, tmp);
        }
        out << res << '\n';
    }
};



int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    DHandstand solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 1020
import sys
def I(): return int(sys.stdin.readline().rstrip())


S = I()
mod = 10**9+7

kaijou = [1]
for i in range(1,S):
    kaijou.append((kaijou[-1]*i) % mod)

inv = [1]
for i in range(1,S):
    inv.append(pow(kaijou[i],mod-2,mod))


def nCr(n,r):
    if n < r:
        return 0
    return (kaijou[n]*inv[r]*inv[n-r]) % mod


ans = 0
for i in range(1,S//3+1):
    ans += nCr(S-1-2*i,i-1)
    ans %= mod

print(ans)


Measured memory_bytes: 67720
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
#define LL long long
using namespace std;
const int N=2e5+10;
struct node{ LL scr; int flg; }pt[N];
int n,m,tot;
LL ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
inline bool cmp(node a,node b){return a.scr<b.scr;}
int main()
{
	//freopen("Gr-idian MST.in","r",stdin);
	read(n,m); tot=n+m;
	for(RG int i=1;i<=n;i++) read(pt[i].scr);
	for(RG int i=1;i<=m;i++) read(pt[i+n].scr), pt[i+n].flg=1;
	sort(pt+1,pt+1+tot,cmp);
	n++; m++;
	for(RG int i=1;i<=tot && n && m;i++)
	{
		ans+=pt[i].scr*(pt[i].flg ? n : m);
		if(pt[i].flg) m--; else n--;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int cnt = 100000;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int j = 0;
    while (A % 2 == 0) {
      A /= 2;
      j++;
    }
    if (cnt > j) {
      cnt = j;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto ab = new long[2][](N);
	auto cd = new long[2][](M);
	foreach (i; 0..N)
	{
		ab[i] = [RD, RD];
	}
	foreach (i; 0..M)
	{
		cd[i] = [RD, RD];
	}

	foreach (i; 0..N)
	{
		long best = long.max, pos;
		foreach (j; 0..M)
		{
			auto d = abs(cd[j][0] - ab[i][0]) + abs(cd[j][1] - ab[i][1]);
			if (d < best)
			{
				best = d;
				pos = j;
			}
		}
		writeln(pos+1);
	}

	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[]args) {
	Scanner sc= new Scanner(System.in);
	int k=sc.nextInt();
	String s= sc.next();
	//System.out.println(s.length());
	if(s.length()>k) {
		System.out.println(s.substring(0,k)+"...");
	}
	else {
		System.out.println(s);
	}
}
}


Measured memory_bytes: 26912
A, B, M = list(map(int,input().split()))
list_a = list(map(int,input().split()))
list_b = list(map(int,input().split()))
buy = []
buy.append(min(list_a) + min(list_b))
for i in range(M):
    x, y, c = list(map(int,input().split()))
    buy.append(list_a[x-1] + list_b[y-1] - c)
answer = min(buy)
print(answer)


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

int main() {
    string S;
    cin >> S;
    ll count = 0;
    ll N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') count ++;
    }
    
    if (N == 1) cout << 0 << endl;
    else {
        if (count == N-count) cout << N << endl;
        else if (count < N-count) cout << 2*count << endl;
        else if (count > N-count) cout << 2*(N-count) << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=list(map(int,input().split()))
    ans=0
    for d in range(1,n):
        score=0
        P=set()
        for x in range(n//d):
            a=(n-1)-x*d
            if(a<=d): break
            if((x*d in P) or (n-1-x*d in P)): break
            if(x*d==n-1-x*d): break
            score+=S[x*d]
            score+=S[n-1-x*d]
            P.add(x*d)
            P.add(n-1-x*d)
            ans=max(ans,score)
    print(ans)
resolve()

Measured memory_bytes: 97016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n;
  cin >> n;
  int mx = mod;
  int res = 0;
  while(n--){
    int x;
    cin >> x;
    if(x < mx){
      res++;
      mx = x;
    }
  }
  cout << res;
}

Measured memory_bytes: 256
S=input()
n=len(S)
t=[0]*(n+2)
b=[0]*2019
m=0
mod2019_10=[0]*(n+1)
#print(S[n-1])
t[n+1]=0
t[n]=int(S[n-1])%2019
mod2019_10[0]=1
for i in range(1,n+1):
    mod2019_10[i]=(mod2019_10[i-1]*10)%2019
for i in range(1,n):
    t[n-i]=(t[n-i+1]+(int(S[n-i-1])*mod2019_10[i])%2019)%2019
#print(t[n-1],t[n-4])
for i in range(1,n+2):
    b[t[i]]+=1
#print(b[0])
for i in range(2019):
    if b[i]>=2:
        m=m+(int(b[i]*(b[i]-1)/2))
print(m)


Measured memory_bytes: 23540
# coding: utf-8
# Your code here!
S = input()
T = input()

a = 0
ans = len(T)

for i in range(len(S)-len(T)+1):
    a = 0
    for j in range(len(T)):
        if(T[j] != S[i+j]):
            a += 1
    ans = min(ans,a)

print(ans)


Measured memory_bytes: 9004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0)break;
			if(x > y) {
				System.out.println(y  + " " + x);
			}
			else{
				System.out.println(x  + " " + y);
			}
		}
	}
}


Measured memory_bytes: 35388
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    T, X = il()
    return T / X


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3316