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

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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  auto calc_satisfaction_level = [&s,&c](int d,int i,auto last){
    int64_t res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  //-----------------------------------------------------

  int k = 50;
  vector<vector<int>> last(k,vector<int>(26));
  vector<vector<int>> ans(k,vector<int>(d));
  vector<int64_t> top_k_val(k);

  auto test_all_get_max = [&](int di,auto last){
    // 日付を引数にして全てのコンテストタイプを試してmaxscoreになるタイプを返す
    // 上位k個を返す
    vector<pair<int,int>> valtype_max(26);
    for(int type=0;type<26;++type){
      valtype_max[type] = {calc_satisfaction_level(di,type,last),type};
    }
    sort(begin(valtype_max),end(valtype_max),greater<>());
    valtype_max.erase(begin(valtype_max)+k,end(valtype_max));
    assert(size(valtype_max)==k);
    return valtype_max;
  };

  rep(di,d){
    vector<tuple<int,int,int>> next_top_k;
    next_top_k.reserve(k*26);
    rep(ki,k){
      auto tmp = test_all_get_max(di,last[ki]);
      for(int i=0;i<26;++i)next_top_k.emplace_back(tmp[i].first+top_k_val[ki],tmp[i].second,ki);
    }
    sort(begin(next_top_k),end(next_top_k),greater<>());
    next_top_k.erase(begin(next_top_k)+k,end(next_top_k));
    vector<vector<int>> nxt_last(k,vector<int>(26));
    vector<vector<int>> nxt_ans(k,vector<int>(d));
    vector<int64_t> nxt_top_k_val(k);
    rep(i,k){
      auto [val,type,prv_ki] = next_top_k[i];
      nxt_last[i] = last[prv_ki];
      nxt_last[i][type] = di+1;
      nxt_ans[i] = ans[prv_ki];
      nxt_ans[i][di] = type;
      nxt_top_k_val[i] = val;
    }
    last = nxt_last;
    ans = nxt_ans;
    top_k_val = nxt_top_k_val;
  }

  //-----------------------------------------------------

  auto t = ans[0];
  auto l = last[0];
  auto v = top_k_val[0];
  int loop_cnt = 1000;
  random_device rnd;
  mt19937 mt(rnd());
  while(loop_cnt--){
    int di = mt()%d;
    int qi = mt()%26;
    auto nt = t;
    vector<int> nl(26);
    vector<int> nv(d);
    nt[di] = qi;
    rep(i,d){
      int64_t tmp = calc_satisfaction_level(i,t[i],nl);
      if(i==0)nv[i]=tmp;
      else nv[i]=nv[i-1]+tmp;
      nl[t[i]] = i+1;
    }
    if(nv.back()>v){
      v = nv.back();
      t = nt;
      l = nl;
    }
  }
  for(auto ti:t)cout<<ti+1<<endl;

}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}
	endre;
}

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

int main() {
	int n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p;
	cin>>t;
	int len=t.size();
	int b[len];
	int ans=0;
	int flag=0;
	map<int,int>mp;
	for(int i=0;i<t.size();i++)
	{
	//	cout<<t[i]<<" "<<t[i-k]<<endl;
	/*	if(i+1-k>=0&&t[i-k]==t[i])
		{
			if(flag)flag=0;
			else flag=1;	
			if(flag)continue;
		//	cout<<"*****"<<i<<" ";
			
		}*/
		if(t[i]=='r')
		{	
			if(mp[i-k]&&t[i-k]==t[i])continue;
			ans+=p;
			mp[i]=1;
		}
		if(t[i]=='s')
		{
			if(mp[i-k]&&t[i-k]==t[i])continue;
			ans+=r;
			mp[i]=1;
		}
		if(t[i]=='p')
		{
			if(mp[i-k]&&t[i-k]==t[i])continue;
			ans+=s;
			mp[i]=1;
		}
	//	cout<<ans<<' '<<i<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8960
# Header {{{
def assert(p)
  raise 'Assertion Failed' unless p
end

# Constants {{{
INF = 10**9
# }}}

# IO {{{
class MyIO
  def initialize
    @input = $stdin
    @output = $stdout
  end

  # @param filename [String]
  def set_input(filename)
    @input = File.open(filename, 'r')
  end

  def set_output(filename)
    @output = File.open(filename, 'w')
  end

  def int
    gets.to_i
  end

  def ints
    split.map(&:to_i)
  end

  def split
    @input.gets.chomp.split(' ')
  end
  alias_method :strings, :split

  def gets
    @input.gets.chomp
  end

  def puts(*args)
    @output.puts(*args)
  end
end

io = MyIO.new
# }}}

# Algorithms {{{

def lower_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] < val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] >= val
    low
  else
    high
  end
