akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long Int;

const Int INF = 1001001001001001001ll;

Int cost[1024][1024];
Int dist[1024][1024];

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

int cv[128];

bool valid(int ny, int nx, int H, int W)
{
	return (0 <= ny && ny < H && 0 <= nx && nx < W);
}

class State {
public:
	int ny, nx;
	Int c;

	State(int ny, int nx, Int c) : ny(ny), nx(nx), c(c){}
	State(){}

	bool operator > (const State &t) const {
		return (this->c > t.c);
	}
};

int main()
{
	int W, H, N;
	int sx, sy, tx, ty;

	cv['U'] = 0, cv['D'] = 1, cv['L'] = 2, cv['R'] = 3;

	scanf("%d %d %d", &W, &H, &N);
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	sy = 2 * sy; sx = 2 * sx;
	ty = 2 * ty; tx = 2 * tx;

	for (int i = 0; i < N; i++){
		int ix, iy, T;
		char s[1024];
		scanf("%d %d", &ix, &iy);
		scanf("%d %s", &T, s);

		while (T--){
			for (int j = 0; s[j]; j++){
				//[2 * iy + 1][2 * ix + 1]
				int ny = iy + dy[cv[s[j]]], nx = ix + dx[cv[s[j]]];
				if (valid(ny, nx, H, W)){
					cost[2 * iy + dy[cv[s[j]]] + 1][2 * ix + dx[cv[s[j]]] + 1]++;
					iy = ny, ix = nx;
				}
			}
		}
	}

	priority_queue<State, vector<State>, greater<State> > pq;
	
	for (int i = 0; i <= 2 * H; i++){
		for (int j = 0; j <= 2 * W; j++){
			dist[i][j] = INF;
		}
	}

	pq.push(State(sy, sx, 0));

	while (pq.size()){
		State now = pq.top(); pq.pop();
		if (dist[now.ny][now.nx] <= now.c) continue;
		dist[now.ny][now.nx] = now.c;

		for (int i = 0; i < 4; i++){
			State nxt = now;
			nxt.ny += dy[i]; nxt.nx += dx[i];
			if ((nxt.ny * nxt.nx) % 2) continue;
			if (valid(nxt.ny, nxt.nx, 2 * H + 1, 2 * W + 1)){
				nxt.c += cost[nxt.ny][nxt.nx];
				if (dist[nxt.ny][nxt.nx] > nxt.c) pq.push(nxt);
			}
		}
	}

	printf("%lld\n", dist[ty][tx]);

	return (0);
}

Measured memory_bytes: 26228
l = input()
n = len(l)

x = 0
y = []
for i in range(1, int(n/2)):
    x = l[0:i*2]
    if x[0:int(len(x)/2)] == x[int(len(x)/2):]:
        y.append(len(x))
    
print(max(y))


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, m;
    cin >> n >> m;
    vs a(n);
    forn(i, n) cin >> a[i];
    vb used(n);
    forn(i, n){
        forn(j, m){
            if (a[i][j] == '#') used[i] = 1;
        }
    }
    forn(i, n){
        forn(j, m){
            cout << ((i % 2 == 0 && j > 0 && j + 1 < m) || j == 0 || a[i][j] == '#' ? '#' : '.');
        }
        cout << '\n';
    }
    cout << '\n';
    forn(i, n){
        forn(j, m){
            cout << ((i % 2 == 1 && j > 0 && j + 1 < m) || j == m - 1 || a[i][j] == '#' ? '#' : '.');
        }
        cout << '\n';
    }
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

