akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pq priority_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
using namespace std;
typedef long long ll; typedef long double ld;
constexpr int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
constexpr int lcm(int a, int b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int inv(const int x, int n, const int mod){ll ret=1,pos=x;while(n){if(n&1)(ret*=pos)%=mod;(pos*=pos)%=mod;n>>=1;}return ret;}
template<int n> struct Factorial{ll arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=inv(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact;
constexpr int comb(int a, int b){ll pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

struct UnionFind{
	vector<int> data;
	
	UnionFind(int n){
		data.assign(n, -1);
	}
	
	void unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return;
		if(data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	
	int find(int k){
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}

	int size(int k){
		return -data[find(k)];
	}
};

int main(){
	int n, m; cin >> n >> m;
	vector<int> vec[100010];
	for(int i = 0; i < n; i++){
		int k; cin >> k;
		for(int j = 0; j < k; j++){
			int a; cin >> a;
			vec[a - 1].push_back(i);
		}
	}
	
	UnionFind uf(n);
	for(int i = 0; i < m; i++){
		for(auto v:vec[i]) uf.unite(vec[i][0], v);
	}
	
	cout << (uf.size(0) == n ? "YES" : "NO") << endl;
	return 0;
}


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

int main() {
  int N,W;
  cin >> N >> W;

  int cost[N];
  int calorie[N];

  for(int i = 0; i < N; i++){
    cin >> cost[i] >> calorie[i];
  }

  long long dp[N + 1][W + 1];

  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < W + 1; j++) {
      dp[i][j] = 0;
    }
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j <= W; j++){
      if(j < cost[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - cost[i]] + calorie[i]);
      }
    }
  }

  cout << dp[N][W] << endl;
}

Measured memory_bytes: 82452
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
int p[210000];

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) cin >> p[i], --p[i];
    int res = 0;
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
      if (p[i] == i) {
	++tmp;
      }
      else {
	res += (tmp + 1) / 2;
	tmp = 0;
      }
    }
    res += (tmp + 1) / 2;
    cout << res << endl;
  }
}
















Measured memory_bytes: 640
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        int x = 0, y = 1, ans = 0;
        map<int, int> mp;
        mp[x]++;
        int n = s.size(), k = 2019;
        for(int i = n - 1; i >= 0; i--) {
            x = ((s[i] - '0') * y + x) % k;
            y = y * 10 % k;
            ans += mp[x];
            mp[x]++;
        }

        cout << ans << '\n';

        
    }
    
    return 0;
}



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

int main(){
	int n,m,c;
	cin >> n >> m >> c;
	int a[n][m],b[m],count=0;
	rep(i,m)cin>>b[i];
	rep(i,n){
		int sum=c;
		rep(j,m){
			cin>>a[i][j];
			sum+=a[i][j]*b[j];
		}
		count+=sum>0?1:0;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(1){
    int num,m;
    cin >> num >> m;if(!(num|m))return;
    int ar[num];
    for(int i=0;i<num;i++)
      cin >> ar[i];
    int res=0;
    for(int i=0;i<num;i++)
      for(int j=i+1;j<num;j++)
        if(ar[i]+ar[j]<=m)
          res=max(res,ar[i]+ar[j]);
    if(res==0)
    {cout << "NONE" << endl; continue;}
    cout << res << endl;
  }
}

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



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string s;
	int i;
	int mostLeftIndex;
	int mostRightIndex;
	cin >> s;
	
	i = 0;
	while(true) { 
		
		if ( s[i] == 'A' ) {
			mostLeftIndex = i;
			break;
		}		
		i++;
	}

	i = s.size() - 1;
	while (true) {

		if (s[i] == 'Z') {
			mostRightIndex = i;
			break;
		}
		i--;
	}
	cout << mostRightIndex - mostLeftIndex + 1 << endl;
	return 0;
}

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

