akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a[] = {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;
  cin >> k;

  cout << a[k-1] << ln;
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(n: usize, mut a: [u64; n]);
    let mut ans = 0;
    fn mv(i: usize, q: u64, ans: &mut u64, a: &mut [u64]) {
        a.iter_mut().for_each(|x| *x += q);
        a[i] -= q * (a.len() as u64 + 1);
        *ans += q;
    }
    for i in 0..n {
        let d = a[i].saturating_sub(3 * n as u64) / (n as u64 + 1) * (n as u64 + 1);
        ans += d;
        a[i] -= d;
    }
    while let Some(i) = (0..n).find(|&i| n as u64 <= a[i]) {
        mv(i, 1, &mut ans, &mut a);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <stdio.h>
int main(void){
    // Your code here!
    
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c); 
  int min=a,max=a,x,y;
  if(min>b) {
      x=min; min=b; b=x;
  }
  if(min>c){
      x=min; min=c; c=x;
  }
 if(max<b){
     y=max; max=b; b=x;
 }
 if(max<c){
     y=max; max=c; c=x;
 }
 printf("%d %d\n",min,max);
    return 0;
  }



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

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

  string s, t;
  cin >> s >> t;

  // Build index table
  vector<vector<int>> occ(256);
  for (int i = 0; i < s.size(); i++) {
    occ[s[i]].push_back(i);
  }

  ll taken = 0, cidx = 0;
  for (char c : t) {
    if (occ[c].empty()) {
      // We can't form t
      cout << -1 << "\n";
      return 0;
    }

    auto it = lower_bound(occ[c].begin(), occ[c].end(), cidx);
    if (it == occ[c].end()) {
      // We can't find it in the rest so start over
      taken += s.size() - cidx;
      it = occ[c].begin();
      cidx = 0;
    }
    taken += *it - cidx + 1;
    cidx = *it + 1;
  }
  cout << taken << "\n";
  return 0;
}

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

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

int main(){
  int a[3] = {};
  int cnt = 0;
  int i = 0;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  qsort(a,3,sizeof(int),compare);
  cnt = (a[2]-a[0])/2 + (a[2]-a[1])/2;
  a[0] += 2 * ((a[2]-a[0])/2);
  a[1] += 2 * ((a[2]-a[1])/2);
  /*for(i=0;i<3;i++){
    printf("%d/",a[i]);
  }*/
  //printf("%d/",cnt);
  if(a[0] == a[1] && a[1] == a[2]){
    printf("%d",cnt);
  }else if(a[0] != a[1]){
    printf("%d",cnt+2);
  }else if(a[0] == a[1] && a[1] != a[2]){
    printf("%d",cnt+1);
  }
  return 0;
}
           

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    X = int(input())

    dp = [0] * 100100
    dp[0] = 1
    for p in range(100, 106):
        for i in range(len(dp)):
            if dp[i] == 1 and i + p < len(dp):
                dp[i + p] = 1

    print(dp[X])


def main():
    solve()