end

def upper_bound(arr, val)
  assert(arr.is_a?(Array))
  low, high = 0, arr.size
  while high - low > 1
    mid = (low + high) / 2
    if arr[mid] <= val
      low = mid
    else
      high = mid
    end
  end
  if arr[low] > val
    low
  else
    high
  end
end

# }}}

# }}}

# io.set_input('inputs/3.txt')

commands = []
m, n = io.ints

m.times do
  conditions = []
  k = io.int
  k.times do
    skill, cond, thresh = io.strings
    skill = skill.to_i - 1
    thresh = thresh.to_i
    conditions << [skill, cond, thresh]
  end
  commands << conditions
end

skills = Array.new(n, 0)
ok = true
while ok
  skills = Array.new(n, 1e9)
  commands.each do |conditions|
    conditions.each do |condition|
      skill, cond, thresh = condition
      if cond == '<=' && skills[skill] > thresh
        skills[skill] = thresh
      end
    end
  end

  ok = false
  _s = commands.size
  commands.delete_if do |conditions|
    conditions.all? do |condition|
      skill, cond, thresh = condition
      (cond == '<=' && skills[skill] <= thresh) || (cond == '>=' && skills[skill] >= thresh)
    end
  end
  ok = true if commands.size < _s
end

if commands.size == 0
  puts 'Yes'
else
  puts 'No'
end

# vim: foldmethod=marker

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


int main() {
	int N,M;
	cin >> N>>M;
	vector<bool> an(N+1,true);
	for(int i=0;i<M;i++){
		int a;
		cin >>a;
		an.at(a)=false;
	}
	long long sn,sn1,sn2;
	sn2=1;
	sn1=1;
	bool pro = true;
	
	if(N==1){
		cout<<1<<endl;
	}
	else{
		if(!an.at(1)){
			sn1=0;
		}
		
		for(int i=2;i<N+1;i++){
			if(!an.at(i)){
				sn=0;
			}
			else{
				sn=(sn1+sn2)%1000000007;
			}
			sn2=sn1%1000000007;
			sn1=sn%1000000007;
			if(sn1==0 && sn2==0){
				pro=false;
				cout<<0<<endl;
				break;
			}
		}
		
		if(pro){
			cout<<sn%1000000007<<endl;
		}
	}
	
	
	return 0;
	
	
}


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

template<class T>
T gcd(T a, T b)
{
    while (a > 0)
    {
        T t = a;
        a = b%a;
        b = t;
    }
    return b;
}

int main()
{
    int K;
    cin>>K;
    int ans = 0;
    for (int a=1; a<=K; a++)
    for (int b=1; b<=K; b++)
    for (int c=1; c<=K; c++)
        ans += gcd(a, gcd(b, c));
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=20005;
int dp[N],a[N],b[N],n,h,ans=1e9;
int main()
{
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(int j=1;j<=20000;j++)
		dp[j]=1e9;
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];j<=20000;j++)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
			if(j>=h)
				ans=min(ans,dp[j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll a,p;
cin >> a>>p;


cout << (a*3+p)/2 << endl;
return 0;
}

Measured memory_bytes: 256
n = int(input())
red_coordinate = []
blue_coordinate = []
for i in range(n):
    a,b = map(int, input().split())
    red_coordinate.append([b,a]) #先y座標
for i in range(n):
    c, d = map(int, input().split())
    blue_coordinate.append([c,d]) #先x座標

red_coordinate.sort(reverse = True) #赤い点の座標はy座標が大きい順に並ぶ
blue_coordinate.sort() #青い点の座標はx座標が小さい順に並ぶ
ans = 0

for i in range(n): #青い点について回す
    for j in range(n): #赤い点について回す
        find = False
        if blue_coordinate[i][0] > red_coordinate[j][1] \
            and blue_coordinate[i][1] > red_coordinate[j][0]:
            ans = ans + 1
            red_coordinate[j][0] = float('inf')
            red_coordinate[j][1] = float('inf')
            find = True
        
        if find:
            break

print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_d() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();

    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i64>().unwrap())
        .collect();

    let mut max = -1 * 1_000_000_i64;
    let mut min = 1_000_000_i64;
    let mut sum = 0;

    for i in v {
        if max < i {
            max = i;
        }
        if i < min {
            min = i;
        }
        sum += i;
    }
    println!("{} {} {}", min, max, sum);
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<&str> = x.trim().split(' ').collect();

        let a = v[0].parse::<i64>().unwrap();
        let op = v[1].to_string();
        let b = v[2].parse::<i64>().unwrap();
        if op == "+".to_string() {
            println!("{}", a + b);
        } else if op == "-".to_string() {
            println!("{}", a - b);
        } else if op == "*".to_string() {
            println!("{}", a * b);
        } else if op == "/".to_string() {
            println!("{}", a / b);
        } else {
            break;
        }
    }
}

