akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

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

struct Tetro {
  int h, w;
  vector<vector<char>> b;
  Tetro(int h, int w, vector<vector<char>> &b) : h(h), w(w), b(b) {}
};

bool is_empty(char ch) { return ch == '.'; }
bool is_filled(char ch) { return ch == '#'; }

bool check(int i, int skip, vector<vector<char>> &b, vector<Tetro> &tetros) {
  if (i == tetros.size()) return true;
  if (i == skip) return check(i + 1, skip, b, tetros);
  int h = b.size(), w = b[0].size();
  auto t = tetros[i];
  rep(y, h) {
    rep(x, w) {
      if (y + t.h <= h and x + t.w <= w) {
        bool can_put = true;
        rep(dy, t.h) {
          rep(dx, t.w) {
            if (is_filled(t.b[dy][dx]) and is_filled(b[y + dy][x + dx])) {
              can_put = false;
            }
          }
        }
        if (can_put) {
          rep(dy, t.h) rep(dx, t.w) {
            if (is_filled(t.b[dy][dx])) b[y + dy][x + dx] = '#';
          }
          auto res = check(i + 1, skip, b, tetros);
          rep(dy, t.h) rep(dx, t.w) {
            if (is_filled(t.b[dy][dx])) b[y + dy][x + dx] = '.';
          }
          if (res) return true;
        }
      }
    }
  }
  return false;
}

bool solve(vector<vector<char>> &b, vector<Tetro> &tetros) {
  rep(i, 4) {
    auto res = check(0, i, b, tetros);
    if (res) return true;
  }
  return false;
}

int main() {

  vector<Tetro> tetros;
  rep(i, 4) {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> b(h, vector<char>(w));
    rep(y, h) rep(x, w) cin >> b[y][x];
    tetros.emplace_back(h, w, b);
  }
  const int H = 4, W = 10;
  int n;
  cin >> n;
  while (n--) {
    vector<vector<char>> B(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> B[i][j];
    auto res = solve(B, tetros);
    cout << (res ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    height_list = list(map(int,input().split()))

    L = {} # i + Ai
    R = {} # j - Ai
    for i,Ai in enumerate(height_list) :
        l = i + Ai
        if (l not in L.keys()) :
            L[l] = 0
        L[l] += 1

        r = i - Ai
        if (r not in R.keys()) :
            R[r] = 0
        R[r] += 1

    count = 0
    for l_key in L.keys() :
        if (l_key in R.keys()) :
            count += L[l_key] * R[l_key]
    
    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 56516
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

        int N = sc.nextInt();

        Map<String, Integer> m = new TreeMap<String, Integer>();

        int max = 0;
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            if (m.containsKey(S)) {
                m.put(S, m.get(S) + 1);
            } else {
                m.put(S, 1);
            }
            if (max < m.get(S)) {
                max = m.get(S);
            }
        }

        for (Entry<String, Integer> s : m.entrySet()) {
            if (s.getValue() == max) {
                System.out.println(s.getKey());
            }
        }

    }

}


Measured memory_bytes: 80188
n = gets.to_i
ary = gets.split.map(&:to_i)

cnt1 = 0
cnt2 = 0
cnt4 = 0

ary.each do |a|
  if a % 4 == 0
    cnt4 += 1
  elsif a % 2 == 0
    cnt2 += 1
  else
    cnt1 += 1
  end
end

puts cnt2 % 2 + cnt1 <= cnt4 + 1 ? :Yes: :No

Measured memory_bytes: 8580
#include <stdio.h>

int main(void)
{
    int i, N, a, b, c, A, B, C;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
	scanf("%d %d %d\n", &a, &b, &c);
	A = a * a;
	B = b * b;
	C = c * c;
	if (C == A + B) {
	    printf("YES\n");
	} else if (A == B + C) {
	    printf("YES\n");
	} else if (B == C + A) {
	    printf("YES\n");
	} else {
	    printf("NO\n");
	}
    }
    return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 100000000;
using namespace std;

map<int, int> m;

//x^n mod M
typedef unsigned long long ull;
ull power(ull x, ull n, ull M){
    ull res = 1;
    if(n > 0){
        res = power(x, n / 2, M);
        if(n % 2 == 0) res = (res * res) % M;
        else res = (((res * res) % M) * x ) %M;
    }
    return res;
}

bool check(int n){
    if(n % 2){
        if(m[0] != 1) return 0;
        for(int i = 2; i <= n; i+=2){
            if(m[i] != 2) return 0;
        }
    }else{
        for(int i = 1; i <= n; i+=2){
            if(m[i] != 2) return 0;
        }
    }
    return 1;
}

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

    rep(i,n){
        int inp;
        cin >> inp;
        m[inp]++;
    }

    if(not check(n)){
        cout << 0 << endl;
        return 0;
    }

    cout << power(2, n / 2, 1000000007) << endl;
}