if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  cin >> n;
  int ans(0);
  int head(0), middle(0), tail(0);

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto pos = s.find("AB");
    while (pos != string::npos) {
      ans++;
      pos = s.find("AB", pos + 2);
    }
    if (s.front() == 'B') {
      if (s.back() == 'A') {
        middle++;
      } else {
        tail++;
      }
    } else if (s.back() == 'A') {
      head++;
    }
  }

  if (middle == 0) {
    ans += min(head, tail);
  } else if (head + tail == 0) {
    ans += middle - 1;
  } else {
    ans += middle + min(head, tail);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input: string) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const args = input.split("\n");

  const a: number = parseInt(args[0], 10);
  const s: string = args[1];
  const o: string = "red";

  if (a >= 3200) {
    console.log(s);
  } else {
    console.log(o);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int n;
    cin >> n;
    vector<int> a(n);
    int amax = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        amax = max(amax, a[i]);
    }

    sort(all(a));
    vector<bool> check(amax + 1, true);
    int ans = 0;
    for(int i = 0; i < n; ++i){
        //if(check[a[i]] == false) continue;
        if(a[i-1] != a[i] && a[i] != a[i+1]){
            ans += check[a[i]];
        }

        for(int j = a[i]; j <= amax; j += a[i]){
            check[j] = false;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4052
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int d[26] = {};
signed main() {
	string s;
	cin >> s;
	int n = s.size(),ans=0,sum=0;
	rep(i, n) {
		if (s[i] == 'W') {
			ans += i - sum;
			sum++;
		}
	}
	cout << ans << endl;
}

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

const int MAX_N = 100000;

int main(){
    int n;
    int a,b;
    cin >> n >> a >> b;
    
    if(n*a<b)cout << n*a << endl;
    else cout << b << endl;
    
    
    return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
if n>=m:
  print(0)
else:
  x.sort()
  #print(x)
  d=[]
  for i in range(m-1):
    d.append(x[i+1]-x[i])
  d.sort()
  #print(d)
  print(sum(d[:m-n]))

Measured memory_bytes: 13840
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

	for(int i=1;i<s.size();i++){
		if(s[i-1]==s[i]){
			ans++;
			if(s[i]=='1')s[i]='0';
			else s[i]='1';
		}
	}

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

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	card := make([][]int, 4)
	mark := []string{"S", "H", "C", "D"}

	for i := 0; i < 4; i++ {
		card[i] = make([]int, 13)
	}

	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var mk string
		var num int
		fmt.Scan(&mk, &num)
		for j := 0; j < 4; j++ {
			if mark[j] == mk {
				card[j][num-1] = 1
			}
		}
	}
	for j := 0; j < 4; j++ {
		for i := 0; i < 13; i++ {
			if card[j][i] == 0 {
				fmt.Printf("%s %d\n", mark[j], i+1)
			}
		}
	}
	return
}




Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
using namespace std;
typedef long long ll;

void findandmark(vector<vector<int>>& arr, int num) {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(arr[i][j] == num) {
                arr[i][j] = 0;
                return;
            }
        }
    }
}

bool bingo(vector<vector<int>> arr) {
    // row wise check
    for(int i = 0; i < 3 ; i++) {
        if(arr[i][0] == 0 && arr[i][1] == 0 && arr[i][2] == 0) {
            return true;
        }
        if(arr[0][i] == 0 && arr[1][i] == 0 && arr[2][i] == 0) {
            return true;
        }
    }

    if(arr[0][0] == arr[1][1] && arr[1][1] == arr[2][2] && arr[1][1] == 0) return true;

    if(arr[0][2] == arr[1][1] && arr[1][1] == arr[2][0] && arr[1][1] == 0) return true;

    return false;
}

int main()
{
	FIO
	vector<vector<int>> arr(3, vector<int>(3,0));
	for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> arr[i][j];

    int q, temp; cin >> q;
    while(q--) {
        cin >> temp;
        findandmark(arr, temp);
    }

    cout << (bingo(arr)?"Yes":"No") << '\n';

	return 0;
}

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

using namespace std;


int main()
{
    int n;
    cin >> n;
    int ar[n];
    for(int i = 0;i<n;i++){
        cin >> ar[i];
    }
    int s = 0;
    for(int i = 0;i<n-1;i++){
        for(int j = i+1;j<n;j++){
            s+=(ar[i]*ar[j]);
        }
    }
    cout << s;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    for(int i=1;i<=n;i++)
    {
        if((int)(i*1.08)==n)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf(":(\n");
    
    
    return 0;
}



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

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

  int m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S[0] == 'M') m++;
    if (S[0] == 'A') a++;
    if (S[0] == 'R') r++;
    if (S[0] == 'C') c++;
    if (S[0] == 'H') h++;
  }

  long long D[5] = {m,a,r,c,h};
  int P[10] = {0,0,0,0,0,0,1,1,1,2};
  int Q[10] = {1,1,1,2,2,3,2,2,3,3};
  int R[10] = {2,3,4,3,4,4,3,4,4,4};
  long long ans = 0;
  for (int i = 0; i < 10; i++) ans += D[P[i]] * D[Q[i]] * D[R[i]];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    int k = min(a, c);
    ans += k;
    a -= k, c -= k;
    k = min(b, c);
    ans += 2 * k;
    b -= k, c -= k;
    ans += b;
    if (c)
        ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#include<unordered_map>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int L = 2000;
