akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
const int MAX_N = 100000;
struct UnionFind{
    int par[MAX_N];
    void init(int n){
        for(int i = 0;i < n;i++)par[i] = i;
    }
    int root(int x){
        if(par[x] == x)return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[y] = x;
    }
};
main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
        A[i]--;
    }
    UnionFind uf;
    uf.init(N);
    for(int i = 0;i < M;i++){
        int a,b;
        cin >> a >> b;
        uf.unite(a-1,b-1);
    }
    int cnt = 0;
    for(int i = 0;i < N;i++){
        if(uf.same(i,A[i]))cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
use std::io::Read;
use std::str::{self, FromStr};

/// readerをラップして、いい感じにトークンを読みます。
pub struct Scanner<R: Read>(R);

impl<R: Read> Scanner<R> {
    /// readerからScannerを作ります。
    /// # Examples
    ///
    /// ```
    /// use tkio::Scanner;
    ///
    /// let stdin = std::io::stdin();
    /// let mut sc = Scanner::new(stdin.lock());
    /// ```
    pub fn new(reader: R) -> Self {
        Self(reader)
    }

    /// ひとつ読みます。
    ///
    /// # Panics
    /// パースできなかったらお手上げです。
    ///
    /// # Examples
    ///
    /// ```
    /// use tkio::Scanner;
    ///
    /// let input = "4 3";
    /// let mut sc = Scanner::new(input.as_bytes());
    ///
    /// let (n, m): (i32, i32) = (sc.read(), sc.read());
    /// assert_eq!((n, m), (4, 3));
    /// ```
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();

        unsafe { str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }

    /// n個読んでVecで返します。
    ///
    /// # Examples
    ///
    /// ```
    /// use tkio::Scanner;
    ///
    /// let input = "\
    /// 5
    /// 1 2 3 4 5
    /// ";
    /// let mut sc = Scanner::new(input.as_bytes());
    ///
    /// let n: usize = sc.read();
    /// assert_eq!(n, 5);
    ///
    /// let v: Vec<i32> = sc.vec(n);
    /// assert_eq!(v, vec![1, 2, 3, 4, 5]);
    /// ```
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    /// Stringをひとつ読んでVec\<char\>で返します。
    ///
    /// # Examples
    ///
    /// ```
    /// use tkio::Scanner;
    ///
    /// let input = ".#..#";
    /// let mut sc = Scanner::new(input.as_bytes());
    ///
    /// let v = sc.chars();
    /// assert_eq!(v, vec!['.', '#', '.', '.', '#']);
    /// ```
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

use std::io::{self, Write};

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());

    solve(&mut sc, &mut out);

    out.flush().ok().unwrap();
}

fn solve(sc: &mut Scanner<io::StdinLock>, _out: &mut io::BufWriter<io::StdoutLock>) {
    let (n, a, b): (u32, u32, u32) = (sc.read(), sc.read(), sc.read());

    let ans: u32 = (1..=n)
        .filter(|&i| {
            let mut i = i;
            let mut sum = 0;
            while i > 0 {
                sum += i % 10;
                i /= 10;
            }
            sum >= a && sum <= b
        })
        .sum();

    println!("{}", ans);
}


Measured memory_bytes: 2148
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> N;
	string s;
	cin >> s;
	ll sums[3] = { 0 };
	rep(i, N) {
		if (s[i] == 'R') sums[0]++;
		if (s[i] == 'G') sums[1]++;
		if (s[i] == 'B') sums[2]++;
	}
	ll _count = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = 1; i + j +  j < N; j++) {
			if((s[i]^s[i+j]^s[i+j+j]) == ('G'^'R'^'B')) _count++;
		}
	}
	cout << sums[0]*sums[1]*sums[2] - _count;
}


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

