akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused_imports)]

// Input
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)*} }; }
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)*} };}
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        X: u64,
        Y: u64,
    }
    let mut ans = "No";
    let A = [1,3,5,7,8,10,12];
    if A.contains(&X) && A.contains(&Y){
        ans = "Yes";
    }
    let B = [4,6,9,11];
    if B.contains(&X) && B.contains(&Y){
        ans = "Yes";
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ret = 0;
  for (long long q = 1; (q + 1) * q < n; q++) {
    if (!(n % q)) {
      long long m = n / q - 1;
      ret += m;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin>>n;
	int a[n];
	forr(i,n) cin>>a[i];
	int ans = INF;
	for(int i=0;i<=100;i++){
		int curr = 0;
		for(int j=0;j<n;j++){
			curr+=(i-a[j])*(i-a[j]);
		}
		ans = min(ans,curr);
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split()))
res = 0
left = 0
right = 0
s0 = 0
s1 = 0
while left < n:
    while right < n and s0 + ls[right] == s1 ^ ls[right]:
        s0 += ls[right]
        s1 ^= ls[right]
        right += 1
    res += right - left
    s0 -= ls[left]
    s1 ^= ls[left]
    left += 1
print(res)

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

int main() {
    int N;
    cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    }
    int count = 0;
    int a,b;
    a = b = 0;
    for(int j = 0;j<N-2;j++){
        vector<int> suuretu(3);
        suuretu.at(0) = retu.at(j);
        suuretu.at(1) = retu.at(j+1);
        suuretu.at(2) = retu.at(j+2);
        sort(suuretu.begin(),suuretu.end());
        if(retu.at(j+1) == suuretu.at(1)){
            count++;
        }
        suuretu = {0,0,0};
    }
  
  	cout << count << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int decks = 100;
		int[] deck = new int[decks];
		
		while(true){
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			char[] input = sc.next().toCharArray();
			for(int i = 0; i < decks; i++){
				if(input[i] == 'M'){
					deck[i] = 0;
				}else if(input[i] == 'S'){
					deck[i] = 1;
				}else if(input[i] == 'L'){
					deck[i] = 2;
				}
			}
			
			int field = 0;
			int[] player = new int[N];
			
			for(int i = 0; i < decks; i++){
				final int play = i % N;
				
				if(deck[i] == 0){
					player[play]++;
				}else if(deck[i] == 1){
					field += player[play] + 1;
					player[play] = 0;
				}else if(deck[i] == 2){
					player[play] += field + 1;
					field = 0;
				}
			}
			
			Arrays.sort(player);
			for(int i = 0; i < N; i++){
				if(i != 0){
					System.out.print(" ");
				}
				
				System.out.print(player[i]);
			}
			System.out.println(" " + field);
		}
	}

}

Measured memory_bytes: 22024
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	for i := 0; i < num; i++ {
		sc.Scan()
		line := sc.Text()

		insertCheck(line)
	}
}