const int MAX = 2 * L + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

int A[MAX][MAX];
int dp[MAX][MAX];
int C[MAX][MAX];

void ADD(int& key, int val)
{
	key += val;
	if (key >= MOD) key -= MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n;
	FOR(i, 0, n)
	{
		int a, b;
		cin >> a >> b;
		A[L - a][L - b]++;
		A[L + a][L + b]++;
	}

	C[0][0] = 1;
	FOR(i, 0, MAX - 1)
	{
		FOR(j, 0, MAX - 1)
		{
			ADD(C[i + 1][j], C[i][j]);
			ADD(C[i][j + 1], C[i][j]);
		}
	}

	FOR(i, 0, MAX - 1)
	{
		FOR(j, 0, MAX - 1)
		{
			if (i < L && j < L && A[i][j])
			{
				ADD(dp[i][j], A[i][j]);
			}

			ADD(dp[i + 1][j], dp[i][j]);
			ADD(dp[i][j + 1], dp[i][j]);
		}
	}

	int res = 0;
	FOR(i, L, MAX)
	{
		FOR(j, L, MAX)
		{
			if (A[i][j])
			{
				ADD(res, (A[i][j] * (LL)dp[i][j]) % MOD);
				int a = i - L;
				int b = j - L;
				res -= (A[i][j] * (LL)C[2 * a][2 * b]) % MOD;
				if (res < 0) res += MOD;
			}
		}
	}

	res = (res * (LL)500000004) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 191232
N, Q = map(int, input().split())

tree = {}
for i in range(1, N + 1):
    tree[i] = []
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a] += [b]

count = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p] += x

stack = [1]
while stack:
    label = stack.pop()
    if tree[label] != []:
        for next_label in tree[label]:
            count[next_label] += count[label]
        stack += tree[label]

print(*count[1:])


Measured memory_bytes: 100976
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    int n,l;
    cin>>n>>l;
    int ans=0;
    int kai;
    for(int i=1;i<=n;i++){
        if(i+l-1==0){
          kai=0;
          break;
        }
        else if(i==n){
            kai=1;
        }
    }
    if(kai==0){
        for(int i=1;i<=n;i++){
            ans+=i+l-1;
        }
        cout<<ans<<endl;
    }
    else{
        for(int i=1;i<=n;i++){
            if(i==1&&i+l-1>=1){
                kai=0;
                continue;
            }
            if(kai==1&&i==n){
                break;
            }
            ans+=i+l-1;
        }
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;
ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
outputString = "No"
if len(S) % 2 !=0:
 outputString="No"
else:
  outputString = "Yes"
  for k,v in enumerate(S):
    if (k % 2 == 0 and v!="h") or (k % 2 == 1 and v!="i"):
       outputString = "No"
       break

print(outputString)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll n,k;cin >> n >> k;
    ll ans = 0;
    for( ll i = k ;i <= n+1;i++){
        ll left,right ;
        right = i*(2*n-i+1)/2;
        left = i*(i-1)/2;
        ans+=right-left+1;
        ans%=MOD;
    }
    cout << ans << endl;
}
// ll n;cin >> n;
// vector<int> a(n);
// rep(i,n) cin >> a[i];

// cout << (res?"Yes":"No") << endl;
// cout << ans << endl;

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int Map[3][3];

