akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
}edge[N*2];
int tot,head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
void SPFA(int s,int e) {
    priority_queue<Edge> Q;
    memset(dis,INF,sizeof(dis));
    memset(vis,false,sizeof(vis));
    dis[s]=0;

    Q.push(Edge(s,0,0));
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;

        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
            }
        }

    }
    printf("%d\n", dis[e]==INF?-1:dis[e]/2);
}

map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);
        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    SPFA(1,n);

    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

i64 k,a,b;

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

  i64 r = k - (a-1);
  i64 c = a + (b-a)*(r/2) + r%2;
  cout << max(c, k + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let n = read!(usize);
    let v = n%10;
    if v==0 || v==1 || v==6 || v==8 {
        println!("pon");
    }
    else if v==3 {
        println!("bon");
    }
    else {
        println!("hon");
    }
}

fn run() {
    solve();
}

Measured memory_bytes: 2240
import sys
input = sys.stdin.buffer.readline

K, N = map(int, input().split())
A = list(map(int, input().split()))

B = [A[0] + K - A[-1]]
for i in range(N - 1):
    B.append(A[i + 1] - A[i])

print(K - max(B))

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

int main(){
    int N;
    cin >> N;
    float sum = 0;
    for (int i = 0; i < N; i++) {
        float a;
        string b;
        cin >> a >> b;
        if(b == "JPY") {
            sum += a;
        } else {
            sum += a * 380000.0;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    a=abs(n-a);
    b=abs(n-b);
    if(a<b)
        cout<<"A";
    else
        cout<<"B";
    return 0;
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        string s,t;
        cin>>s>>t;
        int ans=t.size();
        for(int i=0;i+t.length()-1<s.length();i++){
            int p=0,cnt=0;
            for(int j=i;j<i+t.length();j++){
                if(s[j]!=t[p++])
                    cnt++;
            }
            ans=min(ans,cnt);
        }
        cout<<ans;
    }
    return 0;
}

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

A.sort(reverse = True)

ans = A[0]

idx = 1
cnt = 0
for i in range(2,N):
    ans += A[idx]
    cnt += 1
    if cnt == 2:
        idx += 1
        cnt = 0

print(ans)
    

Measured memory_bytes: 31760
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(a);
    cini(b);

    cout<<max(0, a-2*b)<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------


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

int main()
{
    Phuong_;
    ll n,m;
    cin >> n >> m;
    ll u=n/2;
    ll v=m/2;
    if (n==1 || m==1) cout << 1; else
    cout << (u*v) + (n-u)*(m-v) ;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
const int INF=1000000000;
using LL = long long;
LL n,a,b,ng=0,ok=INF;

bool chk(LL x,vector<LL> hp)
{
    LL ans = 0;
    for(int i = 0;i < n;i++){
       hp.at(i)-=b*x;
       hp.at(i) = max(0LL,hp.at(i));
       ans += hp.at(i)/(a-b);
       if(hp.at(i)%(a-b) != 0)ans++;
    }
    return ans <= x;
}

int main()
{
    cin >> n >> a >> b;
    vector<LL> h(n);
    for(int i=0;i<n;i++)cin >> h.at(i);
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        //cout<<mid<<endl;
        if(chk(mid,h)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<cmath>

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, a, b, x, prevx;
	long long ans = 0;
	cin >> n >> a >> b;
	cin >> prevx;
	for (int i = 1; i < n; i++) {
		cin >> x;
		ans += min(b, (x - prevx)*a);
		prevx = x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}



int main(){
    long long N;
    scanf("%lld",&N);
    for (long long i = 1; i <= N; i++) {
        ll cnt=0;
        for (long long x = 1; x <= 100 ; x++) {
            if(x*x>i) break;
            for (long long y = 1; y <= 100 ; y++) {
                if(x*x+y*y+x*y>i) break;
                for (long long z = 1; z <= 100 ; z++) {
                    if(x*x+y*y+z*z+x*y+y*z+z*x>i) break;
                    if(x*x+y*y+z*z+x*y+y*z+z*x==i) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	int c = max(a, b);
	
	cout << (a == b ? a + b : c + c - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    string t=s;
    reverse(all(t));
    ll cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

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


P extgcd(ll a, ll b, bool gcd = false){
    // return p  :  a * p.fi + b * p.se = gcd(a, b);
    struct eq_elem{
        // ax + by = u
        ll u, x, y;
        eq_elem(ll _a, ll _b, ll _c){
            u = _a; x = _b; y = _c;
        }
        eq_elem& operator *=(const ll &t){
            u *= t; x *= t; y *= t;
            return *this;
        }
        eq_elem operator * (const ll &t){
            return eq_elem(*this) *= t;
        }
        eq_elem& operator -=(const eq_elem &t){
            u -= t.u; x -= t.x; y -= t.y;
            return *this;
        }
        eq_elem operator - (const eq_elem &t){
            return eq_elem(*this) -= t;
        }
    };
    bool flag = a < b;
    if(flag) swap(a, b);
    eq_elem s(a, 1, 0), t(b, 0, 1);
    while(t.u != 0){
        s -= t * (s.u / t.u);
        swap(s, t);
    }
    if(gcd){
        return make_pair(s.u, 0LL);
    }else {
        if(flag) swap(s.x, s.y);
        return make_pair(s.x, s.y);
    }
}

int main() {
    cin>>N;
    if(N <= 100){
        reps(k, 1, N + 10){
            if((k * (k + 1) / 2) % N == 0){
                cout<<k<<endl;
                return 0;
            }
        }
    }else{
        ll ans(N | 1), NN(N);
        N *= 2;
        vec prime(0);
        for(ll i = 2; i * i <= N; ++i){
            if(N%i == 0){
                ll elem = 1;
                while(N%i == 0){
                    N /= i;
                    elem *= i;
                }
                prime.push_back(elem);
            }
        }
        if(N != 1) prime.push_back(N);
        N = NN * 2;
        int sz = prime.size();
        rep(s, (1<<sz)){
            ll temp_k(1);
            rep(j, sz) if((s>>j)&1) temp_k *= prime[j];
            if(temp_k == 1 || temp_k == N) continue;
            P p = extgcd(temp_k, N / temp_k);
            //cout<<temp_k<<' '<<N/temp_k<<' '<<p.fi<<' '<<p.se<<endl;
            chmin(ans, min(abs(p.fi * temp_k), abs(p.se * (N / temp_k))));
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n;
	lli a = 1, t = 1;
	cin >> n;
	
	rep(i, n){
		lli p, q;
		cin >> p >> q;
		lli j = max(a/p+!!(a%p), t/q+!!(t%q));
		a = p*j; t = q*j;
	}

	cout << a+t << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <cstdio>
using namespace std;
#define N 200000
#define F first
#define S second
#define MP(i, j) make_pair((i), (j))
#define int long long
typedef pair<int, int> P;
typedef pair<int, P> Pi;
int cnt;
void init(int n_, int *dat){
	cnt = 1;
	while(cnt < n_) cnt *= 2;
	for(int i = 0; i < 2 * cnt - 1; i++) dat[i] = INT_MAX;
}
void update(int k, int a, int *dat){
	k += cnt - 1;
	dat[k] = a;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}
int query(int a, int b, int k, int l, int r, int *dat){
	if(r <= a || b <= l) return INT_MAX;
	if(a <= l && r <= b) return dat[k];
	else{
		int v1 = query(a, b, k * 2 + 1, l, (l + r) / 2, dat);
		int vr = query(a, b, k * 2 + 2, (l + r) / 2, r, dat);
		return min(v1, vr);
	}
}

int i, j, n, d, ax[3 * N], bx[3 * N], ay[3 * N], by[3 * N], ans;
Pi stars[N];

signed main(){
	cin >> n >> d;
	for(i = 0; i < n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		stars[i] = MP(c, MP(a, b));
	}
	sort(stars, stars + n);
	init(n, ax); init(n, bx); init(n, ay); init(n, by);
	for(i = 0; i < n; i++){
		update(i, stars[i].S.F, ax);
		update(i, -stars[i].S.F, bx);
		update(i, stars[i].S.S, ay);
		update(i, -stars[i].S.S, by);
	}
	i = 0; j = 0;
	for(;;){
		while(j < n){
			if(stars[j].F - stars[i].F <= d)
				j++;
			else
				break;
		}
		ans = max(ans, (-query(i, j, 0, 0, cnt, bx) - query(i, j, 0, 0, cnt, ax)) * (-query(i, j, 0, 0, cnt, by) - query(i, j, 0, 0, cnt, ay)));
		if(j == n)
			break;
		i++;
	}
	cout << ans << endl;
	return 0;
}

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

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    int x;
    cin >> x;
    cout << ll(360 / gcd(360, x)) << endl;
}

Measured memory_bytes: 3604
program main
   integer, allocatable :: j(:), k(:)
   read(*, *) N
   allocate(j(N))
   read(*, *)(j(i), i=1,N)
   k = iqsort(j)
   write(*, *)sum(k(1:N:2)) - sum(k(2:N:2))
   deallocate(j)
   deallocate(k)
   stop
contains
recursive function iqsort(a) result(r)
  integer, intent(in) :: a(:)
  integer, allocatable :: r(:)
  logical, allocatable :: q(:)
  integer:: p
  if(size(a) < 2)then
    r = a
  else
    p = a(1)
    q = a(2:) < p
    r = [iqsort(pack(a(2:), .not. q)), p, iqsort(pack(a(2:), q))]
  endif
end function iqsort
end

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <ctime>
using namespace std;
int n;
int c[555];
int s[555];
int f[555];
int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 1; i < n; i++) {
        int now = s[i];
        for (int j = i + 1; j <= n; j++) {
            now += c[j - 1];
            if (j == n) break;
            if (now <= s[j]) {
                now = s[j];
                continue;
            }
            int k = now - s[j];
            if (k % f[j]) {
                now -= k % f[j];
                now += f[j];
            }
        }
        cout << now << endl;
    }
    cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

lcm = lambda a, b: b // gcd(a, b) * a
mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

L = reduce(lcm, A) % mod
print(sum(L * pow(a, mod - 2, mod) % mod for a in A) % mod)

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

list_Y = list(map(int, input().split()))
addY = list_Y[0] + M
list_Y.append(addY)

max_Y = 0 

for i in range(N):
  kyori = list_Y[i+1] - list_Y[i]
  if kyori >= max_Y:
    max_Y = kyori
    
print(M - max_Y)


Measured memory_bytes: 26464
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vll;
typedef vector<vector<long long>> vvll;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const double eps9 = 1e-9;


int main() {
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	ll res = w * h;
	cout << res / 2;
	if (res % 2 == 1)
		cout << ".5";
	cout << " ";
	if (x * 2 == w && y * 2 == h)
		cout << 1;
	else
		cout << 0;
	return 0;

}

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

using namespace std;

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

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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


int main(void) {
    int n;
    cin >> n;
    map<pii,int> ma;
    vi x(n),y(n);
    rep(i,n){
        int a,b,c;
        cin >> a >> b >> c;
        ma[pii(a,b)] = c;
        x[i] = a;
        y[i] = b;
    }
    int ans = 0;
    int dx[] = {0,1,0,1};
    int dy[] = {0,0,1,1};
    rep(i,n)rep(j,4){
        int t = 0;
        int p = x[i] - dx[j];
        int q = y[i] - dy[j];
        //cout << p << " " << q << endl;
        rep(k,4){
            t += ma[pii(p+dx[k],q+dy[k])];
        }
        ans = max(ans, t);
    }
    cout << ans << " / 1" << endl;
}



Measured memory_bytes: 59872
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        s: chars
    }
    let mut vs = vec![vec!['S','S'],vec!['S','W'],vec!['W','S'],vec!['W','W']];
    for v in vs.iter_mut() {
        if !order(v, &s) {
            continue;
        }
        for c in v {
            print!("{}", c);
        }
        print!("\n");
        return;
    }
    println!("-1");
}

fn order(v: &mut Vec<char>, o: &Vec<char>) -> bool {
    let l = o.len();
    for i in 1..l {
        if (v[i-1] == 'S') ^ (v[i] == 'S') ^ (o[i] == 'o') {
            v.push('S');
        } else {
            v.push('W');
        }
    }
    let last = v.pop().unwrap();
    last == v[0] && (v[1] == v[l-1]) ^ (v[0] == 'S') ^ (o[0] == 'o')
}


Measured memory_bytes: 6396
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, k;
vi h;
vi memo;

int rec(int p) {
    if (p == n - 1) return 0;
    if (memo[p] == -1) {
        memo[p] = INF;
        for(int i = 1; i <= k; i++) {
            if (p + i > n - 1) continue;
            memo[p] = min(memo[p], rec(p + i) + abs(h[p] - h[p + i]));
        }
    }
    return memo[p];
}

int main() {
    cin >> n >> k;
    h.resize(n);
    rep(i, n) {
        cin >> h[i];
        memo.pb(-1);
    }
    cout << rec(0)  << endl;
}

Measured memory_bytes: 5880
#include <cstdio>
#define maxn 200005
using namespace std;

char c[maxn];

inline void swap(char& x, char& y)
{
	char z = x;
	x = y;
	y = z;
}

int main(int argc, char** argv)
{
	int n, ans = 0;
	scanf("%d%s", &n, c);
	bool ok = true;
	for(int i=0; i+1<n; i++)
		if(c[i] == 'W' && c[i + 1] == 'R')
			ok = false;
	if(ok) {puts("0"); return 0;}
	int j = 0;
	while(j < n && c[j] == 'R')
		j ++;
	for(int i=n-1; i>j; i--)
		if(c[i] == 'R')
		{
			ans ++;
			swap(c[i], c[j]);
			while(j < n && c[j] == 'R')
				j ++;
		}
	printf("%d\n", ans);
	return 0;
}

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

import itertools

count = 0
L = sorted(L)
Cmb = itertools.combinations(L,3)
for cmb in Cmb:
    a = cmb[0]
    b = cmb[1]
    c = cmb[2]
    if not(a == b or b == c or c == a):
        if a + b > c:
            count += 1
print(count)

Measured memory_bytes: 67892
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
	string str, a("abcdefghijklmnopqrstuvwxyz");
string s("None");
	int c[26];
	cin >> str;
	for (int i = 0; i < 26; i++){
		c[i] = 0;
	}
	for (int i = 0; i < str.size(); i++){
		for (int j = 0; j < 26; j++){
			if (str[i] == a[j]){
				c[j] = 1;
			}
		}

	}
	for (int i = 0; i < 26; i++){
		if (c[i] == 0){
			cout << a[i]<<endl;
			return 0;
		}
	}

	cout << s<<endl;
	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int const INF = 1 << 30;

int main(){
    int n;
    cin >> n;
    vector<int> m;
    m.push_back(0);
    m.push_back(1);
    int x = 6;
    while(x <= n){
        m.push_back(x);
        x *= 6;
    }
    x = 9;
    while(x <= n){
        m.push_back(x);
        x *= 9;
    }
    sort(all(m));

    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for(int i = 1; i <= m.size(); i++){
        for(int j = 1; j <= n; j++){
            if(j-m[i] < 0) continue;
            dp[j] = min(dp[j-m[i]] + 1, dp[j]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

#define NCR
#define PRIME	M
int pw(int a,int b,int p){
	if(b==0)return 1;
	int t=pw(a,b/2,p);
	if(b%2)return (((a*t)%p)*t)%p;
	else return ((t*t)%p);
}
int fact[200005],invfact[200005];
void init(){
	int p=PRIME;
	fact[0]=1;
	int i;
	for(i=1;i<200005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=pw(fact[i],p-2,p);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
int ncr(int n,int r){
	return (((fact[n]*invfact[r])%PRIME)*invfact[n-r])%PRIME;
}

int h,w,n;
pii x[3005];
int dp[3005];

int calc(int v){
	int &ans=dp[v];
	if(ans!=-1)return ans;
	ans=ncr(h-x[v].fr+w-x[v].sc,h-x[v].fr);
	rep(i,1,n+1){
		if(v==i)continue;
		if(x[v].fr>x[i].fr || x[v].sc>x[i].sc)continue;
		int z=ncr(x[i].fr-x[v].fr+x[i].sc-x[v].sc,x[i].fr-x[v].fr)*calc(i)%M;
		ans=(ans+M-z)%M;
	}
	return ans;
}
void solve(){
	mem1(dp);
	cin>>h>>w>>n;
	x[0]={1,1};
	// dp[n+1]=1;
	rep(i,1,n+1){
		cin>>x[i].fr>>x[i].sc;
	}
	x[n+1]={h,w};
	sort(x,x+n+2);
	cout<<calc(0);
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3584
n, m = $stdin.readline.split(" ").map {|s| s.to_i }

a = Array.new(n) { Array.new(m, 0) }

(0..n-1).each do |i|
  nums = $stdin.readline.split(" ").map {|s| s.to_i }
  nums.each_with_index do |a_i_j, j|
    a[i][j] = a_i_j
  end
end

b = []
(1..m).each do |i|
  b.push($stdin.readline.to_i)
end

c = Array.new(n)
(0..n-1).each do |i|
  sum = 0
  (0..m-1).each do |j|
    sum += a[i][j] * b[j]
  end
  c[i] = sum
end

puts c



Measured memory_bytes: 7056
import itertools
n,m = list(map(int,input().split()))

a = []
for i in range(m):
    b = (list(map(int,input().split())))
    b = [b[0]-1,b[1]-1]
    a.append(b)

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1


c = [i+1 for i in range(n-1)]
ans = 0
for i in itertools.permutations(c,n-1):
    j = [0]
    j += i
    count = 0
    for i in range(n-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == n-1:
                ans += 1
                count = 0
        else:
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i=0;i<n;i++){
    cin >> x[i];
  }
  int ans=0;
  for (int i=0;i<n;i++){
    if(x[i]<=k-x[i]){
      ans+=x[i]*2;
      }
    else {
      ans+=(k-x[i])*2;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9;
const long long LLINF = 1e18;

int dfs(const vector<vector<int>> &G, int v, int p){
  int ret = 0;
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    ret = max(ret,dfs(G,v_,v)+1);
  }
  return ret;
}

long long solve(const vector<vector<int>> &G, const vector<int> &C){
  int N = G.size();
  vector<int> D(N,INF);
  queue<int> Q;
  for(auto v : C) Q.push(v), D[v] = 0;
  // cerr << "C.size() = " << C.size() << endl;
  // cerr << "C : "; for(auto v : C) cerr << v << " " ; cerr << endl;
  while(not Q.empty()){
    int v = Q.front();
    Q.pop();
    for(auto v_ : G[v]){
      if(D[v_] < INF) continue;
      D[v_] = D[v]+1;
      Q.push(v_);
    }
  }
  int d = *max_element(D.begin(), D.end());
  vector<int> dig_max(d+1,0);
  for(int i = 0; i < N; ++i){
    if(C.size() == 1 and not D[i]){
      dig_max[D[i]] = max(dig_max[D[i]],(int)G[i].size());
      continue;
    }
    dig_max[D[i]] = max(dig_max[D[i]],(int)G[i].size()-1);
  }
  // cerr << "D       : "; for(auto e : D) cerr << e << " "; cerr << endl;
  // cerr << "dig_max : "; for(auto e : dig_max) cerr << e << " "; cerr << endl;
  // cerr << "cnt     : "; for(auto e : cnt) cerr << e << " "; cerr << endl;
  long long l = C.size();
  for(int i = 0; i < d; ++i){
    l *= dig_max[i];
  }
  return l;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i = 0; i < N-1; ++i){
    int a,b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans = max(ans,dfs(G,i,-1));
  }
  int d = (ans+1)/2;
  vector<int> C;
  for(int i = 0; i < N; ++i){
    if(dfs(G,i,-1) != d) continue;
    C.push_back(i);
  }
  long long l = LLINF;
  if(C.size() == 2) l = solve(G,C);
  else{
    l = min(l,solve(G,C));
    int c = C[0];
    //cerr << "c = " << c << endl;
    for(auto c_ : G[c]){
      if(dfs(G,c_,-1) != d+1) continue;
      C.push_back(c_);
      l = min(l,solve(G,C));
      //cerr << "Debug : " << c_ << " " << solve(G,C) << endl;
      C.pop_back();
    }
  }
  cout << ans/2+1 << " " << l << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# Input
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

list = [a, b, c, d, e]

count = 0
num = len(list) - 1
for ii in range(num):
    for hh in range(num - (int(ii) - 1)):
        if list[num - ii] - list[ii] > k:
            count += 1

if count == 0:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int K=sc.nextInt();
	int R=sc.nextInt();
	int S=sc.nextInt();
	int P=sc.nextInt();
	String T=sc.next();
	String[] T2=T.split("");
	long score=0;
	for(int i=0;i<N;i++) {
		if(i<K) {
			if(T2[i].equals("r")) {
				score+=P;
			}else if(T2[i].equals("s")){
				score+=R;
			}else if(T2[i].equals("p")){
				score+=S;
			}
		}else {
			if(T2[i-K].equals(T2[i])) {
				T2[i]="1";
					continue;
				}else {
			if(T2[i].equals("r")) {
				score+=P;
			}else if(T2[i].equals("s")){
				score+=R;
			}else if(T2[i].equals("p")){
				score+=S;
			}
		}
			}
	}
	System.out.println(score);
	}
}

Measured memory_bytes: 33052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = 1e18;
    FOR(i,1,h-1){
        VL a(3);
        a[0] = w * i;
        a[1] = w * ((h-i)/2);
        a[2] = w * ((h-i+1)/2);
        sort(ALL(a));
        ans = min(ans, a[2]-a[0]);
        a[0] = w * i;
        a[1] = (h-i) * (w/2);
        a[2] = (h-i) * ((w+1)/2);
        sort(ALL(a));
        ans = min(ans, a[2]-a[0]);
    }
    FOR(i,1,w-1){
        VL a(3);
        a[0] = h * i;
        a[1] = h * ((w-i)/2);
        a[2] = h * ((w-i+1)/2);
        sort(ALL(a));
        ans = min(ans, a[2]-a[0]);
        a[0] = h * i;
        a[1] = (w-i) * (h/2);
        a[2] = (w-i) * ((h+1)/2);        
        sort(ALL(a));
        ans = min(ans, a[2]-a[0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    int n, T, ans=10000;
    cin >> n >> T;
    vector<int> c(n), t(n);
    rep(i, n){
        cin >> c.at(i) >> t.at(i);
        if(t.at(i) <= T)ans = min(ans, c.at(i));
    }
    if(ans == 10000)cout << "TLE";
    else cout << ans;
}

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

using namespace std;

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

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int ans=0;
  rep(i,n){
    j=0;
    while(a[i]==a[i+j])j++;
    if(a[i]<=j)ans+=j-a[i];
    else ans+=j;
    i+=j-1;
  }
  cout<<ans<<endl;
}


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

int main() {

    long long N,max,min,sum;
    cin >> N;
    vector<long long> vec(N);
    
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    
    max = vec.at(0);
    min = vec.at(0);
    sum = vec.at(0);
    
    if(N == 1){
    cout << min << " " << max << " " << sum << endl;
    }
    else{
        for(int i = 1; i < N; i++){
            if(max < vec.at(i))max = vec.at(i);
            if(min > vec.at(i))min = vec.at(i);
            sum += vec.at(i);
        }
        cout << min << " " << max << " " << sum << endl;
    }

}


Measured memory_bytes: 3184
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int n;
    string s;
    int k;
    cin >> n >> s >> k;
    for(int i=0; i<n; i++){
        if(s[i]!=s[k-1])s[i]='*';
    }
    cout << s << endl;
    return 0;
}

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

const int MOD=1e9+7;
long dp[1000001][13];

int main(){
  string S;
  cin >> S;
  dp[0][0]=1;
  for(int i=0; i<S.size(); i++){
    int c;
    if(S[i]=='?') c=-1;
    else c=S[i]-'0';

    for(int j=0; j<10; j++){
      if(c!=-1 && c!=j) continue;
      for(int k=0; k<13; k++){
        dp[i+1][(k*10+j)%13]=(dp[i+1][(k*10+j)%13]+dp[i][k]) % MOD;
      }
    }
  }
  cout << dp[S.size()][5] << endl;
  return 0;
}

Measured memory_bytes: 10752
N = int(input())
H = list(map(int, input().split()))
hs = H[::]
hs[0] -= 1
for i in range(1, N):
    if hs[i - 1] <= hs[i] - 1:
        hs[i] -= 1
print('Yes' if all(hs[i] <= hs[i + 1] for i in range(N - 1)) else 'No')


Measured memory_bytes: 63856
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
typedef long long ll;
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
using P = pair<double, int>;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    vector<int> wt(n);
    vector<int> va(n);
    for (int i = 0; i < n; i++) {
        cin >> wt[i];
        cin >> va[i];
    }
    int sum = accumulate(va.begin(), va.end(), 0LL);
    vector<vector<int>> dp(n + 1, vector<int>(sum + 1, 0));
    for (int i = 1; i < sum + 1; i++) dp[0][i] = INF;
    for (int i = 1; i < n + 1; i++) {
        for (int j = 1; j < sum + 1; j++) {
            if (j < va[i - 1]) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - va[i - 1]] + wt[i - 1]);
        }
    }
    for (int i = sum; i >= 0; i--) {
        if (dp[n][i] <= w) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int fastpow(int x,int a){
	int ret=1;
	while(a){
		if(a&1) ret=ret*1LL*x%mod;
		a>>=1;x=x*1LL*x%mod;
	}
	return ret;
}
#define LL long long
struct Combin{
	#define N 405
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;
#define N 55 
struct edge{
	int t,next;
}e[205];int ecnt,head[N],du[N];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;du[f]++;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;du[t]++;
}
int n,m,k;
int ans=1;
void calc2(int sz){
	int ret=0;
	for(int i=1;i<=sz;i++)
		ret=(ret+fastpow(k,__gcd(sz,i)))%mod;
	ans=ans*1LL*(ret*1LL*C.rv[sz]%mod)%mod;
}
void calc3(int sz){
	ans=ans*1LL*C.C(k-1,sz+k-1)%mod;
}

int sz[N],mint[N],ti[N],tcnt,etcnt,vis[N];
int top,sta[205];
void tarjan(int u,int fre){
	ti[u]=++tcnt;mint[u]=ti[u];
	int mn=ti[u];
	for(int i=head[u];i;i=e[i].next){
		if((i^fre)==1) continue;
		if(ti[e[i].t]==0){
			sta[++top]=i;
			tarjan(e[i].t,i);
			mn=min(mn,mint[e[i].t]);
			if(mint[e[i].t]>=ti[u]){
				int n1=0,m1=0;
				etcnt++;
				while(top>0&&sta[top]!=fre&&mint[e[sta[top]].t]>=ti[u]){
					m1++;
					if(vis[e[sta[top]].t]!=etcnt) n1++,vis[e[sta[top]].t]=etcnt;
					if(vis[e[sta[top]^1].t]!=etcnt) n1++,vis[e[sta[top]^1].t]=etcnt;
					top--;
				}
				if(m1==1) ans=ans*1LL*k%mod;
				else if(n1==m1) calc2(m1);
				else calc3(m1);
			}
		}else{
			if(ti[u]>ti[e[i].t]) sta[++top]=i;
			mn=min(mn,mint[e[i].t]);
		}
	}
	mint[u]=mn;
}

int main(){
	ecnt=1;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,f,t;i<=m;i++) scanf("%d%d",&f,&t),addedge(f,t);
	for(int i=1;i<=n;i++)
		if(ti[i]==0)
			tarjan(i,0);	

	cout<<(ans+mod)%mod<<endl;
	return 0;
} 

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    println!("{}{}{}", s[0], s.len() - 2, s.last().unwrap());
}


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

using namespace std;

int main(void) {
	string s;
	cin >> s;

	int count = 0;

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			s[i + 1] = s[i + 1] == '0' ? '1' : '0';
			count++;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }

        for(int i=n-1; i>0; i--){
            System.out.printf("%d ", a[i]);
        }
        System.out.println(a[0]);
    }
}


Measured memory_bytes: 26312