int main() {
	int n,k;cin>>n>>k;

	if(n%2==0){
		if(2*k>n){cout<<-1<<endl;return 0;}
		int m=n/2;
		for(int i=0;i<m;i++){
			cout<<k+2*i<<" "<<k+2*n-1-i<<" "<<k+2*n+m+i<<endl;
		}
		for(int i=0;i<m;i++){
			cout<<k+2*i+1<<" "<<k+n+n-m-1-i<<" "<<k+2*n+i<<endl;
		}
	}
	else{
		if(2*k>n+1){cout<<-1<<endl;return 0;}
		int m=(n+1)/2;

		for(int i=0;i<m;i++){
			cout<<k+2*i<<" "<<k+n+n-1-i<<" "<<k+n+n+m+i-1<<endl;
		}
		for(int i=0;i<m-1;i++){
			cout<<k+2*i+1<<" "<<k+n+n-m-1-i<<" "<<k+2*n+i<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        scanner.close();

        int train = (A <= B) ? A : B;
        int bus = (C <= D) ? C : D;

        System.out.println(train + bus);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    string s=a+b;
    int c;
    c=stoi(s);
    REP(i,c/2){
        if(i*i==c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  int ans = (H-h)*(W-w);
  cout << ans << endl;
}

Measured memory_bytes: 3608
N,K=map(int,input().split())
sunuke = [0]*N

for _ in range(K):
    d = int(input())
    temp = list(map(int,input().split()))
    for j in temp:
        sunuke[j-1]+=1

ans = 0
for k in range(len(sunuke)):
    if sunuke[k] == 0:
        ans +=1
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 1;
  for (int i = 0; i < N; i ++) {
    if (sum * 2 >= sum + K) {
      sum += K;
    } else {
      sum *= 2;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    unsigned int num;
    unsigned int house[4][3][10];
    unsigned int bil;
    unsigned int flor;
    unsigned int room;
    signed int  riside;
    unsigned int i, j, k;
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                house[i][j][k] = 0;
            }
        }
    }
    scanf("%d", &num);
    for(i = 0;i < num;i++){
        scanf("%d %d %d %d", &bil, &flor, &room, &riside);
        house[bil - 1][flor - 1][room - 1] += riside;
    }
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                printf(" %d", house[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3){
           printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2032
n = int(input())
s = input()

b = 0
w = 0
tb = 0
tw = 0

for i in reversed(range(n)):
    if s[i] == '#':
        tb += 1
        if tb > tw:
            b += tb
            w += tw
            tb = 0
            tw = 0
    else:
        tw += 1
print(tb + w)





Measured memory_bytes: 3500
#!/usr/bin/env python3


def read_h(typ=int):
    return map(typ, input().split())


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def main():
    a, b = read_h()
    cnt = 0
    for i in range(a, b + 1):
        s = str(i)
        if s[:2] == s[3:][::-1]:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion

//079 C-Train Ticket

int main(void) {
	int a, b, c, d,i;
	char s[5];
	int f[8][3] = { 1,1,1,  1,1,-1,  1,-1,1,  1,-1,-1,
				 -1,-1,-1, -1,-1,1, -1,1,-1, -1,1,1  };

	scanf("%s", &s);
	a = s[0] - '0'; b = s[1] - '0'; c = s[2] - '0';d=s[3]-'0';
	for (i = 0; i < 8; i++) {
		if (7 == (a + b * f[i][0] + c * f[i][1] +
			d * f[i][2]))
			break;
	}
	printf("%d%c%d%c%d%c%d=7\n", a,
		(f[i][0] == 1) ? '+' : '-', b,
		(f[i][1] == 1) ? '+' : '-', c,
		(f[i][2] == 1) ? '+' : '-', d);

	return 0;
}





Measured memory_bytes: 2124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]){
        char buf[7];
        scanf("%s", &buf);
        if (buf[2] == buf[3] && buf[4] == buf[5]){
                printf("Yes\n");
        } else {
                printf("No\n");
        }
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;

int main() {

    char a,b ; 
    cin >> a >> b  ;

    if(a<b)
     cout << '<' ;
    else if(a>b)
     cout << '>' ;
    else 
     cout << '=' ;
    
  cout << endl ;

  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define what_is(x) cerr<<#x<<" is "<<x<<"\n";
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bi back_inserter
using ll=long long;
using namespace std;
const long MOD=998244353;
const long mod1=1000000007;
/*__gcd(a,b),__builtin_ffs(ll)(x),__builtin_clz(x),__builtin_popcount(x)*/
/*ll comb(int n,int r){
	ll p=1,q=1,m;
	if(n-r<r)
		r=n-r;
	while(r){
		p*=n;
		q*=r;
		m=__gcd(p,q);
		p/=m;
		q/=m;
		n--;r--;
	}
	return p;
}*/

void solve()
{
		int n,m,i,sum=0;
		cin>>n>>m;
		vector <int> a(n);
		for(i=0;i<n;i++)
				{
						cin>>a[i];sum+=a[i];
				}
		sort(a.begin(),a.end());
		int temp=ceil((float)sum/(4*m));
		if(a[n-m]>=temp)
				cout<<"Yes";
		else
				cout<<"No";
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	long t=1;
	//cin>>t;
		while(t--) solve();
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s;
    vector<pair<ll,ll> > v,ve;
    for(int i=0;i<n;i++){
    	cin >> s;
    	ll num = 0;
    	ll m = s.length();
    	ll mi = 0;
    	for(int j=0;j<m;j++){
    		if(s[j] == '(') num++;
    		else num--, mi = min(mi, num);
    	}
    	if(num >= 0)v.push_back({mi, num});
    	else{
    		num = 0;
    		mi = 0;
    		for(int j=m-1;j>=0;j--){
    			if(s[j] == ')') num++;
    			else num--, mi = min(mi, num);
    		}
    		ve.push_back({mi, num});
    	}
    }
    ll ans = 0;
    sort(be(v));
    reverse(be(v));
    for(auto i: v){
    	if(ans + i.first < 0LL){
    		cout << "No" << endl;
    		return 0;
    	}
    	ans += i.second;
    }
    ll num = 0;
    sort(be(ve));
    reverse(be(ve));
    for(auto i: ve){
    	if(num + i.first < 0LL){
    		cout << "No" << endl;
    		return 0;
    	}
        num += i.second;
    }
    if(num == ans) {
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 18972
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
char S[MAXN];
int ans;

int main() {
	register int i;
	scanf("%s", S + 1); N = strlen(S + 1);
	ans = N / 2; for(i = 1; i <= N; ++i) ans -= S[i] == 'p';
	printf("%d\n", ans);
	return 0;
}

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

int main() {
	vector<pair<int, int>> x(100), y(100);
	int n, m, o, t, h;
	o = t = h = 10;
	cin >> n >> m;
	vector<int> s(m), c(m);
	for(int i = 0; i < m; ++i) {
		cin >> s.at(i) >> c.at(i);
		(s.at(i) == 1 ? o = min(o, c.at(i)) : 
			(s.at(i) == 2 ? t = min(t, c.at(i)) : h = min(h, c.at(i))));
		x.at(s.at(i)).first += 1;
		if(x.at(s.at(i)).first > 0 && c.at(i) == x.at(s.at(i)).second) {
			x.at(s.at(i)).first -= 1;
			x.at(s.at(i)).second = c.at(i);
		}
		if(x.at(s.at(i)).second == 0)
			x.at(s.at(i)).second = c.at(i);
		else if(x.at(s.at(i)).second != c.at(i)) {
			cout << "-1" << endl;
			return 0;
		}
		if(x.at(s.at(i)).second == c.at(i))
			x.at(s.at(i)).first = 1;
		if(s.at(i) == 1 && c.at(i) == 0) {
			if(n == 1) {
				cout << 0 << endl;
				return 0;
			}
			cout << "-1" << endl;
			return 0;
		}
		if(x.at(s.at(i)).first != 0)
			if(x.at(s.at(i)).second != c.at(i)) {
				cout << "-1" << endl;
				return 0;
			}
	}
	if(o == 10) {
		o = 1;
		if(n == 1)
			o = 0;
	}
	if(t == 10) {
		t = 0;
	}
	if(h == 10)
		h = 0;

	cout << o;
	if(n == 2)
		cout << t;
	if(n == 3)
		cout << t << h;
	cout << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>

#define NMAX 2000000
#define IMAX 10000
using namespace std;

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

	int n;
	int cnt=0;
	int min=IMAX+1,max=-1;
	int A[NMAX+1],C[IMAX+1]={0};

	cin>>n;

	for(int i=0;i<n;i++){
		cin>>A[i];
		if(A[i]>max) max=A[i];
		else if(A[i]<min) min=A[i];
	}

	for(int i=0;i<n;i++){
		C[A[i]]++;
	}
	
	for(int i=min;i<=max;){
		if(C[i]>0){
			A[cnt]=i;
			C[i]--;
			cnt++;
		}
		else i++;
	}

	for(int i=0;i<n-1;i++){
		cout<<A[i]<<" ";
	}
	cout<<A[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 9064
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
	int N,M;

	cin >> N;

  multiset<long long int> A, plu, minu;
  for (int i = 0;i<N;i++)
  {
    long long int tmp;
    cin >> tmp;
    A.insert(tmp);
    if (tmp < 0)
      minu.insert(tmp);
    else
      plu.insert(tmp);
  }
  
  auto sum = 0LL, neuv = 0LL;
  vector<pair<long long int,long long int>> r;
  
  while (plu.size() + minu.size() > 1) {
    if (plu.empty()){
      if (minu.size() == 2){
      	neuv = *minu.rbegin() - *(minu.rbegin()++);
     	r.emplace_back(*minu.rbegin(), *(minu.rbegin()++));
      }
      else{
      	neuv = *(minu.rbegin()++) - *minu.rbegin();
     	r.emplace_back(*(minu.rbegin()++), *minu.rbegin());
      }
      sum = neuv;
      minu.erase(--minu.end());
      minu.erase(--minu.end());
      if (neuv < 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
    }
    else if (minu.empty()) {
      if (plu.size() == 2){
        neuv = *(plu.begin()++) - *plu.begin();
      r.emplace_back(*(plu.begin()++), *plu.begin());
      }
      else{
        neuv = *plu.begin() - *(plu.begin()++);
      r.emplace_back(*plu.begin(), *(plu.begin()++));
      }
      sum = neuv;
      plu.erase(plu.begin());
      plu.erase(plu.begin());
      if (neuv <= 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
    }
    else if (plu.size() <= minu.size()) {
      neuv = *plu.begin() - *minu.rbegin();
      sum = neuv;
      r.emplace_back(*plu.begin(), *minu.rbegin());
      plu.erase(plu.begin());
      minu.erase(--minu.end());
      if (neuv < 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
      
    }
    else {
      neuv = *minu.rbegin() - *plu.begin();
      sum = neuv;
       r.emplace_back(*minu.rbegin(), *plu.begin());
      plu.erase(plu.begin());
      minu.erase(--minu.end());
      if (neuv <= 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
      
    }
  }
	cout << sum << endl;
  for (auto&& i : r)
    cout << i.first << " " << i.second << endl;

	return 0;
}


Measured memory_bytes: 13556
N,K = map(int,input().split())
s = input()
A = [0,0]
zerodig = 0
for i in range(N-1):
    if s[i] != s[i+1]:
        A.append(i+1)
        if (s[i] == "0" and s[i+1] == "1"):
            zerodig += 1
if s[N-1] == "0":
    zerodig += 1

A.append(len(s))
A.append(len(s))

if s[0] == "0":
    check = 0
else:
    check = 1

width = 2 * K + 1
score = 0

if zerodig <= K:
    print(len(s))
else:
    for i in range(len(A)-width):
        if score <= A[i+width] - A[i] and (i+check) % 2 == 0:
            score = A[i+width] - A[i]
    print(score)

Measured memory_bytes: 7236
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int disx = tx - sx, disy = ty - sy;
    rep(i, disy){
        cout << 'U';
    }
    rep(i, disx){
        cout << 'R';
    }
    rep(i, disy){
        cout << 'D';
    }
    rep(i, disx+1){
        cout << 'L';
    }
    rep(i, disy+1){
        cout << 'U';
    }
    rep(i, disx+1){
        cout << 'R';
    }
    cout << "DR";
    rep(i, disy+1) {
        cout << 'D'; 
    }
    rep(i, disx+1) {
        cout << 'L';
    }
    cout << 'U' << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;


int main (){
    double a,b,x;
    cin >> a >> b >> x;
    double ans;

    if (x<=0.5*b*a*a) {
        ans = 90-atan(2*x/b/b/a)*180/PI;
    }
    else {
        ans = 90-atan(a/(2*b-2*x/a/a))*180/PI;;
    }

    cout << fixed << setprecision(6) << ans << endl;
}



Measured memory_bytes: 512
main(w,n,x,y,z){
  for(w=1;w<31;w++)
    a[w]=w;
  scanf("%d%d",&w,&n);
  for(;n--;z=a[x],a[x]=a[y],a[y]=z)
    scanf("%d,%d",&x,&y);
  for(n=1;n<=w;n++)
    printf("%d\n",a[n]);
  return 0;
}

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

int main(){
    long N,D;
    cin >> N >> D;
    long X,Y;
    long count = 0;
    for(long i=0; i<N; i++){
        cin >> X >> Y;
        if(D>=sqrt(X*X+Y*Y)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

ll x, y;
int main(){
  ll x, y;
  cin >> x >> y;
  if(x >= 0 && y >= 0){
    if(y >= x) cout << y-x << endl;
    else{
      cout << min(1 + y+x, x-y+2) << endl;
    }
  }else if(x >= 0 && y < 0){
    if(abs(x) >= abs(y)){
      cout << 1 + abs(x) - abs(y) << endl;
    }else{
      cout << 1 + abs(y) - abs(x) << endl;
    }
  }else if(x < 0 && y >= 0){
    if(abs(x) >= abs(y)){
      cout << min(1 + abs(x) - abs(y), abs(x) + abs(y)) << endl;
    }else{
      cout << min(1 + abs(y) - abs(x), abs(x) + abs(y)) << endl;
    }
  }else{
    if(abs(x) >= abs(y)){
      cout << abs(x) - abs(y) << endl;
    }else{
      cout << min(2 + abs(y) - abs(x), abs(x) + abs(y) + 1) << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    cin>>S;
    
    vvll a;
    vll b={0};
    for(int i=0;i<S.size();i++){
        if(b.size()==1){
            if(S[i]!='R'){
                b.push_back(i);
            }
        }else if(b.size()==2){
            if(S[i]!='L'){
                b.push_back(i);
                a.push_back(b);
                b.clear();
                b.push_back(i);
            }
        }
    }
    
    ll ans=0;
    for(int i=0;i<a.size();i++){
        for(ll j=a[i][0];j<a[i][1]-1;j++) printf("%d ",0);
        ll left=a[i][1]-a[i][0];
        ll right=a[i][2]-a[i][1];
        printf("%lld ",(left+1)/2+right/2);
        printf("%lld ",left/2+(right+1)/2);
        for(ll j=a[i][1]+1;j<a[i][2];j++) printf("%d ",0);
    }
    
    for(ll j=b[0];j<b[1]-1;j++) printf("%d ",0);
    ll left=b[1]-b[0];
    ll right=S.size()-b[1];
    printf("%lld ",(left+1)/2+right/2);
    printf("%lld ",left/2+(right+1)/2);
    for(ll j=b[1]+1;j<S.size();j++) printf("%d ",0);
    
    return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 2019
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 200005
string s;
int n;
map<int, int> hmm;

ll modExp(ll b, ll ex){
    ll prod = 1;
    while(ex > 0){
        if(ex % 2 == 0){
            b = (b * b) % MOD;
            ex /= 2;
        } else{
            prod = (prod*b) % MOD;
            ex--;
        }
    }
    
    return prod;
}

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

    cin >> s;
    n = s.length();
    ll ans = 0;
    hmm[0]++;
    int cur = 0;
    F0R(i, n){
        int x = (s[i]-'0')*modExp(10, n-i);
        cur = (cur+x)%MOD;
        ans += hmm[cur];
        hmm[cur]++;
    }
    cout << ans << "\n";

    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

int main(){
   int x;
   cin>>x;
   int ans=360 / gcd(x, 360);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AWhiteCells solver = new AWhiteCells();
        solver.solve(1, in, out);
        out.close();
    }

    static class AWhiteCells {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int nn = in.nextInt();
            int mm = in.nextInt();
            int ans = n * m;
            ans -= nn * m;
            ans -= mm * (n - nn);
            out.println(ans);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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



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

int main() {
  string s;
  cin>>s;
  if(s.size()==2){
    cout<<s<<endl;
  }
  else if(s.size()==3){
    cout<<s[2]<<s[1]<<s[0]<<endl;
  }

}




Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        if(i >=k){
            ans += (double)1.0/n;
            continue;
        }
        int c = i;
        double temp = (double)1.0/n;
        while(c < k){
            c *= 2;
            temp/=2.0;
        }
        ans += temp;
        
    }
    printf("%.10lf\n", ans);
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
ll A, B;
cin >> A >> B;
if(A % B == 0){
	print(-1);
	return 0;
}

print(A);

}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
x=abs(x)
t=x-k*d
if t>=0:
  print(t)
else:
  td=x%d
  tk=x//d
  if (k-tk)%2==0:
    print(td)
  else:
    print(abs(td-d))

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

int main(){
    ll N,sum=0;
    cin >> N;
    for(ll i=1;i<=N;i++){
        if(i%3 !=0 && i%5 !=0) sum +=i;
    } 
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//int 整数 double 小数（実数） string 文字列 bool 0以外真 if else char ''
// != 等しくない true 1 真  false 0 偽
// ! 偽 && かつ || または 文字列変数.size() 文字数 文字列.at(i)　i文字目

int main(){
    
    int X,Y;
    
    cin >> X >> Y;
    
    cout << X + (Y / 2) << endl;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] = tolower(s[k-1]);
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}

int main() {
  IN(ll, N);
  IN(ll, L);
  IN(ll, T);
  vector<vector<ll>> X(N,vector<ll>(2,0));
  vector<ll> W(N);
  REP(i, N){
    cin >> X[i][0];
    cin >> W[i];
  }
  int count = 0;
  int ant0 = 0;
  if(W[0] == 1){
    for(int i = 1; i < N; i++){
      if(W[0] != W[i]){
        ll d = X[i][0] - X[0][0];
        count += (2*T)/L;
        if((2*T)%L >= d)
          count++;
      }
    }
    count %= N;
    ant0 = count;
  }
  else{
    for(int i = 1; i < N; i++){
      if(W[0] != W[i]){
        int d = X[i][0] - X[0][0];
        count += (2*T)/L;
        if((2*T)%L >= L-d)
          count++;
      }
    }
    count %= N;
    ant0 = (N - count)%N;
  }
  if(W[0] == 1)
    X[0][1] = 1;
  else
    X[0][1] = -1;
  REP(i, N){
    if(W[i] == 1)
      X[i][0] = (X[i][0] + T)%L;
    else
      X[i][0] = (L + X[i][0] - T%L)%L;
  }
  SORT(X);
  int num = 0;
  REP(i, N){
    if(X[i][1] != 0){
      num = i;
    }
  }
  ant0 = (N + num - ant0)%N;
  for(int i = 0; i < N; i++){
    OUT(X[(i+ant0)%N][0]);
  }
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
int main() {
  ll a,ave;
  cin>>a;
  ave=0;
  vector<ll>v1(a);
  vector<ll>cost(a);
  for(ll i=0;i<a;i++){
    cin>>v1.at(i);
    ave+=v1.at(i);
  }
  ave/=a;
  ll ave2=ave+1;
  ll count1=0,count2=0;
  for(ll j=0;j<a;j++){
    ll x=v1.at(j);
    count1+=(x-ave)*(x-ave);
    count2+=(x-ave2)*(x-ave2);
  }
  cout<<min(count1,count2)<<endl;
}
  
  

Measured memory_bytes: 256
N = 0
FList = []
PList = []

def open_shop_num( n ):
    open_shop = [0] * N
    for i in range(10):
        if n % 2 == 1:
            for shop in range(N):
                if FList[shop][i] == 1:
                    open_shop[shop] += 1
        n = n//2
    return open_shop

def calc_profit( open_shop ):
    sum1 = 0
    for i in range(N):
        sum1 += PList[i][open_shop[i]]
    return sum1

N = int(input())
for _ in range(N):
    FList.append(list(map(int,input().split())))
for _ in range(N):
    PList.append(list(map(int,input().split())))

ans = -(10**10)
for pat in range(1,2**10):
    open_shop = open_shop_num( pat )
    ans = max(ans, calc_profit(open_shop))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  bool ans = true;
  while (0 == 0) {
    C = C - B;
    if (C <= 0) {
      ans = true;
      break;
    }
    A = A - D;
    if (A <= 0) {
      ans = false;
      break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;


long long int N,M,K,res;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    res=M;
    for(long long int i=0;i<N-1;i++){
        res*=M-1;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt
  val a = StdIn.readLine.split(" ").map(_.toLong)
  
  val odd = a.count(i => (i&1) == 1)
  val even = a.count(i => (i&1) == 0)
  val mlt4 = a.count(i => (i&3) == 0)

  // println(odd + " " + even + " " + mlt4)

  val ans = if(odd == mlt4+1) {
    if(even == mlt4) "Yes"
    else "No"
  }
  else if(odd <= mlt4) "Yes" else "No"
  println(ans)
}

Measured memory_bytes: 42044
N, T = map(int, input().split())
A = [0]*N
B = [0]*N
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
dp = [[0]*(T) for _ in range(N+1)]
ans = 0
for i in range(N):
    for j in range(T):
        dp[i+1][j] = dp[i][j]
        ans = max(ans, dp[i][j] + AB[i][1])
        # 上は この時刻jまでで商品i-1個を入れた後に時間制約の無いi個目の商品を追加している
        if j - AB[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-AB[i][0]] + AB[i][1])
print(ans)


Measured memory_bytes: 141252
#include<stdio.h>
#include<string.h>
int main(void){
  char s[100001];
  scanf("%s",s);
  long l=strlen(s);
 
  while(1){
    if(strncmp(s+l-5,"dream",5)==0){
      s[l-5]='\0';
      l-=5;
    }else if(strncmp(s+l-7,"dreamer",7)==0){
      s[l-7]='\0';
      l-=7;
    }else if(strncmp(s+l-5,"erase",5)==0){
      s[l-5]='\0';
      l-=5;
    }else if(strncmp(s+l-6,"eraser",6)==0){
      s[l-6]='\0';
      l-=6;
    }else{
      break;
    }
  }
    if(l==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}
 

Measured memory_bytes: 256
N = int(input())
li = [i for i in range(1, N + 1)]
acc = 0
index = 0
for i in range(N):
    acc += li[i]
    if acc >= N:
        index = i
        break
garbage = acc - N
for i in range(index + 1):
    if li[i] != garbage:
        print(li[i])


Measured memory_bytes: 221840
import static java.lang.Integer.min;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int w[] = new int[N];
        int difference[] = new int[N];
        for(int i = 0; i < w.length; i++){
            w[i] = sc.nextInt();
        }
        int point = 0;
        
        while(point < N){
            int front = 0;
            int back = 0;
            for(int i = 0; i < point; i++){
                front += w[i];
            }
            for(int i = point; i < N; i++){
                back += w[i];
            }
            difference[point] = Math.abs(front - back);
            point++;
        }
        
        int min = difference[0];
        for(int i = 1; i < difference.length; i++){
            min = min(min,difference[i]);
        }
        
        
        System.out.println(min);
        
    }
}


Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
using namespace std;
int _P=1000000007;
int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(int i=0;i<n;++i) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int res;
	if(n%2) {
		res = b[n/2]-a[n/2]+1;
	}
	else {
		res = b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
ll D;
ll pw[20],dx1[20],dx2[20];
vector<ll>v;

void dfs(int s,int e,ll val,ll cnt,ll &res){
	if(s==e){
		if(val==D){
			res+=cnt;
		}
		return;
	}
	if(abs(val-D)>v[s]*20)return;
	
	for(int i=-9;i<=9;i++){
		dfs(s+1,e,val+v[s]*i,cnt*(s==0?dx2[i+10]:dx1[i+10]),res);	
	}
}

ll solve(int n){
	v.clear();
	for(int i=0;n-1-i>i;i++){
		v.push_back(pw[n-1-i]-pw[i]);
	}
	ll res=0;
	dfs(0,SZ(v),0LL,1LL,res);
	
	if(n%2)res*=10LL;
	return res;
}

int main(){
	cin>>D;
	if(D%9!=0){
		cout<<0<<endl;
		return 0;
	}
	pw[0]=1;
	for(int i=1;i<20;i++)pw[i]=pw[i-1]*10;
	
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			dx1[i-j+10]++;
		}
	}
	for(int i=0;i<10;i++){
		for(int j=1;j<10;j++){
			dx2[i-j+10]++;
		}
	}
	ll ans=0;
	for(int i=2;i<=19;i++)ans+=solve(i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3612
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE StrictData #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L
import Data.Maybe

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [n] = sum [f a b c | a <- [1..n], b <- [1..n], c <- [1..n]]
  where
    f 1 _ _ = 1
    f _ 1 _ = 1
    f _ _ 1 = 1
    f a b c = gcd (gcd a b) c

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 4812
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<random>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 500+10
    int N,K,ans=1;
int main(){
    cin>>N>>K;
    REP(i,N){
        ans+=min(ans,K);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct 
{
  char gara;
  int value;
  int position;
}card;

void QuickSort(int,int);
int partition(int,int);
int inStable();

int n;
card A[100000];

int main(){

  int i;

  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf(" %c%d",&A[i].gara,&A[i].value);
    A[i].position = i;
  }

  QuickSort(1,n);

  if(inStable()==1)printf("Stable\n");
     else printf("Not stable\n");
  
  for(i = 1;i <= n;i++){
    printf("%c %d\n",A[i].gara,A[i].value);
   
  }
  return 0;
}

void QuickSort(p,r){
  int q;

  if(p < r){
    q = partition(p,r);
    QuickSort(p,q-1);
    QuickSort(q+1,r);
  }
}

int partition(int p,int r){

  int x;
  card y;
  int i,j;

  x = A[r].value;
  i = p-1;

  for(j = p;j <= r-1;j++){
    if(A[j].value <= x){
      i = i+1;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }
  y = A[i+1];
  A[i+1] = A[r];
  A[r] = y;
  return i+1;
}

int inStable()
{
  int i,j;

  for(i = 1;i <= n;i++){
  
    if(A[i].value == A[i-1].value){
      if(A[i].position < A[i-1].position) return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
#define pi 3.1415926535898
int  main()
{
	int r;
	cin >> r;
	// int x = 1;
	// int area = r*r*pi;
	// int xarea = x*x*pi;
	// cout << area / xarea << endl;
	double r1 = (double)1* 1 * pi;
	double a = (double)r * r * pi;

	printf("%d", (int)r*r);
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool check(int count, int N);
int main() {
    while (true) {
        int N;
        cin >> N;
        if (N == 0)return 0;
        int ans=0;
        for (int count = 2; count < N; count++) {
            if (check(count, N))ans++;
        }
        cout << ans << endl;
    }
}
bool check(int count,int N) {
    int med2 = N * 2 / count;
    int begin = (med2 - count+1) / 2;
    return begin > 0 && (begin+begin+count-1)*count == N * 2;
}

Measured memory_bytes: 3052