bool solve() {
    forin(j, 0, 2) {
        auto src = Map[0][j] - Map[0][j + 1];
        if (src != Map[1][j] - Map[1][j + 1] ||
            src != Map[2][j] - Map[2][j + 1]) {
            return false;
        }
    }
    forin(j, 0, 2) {
        auto src = Map[j][0] - Map[j + 1][0];
        if (src != Map[j][1] - Map[j + 1][1] ||
            src != Map[j][2] - Map[j + 1][2]) {
            return false;
        }
    }
    return true;
}

int main() {
    forin(i, 0, 3) forin(j, 0, 3) cin >> Map[i][j];
    
    cout << (solve() ? "Yes" : "No") << endl;
}



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

int main(){
    int a,b;
    cin >> a >> b;
	if(a<b){
		cout<<"a < b\n";
	}
    else if(a>b){
    	cout<<"a > b\n";
    }
    else{
    	cout<<"a == b\n";
    }
    return 0;
}


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

int main() {
  double a;
  cin >> a;
  int b;
  b = a;
  double ans = 0.0;
  if(b % 2 == 1){
  ans = 0.5 + 0.5 / a;
  cout << ans;
  }else{
  ans = 1.0 / 2.0;
  cout <<  ans;
  }
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int x;
    cin >> x;
    int ans = 0, sum = 0;
    for(int i = 1; sum < x; i++){
        sum += i;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
//vector<ll> g[1003];
ll i,j;
void solve()
{
	ll n,m,a,b;
	cin>>n>>m>>a>>b;
	ll ans[n][m];
	rep(i,0,n){
		rep(j,0,m)
		{
			if((i<b)^(j<a))
			cout<<1;
			else
			cout<<0;
		}
		cout<<'\n';
	}
	
	
}

int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
//	ff();
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n, m, d;
    cin >> n >> m >> d;
    double paired = 0;
    if(d == 0){
        paired = n / (double(n)*n);
    }else{
        paired = max<double>(0.0, n - d) * 2.0 / (double(n)*n);
    }
    cout << setprecision(13) << paired * (m - 1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,k,a,b,t[100000];
string s;
int main(void){
    cin>>n>>k>>s;
    for(int i=0;i<n-1;i++){
        if(s[i]=='A'&&s[i+1]=='C')t[i+1]=1;
        t[i+1]+=t[i];
    }
    
    for(int i=0;i<k;i++){
        cin>>a>>b;
        cout<<t[b-1]-t[a-1]<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



    int main(){
        ll N;
        cin>>N;
        vector<ll> D1(N);
        vector<ll> D2(N);

        for(ll i=0;i<N;i++){
            cin>>D1[i]>>D2[i];
        }
    ll tppp=0;
    ll now=0;
        for(ll i=0;i<N;i++){
            if(D1[i]==D2[i]){
                now++;
            }
            else{
                now=0;
            }
            if(now>=3){
                tppp=1;
            }
        }

        if(tppp==0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(n);
    vector<ll> h(n);
    loop(i, n) cin >> h[i];
    loop(i, m)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ans = 0;
    loop(i, n)
    {
        ll siz = G[i].size();
        bool check = true;
        loop(j, siz)
        {
            if (h[i] <= h[G[i][j]])
                check = false;
        }
        if (check){
            ans++;
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 9860
M = 10**9 + 7
n,a,b = map(int, input().split())

def modinv(n):
    return pow(n, M-2, M)

def comb(n, r):
    num = denom = 1
    for i in range(1,r+1):
        num = (num*(n+1-i))%M
        denom = (denom*i)%M
    return num * modinv(denom) % M

print((pow(2, n, M) - comb(n, a) - comb(n, b) - 1) % M)

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct edge{int to,cap,cost,rev;};
const int MAX_V=3010;
const int INF=1001001001;
const int D=MAX_V-3,S=MAX_V-2,T=MAX_V-1;
int N;
int base;

vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].pb((edge){to,cap,cost,(int)G[to].size()});
    G[to].pb((edge){from,0,-cost,(int)G[from].size()-1});
}

int solve(){
    int res=0;
    while(true){
        fill_n(dist,MAX_V,INF);
        dist[S]=0;
        while(true){
            bool update=false;
            rep(i,MAX_V){
                if(dist[i]==INF)continue;
                for(int j=0;j<G[i].size();j++){
                    edge &e=G[i][j];
                    if(e.cap==0||dist[e.to]<=dist[i]+e.cost)continue;
                    dist[e.to]=dist[i]+e.cost;
                    prevv[e.to]=i;
                    preve[e.to]=j;
                    update=true;
                }
            }
            if(!update)break;
        }
        if(dist[T]==INF)return res;
        res-=dist[T];
        for(int i=T;i!=S;i=prevv[i]){
            edge &e=G[prevv[i]][preve[i]];
            e.cap--;
            G[i][e.rev].cap++;
        }
    }
}

int A[1111],B[1111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i]>>B[i];
    vint hs;
    rep(i,N){
        hs.pb(A[i]);hs.pb(B[i]);
    }
    sort(all(hs));hs.erase(unique(all(hs)),hs.end());
    base=hs.back();
    rep(i,N)add_edge(S,i,1,0);
    rep(i,hs.size())add_edge(N+i,T,1,0);
    add_edge(D,T,INF,0);
    rep(i,N){
        int a=lower_bound(all(hs),A[i])-hs.begin();
        int b=lower_bound(all(hs),B[i])-hs.begin();
        add_edge(i,N+a,1,-B[i]);
        add_edge(i,N+b,1,-A[i]);
        add_edge(i,D,1,0);
    }

    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3816
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            # print(i, j, k)
            if (500 * i + 100 * j + 50 * k == x):
                cnt += 1

print(cnt)

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll N, K;

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

    ll m = N % K;

    ll ans = min(m, abs(m - K));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
string s;
ll n,m,k;
int a[100010];
vi v;
vi uni(vi v)
{
	vi ans=v;
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	return ans;
}
int quickpower(int m,int n)
{
    if(n==1) return m;
    int temp=quickpower(m,n/2);
    return (n%2==0 ? 1 : m)*temp*temp;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>k>>n>>m;
	rep3(i,n,m+1)
	{
		if(i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	if(n <= k)cout << s << endl;
	else{
		string emp = "";
		for(int i = 0;i < k;i++)emp += s[i];
		emp += "...";
		cout << emp << endl;
	}
}


Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx < vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() <= xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] > xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; 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;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}





signed main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}


Measured memory_bytes: 3624
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int s[200100];
int a[200100];
int main()
{
	int n,k;
	cin>>n>>k;
	rep(i,n) cin>>a[i];
	rep(i,min(k,100)){
		memset(s,0,sizeof(s));
		rep(j,n){
			s[max(0,j-a[j])]++;
			s[min(n,j+a[j]+1)]--;
			//cout<<' '<<max(0,j-a[j])<<' '<<min(n,j+a[j]+1)<<endl;
		}
		a[0]=s[0];
		rep(j,n) a[j+1]=a[j]+s[j+1];
	}
	rep(i,n){
		cout<<a[i];
		if(i<n-1) cout<<' ';else cout<<endl;
	}
}


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

int main(){
    ll N; cin >> N;
    ll ans = 0;
    vector<int> P(N+1), rP(N+1);
    set<ll> st;
    rep(i, 1, N+1) cin >> P[i];
    rep(i, 1, N+1) rP[P[i]] = i;
    rep(i, 0, N + 2) st.insert(i);
    //vector<ll> R1(N+1,0), R2(N), L1(N,0), L2(N,0);

    rep(i, 1, N){
        st.erase(rP[i]);
        auto r1 = st.upper_bound(rP[i]);
        auto l1 = r1; l1--;
        cerr << *l1 << " " << *r1 << endl;
        if(*r1 != N + 1){
            auto r2 = r1;
            r2++;
            ans += i * (rP[i] - *l1) * (*r2 - *r1);
        }
        if(*l1 != 0){
            auto l2 = l1; l2--;
            ans += i * ((*l1 - *l2) * (*r1 - rP[i]));
        }
        cerr << ans << endl;
        
        //ans += i * ((rP[i] - *l1)*(*r2 - *r1) + (*l2 - *l1) * (*r1 - rP[i]));
        
        //st.erase(rP[i]);
    }
    
    cout << ans << endl;
    // vector<pair<int,int> > p(N);
    
    //sort(P.begin(), P.end());

    //for(auto )
    

    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        final String[] str = scan.nextLine().split(" ");

        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scan.close();
    }

}

Measured memory_bytes: 25896
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const string ROMA_STR("MDCLXVI");
const VI ROMA_NUM({1000, 500, 100, 50, 10, 5, 1});

int main(void) {
	string str;

	while (cin >> str) {
		VI nums;
		for (char c : str) {
			nums.push_back(ROMA_NUM[ROMA_STR.find(c)]);
		}

		int total = 0;
		for (int i = 0; i < (int)nums.size(); i++) {
			if (i == (int)nums.size() - 1) {
				total += nums[i];
			} else if (nums[i] >= nums[i + 1]) {
				total += nums[i];
			} else {
				total -= nums[i];
			}
		}

		cout << total << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
from collections import Counter
s=input()
c=Counter(s).most_common()
ans=10**10
top=c[0][1]
for k,x in c:
    N=len(s)
    m=k
    cnt=0
    tmp=s
    for i in range(100):
        cn=Counter(tmp).most_common()
        if(cn[0][1]==len(tmp)):
            ans=min(ans,cnt)
            break
        l=''
        for j in range(N-1):
            if(tmp[j]==m or tmp[j+1]==m):
                l+=m
            else:
                l+=s[j]
        tmp=l
        cnt+=1
        N-=1
print(ans)

Measured memory_bytes: 3316
inp=""

while True:
    try:
        in1 = input()
        inp =inp + in1
    except EOFError:
        break

s = "abcdefghijklmnopqrstuvwxyz"
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
count=[0]*26

for i in inp:
    if i in s:
        count[s.index(i)]+=1
    if i in l:
        count[l.index(i)]+=1

for i in range(len(count)):
    print(s[i]+" : "+str(count[i]))



Measured memory_bytes: 5564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;

    public int cal(int n, int m) {
        while (n > 0) {
            int nn = n % 2;
            int mm = m % 2;
            if (mm > nn) {
                return 0;
            }
            n /= 2;
            m /= 2;
        }
        return 1;
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        if (n >= 2 || m >= 2) {
            out.println(n * (n - 1) / 2 + m * (m - 1) / 2);
        } else {
            out.println(0);
        }
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

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

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 23380
N = int(input())
S = input()

e_cnt, w_cnt = 0, 0
e_arr, w_arr = [0]*(N+1), [0]*(N+1)
for i,s in enumerate(S):
    if s=='E':
        e_cnt += 1
    else:
        w_cnt += 1
    e_arr[i+1] = e_cnt
    w_arr[i+1] = w_cnt

max_ew = -1e6
for i in range(N):
    max_ew =  max(e_arr[i] - w_arr[i+1], max_ew)
print(N - 1 - (max_ew+w_cnt))

Measured memory_bytes: 46944
k,x = map(int,input().split())
start = -1000000
end = 1000000

if x -(k-1) >= start:
    start =  x -(k-1)
if x + (k-1) <= end:
    end = x + (k-1)
a = [n for n in range(start,end+1)]
print(' '.join(map(str,a)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int A[100010];

void _main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    int ans = 0;
    FOR (i, 1, N) ans += (A[i] > A[i - 1]);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3964
#include<cstdio>
#include<utility>

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

using namespace std;

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

int main(){
	char B[8][9];
	rep(i,8) scanf("%s",B[i]);

	rep(t,64){
		char c1=(t%2?'x':'o'),c2=(t%2?'o':'x'); // ©ªÌNbL[, èÌNbL[

		int i_opt=0,j_opt=0,tot_opt=0;
		rep(i,8) rep(j,8) if(B[i][j]=='.') {
			int tot=0; // ÆêéèÌNbL[ÌÂ
			rep(k,8){ // (i,j) Éu¢½Æ«ÉèÌNbL[ðÍ³ßé©
				int l,y,x;
				for(l=1;;l++){
					y=i+l*dy[k];
					x=j+l*dx[k];
					if(0<=y && y<8 && 0<=x && x<8 && B[y][x]==c2);
					else break;
				}
				y=i+l*dy[k];
				x=j+l*dx[k];
				if(0<=y && y<8 && 0<=x && x<8 && B[y][x]==c1) tot+=l-1;
			}
			if(tot_opt<tot
			|| tot_opt==tot && (t%2?make_pair(i_opt,j_opt)<make_pair(i,j)
								   :make_pair(i_opt,j_opt)>make_pair(i,j))){
				i_opt=i;
				j_opt=j;
				tot_opt=tot;
			}
		}

		if(tot_opt==0) continue;

		// NbL[ðu­
		B[i_opt][j_opt]=c1;
		rep(k,8){ // ½]
			int l,y,x;
			for(l=1;;l++){
				y=i_opt+l*dy[k];
				x=j_opt+l*dx[k];
				if(0<=y && y<8 && 0<=x && x<8 && B[y][x]==c2);
				else break;
			}
			y=i_opt+l*dy[k];
			x=j_opt+l*dx[k];
			if(0<=y && y<8 && 0<=x && x<8 && B[y][x]==c1){
				for(l--;l>0;l--){
					int y=i_opt+l*dy[k],x=j_opt+l*dx[k];
					if(0<=y && y<8 && 0<=x && x<8 && B[y][x]==c2) B[y][x]=c1;
					else break;
				}
			}
		}
	}

	rep(i,8) puts(B[i]);

	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int  x,y,z;cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
int n,h,w,u,v,ans[100],sum=0;
map<ii,int > cnt;
set<ii> adj;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>h>>w>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>u>>v;
		adj.insert(ii(u,v));
		adj.insert(ii(u+1,v+1));
		adj.insert(ii(u-1,v-1));
		adj.insert(ii(u+1,v));
		adj.insert(ii(u-1,v));
		adj.insert(ii(u-1,v+1));
		adj.insert(ii(u,v+1));
		adj.insert(ii(u,v-1));
		adj.insert(ii(u+1,v-1));
		cnt[ii(u,v)]=1;
	}
	for(set<ii>::iterator it=adj.begin();it!=adj.end();it++)
	{
		int u=it->first,v=it->second;
		if(u>h||u==0||v>w||v==0||v-1==0||v+1>w||u-1==0||u+1>h) continue;
		else
		{
			int dem=0;
			if(cnt[ii(u,v)]==1) dem++;
			if(cnt[ii(u+1,v+1)]==1) dem++;
			if(cnt[ii(u-1,v-1)]==1) dem++;
			if(cnt[ii(u+1,v)]==1) dem++;
			if(cnt[ii(u-1,v)]==1) dem++;
			if(cnt[ii(u-1,v+1)]==1) dem++;
			if(cnt[ii(u,v+1)]==1) dem++;
			if(cnt[ii(u,v-1)]==1) dem++;
			if(cnt[ii(u+1,v-1)]==1) dem++;
			ans[dem]++;
		}
	}
	for(int i=1;i<=9;i++) sum+=ans[i];
	cout<<(h-2)*(w-2)-sum<<"\n";
	for(int i=1;i<=9;i++) cout<<ans[i]<<"\n";
}

Measured memory_bytes: 213376