bool IsOneBit(long long bits, int i) {
	return (bits & (1ll << i)) > 0;
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
	for (int i = 0; i < N; i++) for (int j = 0; j < 10; j++) cin >> F[i][j];
	for (int i = 0; i < N; i++) for (int j = 0; j < 11; j++) cin >> P[i][j];

	int MAX = -1000000001;
	for (int bits = 1; bits < 1024; bits++) {
		int cost = 0;
		for (int shop = 0; shop < N; shop++) {
			int doubled = 0;
			for (int i = 0; i < 10; i++) doubled += IsOneBit(bits,i) * F[shop][i];
			cost += P[shop][doubled];
		}
		MAX = max(MAX, cost);
	}
	cout << MAX << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long  h , w;
        cin >> h >> w;
        vector<vector<long>>  v1, v2;
        vector<long>  vh , vw;
        string str;
        vector<string> vs , vs2;
        vs2.assign(w , "");
        for(int i = 0 ; i < h ; i++){
            cin >> str;
            vs.push_back(str);
            for(int j = 0; j < w ; j++ ){
                vs2[j] = vs2[j] + str[j];
            }
        }
        long t;
        for(int i = 0 ; i < h ; i++){
            vector<long> vt;
            vt.assign(w , 0);
            t = 0;
            for(int j = 0 ; j < w ; j++ ){
                if(vs[i][j] == '#'){
                    t = 0;
                }else{
                    t += 1;
                    vt[j] = t;
                }
            }
            for(int j = w - 2 ; j >= 0 ; j-- ){
                if(vs[i][j] != '#' && vs[i][j+1] != '#' ){
                    vt[j] = vt[j+1];
                }
            }
            v1.push_back(vt);
            /*
            if (vt.size() > 0){
                cout << vt[0];
                for( int k = 1; k < vt.size() ; k++){
                cout << " " << vt[k] ;
                }
                cout << endl;
            }
            */
            
        }
        for(int i = 0 ; i < w ; i++){
            vector<long> vt;
            vt.assign(h , 0);
            t = 0;
            for(int j = 0 ; j < h ; j++ ){
                if(vs2[i][j] == '#'){
                    t = 0;
                }else{
                    t += 1;
                    vt[j] = t;
                }
            }
            for(int j = h - 2 ; j >= 0 ; j-- ){
                if(vs2[i][j] != '#' && vs2[i][j+1] != '#' ){
                    vt[j] = vt[j+1];
                }
            }
            v2.push_back(vt);
        }
        long ans = 0;
        for(int i = 0 ; i < h ; i++){
            for(int j = 0 ; j < w ; j++){
                ans = max(ans , v1[i][j] + v2[j][i] -1);
                //ans = max(ans , v1[i][j]);
            }
        }
        cout << ans << endl;
        
        return 0;
    }

Measured memory_bytes: 74544
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {
       
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
     t=1;
    while (t--)
    {
        string s;
        ll c=0;
        cin>>s;
       for(i=0;i<3;i++)
        {
            if(s[i]=='R')
            { c=1;
            i++;
              while(s[i]!='S' && i<3)
              {
                  i++;
                  c++;
              }
            }
        }
        cout<<c<<e;
    }
    return 0;
}

Measured memory_bytes: 3608
# 二つの整数 A, Bが入力されます。
# A + B の値を出力してください。
# ただし、
# A + B が 10 以上の場合は、
# 代わりに error と出力してください。

# 制約
# A, B は整数である。
# 1 ≦ A, B ≦ 9

# 標準入力から A, B の値を取得する
a, b = map(int, input().split())

# 計算結果を出力する
result = "error"

if a + b < 10:
    result = a + b

print(result)


Measured memory_bytes: 9048
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var tmpT = 0;
            var rem = new List<int>();
            for (int i = 0; i < N; i++)
            {
                var input = ReadInt();
                if (input % 10 == 0) tmpT += input;
                else rem.Add(input);
            }
            rem = rem.OrderBy(i => i).ToList();
            var ans = 0;
            if (rem.Count == 0) ans = 0;
            else if (rem.Sum() % 10 != 0) ans = tmpT + rem.Sum();
            else ans = tmpT + rem.Sum() - rem[0];

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main()
{ 
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u){cout<<a-1<<' '<<b<<endl;}
    else{cout<<a<<' '<<b-1<<endl;}
    return 0;
}

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

