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

using namespace std;

int min(int a, int b)
{
    if(a<b) return a; return b;
}

typedef long long ll;

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

//     ll n, k; cin>>n>>k;
//     double arr[n];
//     for(ll i=0; i<n; i++) {cin>>arr[i]; arr[i]++; arr[i]/=2;}
//     double m=0; double x;
//     for(ll i=1; i<n; i++) arr[i]+=arr[i-1];
//     for(ll i=k; i<n; i++)
//     {
//         x = arr[i]-arr[i-k];
//         if(x>m) m=x;
//     }
//     cout << setprecision(10) << m << endl;
//     // printf("%.12f\n", m);


//     return 0;
// }

int main(){
	int n, k;
	cin >> n >> k;
	double p[200001];
	double sum[200001];
	double ans = 0;
 
	sum[0] = 0;
 
	for (int i = 1; i <= n; i++){
		double temp;
		cin >> temp;
		p[i] = (temp+1)/2;
	}
 
	for (int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + p[i];
	}
 
	for (int i = k; i <= n; i++){
		ans = max(ans, sum[i] - sum[i-k]);
	}
 
	cout << setprecision(10) << ans << endl;
 
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  bool Sub = false;
  int Length = 0;
  for (int i = S.size(); i > 0; i--){
    for (int j = 0; j < S.size() - i+1; j++){
      string A = S.substr(j,i);
      bool Asub = false;
       for(int k = 0; k < i; k++){
         Asub = false;
         if (A[k] == 'A'|| A[k] == 'T'|| A[k] == 'G'||A[k] == 'C'){
           Asub = true;
         }
         if(!Asub) break;
       }
      if(Asub) Sub = true;
    }
    if(Sub){
      Length = i;
      break;
    }
  }
  if(Sub) cout << Length << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
    int N, K; cin >> N >> K;
    map<int, vector<int>> mp;
    vector<int64> maxes, others;
    vector<int64> maxes_s(N + 1, 0), others_s(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        int64 t, d; cin >> t >> d;
        mp[t].push_back(d);
    }
    for (auto &p : mp) {
        auto tp = p.second;
        sort(tp.rbegin(), tp.rend());
        maxes.push_back(tp[0]);
        for (int i = 1; i < tp.size(); ++i) others.push_back(tp[i]);
    }
    sort(maxes.rbegin(), maxes.rend());
    sort(others.rbegin(), others.rend());
    for (int i = 0; i < maxes.size(); ++i) maxes_s[i + 1] = maxes_s[i] + maxes[i];
    for (int i = 0; i < others.size(); ++i) others_s[i + 1] = others_s[i] + others[i];
    int64 ans = 0;
    int kmax = min(K, (int)mp.size());
    for (int64 k = 1; k <= kmax; ++k) {
        int64 result = maxes_s[k] + others_s[K - k] + (k * k);
        ans = max(ans, result);
    }
    cout << ans << endl;
    return;
}
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 14072
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = True

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:


        return array_result

arr_data = getinputdata()

#島数
n = arr_data[0][0]
m = int(arr_data[0][1])

arr01 = []
arr02 = []
for i in range(1, 1 + m):

    if arr_data[i][0] == "1":
        
        arr01.append(arr_data[i][1])

    if arr_data[i][1] == n:
        
        arr02.append(arr_data[i][0])


print("POSSIBLE" if len(list(set(arr01) & set(arr02))) == 1 else "IMPOSSIBLE")


Measured memory_bytes: 68284
def resolve():
    from collections import deque
    N = int(input())
    A = [int(i) for i in input().split()]
    Q = int(input())
    ans = [i for i in range(N)]
    for _ in range(Q):
        b, e, t = [int(i) for i in input().split()]
        tmp = deque(ans[t:t + (e - b)])
        for i in range(b, e):
            ans[i + t - b] = ans[i]
            ans[i] = tmp[i - b]
    prt = [0] * N
    for i in range(N):
        prt[i] = A[ans[i]]
    print(*prt)


resolve()



Measured memory_bytes: 6244
import java.util.Scanner;

public class Main{
  public static void main(String... args){
    Scanner scanner = new Scanner(System.in);
    
    int s1 = scanner.nextInt() * 60 + scanner.nextInt();
    int s2 = scanner.nextInt() * 60 + scanner.nextInt();
    int t = scanner.nextInt();
    
    System.out.println(Math.max(0, s2 - s1 - t));
  }
}