func insertCheck(line string) {
	var B, C []int

	for _, v := range strings.Split(line, " ") {
		ball, _ := strconv.Atoi(v)
		switch {
		case len(B) == 0:
			B = append(B, ball)
		case B[len(B)-1] < ball:
			B = append(B, ball)
		case B[len(B)-1] >= ball:
			switch {
			case len(C) == 0:
				C = append(C, ball)
			case C[len(C)-1] < ball:
				C = append(C, ball)
			case C[len(C)-1] >= ball:
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}



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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> f(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  for(ll i=0;i<n;i++) {
    cin >> f[i];
  }
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  ll ng=-1,ok=a[n-1]*f[n-1];
  for(ll i=0;i<n;i++) {
    ok=max(ok,a[i]*f[i]);
  }
  ll temp=(ng+ok)/2;
  while(ok-ng>1) {
    ll syu=k;
    for(ll i=0;i<n;i++) {
      if(a[i]*f[i]>temp) {
        syu-=a[i]-temp/f[i];
      }
    }
    if(syu>-1){
      ok=temp;
    }
    else {
      ng=temp;
    }
    temp=(ng+ok)/2;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    
    int s = 0;
    FOR(i,1,n) s += a[i];
    int res = 1000000000, lef = 0;
    FOR(t,1,n-1) {
        lef += a[t];
        int rig = s - lef;
        res = min(res, abs(lef-rig));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n,p;
long long m,v,a[100100],qzh[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>v>>p;
	v=n-v;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]=10-a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		qzh[i]=qzh[i-1]+a[i];
	for(int i=p+1;i<=n;i++){
		if(a[i]-a[p]>m){
			cout<<i-1<<endl;
			return 0; 
		}
		long long he=qzh[i-1]-qzh[p-1];
		he=a[i]*(i-p)-he;
		if(he>1LL*m*v){
			cout<<i-1<<endl;
			return 0;
		}
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 1792
package main

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

func main() {
	reader := bufio.NewScanner(os.Stdin)
	var r bool
	for reader.Scan() {
		text := reader.Text()
		r = strings.HasPrefix(text, "YAKI")
	}
	if r {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i
    integer(int32), allocatable:: x(:),dx(:)

    read*, n,m
    if (n >= m) then
        print'(i0)', 0
        stop
    end if
    allocate(x(m))
    read*, x(:)
    allocate(dx(m-1))
    call merge_sort(x,1,m)
    do i=1,m-1
        dx(i) = x(i+1)-x(i)
    end do
    call merge_sort(dx,1,m-1)
    print'(i0)', sum(dx(1:m-n))

contains
recursive subroutine merge_sort(ar, fst, lst)
    integer(int32),intent(inout):: ar(:)
    integer(int32),intent(in):: fst,lst
    integer(int32):: mdl

    if (lst-fst < 2) then
        if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
        return
    end if

    mdl = (fst+lst)/2
    call merge_sort(ar, fst, mdl)
    call merge_sort(ar, mdl+1, lst)
    call merge_(ar, fst, mdl, lst)
end subroutine

subroutine merge_(ar, fst, mdl, lst)
    integer(int32),intent(inout):: ar(:)
    integer(int32),intent(in):: fst, mdl, lst
    integer(int32),allocatable:: tmp(:)
    integer(int32):: li, ri, ti

    allocate(tmp(lst-fst+1))

    li=fst
    ri=mdl+1   
    ti=1

    do while (li <= mdl .and. ri <= lst)
        if (ar(li) <= ar(ri)) then
            tmp(ti) = ar(li)
            li=li+1
        else
            tmp(ti) = ar(ri)
            ri=ri+1
        end if
        ti=ti+1
    end do

    if (li <= mdl) then
        tmp(ti:) = ar(li:mdl)
    else
        tmp(ti:) = ar(ri:lst)
    end if

    ar(fst:lst) = tmp(:)
    deallocate(tmp)
end subroutine

subroutine swap(x,y)
    integer(int32),intent(inout):: x,y
    integer(int32):: tmp
    tmp = x
    x = y
    y = tmp
end subroutine
end program name

Measured memory_bytes: 1844
import math

one = [10]
total = 0
for i in range(5):
    time = input()
    if time[-1] != "0":
        one.append(int(time[-1]))
    time = int(time)
    time = math.ceil(time / 10) * 10
    total += time
total += min(one) - 10
print(int(total))


Measured memory_bytes: 3060
#include<stdio.h> 
#include<algorithm> 
using namespace std; 
struct tt{
	long long v,t;
	long double w;
}c[5];
bool cmp(tt p1,tt p2){
	return p1.w<p2.w;
}
long long n; 
int main(){
    scanf("%lld %lld %lld %lld %lld",&c[1].v,&c[2].v,&c[3].v,&c[4].v,&n);
    c[1].t=25;
    c[2].t=50;
    c[3].t=100;
    c[4].t=200;
    for(int i=1;i<=4;i++)
    	c[i].w=c[i].v*1.0/c[i].t;	
    n*=100;
    sort(c+1,c+5,cmp);
    long long sum=0,ans=0;
    for(int i=1;i<=4;i++){
    	long long a=n/c[i].t;
    	n-=a*c[i].t;
    	ans+=a*c[i].v;
    	//printf("%lld %lld\n",c[i].t,a);
	    if(n==0)break;
    }
    printf("%lld\n",ans); 
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	int ans=0;
	
	cin>>n;
	if(n>=64)
	{
		ans=64;
	}else if(n>=32){
		ans=32;
	}else if(n>=16){
		ans=16;
	}else if(n>=8){
		ans=8;
	}else if(n>=4){
		ans=4;
	}else if(n>=2){
		ans=2;
	}else{
		ans=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}string s;

ll buc[30];
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,k,x,q;
    int t=1;
    cin>>n;
    cin>>s;
    fr(i,n)buc[s[i]-'a']++;
    ll ans = 1;
    fr(i,26)ans = (ans*1ll*(buc[i]+1))%mod;
    cout<<(ans+mod-1)%mod<<"\n";

    
    return 0;
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DPowerfulDiscountTickets {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      priority_queue<int> que;
      rep(i, n) {
        int a; cin >> a;
        que.push(a);
      }
      while(m--) {
        int p = que.top(); que.pop();
        p /= 2;
        que.push(p);
      }
      ll ans = 0;
      while(!que.empty()) {
        int p = que.top(); que.pop();
        ans += p;
      }
      cout << ans << endl;
    }
};

signed main() {
  DPowerfulDiscountTickets solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K, Q;
  cin >> N >> K >> Q;
  vl P(N, K - Q);
  REP(i, Q) {
    ll s;
    cin >> s;
    P[s - 1]++;
  }
  REP(i, N) {
    if (P[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int n,m,num,t,ans;
int P[100];
struct node{
	int cnt;
	int a[100];
}b[100];
bool vis[100];
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

void dfs(int pos){
	if(pos>n){
		num=0;
		For(i,1,m){
			t=0;
			For(j,1,b[i].cnt){
				t+=vis[b[i].a[j]];
			}
			if(t%2==P[i]) num++;
		}
		if(num==m)  ans++;
		return;
	}
	For(i,0,1){
		vis[pos]=i;
		dfs(pos+1);
	}
}

signed main(){
    in(n);in(m);
    For(i,1,m){
    	in(b[i].cnt);
    	For(j,1,b[i].cnt){
    		in(b[i].a[j]);
    	}
    }
    For(i,1,m) in(P[i]);
    For(i,0,1){
    	vis[1]=i;
    	dfs(2);
    }
    o(ans);
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	ll X = 1;
	while (X * (X+1) <= 2*N) ++X;
	FOR(i, 1, X+1) if (i != X*(X+1)/2-N) print(i);
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main()
{
    int k;
    cin >> k;
    int a, b;
    int flag = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) 
    {
        if(i % k == 0) 
        {
            cout << "OK";
            flag = 1;
            break;
        }
    }
    if (flag == 0)
    {
        cout << "NG";
    }
    return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
int main(void)
{
  int A[100][100],b[100],c[100],n,m,i,j,sum;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
	{scanf("%d",&A[i][j]);}
    }
  for(j=0;j<m;j++)
    {scanf("%d",&b[j]);}
  for(i=0;i<n;i++)
    {
      sum=0;
      for(j=0;j<m;j++)
	{sum+=A[i][j]*b[j];}
      c[i]=sum;
    }
  for(i=0;i<n;i++)
    {
      printf("%d\n",c[i]);
    }
  return 0;
}

Measured memory_bytes: 640
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    x = I()
    n = x//100
    a = x%100
    print(1 if a <= 5*n else 0)

Measured memory_bytes: 9128
import math
import bisect
inf=10**12
a,b,q=map(int,input().split())
s=[-inf]+[int(input()) for _ in range(a)]+[inf];s.sort()
t=[-inf]+[int(input()) for _ in range(b)]+[inf];t.sort()

for i in range(q):
    x=int(input())
    p=bisect.bisect_left(s,x)
    q=bisect.bisect_left(t,x)

    sl,sr,tl,tr=s[p-1],s[p],t[q-1],t[q]

    sltl=x-min(sl,tl)
    srtr=max(sr,tr)-x
    sltr=min(x-sl*2+tr,-x-sl+tr*2)
    srtl=min(x-tl*2+sr,-x-tl+sr*2)
    print(min(sltl,srtr,sltr,srtl))

Measured memory_bytes: 12824
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    int n;int ti=0;
    cin>>n;
    while(n>0)
    {
        if(n%10==9){ti = 1;cout<<"Yes"<<endl;break;}
        n/=10;
    }
    if(ti == 0)cout<<"No"<<endl;

    return 0;
}


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

const int N = 2e5;
int n;
ll A[N + 87];
ll dp[N + 87][5];///all->#odd->#even->#odd->all

int iseven(ll k){
	return (k % 2 == 0) ? 1 : 0;
}
int isodd(ll k){
	if(k == 0)
		return 2;
	return 1 - iseven(k);
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	ll now = A[0];
	dp[0][0] = now;
	dp[0][1] = isodd(now);
	dp[0][2] = iseven(now);
	dp[0][3] = isodd(now);
	dp[0][4] = now;

	for(int i = 1; i <= n; i++){
		now = A[i];
		ll tmp = dp[i - 1][0];
		dp[i][0] = tmp + now;
		tmp = min(tmp, dp[i - 1][1]);
		dp[i][1] = tmp + isodd(now);
		tmp = min(tmp, dp[i - 1][2]);
		dp[i][2] = tmp + iseven(now);
		tmp = min(tmp, dp[i - 1][3]);
		dp[i][3] = tmp + isodd(now);
		tmp = min(tmp, dp[i - 1][4]);
		dp[i][4] = tmp + now;
	}

	ll ans = dp[n][1];
	for(int i = 1; i < 5; i++)
		ans = min(ans, dp[n][i]);
	cout << ans << "\n";
}

Measured memory_bytes: 9728
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int x = sc.nextInt();
        long ans = (x / 500)*1000;
        x %= 500;
        ans += (x/5)*5;
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 32928
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int ans = 1;
		for(int i=1;i<=D;++i){
			ans *= 100;
		}
		if(N==100) N++;
		System.out.println(ans * N);
		return;
	}
}

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

int main() {
  int N;
  bool ans;
  ans = false;
  cin >> N;
  for (int m=1; m < 10; m++){
    if (N%m == 0 && N/m < 10){
      ans = true;
    }
  }
  if (ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int l1;
#define input l1 t;cin>>t;while(t--)
#define pb push_back
int main(){
	l1 n,m,ans;
  	cin>>n>>m;
  	if(n>m){
      l1 k=n%m;
      l1 r=abs(k-m);
      ans=(r<k)?r:k;
    }
  	else{
      l1 r1=abs(n-m);
      ans=(r1<n)?r1:n;
    }
  cout<<ans;
  
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int a[10010] = {0};
    rep(i,100){
        rep(j,100-i/2){
            rep(k,100-i/2-j/2){
                int t= (i+1)* (i+1)+ (j+1)* (j+1)+ (k+1)* (k+1)+(i+1)* (j+1)+ (i+1)* (k+1)+ (j+1)* (k+1);
                if(t<10010){
                    a[t]++;
                }
            }
        }
    }
    int n,total=0;
    cin >> n;
    rep(i,n){
        cout << a[i+1] << endl;
    }
}

Measured memory_bytes: 3196
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


template< typename Monoid >
class SegmentTree {
public:
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

vector<ll> compress(vector<ll>v){
    ll N=v.size();
    vector<ll>copy;
    for(int i=0;i<N;i++){
        copy.push_back(v[i]);
    }
    sort(copy.begin(),copy.end());
    vector<ll>ret;
    for(int i=0;i<N;i++){
        ret.push_back(lower_bound(copy.begin(),copy.end(),v[i])-copy.begin());
    }
    return ret;
}

int main(){
    init();
    ll N;cin>>N;
    vector<ll>ans(N,-1);
    ll ansnum=0;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        //これより小さい最小のindex
        *(lower_bound(ans.begin(),ans.end(),a)-1)=a;
    }
    for(auto i : ans)if(i!=-1)ansnum++;
    cout<<ansnum<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ms=(1<<16)-1;
int expr(string s,int& p);
int factor(string s,int& p);
int number(string s,int& p);
int expr(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      res&=factor(s,p);
      continue;
    }
    if(s[p]=='^'){
      p++;
      res^=factor(s,p);
      continue;
    }
    break;
  }
  return res;
}
int factor(string s,int& p){
  if(s[p]=='-'){
    p++;
    return (~factor(s,p))&ms;
  }
  if(s[p]=='('){
    p++;
    int res=expr(s,p);
    assert(s[p]==')');
    p++;
    return res;
  }
  assert(isalpha(s[p])||isdigit(s[p]));
  return number(s,p);
}
int calc(char c){
  if(c=='0') return 0b0000000000000000;
  if(c=='1') return 0b1111111111111111;
  if(c=='a') return 0b1010101010101010;
  if(c=='b') return 0b1100110011001100;
  if(c=='c') return 0b1111000011110000;
  if(c=='d') return 0b1111111100000000;
  assert(0);
}
int number(string s,int& p){
  char c=s[p++];
  return calc(c);
}
int dp[1<<16];
typedef pair<int,int> P;
signed main(){
  for(int i=0;i<(1<<16);i++) dp[i]=16;
  priority_queue<P,vector<P>,greater<P> > q;
  string t="01abcd";
  for(int i=0;i<(int)t.size();i++){
    int k=calc(t[i]);
    dp[k]=1;
    q.push(P(dp[k],k));
  }
  while(!q.empty()){
    P p=q.top();q.pop();
    int k=p.second;
    if(dp[k]<p.first) continue;
    //cout<<bitset<16>(k)<<" "<<dp[k]<<endl;
    {
      int nk=(~k)&ms,c=1;
      if(dp[nk]>dp[k]+c){
	dp[nk]=dp[k]+c;
	q.push(P(dp[nk],nk));
      }
    }
    for(int i=0;i<(int)t.size();i++){
      int nk=k&calc(t[i]),c=4;
      if(dp[nk]>dp[k]+c){
	dp[nk]=dp[k]+c;
	q.push(P(dp[nk],nk));
      }
    }
    for(int i=0;i<(int)t.size();i++){
      int nk=k^calc(t[i]),c=4;
      if(dp[nk]>dp[k]+c){
	dp[nk]=dp[k]+c;
	q.push(P(dp[nk],nk));
      }
    }
    for(int i=0;i<(int)t.size();i++){
      int nk=k&((~calc(t[i]))&ms),c=5;
      if(dp[nk]>dp[k]+c){
	dp[nk]=dp[k]+c;
	q.push(P(dp[nk],nk));
      }
    }
    for(int i=0;i<(int)t.size();i++){
      int nk=k^((~calc(t[i]))&ms),c=5;
      if(dp[nk]>dp[k]+c){
	dp[nk]=dp[k]+c;
	q.push(P(dp[nk],nk));
      }
    }
  }
  string s;
  while(cin>>s,s!="."){
    int p=0;
    int k=expr(s,p);
    cout<<min((int)s.size(),dp[k])<<endl;
  }
  return 0;
}

Measured memory_bytes: 3736
n, k = map(int, input().split())
s = str(input())
ans = 0
for i in range(n-2):
    if s[i + 1] == 'L':
        if s[i] == 'L':
            ans += 1
    if s[i + 1] == 'R':
        if s[i + 2] == 'R':
            ans += 1
if s[0] == 'R':
    if s[1] == 'R':
        ans += 1
if s[n-1] == 'L':
    if s[n - 2] == 'L':
        ans += 1
ans += k * 2
print(min(n-1,ans))


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ws(n);
    for (auto& w : ws) {
        cin >> w;
    }
    int total_sum = 0;
    for (auto w : ws) {
        total_sum += w;
    }
    int best_diff = total_sum;
    int running_sum = 0;
    for (auto w : ws) {
        running_sum += w;
        best_diff = min(best_diff, abs(2*running_sum - total_sum));
    }
    cout << best_diff << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e3+17;
int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    vector<pair<int, pair<int,int > > > vec(n+1);
    vec.push_back({0,{0,0}});
    for (int i = 1; i <= n; ++i)
    	cin>>vec[i].first>>vec[i].second.first>>vec[i].second.second;
    for (int i = 0; i <= n-1; ++i)
    {
    	debug(abs(vec[i+1].second.first-vec[i].second.first));
    	debug(abs(vec[i+1].second.second-vec[i].second.second));
    	int dis = abs(vec[i+1].second.first-vec[i].second.first)
    			 +abs(vec[i+1].second.second-vec[i].second.second);
    	int t = vec[i+1].first-vec[i].first;
    	debug(dis);
    	debug(t);
    	if(dis>t||(t-dis)%2!=0)
    		return cout<<"No"<<endl,0;
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
const int mx = 100020;
ll gcd(ll a, ll b)
{
    return a == 0 ? b : gcd(b%a, a);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    int res = 0;
    for (int i = 2; 1ll * i *i <= g; ++i)
    {
        if (g%i == 0)
        {
            res++;
            while (g&&g%i == 0)g /= i;
        }
    }
    if (g > 1) res++;
    cout << res + 1;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<pair<bool,int>>choice(n);
	bool same=true;
	int ans=0,mini=0;
	for(int i=0;i<n;i++){
		choice[i].second=i;
		ans+=abs(a[i]);
		if(a[i]>0)
			choice[i].first=true;
		else
			choice[i].first=false;
		if(i>=1&&choice[i].first!=choice[i-1].first)
			same=false;
		if(abs(a[i])<abs(a[mini]))
			mini=i;
	}
	if(same){
		ans-=2*abs(a[mini]);
		choice[mini].first=!choice[mini].first;
	}
	int m,x[99999],y[99999];
	m=ans;
	bool rev=false;
	for(int i=0;i<n-1;i++){
		if(i==n-2){
			if(choice[0].first!=rev){
				x[0]=a[choice[0].second];
				y[0]=a[choice[1].second];
			}else{
				x[0]=a[choice[1].second];
				y[0]=a[choice[0].second];
			}
		}else{
			int sz=choice.size();
			int num=-1;
			if(choice[sz-1].first==choice[sz-2].first)
				num=sz-1;
			else
				num=sz-3;
			if(choice[num].first!=rev){
				rev=!rev;
				x[n-2-i]=choice[num].second;
				y[n-2-i]=-1;
			}else{
				x[n-2-i]=-1;
				y[n-2-i]=choice[num].second;
			}
			choice.erase(choice.begin()+num);
		}
	}
	int sum=x[0]-y[0];
	for(int i=1;i<n-1;i++){
		if(x[i]==-1){
			x[i]=sum;
			y[i]=a[y[i]];
			sum-=y[i];
		}else{
			y[i]=sum;
			x[i]=a[x[i]];
			sum=x[i]-sum;
		}
	}
	cout<<m<<endl;
	for(int i=0;i<n-1;i++)
		cout<<x[i]<<' '<<y[i]<<endl;
}


Measured memory_bytes: 3840
using System;
using System.IO;
using System.Linq;

namespace ABC127C
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = temp[0];
            var M = temp[1];
            var lmax = 0;
            var rmin = N - 1;

            for (int i = 0; i < M; i++)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                lmax = Math.Max(lmax, temp[0] - 1);
                rmin = Math.Min(rmin, temp[1] - 1);
                // Console.WriteLine(lmax + " : " + rmin);
            }

            if (rmin < lmax)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(rmin - lmax + 1);
            }
        }
    }
}


Measured memory_bytes: 17472
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;
int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << Max(A * C, A * D, max(B * C, B * D));
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;

int main(){
    int N;
    cin >> N;
    double sum=0;

    for(int i=0;i<N;i++){
        double A;
        string S;
        cin >> A >> S;
        if(S == "BTC") sum+= 380000*A;
        else sum += A;
    }
    cout << sum << endl;

}

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

int main() {
    long double A,B,H,M;
    cin >> A >> B >> H >> M;
    long double PI=3.1415926535;
    long double theta=(30.0*(H+M/60.0) - 6.0*M)/180.0*PI;
    cout<< setprecision(10) << sqrtl((A*A+B*B)-(2.0*A*B*cosl(theta))) << endl;

    }
    

Measured memory_bytes: 4164
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>

using lli = long long int;
using namespace std;
int inf = 1000000007;

class Edge {
public:
	int to;
	lli cost;
	Edge(int t, lli c) { to = t; cost = c; }
};

class Node {
public:
	vector<Edge> relate;
	lli cost = 0;
	bool visit = false;
};

int N;
int a, b, c;
int Q, K;
int x, y;

int main() {
	cin >> N;
	vector<Node> nodes(N + 1);
	//木なのでBFSでよい
	for (int i = 1; i < N; i++) {
		cin >> a >> b >> c;
		nodes[a].relate.push_back(Edge(b, c));
		nodes[b].relate.push_back(Edge(a, c));
	}
	cin >> Q >> K;
	queue<int> q;
	q.push(K);
	while (q.size() != 0) {
		int n = q.front();
		q.pop();
		if (nodes[n].visit)continue;
		nodes[n].visit = true;
		for (auto z : nodes[n].relate) {
			if (!nodes[z.to].visit) {
				nodes[z.to].cost = nodes[n].cost + z.cost;
				q.push(z.to);
			}
		}
	}
	//質問に答える
	for (int i = 0; i < Q; i++) {
		cin >> x >> y;
		cout << nodes[x].cost + nodes[y].cost << endl;
	}
}


Measured memory_bytes: 10752
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

int cntDigits(int num) {
    int cnt = 0;
    while(num > 0) {
        num /= 10;
        cnt++;
    }
    return cnt;
}

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

    int n, ans = 0;
    cin >> n;
    REP(i, 1, n + 1) {
        if(cntDigits(i) & 1) ans++;
    }
    COUT(ans);
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S, T;
	cin >> S >> T;

	ll A = S.size();
	ll B = T.size();

	ll dp[A+1][B+1];
	pll st[A+1][B+1];
	REP(i, A+1) dp[i][0] = 0, st[i][0] = {-1, -1};
	REP(i, B+1) dp[0][i] = 0, st[0][i] = {-1, -1};
	REP(i, A){
		REP(j, B){
			if(S[i]==T[j]){
				dp[i+1][j+1] = dp[i][j] + 1;
				st[i+1][j+1] = {i, j};
			}else{
				if(dp[i+1][j] >= dp[i][j+1]){
					dp[i+1][j+1] = dp[i+1][j];
					st[i+1][j+1] = {i+1, j};
				}else{
					dp[i+1][j+1] = dp[i][j+1];
					st[i+1][j+1] = {i, j+1};
				}
			}
		}
	}
	pll now = {A, B};
	string res = "";
	while(now.first>0&&now.second>0){
		pll back = st[now.first][now.second];
		if(now.first-back.first==1&&now.second-back.second==1){
			res = S[back.first] + res;
		}
		now = back;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 211328
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b;
    if ((a%2) && (b%2)) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
gets.to_i
T, A = gets.chomp.split(" ").map(&:to_f)
H = gets.chomp.split(" ").map(&:to_f)

ans = H.map.with_index{|h, i| [(T - h * 0.006 - A).abs, i + 1]}.min_by{|t, i| t}

puts ans[1]


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

int main(){
    ll A, B, time;
    cin >> A >> B >> time;

    vector<ll> S1(A+1), S2(B+1);
    S1[0] = S2[0] = 0;

    for(ll i = 1; i <= A; i++ )
        cin >> S1[i], S1[i] += S1[i-1];
    for(ll i = 1; i <= B; i++ )
        cin >> S2[i], S2[i] += S2[i-1];

    ll i = 0, j = B;
    ll ans = 0;
    for( ; i <= A; i++){
        if(S1[i] > time) break;
        while(S1[i]+S2[j] > time) j--;
        ans = max(ans, i+j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6432
// 419 Molting
// 2019.12.7 bal4u

#include <stdio.h>

typedef long long ll;

char s[103];

int main()
{
	int i, L, N;
    ll ans;

    scanf("%d%d%s", &L, &N, s);
    ans = 0;
    for (i = 0; i < L; ++i) {
        if (s[i] == 'o' && s[i+1] == 'o') {
            ans += ((1LL << N)-1)*3;
        }
        ++ans;
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2144
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int a,b,c,d,ck=1;
	cin>>a>>b>>c>>d;
	while(1){
		c -= b;
		if(c<=0){
			ck=1;
			break;
			}
		a -= d;
		if(a<=0){
			ck=0;
			break;
			}
		}
	if(ck)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3632