fn solve_b() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for i in 0..h {
                for j in 0..w {
                    if 1 <= i && i < h - 1 && 1 <= j && j < w - 1 {
                        print!(".");
                    } else {
                        print!("#");
                    }
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}

fn solve_a() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<u64> = x.trim()
            .split(' ')
            .map(|s| s.parse::<u64>().unwrap())
            .collect();

        let h = v[0];
        let w = v[1];
        if h == 0 && w == 0 {
            break;
        } else {
            for _i in 0..h {
                for _j in 0..w {
                    print!("#");
                }
                print!("\n");
            }
            print!("\n");
        }
    }
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int a; cin>>a;
    int b=a*a;
    int c=b*a;
    cout<<a+b+c<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
int N,C,cnt;
bool flg,visited[10][10];
vector<int> G[10];
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};
 
bool inField(int x,int y){
  if(x > y || y >= N || x < 0 || y < 0){
    return false;
  }
  return true;
}
 
bool dfs(int x,int y,int c){
  if(G[y][x] == 0) return true;
  if(G[y][x] != c || visited[y][x]) return false;
  visited[y][x] = true; cnt++;
  bool res = false;
  for(int i = 0 ; i < 6 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(!inField(nx,ny)) continue;
    res |= dfs(nx,ny,c);
  }
  return res;
}

int solve(int x,int y){
  int res = 0;
  memset(visited,false,sizeof(visited));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j <= i ; j++){
      if(G[i][j] == 0) continue;
      if(visited[i][j]) continue;
      
      cnt = 0; flg = false;
      if(dfs(j,i,G[i][j])) continue;
      res += (G[i][j] != C ? cnt : -cnt);
    }
  }
  return res;
}
 
int main(){
  int in;
  while(cin >> N >> C,(N|C)){
    for(int i = 0 ; i < N ; i++){
      G[i].clear();
      for(int j = 0 ; j <= i ; j++){
        cin >> in;
        G[i].push_back(in);
      }
    }
    int res = INT_MIN;
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j <= i ; j++){
        if(G[i][j] == 0){
          G[i][j] = C;
          res = max(res,solve(j,i));
          G[i][j] = 0;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,int> P;

static const double eps = 10e-9;

int main(){
	int n;
	vector<P> remain;
	for(int i=0;i<3;i++){
		vector<P> men;
		for(int j=0;j<8;j++){
			int num;
			double time;
			
			scanf("%d %lf",&num,&time);
			men.push_back(P(time,num));
		}

		sort(men.begin(),men.end());
		printf("%d %.2lf\n",men[0].second,men[0].first);
		printf("%d %.2lf\n",men[1].second,men[1].first);
		for(int j=2;j<men.size();j++) remain.push_back(men[j]);
	}

	sort(remain.begin(),remain.end());
	printf("%d %.2lf\n",remain[0].second,remain[0].first);
	printf("%d %.2lf\n",remain[1].second,remain[1].first);

}

Measured memory_bytes: 0
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

const p = 1000000007

func main() {
  NK := NextIntVec()
  N, K := NK[0], NK[1]
  R := 1
  for R * R <= N {
    R++
  }
  R--
  A := make([]int, R + 1)
  B := make([]int, R + 1)
  for i := 1; i <= R; i++ {
    A[i] = N / i
  }
  B[R] = A[R] - R
  for i := R - 1; 0 < i; i-- {
    B[i] = A[i] - A[i + 1]
  }
  TA := make([][]int, K + 1)
  SA := make([][]int, K + 1)
  TB := make([][]int, K + 1)
  SB := make([][]int, K + 1)
  for i := range TA {
    TA[i] = make([]int, R + 1)
    SA[i] = make([]int, R + 1)
    TB[i] = make([]int, R + 1)
    SB[i] = make([]int, R + 2)
  }
  TA[0][1] = 1
  for i := 1; i <= R; i++ {
    SA[0][i] = 1
  }
  for i := 1; i <= K; i++ {
    for j := 1; j <= R; j++ {
      TA[i][j] = (SA[i - 1][R] + SB[i - 1][j]) % p
      SA[i][j] = (SA[i][j - 1] + TA[i][j]) % p
    }
    for j := R; 0 < j; j-- {
      TB[i][j] = SA[i - 1][j] * B[j] % p
      SB[i][j] = (SB[i][j + 1] + TB[i][j]) % p
    }
  }
  Write((SA[K][R] + SB[K][1]) % p)
  Output()
}

Measured memory_bytes: 104704
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0]){
    int hit =0,blow = 0;
    for(int i=1;i<4;i++)
      cin >> a[i];
    for(int i=0;i<4;i++)
      cin >> b[i];
      for(int k=0;k<4;k++){
        for(int j=0;j<4;j++){
      if(a[k]==b[j]){
        if(k==j) hit++; 
        else blow++;
      }
    }
      }
      cout << hit <<" "<< blow <<endl;
  }
}

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