Measured memory_bytes: 35744
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dx2[] = { -1, 1, 0, 0 };
const int dy2[] = { 0, 0, 1, -1 };
const int N = 8e3 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
string s;
int x, y;
vi xx, yy, vv;
unordered_map<int, int> dp[N];
inline int solve(int idx, int cur) {
	if (idx >= (int) vv.size())
		return (cur == 0);
	if (dp[idx].count(cur))
		return dp[idx][cur];
	int &ret = dp[idx][cur];
	ret = 0;
	ret |= solve(idx + 1, cur - vv[idx]);
	ret |= solve(idx + 1, cur + vv[idx]);
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> s >> x >> y;
	int idx = 0, r = 1, ff = 1;
	while (idx < (int) s.size()) {
		int tmp = 0;
		while (idx < (int) s.size() && s[idx] == 'F')
			idx++, tmp++;
		if (ff == 1)
			x -= tmp;
		if (r && !ff)
			xx.pb(tmp);
		else if (!r)
			yy.pb(tmp);
		r ^= 1;
		ff = 0;
		idx++;
	}
	vv = xx;
	int q1 = solve(0, x);
	if (!q1)
		f("No");
	lp(i,0,vv.size())
		dp[i].clear();
	vv = yy;
	int q2 = solve(0, y);
	if (!q2)
		f("No");
	f("Yes");
	return 0;
}


Measured memory_bytes: 166528
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

use std::collections::HashSet;

