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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;//__float128;
using piiii = pair<pii, pii>;

#define endl "\n"
#define inf 0x3f3f3f3f3f
#define f first
#define s second

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

string s;

int main() {
    //freopen("deleg.in", "r", stdin);
    //freopen("deleg.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    if (s.length()%2){
        cout << "No" << endl;
    }else{
        for (int i=0; i<s.length(); i+=2){
            if (s[i]!='h'||s[i+1]!='i'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))

ok_list = []

for i in range(1, N+1):
    str_i = str(i)
    i_sum = sum(map(int, list(str(i))))
    if A <= i_sum and i_sum <= B:
        ok_list.append(int(i))
print(sum(ok_list))

Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, x;
	vector<int>lista;

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		lista.push_back(num);
	}

	sort(lista.begin(), lista.end());

	int cnt = 0;

	for (int i = 0; i < n; i++) {
		if (x >= lista[i]) {
			if (i != n - 1) {
				x -= lista[i];
				cnt++;
			}
			else {
				if (x == lista[i]) {
					x -= lista[i];
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        int H,W;
 
        H = sc.nextInt();
        W = sc.nextInt();
 
        int table[][] = new int[H+1][W+1];
 
        for(int row = 0; row < H; row++){
            for(int col = 0; col < W; col++){
                table[row][col] = sc.nextInt();
            }
        }
 
        for(int row = 0; row < H; row++){
            table[row][W] = 0;
            for(int col = 0; col < W; col++){
                table[row][W] += table[row][col];
            }
        }
 
        for(int col = 0; col <= W; col++){
            table[H][col] = 0;
            for(int row = 0; row < H; row++){
                table[H][col] += table[row][col];
            }
        }
 
        for(int row = 0; row <= H; row++){
            System.out.printf("%d", table[row][0]);
            for(int col = 1; col <= W; col++){
                System.out.printf(" %d", table[row][col]);
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 53144
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! swap {
    ($a:expr, $b:expr) => {
        let tmp = $a;
        $a = $b;
        $b = tmp;
    };
}

#[allow(unused_macros)]
macro_rules! vecs {
    ($init:expr; $($dim:expr);*) => {
        vecs!($($dim);* => $init)
    };
    ($head:expr; $($tail:expr);* => $init:expr) => {
        vec![vecs!($($tail);* => $init); $head]
    };
    ($head:expr => $init:expr) => {
        vec![$init; $head]
    };
}

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let x = scan.readn::<i64>(n);
    let l = scan.read::<i64>();
    let q = scan.read::<usize>();
    let mut nt = vecs![0;n;21];
    for i in 0..n {
        nt[i][0] = upper_bound(&x, &(x[i] + l))-1;
    }
    for i in 0..20 {
        for j in 0..n {
            nt[j][i+1] = nt[nt[j][i]][i];
        }
    }
    for _ in 0..q {
        let mut a = scan.read::<usize>()-1;
        let mut b = scan.read::<usize>()-1;
        if a > b {swap!(a, b);}
        let mut ret = 0;
        for i in (0..21).rev() {
            if nt[a][i] < b {
                a = nt[a][i];
                ret += 1 << i;
            }
        }
        ret += 1;
        println!("{}", ret);
    }
}

#[allow(dead_code)]
fn upper_bound<T: Ord>(arr: &[T], x: &T) -> usize {
    let mut ok = arr.len() as i64;
    let mut ng = -1i64;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if &arr[mid as usize] > x {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok as usize
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 27388
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int A=0, B=0, t;

	for (int i = 0; i < 4; i++) {
		scanf("%d", &t);
		A += t;
	}
	for (int i = 0; i < 4; i++) {
		scanf("%d", &t);
		B += t;
	}

	printf("%d\n", max(A, B));

	return 0;
}

Measured memory_bytes: 2732
#include<stdio.h>
int main(void)
{
	int a,b,c,t,i,j ;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		t=a;
		a=b;
		b=t;
	}
	if(a>c){
		t=a;
		a=c;
		c=t;
	}
	if(b>c){
		t=b;
		b=c;
		c=t;
	}
		printf("%d %d %d\n",a,b,c);
	return 0;
}

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

int main(void) {
	int a1, a2, a3;
	cin >> a1;
	a2 = a1 * a1;
	a3 = a2 * a1;
	int ans = a1 + a2 + a3;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3556
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    NT=1
    NA=1
    for i in range(N):
        T,A=MI()
        xt=(NT+T-1)//T
        xa=(NA+A-1)//A
        x=max(xt,xa)
        NT=T*x
        NA=A*x
    print(NT+NA)
            

main()


Measured memory_bytes: 38256
def func(lv, id):
    sz = 4 * 2 ** lv - 3
    num = 2 * 2 ** lv - 1
    mid = (sz + 1) / 2
    if id < 1 or id > sz:
        return 0
    return [0, func(lv - 1, id - 1), num / 2 + 1, func(lv - 1, id - sz / 2 - 1) + num / 2 + 1, num, 1][(id > 1) + (id >= mid) + (id > mid) + (id >= sz) + (lv == 0) * 3]

print func(*map(int, raw_input().split()))

Measured memory_bytes: 2692
/*input
3
2
1 5 10
2 15 5
3
2 93 78
1 71 59
3 57 96
19
19 23 16
5 90 13
12 85 70
19 67 78
12 16 60
18 48 28
5 4 24
12 97 97
4 57 87
19 91 74
18 100 76
7 86 46
9 100 57
3 76 73
6 84 93
1 6 84
11 75 94
19 15 3
12 11 34
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
void solve_case() {
	int n;
	cin >> n;
	vector<int>L(n + 1), R(n + 1), K(n + 1), val(n + 1);
	vector<int>v1, v2;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> K[i] >> L[i] >> R[i];
		ans += min(L[i], R[i]);
		if (L[i] >= R[i]) {
			val[i] = L[i] - R[i];
			v1.pb(i);
		} else {
			val[i] = R[i] - L[i];
			v2.pb(i);
		}
	}

	sort(all(v1), [&](int i, int j) {
		if (val[i] != val[j]) {
			return val[i] > val[j];
		}
		return K[i] < K[j];
	});

	set<int>ind;
	for (int i = 1; i <= sz(v1); i++) {
		ind.insert(i);
	}

	for (int i : v1) {
		auto it = ind.upper_bound(K[i]);
		if (it == ind.begin()) {
			continue;
		}
		--it;
		ans += val[i];
		ind.erase(it);
	}

	for (int i : v2) {
		K[i] = n - K[i];
	}

	sort(all(v2), [&](int i, int j) {
		if (val[i] != val[j]) {
			return val[i] > val[j];
		}
		return K[i] < K[j];
	});

	ind.clear();
	for (int i = 1; i <= sz(v2); i++) {
		ind.insert(i);
	}

	for (int i : v2) {
		auto it = ind.upper_bound(K[i]);
		if (it == ind.begin()) {
			continue;
		}
		--it;
		ans += val[i];
		ind.erase(it);
	}

	cout << ans << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		solve_case();
	}
	return 0;
}

Measured memory_bytes: 11980
import scala.io.StdIn
object Main extends App {
  val List(n,x) = StdIn.readLine().split(" ").map(_.toInt).toList
  val sa = StdIn.readLine().split(" ").map(_.toInt).sorted
  val sum = sa.scan(0)(_+_).drop(1)
  val small = sa.take(sum.takeWhile(_ <= x).length)
  val large = sa.drop(small.length)
  println(if (small.sum == x || large.nonEmpty) small.length else 0.max(small.length - 1))
}


Measured memory_bytes: 25428
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using u32 = uint32_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	u32 n;
	
	std::cin >> n;

	u32 m = std::pow(2, n);
	
	std::vector<u32> v;
	v.reserve(m);

	std::map<u32, u32, std::greater<u32>> hist;
	
	for(u32 i = 0; i < m; i++)
	{
		u32 x;
		std::cin >> x;
		hist[x]++;
	}
/*
	std::cout << "map:\n";

	for(auto it = hist.begin(); it != hist.end(); it++)
	{
		std::cout << (*it).first << ": " << (*it).second << "\n";
	}

	std::cout << "\n";
*/
	v.push_back((*(hist.begin())).first);

	for(u32 i = 0; i < n; i++)
	{
		for(auto it = v.begin(); it != v.begin() + std::pow(2, i); it++)
		{
			//std::cout << "it = " << *it << "\n";
			auto lb = hist.lower_bound((*it)-1);
			bool ok = false;
			while (lb != hist.end()) {
				if((*lb).first < *it) {
					//std::cout << " " << (*lb).first << " : " << (*lb).second << "\n";
					ok = true;
					break;
				}
				lb++;
			}

			if (!ok) {
				std::cout << "No\n";
				return 0;
			}
			else
			{
				(*lb).second--;
				v.push_back((*lb).first);
				if((*lb).second == 0)
				{
					hist.erase(lb);
				}
			}
		}
/*
		std::cout << "i = " << i << "\n";
		for(u32 j = 0; j < v.size(); j++)
		{
			std::cout << v[j] << " ";
		}

		std::cout << "\n";*/
	}

	std::cout << "Yes\n";
	
	return 0;
}

Measured memory_bytes: 13568
import Data.Functor( (<$>))
import Text.Printf( printf)

main = do
    n <- read <$> getLine   ::IO Int
    xs <- (read <$>) . words <$> getLine
    ys <- (read <$>) . words <$> getLine
    let
	manhattan_base::[Double]
	manhattan_base = abs <$> zipWith (-) xs ys
	euclidean = sqrt . sum $ (^2) <$> manhattan_base
	l3 =  cubicrtMacro 1 0 . sum $ (^3) <$> manhattan_base
	chebyshev = maximum manhattan_base

	cubicrtMacro try last target
	  = let
		v = try^3
		diff = abs $ v - target
		macro = 2 * (try - last)
		micro = (try - last) / 2
	    in
		if diff < 0.000000000000001
		then try
		else if v < target
		    then cubicrtMacro (try + macro) try target
		    else cubicrtMicro (try - micro) try target

	cubicrtMicro try last target
	  = let
		v = try^3
		diff = abs $ v - target
		micro =  abs $ (try - last) / 2
	    in
		if micro < 0.000000000000001
		then try
		else if v < target
		    then cubicrtMicro (try + micro) try target
		    else cubicrtMicro (try - micro) try target

    printf "%.5f\n" $ sum manhattan_base
    printf "%.5f\n" euclidean
    printf "%.5f\n" l3
    printf "%.5f\n" chebyshev



Measured memory_bytes: 4488
import itertools

#19 choose 9
#92378

def main():
    N, M, Q = map(int, input().split())
    Q_l = []
    final_score = 0
    for i in range(Q):
        Q_l.append(list(map(int, input().split())))
    for A in itertools.combinations_with_replacement(range(1, M+1), N):
        score = 0
        for q in Q_l:
            if A[q[1]-1] - A[q[0]-1] == q[2]:
                score += q[3]
            final_score = max([final_score, score])
    print(final_score)
main()

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

int main(){
  int H,W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  vector<vector<int> > ans(H,vector<int>(W));
  int index=0;
  for(int i=0;i<H;i++){
    if(i%2==0){
      for(int j=0;j<W;j++){
        if(a.at(index)>0){
          ans.at(i).at(j)=index+1;
          a.at(index)--;
        }
        if(a.at(index)==0){
          index++;
        }
      }
    }else{
      for(int j=W-1;j>=0;j--){
        if(a.at(index)>0){
          ans.at(i).at(j)=index+1;
          a.at(index)--;
        }
        if(a.at(index)==0){
          index++;
        }
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << ans.at(i).at(j);
      if(j==W-1){
        cout << endl;
      }else{
        cout << " ";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 384
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val store = Array.tabulate(n){_ ⇒
    val Array(a, b) = readLine.trim.split(' ').map(_.toLong)
    (a, b)
  }.sortBy(_._1)
  println(
    buyM(m, store.toList)
  )

  def buyM(m: Int, store: List[(Long, Long)]): Long = {
    def sub(rest: Long, store: List[(Long, Long)], result: Long = 0): Long = {
      store match {
        case (a, b)::_ if b >= rest ⇒ result + a * rest
        case (a, b)::t ⇒ sub(rest - b, t, result + a * b)
        case Nil ⇒ ???
      }
    }
    sub(m, store)
  }

}

Measured memory_bytes: 78440
import java.io.*;
import java.util.*;

class Main{
	public void run(){
		String str = next();
		int win = 0;
		int lose = 0;
		for(int i=0;i<str.length();i++){
			if(i % 2 == 0){
				if(str.charAt(i) == 'p'){
					lose++;
				}
			}else{
				if(str.charAt(i) == 'g'){
					win++;
				}
			}
		}
        out.println(win - lose);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 9172
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long 
// #define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}
int d1[N] , d2[N];
vec g[N];
void dfs1(int x , int p){
	   for(auto y : g[x]){
	   	    if(y == p) continue;
	   	    else{
	   	    	   d1[y] = d1[x] + 1;
	   	    	   dfs1(y , x);
	   	    }
	   }
}
void dfs2(int x , int p){
	   for(auto y : g[x]){
	   	    if(y == p) continue;
	   	    else{
	   	    	   d2[y] = d2[x] + 1;
	   	    	   dfs2(y , x);
	   	    }
	   }
}
signed main(){
  fast;
  
  int n  , u , v , x , y;
  cin >> n >> u >> v;
  for(int i = 1 ; i < n ; i++){
  	   cin >> x >> y;
  	   g[x].pb(y);
  	   g[y].pb(x);
  }
  d1[u] = 0;
  dfs1(u , 0);
  d2[v] = 0;
  dfs2(v, 0);
  int ans = d2[u] - 1;
  for(int i = 1 ; i <= n ; i++){
  	     if(d1[i] < d2[i] && d2[i] > d2[u]){
  	     	
  	     	ans = max(ans ,d2[i] - 1);
  	     }
  }
  cout << ans << endl;
  
 }

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i=0; i<H; i++){
    cin >> vec.at(i);
  }
  
  
  
  for(int i=0; i<H; i++){
    if(i == 0){
      for(int j=0; j<W+2; j++){
        cout << '#';
      }
      cout << endl;
    }
      
    cout << '#';
    cout << vec.at(i);
    cout << '#' << endl;
    
    if(i == H-1){
      for(int j=0; j<W+2; j++){
        cout << '#';
      }
      cout << endl;
    }
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
#define  fi first
#define  se second 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    string s;
    cin>>s;
    cout<<(s.substr(0,4)=="YAKI"?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <bitset>

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

using namespace std;

pair<bool,int> ok(string& str,int beg=0){
  if(str[beg]=='-'){
    auto res = ok(str,beg+1);
    return make_pair(!res.first, res.second);
  } else if(str[beg] == '(') {
    auto res1 = ok(str, beg+1);
    if(str[res1.second] == '-') {
      auto res2 = ok(str, res1.second+2);
      return make_pair(!res1.first || res2.first, res2.second+1);
    } else {
      auto res2 = ok(str, res1.second+1);
      switch(str[res1.second]) {
        case '+':
        return make_pair(res1.first || res2.first, res2.second+1);
        case '*':
        return make_pair(res1.first && res2.first, res2.second+1);
        case '=':
        return make_pair(res1.first == res2.first, res2.second+1);
      }
    }
  } else {
    return make_pair(str[beg] == 'T', beg+1);
  }
}

int main() {
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    str = '(' + str + ')';
    bool f=true;
    REP(i,1<<11){
      string cp=str;
      bitset<11> b(i);
      REP(j,11){
        for(char& c:cp){
          if(c=='a'+j){
            c=b[j]?'T':'F';
          }
        }
      }
      if(!ok(cp).first)
        f=false;
    }
    if(f)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
#define MAX 100000
using namespace std;

int main()
{
  fastio
  int k, a, b;
  cin >> k >> a >> b;
  int total=0;
  bool done = false;
  while(total<=b)
  {
    total += k;
    if(total>=a && total<=b) done=true;
  }
  if(done) cout << "OK";
  else cout << "NG";
  return 0;
}




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

int main() {
    int N;
    cin >> N;
    int max_v = 0;
    int a;
    int r = 0;
    for (int i = 0; i < N;i++) {
        cin >> a;
        max_v = max(a, max_v);
        if (a >= max_v)
        {
            r++;
        }
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

inline void solve(){
	int N;
	cin >> N;
	int Amax = 100001;
	vector<int> Ah(Amax,0);
	int temp;
	for(int i=0;i<N;++i){
		cin >> temp;
		++Ah[temp];
	}
	vector<int> A;
	int kind = 0;
	for(int i=1;i<Amax;++i){
		if( Ah[i] ){
			if( (Ah[i]-1)%2 == 0 ){
				++kind;
			}else{
				A.push_back( 2 );
			}
		}
	}
	int Asize = A.size();
	int ama = Asize%2;
	if( ama == 1 ){
		//--
		--Asize;
	}
	cout << kind + Asize << endl;
}

int main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();

	return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>

int main()
{
  int n, a, b, c, d;
  char s[2000001];
  scanf("%d%d%d%d%d%s", &n, &a, &b, &c, &d, s);
  --a, --b, --c, --d;
  for (int i = a; i < c; ++i)
  {
    if (s[i] == '#' && s[i + 1] == '#')
    {
      puts("No");
      return 0;
    }
  }
  bool leap = false;
  for (int i = b; i <= d; ++i)
  {
    if (s[i] == '#' && s[i + 1] == '#' && i != d)
    {
      puts("No");
      return 0;
    }
    leap |= (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.');
  }
  if (c < d)
  {
    puts("Yes");
  }
  else
  {
    puts(leap ? "Yes" : "No");
  }
  return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define ABS(x) max((x),-(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T>>

template<typename T1, typename T2> inline void amin(T1 & a, T2 const & b) { if (a>b) a=b; }
template<typename T1, typename T2> inline void amax(T1 & a, T2 const & b) { if (a<b) a=b; }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
inline ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }

int solve(int H,int W,int N) {
    int res = H+W;
    rep(a,H+1) rep(b,W+1){
        int painted = a*b + a*(W-b) + b*(H-a);
        if (painted >= N){
            amin(res, a+b);
        }
    }
    return res;
}

int main() {
    int H,W,N; cin >> H >> W >> N;
    cout << solve(H,W,N) << endl;
    return 0;
}


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

int main(){
  int i,j,n,c[1001][1001];
  string x,y;
  cin >> n;
  while(n>0){
    n--;
    cin >> x;
    cin >> y;

    int lenx = x.size();
    int leny = y.size();

    for(i = 1; i <= lenx; i++){
      c[i][0] = 0;
    }
    for(j = 1; j <= leny; j++){
      c[0][j] = 0;
    }
  
    for(i = 1; i <= lenx; i++){
      for(j = 1; j <= leny; j++){
	if(x[i-1]==y[j-1]){
	  c[i][j] = c[i-1][j-1] + 1;
	}else if(c[i-1][j] >= c[i][j-1]){
	  c[i][j] = c[i-1][j];
	}else{
	  c[i][j] = c[i][j-1];
	}
      }
    }
    cout << c[lenx][leny] << endl;
  }
  return 0;
}

Measured memory_bytes: 5116
#include<cstdio>
#include<cstring>

char s[100100];

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=len;i>=len-7;i--)
	{
		s[i]=s[0];
	}
	printf("%s",s+1);
}

Measured memory_bytes: 128
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const x = BigInt(input[0])
    let m = BigInt(100)
    let y = 0
    while(m < x){
        m = BigInt(Math.trunc(Number(m) * 1.01))
        y++
    }
    console.log(y)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------
 
int n,d;

void solve()
{
	cin>>n>>d;
	int ans=(n/(2*d+1));
	if (ans*(2*d+1)!=n)ans++;cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    int t=1;
   // cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n%2!=0){
        cout<<"No"<<endl;
    }else{
    
        for(int i=0; i<n/2; i++){
            if(s[i]!=s[i+n/2]){
                cout<<"No"<<endl;
                break;
            }else if(i==n/2-1){
                cout<<"Yes"<<endl;
            }
        }
        
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int[] side = new int[n];
       for(int i=0;i<n;i++){
          side[i] = sc.nextInt();
       }
       int max = 0;
       for(int p=0;p<n;p++){
          if(max < side[p]){
            max = side[p];
          }
       }
       int sum = 0;
       for(int q=0;q<n;q++){
         sum += side[q];
       }
       if(sum-max>max){
         System.out.println("Yes");
       } else {
         System.out.println("No");
       }
	}
}

Measured memory_bytes: 23892
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
bool vis[maxn];
LL INF,dis[maxn];
int n,e,que[maxn];
int tot,lnk[maxn],son[maxn<<2],net[maxn<<2],w[maxn<<2];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
inline void add(int x,int y,int z){net[++tot]=lnk[x];son[tot]=y;w[tot]=z;lnk[x]=tot;}
void spfa(){
	memset(dis,63,sizeof(dis));INF=dis[0];
	int hed=0,tal=1;
	que[1]=1;dis[1]=0;
	while (hed!=tal){
		hed=(hed+1)%maxn;
		int x=que[hed];vis[x]=0;
		for (int j=lnk[x];j;j=net[j])
		if (dis[x]+w[j]<dis[son[j]]){
			dis[son[j]]=dis[x]+w[j];
			if (!vis[son[j]]){
				que[tal=(tal+1)%maxn]=son[j];vis[son[j]]=1;
				if (dis[que[(hed+1)%maxn]]>dis[son[j]]) swap(que[(hed+1)%maxn],que[tal]);
			}
		}
	}
}
int main(){
	n=read();e=read();
	for (int i=2;i<=n;i++) add(i,i-1,0);
	for (int i=1;i<=e;i++){int x=read(),y=read(),z=read();add(x,y,z);}
	spfa();
	if (dis[n]==INF) printf("-1");else printf("%lld",dis[n]);
	return 0;
}

Measured memory_bytes: 5888
import java.util.*;

public class Main {
	static long A[] = new long[87];
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(l(N));
	}
	
	public static long l(int n) {
		if (A[n] != 0) {
			return A[n];
		}
		
		long ans;
		if (n == 0) {
			ans = 2;
		} else if (n == 1) {
			ans = 1;
		} else {
			ans = l(n - 2) + l(n - 1);
		}
		A[n] = ans;
		
		return ans;
	}
}

Measured memory_bytes: 23124
<?php

fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);

$sum = 0;
if($a>$b){
$sum = $b;    
}else{
    $sum = $a;
}
if($c>$d){
$sum += $d;    
}else{
    $sum += $c;
}
echo  $sum;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli t;
	cin >> t;
	vector<lli> v;
	lli arr[15];
	arr[1] = 26;
	for1(i, 2, 13)
	{
		arr[i] = arr[i - 1] * 26;
	}
	lli k = 0;
	for1(i, 1, 13)
	{
		if (t <= arr[i])
		{
			k = i;
			break;
		}
	}
	lli a = 26;
	string s;
	while (t != 0)
	{
		lli y = t % a;
		char c = 'a' + y - 1;
		if (y == 0)
		{
			c = 'z';
			y = a;
		}
		// cout << c;
		s.pb(c);
		t -= y;
		t /= 26;
		// a *= 26;
	}
	for (int i = s.length() - 1; i >= 0; i--)
	{
		cout << s[i];
	}
	cout << endl;
	// // cout << t << " " << a << endl;
	// // lli y = t / a;
	// // cout << y << endl;
	// // char c = y + 'a' - 1;
	// // cout << c << endl;
	// while (k != 0)
	// {
	// 	lli a = pow(26, k - 1);
	// 	lli y = t / a;
	// 	cout << t << " " << a << endl;

	// 	t -= y * a;
	// 	k -= 1;
	// 	char c = y + 'a' - 1;
	// 	if (y == 0)
	// 	{
	// 		c = 'z';
	// 	}
	// 	cout << c << endl;

	// 	cout << c;
	// }
	// cout << endl;
}

Measured memory_bytes: 3640
import math

a,b,c = [float(s) for s in input().split()]
r = c * math.pi / 180
h = math.sin(r) * b
s = a * h / 2

x1 = a
y1 = 0
if c == 90:
    x2 = 0
else:
    x2 = math.cos(r) * b
y2 = h

d = math.sqrt((math.fabs(x1 - x2) ** 2) + (math.fabs(y1 - y2) ** 2))
l = a + b + d

print(s)
print(l)
print(h)

Measured memory_bytes: 7832
import math

from decimal import Decimal

A,B,C = map(int,input().split())

a = Decimal(A).sqrt()
b = Decimal(B).sqrt()
c = Decimal(C).sqrt()


#if math.sqrt(A)+math.sqrt(B)<math.sqrt(C):
if a+b<c:
    print("Yes")
else:
    print("No")
    
    



Measured memory_bytes: 60140
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	k <- readInt
	print $ sum $ do
		i <- [ 1 .. k ] 
		j <- [ 1 .. k ] 
		let
			ij = gcd i j
		k <- [ 1 .. k ] 
		return $ gcd ij k

Measured memory_bytes: 3904
import java.util.*;

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

        String s = sc.next();
        int cnt = 0;
        int n = s.length();

        for(int i = 0; i < n; i++){
            if(s.charAt(i) == '1'){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
main()
{
    int n;cin>>n;
    pair<int,int> a[n];
    rep(i,n)
    {
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(a,a+n,greater<>());
    rep(i,n)
    {
        if(a[0].second==i)cout<<a[1].first<<endl;
        else cout<<a[0].first<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
// using std::gcd;
using std::make_pair;
using std::max;
using std::min;
using std::pair;
using std::sort;
using std::string;
using std::vector;
using lli  = long long;
using ulli = unsigned long long;

// pairの入出力
template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
    os << p.first << " " << p.second;
    return os;
}

// vectorの入出力
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &in : v) is >> in;
    return is;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return os;
}

// よく使う定数
// std::string ans[2] = {"No\n", "Yes\n"};
constexpr int MOD = 1'000'000'007;
// constexpr int MOD = 998'244'353;

// メイン
int main() {
    using std::cin;
    using std::cout;
    using std::endl;

    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int awaik = (h2 - h1 - 1) * 60 + m2 + 60 - m1;
    int ans   = awaik - k;
    cout << ans << endl;

    return 0;
}

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




int main()
{
long long a, b;
cin >> a >> b;
if(a % 2 != b % 2)
{
	cout << "IMPOSSIBLE" << endl;
}
else
{
	cout << (a + b) / 2 << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<n;i++){
    if(i==n-1){
      sum+=p[i]/2;
    }
    else{
      sum+=p[i];
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <stack>
#include <string>
#include <map>

using namespace std;

int main()
{
	int H,W,h,w;
	cin >> H >> W;
	cin >> h >> w;
	cout << (H*W) - h * W - H * w +h*w<< endl;
}


Measured memory_bytes: 256
mod = 1000000007
with open(0) as f:
    N, s, t = f.read().split()

#ドミノの並べ方を0,1で整理
domino = []
s += '_'
c = s[0]
lying = False
for x in s[1:]:
    if x == c:
        lying = True
        continue

    if lying:
        domino.append(1)
    else:
        domino.append(0)
    c = x
    lying = False

#初期値
if domino[0] == 0:
    ans = 3
else:
    ans = 6
#右へ走査
for idx,d in enumerate(domino[1:]):
    if domino[idx] == 0:
        ans *= 2
    else:
        if d == 0:
            ans *= 1
        else:
            ans *= 3
    ans %= mod
print(ans)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(k>0) ans+=min(a,k);
    k-=min(a+b,k);
    if(k>0) ans-=min(c,k);
    cout<<ans<<endl;
} 

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int n, m, x, fro = 0, buc = 0;
	cin >> n >> m >> x;
	int a[m];

	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		if (x < a[i]) fro++;
		else buc++;
	}

	cout << min(fro, buc) << "\n";

	return 0;
}

Measured memory_bytes: 256
from math import ceil, floor

X, K, D = map(int, input().split())

X = abs(X)

r = floor(X / D)

if K <= r:
    print(X - K * D)
    exit()

l = r + 1

if (K - r) % 2 == 0:
    print(X - r * D)
else:
    print(abs(X - l * D))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;(i)<(n);i++)
typedef long long ll;
using namespace std;
int main(void){
    int n; cin >> n;
    string s[50];
    int t[50];
    rep(i,n){
        cin >> s[i] >> t[i];
    }
    string asleep; cin >> asleep;
    int x=0;
    rep(i,n){
        if(asleep==s[i]){
            x = i;
            break;
        }
    }
    int ans = 0;
    for(int i=x+1;i<n;i++) ans+=t[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

const int MAX_N = 110;
const int MAX_V = 100010;
int main() {
    int n, w;
    cin >> n >> w;
    int weight[n];
    ll values[n];
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> values[i];
    }

    vector<vector<ll>> dp(MAX_N, vector<ll>(MAX_V));
    for (int i = 0; i < MAX_N; i++) {
        for (int j = 0; j < MAX_V; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int sum_v = 0; sum_v < MAX_V; sum_v++)
        {
            if (sum_v - values[i] >= 0)
            {
                chmin(dp[i + 1][sum_v], dp[i][sum_v - values[i]] + weight[i]);
            }
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    ll res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[n][sum_v] <= w) res = sum_v;
    }

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

Measured memory_bytes: 90384
n,q = map(int,input().split())
s = input()
lr = []
for i in range(q):
    lr.append([int(i) for i in input().split()])
    
acnum = []
acsum = 0
acnum.append(acsum)
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        acsum +=1
    acnum.append(acsum)
for i in range(q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1
    retSum = 0
    print(acnum[r] - acnum[l])

Measured memory_bytes: 24468
#include <stdio.h>

typedef long long ll;

ll A[100005];

ll min(ll a, ll b);

int main() {

	int N;

	scanf("%d",&N);

	int i;

	for (i = 0; i < N; i++) {
		scanf("%lld",&A[i]);
	}
	
	ll ans = 0;

	for (i = 0; i < N - 1; i++) {
		ans += A[i] / 2;
		A[i] -= (A[i] / 2) * 2;
		if (A[i] > 0 && A[i + 1] > 0) {
			ans++;
			A[i]--;
			A[i + 1]--;
		}
	}
	ans += A[N - 1] / 2;

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

	return 0;
}
ll min(ll a, ll b) {
	if (a >= b) { return b; }
	else { return a; }
}

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

int main() {
  int x, y;
  cin >> x >> y;
  bool r = false;
  for (int i = 0; i <= x; i++) r = r || 2 * i + 4 * (x - i) == y;
  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string s, in;
    while (cin >> in)
        s += in;
    for (char c = 'a'; c <= 'z'; c++)
        cout << c << " : " << count(s.begin(), s.end(), c) + count(s.begin(), s.end(), toupper(c)) << endl;
}


Measured memory_bytes: 3240
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string N;
    cin >> N;
    rep(i, 3) {
        if(N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628