int main(){
    int n;
    double a;
    cin >> n;
    if(n % 2 == 0){
        a = n / 2;
    }
    else{
        a = n / 2 + 1;
    }
    cout << a / n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<chrono>
#include<set>
#include<cstdio>
#include<string>
#include<unordered_map>

using namespace std;
typedef long long ll;
const int mod=1e9+7;

ll qpow(ll a,ll n){
    ll res=1;
    while(n)
    {
        if(n&1) 
          res = res*a%mod;
        a=a*a%mod;
        n >>= 1;
    }
    return res;
}

int n,m;
ll ans,f[2000005]={1}, inv[2000005]={1};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for(int i=1;i<=2e6+3;i++){
        f[i] = f[i-1] * i%mod;
        inv[i] = qpow(f[i],mod-2); //质数模下的逆元，根据费马定理
    }
    int K;
    long long ans = 0;
    string S;
    cin >> K >> S;
    int n = S.length();
    for(int i = 0; i <= K; i++){
        ans = (ans + qpow(26,i)%mod*f[n+K-i-1]%mod*inv[n-1]%mod*inv[K-i]%mod*qpow(25,K-i)%mod)%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 35712
#include<iostream>
#include<set>
using namespace std;
typedef pair<int,int> P;

set<P> data;
set<P>star;

bool dfs(set<P>::iterator d,set<P>::iterator s){
	if(d==data.end())return false;
	if(s==--star.end())return true;
	set<P>::iterator tmp=++s;
	--s;
	P now=P((*tmp).first-(*s).first,(*tmp).second-(*s).second);
	P next=P((*d).first+now.first,(*d).second+now.second);
	
	return dfs(data.find(next),++s);
}

int main(){
	int n;
	while(cin>>n && n){
		data.clear();
		star.clear();
		for(int i=0;i<n;i++){
			P a;
			cin>>a.first>>a.second;
			star.insert(a);
		}
		int m;
		cin>>m;
		for(int i=0;i<m;i++){
			P a;
			cin>>a.first>>a.second;
			data.insert(a);
		}
		P ans;
		for(set<P>::iterator itr=data.begin();itr!=data.end();itr++){
			if(dfs(itr,star.begin()))ans=P((*itr).first-(*star.begin()).first,(*itr).second-(*star.begin()).second);
		}
		
		cout<<ans.first<<" "<<ans.second<<endl;
	}
}

Measured memory_bytes: 1252
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    vi h = H;
    int cnt = 0;
    int l = 0;
    while(l<N) {
        bool done = false;
        for(int r=l; r<N && h[r]>0; r++) {
            h[r]--;
            done = true;
        }        
        if (done) cnt++;
        if (h[l] == 0) l++;
    }

    int ans = cnt;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,K=input(),int(input())
m=len(n)

DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)]
DP[0][0][0]=1

for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k!=0:DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]
                else:DP[i][flag or k<num][j] +=DP[i-1][flag][j]

print(DP[m][0][K]+DP[m][1][K])

Measured memory_bytes: 41328
#include<stdio.h>

int fib(int);
int F[44];

int main(){
  int n, a;
  scanf("%d", &n);

  a = fib(n);

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

  return 0;
}