fn main() {
    let n = input!(usize);
    let a_lst = input!(i64; n);
    let mut set: HashSet<i64> = HashSet::new();

    let mut pro_cnt = 0;
    for &rate in a_lst.iter() {
        if rate / 400 > 7 {
            pro_cnt += 1;
        } else {
            set.insert(rate / 400);
        }
    }
    let min = set.iter().count();
    // let max = if min + pro_cnt > 8 { 8 } else { min + pro_cnt };
    let max = min + pro_cnt;
    if min == 0 {
        println!("{} {}", 1, max);
    } else {
        println!("{} {}", min, max);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef uint64_t ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
ll helper(ll upper) {
    vector<ll> ans = {upper, 1, upper+1, 0};
    return ans[upper%4];
    /*
    ll ans = 0;
    for(int i = 1; i <= 45; i++) {
        ll pw = 1ull << i;
        ll half = 1ull << (i-1);
        ll remain = upper % pw;
        if (remain >= half) {
            if ((remain-half+1)%2 == 1)
                ans += half;
        }
    }
    cout << ans << endl;
    */
    // return ans;
}
int main() {
    ll A, B;
    cin >> A >> B;
    ll res = 0;
    /*
    for(int i = 1; i <= 30; i++) {
        res ^= i;
        printf("i(%d) = %u\n", i, res);
    }*/
    if (A == 0)
        cout << helper(B) << endl;
    else
        cout << (helper(A-1) ^ helper(B)) << endl;
    return 0;
}




Measured memory_bytes: 384
n, k = map(int, input().split())
emp_file = {}
num_list = []
count = 0
for i in range(n):
    a, b = map(int, input().split())
    num_list.append([a, b])
for i in range(n):
    emp_file[num_list[i][0]] = 0
for i in num_list:
    emp_file[i[0]] += i[1]
sort_file = sorted(emp_file.items())

sum_ = 0

for i in range(len(sort_file)):
    if sum_ < k:
        sum_ += sort_file[i][1]
        if sum_ >= k:
            print(sort_file[i][0])

Measured memory_bytes: 29196
import math
mod = 10**9+7

n,k = map(int,input().split())
cnt = [0]*(k+1)
ans = 0
for i in range(k,0,-1):
    cnt[i] = pow(k//i,n,mod)
    for j in range(2,k//i+1):
        cnt[i] -= cnt[i*j]
        if cnt[i] < 0:
            cnt[i] += mod
    ans += cnt[i]*i
    if ans > mod:
        ans %= mod
print(ans)


Measured memory_bytes: 11244
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int sum = 0;
  int tmp1,tmp2;

  cin >> tmp1 >> tmp2;
  sum += min(tmp1,tmp2);
  cin >> tmp1 >> tmp2;
  sum += min(tmp1,tmp2);

  cout << sum << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys




def main():
    N=int(input())
    S=input()
    if len(S)%2==1:
        print("No")
        exit(0)
    if S[:N//2] == S[N//2:]:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
w,h,n=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]

x,y=0,0
for s,t,u in a:
    if u==1:
        x=max(x,s)
    elif u==2:
        w=min(w,s)
    elif u==3:
        y=max(y,t)
    else:
        h=min(h,t)
height=max(0,h-y)
width=max(0,w-x)
print(height*width)

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

using namespace std;
 
using tint = long long;
using ld = long double;
 
#define forsn(i, s, n) for(int i = int(s); i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
 
using vi = vector<tint>;
 
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
 
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
 
#define DBG(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9+7;
const int MX = 3005;
const int INF = 1e9;
const ld PI = acos(ld(-1)); 
 
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
 
bool valid(int x, int y, int n, int m){
	return (0<=x && x<n && 0<=y && y<m);
}
 
void NACHO(string name = "", bool file = 0){
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(file){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){
    NACHO();
	tint k; cin >> k;
	if(k % 2 == 0 || k % 5 == 0){ cout << -1 << endl; return 0; }
	if(k == 7 || k == 1){ cout << 1 << endl; return 0; }
	tint res = 7;
	int ret = -1;
	forsn(i, 2, 5000001){
		res = (((res*10 % k+7 % k) % k)+k)%k;
		if(res % k == 0){ ret = i; break; }
	}
	cout << ret << endl;
}


Measured memory_bytes: 3616
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(11).
01 H              PIC 9(5).
01 A              PIC 9(5).
01 num            PIC 9(5).
01 ans            PIC Z(4)9.

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO H A.
  COMPUTE num = (H + (A - 1)) / A.
  MOVE num TO ans.
  DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
  STOP RUN.


Measured memory_bytes: 636
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
    ll n;cin>>n;
    ll a[n];ll dp[n]={0};
    for(ll i=0;i<n;i++)
     cin>>a[i];
     for(ll i=n-2;i>=0;i--)
     {
     	if(a[i]>=a[i+1]) dp[i]+=dp[i+1]+1;
	 }
	 cout<<*max_element(dp,dp+n);
 return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AIntegerProduct {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<vector<ll>> dp(20, vector<ll>(20));

      rep(i, n) {
        string s; cin >> s;
        ll p = 0;
        int pos = -1;
        for(int j=0; j<s.size(); j++) {
          if (s[j] == '.') {
            pos = j;
            continue;
          }
          p *= 10;
          p += s[j] - '0';
        }
        int digit = 0;
        if (pos != -1) {
          digit = s.size() - 1 - pos;
        }
        digit = 9 - digit;
        rep(_, digit) {
          p *= 10;
        }

        int cnt2 = 0;
        int cnt5 = 0;
        while(p%2 == 0) {
          cnt2++;
          p /= 2;
        }
        while(p%5 == 0) {
          cnt5++;
          p /= 5;
        }
        chmin(cnt2, 18);
        chmin(cnt5, 18);
        debug(cnt2, cnt5);
        dp[cnt2][cnt5]++;
      }

      ll ret = 0;
      rep(i, 19) {
        rep(j, 19) {
          rep(k, 19) {
            rep(l, 19) {
              if (i==k && j==l && i >= 9 && j >= 9) {
                ret += dp[i][j]*(dp[i][j]-1);
                if (dp[i][j]*(dp[i][j]-1)>0) debug(i, j);
              } else {
                if (i+k >= 18 && j+l >= 18) {
                  ret += dp[i][j] * dp[k][l];
                  if (dp[i][j]*dp[k][l] > 0) debug(i, j, k, l);
                }
              }



            }
          }
        }
      }
      cout << ret/2 << endl;




    }
};

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

Measured memory_bytes: 3616
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		char a='1';
		char b='2';
		int aa=1;
		int bb=1;
		for(int i=0; i<s.length(); i++){
			if(i==0){
				a=s.charAt(i);
				continue;
			}
			if(s.charAt(i)!=a && b=='2'){
				b=s.charAt(i);
				continue;
			}
			if(s.charAt(i)!=a && s.charAt(i)!=b){
				System.out.println("No");
				return;
			}else{
				if(s.charAt(i)==a){
					aa++;
				}else{
					bb++;
				}
			}
		}
		if(aa==2 && bb==2){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}




Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n;cin>>n;

    int minimum = n+1 ,res=0,x;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x<minimum){
            minimum = x;
            res++;
        }
    }
    cout<<res;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    int a,b;
    cin>>a>>b;
    
    for(int i=1;i<=1500;i++)
    {
       if ((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i ; return 0;}
        
    }
    
    
    cout<<-1<<endl;

        
    }


Measured memory_bytes: 256
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]

listl = [0]*n
listr = [0]*n

tmpmax = 0
for i in range(1,n):
    tar = lista[i]
    for j in range(i,-1,-1):
        if lista[j]<tar:
            #listl[i] = listl[j]+1
            #break
            listl[i] +=1

for i in range(n-2,-1,-1):
    tar = lista[i]
    for j in range(i,n):
        if lista[j]<tar:
            #listr[i] = listr[j]+1
            #break
            listr[i] += 1
            
            
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

ans = 0
i2 = mod_inv(2,((10**9)+7))
for i in range(n):
    f = (listl[i]*(k-1)+listr[i]*k)%((10**9)+7)
    t = (listr[i])%((10**9)+7)
    
    ans += int(((f+t)*k)*i2)
    
    ans = int(ans%((10**9)+7))
    
print(ans)

Measured memory_bytes: 41820
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int N, K;
    cin >> N >> K;

    cout << (N - K + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 75
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
#define mod 1000000007
#define vi vector<int>
#define pb push_back
using namespace std;

int n,K,fac[maxn << 2],invf[maxn << 2],inv[maxn << 2];
int C(int a,int b){ if(a<0 || b<0 || a-b<0) return 0;return fac[a] * 1ll * invf[b] % mod * invf[a-b]%mod; }
char s[maxn];
vi p;int ans;

bool check(){
	static bool vis[maxn];
	static int loc[maxn];
	memset(vis,0,sizeof vis);
	int j=1;
	for(int i=p.size()-1;i>=0 && p[i];i--){
		for(;j <= K && s[j] != 'r';j++);
		if(j > K) return 0;
		vis[j] = 1 , loc[i] = j , j++;
	}
	j=1;
	for(int i=p.size()-1;i>=0 && p[i];i--){
		j = max(j , loc[i]);
		for(;j <= K && s[j] != 'b';j++);
		if(j > K) return 0;
		vis[j] = 1 , loc[i] = j , j++;
	}
	j=1;
	for(int i=0;i<p.size() && p[i]==0;i++){
		for(;j <= K && (s[j] != 'r' || vis[j]);j++);
		if(j > K) return 0;
		vis[j] = 1 , j++;
	}
	j=1;
	for(int i=p.size()-1;i>=0 && p[i] > 1;i--){
		j = max(j , loc[i]);
		rep(k,2,p[i]){
			for(;j <= K && vis[j];j++);
			if(j > K) return 0;
			vis[j] = 1 , j++;
		}
	}
	return 1;
}

void dfs(int sz,int mx,int lim){
	if(sz > n) return;
	if(check()){
		int sm = fac[p.size()];
		for(int i=0,j;i<p.size();i=j){
			for(j=i;j<p.size() && p[j] == p[i];j++);
			sm = 1ll * sm * invf[j-i] % mod;
		}
		ans = (ans + 1ll * C(n-sz+mx-1,mx-1) * sm) % mod;
		//printf("%d %d %d %d\n",sm,ans,sz,mx);
	}
	else return;
	rep(i,lim,(n-sz+1)/2){
		p.pb(i);
		dfs(sz+max(2*i-1,1)+(sz!=0),mx+2*i+2,i);
		p.pop_back();
	}
}

int main(){//freopen("1.in","r",stdin);//freopen("2.out","w",stdout);
	scanf("%d%d",&n,&K);
	scanf("%s",s+1);
	fac[0] = inv[0] = inv[1] = fac[1] = invf[0] = invf[1] = 1;
	rep(i,2,(maxn << 2) - 1) fac[i] = 1ll * fac[i-1] * i % mod , inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod,
		invf[i] = 1ll * invf[i-1] * inv[i] % mod;
	dfs(0,1,0);
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 3820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args){

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			String line=reader.readLine();
			int x=Integer.parseInt(line);
			System.out.println(x*x*x);

		}catch(IOException e){
			System.out.println(e);
		}
	}

}