Measured memory_bytes: 3200
import math
n=int(input())
hyou=[list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
  syoki=hyou[i][0]+hyou[i][1]
  for j in range(i+1,n-1):
    temp=hyou[j][1]
    if temp<syoki:
      syoki=temp+math.ceil((syoki-temp)/hyou[j][2])*hyou[j][2]+hyou[j][0]
    else:
      syoki=temp+hyou[j][0]
  print(syoki)
print(0)

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

main()
{
  int n,h;
  int ans=0;
  int a_max=0;
  int a,b;

  priority_queue<int>que;
  que.push(0);

  cin >> n >> h;

  for(int i=0;i<n;i++){
    cin >> a >> b;
    a_max=max(a,a_max);
    que.push(b);
  }

  b=que.top();
  que.pop();
  
  while(b>a_max&&(!que.empty())&&h>0){
    ans++;
    h-=b;
    b=que.top();
    que.pop();
  }

  if(h>0){
    int d=h/a_max;
    if(d*a_max<h)
      ans++;
    ans+=d;
  }

  cout << ans << endl;

  return (0);
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

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

    if (r > l + 2018) {
      System.out.println(0);
      System.exit(0);
    }

    long res = 2019;

    for (long i = l; i <= r; ++i) {
      for (long j = l; j <= r; ++j) {
        if (i == j)
          continue;
        res = ((i * j) % 2019 < res) ? (i * j) % 2019 : res;
      }
    }

    System.out.println(res);
  }
}

Measured memory_bytes: 23636
import numpy as np


def main():
    N, M = map(int, input().split())
    KA = [list(map(int, input().split())) for _ in range(N)]

    flag = np.array([1]*M)

    for l in KA:
        tmp = np.array([0]*M)
        for i in range(1, l[0]+1):
            tmp[l[i]-1] = 1
        flag *= tmp

    print(sum(flag))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12388
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

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

    llint total = k;
    rep(i, n - 1) total *= (k - 1);
    cout << total << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define Next(i, u) for(int i = h[u]; i; i = e[i].next)
struct edge{
    int v, next;
}e[N << 1];
struct node{
    int p, w;
    bool operator < (const node &x) const{
        return w > x.w;
    }
};
bool flag;
int n, m, u, v, tot, h[N], val[N];
priority_queue <node> q;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
void add(int u, int v){
    e[++tot].v = v, e[tot].next = h[u], h[u] = tot;
}
int main(){
    n = read();
    memset(val, -1, sizeof(val));
    rep(i, 1, n - 1) u = read(), v = read(), add(u, v), add(v, u);
    m = read();
    rep(i, 1, m) u = read(), v = read(), val[u] = v, q.push(node{u, v});
    while(!q.empty()){
        int u = q.top().p, w = q.top().w; q.pop();
        Next(i, u){
            int v = e[i].v; 
            if(val[v] != -1){
                if(abs(val[v] - val[u]) != 1) flag = true;
            }
            else val[v] = val[u] + 1, q.push(node{v, val[v]});
        }
    }
    if(flag) puts("No");
    else{
        puts("Yes");
        rep(i, 1, n) printf("%d\n", val[i]);
    }
    return 0;
}