int fib(int n){

  if(n == 0 || n == 1)
    return 1;

  if(F[n] > 0)
    return F[n];

  return F[n] = fib(n -2) + fib(n - 1);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
    int n,a,b,cnt;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        if(s<a||s>=b){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

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

int main(){
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 36
int main(){

  int i,j,n,min,flag=0;
  int swap,N1[N],N2[N];
  char tmp,data1[N][2],data2[N][2];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N1[i]=i;
    scanf("%s",&data1[i]);
  }
  for(i=0;i<n;i++){
    N2[i]=i;
    strcpy(data2[i],data1[i]);
  }
  
  /*Bubble sort*/
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(data1[j][1]-'0'<data1[j-1][1]-'0'){
	tmp=data1[j][1];
	data1[j][1]=data1[j-1][1];
	data1[j-1][1]=tmp;
	tmp=data1[j][0];
	data1[j][0]=data1[j-1][0];
	data1[j-1][0]=tmp;
	swap=N1[j];
	N1[j]=N1[j-1];
	N1[j-1]=swap;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%c%c\n",data1[i][0],data1[i][1]);
    }
    else{
      printf("%c%c ",data1[i][0],data1[i][1]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(data1[i][1]==data1[j][1] && N1[i]>N1[j]){
	flag=1;
	break;
      }
    }
    if(flag==1) break;
  }
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");
  flag=0;
  
  /*Selection sort*/
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(data2[j][1]-'0'<data2[min][1]-'0'){
	min=j;
      }
    }
    tmp=data2[i][1];
    data2[i][1]=data2[min][1];
    data2[min][1]=tmp;
    tmp=data2[i][0];
    data2[i][0]=data2[min][0];
    data2[min][0]=tmp;
    swap=N2[i];
    N2[i]=N2[min];
    N2[min]=swap;
  }
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%c%c\n",data2[i][0],data2[i][1]);
    }
    else{
      printf("%c%c ",data2[i][0],data2[i][1]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(data2[i][1]==data2[j][1] && N2[i]>N2[j]){
	flag=1;
	break;
      }
    }
    if(flag==1) break;
  }
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int K;
  cin >> K;
  int64_t d,e;
  d =0;
  e =0;
    
  for ( int i=1; i < K+1 ; i++ )
  {
    for ( int j=1 ; j < K+1 ; j++)
    {
      for (int l=1 ; l  < K+1 ; l++)
      {
        e = e + gcd(gcd(i,j),l);
      }
    }
  }
  cout << e << endl;
}

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

