akhauriyash/Code-Regression huggingface dataset:
# require 'pry'

N = gets.chomp.to_i
V = gets.chomp.split(' ').map(&:to_i)


denominator = 2**(N-1)

V.sort!

@sum = 0
V.each_with_index do |v, i|
  if i < 2
    @sum += v
  else
    @sum += v*(2**(i-1))
  end
end

puts ans = @sum.to_f / denominator


# binding.pry


Measured memory_bytes: 1788
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    int N;cin>>N;
    ll sum = 0;
    for(int i=1;i<=N;i++){
        if(i%3!=0&&i%5!=0){
            sum += i;
        }
    }
    cout << sum << endl;
}

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

struct edge{
    int to;
    int cost;
    edge(int a, int b){
        to=a;
        cost=b;
    }
};
typedef pair<long long, int> P;

struct D{
    vector<edge> G[200008];
    long long d[200008],INF=1e18;

    void AddEdge(int from, int to, int cost){
        G[from].push_back(edge(to, cost));
    }

    void dijkstra(int n, int s){
        priority_queue<P, vector<P>, greater<P> > q;
        fill(d,d+n,INF);
        d[s]=0;
        q.push(P(0,s));
        while(!q.empty()){
            P p=q.top();
            q.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    q.push(P(d[e.to],e.to));
                }
            }
        }
    }
};

int main(void){
    int n, q, k;
    D d;
    cin >> n;
    for(int i=0;i<n-1;i++){
        int a, b, c;
        cin >> a >> b >> c;
        d.AddEdge(--a, --b, c);
        d.AddEdge(b, a, c);
    }
    cin >> q >> k;
    d.dijkstra(n, --k);
    for(int i=0;i<q;i++){
        int x, y;
        cin >> x >> y;
        cout << d.d[--x] + d.d[--y] << endl;
    }
}


Measured memory_bytes: 12020
#include "stdio.h"