using namespace std;
using LLONG = long long;

int N, A, B, C;

const int DFS(
    const vector<int> &lengths, const int cur,
    const int a, const int b, const int c)
{
    if (cur == N)
    {
        if (min({ a, b, c }) > 0)
        {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        }
        else
        {
            return 1000000000;
        }
    }
    int ret0 = DFS(lengths, cur + 1, a, b, c);
    int ret1 = DFS(lengths, cur + 1, a + lengths[cur], b, c) + 10;
    int ret2 = DFS(lengths, cur + 1, a, b + lengths[cur], c) + 10;
    int ret3 = DFS(lengths, cur + 1, a, b, c + lengths[cur]) + 10;
    return min({ ret0, ret1, ret2, ret3 });
}

int main()
{
    cin >> N >> A >> B >> C;
    vector<int> lengths(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> lengths[i];
    }

    cout << DFS(lengths, 0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int N, M;
        cin >> N;

        if (N < 1200)
        {
                cout << "ABC" << endl;
        }
        else if (N < 2800)
        {
                cout << "ARC" << endl;
        }
        else
        {
                cout << "AGC" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    int oneSubmit = (1900 * M) + (100 * (N - M));
    int kakeru = pow(2, M);
    cout << oneSubmit * kakeru << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


int N,M;
char S[10];
signed main(){
    scanf("%s",S);
    if(strcmp("ABC",S)==0)printf("ARC\n");
    if(strcmp("ARC",S)==0)printf("ABC\n");
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

#define int ll

const int INF = 2e18;

int mul(int a, int b) {
	a = min(a, INF);
	b = min(b, INF);
	if (INF / a < b) return INF;
	return a * b;
}

int add(int a, int b) {
	return min(a + b, INF);
}

int a, b, c, d;

map<int, int> have;
set<int> used;

int get(int n) {
	if (n == 0) return 0;
	if (have.count(n)) return have[n];
	have[n] = INF;
	int ans = mul(n, d);
	chkmin(ans, get(n / 2) + (n % 2) * d + a);
	chkmin(ans, get((n + 2) / 2) + (2 - n % 2) * d + a);

	chkmin(ans, get(n / 3) + (n % 3) * d + b);
	chkmin(ans, get((n + 3) / 3) + (3 - n % 3) * d + b);
	
	chkmin(ans, get(n / 5) + (n % 5) * d + c);
	chkmin(ans, get((n + 5) / 5) + (5 - n % 5) * d + c);
	have[n] = ans;
	return ans;
}

void solve() {
	int n;
	have.clear();
	cin >> n >> a >> b >> c >> d;
	cout << get(n) << endl;
	/*cout << "have = " << endl;
	for (auto i : have) {
		cout << i.first << " " << i.second << endl;
	}*/
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4892
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;

int main(){
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<int> Nums;
    int now = 1;
    int cnt = 0;

    for(int i=0;i<n;i++){
        if(s[i] == (char)('0'+now)) cnt++;
        else{
            Nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);

    //1-0-1-0-1-0-1が欲しい
    //1-0-1-0みたいなので終わってたら1を足したい
    if(Nums.size() % 2 == 0) Nums.push_back(0);

    /*for(int i=0;i<n;i++){
        cout << Nums[i];
    }*/

    int Add = 2 * k + 1;

    int ans = 0;
    int tmp = 0;
    int left,right;

    //偶数番目だけ足したい
    /*for(int i = 0;i < Nums.size();i+=2){
        tmp = 0;

        left = i;
        right = min(i+Add,(int)Nums.size());

        for(int j = left; j < right;j++){
            tmp += Nums[j];
        }
        ans = max(ans,tmp);
    }*/

    //累積和を作る
    vector<int> sum(Nums.size()+1);

    for(int i=0;i<Nums.size();i++){
        sum[i+1] = sum[i] + Nums[i];
    }

    for(int i=0;i<Nums.size();i+=2){
        left = i;
        right = min(i + Add,(int)Nums.size());
        tmp = sum[right] - sum[left];

        ans = max(tmp,ans);
    }

    

    cout << ans << endl;

}

Measured memory_bytes: 1272
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) //xを全探索
    {
        for (int y = 0; y <= k; y++) //yを全探索
        {
            int z = s - x - y; //zはyからxとsを引いて求められる。合計がsになるという式でもある。
            if(0 <= z and z <= k) { //上記の式を満たし、かつ0からk以内ならカウントする
                ans = ans + 1;
            }
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,sum=0;
  cin >> n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;i++){
    cin >> b.at(i);
  }
  sum += b.at(0);
  for(int i=1;i<n-1;i++){
    sum += min(b.at(i),b.at(i-1));
  }
  sum += b.at(n-2);
  cout << sum << endl;
}
    

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

int main() {
  double pi = 3.141592653;
  double a, b, x;
  cin >> a >> b >> x;
  if(2 * x >= a * a * b) {
    double ans = atan((2 * a * a * b - 2 * x) / (a * a * a));
    ans *= 180;
    ans /= pi;
    cout << fixed << setprecision(7) << ans << endl;
  }
  else {
    double ans = atan((a * b * b) / (2 * x));
    ans *= 180;
    ans /= pi;
    cout << fixed << setprecision(7) << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main(){
    ll n;cin>>n;
    vector< int64_t > v;
    v=divisor(n);
    ll c;
    c=0;
    for(int i=0;i<v.size();i++){
        if(v[i]-1>n/v[i])c=c+v[i]-1;
    }
    
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    // freopen("in.txt","r",stdin);
    unsigned long long S;
    scanf("%lld",&S);
    unsigned long long x2=1e9,x3=1,y2,y3;
    if(S%x2)
    {
        y3=(S/x2)+1;
        y2=x2*y3-S;
    }else
    {
        y3=S/x2;
        y2=0;
    }
    printf("0 0 %lld %lld %lld %lld\n",x2,y2,x3,y3);
    return 0;
}

Measured memory_bytes: 256
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() { 
    int n,k;cin >> n >> k;
    vi h(n);
    rep(i, n)cin >> h[i];
    vi v(n+110,inf);
    v[0]=0;
    rep(i, n) {
        rep1(j, k) {
            chmin(v[i+j],abs(h[i+j]-h[i])+v[i]);
        }
    }
    cout << v[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
#define all(i) (i).begin(), (i).end()
using namespace std;

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

ll n;

int main()
{
	scanf("%lld", &n);
	if (n % 2) printf("0\n");
	else
	{
		ll ans = 0;
		n /= 2;
		for (ll i = 5; i <= n; i *= 5)
			ans += n / i;
		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String str;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		str = scan.nextLine();
		//???????????????????????°???dice???????´?
		String[] dice = str.split(" ");
		str = scan.nextLine();
		//?????????????§???????direction???????´?
		String[] direction = str.split("");
		
		//move?????????????????????????????????????????????????????????
		System.out.println(move(dice, direction));
	}

	/**
	 * move
	 * ???????????????????????°???????????????
	 * @param dice
	 * @param direction
	 * @return dice[0]
	 */
	private static String move(String[] dice, String[] direction) {
		for (int i = 0; i < direction.length; i++) {
			if(direction[i].equals("E")){
				str = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = str;
			}else if(direction[i].equals("W")){
				str = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = str;
			}else if(direction[i].equals("S")){
				str = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = str;
			}else if(direction[i].equals("N")){
				str = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = str;
			}
		}
		return dice[0];
		
	}
}

Measured memory_bytes: 17276
#include<stdio.h>

int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
		printf("Possible\n");
	}else{
		printf("Impossible\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int N,can=1;
    cin >>N;
    vi t(N+1,0),x(N+1,0),y(N+1,0);
    FOR(i,1,N) {
        cin >>t[i]>>x[i]>>y[i];
        if(abs(t[i]-t[i-1])<(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))) can=0;
        if((abs(t[i]-t[i-1])%2)!=((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2)) can=0;
    }
    Yn(can);

    return 0;
}





Measured memory_bytes: 1408
N = int(input())
# 変数名を"_"にすることで「その変数を使っていません」ということを表現している(Pythonの習慣)
# リストの中にリスト
box = [list(map(int, input().split())) for _ in range(N)]
sum = 0
for i in range(N):
    # 各リストの人数を求める
    sum += box[i][-1] - box[i][0] + 1
print(sum)

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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int n;
unordered_map<int64_t, int> cnt;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    cnt[0] = 1;

    int64_t sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
        cnt[sum] = cnt[sum] + 1;
    }

    int64_t ans = 0;
    for (auto x : cnt) {
        int64_t y = x.second;
        ans += y * (y - 1) / 2;
    }
    cout << ans << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll n, k, s;
    cin >> n >> k >> s;
    if (s != 1000000000)
    {
        rp(i, 0, k)
        {
            cout << s << " ";
        }
        rp(i, 0, n - k)
        {
            cout << 1000000000 << " ";
        }
    }
    else
    {
        rp(i, 0, k)
        {
            cout << s << " ";
        }
        rp(i, 0, n - k)
        {
            cout << 1 << " ";
        }
    }
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int M = sc.nextInt();
      int Q = sc.nextInt();
      int[][] arr = new int[Q][4];
      for(int i = 0; i < Q; i++){
        for(int j = 0; j < 4; j++){
          arr[i][j] = sc.nextInt();
        }
      }
      
      // スコア計算
      int[] A = new int[N];
      for(int i = 0; i < N; i++){
        A[i] = 1;
      }
      
      boolean endFlg = false;
      int maxScore = 0;
      while(!endFlg){
        int score = calcScore(A, arr, Q);
        
        if(maxScore < score){
          maxScore = score;
        }
        endFlg = arrInc(A,N,M);
      }
      
      // 出力
      System.out.println(maxScore);
    }
    
    // スコア計算を行う関数
    public static int calcScore(int[] A, int[][] arr, int Q){
      int score = 0;
      for(int i = 0; i < Q; i++){
        int a = arr[i][0]-1;
        int b = arr[i][1]-1;
        int c = arr[i][2];
        int d = arr[i][3];
        if(A[b] - A[a] == c){
          score += d;
        }
      }
      return score;
    }
    
    // 数列をインクリメントする関数
    public static boolean arrInc(int[] A, int N, int M){
      boolean endFlg = true;
      for(int i = N-1; i >= 0; i--){
        if(A[i] != M){
          endFlg = false;
          A[i]++;
          for(int j = i+1; j < N; j++){
            A[j] = A[i];
          }
          break;
        }
      }
      
      return endFlg;
    }
    
}

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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>value(n);
  vector<int>cost(n);
  
  for (int i = 0; i < n; i++) {
    cin >> value.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> cost.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (value.at(i) > cost.at(i)) {
      ans += value.at(i) - cost.at(i);      
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			sc.nextLine();
			String s = sc.nextLine();

			String regex = "^[0-9]{%d}-[0-9]{%d}$";
			regex = String.format(regex, a, b);

			if (s.matches(regex)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

			sc.close();
		}
}

Measured memory_bytes: 21716
import math
a, b, h, m = map(int, input().split())

short = (h*30 + m*0.5) % 360
long = m*6
C = abs(long - short)

print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(min(C,360 - C)))))

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;

	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	if(n==1){
		cout<<"Yes";
	}
	else{
		k=ar[n]; l=1;
		for(i=n-1;i>=1;i--){
			if(ar[i]<=k){
				//pass
			}
			else{
				if(ar[i]-k>1){
					l=0;break;
				}
			}
			k=min(k,ar[i]);
		}
		if(l) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  ll taka = 0,ao = 0;
  priority_queue<Pl> que;
  vector<Pl> v(n);
  rep(i,n){
    ll a,b;cin >> a >> b;
    que.push(make_pair(a+b,i));
    v[i] = make_pair(a,b);
  }
  rep(i,n){
    Pl k = que.top();que.pop();
    if(!(i & 1))taka += v[k.second].first;
    else ao += v[k.second].second;
  }
  cout << taka-ao << endl;
  







  

  return 0;
}

Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
const long MOD=1e9+7;

template<class T> T lcm(T a,T b){
	return a/__gcd(a,b)*b;
}

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

	if(s.size()<=k){
		cout << s;
	}else{
		for(int i=0;i<k;i++){
			cout << s[i];
		}
		cout << "...";
	}
	return 0;
}


Measured memory_bytes: 3628
n,m,l = gets.split.map {|s| s.to_i}
a = Array.new
b = Array.new
for i in 1..n
  c = gets.split.map {|s| s.to_i}
  a.push(c)
end
for j in 1..m
  c = gets.split.map {|s| s.to_i}
  b.push(c)
end
for i in 1..n
  for j in 1..l
    print " " unless j == 1
    s = 0
    for k in 1..m
      s += a[i-1][k-1] * b[k-1][j-1]
    end
    print s
  end
  print "\n"
end

Measured memory_bytes: 6144
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld",i)
#define fendl printf("\n")
//Library-End

int a[5][5],cnt,n,b[14];
bool ok[5][5];
signed main() {
    rep(i,3){
        rep(j,3)cin>>a[i][j];
    }
    cin>>n;
    rep(i,n){
        cin>>b[i];
    }
    rep(i,3){
        rep(j,3){
            rep(k,n){
                if (a[i][j]==b[k]) {
                    ok[i][j]=1;
                }
            }
        }
    }
    rep(i,3){
        bool did=1;
        rep(j,3){
            if(!ok[i][j]){
                did=0;
            }
        }
        if (did) {
            Yes();
            return 0;
        }
    }
    rep(i,3){
        bool did=1;
        rep(j,3){
            if(!ok[j][i]){
                did=0;
            }
        }
        if (did) {
            Yes();
            return 0;
        }
    }
    if (ok[0][0]&&ok[1][1]&&ok[2][2]) {
        Yes();
        return 0;
    }
    if (ok[0][2]&&ok[1][1]&&ok[2][0]) {
        Yes();
        return 0;
    }
    No();
}


Measured memory_bytes: 256
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, Z, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
    seen = set()
    ans = []
    while len(ans) < K:
        s, i, j, k = heappop(hq)
        ans.append(-s)
        if i < X - 1 and (i + 1, j, k) not in seen:
            heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
            seen.add((i + 1, j, k))
        if j < Y - 1 and (i, j + 1, k) not in seen:
            heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
            seen.add((i, j + 1, k))
        if k < Z - 1 and (i, j, k + 1) not in seen:
            heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
            seen.add((i, j, k + 1))

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10800
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <tuple>
#include <vector>
#include <numeric>

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D

const int maxi = 20000;
const char UP = '/';
const char DOWN = '\\';
const char FLAT = '_';

vector<tuple<char, int>> altitudes;
vector<int> areas;

template<typename I, typename F>
void for_each2(I begin, I end, F fnc){
    if (begin == end) return;
    fnc(true, begin == end - 1, *begin);
    while(++begin <= end - 1) fnc(false, begin == end - 1, *begin);
}

template<typename T>
int calc_area(T start, T end){
    auto s_alti = get<1>(*start);
    int area = 0;
    while (start != end + 1) {
        int alti = get<1>(*start);
        switch (get<0>(*start)) {
            case DOWN:
            case UP:
                area += s_alti - alti + 1;
                break;
            case FLAT:
                area += s_alti - alti + 2;
                break;
        }
        start++;
    }

    return area / 2;
}

int main(int argc, char const* argv[])
{
    int alti = 0;
    vector<int> areas;

    int c;
    while ((c = getchar()) != EOF) {
        switch (c) {
            case DOWN:
                alti -= 2;
                altitudes.emplace_back(c, alti);
                break;
            case FLAT:
                altitudes.emplace_back(c, alti);
                break;
            case UP:
                altitudes.emplace_back(c, alti);
                alti += 2;
                break;
        }
    }

    auto s = altitudes.begin(); // ????????¢?????§??????
    auto last = altitudes.end() - 1;

    while(s < last){
        auto c = get<0>(*s);
        if(c == DOWN){
            auto s_alti = get<1>(*s); // ??????????¬??????????
            auto e = s + 1; // ????????¢????????????
            while(e != altitudes.end()){
                auto e_alti = get<1>(*e);
                auto e_type = get<0>(*e);
                if(s_alti == e_alti && e_type == UP){
                    int area = calc_area(s, e);
                    areas.push_back(area);
                    s = e;
                    break;
                }
                e++;
            }
        }
        s++;
    }

    printf("%d\n", accumulate(areas.begin(), areas.end(),0));
    if(areas.size() > 0){
        printf("%d ", areas.size());
        for_each2(areas.begin(), areas.end(), [](bool is_first, bool is_last, int &v)
            { printf(!is_last ? "%d " : "%d\n", v); });
    }else{
        puts("0");
    }

    return 0;
}

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

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

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

    int n;
    cin >> n;
    ll ans = 1ll;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        ans = lcm(ans, x);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ld h, w, x, y;
    cin >> h >> w >> x >> y;
    cout << h * w / 2 << " " << (x * 2 == h and y * 2 == w ? 1 : 0) << endl;
}


Measured memory_bytes: 3772
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }  // answer stored in matrix A
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }
ll ainv, binv;
void extgcd(ll a, ll b){ if(b==0){/* hcf = a; */ ainv = 1; binv = 0; } else{ extgcd(b, a%b); ll temp = ainv; ainv = binv; binv = temp - (a/b)*binv; } }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    str s[3] = {"ABC", "ARC", "AGC"};
    int r;
    cin >> r;
    if(r < 1200) cout << s[0];
    else if(r < 2800) cout << s[1];
    else cout << s[2];
    return 0; 
}