void dfs(string s, char mx,int N){
  if(s.size() == N) cout << s << endl;
  else{
    for(char c = 'a'; c<=mx; c++) dfs(s+c,(c==mx)?(char)(mx+1):mx, N);
  }
}

int main(){
  int N; cin >> N;
  dfs("",'a',N);
}

Measured memory_bytes: 1536
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] s1 = Console.ReadLine().Split(' ');
        int q = int.Parse(Console.ReadLine());
        string[] s2 = Console.ReadLine().Split(' ');

        int[] a = new int[N];
        int[] b = new int[q];
        int cnt = 0;

        for (int i = 0; i < N; i++)
        {
            a[i] = int.Parse(s1[i]);
        }

		for (int i = 0; i < q; i++)
		{
			b[i] = int.Parse(s2[i]);
		}

        Array.Sort(a);

        for (int i = 0; i < q;i++)
        {
            if (Array.BinarySearch(a, b[i])>=0) cnt++;
        }


        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 22428
#C
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(0)
m = [0 for _ in range(n+1)]
tmp = 0

for i in range(n+1):
    if tmp > a[i]:
        m[i] += a[i]
        a[i] = 0
        tmp = b[i]
        
    else:
        m[i] += tmp
        a[i] -= tmp
        if a[i] <= b[i]:
            b[i] -= a[i]
            m[i] += a[i]
            tmp = b[i]       
        else:#a >             
            m[i] += b[i]
            #b[i] = 0
            tmp = 0
     
     
print(sum(m))
        

Measured memory_bytes: 19004
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-25 22:12:11 +0900
# LastModified: 2020-06-25 22:33:48 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    if x<a[0] or a[-1]<x:
        print("0")
        return

    for i in range(len(a)):
        if a[i] > x:
            tmp = i
            break
    if tmp < m-tmp:
        print(tmp)
    else:
        print(m-tmp)
            



if __name__ == "__main__":
    main()


Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;

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


Measured memory_bytes: 256
# 温度の読み込み
in_data = int(input())
# 室温が 30 度以上のとき、またそのときに限り、冷房の電源を入れる。
# 冷房の電源を入れるならば Yes、入れないならば No を出力
if in_data >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9088
def compress(S):
    res = []
    prev = "aa"
    for c in S:
        if c != prev:
            res.append([c, 1])
        else:
            res[-1][1] += 1
        prev = c
    return res


N, K = map(int, input().split())
S = list(map(int, input()))
S_comp = compress(S)
M = len(S_comp)
ans = 0
total = 0
right = 0
zero_chunks_cnt = 0
for left in range(M):
    while right < M and zero_chunks_cnt + 1 - S_comp[right][0] <= K:
        zero_chunks_cnt += 1 - S_comp[right][0]
        total += S_comp[right][1]
        right += 1
    ans = max(ans, total)
    if right == left:
        right += 1
    else:
        zero_chunks_cnt -= 1 - S_comp[left][0]
        total -= S_comp[left][1]
print(ans)


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

int discover(int &t, int node, int n, vector<vector<int>> &g, vector<int> &d, vector<int> &f);

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> g(n+1);
	for (int i=1;i<=n;++i)
	{
		int u,k;
		cin >> u >> k;
		for (int j=0;j<k;++j)
		{
			int v;
			cin >> v;
			g[u].push_back(v);
		}
	}

	vector<int> d(n+1);
	vector<int> f(n+1);
	stack<int> st;

	for (int i=1;i<=n;++i)
	{
		d[i]=-1;
		f[i]=-1;
	}


	int t=0;
	for (int i=1;i<=n;++i)
	{
		if (d[i]<0)
		{
			d[i]=++t;
			discover(t,i,n,g,d,f);
			//f[i]=++t;
		}
	}

	for (int i=1;i<=n;++i)
	{
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
}