int main()
{
	//入力用の変数
	int r = 0, g = 0, b = 0;
	//三桁の整数に変換して格納するための変数
	int number = 0;

	//標準入力
	scanf("%d %d %d", &r, &g, &b);

	//カードの数字をつなげて三桁の整数にする
	number = 100 * r + 10 * g + b;

	//４の倍数かどうか判定
	if (number % 4 == 0)
		printf("YES");
	else
		printf("NO");


    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int ans = 0, m = 1;
    REP(i, n){
        if(v[i] == m){
            m++;
        }else{
            ans++;
        }
    }
    cout << (ans == n ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 1024
o = list(input())
e = list(input())
ans = []

count = 0

if len(o) > len(e):
    for i in range(len(e)):
        ans.append(o[i])
        ans.append(e[i])
    ans.append(o[-1])
elif len(o) < len(e):
    for i in range(len(o)):
        ans.append(o[i])
        ans.append(e[i])
    ans.append(e[-1])
else:
    for i in range(len(o)):
        ans.append(o[i])
        ans.append(e[i])

print("".join(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> l(n);
  	int sum = 0;
    for (int i=0; i<n; ++i) {
        cin >> l[i];
      	sum += l[i];
    }
    int max = *max_element(l.begin(), l.end());

    //cout << "max = " << max << endl; 
    //cout << "sum = " << sum << endl; 

 	if (max < sum - max) {
	    cout << "Yes" << endl;
    } else {
	    cout << "No" << endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
/* List of Top 3 Hills */
#include <iostream>
using namespace std;

int main(void) {
  int height[3] = {0,0,0};
  int n;
  while(cin >> n) {
    if (n > height[0]) {
      height[2] = height[1];
      height[1] = height[0];
      height[0] = n;
    }
    else if (n > height[1]) {
      height[2] = height[1];
      height[1] = n;
    }
    else if (n > height[2]) {
      height[2] = n;
    }
  }

  for (int i = 0; i < 3; i++) {
    cout << height[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int k,n;

int main(){
	cin>>k>>n;
	vi a;
	if(n==1) a=vi(n,(k+1)/2);
	else if(k%2==0){
		a=vi(n,k);
		a[0]=k/2;
	}
	else{
		a=vi(n,k/2+1);
		for(int i=0;i<n/2;i++){
			int l=0,r=n;
			while(r-l>1){
				int m=(l+r)/2;
				if(a[m]) l=m;
				else r=m;
			}
			a[l++]--;
			if(a[l-1]) while(l<n) a[l++]=k;
		}
	}
	cout<<a[0];
	for(int i=1;i<n&&a[i];i++) cout<<' '<<a[i];
	cout<<endl;
}

Measured memory_bytes: 3456
import numpy as N;p=print;i=int;n=i(input());c=i(N.sqrt(n*2))
if c**2+c-n*2:p('No')
else:a=N.zeros((c+1,c),i);t=N.triu_indices(c);a[t]=a[1:].T[t]=N.arange(n)+1;p('Yes');p(c+1);[p(c,*r)for r in a]

Measured memory_bytes: 20428
using System;

public class my
{
	public static void Main()
	{
		var n = my.GetInt();
		var A = my.GetIntArray(n);
		
		var q = my.GetInt();
		var M = my.GetIntArray(q);
		
		foreach(var m in M) {
			Console.WriteLine(my.Solve(A, 0, m)? "yes" : "no");
		}
	}
	
	private static bool Solve(int[] A, int i, int m)
	{
		if(m==0)	return true;
		if(i >= A.Length)	return false;
		
		return my.Solve(A, i+1, m) || my.Solve(A, i+1, m-A[i]);
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');
		
		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
}

Measured memory_bytes: 8968
import sys
sys.setrecursionlimit(2 * 10**5)
N,M = map(int,input().split())

par = [i for i in range(N+M)]
def root(a):
    if par[a] == a: return a
    par[a] = root(par[a])
    return par[a]

def same(a,b):
    return root(a) == root(b)

def unite(a,b):
   ra,rb = root(a),root(b)
   if ra == rb: return
   par[ra] = rb

for i in range(N):
    src = list(map(lambda x:int(x)-1,input().split()))
    if len(src) == 1: continue
    for j in src[1:]:
        unite(i,N+j)

for i in range(1,N):
    if not same(0,i):
        print('NO')
        exit()
print('YES')

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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, b * c, b * d}) << endl;
    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;

  if(a+b>=10)
    cout << "error";
  else
  {
    cout << a + b;
  }
  


}


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

bool isPalindrome(string s){
    string t = s;
    reverse(t.begin(),t.end());
    return s == t;
}

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if(!isPalindrome(s)) ans = false;
    if(!isPalindrome(s.substr(0, s.size()/2))) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3628
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
ans=0
for i in range(n-1,-1,-1):
  m=a[i]%b[i]
  if m:ans+=b[i]-m
  a[i-1]+=ans
print(ans)

Measured memory_bytes: 21440
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n,c=-1,l=0,r=-1,a[maxn]={},b[maxn]={},h[maxn]={};
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),h[n-i+1]=b[i];
	for(int i=1;i<=n;i++)b[i]=h[i];
	for(int i=1;i<=n;i++)if(a[i]==b[i]){c=a[i];break;}
	for(int i=1;i<=n;i++)if(a[i]==c&&b[i]==c){l=i;break;}
	for(int i=n;i>=1;i--)if(a[i]==c&&b[i]==c){r=i;break;}
	for(int i=1;i<=n;i++)if(a[i]!=c&&b[i]!=c&&l<=r)swap(b[l],b[i]),l++;
	if(l<=r)printf("No");
	else{printf("Yes\n");for(int i=1;i<=n;i++)printf("%d ",b[i]);}
	return 0;
}

Measured memory_bytes: 6164
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 ans = 1;
map<int,int> mp;

int func(int n){
  for(int i = 2;i * i <= n;i++){
    while(n % i == 0){
      mp[i]++;
      n /= i;
    }
  }
  if(n != 1) mp[n]++;
}

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

  rep(i,1,n){
    func(i);
  }

  i64 MOD = 1e9+ 7;

  for(auto& a : mp){
    ans = (ans * (a.second + 1)) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$a = $key->A[0];
$b = $key->X[0][0];

if ($a > $b) {
  printf("GREATER\n");
  exit;
}
if ($a < $b) {
  printf("LESS\n");
  exit;
}
printf("EQUAL\n");


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int a,b;
    cin>>a>>b;
    if(b*2>a){
        cout<<0<<endl;
    }
    else{
        cout<<a-b*2<<endl;
    }
}


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

int alpha[26];


int main() {
    
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        alpha[s[i] - 'a']++;
    }
    
    for (int i = 0; i < 26; i++) {
        if (alpha[i] % 2) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    
    return 0;
}



Measured memory_bytes: 256
package main

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

func Solve() {
  var N, M, A, B int
  NextInt(&N, &M)
  R := make([]int, N)
  for i := range R { R[i] = i }
  var Find func(int)int
  Find = func(u int) int {
    if u == R[u] { return u }
    R[u] = Find(R[u])
    return R[u]
  }
  Unite := func(u, v int) {
    ru, rv := Find(u), Find(v)
    if ru < rv {
      R[rv] = ru
    } else {
      R[ru] = rv
    }
  }
  for i := 0; i < M; i++ {
    NextInt(&A, &B)
    A--; B--
    Unite(A, B)
  }
  G := make([]int, N)
  for _, r := range R { G[Find(r)]++ }
  Write(MaxInt(G...))
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

class ConvexHullTrick {
    struct Line {
        ll a, b;
        ll get(const ll &x) { return a * x + b; }
    };
    deque<Line> que;
    inline bool check(const Line &a, const Line &b, const Line &c) {
        return (b.b - c.b) * (b.a - a.a) <= (a.b - b.b) * (c.a - b.a);
    }

  public:
    inline void add(const ll &a, const ll &b) {
        Line l{a, b};
        while(que.size() > 1 && check(que[que.size() - 2], que.back(), l))
            que.pop_back();
        que.emplace_back(l);
    }
    inline ll query(const ll &x) {
        if(que.empty()) return INT64_MAX;
        while(que.size() > 1 && que[0].get(x) >= que[1].get(x))
            que.pop_front();
        return que[0].get(x);
    }
};

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

    int n;
    ll C;
    cin >> n >> C;
    V<ll> h(n);
    rep(i, n) cin >> h[i];
    ConvexHullTrick cht;
    V<ll> dp(n);
    cht.add(-2 * h[0], h[0] * h[0]);
    FOR(i, 1, n) {
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    cout << dp.back() << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  long double sa, sb, sc, eps;
  sa = sqrtl(a);
  sb = sqrtl(b);
  sc = sqrtl(c);
  eps = 1.0E-14;
  if (sa + sb + eps < sc) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
S = input()
if S == 'SUN':
  print(7)
elif S =='MON':
  print(6)
elif S =='TUE':
  print(5)
elif S =='WED':
  print(4)
elif S =='THU':
  print(3)
elif S =='FRI':
  print(2)
elif S =='SAT':
  print(1)
  

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

int main(){
    using ll = long long;
    constexpr ll MOD = 1'000'000'007;
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll k = K; k <= N + 1; ++k) {
        ll up = N*(N+1) / 2 - (N-k)*(N-k+1)/2;
        ll lo = (k-1)*k / 2;
        ans += up - lo + 1;
        ans %= MOD;
    } // end k
    cout << ans << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=1e9+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    int n;
    cin>>n;
    string s1, s2;
    cin>>s1>>s2;
    int ans=1;
    int i=1;
    if(s1[0]==s2[0])
        ans=3;
    else
        ans=6, i++;
    for(;i<n;i++)
    {

        if(s1[i-1]!=s2[i-1])
        {
            if(s1[i]==s2[i])

                ans=(ans);
            else if(s1[i]!=s2[i])
            {
                ans=(ans*3)%mod;
                i++;
            }
        }
        else

        {

            if(s1[i]==s2[i])

                ans=(ans*2)%mod;
            else if(s1[i]!=s2[i])
            {
                ans=(ans*2)%mod;
                i++;
            }
        }
    }
    cout<<ans%mod<<endl;
}
signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int h1,m1,h2,m2,k;
	scan(h1>>m1>>h2>>m2>>k);
	prin(h2*60+m2-h1*60-m1-k);
	return 0;
}


Measured memory_bytes: 3592
from collections import Counter
N = int(input())
blue = []
for _ in range(N):
    blue.append(input())
blue = Counter(blue)

M = int(input())
red = []
for _ in range(M):
    red.append(input())
red = Counter(red)

diff = blue - red
if len(diff)==0:
    print(0)
else:
    print(max(diff.values()))

Measured memory_bytes: 38384
#include<stdio.h>
#define MAX 2000000
int H,A[MAX+1];
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapity(int i){
  int l,r,large,t;
  l=left(i);
  r=right(i);
  if(l<=H&&A[l]>A[i])large=l;
  else large=i;
  if(r<=H&&A[r]>A[large])large=r;
  if(large!=i){
    t=A[i];
    A[i]=A[large];
    A[large]=t;
    maxHeapity(large);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=H/2;i>=1;i--){
    maxHeapity(i);
  }

  for(i=1;i<=H;i++){
    //if(i>1) printf(" ");
    printf(" %d",A[i]); 
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3648
# 結局出ていくのと入ってくるのを比較すればいいのか？
N,K = map(int,input().split())
A = list(map(int,input().split()))

for i in range(K,N):
    if A[i]>A[i-K]:
        print('Yes')
    else:
        print('No')


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



int main() {
    int x;
    cin >> x;
    
    if(x)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    
    
    return 0;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define pb push_back


using namespace std;


int main() {
  //cout << "Hello world";
  ll b = 26;
  ll n;
  cin >> n;
  n--;
  string ans = "";
  while(n >= 0) {
    ll v = ((n%b) + b) % b;
    ans = char(v + 'a') + ans;
    if(n == 0)
      break;
    n = n/b;
    n--;
  }
  //ans = char(((n + b)%b) + 'a') + ans;
//  reverse(ans, ans.end());
  cout << ans << endl;

}



Measured memory_bytes: 3628
def examA():
    C = SI()
    ans = chr(ord(C)+1)
    print(ans)
    return

def examB():
    N,K,M = LI()
    A = LI()
    ans = N*M-sum(A)
    if ans>K:
        ans = -1
    elif ans<0:
        ans = 0
    print(ans)
    return

def examC():
    N, M = LI()
    ansT = 0; ansP = 0
    d = defaultdict(bool)
    WA = [0]*(N+1)
    for i in range(M):
        S, P = LSI()
        S = int(S)
        if P=="WA":
            WA[S] +=1
        elif P=="AC":
            if d[S]:
                continue
            else:
                d[S] = True
                ansT +=1
                ansP +=WA[S]
    print(ansT,ansP)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()


Measured memory_bytes: 16452
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char buf[1024];
int bufl=sizeof(buf);
char bufr(void){
	if(bufl==sizeof(buf)){
		read(STDIN_FILENO, buf, sizeof(buf));
		bufl=0;
	}
	return buf[bufl++];
}

#define getchar bufr

void rsort_d32(void *base, const int count){
	int32_t *a=base;
	int32_t *b=malloc(count*sizeof(int32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))+0x80]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))+0x80]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }

#define P 1000000007

int k[100001];
int rk[100001];

int getk(int a, int x){
	if(x==1) return a;
	int b = getk(a, x/2);
	b = ((long)b)*b%P;
	if((x&1)==0){
		return b;
	}else{
		return ((long)b)*a%P;
	}
}
 
int comb(int a, int b){
	if(a<b) return 0;
	return ((long)k[a])*rk[b]%P*rk[a-b]%P;
}

void comb_init(int n){
	k[0]=1;
	for(int i=1; i<=n; i++){
		k[i]=k[i-1]*((long)i)%P;
	}	
	rk[n]=getk(k[n], P-2);
	for(int i=n-1; i>=0; i--){
		rk[i]=((long)rk[i+1])*(i+1)%P;
	}
}

int a[100000];
int main(void){
	int n=nextint();
	int k=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	rsort_d32(a, n);
	comb_init(n);
	long ans=0;
	for(int i=0; i<=n-k; i++){
		int c = comb(n-i-1, k-1);
		ans=((long)(a[n-i-1]-a[i])*c%P+ans+P)%P;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 1300
#include<stdio.h>
int search(int A[], int n, int key);

int main(){
  int i,n,A[10000+1],q,key,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key)==key) sum++;
  }
  printf("%d\n", sum);
  
  return 0;
}

int search(int A[], int n, int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  if(i==n) return i;
  }
  return A[i];
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	998244353;

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	cout<<s.substr(0,3);newl;
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3644
// ABC122
// A - Double Helix
#include<bits/stdc++.h>

using namespace std;

int main(){
    char b;
    map<char,char> mp{{'A','T'},{'T','A'},{'C','G'},{'G','C'}};
    cin >> b;
    cout << mp[b] << endl;
    return 0;
}


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

int main(){
int w,a,b;
int ea,eb;
cin>>w>>a>>b;
ea=a+w;eb=b+w;
if((b>=a&&b<=ea)||(eb>=a&&eb<=ea))
	cout<<0<<endl;
else if(ea<b)
	cout<<b-ea<<endl;
else
	cout<<a-eb<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  long long k;
  cin>>n>>k;
  int p[n];
  REP(i, n){
    cin>>p[i];
    p[i]--;
  }
  long long c[n];
  REP(i, n) cin>>c[i];
  
  vector<long long> temp(n);
  REP(i, n){
    long long loop = 1;
    long long lscore = c[i];
    long long score = 0;
    int now = i;
    vector<long long> scores;
    while(p[now] != i){
      loop++;
      lscore += c[p[now]];
      score += c[p[now]];
      scores.push_back(score);
      now = p[now];
    }
    scores.push_back(lscore);
    if(lscore <= 0){
      vector<long long> tscores;
      if(k >= loop){
        sort(ALL(scores), greater<long long>());
        temp[i] = scores[0];
        continue;
      }
      REP(j, k) tscores.push_back(scores[j]);
      sort(ALL(tscores), greater<long long>());
      temp[i] = tscores[0];
    }else{
      long long q = k / loop;
      long long r = k % loop;
      if(r == 0){
        q--;
        r = loop;
      }
      long long a = q * lscore;
      vector<long long> tscores;
      if(q > 0) tscores.push_back(0);
      REP(j, r) tscores.push_back(scores[j]);
      sort(ALL(tscores), greater<long long>());
      temp[i] = tscores[0] + a;
    }
  }
  sort(ALL(temp), greater<long long>());
  long long ans = temp[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3872
def dijkstra_heap(s,edge,mask):
    dist = defaultdict(lambda: float("inf"))
    q = [s]  # 0 が会社に属していない状態
    dist[s] = 0
    d = 0; q0 = []; q1 = []
    while q:
        for x in q:
            if x & mask == 0:
                for y in edge[x]:
                    if dist[y[1]] <= d + y[0]:
                        continue
                    dist[y[1]] = d + y[0]
                    q1.append(y[1])
            else:
                for y in edge[x]:
                    if dist[y[1]] <= d:
                        continue
                    dist[y[1]] = d
                    q0.append(y[1])
        if q0:
            q = q0
            q0 = []
            continue
        q = q1
        q1 = []
        d += 1
    return dist

def examE(inf):
    N, M = LI()
    edge = defaultdict(list)
    # edge[i] : iから出る道の[重み,行先]の配列
    L = 32
    Mask = (1 << L) - 1
    for i in range(M):
        p, q, c = map(int, input().split())
        p -=1; q -=1
        p <<= L
        q <<= L
        edge[p].append((1,p + c))
        edge[p + c].append((0,p))
        edge[q].append((1,q + c))
        edge[q + c].append((0,q))
        #同じ路線だとコスト０
        edge[p + c].append((0,q + c))
        edge[q + c].append((0,p + c))
    start = 0
    goal = (N-1) << L
    res = dijkstra_heap(start, edge, Mask)
#    print(res)
    ans = res[goal]
    if ans == inf:
        ans = -1
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examE(inf)


Measured memory_bytes: 194904
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll M=1000000007;

ll dfs(int u,const vector<int> *T){
	if(T[u].empty()) return 2;
	ll res=1;
	rep(i,T[u].size()){
		int v=T[u][i];
		res=res*dfs(v,T)%M;
	}
	return (res+1)%M;
}

// 出次数が高々 1 という制約から, 連結成分はループに木がくっついた形になる
// この連結成分についての解を求める
ll solve(int n,const int *G){
	vector<int> G2[1000]; // G の辺の向きを逆転したグラフ
	rep(u,n) if(G[u]!=-1) G2[G[u]].push_back(u);

	// ループ検出
	rep(u,n){
		int v=u;
		bool vis[1000]={};
		while(G[v]!=-1 && !vis[v]){
			vis[v]=true;
			v=G[v];
		}
		if(v==u){ // ループor根が見つかった
			ll res=1;
			int v=u;
			do{
				// ループ上の各頂点を根とする木について答えを求めて, それらをかけあわせる
				rep(i,G2[v].size()){
					int w=G2[v][i];
					if(!vis[w]) res=res*dfs(w,G2)%M;
				}
				v=G[v];
			}while(v!=u && v!=-1);
			return (res+1)%M; // どれも選ばないという解があるので +1
		}
	}
	for(;;);
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int to[1000];
	rep(u,n) to[u]=-1;
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		to[u]=v;
	}
	vector<int> G[1000]; // 無向グラフ
	rep(u,n) if(to[u]!=-1) {
		int v=to[u];
		G[u].push_back(v);
		G[v].push_back(u);
	}

	ll ans=1;
	bool vis[1000]={};
	rep(u,n) if(!vis[u]) {
		vis[u]=true;

		vector<int> cc;
		queue<int> Q; Q.push(u);
		while(!Q.empty()){ // 弱連結成分ごとに調べる
			int u=Q.front(); Q.pop();
			cc.push_back(u);
			rep(i,G[u].size()){
				int v=G[u][i];
				if(!vis[v]) vis[v]=true, Q.push(v);
			}
		}

		int N=cc.size();
		int D[1000]; // 弱連結な有向グラフ
		rep(i,N) D[i]=-1;
		rep(i,N) rep(j,N) {
			int u=cc[i],v=cc[j];
			if(to[u]==v) D[i]=j;
		}
		ans=ans*solve(N,D)%M;
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1156
N = int(input())
steps = list(map(int, input().split()))
costs = [0]*(N+1)
for i in range(1, N):
  if i==1:
    costs[1] = abs(steps[1]-steps[0])
    continue
  a = costs[i-1]+abs(steps[i]-steps[i-1])
  b = costs[i-2]+abs(steps[i]-steps[i-2])
  costs[i] = min(a, b)
print(costs[N-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,r;
  cin>>n;
  while(n)
  {
    r=n%10;
    n/=10;
    if(r==7)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3636
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long K = long.Parse(str[1]);
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            A[i] = int.Parse(str[0]);
            B[i] = int.Parse(str[1]);
        }
        Array.Sort(A,B);
        for(int i=0;i<N;i++){
            if(B[i] >= K){
                sb.Append(A[i]+"\n");
                break;
            }
            K -= B[i];
        }
    }
}

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

const int N = 100100, inf = 2e9;

int n, k, h[N], dp[N];

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n, k;

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

    lin m = n / k;
    lin res = m * m * m;

    if(k % 2 == 0)
    {
        lin l = (n + k / 2) / k;
        res += l * l * l;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		if(N>=M) {
			System.out.println(0);
			System.exit(0);
		}
		int x[]=new int[M];

		for(int i=0;i<M;i++) {
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		int l[]=new int[M-1];
		for(int i=0;i<M-1;i++) {
			l[i]=x[i+1]-x[i];
		}
		int length=x[M-1]-x[0];
		Arrays.sort(l);
		for(int i=0;i<N-1;i++) {
			length=length-l[M-2-i];
		}
		System.out.println(length);
	}
}

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

#define MAXLEN_S (100000)

int possible(const char *s) {
  // printf("[possible] s = %s\n", s);
  if (s[0] == '\0')
    return 1;
  else
    return (strstr(s, "dream") == s && possible(s + 5)) ||
        (strstr(s, "dreamer") == s && possible(s + 7)) ||
        (strstr(s, "erase") == s && possible(s + 5)) ||
        (strstr(s, "eraser") == s && possible(s + 6));
}

int main(int argc, char *argv[]) {
  int len;
  char S[MAXLEN_S + 1];
  fgets(S, MAXLEN_S + 1, stdin);
  len = strlen(S);
  S[len - 1] = '\0';
  if (possible(S))
    printf("YES\n");
  else
    printf("NO\n");
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int M = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
int a[N], pre[N];
pii op[M];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=m; i++) cin >> op[i].st >> op[i].nd;
	sort(a+1, a+n+1);
	sort(op+1, op+m+1, [](pii x, pii y){
		return x.nd > y.nd;
	});
	for(int i=1; i<=n; i++) pre[i] = a[i] + pre[i-1];
	int sum = pre[n];
	int l = 1, cur = 1;
	for(int i=1; i<=m; i++){
		while(cur <= n && a[cur] < op[i].nd && op[i].st > 0) {
			cur++;
			op[i].st--;
		}
		sum += (cur-l)*op[i].nd - (pre[cur-1]-pre[l-1]);
		l = cur;
		if (cur > n) break;
	}
	cout << sum << endl;
	return 0;
}


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

const int INF = 0x3f3f3f3f;
const int MAXN = 1005;

int x,y,z,K;
ll a[MAXN],b[MAXN],c[MAXN];
vector<ll> ans;

int main()
{
	scanf("%d%d%d%d",&x,&y,&z,&K);
	for(int i=1;i<=x;i++)
	    scanf("%lld",&a[i]);
	for(int i=1;i<=y;i++)
	    scanf("%lld",&b[i]);
	for(int i=1;i<=z;i++)
	    scanf("%lld",&c[i]);
	
	sort(a+1,a+1+x,greater<ll>());
	sort(b+1,b+1+y,greater<ll>());
	sort(c+1,c+1+z,greater<ll>());
	
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
			for(int k=1;k<=z;k++)
			{
				if(i*j*k>K)
				    break;
				ans.push_back(a[i]+b[j]+c[k]);
			}
	sort(ans.begin(),ans.end(),greater<ll>());
	for(int i=0;i<K;i++)
	    printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int a=0,b=0,c=0;
    int coin=0;
    cin >> a >> b >> c;
    int loginbonasu=0;
    int count=0;
    while(coin<c)
    {   
        loginbonasu++;
        coin+=a;   
        if(loginbonasu%7==0)
        {
            coin+=b;
        }
        count++;
           
    }
    cout << count << endl;
    return(0);
}    


Measured memory_bytes: 3124
#include <iostream>
#include <string>
int main() {
  std::string S;
  std::cin >> S;
  int true_cnt=0;
  bool even = true;
  for(int i=0;i<S.size();i++) {
    bool zero = S[i]=='0';
    if ((even && zero) || (!even && !zero))
      true_cnt++;
    even = !even;
  }
  int ans = true_cnt > S.size()/2 ? S.size() - true_cnt: true_cnt;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 512
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
k=0
while k<n:
    if l[k]%2==0:
        k+=1
        continue
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>v(N+1);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}
	int flag = 1;
		while (flag == 1) {
			flag = 0;
			for (int i = 0; i < N - 1; i++) {
				if (v.at(i) < v.at(i + 1)) {
					int a = v.at(i);
					v.at(i) = v.at(i + 1);
					v.at(i + 1) = a;
					flag = 1;
				}
			}
		}
		int ans=0;
		for (int i = 0; i < (N + 1) / 2; i++) {
			ans += v.at(2 * i);
			ans -= v.at(2 * i + 1);
		}
		cout << ans << endl;
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';
 
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

inline ll add(ll a, ll b){
  return ((a % mod) + (b % mod)) % mod;
}
inline ll sub(ll a, ll b){
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline ll mul(ll a, ll b){
  return ((a % mod) * (b % mod)) % mod;
}
inline ll modexpo(ll a, ll b){
  ll res = 1;
  while(b){
    if(b & 1){
      res = mul(res, a);
    }
    a = mul(a, a);b /= 2;
  }
  return res;
}
inline ll divide(ll a, ll b){
  return mul(a, modexpo(b, mod - 2));
}
 
clock_t time_p = clock();
 
void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}
  
int main(){
  fastio
  ll n, m;
  cin >> n >> m;
  ll now = 1;
  ll need = 0;
  while(now < m){
    now += n - 1;
    need++;
  }
  cout << need << '\n';
  ktj();
}

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

using namespace std;

int main(){
	long long n;//nは10^15+1まであり得るのでint64_t〜long long
	cin >> n;
	string s;//出力する文字列s=ここではNullで規定される
	while(n){
		--n;//1を引く
		s.push_back(n%26 + 'a');//例えばn=701なら、700%26=24にaを足して25番目のyが出力され、2回目は700/26=26から1を引くと25になるのでzになる
		n /= 26;
	}
	reverse(s.begin(),s.end());
	cout << s << endl;
	return 0;//書いておくと競技以外で役に立つことがある
}

//zがN個並ぶとき(((...((26+1)26+1)26+1......)26を表すので、1を引きながら一番上を規定していくといい(らしい)


Measured memory_bytes: 3608
n = int(input())
L = list(map(int,input().split()))

cnt = 0
ud = 0
ch = 1
for i in range(n-1):
    if L[i] < L[i+1] and ud == -1 and ch == 0:
        ch = 1
        ud = 1
        cnt +=1
    elif L[i] < L[i+1] and ch ==1:
        ch = 0
        ud = 1
    elif L[i] > L[i+1] and ud == 1 and ch == 0:
        ch = 1
        ud= -1
        cnt +=1
    elif L[i] > L[i+1] and ch == 1:
        ch = 0
        ud = -1
print(cnt+1)

Measured memory_bytes: 14480
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A1 = sc.nextInt();
    int A2 = sc.nextInt();
    int A3 = sc.nextInt();    

    int max = Math.max(A3,Math.max(A1,A2));
    int min = Math.min(A3,Math.min(A1,A2));

    System.out.println(max-min);
      }
}


Measured memory_bytes: 22484
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        print("Yes")
        exit()

    if a[0][i] + a[1][i] + a[2][i] == 0:
        print("Yes")
        exit()

if a[0][0] + a[1][1] + a[2][2] == 0:
    print("Yes")
    exit()
if a[2][0] + a[1][1] + a[0][2] == 0:
    print("Yes")
    exit()

print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    bool a=true;
    for(int i=0;i<N;i++){
        cin >> A.at(i);
        if(A.at(i)%2==0){
            if(A.at(i)%3!=0&&A.at(i)%5!=0) a=false;
        }
    }
    if(a) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] result = {a + b, a - b, a * b};
        int max = result[0];
        for (int i = 0; i < 3; i++) {
            if (max < result[i]) {
                max = result[i];
            }
        }
        System.out.println(max);
        sc.close();
    }
}

Measured memory_bytes: 23124