Measured memory_bytes: 256
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(S[K - 1])


Measured memory_bytes: 2940
n = int(input())
l = list()
money = 0
for i in range(n):
    a,b = input().split()
    l.append([float(a), b])
for i in range(n):
    if l[i][1] =="JPY":
        money += l[i][0]
    else:
        money += l[i][0]* 380000.0
print(money)

Measured memory_bytes: 3060
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(S) {
    // ????????????????????????
    var h = Math.floor(S / (60*60));
    var m = Math.floor((S - 60*60*h) / 60);
    var s = S - 60*60*h - 60*m;

    console.log('%d:%d:%d', h, m, s);
    //print('%d:%d:%d', h, m, s);


  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15492
# -*- coding: utf-8 -*-
import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
f_dist = [-1]*(N+1)
s_dist = [-1]*(N+1)
G = [[] for _ in range(N+1) ]
for _ in range(N-1):
    x, y = map(int,readline().split())
    G[x].append(y)
    G[y].append(x)
    
def dfs(q,dist):       
    while q:
        x = q.popleft()
        for nx in G[x]:
            if dist[nx] != -1:
                continue
            dist[nx] = dist[x] + 1
            q.append(nx)

q = deque([1])
f_dist[1] = 0
dfs(q,f_dist)
q = deque([N])
s_dist[N] = 0
dfs(q,s_dist)
f_cnt = 0
s_cnt = 0
for i in range(1,N+1):
    if f_dist[i] <= s_dist[i]:
        f_cnt += 1
    else:
        s_cnt += 1
if f_cnt > s_cnt:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 33656