int main() {
  	char b;
	cin >> b;
  	switch(b) {
      case 'A':
        cout << 'T' << endl;
 		break;
      case 'T':
        cout << 'A' << endl;
        break;
      case 'C':
        cout << 'G' << endl;
        break;
      case 'G':
        cout << 'C' << endl;
        break;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
char ch[5] ;
int main() {
	scanf("%s", ch);
	if(ch[0]>='a'&&ch[0]<='z') cout<<'a';
	else cout<<'A';
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
 
int main (){
  ll k,a,b;cin>>k>>a>>b;
  bool ok = false;
  for (int i = a;i<=b;i++){
    if (i%k == 0){
      ok = true;
    }
  }
  if (ok){
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}

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

long long const INF = 1001001001001001001;

int main() {
    int N; cin >> N;
    vector<long long> A(N + 1);
    for(int i=0; i<=N; ++i) cin >> A[i];

    if(N == 0) {
        if(A[0] == 1) cout << "1\n";
        else cout << "-1\n";
        return 0;
    }

    if(A[0] != 0) {
        cout << "-1\n";
        return 0;
    }

    vector<long long> mi(N + 1, 0), ma(N + 1, 0);
    mi[N] = A[N]; ma[N] = A[N];
    for(int i = N - 1; i >= 0; --i) {
        mi[i] = (mi[i + 1] + 1) / 2 + A[i];
        ma[i] = ma[i + 1] + A[i];
    }

    long long res = 1;
    ma[0] = 1;
    for(int i=1; i<N; ++i) {
        ma[i] = min(ma[i], (ma[i - 1] - A[i - 1]) * 2);
        if(ma[i] < A[i] || mi[i] > ma[i]) {
            cout << "-1\n";
            return 0;
        }
        res += ma[i];
    }
    res += A[N];
    cout << res << '\n';
}

Measured memory_bytes: 5580
n, p = map(int, input().split())
s = list(map(int, input()))
if p == 2 or p == 5:
    ans = 0
    for i, digit in enumerate(s):
        if digit % p == 0:
            ans += i + 1
    print(ans)
else:
    ans = 0
    ten_pow_i_mod = 1
    #rev_s_mod = []
    temp_mod = 0
    mod_multiset = [1] + [0] * (p - 1)
    for digit in reversed(s):
        temp_mod += digit * ten_pow_i_mod
        temp_mod %= p
        #rev_s_mod.append(temp_mod)
        ans += mod_multiset[temp_mod]
        mod_multiset[temp_mod] += 1
        ten_pow_i_mod *= 10
        ten_pow_i_mod %= p
    print(ans)

Measured memory_bytes: 48076
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[55],Patty[55];
int Solve(int Level,int Layer)
{
	if(Layer==0) return 0;
	if(Level==0) return 1;
	if(Layer==1) return 0;
	if(Layer==dp[Level-1]+1) return Patty[Level-1];
	if(Layer==dp[Level-1]+2) return Patty[Level-1]+1;
	if(Layer==dp[Level]-1) return Patty[Level];
	if(Layer==dp[Level]) return Patty[Level];
	if(Layer<dp[Level-1]+1) return Solve(Level-1,Layer-1);
	return Patty[Level-1]+1+Solve(Level-1,Layer-2-dp[Level-1]);
}
signed main()
{
	int N,X;
	cin>>N>>X;
	dp[0]=1,Patty[0]=1;
	for(int i=1;i<=N;i++) dp[i]=dp[i-1]*2+3,Patty[i]=(dp[i]+1)/2;
	cout<<Solve(N,X)<<endl;
	return 0;
}

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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a;
	cin>>a;
	cout<<a[0]<<(a.size()-2)<<a[a.size()-1];
	return 0;
}

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

#define ll long long

const int inf = 1e9+5;

int main() {
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for(int &x:h) cin >> x ;
  vector<int> dp(n, inf); dp[0] = 0;
  
  for(int i=0; i<n; i++){
    for(int j = i+1; j<=i+k; j++){
      if(j<n){
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      }
    }
  }

cout << dp[n-1] << "\n" ;

}
  

Measured memory_bytes: 1024
using System;
using System.Linq;

public class B{
  static void Main(string[] args)
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).OrderByDescending(x => x).ToArray();
    Console.WriteLine(inputs[0] * 10 + inputs[1] + inputs[2]);
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;
using namespace atcoder;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll op(ll a, ll b){
    return max(a,b);
}

ll e(){
    return -1;
}

void solve(){
    ll n,k;
    cin >> n >> k;
    segtree<ll,op,e> seg(300010);
    rp(i,300002) seg.set(i,0);

    rp(i,n){
        ll a;
        cin >> a;
        ll L=max(a-k,0ll);
        ll R=min(a+k,300001ll);
        ll tmp=seg.prod(L,R+1)+1;
        seg.set(a,tmp);
    }
    print(seg.all_prod());
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 13776
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	REP(i, N) cin >> X[i];
	
	int ans = INF;
	REP(x, 101) {
		int cur = 0;
		REP(i, N) cur += (X[i] - x)*(X[i] - x);
		chmin(ans, cur);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <cstring>
using namespace std;


int main(){
	int N;cin>>N;
	int A[N+1]; memset(A,0,sizeof(A));
	for(int i=2; i<=N; ++i){
		int x;cin>>x;
		A[x]++;
	}
	for(int i=1; i<=N; ++i) cout<<A[i]<<'\n';
}

Measured memory_bytes: 4416
#include<iostream>
#include<cstdio>
using namespace std;
int a[24 * 60 * 60+10];
int main() {
	long long a1, m1, a2, m2, a3, m3;
	int n;
	while (cin >> n&&n != 0) {
		int h1, m1, s1, h2, m2, s2;
		fill(a, a + 60 * 24 * 60+10, 0);
		int sum = 0;
		for (int i = 0; i<n; i++) {
			scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			bool k = false;
			for (int i = h1 * 3600 + m1 * 60 + s1; i<h2 * 3600 + m2 * 60 + s2; i++) {
				a[i]--;
				if (a[i] < 0) {
					sum++;
					for (int i = 0; i < 24 * 60 * 60+10; i++) a[i]++;
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005

vector<int> adj[MAXN];
bool visited[MAXN]={0};
vector<int> dfs;
map<int,int> v1;
map<int,int> end1;
int tim=0;
void DFSUtil(int v) 
{ 	
	tim++;
	v1[v] = tim;
    visited[v] = true; 
    dfs.pb(v);
    for (auto i = adj[v].begin(); i != adj[v].end(); ++i) 
        if (!visited[*i]) 
            DFSUtil(*i);
    end1[v] = tim;         
} 
int partial[MAXN]={0};
int anss[MAXN]={0};

signed main() 
{ 
int n,k,x,a,b,q,c,d,v;
	
	cin>>n>>q; 
	For(i,0,n-1){
		cin>>a>>b;
		adj[a].pb(b);
	}
	DFSUtil(1);
	For(i,0,q){
		cin>>a>>v;
		partial[v1[a]-1]+=v;
		partial[end1[a]]-=v;			
	}
	For(i,1,n+1){
		partial[i]+=partial[i-1];
		// cout<<partial[i]<<" ";

	}


	For(i,0,dfs.size()){
		anss[dfs[i]-1]=partial[i];
	}
	For(i,0,n){
		cout<<anss[i]<<" ";
	}

	
} 



Measured memory_bytes: 55664
tmp = [int(i) for i in input().split(" ")]
m = tmp[0]
d = tmp[1]
if d < 22 or m<4:
    count = 0
else:
    count = 0
    for j in range(4,m+1):        
        for i in range(22, d+1):
            if i%10 < 2:
                continue
            if (int(i%10) * int(i//10)) == j:
                count += 1
print(count)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        string[] kionmo = ReadLine().Split(' ');
        int kion = int.Parse(kionmo[0]);
        int moku = int.Parse(kionmo[1]);
        string[] hyokol = ReadLine().Split(' ');
        double minsa = 99999999;
        int titen = 0;
        for(int i=0;i<kazu;i++){
            int hyoko = int.Parse(hyokol[i]);
            double hiku = (double)(hyoko*6)/1000;
            double kionh = (double)kion - hiku;
            double sa = Abs(kionh - (double)moku);
//            WriteLine(kionh);
//            WriteLine(sa);
            if(minsa > sa){
                minsa = sa;
                titen = i+1;
            }
        }
        WriteLine(titen);
    }
}

Measured memory_bytes: 13212
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>
#include <set>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 1000000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
ll calc(int x, int k);
ll comb(int x, int k);

/* main */
int main(){

    string N; cin >> N;
    int K; cin >> K;

    ll ans = 0;

    int digit = N.size();
    for (int i = 0; i < N.size() && K > 0; i++) {
        int a_i = N[i] - '0';
        //cout << "a_i : " << a_i << '\n';
        digit--;
        //cout << "digit : " << digit << '\n';
        if (a_i == 0) {
            continue;
        }
        if (K == 1) {
            ans += a_i;
        }
        if (K >= 1) {
            //cout << calc(digit, K) << '\n';
            ans += calc(digit, K);
        }
        a_i--;
        if (a_i) {
            if (K >= 2) {
                // cout << a_i * calc(digit, K-1) << '\n';
                ans += a_i * calc(digit, K-1);
            }
        }
        K--;
    }

    cout << ans << '\n';

    return 0;
}


ll calc(int x, int k) {

    return comb(x, k) * pow(9, k);
}

ll comb(int x, int k) {
    
    ll ret = 1;
    for (ll i = 1; i <= k; i++) {
        ret *= x - (i - 1);
        ret /= i;
    }
    return ret;

}


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


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

using namespace std;
using ll = long long;

const ll mx = LLONG_MAX;

int n;
vector<ll> h, dp;

int main(){
    cin>>n;
    h.resize(n); dp.resize(n);
    for(int i = 0; i < n; i++){
        cin>>h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
    }
    ll res = dp[n-1];
    cout<<res<<endl;
    return 0;
}

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

int main(){	
	int n; cin >> n;
	n = n % 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
		cout << "hon" << endl;
	if(n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon" << endl;
	if(n == 3)
		cout << "bon" << endl;

	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            agc001_a();
        }

        static void agc001_a()
        {
            // A - BBQ Easy
            int n = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            // 長い順に並べて、2本取ったときの短いほうが律速
            Array.Sort(L);
            Array.Reverse(L);
            int ans = 0;
            for (int i=1; i<n*2; i=i+2) ans += L[i];
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
from sys import stdin
from itertools import product

s = stdin.readline().rstrip()

li = ["+","-"]
for i in range(8):
    lin = list(product(li, repeat=3))

def game(a,b,c):
    if c == "-":
        return(a-b)
    else:
        return(a+b)

for j in lin:
    a = game(int(s[0]),int(s[1]),j[0])
    a = game(a,int(s[2]),j[1])
    a = game(a,int(s[3]),j[2])
    if a == 7:
        print(s[0]+j[0]+s[1]+j[1]+s[2]+j[2]+s[3]+str("=7"))
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;


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

	n = n % 500;

	if(n <= a)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}


Measured memory_bytes: 256
N = int(input());    # N 1≤N≤10^5
Hi = [int(i) for i in input().split()]; #Hi 1≤Hi≤10^9

#A = list1[0];   #A個口の電源タップ
#B = list1[1];   #未使用の差込口を B口以上に拡張したい
#print(N)
#print(Hi[1]);

#lack   = B % (A-1); #足りない個数
#supply = B / (A-1); #最低いる数 

count_total =0;
count = 0;
for i in range(N-1) :
    if (Hi[i] >= Hi[i+1]) :
        count +=1; 
    if (Hi[i] < Hi[i+1]) :
        count =0;
    if(count > count_total):
        count_total = count;
print(count_total);

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main() {
    int tbl[10001];
    fill(tbl, tbl+10001, 1);
    for (int i=2; i<10001; ++i) {
        for (int j=i*2; j<10001; j+=i) {
            tbl[j] = 0;
        }
    }

    int n;
    while (cin >> n && n != 0) {
        for (int i=n; i>=5; --i) {
            if (tbl[i] && tbl[i-2]) {
                cout << i-2 << " " << i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
char t[100][100];
bool visited[100][100];
bool a,b;
int h,w,cnt;
void rec(int y,int x){
  if(t[y][x]=='B')a=true;
  if(t[y][x]=='W')b=true;
  if(t[y][x]!='.')return;
  if(visited[y][x])return;
  visited[y][x]=true;
  cnt++;
  if(y>0)rec(y-1,x);
  if(y+1<h)rec(y+1,x);
  if(x>0)rec(y,x-1);
  if(x+1<w)rec(y,x+1);
}
int main(){
  while(1){
    cin>>w>>h;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
    cin>>t[i][j],visited[i][j]=false;
    int suma=0,sumb=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    if(visited[i][j])continue;
    if(t[i][j]!='.')continue;
    a=b=cnt=false;
    rec(i,j);
    if(a&&!b)suma+=cnt;
    else if(!a&&b)sumb+=cnt;
      }
    }
    cout<<suma<<' '<<sumb<<endl;
  }
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,su,mh,dh;
    scanf("%d%d",&a,&b);
    su =a+b;
    mh =a-b;
    dh =a*b;
    if(su>=mh && su>=dh){
        printf("%d\n",su);
    }
    else if(mh>=dh && mh>=su){
        printf("%d\n",mh);
    }
    else{
        printf("%d\n",dh);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c <= a + b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();
		a=a-1;
 
        long s1=a-(a/c+a/d-a/lcm(c,d));
        long s2=b-(b/c+b/d-b/lcm(c,d));
 
        System.out.println(s2-s1);
        sc.close();
    }
 
    static long gcd(long a,long b) {
        if(b%a==0) {
            return a;
        }
        return gcd(b%a,a);
    }
 
    static long lcm(long a,long b) {
        return a*b/gcd(a,b);
	}
}

Measured memory_bytes: 27076
#include<bits/stdc++.h>
#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 K;
    cin >> K;

    ll ans=0;
    rep(i, K+1)rep(j, K+1)rep(k, K+1){
        if(i*j*k!=0){
            ans+=gcd(i, gcd(j, k));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 2600
int a[N][27];
int a2[N][27];
int e[N][365];
int v[N][365];
int sz, sz2;

int main() {
	int n;
	int x, y;
	vector<pair<int,pair<int,int> > >b;
	int c[26];
	int d[365][26];
	int ans[365];
	scanf("%d", &n);
	f(i, 26)scanf("%d", &c[i]);
	f(i, n) {
		f(j, 26)scanf("%d", &d[i][j]);
	}
	sz = 1;
	f(i, 26)a[0][i] = -1;
	a[0][26] = 0;
	f(t, n) {
		b.clear();
		f(i, sz) {
			x = a[i][26];
			f(j, 26) {
				x -= ((t - a[i][j])*c[j]);
			}
			f(j, 26) {
				y = x + d[t][j];
				y += ((t - a[i][j])*c[j]);
				b.push_back(make_pair(y, make_pair(i, j)));
			}
		}
		sort(b.begin(), b.end(), greater<pair<int, pair<int,int> > >());
		sz2 = b.size();
		if (sz2 > N)sz2 = N;
		f(i, sz2) {
			x = b[i].second.first;
			y = b[i].second.second;
			a2[i][26] = b[i].first;
			f(j, 26)a2[i][j] = a[x][j];
			a2[i][y] = t;
			e[i][t] = x;
			v[i][t] = y;
		}
		f(i, sz2) {
			f(j, 27)a[i][j] = a2[i][j];
		}
		sz = sz2;
	}
	x = 0;
	for (int i = n - 1; i >= 0; i--) {
		ans[i] = v[x][i];
		x = e[x][i];
	}
	f(i, n)printf("%d\n", ans[i]+1);

	return 0;
}


Measured memory_bytes: 12460
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[1020];
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int anss = 0,ansm = 100*a;
    double dense = 0;
    rep(i,31){
        rep(j,31){
            rep(m,101){
                rep(n,101){
                    int water = i*100*a+j*100*b,sugar = m*c+n*d;
                    if (water*e/100 < sugar) continue;
                    if (water+sugar > f) continue;
                    double k = 100.0*sugar/(double)(water+sugar);
                    if (k > dense){
                        ansm = water+sugar;
                        anss = sugar;
                        dense = k;
                    }
                }
            }   
        }
    }
    PRINT(ansm << " " << anss);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
   int result =0;
if(a>b){
 result =a-1;
}else{
result =a;
 }
 System.out.println(result);
 }
}


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



int main(void)
{
    int n, l;
    cin >> n >> l;
    int sum = 0;
    int tmp = 1000;
    rep(i, n)
    {
        if(abs(tmp) > abs(l + i)) tmp = l + i;
        sum += l + i;
    }
    cout << sum - tmp << endl;
    return 0;
}

Measured memory_bytes: 256