Measured memory_bytes: 6492
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int pa, pb;
	int ans = 0;
	for(int i=0;i<1000;i++){
		bool flaga = false, flagb = false;
		int a = i/100, b = (i%100)/10, c = i%10;
		for(int j=0;j<n-2;j++){
			char p = s.at(j);
			int x = p - '0';
			if(x == a){
				flaga = true;
				pa = j;
				break;
			}
		}
		if(flaga){
			for(int k=pa+1;k<n-1;k++){
				char q = s.at(k);
				int y = q - '0';
				if(y == b){
					flagb = true;
					pb = k;
					break;
				}
			}
		}
		if(flagb){
			for(int l=pb+1;l<n;l++){
				char r = s.at(l);
				int z = r - '0';
				if(z == c){
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            List<string> input = new List<string>();
            List<double> iList=new List<double>();
            int count=0;
            input.AddRange(Console.ReadLine().Split(' '));
            double answer =0;

            foreach(var s in input)
            {
                iList.Add(double.Parse(s));
            }
            iList.Sort();
            count=iList.Count;
            
            while(iList.Count!=1)
            {
                answer = (iList[0]+iList[1])/2;
                iList.RemoveAt(0);
                iList.RemoveAt(0);
                iList.Insert(0,answer);
            }

                Console.WriteLine(iList[0]);
        }
}


Measured memory_bytes: 13268
#include<iostream>

using namespace std;

int main(){

  int n;
  int tekityu;
  int total[100]={0};
  int count=0;  

  while(cin>>n,n){
    
    for(int i=0;i<n/4;i++){
      cin>>tekityu;
      total[count]+=tekityu;
    }
    
    count++;

  }
  
  for(int i=0;i<count;i++)
    cout<<total[i]<<endl;

  return 0;

}

Measured memory_bytes: 2992
#include<stdio.h>
int main(){
	int i,n,sum=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		sum=sum+(double)(sum*5)/100;
		if(sum%1000!=0){
			sum+=1000;
		}
		sum=sum/1000*1000;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
 
using namespace std;
 
main(){
auto& ssin = cin;
unordered_map<string,string> mmm;
 
mmm["Sunny"]="Cloudy";
mmm["Cloudy"]="Rainy";
mmm["Rainy"]="Sunny";
 
string s;
ssin>>s;
cout << mmm[s] << endl;
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
#define _USE_MATH_DEFINES
using namespace std;
using namespace std::chrono;

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  int n;
  string s;
  cin >> n >> s;


  Vi r, g, b;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R')
      r.pb(i);
    else if (s[i] == 'G')
      g.pb(i);
    else if (s[i] == 'B')
      b.pb(i);

  int ans = 0;

  vector<Vi> vs;
  vs.pb(r), vs.pb(g), vs.pb(b);
  string ref = "RGB";
  
  for (int i = 0; i < vs.size(); i++)
    for (int j = 0; j < vs.size(); j++)
      if (i != j){
	int other = 3 - i - j;
	for (int ii = 0; ii < vs[i].size(); ii++)
	  for (int jj = 0; jj < vs[j].size(); jj++){
	    int min_ = min(vs[i][ii], vs[j][jj]);
	    int max_ = max(vs[i][ii], vs[j][jj]);
	    ans += vs[other].size() - (2 * max_ - min_ < s.size() and s[2 * max_ - min_] == ref[other]) - (2 * min_ - max_ >= 0 and s[2 * min_ - max_] == ref[other]) - (not ((min_ + max_) & 1) and  s[(min_ + max_) / 2] == ref[other]);
	  }
      }


  cout << ans / 6 << endl;
  
}


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
   int x;
       cin>>x;
    
       int q=x/100;
       int r=x%100;
    
       cout<<(r<=q*5)<<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int dp[][] = new int[n][3];
        for(int i = 0 ; i < n ; i++){
            int first = s.nextInt();
            int second = s.nextInt();
            int third = s.nextInt();
            if(i == 0){
                dp[i][0] = first;
                dp[i][1] = second;
                dp[i][2] = third;
                continue;
            }
            dp[i][0] = first + Math.max(dp[i-1][1] , dp[i-1][2]);
            dp[i][1] = second + Math.max(dp[i-1][2] , dp[i-1][0]);
            dp[i][2] = third + Math.max(dp[i-1][1] , dp[i-1][0]);
        }
        System.out.println( Math.max(dp[n-1][0] , Math.max(dp[n-1][1] , dp[n-1][2])) );
    }
}

Measured memory_bytes: 63660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
const ll MOD = 1e9 + 7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll num){
    if(num<=1) return;
    ll l=sqrt(num);
    for (ll i=2; i<=(l); i++){
        if(num%i==0){
            prime_factorize(i);
            prime_factorize(num/i);
            return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[num]++;
    return;
}

int main() {
    ll n, num;
    cin >> n;
    ll ans = 1;
    for (ll i=2; i<(n+1); i++){
        num = i;
        prime_factorize(num);
    }
    for (auto x: prime){
        ans *= x.second + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    P(2 * a);
  } else {
    int tmp = max(a, b);
    P(2 * tmp - 1);
  }



  return 0;

}

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

int main() {
    int n1,n2,n3,n4;
    cin >> n1 >> n2 >> n3 >>n4;
    vector<int>a(4);
    a = {n1,n2,n3,n4};
    sort(a.begin(), a.end());
    if(a.at(0)==1 && a.at(1)==4 && a.at(2)==7 && a.at(3)==9)cout << "YES" <<endl; 
    else cout << "NO" <<endl;
}

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

#define ll long long int
#define vi vector<int>

int main() {

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (A > 0 && C > 0) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> LLLL;

const LL MOD = 1000000007;
static const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, a, b;
		cin >> n;
		if (n < 0) return 0;
		map<LLLL, LL> m;
		map<LLLL, LL> zm;
		LL zc = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			LL g = gcd(a, b);
			if (a == 0 && b == 0) {
				++zc;
				continue;
			} else if (a == 0) {
				b = -1;
			} else if (b == 0) {
				a = 1;
			} else {
				a /= g, b /= g;
			}
			if (a < 0) {
				a = -a;
				b = -b;
			}
			m[LLLL(a, b)] += 1;
		}
		set<LLLL> s;
		modll ans = 1;
		for (auto kv : m) {
			if (s.find(kv.first) != s.end()) continue;
			s.insert(kv.first);
			LLLL dis(kv.first.second, -kv.first.first);
			auto it = m.find(dis);
			LL dc = 0;
			if (it != m.end()) {
				dc += it->second;
				s.insert(dis);
			}
			dis = LLLL(-kv.first.second, kv.first.first);
			it = m.find(dis);
			if (it != m.end()) {
				dc += it->second;
				s.insert(dis);
			}
			if (dc > 0) {
				modll x = modll::modpow(2, kv.second);
				modll y = modll::modpow(2, dc);
				x -= 1;
				y -= 1;
				x += y;
				x += 1;
				ans *= x;
			} else {
//				cout << kv.first.first << " " << kv.first.second << endl;
				ans *= modll::modpow(2, kv.second);
			}
		}
		ans -= 1;
		ans += zc;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 28512
#include <iostream>
#include <vector>
#include <set>
#include <map>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;


int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  auto table = make_2d_vector(N, N, '.');
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      cin >> table[i][j];
    }
  }

  bool all_white = true;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if( table[i][j] == '#' ) {
        all_white = false;
      }
    }
  }
  if(all_white) {
    cout << "-1\n";
    return 0;
  }


  int all_b_cols = 0;
  for(int j = 0; j < N; j++) {
    bool allb = true;
    for(int i = 0; i < N; i++) {
      if(table[i][j] == '.') {
        allb = false;
      }
    }
    if(allb) { all_b_cols++; }
  }

  set<int> paintable_rows;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(table[i][j] == '#')   paintable_rows.insert(j);
    }
  }





  int min_paint = inf;
  for(int i = 0; i < N; i++) {

    int paint_c = 0;
    int make_b_row = 0;
    if( paintable_rows.count(i) == 0 ) {
      make_b_row = 1;
    }
    for(int j = 0; j < N; j++) {
      if(table[i][j] == '.' ) {
        paint_c++;
      }
    }
    min_paint = min(min_paint, paint_c + N - all_b_cols + make_b_row );

  }

  if(min_paint == inf) {
    cout << "-1\n";
  } else {
    cout << min_paint << "\n";
  }

  return 0;
}


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