Measured memory_bytes: 24024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		
		for(int i = 1; i <= K; i++) {
			if(i % 2 != 0) {
				if(A % 2 == 1) A--;
				B += A / 2;
				A -= A / 2;
			}else {
				if(B % 2 == 1) B--;
				A += B / 2;
				B -= B / 2;
			}
		}
		System.out.println(A + " " + B);
	}

}

Measured memory_bytes: 24020
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <queue>

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

int main(){
    string  n;
    cin >> n;
    
    if(n[n.length()-1] == '0' || n[n.length()-1] == '1' ||
        n[n.length()-1] == '6' || n[n.length()-1] == '8'){
         cout << "pon" << endl;
    }else if(n[n.length()-1] == '3'){
        cout << "bon" <<endl;
    }else{
        cout << "hon" <<endl;
    }

    return 0;
}

Measured memory_bytes: 3624
n,m=map(int,input().split())
A=[]
c=0
for i in range(n):
    a=list(map(str,input().split()))
    a.pop(0)
    A=A+a
for i in range(1,31):
    if A.count(str(i))==n:
        c+=1
print(c)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

public class Program
{	static public void Main(string[] args)
	{
		string str = Console.ReadLine();
		string[] input = str.Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		if (n == m)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 13140
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		int H, W;
		int count;
		for (count = 0; true; count++) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			h.add(H);
			w.add(W);
		}
		for (int i = 0; i < count; i++) {
			for (int j = 0; j < h.get(i); j++) {
				for (int k = 0; k < w.get(i); k++) {
					if (j == 0 || j + 1 == h.get(i)) {
						System.out.print("#");
					} else if (k == 0 || k + 1 == w.get(i)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 34976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC118A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (b % a == 0)
                c = a + b;
            else
                c = b - a;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>

using namespace std;
typedef pair<int, int> P;
#define mp make_pair
bool cmp(P a, P b){
  return a.first > b.first;
}

int main(){
  int n,m;
  vector<P> c;
  vector<int>  a;
  cin >> n >> m;
  int count = n;
  for(int i = 0; i < n; i ++){
    int t;
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(),a.end());

  for(int i = 0; i < m; i ++){
    int t1,t2;
    cin >> t1 >> t2;
    c.push_back ( mp(t2,t1) );
  }
  sort(c.begin(),c.end(),cmp);
  for(int i = 0 ; i < n; i++){
    if(c[0].second == 0) break;
    if(a[i] > c[0].first) break;
    else {
      a[i] = c[0].first;
      c[0].second --;
      if(c[0].second == 0){
        c.erase(c.begin());
      }
    }
  }
  long long sum = 0;
  for(int i=0;i<n;i++){
    //cout << a[i] << ' ';
    sum += a[i];
  }
  cout  << sum;
  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, X, t;
  scanf("%d %d %d", &N, &X, &t);

  int y = N/X;

  if(N%X!=0){
    y++;
  }

  int T = y*t;

  printf("%d\n", T);

  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0,k=0;
  string a;
  cin>>n;
  while(n--){
    cin>>a;
    if(a=="A")c++;
    else c--;
    if(c<0)k++;
  }
  if(k||c)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N, A, B, C, D, X, Y, i = 0, j = 0, a = 0, b = 0;
    cin >> N >> A >> B >> C >> D;
    X = B;
    Y = D;
    while (N > a)
    {
        a += A;
        i++;
    }
    while (N > b)
    {
        b += C;
        j++;
    }
    X *= i;
    Y *= j;
    if (X < Y)
        cout << X << endl;
    else
        cout << Y << endl;
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint A, B, X;
	cin >> A >> B >> X;
	if (A != 0 && B != 0) {
		cout << (B / X) - ((A - 1) / X) << endl;
	}
	else if (A == 0 && B == 0) {
		cout << 1 << endl;
	}
	else if (A == 0) {
		cout << (B / X) + 1 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(const pair<int,int> &p1,const pair<int,int> &p2){
  return p1.second<p2.second;
}

int main(){
  int n;
  cin>>n;
  vector<pair<long long int,long long int> > v;
  long long int x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    v.push_back({x-y,x+y});
  }
  
  sort(v.begin(),v.end(),cmp);
  int cnt=1;
  int r1=v[0].second;
  for(int i=1;i<n;i++){
    int l1=v[i].first;
    int r2=v[i].second;
    if(l1>=r1){
      cnt+=1;
      r1=r2;
    }
  }
  cout<<cnt;
}
  
  


Measured memory_bytes: 2420
#include <stdio.h>
#include <math.h>
int main(void)
{
 int x[1000], y[1000],n,i;
 double p1 = 0, p2 = 0, p3 = 0, p = 0;

 scanf("%d",&n);
 for (i = 0; i < n; i++)
 {
  scanf("%d",&x[i]);
 }
 for (i = 0; i < n; i++)
 {
  scanf("%d", &y[i]);
 }

 for (i = 0; i < n; i++)
 {
  if (x[i] < y[i])
  {
   p1 = p1 + y[i] - x[i];
   p3 = p3 + (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
  }
  if (y[i] < x[i])
  {
   p1 = p1 + x[i] - y[i];
   p3 = p3 + (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
  }
  p2 = p2 + (x[i] - y[i]) * (x[i] - y[i]);

  if (x[i] < y[i])
  {
   if (p < y[i] - x[i])
   {
    p = y[i] - x[i];
   }
  }
  if (x[i] > y[i])
  {
   if (p < x[i] - y[i])
   {
    p = x[i] - y[i];
   }
  }
 }
 printf("%f\n%f\n%f\n%f\n", p1, sqrt(p2), pow(p3, 1.0 / 3.0), p);

 return 0;
}

Measured memory_bytes: 680
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun f (x)
  (if (> x 0)
	(+ (mod x 10) (f (floor x 10)))
	0))

(let ((n (read)))
  (princ
	(if (zerop (mod n (f n)))
	  "Yes"
	  "No")))


Measured memory_bytes: 9524
#include <cmath>
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  int d = log10(n) + 1;
  
  int ans = 0;
  for(int i = 1; i < d; i+=2){
    ans += 9 * pow(10, i - 1);
  }
  if(d % 2 == 1){
    ans += n + 1 - pow(10, d - 1);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define SE second
#define PI acos(-1.00)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define edl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,w,zz;
map<LL,LL>ww,u,st;
V<LL>uuu[500005];
V<pair<LL,LL> >uu;
map<pair<LL,LL>,LL> vo,vu,uh,ve;
set<LL>uo;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    char ch;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    cin>>tt;
    while(tt--)
    {
        cin>>n;
        k=0;
        for(i=0; i<n; i++)
        {
            cin>>o;
            v.PSB(o);
            if(o==0)
            {
                k=2;
            }
        }
        if(k==2)
        {
            cout<<0<<endl;
            return 0;
        }
        sort(v.B,v.E);
        s=1;
        for(i=0; i<n; i++)
        {
            s*=v[i];
            if(i<n-1 && 1000000000000000000/v[i+1]<s)
            {
                s=-1;
                break;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 16004
#include <iostream>
using namespace std;
const int I=2001;

int main(){
  int n; cin>>n;
  int a[n]; for(int i=0;i<n;i++) cin>>a[i];
  bool u[I]; u[0]=true; fill(u+1,u+I,false);
  for(int i=0;i<n;i++) {
    for(int j=I-1;j>=0;j--) {
      if (a[i]+j <= I-1 && u[j]) u[a[i]+j]=true;
    }
  }
  
  int q; cin>>q;
  int m[q]; for(int i=0;i<q;i++) cin>>m[i];
  for(int i=0;i<q;i++) cout<<(u[m[i]]?"yes":"no")<<endl;
  //for(bool x:u) cout<<x<<" "; cout<<endl;
}


Measured memory_bytes: 3116
_, _, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mi = 10**6
for _ in range(m):
    x, y, c = map(int, input().split())
    mi = min(mi, a[x-1] + b[y-1] - c)
print(min(mi, min(a)+min(b)))

Measured memory_bytes: 18736
from collections import defaultdict

n = int(input())
counts = defaultdict(int)

for _ in range(n):
    counts[input().strip()] += 1

vec = sorted([(value, key) for key, value in counts.items()])
best = vec[-1][0]
keys = sorted([key for value, key in vec if value == best])
for key in keys:
    print(key)

Measured memory_bytes: 46880
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)


int h,w,d;

int q;

int a[310][310];

P num[310 * 310];

int sum[310 * 310];
int main()
{
    cin >> h >> w >> d;

    rep(i,1,h)
    {
        rep(j,1,w)
        {
            cin >> a[i][j];
            num[a[i][j]].first = i;
            num[a[i][j]].second = j;
        }
    }

    rep(i,1,h * w)
    {
        if(i - d >= 0)
        {
            auto p1 = num[i];
            auto p2 = num[i - d];
            sum[i] = sum[i - d] + abs(p1.first - p2.first) + abs(p1.second - p2.second);
        }
    }

    cin >>q;

    rep(c,1,q)
    {
        int result = 0;
        int l,r;
        cin >> l >> r;


        cout << sum[r] - sum[l]  << endl;
    }
}

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>b){
    	swap(a,b);
    }
    for(int i=0;i<b;i++){
    	cout << a;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

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

	string S;
	READ(S);
	bool flag=false;
	FORI(i,0,3)
	{
		if (S[i]==S[i+1])
		{
			flag=true;
		}
	}
	if (flag)
	{
		cout<<"Bad"<<endl;
	}
	else
	{
		cout<<"Good"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
n=10**5;p=[0,0]+[1]*~-n
for i in range(2,int(n**0.5)+1):
 if p[i]:
  for j in range(i*2,n+1,i):p[j]=0
c=[0]
for i in range(1,n+1):c.append(c[-1]+(i%2and p[i]and p[-~i//2]))
for _ in[0]*int(input()):l,r=map(int,input().split());print(c[r]-c[l-1])

Measured memory_bytes: 7908
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		cout << "YES";
	else
		cout << "NO";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<bool>> P(N,vector<bool>(M,false));
  for (int i = 0; i < N; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int A;
      cin >> A;
      P[i][A - 1] = true;
    }
  }
  int c = 0;
  for (int i = 0; i < M; i++){
    bool res = true;
    for (int j = 0; j < N; j++){
      if (!P[j][i]) res = false;
    }
    if (res) c++;
  }
  cout << c;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(' ').map(&:to_i)
h = Hash.new(false)
k.times do
  _d = gets.chomp.to_i
  arr = gets.chomp.split(' ').map(&:to_i)
  arr.each { |a| h[a] = true }
end
count = 0
(1..n).each do |i|
  count += 1 unless h[i]
end
puts count

Measured memory_bytes: 14316
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    long numw, numh;
    cin >> numw >> numh;
    long numx, numy;
    cin >> numx >>numy;
    
    if((numw%2==0)&&(numh%2==0)){
        cout << numw/2*numh <<" ";
        if((numw/2==numx)&&(numh/2==numy)){
            cout << "1" <<endl;
        }else{
            cout << "0" <<endl;
        }
    }else if((numh%2==1)&&(numw%2==1)){
        cout << numw*numh/2 <<".5 0" <<endl;
    }else{
        cout << numw*numh/2 << " 0"<<endl;
    }
    return 0;
}

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

int main(){
  	int n;
    string S;
    cin >> n >> S;
    for(int i=0;i<S.length();i++){
        if(S[i]+n<='Z'){
            S[i] += n;
        }else{
            S[i] = 'A'-1+(S[i]+n-'Z');
        }
    }
    cout << S << endl;
}



Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    import math
    a,b,h,m=L()
    m_rote=360//60*m
    h_rote=360/(12*60)*(h*60+m)
    rot=abs(m_rote-h_rote)
    ans=pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(rot))
    print(pow(ans,1/2))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9600
#include <stdio.h>

int main() {
  int number_a, number_b;
  scanf("%d %d", &number_a, &number_b);
  if(number_a + number_b >= number_a - number_b && number_a + number_b >= number_a * number_b) {
    printf("%d\n", number_a + number_b);
  } else if(number_a - number_b >= number_a + number_b && number_a - number_b >= number_a * number_b) {
    printf("%d\n", number_a - number_b);
  } else {
    printf("%d\n", number_a * number_b);
  }
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
using namespace std;


const int N = 31;

int num[N];

int main() {
    int n;
    scanf("%d", &n);
    int xr = 0;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        int pw = 0;
        xr ^= a;
        while (!(a & 1))
            pw++, a >>= 1;
        num[pw]++;
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        if ((xr >> i) & 1) {
            if (num[i]) {
                ans++;
                xr ^= (1 << (i + 1)) - 1;
            } else {
                puts("-1");
                return 0;
            }
        }
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 128
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int

int n,d[300000],p=0,c=0,q;
string s;



int main() {
	
	cin >> n>>s;
	fori0(n) {
		if (s[i] == 'W') { d[i] = 1; }
		else {
			d[i] = 0;if (i >= 1) { c++; }
		}
	}
	p = c;
	q = c;
	fori1(n-1) {
		 
		 if (d[i - 1] == 1) { q++; }
		 if (d[i] == 0) { q--; }
		 p = min(p, q);
	}
	cout << p;
	//system("pause");
	return 0;

}



Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		
		if((double)d / (double)s <= t) System.out.println("Yes");
		else System.out.println("No");
		
		
		
	}

}


Measured memory_bytes: 35612
def GCD(x,y):
    if y>x :
        x,y = y,x
    mod = x%y
    return GCD(y,mod) if mod!=0 else y

N,X = map(int,input().split())
x = list(map(int,input().split()))
for i in range(N-1,0,-1):
    x[i] = abs(x[i]-x[i-1])
x[0] = abs(x[0]-X)
gcd = x[0]
for i in range(1,N):
    gcd = GCD(gcd,x[i])
print(gcd)

Measured memory_bytes: 14252
#include <iostream>
#include <cstring>
using namespace std;
const int N=20;
bool solve(int,int,char*);

int main()
{
	int a,b;
	char s[N];
	cin>>a>>b>>s;
	if(solve(a,b,s))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

bool solve(int a,int b,char*s)
{
	for(int i=0;i<a;i++)
		if(s[i]<'0' || s[i]>'9')
			return false;
	if(s[a]!='-')
		return false;
	for(int i=a+1;i<=a+b;i++)
		if(s[i]<'0' || s[i]>'9')
			return false;	
	return true;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
L = set(int(input()) for _ in range(m))
dp = [0]*(n+1)
mod = 10**9+7
dp[0] = 1
for i in range(n):
    if i + 1 not in L:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    if i+2 not in L and i+2 < n+1 :
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[n])

Measured memory_bytes: 58200
import java.util.*;

class Main{

    LinkedList<int[]> list;
    PriorityQueue<int[]> empty;

    void solve(){
        Scanner sc = new Scanner(System.in);
        int INF = Integer.MAX_VALUE;

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            list = new LinkedList<int[]>(); // from, to, id
            empty = new PriorityQueue<int[]>(10, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b){
                        return a[0] - b[0];
                    }
                });
            empty.add(new int[]{0, INF});

            for(int i=0; i<n; i++){
                char command = sc.next().charAt(0);
                if(command=='R') print(sc.nextInt());
                if(command=='W') write(sc.nextInt(), sc.nextInt());
                if(command=='D') delete(sc.nextInt());
            }
            System.out.println();
            System.gc();
        }
    }

    void print(int idx){
        for(int i=0; i<list.size(); i++){
            int[] one = list.poll();
            if(one[0]<=idx && idx<=one[1]){
                System.out.println(one[2]);
                list.add(one);
                return;
            }
            list.add(one);
        }
        System.out.println(-1);
    }

    void write(int idx, int length){
        while(length>0){
            int[] one = empty.poll();
            int from = one[0], to = Math.min(one[0]+length-1, one[1]);
            list.add(new int[]{from, to, idx});
            length -= Math.min(length, to-from+1);
            if(to<one[1]) empty.add(new int[]{to+1, one[1]});
        }
    }

    void delete(int idx){
        int size = list.size();
        for(int i=0; i<size; i++){
            int[] one = list.poll();
            if(one[2]==idx) empty.add(new int[]{one[0], one[1]});
            else list.add(one);
        }
    }

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

Measured memory_bytes: 261244
#include <iostream>
#include <cstdio>
#define maxn 100005
using namespace std;
int n;
long long L,a[maxn];
int main()
{
	scanf("%d%lld",&n,&L);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>=L)
		{
			printf("Possible\n");
			for(int j=n-1;j>=i+1;j--) printf("%d\n",j);
			for(int j=1;j<i;j++) printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	}
	printf("Impossible");
	return 0;
}

Measured memory_bytes: 4560
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd

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


ans = 1
x = a

if b == 1:
    print(0)
else:
    while x < b:
        ans = ans + 1
        x = x + a-1
    print(ans)
     

Measured memory_bytes: 13512