int discover(int &t, int node, int n, vector<vector<int>> &g, vector<int> &d, vector<int> &f)
{

	for (int i=0;i<g[node].size();++i)
	{
		int nn=g[node][i];
		if (d[nn]<0)
		{
			++t;
			d[nn]=t;
			discover(t,nn,n,g,d,f);
		}
	}

	++t;
	f[node]=t;

	return 0;
}









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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

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


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

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

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

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

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

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

const ll size = 1e6 + 10;
ll N;
vector<ll> A(size);
vector<ll> eff(size);
vector<ll> cnt(size);
vector<ll> sum(size);

ll solve(){
  for(ll i = 1; i < size; i++) eff[i] = inverse(i);
  for(ll i = 1; i < size; i++){
    for(ll j = i * 2; j < size; j += i){
      eff[j] = (eff[j] - eff[i] + MOD) % MOD;
    }
  }

  rep(i, N){
    cnt[A[i]]++;
  }

  for(ll i = 1; i < size; i++){
    for(ll j = i; j < size; j += i) sum[i] = (sum[i] + cnt[j] * j) % MOD;
  }

  ll ans = 0;
  for(ll i = 1; i < size; i++){
    ans = (ans + sum[i] * sum[i] % MOD * eff[i] % MOD) % MOD;
  }

  rep(i, N) ans = (ans - A[i] + MOD) % MOD;
  return ans * inverse(2) % MOD;
}

int main(){
  cin >> N;
  rep(i, N) cin >> A[i];
  ll ans = solve();
  cout << ans << endl;
}


Measured memory_bytes: 31488
N = (gets).to_i
ms = (gets).split(" ").map { |i| i.to_i }

count = 1 # ０番目は必ず見えている

1.upto(N-1) do |n|
    # 要するに前のやつより大きければ見える。
    t = ms[0..(n-1)].max
    if t <= ms[n] then
        count = count + 1
    end
end

puts count


Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

// isLoaded(p, k int, w []int) bool
// 最大積載量p, トラックの台数k, len(w)個の荷物が与えられたとき、全ての荷物を積み切れるか？
func isLoaded(p, k int, w []int) bool {
	i := 0
	for j := 0; j < k; j++ { // k台のトラック
		s := 0
		for s+w[i] <= p {
			s += w[i]
			i++
			if i == len(w) {
				return true
			}
		}
	}
	return false
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	w := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		w[i] = nextInt(sc)
	}
	// 最大積載量の最小値を求める -> 2分探索
	// 1 <= p <= 10^4 * 10^5 (== 10^9)
	left, right := -1, int(1e9)+1
	for right-left > 1 {
		// mid := left + (right-left)/2
		mid := (left + right) / 2
		if isLoaded(mid, k, w) {
			right = mid
		} else {
			left = mid
		}
	}
	fmt.Println(right)
}



Measured memory_bytes: 2364
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
   int K;
   cin >> K;
   int A[K];
   for( int i = 0 ; i< K; i++ ){
      cin >> A[i];
   }
   if( A[K-1] != 2 ){
      cout << -1 << endl;
      return 0;
   }
   long long left = 2;
   long long right = 2;
   for( int i = K-1; i>=0; i--){
      int a = A[i];
      long long k = (left+a-1)/a;
      long long h = right/a;
      if( k*a > right){
         cout << -1 << endl;
         return 0;
      }
      left = k*a;
      right = (h+1)*a-1;
   }
   cout << left << " " << right << endl;
   return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  int n; cin >> n;
  ll acc = 0;
  for(int i=1; i<=n; i++) acc += i;
  cout << acc << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