int main(){
  int N; cin >> N;
  int zcount=0;
  for(int i=0; i<N; i++){
    int d1,d2; cin >> d1 >> d2;
    if(d1==d2) zcount++;
    else zcount=0;
    if(zcount==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3620
import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = tuple(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)

ans = [-1] * (N + 1)
inf = 10**18
LIS = [inf] * (N + 10)


def DFS(s, parent=0):
    a = A[s - 1]
    i = bisect.bisect_left(LIS, a)
    v = LIS[i]
    LIS[i] = a
    ans[s] = bisect.bisect_left(LIS, inf)
    for t in edge[s]:
        if t == parent:
            continue
        DFS(t, s)
    # 頂点sでの結果をもとに戻す
    LIS[i] = v
    return


DFS(1)
print(*ans[1:], sep="\n")

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

int kai(char S[], int length){

    int judge = 1;
    int i;
    for(i = 0; i<=(length-3)/2; i++){
        if(S[i]!=S[length-1-i]){
            judge = 0;
        }
    }
    return judge;
}


int main(){

    char S1[99], S2[49], S3[49];
    scanf("%s",S1);
    int length = strlen(S1);

    int i, j;
    for(i = 0; i <= (length-1)/2-1; i++){
        S2[i] = S1[i];
    }
    S2[i] = '\0';
    int k = (length+3)/2-1;
    for(j = 0; j <= length-(length+3)/2; j++){
        S3[j] = S1[k];
        k++;
    }
    S3[j] = '\0';

    if((kai(S1,length)==1)&&(kai(S2,strlen(S2))==1)&&(kai(S3,strlen(S3))==1)){
        printf("Yes");
    }else{
        printf("No");
    }

   return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    double s = w*h/2.0;
    cout << s << " ";
    if(x == w/2 && y == h/2) cout << 1 << endl;
    else cout << 0 << endl;

}

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

Measured memory_bytes: 256
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    int N ; cin >> N ;
    int arr[N+1] ;
    for( int i = 1 ; i <= N ; i++ )
        cin >> arr[i] ;
    int cnt = 0 ;
    for( int i = 1 ; i <= N ; i++ ){
        if( arr[i] != -1 ){
            if( i == arr[arr[i]] ){
                cnt++ ;
                arr[arr[i]] = -1 ;
            }
        }
    }
    cout << cnt << endl ;
    return 0 ;
}


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


int main() {
  string S;
  cin >> S;
  if (S.at(0)==S.at(1) && S.at(1)==S.at(2)) {
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

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

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int a[1010];

signed main()
{
	ios::sync_with_stdio(false);
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<=k;i++) sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3652
"""
atcoder workspace
"""
from bisect import bisect_left, bisect_right

N = int(input())

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

A.sort()
C.sort()

ans = int()
for i in B:
    x = bisect_left(A, i)
    y = bisect_right(C, i)
    ans += x * (N-y)

"""
 A = [1,2,2,3,4]
 B = [1,1,2,4,5]
 C = [1,1,2,2,3]
 A < B < C
 when i+2(B = 2),
 x = 1, y = 3
 N_A = 1 (A=1), N_C = 1 (C=3)
"""

print(ans)

Measured memory_bytes: 23360
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;

    int main(){
      long n;
      cin>>n;
      VEC(long,a,n);
      sort(a.begin(),a.end(),greater<long>());
      long res1 = 0;
      long res2 = 0;
      long now;
      if(a[0] == a[1] && a[0] == a[2] && a[0] == a[3]){
        long long ans = a[0]*a[0];
        cout <<ans<<endl;
        return 0;
      }
      rep(i,n){
        if(now == a[i])continue;
        if(a[i] == a[i+1] && !res1){
          res1 = a[i];
          now = a[i];
          continue;
        }
        else if(a[i] == a[i+1])res2 = a[i];
        if(res1 && res2)break;
        if(a[i] != a[i+1])continue;
        now = a[i];
      }
      long long ans = res1*res2;
      cout <<ans<<endl;
      
    }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    string a,b;
    cin>>a>>b;
    ll c=0;
    for(ll i=0;i<a.length();i++)
    {
        if(a[i]==b[i])
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
// One Card Poker

#include <iostream>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;

	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;

	if (A < B)
		cout << "Bob" << endl;
	else if (A == B)
		cout << "Draw" << endl;
	else
		cout << "Alice" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int dp[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    dp[1] = abs(a[1]-a[0]);
    for(int i=2; i<n; i++)
    {
        dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout << dp[n-1];
}
//TODO: 56
//come back to 50D, 55D


Measured memory_bytes: 1024
io = STDIN
 n,k=io.gets.split.map(&:to_i)
 s=io.gets.chomp

units= s.each_char.chunk_while{|x,y|x==y}.map{|ar|[ar[0],ar.size]}
#start:0
#0101010
#**
# ***
#   ***
#start:1
#1010101
#***
#  ***
#    ***
#end:0
#101010
#***
#  ***
#    **
units.unshift(["1",0]) if units[0][0]=="0"
units.push(["1",0]) if units[-1][0]=="0"
units.map!{|x,y|y}
#(units.size-1)/2 :0の数
#((units.size-1)/2-k+1) :try数
ans=unit_sum=units[0..(2*k)].inject(:+)
((units.size-1)/2-k).times do |i|
  unit_sum=unit_sum-units[2*i]-units[2*i+1]+units[2*i+2*k+1]+units[2*i+2*k+2]
  ans=[unit_sum,ans].max
end
puts ans


Measured memory_bytes: 15484
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
ab = [tuple(int(j) for j in S().split()) for i in range(N)]
cd = [tuple(int(j) for j in S().split()) for i in range(N)]

from operator import itemgetter

ab = sorted(ab,key=itemgetter(1))
cd = sorted(cd,key=itemgetter(0))

ans = 0
for c,d in cd:
    A = []
    for i in range(N):
        if ab[i][0] < c and ab[i][1] < d:
            A.append(ab[i])
    if len(A) == 0:
        continue
    else:
        ans += 1
        for i in range(N):
            if ab[i] == A[-1]:
                ab[i] = (200,200)
                break

print(ans)

Measured memory_bytes: 39664
package main
import (
  "fmt"
)
func main() {
  var n, k int
  fmt.Scan(&n, &k)
  hs := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&hs[i])
  }
  result := 0;
  for _, h := range hs {
    if k <= h {
      result++
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,l,b,dp[2][10005];
string s;
int main()
{
	cin>>n>>s;
	l=s.size();b=0;
	dp[b^1][0]=1;
	for(int i=1;i<=n;i++,b^=1)for(int j=0;j<=l+n;j++)if(!j)dp[b][j]=(dp[b^1][j]+dp[b^1][j+1]*2)%md;else dp[b][j]=(dp[b^1][j-1]+dp[b^1][j+1]*2)%md;
	printf("%lld\n",dp[b^1][l]);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for(int i = 0; i < n; i++){
        if(ans > k) ans += k;
        else ans += ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
      int K = sc.nextInt();
      int X = sc.nextInt();
      int Y = sc.nextInt();
      
      if(K < N){
      System.out.println((K * X) + (N - K) * Y);
      }else{
      System.out.println(N * X);
      }
   }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
using namespace std;
int main(){
int N,K;
int count=0;
cin>>N>>K;
int min=K-1;
int ans=K;
ans=K;
int A[N];
for (int i = 0; i < N; i++) {
  cin>>A[i];
}

for (int i = 0;; i++) {
  ans=K+(K-1)*i;
  count++;
  if(ans>=N){
    cout<<count<<endl;
    break;
  }


}
return 0;









}


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

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

	int ans = 0;
	int min = 1e9;
	for (int i = 0; i < n; i++) {
		if (p[i] < min) {
			ans++;
			min = p[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=list(map(int,input().split()))
bb=[0]*len(aa)
for i in range(n):
    j = n-i-1
    s = sum(bb[j::j+1])
    if s % 2 != aa[j]:
       bb[j] = 1
print(sum(bb))
print(' '.join(str(i+1) for i in range(len(bb)) if bb[i]))

Measured memory_bytes: 14776
import networkx as nx
from networkx.algorithms.flow import dinitz

N = int(input())
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]
G = nx.DiGraph()
for rx, ry in reds:
    for bx, by in blues:
        if rx < bx and ry < by:
            G.add_edge("S", (rx, ry), capacity=1)
            G.add_edge((rx, ry), (bx, by), capacity=1)
            G.add_edge((bx, by), "T", capacity=1)
if G.nodes:
    R = dinitz(G, "S", "T")
    print(R.graph["flow_value"])
else:
    print(0)



Measured memory_bytes: 56416
#include <stdio.h>
#include <math.h>
int trianglechecker(int x, int y, int z);
int main(void){
    int loop, len1, len2, len3;
    int f = 0;
    scanf("%d", &loop);
    for(int i = 0; i < loop; i++)
    {
        scanf("%d%d%d", &len1, &len2, &len3);
        f = trianglechecker(len1, len2, len3);
        if(f == 1)
        {
            printf("YES\n");
        }
        if(f == 0)
        {
            printf("NO\n");
        }
    }
    return 0;
}
int trianglechecker(int x, int y, int z)
{
    if(x * x == y * y + z * z){
        return 1;
    }
    if(y * y == x * x + z * z){
        return 1;
    }
    if(z * z == y * y + x * x){
        return 1;
    }
    return 0;
}

Measured memory_bytes: 1008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		List<Integer> X = new ArrayList<Integer>();
		List<Integer> Y = new ArrayList<Integer>();
		for(int i = 0; i*K <= B; i++) {
			if(i*K >= A) {
			X.add(i*K);
			}else {
			Y.add(i*K);
			}
		}
		if(X.size()==0) {
			System.out.println("NG");
		}else {
			System.out.println("OK");
		}
	}
}


Measured memory_bytes: 35748
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int x = abs(x1 - x2);
    int y = abs(y1 - y2);
    int x3 = y1 >= y2 ? x2 + y : x2 - y;
    int y3 = x1 >= x2 ? y2 - x : y2 + x;
    int x4 = y1 >= y2 ? x1 + y : x1 - y;
    int y4 = x1 >= x2 ? y1 - x : y1 + x;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

#define MAX_N 6
#define MAX_X 100000
#define INF 10000000000

int N = 6;
// int X = 615;
int X;
int dp[MAX_N + 1][MAX_X + 1];
// int w[] = {101, 102, 103, 104, 105, 106};
int w[] = {100, 101, 102, 103, 104, 105};

int main() {
    cin >> X;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= X; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                if (dp[i][j] == X || dp[i + 1][j - w[i]] + w[i] == X) {
                    printf("1\n");
                    return 0;
                }

                int t = max(dp[i][j], dp[i + 1][j - w[i]] + w[i]);
                if (t <= X) {
                    dp[i + 1][j] = t;
                }
            }

            // 答えが見つかった
            if (dp[i + 1][j] == X) {
                printf("1\n");
                return 0;
            }
         }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 640
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse= True)
suma = sum(a)
a = [i / suma for i in a]
flag = True
for i in range(m):
    if a[i] < 1/(4*m):
        flag = False
        break

print('Yes') if flag else print('No')

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    long long isi=0,count=0;
    for(int i=0;i<S.size();i++){
       if(S.at(i)=='B'){
           isi++;
       }
       else{
           count+=isi;
       }
    }
    cout << count <<endl;
}

Measured memory_bytes: 3688
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
void Dice(char p, int d[]);

int main() {
	int d[6], i, n,top,front;
	char dir[101], *p;
	for (i = 0; i < 6; i++)  scanf("%d", &d[i]);
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d%d", &top, &front);
		if (d[0] == top);
		else if (d[5] == top) Dice('N', d), Dice('N', d);
		else if (d[1] == top) Dice('N', d);
		else if (d[4] == top) Dice('S', d);
		else if (d[2] == top) Dice('W', d);
		else if (d[3] == top) Dice('E', d);
		
		if (d[1] == front) printf("%d\n",d[2]);
		else if(d[2] == front) printf("%d\n",d[4]);
		else if (d[3] == front) printf("%d\n",d[1]);
		else if (d[4] == front) printf("%d\n",d[3]);
	}
	return 0;
}

void Dice(char p, int d[]) {
	int tmp;
		if (p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
		if (p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
		if (p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
		if (p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
}

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    string s;
    cin >> s;

    vector<int> ans(s.size());
    int o = 0;
    int e = 0;
    int turn = 0;
    rep(i, s.size()) {
        if (s[i] == 'R')
            if (i % 2 == 0) e++;
            else o++;
        else {
            if (s[i - 1] == 'R') {
                turn = i;
                if ((i - 1) % 2 == 0) {
                    ans[i - 1] += e;
                    ans[i] += o;
                }
                else {
                    ans[i - 1] += o;
                    ans[i] += e;
                }
                ans[i]++;
                o = 0; e = 0;
            }
            else {
                if ((i - turn) % 2 == 0) {
                    ans[turn]++;
                }
                else {
                    ans[turn - 1]++;
                }
            }
            
        }
    }

    rep(i, s.size()) {
        cout << ans[i] << " ";
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3888
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		
		int ans = 0;
		
		for(int i = 0; i < n; i++) {
			h[i]= sc.nextInt();
			
			if(i == 0) {
				ans++;
			} else {
				boolean flag = true;
				for(int j = 0; j < i; j++) {
					if(h[j] > h[i]) {
						flag = false;
					}
				}
				if(flag) {
					ans++;
				}
			}
		}

		String reString = "" + ans;
		System.out.println(reString);
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> tall(N);
    int max=0;
    long total_step=0;
    for (int i=0; i<N; i++) {
        cin >> tall[i];
        if (max > tall[i]) {
            total_step += max - tall[i];
        }
        if (tall[i] > max) {
            max = tall[i];
        }
    }

    cout << total_step;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> rui(26, vector<int>(n + 1, 0));
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < n; j++) {
            rui[i][j + 1] = rui[i][j] + ((s[j] - 'a') == i);
        }
    }
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < n + 1; j++) {
            rui[i][j] = 2 * rui[i][j] - j;
        }
    }
    for(int i = 0; i < 26; i++) {
        int m = INT_MAX;
        int mind = -1;
        for(int j = 2; j < n + 1; j++) {
            if(m > rui[i][j - 2]) {
                m = rui[i][j - 2];
                mind = j - 2;
            }
            if(m < rui[i][j]) {
                cout << mind + 1 << " " << j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int a[3];

int main() {
    forn(i, 3) cin >> a[i];
    forn(i, 3) if (a[i] % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    sort(a, a + 3);
    cout << (LL)a[0] * a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = list(map(int,input().split()))
r,s,p = list(map(int,input().split()))
t = input()

def opt(c):
    if c=='r':
        return 'p'
    if c=='s':
        return 'r'
    if c=='p':
        return 's'

def sec(c,x):
    if x!=opt(c):
        return opt(c)
    else:
        return 'x'
    
def cnt(ans):
    c = 0
    for i in range(len(ans)):
        if ans[i]=='r':
            c+=r
        if ans[i]=='s':
            c+=s
        if ans[i]=='p':
            c+=p
    return c


ans = ""
for i in range(len(t)):
    if i-k>=0:
        ans+=sec(t[i],ans[i-k])
    else:
        ans+=opt(t[i])
        
print(cnt(ans))

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    int H,A;
    cin>>H>>A;
    cout<<(H+A-1)/A<<endl;
}

Measured memory_bytes: 256
#include <iostream>

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

    std::string s;
    std::cin >> s;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != s[0]) {
            while (i < s.length() && s[i] != s[0]) {
                s[i] = s[0];
                i++;
            }
            k--;
        }

        if (!k) {
            break;
        }
    }
    int ans = 0;
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == s[i + 1]) {
            ans++;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 512