akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [usize; n],
    }

    let mut ans = vec![0; n];
    let mut idx: i64 = n as i64 -1;
    let mut d: i64 = -2;
    for i in 0..n {
        // debug!(idx);
        ans[i] = aa[idx as usize];
        idx += d;
        if idx < 0 {
            d = 2;
            idx = if idx == -1 { 0 } else { 1 }
        }
    }
    for i in 0..n {
        if i != n-1 {
            print!("{} ", ans[i]);
        } else {
            println!("{}", ans[i]);
        }
    }
}


Measured memory_bytes: 10364
#include<iostream>

using namespace std;

int main()
{
  int n, tou[4][3][10]={0},a,b,c,d;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a >> b >> c >> d;
    tou[a-1][b-1][c-1]+=d;
  }
  for(int i=0; i<4; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        cout << ' ' << tou[i][j][k];
      }
      cout << endl;
    }
    if(i-3)cout << "####################\n";
  }
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
  char c;
  cin >> c;
  switch (c) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      cout << "vowel" << endl; break;
    default:
      cout << "consonant" << endl; break;
  }
}


Measured memory_bytes: 256
x = int(input())

for h in range(1,4000):
    for n in range(1,4000):
        denom = 4/x - 1/h - 1/n
        if denom == 0:
            continue

        w = 1/denom
        if w < 0 or w > 50000:
            continue
        rounded = round(w)
        gosa = w - rounded
        if abs(gosa) < 10**-10:
            print(h,n,rounded)
            exit()

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