max_ = -1
for tail in range(2, len(s)):
    s_ = s[:tail]
    if len(s) % 2 == 0 and s_[:len(s_)//2] == s_[len(s_)//2:]: 
        max_ = max(max_, len(s_))

print(max_)


Measured memory_bytes: 3316
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
using namespace std;
typedef long long int ll;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

ll n;
ll a[200000];
int main(){
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n,std::greater<int>());
	ll ans=0;
	ans+=a[0];
	n-=2;
	int index=1;
	while(n>0){
		ans+=a[index];
		n--;
		if(n==0){break;}
		ans+=a[index];
		n--;
		index++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5180
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

ll f(ll H){
    if(H==1){
        return 1;
    }
    return 2*f(H/2)+1;
}

void Main(){
    ll H;
    cin >> H;
    cout << f(H) << el;
}



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

using namespace std;
#define int long long
int MOD = 1000000007;


signed main(){
    int A;
    map<int,int> mp;
    for(int i=0;i<6;i++){
        cin >> A;
        mp[A]++;
    }
    int cnt = 0;
    
    for(int i=1;i<=4;i++){
        if(mp[i]!=2) cnt++;
    }
    
    if(cnt==2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
DP = [0] * H

for i in range(H):
    minM = float('inf')
    for j in range(N):
        if i+1 - A[j] >= 0:
            M = DP[i-A[j]] + B[j]
        else:
            M = B[j]
        if minM > M:
            minM = M
    DP[i] = minM

print(int(DP[H-1]))


Measured memory_bytes: 42476
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
import math
a_1=a-math.floor((a-1)/10)*10
b_1=b-math.floor((b-1)/10)*10
c_1=c-math.floor((c-1)/10)*10
d_1=d-math.floor((d-1)/10)*10
e_1=e-math.floor((e-1)/10)*10
a_1n=math.ceil(a/10)*10
b_1n=math.ceil(b/10)*10
c_1n=math.ceil(c/10)*10
d_1n=math.ceil(d/10)*10
e_1n=math.ceil(e/10)*10
lists=[]
lists.append(a_1)
lists.append(b_1)
lists.append(c_1)
lists.append(d_1)
lists.append(e_1)
lists.sort()
print(a_1n+b_1n+c_1n+d_1n+e_1n-10+lists[0])

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m,c; cin>>n>>m>>c;
  vector<int> b(m, 0);
  rep(i,m) cin>>b[i];
  vector<vector<int>> a(n, vector<int>(m, 0));
  int ans=0;
  rep(i,n) {
    int sum=0;
    rep(j,m) {
      int a; cin>>a;
      sum+=a*b[j];
    }
    if(sum+c>0) ans++;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

void SOE(ll N, vi & p) {
    int m = int(floor(sqrt(N))) + 1;
    int s[m];
    REP(i ,m) s[i] = i;

    FOR (i, 2, m) {
        if (s[i] != i) continue;

        p.pb(i);

        for (int j = i+i; j <= m; j += i) {
            s[j] = i;
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N;
    cin >> N;

    vi p;
    SOE(N, p);

    map<int, int> m;
    for(auto &pp: p) {
        if (N % pp) continue;

        while(N % pp == 0) {
            m[pp]++;
            N /= pp;
        }
    }

    if (N > 1) m[N] = 1;

    ll ans = 0;
    for(auto p: m) {
        int c = 0, s = 0;
        while(s + c <= p.se) {
            s += c;
            c++;
        }

        ans += c - 1;
    }

    print(ans);
    
}


Measured memory_bytes: 7832
N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
d=[0]*N
M=sum(b)

tmp=0
for i in range(N):
    if a[i]<0: tmp+=1
    d[i]=tmp

if d[N-1]%2==0 or 0 in a:
    print(M)

else: print(M-min(b)*2)

Measured memory_bytes: 15020
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    L = defaultdict(list)
    R = defaultdict(list)
    for i in range(N):
        L[A[i] + i].append(i)
        R[i - A[i]].append(i)
    K = list(L.keys())

    answer = 0
    for k in K:
        l = len(L[k])
        r = len(R[k])
        answer += l * r
    print(answer)


if __name__ == "__main__":
    main()


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    char c[5];
    REP(i, 5) cin >> c[i];
    REP(i, 5) {
        if (c[i] == '0') {
            cout << i + 1 << endl;
        }
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int A, B, Q;
vector<ll> s, t;
vector<ll> x;

int main() {
    cin >> A >> B >> Q;
    s.resize(A); t.resize(B); x.resize(Q);
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    rep(i, Q) cin >> x[i];

    rep(q, Q) {
        auto ita = lower_bound(all(s), x[q]);
        ll sr = ita != s.end() ? *ita : LINF;
        ll sl = ita != s.begin() ? *(--ita) : -LINF;

        auto itb = lower_bound(all(t), x[q]);
        ll tr = itb != t.end() ? *itb : LINF;
        ll tl = itb != t.begin() ? *(--itb) : -LINF;

        ll ans = min(
            max(sr, tr) - x[q],
            min(
                x[q] - min(sl, tl),
                min(sr - tl, tr - sl) + min(min(sr -x[q], tr - x[q]), min(x[q] - sl, x[q] - tl))
            ));
        write(ans);
    }
}

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

int n, a, b, c, ans = 999999999;
vector<int> l;

void check(vector<int> v) {
  int sum[3] = {0}, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] == 0) {
      sum[0] += l[i];
      cnt++;
    }
    else if (v[i] == 1) {
      sum[1] += l[i];
      cnt++;
    }
    else if (v[i] == 2) {
      sum[2] += l[i];
      cnt++;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (sum[i] == 0) {
      return;
    }
  }
  int tmp = abs(a - sum[0]) + abs(b - sum[1]) + abs(c - sum[2]) + 10*(cnt - 3);
  if (tmp < ans) {
    ans = tmp;
  }
  return;
}

void dfs(vector<int> v) {
  if (v.size() == n) {
    check(v);
    return;
  }
  for (int i = 0; i < 4; i++) {
    v.push_back(i);
    dfs(v);
    v.pop_back();
  }
  return;
}

int main() {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    l.push_back(x);
  }
  vector<int> v;
  dfs(v);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
int main(void){
    int i=0;
    int j=0;
    
    int t[9<<14]={};
    int max=0;
    int scn=0;
    
    for(;~scanf("%d",&t[i]);i++){
        i*(t[i]>max)?max=t[i]:0;
    }
    for(j=1;j<t[0]+1;j++){
        if(abs(t[j]-max/2)<abs(scn-max/2))scn=t[j];
    }
    printf("%d %d",max,scn);
}

Measured memory_bytes: 2272
#include<stdio.h>
int main()
{
   int n,r;
   scanf("%d",&n);
   r=n%10;
   if(r==2||r==4||r==5||r==7||r==9)
      printf("hon");
      else if(r==0||r==1||r==6||r==8)
        printf("pon");
      else
        printf("bon");
  return 0;
}
  


Measured memory_bytes: 1708
import sys

def solve():
    n, q = map(int, sys.stdin.readline().split())

    ft = FenwickTree(n)

    for qi in range(q):
        query = sys.stdin.readline().rstrip()

        if query[0] == '0':
            c, s, t, x = map(int, query.split())
            ft.add(s, x)
            ft.add(t + 1, -x)
        else:
            c, i = map(int, query.split())

            print(ft.get_sum(i))


class FenwickTree:
    def __init__(self, size):
        self.n = size
        self.data = [0]*(size + 1)

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & (-i)

    def get_sum(self, r):
        res = 0

        while r > 0:
            res += self.data[r]
            r -= r & (-r)

        return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 10924
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x;
  cin >> x;
  int ans = 1;
  while(ans*(ans+1)/2<x) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  cin >> A;
  double B = A;
  if(A % 2 == 0) {
    cout << 0.5 << endl;
  }
  else {
    cout << (B + 1) / 2 / B << endl;
  }
}


Measured memory_bytes: 3800
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		char[][] map = new char[h][w];
		int[][] cost = new int[h][w];
		for(int i=0;i<h;i++){
			map[i] = sc.next().toCharArray();
			Arrays.fill(cost[i], Integer.MAX_VALUE);
		}
		
		ArrayDeque<Integer> x = new ArrayDeque<Integer>();
		ArrayDeque<Integer> y = new ArrayDeque<Integer>();
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='S'){
					x.offer(j);
					y.offer(i);
					cost[i][j] = 0;
					i = h;
					j = w;
				}
			}
		}
		
		int p, q;
		int sum = 0;
		int cnt = 1;
		while(true){
			p = x.poll();
			q = y.poll();
			if(map[q][p]==(char)(cnt+48)){
				sum += cost[q][p];
				if(cnt==n) break;
				else{
					cnt++;
					for(int i=0;i<h;i++){
						for(int j=0;j<w;j++){
							cost[i][j] = Integer.MAX_VALUE;
						}
					}
					cost[q][p] = 0;
					x.clear();
					y.clear();
				}
			}
			
			if(p!=0 && map[q][p-1]!='X' && cost[q][p]+1<cost[q][p-1]){
				x.offer(p-1);
				y.offer(q);
				cost[q][p-1] = cost[q][p]+1;
			}
			if(p!=w-1 && map[q][p+1]!='X' && cost[q][p]+1<cost[q][p+1]){
				x.offer(p+1);
				y.offer(q);
				cost[q][p+1] = cost[q][p]+1;
			}
			if(q!=0 && map[q-1][p]!='X' && cost[q][p]+1<cost[q-1][p]){
				x.offer(p);
				y.offer(q-1);
				cost[q-1][p] = cost[q][p]+1;
			}
			if(q!=h-1 && map[q+1][p]!='X' && cost[q][p]+1<cost[q+1][p]){
				x.offer(p);
				y.offer(q+1);
				cost[q+1][p] = cost[q][p]+1;
			}	
		}
		System.out.println(sum);
	}	
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
int incnt[1000010];
vector<int> e[1000010];
int in[1010][1010];
int ind(int a,int b){
	if(a>b)swap(a,b);
	return in[a][b];
}
signed main(){
	int n;
	cin>>n;
	rep(i,n){
		rep(j,i+1,n){
			if(i==0&&j==1)in[i][j]=0;
			else if(j==i+1)in[i][j]=in[i-1][n-1]+1;
			else in[i][j]=in[i][j-1]+1;
		}
	}
	rep(i,n){
		int a[1010];
		rep(j,n-1){
			cin>>a[j];
			a[j]--;
		}
		rep(j,n-2){
			e[ind(i,a[j])].push_back(ind(i,a[j+1]));
			incnt[ind(i,a[j+1])]++;
		}
	}
	stack<int> s;
	rep(i,ind(n-2,n-1)+1){
		if(incnt[i]==0){
			s.push(i);
		}
	}
	int ans=0;
	vector<int> g;
	while(!s.empty()){
		ans++;
		stack<int> t;
		while(!s.empty()){
			int a=s.top();
			s.pop();
			t.push(a);
		}
		while(!t.empty()){
			int a=t.top();
			t.pop();
			g.push_back(a);
			rep(i,e[a].size()){
				incnt[e[a][i]]--;
				if(incnt[e[a][i]]==0){
					s.push(e[a][i]);
				}
			}
		}
	}
	if(g.size()==ind(n-2,n-1)+1)cout<<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 58228
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

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

	for (int i=0; i<n; ++i) {
		int a;
		cin >> a;
	}

	cout << (n - 2) / (k - 1) + 1 << endl;	
	return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
//Atcoder Educational DP
//E-Knapsack2
/*
    I ♥ CLARICE STARLING

    EXPLAINATION BELOW->
    Dp + Probability
      
    Observation:->
   
*/
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF=(ll)1e18+5;
void solve()
{
    int n,i,j;cin>>n;
    double p[n+1],ans=0;
    foe(i,1,n)cin>>p[i];
    
    double dp_heads[n+1][n+1];
    foe(i,0,n)
    foe(j,0,n)
    dp_heads[i][j]=0;
    
    dp_heads[0][0]=1;
    foe(i,1,n)
    {
        double h,t;
        h=p[i];t=1.0-h;
        dp_heads[0][i]=t*dp_heads[0][i-1];
        int heads;
        foe(heads,1,i)
        dp_heads[heads][i]=h*dp_heads[heads-1][i-1]+t*dp_heads[heads][i-1];
    }
    for(i=(n/2)+1;i<=n;i++)ans+=dp_heads[i][n];
    cout<<setprecision(10)<<ans<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}



Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
#ifdef umang99m
    #include "/home/umang/Desktop/folder/home/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    vector<string> a(h);
    rep(i,h) cin>>a[i];
    ll dp[h][w];
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(i==0 && j==0) continue;
            dp[i][j] = 0;
            if(a[i][j] == '#') {
                continue;
            }
            if(i>0){
                dp[i][j] += dp[i-1][j];
            }
            if(j>0){
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    timer();
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() {
	string s;
	cin>>s;
    int n=s.size();
    int del=0;
    int fn=n;
    
    if(n%2==1) {n--;del+=1;}
    else {n-=2;del+=2;}
    
    string fh="",sh="";
    
    for(int i=0;i<n/2;i++) fh+=s[i];
    
    for(int i=n/2;i<n;i++) sh+=s[i];
    
    //cout<<fh<<" "<<sh<<endl;
    while(1){
        if(fh==sh){
            cout<<fn-del<<endl;
            break;
        }
        else{
            string full=fh+sh;
            fh="";
            sh="";
            del+=2;
            for(int i=0;i<(full.size()-2)/2;i++)
                fh+=full[i];
            for(int i=(full.size()-2)/2;i<full.size()-2;i++)
                sh+=full[i];
            
        }
    }
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	sArr := strings.Split(s, "")
	tArr := strings.Split(t, "")
	sort.Strings(sArr)
	sort.Strings(tArr)
	ReverseStrings(tArr)
	
	if strings.Join(sArr, "") < strings.Join(tArr, "") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func ReverseStrings(s []string) {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}


Measured memory_bytes: 1840
h, w = list(map(int, input().split()))
s = []
ans = []
for i in range(h):
    s.append(input())
    ans.append([])
for i in range(h):
    for j in range(w):
        if(s[i][j] == "#"):
            ans[i].append("#")
            continue
        ans[i].append(0)
for i in range(h):
    for j in range(w):
        if(s[i][j] == "#"):
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if(x == 0 and y == 0):
                        continue
                    if((i == 0 and x == -1) or (i == h - 1 and x == 1) or (j == 0 and y == -1) or (j == w - 1 and y == 1)):
                        continue
                    if(ans[i + x][j + y] != "#"):
                        ans[i + x][j + y] += 1

o = ""
for i in range(h):
    for j in range(w):
        o += str(ans[i][j])
    o += "\n"
print(o)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>

using namespace std;
#define INF 1500000


int main(void) {

	while (1) {
		int max = INF, min = 0;
		int floor, n, book[102] = { 0 };
		cin >> floor >> n;

		if (floor == 0)return 0;

		for (int i = 0; i < n; i++) {
			cin >> book[i];
		}
		while (max - min > 1) {
			int count = floor;
			int  mid = (max + min) / 2;
			int length = mid;
			int i = 0;
			while (count != 0 && i < n) {
				if (length >= book[i]) {
					length -= book[i];
					i++;
				}
				else {
					length = mid;
					count = count - 1;
				}
			}	
				if (count != 0) {
					max = mid;
				}else {
					min = mid;
				
			}
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, l[10], wa=0, sd=0;
	cin >> n;
	for (int a = 0; a < n; a++) {
		cin >> l[a];
		wa = wa + l[a];
		if (sd <= l[a]) {
			sd = l[a];
		}
	}
	wa = wa - sd;
	if (wa > sd)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int x;
	double len;
	double volume;

	cin >> x;
	len = x / 3.0;
	
	volume = len * len * len;

	printf("%12f", volume);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll n,x,a[2005],f[2005][2005],t,ans=1000000000000000;
ll min(ll x,ll y){
	return x<y?x:y;
}
int main(){
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		f[i][0]=a[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			t=i-j;
			if(t<=0) t=n+t;
			f[i][j]=min(f[i][j-1],a[t]);
		}
	for(int i=0;i<=n;i++){
		t=0;
		for(int j=1;j<=n;j++) t+=f[j][i];
		ans=min(ans,t+x*i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31616
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;

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

	final long MODULO = (long) (1e9 + 7);
	String[] str;
	char empty = '`';

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		str = new String[n];
		for (int i = 0; i < n; ++i) {
			str[i] = sc.next();
			while (str[i].length() < 20)
				str[i] += empty;
		}
		System.out.println(f(0, n - 1, 0, 0));
	}

	long[][][][] memo = new long[50][50][20][28];
	{
		for (int i = 0; i < memo.length; ++i) {
			for (int j = 0; j < memo[i].length; ++j) {
				for (int k = 0; k < memo[i][j].length; ++k) {
					for (int l = 0; l < memo[i][j][k].length; ++l) {
						memo[i][j][k][l] = -1;
					}
				}
			}
		}
	}

	long f(int l, int r, int i, int c) {
		if (i == 20)
			return 0;
		if (r - l < 0)
			return 1;
		if (c >= 27)
			return 0;
		if (memo[l][r][i][c] != -1)
			return memo[l][r][i][c];
		if (i == 19 && r - l == 0) {
			if (str[l].charAt(i) == '?') {
				return c == 0 ? 26 : 27 - c;
			} else if (str[l].charAt(i) - 'a' + 1 >= c) {
				return 1;
			} else {
				return 0;
			}
		}

		long ret = f(l, r, i, c + 1);
		for (int j = l; j <= r; ++j) {
			boolean flag = true;
			for (int k = l; k <= j; ++k) {
				flag &= (str[k].charAt(i) == '?' && c > 0) || str[k].charAt(i) - 'a' + 1 == c;
			}
			if (flag) {
				ret += (j - l == 0 && i + 1 == 20 ? 1 : f(l, j, i + 1, 0)) * f(j + 1, r, i, c + 1) % MODULO;
				if (ret >= MODULO)
					ret -= MODULO;
			}
		}
		return memo[l][r][i][c] = ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 42068
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(1e5)+5;

ll modpow(ll a,ll b)
{
    ll r=1;
    while(b)
    {
        if(b&1)
        {
            r=(r*a)%modo;
        }
        b>>=1;
        a=(a*a)%modo;
    }
    return r;
}

ll ncr(int n,int r)
{
    ll ans=1;
    int lim=max(r,n-r);
    ll cc=1;
    for(ll i=lim+1;i<=n;i++)
    {
        ans=((ans*i)%modo)*modpow(cc,modo-2);
        ans%=modo;
        cc++;
    }
    return ans;
}

int main()
{
    idfc;
    int n,m;
    cin>>n>>m;

    int lim=m/n;
    int j;
    int ans=0;
    for(int i=1;i*i<=m;i++)
    {
        if(!(m%i))
        {
          if(i<=lim)
          {
              ans=max(ans,i);
          }
          j=m/i;
       //  cout<<i<<" "<<j<<"\n";
          if(j<=lim)
          {
              ans=max(ans,j);
          }
        }
    }
    cout<<ans;


    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i += 2) {
        if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {

        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 1; i < n; i += 2) {
        if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {

        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256