int main(){
  int n,a,f,ans=0;
  cin>>n;
  while(n--){
    cin>>a;
    f=0;
    for(int i=2;i*i<=a;i++)
      if(!(a%i))f=1;
    if(!f)ans++;
    if(a==1)f=1;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
  int a, b, c, x, y;

  cin >> a >> b >> c >> x >> y;

  int cyen = c * 2;
  int minxy = min(x, y);
  int ans = 0;

  if(cyen < a+b){
    ans = cyen * minxy;
    x -= minxy;
    y -= minxy;

    ans += x * min(a, cyen);
    ans += y * min(b, cyen);
  }

  else ans = a*x + b*y;

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
local n,k=io.read("n","n")
local R,S,P=io.read("n","n","n","l")
local t=io.read()
local a={}
local point=0

for i=1,n do
    if t:sub(i,i)=="r" then
        a[i]="p"
        point=point+P
    end
    if t:sub(i,i)=="s" then
        a[i]="r"
        point=point+R
    end
    if t:sub(i,i)=="p" then
        a[i]="s"
        point=point+S
    end
end

for i=1,n-k do
    if a[i]==a[i+k] then
        if a[i]=="p" then
            point=point-P
            a[i+k]=""
        end
        if a[i]=="r" then
            point=point-R
            a[i+k]=""
        end
        if a[i]=="s" then
            point=point-S
            a[i+k]=""
        end
    end
end

print(point)

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	int n;cin >> n;
	vector<int> a(n+1);
	rep(i,n) cin >> a.at(i+1);
	vector<vector<int>> ans(h,vector<int>(w));
	int k=1;
	rep(i,h){
		rep(j,w){
			if(i%2==0){
				if(a[k]){
					ans[i][j]=k;
					a[k]--;
				}
				else{
					k++;
					ans[i][j]=k;
					a[k]--;
				}
			}
			else{
				if(a[k]){
					ans[i][w-1-j]=k;
					a[k]--;
				}
				else{
					k++;
					ans[i][w-1-j]=k;
					a[k]--;
				}
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(j==w-1) cout << ans[i][j];
			else cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
n = int(input())
W = [[int(i)] for i in input().split()]
for ni in range(n):
    W[ni].append(ni)
W.sort()
G = [[] for i in range(n)]
i = 0
j = 0
cnt = 0
D = []
while cnt < n:
    if W[i][0] in G[j]:
        j += 1
        while i in D:
            i += 1
    else:
        G[j].append(W[i][0])
        D.append(i)
        cnt += 1
        i = W[i][1]
group_num = j + 1
cost = 0
W_min = min([min(G[i]) for i in range(group_num)])
for gi in range(group_num):
    if len(G[gi]) > 1:
        if (min(G[gi])+W_min)*2 > (min(G[gi])-W_min)*(len(G[gi])-1):
            cost += sum(G[gi])+ (len(G[gi])-2)*min(G[gi])
        else:
            cost += sum(G[gi])-min(G[gi])+ (len(G[gi])-1)*W_min+(min(G[gi])+W_min)*2

print(cost)


Measured memory_bytes: 5892
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Mon Jan  7 17:54:40 2019
//
package main

import (
	"errors"
	"fmt"
)

type graph [][]int

func warshalFloyd(g graph) (int, error) {

	g2 := make(graph, len(g))
	for i := range g2 {
		g2[i] = make([]int, len(g[0]))
		for j := range g2 {
			g2[i][j] = g[i][j]
		}
	}

	for k := range g {
		for i := range g {
			for j := range g {
				if g[i][k]+g[k][j] < g[i][j] {
					return 0, errors.New("error")
				} else if i != k && k != j && g[i][k]+g[k][j] == g[i][j] {
					g2[i][j] = 0
				}
			}
		}
	}

	sum := 0
	for i := range g2 {
		for j := range g2[i] {
			sum += g2[i][j]
		}
	}

	return sum / 2, nil
}

func main() {
	var N int
	fmt.Scan(&N)

	routes := make(graph, N)
	for i := range routes {
		routes[i] = make([]int, N)
		for j := range routes[i] {
			fmt.Scan(&routes[i][j])
		}
	}

	if n, err := warshalFloyd(routes); err != nil {
		fmt.Println(-1)
	} else {
		fmt.Println(n)
	}
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
int x[N], y[N], t[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> t[i] >> x[i] >> y[i];
	}
	bool pos = 1;
	fr(i, 1, n){
		int val = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		if(val > t[i] - t[i - 1])
			pos = 0;
		else if((t[i] - t[i - 1] - val) % 2 != 0)
			pos = 0;
	}
	if(pos)
		cout << "Yes";
	else
		cout << "No";
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll X;
  cin >> X;
  ll N = 1000;
  for (ll a = -N; a <= N; ++a) {
    for (ll b = -N; b <= N; ++b) {
      ll a5 = a * a * a * a * a;
      ll b5 = b * b * b * b * b;
      if (a5 - b5 == X) {
	cout << a << " " << b << endl;
	return 0;
      }
    }
  }    
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>

typedef long long lint;
typedef std::pair<lint, lint> bag;

std::multiset<lint> left, right;
bag list[200000];

inline lint calc() {
	return ((*left.rbegin()) - (*left.begin()))* ((*right.rbegin()) - (*right.begin()));
}

int main() {
	int count;
	std::cin >> count;

	for (int i = 0; i < count; i++) {
		scanf("%lld%lld", &list[i].first, &list[i].second);
		if (list[i].first > list[i].second) {
			std::swap(list[i].first, list[i].second);
		}

		left.insert(list[i].first);
		right.insert(list[i].second);
	}

	lint res = calc();
	std::sort(list, list + count);

	for (int i = 0; i < count; i++) {
		right.insert(list[i].first);
		left.erase(left.find(list[i].first));

		left.insert(list[i].second);
		right.erase(right.find(list[i].second));

		lint temp = calc();
		res = std::min(res, temp);
	}

	std::cout << res << std::endl;
	return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

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

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

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int a = (2 * X - Y) / 3, b = (2 * Y - X) / 3;
    mint ans = c(a + b, a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt = 0;cin >> n;
    char word[n+1];
    cin >> word;
    for(int i = 0;i < n - 2;i++)
        if(word[i] == 'A' && word[i+1] == 'B' && word[i+2] == 'C')cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int A, B, C;
  int K;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &K);

  for (int i = 0; i < K; i++)
  {
    if (A >= B)
    {
      B *= 2;
      continue;
    }
    if (B >= C)
    {
      C *= 2;
      continue;
    }
    C *= 2;
  }
  if (A < B && B < C)
    printf("Yes");
  else
    printf("No");

  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main()
{
	int r=0, c=0, a[101][101] = {0};
	cin >> r >> c;
	for (int aa = 0; aa <= r; aa++)
	{
		if (aa < r)/*???????????¨?¨????????????§?????\????????¨?¨????*/{for (int bb = 0; bb <= c; bb++){
			if (bb < c)
			{
				cin >> a[aa][bb]; /*???????????\???*/
			}
			else if (bb == c)
			{
				for (int cc = 0; cc < bb; cc++)
				{
					a[aa][bb] += a[aa][cc];/*???????????¨?¨????*/
				}
			}
		}
		}
		else if (aa == r)/*???????????¨?¨????????????????*/{
			for (int bb = 0; bb <= c; bb++){
				if (bb < c)
				{
					for (int cc = 0; cc < r; cc++)
					{
						a[aa][bb]+=a[cc][bb]; /*r??????????????¨????????¨?¨????*/
					}
				}
				else if (bb == c)
				{
					for (int cc = 0; cc < bb; cc++)
					{
						a[aa][bb] += a[aa][cc];/*???????????¨?¨????*/
					}
				}
			}
		}
	}
	/*???????????§??\???*/
	/*-----------------------------------??????????????????--------------------------------------*/
	/*??????????????????*/
	for (int aa = 0; aa <= r; aa++)
	{
		for (int bb=0; bb <= c; bb++)
		{
			cout << a[aa][bb];
			if (bb < c){ cout << " "; }
		}cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
S = rs()

dp = [[0] * (N+1) for _ in range(N+1)]

ans = 0
for i in range(N):
	for j in range(i+1,N):
		if S[i] == S[j]:
			if i+1 < j+1-(dp[i][j]+1)+1:
				dp[i+1][j+1] = dp[i][j]+1
			else:
				dp[i+1][j+1] = 0
			ans = max(ans, dp[i+1][j+1])
print(ans)

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

int main(){
	int a, b;
	cin >> a >> b;
	cout << a / b << " " ;
	cout << a % b << " " ;
	printf("%.5lf\n", 1.0 * a / b);
	
	return 0;	
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, a[20], b[20], c[20];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n - 1; i++)
        cin >> c[i];

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += b[a[i] - 1];
    for (int i = 1; i < n; i++)
        if (a[i] == a[i - 1] + 1)
            ans += c[a[i - 1] - 1];
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

if N%2==1:
  for i in range(M):
    print(str(i+1) + " " + str(N-(i+1)))
else:
  flag = False
  l = 1
  r = N-1
  cnt = 0
  while cnt < M and l < r:
    if not flag and r-l <= N//2:
      r -= 1
      flag = True
    print(str(l) + " " + str(r))
    l += 1
    r -= 1
    cnt += 1

Measured memory_bytes: 69344
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int min = 2000000000;
    int diffMax = -2000000000;
    for (int i = 0; i<n; i++) {
        int r;
        cin >> r;
        diffMax = std::max(diffMax, r - min);
        min = std::min(min, r);
    }
    cout << diffMax<<endl;
    return 0;
}



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

int main(){
  int64_t N, M;
  cin >> N >> M;
  // Tenbodai_i(height, {link1, link2,...})
  vector<pair<int64_t, vector<int64_t>>> T(N);
  int height;
  for(int64_t i=0;i<N;i++){
    cin >> height;
    T.at(i).first = height;
  }
  int64_t A, B;
  for(int64_t i=0;i<M;i++){
    cin >> A >> B;
    T.at(A-1).second.push_back(B-1);
    T.at(B-1).second.push_back(A-1);
  }
  int64_t count=0;
  bool state;
  for(int64_t i=0;i<N;i++){
    state = true;
    for(auto linked : T.at(i).second){
      if(!(T.at(i).first > T.at(linked).first)) state = false;
    }
    if(state) count++;
  }

  cout << count << endl;
  // debug
  /*
  for(int64_t i=0;i<N;i++){
    cout << T.at(i).first << " ";
    for(auto p : T.at(i).second){
      cout << p << " ";
    }
    cout << endl;
  }
  */
  return 0;
}

Measured memory_bytes: 9776
from collections import deque

h, w = map(int, input().split())
maze = [list(input()) for a in range(h)]
visited = [[0]*w for a in range(h)]

dy = [0,1,0,-1]
dx = [1,0,-1,0]
def bfs():
    que = deque([])
    que.append((0,0))
    visited[0][0]=0

    while que:
        p = que.popleft()

        if p[0]==h-1 and p[1]==w-1:
            break

        for i in range(4):
            ny = p[0]+dy[i]
            nx = p[1]+dx[i]

            if 0<=ny<h and 0 <=nx<w and maze[ny][nx]=='.' and visited[ny][nx]==0:
                visited[ny][nx]=visited[p[0]][p[1]]+1
                que.append((ny,nx))

    return visited[h-1][w-1]

ans = bfs()
if ans == 0:
    print(-1)
else:
    cnt = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j]=='#':
                cnt +=1

    print(h*w-cnt-ans-1)            


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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int counter = 0;

  for(int i = 0;i <= N / R;i++){
    for(int j = 0;j <= N / G;j++){
      int k = N - (R * i + G * j);
      if(k >= 0 && k % B == 0)counter++;
    }
  }

  cout << counter << endl;
}

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

int main()
{
	string s,t;
	cin>>s;
	cin>>t;
	if(t.length()==s.length()+1)
	{

int flag=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No"<<endl;
			flag=1;
			break;
		}	
	}
	if(flag==0)
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

	   

    return 0;
	
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 50;
const ll MOD = 998244353;

ll x, y, A, B, C;
ll c1 = 0, c2 = 0, c3 = 0;
ll ans = 0;
ll p[N], q[N], r[N];

bool cmp (ll n, ll m) {
    return n > m;
}

int main() {
    cin>>x>>y>>A>>B>>C;
    for(int i=0;i<A;i++)
        cin>>p[i];
    for(int i=0;i<B;i++)
        cin>>q[i];
    for(int i=0;i<C;i++)
        cin>>r[i];

    sort(p, p+A, cmp);
    sort(q, q+B, cmp);
    sort(r, r+C, cmp);

    ll cnt = x + y;
    for(int i=0;i<cnt;i++) {
        ll t = 0, flag = 0;
        if(c1 < x && p[c1] > t) {
            t = p[c1];
        }
        if(c2 < y && q[c2] > t) {
            t = q[c2];
            flag = 1;
        }
        // cout<<r[c3]<<" "<<t<<endl;
        if(c3 < C && r[c3] > t) {
            t = r[c3];
            flag = 2;
        }
        ans += t;
        if(flag == 0) {
            c1 ++;
        }else if(flag == 1) {
            c2 ++;
        }else {
            c3 ++;
        }
        //cout<<ans<<endl;
    }

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


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iA = int.Parse(sS[1]);
            int iB = int.Parse(sS[2]);
            List<int> lstInp = new List<int>();
            for (int i = 0; i < iN; i++)
            {
                lstInp.Add(int.Parse(System.Console.ReadLine().Trim()));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstInp.Sort();
            int iOut = 0;
            for (int i = 0; i < lstInp.Count; i++)
            {
                if (iA <= lstInp[i] && lstInp[i] < iB) { iOut += 1; }
                if (lstInp[i] >= iB) { break; }
            }
            iOut = lstInp.Count - iOut;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, a = 1, b = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    a *= 2;
    b += K;
    if(a < b) b = a;
    else a = b;
  }
  cout << a << endl;
}

Measured memory_bytes: 3584
# Half and Half
a, b, c, x, y = map(int, input().split())
ans = 0
if a + b >= 2 * c:
    if x >= y:
        ans += c * 2 * y
        x = max(x-y, 0)
        y = 0
    else:
        ans += c * 2 * x
        y = max(y-x, 0)
        x = 0
if a >= 2 * c:
    ans += c * 2 * x
    y = max(y - x, 0)
    x = 0
if b >= 2 * c:
    ans += c * 2 * y
    x = max(x - y, 0)
    y = 0
ans += a * x + b * y
print(ans)


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var inc = false;
        var dec = false;
        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            if(i == n-1) 
            {
                ans++;
                break;
            }

            if(!inc && !dec)
            {
                if(a[i] == a[i+1])
                {

                }
                else if(a[i] < a[i+1])
                {
                    inc = true;
                }
                else
                {
                    dec = true;
                }
            }
            else if(inc)
            {
                if(a[i+1] < a[i] )
                {
                    ans++;
                    inc = false;
                }
            }
            else if(dec)
            {
                if(a[i] < a[i+1])
                {
                    ans++;
                    dec = false;
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 38688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int x,y;
int main() {
  	cin>>x>>y;
  	set<int> s1 {1, 3, 5, 7, 8, 10, 12};
  	set<int> s2 {4, 6, 9, 11};
  	if ((s1.find(x) != s1.end() && s1.find(y) != s1.end()) || (s2.find(x) != s2.end() && s2.find(y) != s2.end())) {
    	cout<<"Yes"<<endl;
    } else {
    	cout<<"No"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]
N = int(input())
list_d = list(map(int, input().split()))

list_d.sort()
print(list_d[N//2]-list_d[N//2 - 1])


Measured memory_bytes: 20688
w, h, n = gets.split.map(&:to_i)
# ai=1 のときは長方形の x<xi をみたす領域
# ai=2 のときは長方形の x>xi をみたす領域
# ai=3 のときは長方形の y<yi をみたす領域
# ai=4 のときは長方形の y>yi をみたす領域
x = [0, w]
y = [0, h]
n.times.map do
  a, b, c = gets.split.map(&:to_i)
  case c
  when 1
    x[0] = [x[0], a].max
  when 2
    x[1] = [x[1], a].min
  when 3
    y[0] = [y[0], b].max
  when 4
    y[1] = [y[1], b].min
  end
end
puts [x.reverse.inject(&:-), 0].max * [y.reverse.inject(&:-), 0].max


Measured memory_bytes: 1916
R=range
N,M,*S=open(0).read().split()
N=int(N)+1
M=int(M)-1
l=lambda:[[0]*N for _ in R(N)]
C=l()
D=l()
r=0
for t in R(M):
	for i in R(1,N):
		for j in R(1,N):u=C[i][j]=C[i-1][j-1]+(S[i-1][t]==S[j-1][t+1]);v=D[i][j]=min(D[i-1][j],D[i][j-1])+u
	r+=v
print(r)

Measured memory_bytes: 47636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int n =0;
    int s =0;
    int e =0;
    int w =0;
    
    for(int i=0; i<S.length(); i++){
      if(S.charAt(i)=='N')n++;
      else if(S.charAt(i)=='S')s++;
      else if(S.charAt(i)=='E')e++;
      else if(S.charAt(i)=='W')w++;
    }
    if(s>0&&n>0&&w==0&&e==0) {
			System.out.println("Yes");
			return;
		}
		if(s==0&&n==0&&w>0&&e>0) {
			System.out.println("Yes");
			return;
		}
		if(s>0&&n>0&&w>0&&e>0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
  }
}   

Measured memory_bytes: 35564
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

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

Measured memory_bytes: 3076
#!/usr/bin/env python3
# CGL_3_C: Polygon - Polygon-Point Containment

from enum import Enum


class Position(Enum):
    OUTSIDE = 0
    BORDER = 1
    INSIDE = 2


class Polygon:
    def __init__(self, ps):
        self.ps = ps
        self.convex_poligons = divide(ps)

    def position(self, p):
        if p in self.ps:
            return Position.BORDER

        pos = [position(*c, p) for c in self.convex_poligons]
        if all([x == Position.OUTSIDE for x in pos]):
            return Position.OUTSIDE
        elif any([x == Position.INSIDE for x in pos]):
            return Position.INSIDE
        elif len([x for x in pos if x == Position.BORDER]) > 1:
            return Position.INSIDE
        else:
            return Position.BORDER


def divide(ps):
    if len(ps) < 3:
        return []

    p0, p1, p2, *ps = ps
    if not ccw(p0, p1, p2):
        return divide([p1, p2] + ps + [p0])

    for p in ps:
        if position(p0, p1, p2, p) != Position.OUTSIDE:
            return divide([p1, p2] + ps + [p0])

    return [(p0, p1, p2)] + divide([p0, p2] + ps)


def ccw(p0, p1, p2):
    x0, y0 = p0
    x1, y1 = p1
    x2, y2 = p2
    v1 = (x1-x0, y1-y0)
    v2 = (x2-x1, y2-y1)
    return dot(orthogonal(v1), v2) > 0


def dot(v1, v2):
    x1, y1 = v1
    x2, y2 = v2
    return x1 * x2 + y1 * y2


def cross(v1, v2):
    x1, y1 = v1
    x2, y2 = v2
    return x1 * y2 - y1 * x2


def orthogonal(v):
    x, y = v
    return -y, x


def position(p0, p1, p2, p):
    x, y = p
    ps = [p0, p1, p2]
    online = False
    for i in range(3):
        pa = ps[i]
        pb = ps[(i+1) % 3]
        pc = ps[(i+2) % 3]
        xa, ya = pa
        xb, yb = pb
        xc, yc = pc
        vab = (xb-xa, yb-ya)
        vac = (xc-xa, yc-ya)
        vp = (x-xa, y-ya)
        c = cross(vab, vp) * cross(vp, vac)
        if c == 0:
            online = True
        elif c < 0:
            return Position.OUTSIDE

    if online:
        return Position.BORDER
    else:
        return Position.INSIDE


def run():
    g = int(input())

    ps = []
    for _ in range(g):
        x, y = [int(i) for i in input().split()]
        ps.append((x, y))

    poly = Polygon(ps)

    n = int(input())
    for _ in range(n):
        qx, qy = [int(i) for i in input().split()]

        pos = poly.position((qx, qy))
        print(pos.value)


if __name__ == '__main__':
    run()



Measured memory_bytes: 6668
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    ll const mod = 1000000007;
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    // 累積和を計算
    ll sm[n];
    sm[n-1] = a[n-1];
    for(ll i = n - 1; i > 0; i--){
        sm[i-1] = sm[i] + a[i-1];
        sm[i-1] %= mod;
    }
    ll ans = 0;
    rep(i, n - 1){
        ans += a[i] * (sm[i+1]);
        ans %= mod;
    }

    // ll ans = 0;
    // rep(i, n - 1){
    //     for (int j = i + 1; j < n; j++){
    //         ans += a[i] * a[j];
    //         ans %= mod;
    //     }
    // }

    // rep(i, n) cout << sm[i] << endl;
    cout << ans % mod << endl;
    // cout << mod << endl;
}

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

int main(){
  int n;
  while(cin>>n,n){
    int cnt=0;
    int ans=0;
    int data[n];
    for(int i=0;i<n;i++){
      data[i]=i+1;
    }
    int s,t;
    s=t=0;
    for(;;){
      while(t<n && cnt<n){
	cnt+=data[t++];
      }
      if(cnt<n)break;
      if(cnt==n){
	ans++;
      }
      cnt-=data[s++];
    }
    cout << ans-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( int i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 998244353
#define PI 3.14159265358979323846
const ll N = 200007;

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }

int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        ll n;
        cin >> n;
        ll ac = 0, tle = 0, re = 0, wa = 0;
        REP(i, 0, n)
        {
            string s;
            cin >> s;
            if (s == "AC")
                ac++;
            if (s == "WA") wa++;
            if (s == "TLE") tle++;
            if (s == "RE") re++;
        }
        cout << "AC x " << ac << endl;
        cout << "WA x " << wa << endl;
        cout << "TLE x " << tle << endl;
        cout << "RE x " << re << endl;
    }
    return 0;
}



Measured memory_bytes: 3660
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
    };
    let mut s = vec![0; n];
    loop {
        // eprintln!("{:?}", s);
        for c in s.iter() {
            print!("{}", (*c + 'a' as u8) as char);
        }
        println!();
        let mut change  = false;
        for i in (1..n).rev() {
            if s[i] == s[..i].iter().max().unwrap() + 1 {
                s[i] = 0
            } else {
                s[i] += 1;
                change = true;
                break;
            }
        }
        if !change {
            break;
        }
    }
}


Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

    int N, T; cin >> N >> T;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int maxv = -1, minv = a[0];
    repr(i, 1, N){
        chmax(maxv, a[i]-minv);
        chmin(minv, a[i]);
    }

    int ans = 0;
    minv = a[0];
    repr(i, 1, N){
        if(a[i]-minv == maxv) ++ans;
        chmin(minv, a[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>

int main(){
    char a, b;
    std::cin >> a >> b;
    if((a == 'H' && b == 'H')
       || (a == 'D' && b == 'D')){
           std::cout << "H" << std::endl;
       }else{
           std::cout << "D" << std::endl;
       }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c,d,e;
    string s,t,u;
    cin>>a>>b>>c>>d>>e;

    cout<<c*60+d-(a*60+b)-e<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    string s;
    int n,a,b,c;
    cin >> a >> b;
    if(a <10 && b < 10){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 1000
#define MAX_M 1000

using P = pair<i64, i64>;

int main() {
    i64 N, M; cin >> N >> M;
    vector<i64> A(N);
    vector<i64> B(N);
    vector<i64> C(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    i64 maxv = 0;
    for (i64 bit = 0; bit < (1 << 3); bit++) {
        vector<P> X(N);
        auto f = [&](i64 a, i64 b, i64 c) {
            i64 s = 0;
            s += (bit >> 0 & 1 ? 1 : -1) * a;
            s += (bit >> 1 & 1 ? 1 : -1) * b;
            s += (bit >> 2 & 1 ? 1 : -1) * c;
            return s;
        };

        REP(i, N) X[i] = {f(A[i], B[i], C[i]), i};
        sort(X.rbegin(), X.rend());

        vector<i64> s(3, 0);
        REP(i, M) {
            s[0] += A[X[i].second];
            s[1] += B[X[i].second];
            s[2] += C[X[i].second];
        }
        chmax(maxv, abs(s[0]) + abs(s[1]) + abs(s[2]));
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<Pii,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
vector < string > ans;
int a,b;
void solve(int jo,int ya,string state){
    if(jo == a && ya == b){
        ans.PB(state);
        return ;
    }
    if(jo < a){
        bool f=true;
        if(5 <= a){
            if(jo+1 == a && ya != b)f=false;
            if(a >= 4 && b >= 4){
                if(jo+1 > 4 && ya < 4)f=false;
            }
            if(a == 5 && jo == 4 && ya == 4)f=true;
        }
        if(f)solve(jo+1,ya,state+"A");
    }
    if(ya < b){
        bool f=true;
        if(5 <= b){
            if(jo != a && ya+1 == b)f=false;
            if(a >= 4 && b >= 4){
                if(jo < 4 && ya+1 > 4)f=false;
            }
            if(b == 5 && jo == 4 &&ya == 4)f=true;
        }
        if(f)solve(jo,ya+1,state+"B");   
    }
}
int main(){
    scanf("%d%d",&a,&b);
    solve(0,0,"");
    rep(i,ans.size()){
        printf("%s\n",ans[i].c_str());
    }
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main() {
    int N;
    cin >> N;
    int cnt =0;
    if(N<10){
        cout << N;
    }else if(N<100){
        cout << 9;
    }else if(N<1000){
        cout << 9+(N-99);
    }else if(N<10000){
        cout << 9+900;
    }else if(N<100000){
        cout << 9+900+(N-9999);
    }else{
        cout << 9+900+90000;
    }
}

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

int main(){
    ll n;
    cin>>n;
    n%=10;
    if(n==3) cout<<"bon"<<endl;
    else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
    return 0;
}

Measured memory_bytes: 3628
def arrow(current, tiles)
  case tiles[current[0]][current[1]]
  when ">"
    return [current[0], current[1] + 1]
  when "<"
    return [current[0], current[1] - 1]
  when "^"
    return [current[0] - 1, current[1]]
  when "v"
    return [current[0] + 1, current[1]]
  end  
  
end

while true
  tiles, path, current = [], [], [0, 0]
  h, w = gets.split.map(&:to_i)
  
  break if h == 0 && w == 0
  
  h.times do |i|    
    tiles[i] = gets.chomp.split("")
  end

  while true
    if tiles[current[0]][current[1]] == "."
      puts current.reverse.join(" ")
      break
    elsif path.include?(current)
      puts "LOOP"
      break
    end
  
    path << current
    current = arrow(current, tiles)
  end
end

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>
#include <iomanip>

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


int main() {
    long long n,k;
    cin >> n >> k;
    vector<double> p(n),p_sum(n);
    long long tmp;
    
    rep(i,n){
        cin>>tmp;
        p[i]=(double)(1+tmp)/2;
        if(i==0){
            p_sum[0]=p[0];
        }else{
            p_sum[i]=p_sum[i-1]+p[i];
        }
    }
    double ans=0.0;
    for(int i=k-1;i<n;i++){
        ans=max(ans,p_sum[i]-p_sum[i-k]);
    }  
    cout << fixed << setprecision(10) << ans << endl;
}

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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   for(int i = 1 ; i <= 5 ; i++){
      int x;
      cin >> x;
      if(x == 0)
         cout << i;
   }
   return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A>B&&(A>C&&B<C)) cout<<"Yes"<<endl;
  else if(A<B&&(A<C&&B>C)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

int solve(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        ll a;
        cin >> a;
        if(a==0) {
            out(0);
            return 0;
        }
        A[i] = a;
    }
    Bint ans=1;
    ll th=1;
    rep(i, 18) th *= 10;
    for(auto& a : A){
        ans *= a;
        if(ans > th){
            out(-1);
            return 0;
        }
    }
    out(ans);
    return 1;
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 4012
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define veci vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;

    

void solve(){
    
    long double a, b, h, m;
    cin>>a >>b >>h >>m;

    long double ang = pie * 2 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
    long double sqr = a*a + b*b - 2*a*b*cosl(ang);

    cout<<sqrt(sqr);

}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}



Measured memory_bytes: 4184