akhauriyash/Code-Regression huggingface dataset:
N, M = list(map(int,input().split()))
max = -float('inf')
x = []
y = []
z = []
for i in range(N):
	xx,yy,zz = list(map(int,input().split()))
	x.append(xx)
	y.append(yy)
	z.append(zz)
for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			s = []
			for m in range(N):
				s.append(i*x[m]+j*y[m]+k*z[m])
			s = sorted(s)
			tmp = sum(s[-1*M:])
			if tmp > max:
				max = tmp
if M==0:
	print(0)
else:
	print(max)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n,m;
vector<int> a, b;
int g[55][55];

int dfs(void)
{
	int used[55];
	memset(used, 0, sizeof used);
	queue<int> q;
	q.push(1);
	used[1] = 1;

	while (!q.empty()) {
		int node = q.front();
		q.pop();
		for (int i = 1;i <= n;i++) {
			if (g[i][node] == 1 && used[i] == 0) {
				used[i] = 1;
				q.push(i);
			}
		}
	}

	int ans = 0;
	for (int i = 1;i <= n;i++) {
		if (used[i] == 1) ans++;
	}

	return ans;
}


int main()
{
	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		a.push_back(0);
		b.push_back(0);
		cin >> a[i] >> b[i];
		g[a[i]][b[i]] = 1;
		g[b[i]][a[i]] = 1;
	}

	int ans = 0;
	for (int i = 0;i < m;i++) {
		int x = a[i];
		int y = b[i];
		g[x][y] = 0;
		g[y][x] = 0;
		if (dfs() < n) ans++;
		g[x][y] = 1;
		g[y][x] = 1;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(S: str):
    a = 'abcdefghijklmnopqrstuvwxyz'
    if len(S) != 26:
        for i in range(26):
            if not a[i] in S:
                print (*S, sep = '', end = '')
                print (a[i])
                exit()

    for i in range(25, -1, -1):
        if i == -1:
            break
        if ord(S[i]) < ord(S[i - 1]):
            continue
        else:
            break
    if i == 0:
        print (-1)
        exit()

    tmp_n = ord('z')
    for j in S[i:]:
        if ord(j) > ord(S[i - 1]):
            tmp_n = min(tmp_n, ord(j))

    print (*S[:i - 1], sep = '', end = '')
    print (chr(tmp_n))
 
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
import math
a,b,x = map(int,input().split())
full = a*a*b
ans = 0
if x == full:
    ans = 0
elif x<=full/2:
    c = (2*x)/(a*b)
    d = math.sqrt(b**2+c**2)
    cosB = (c**2+d**2-b**2)/(2*c*d)
    acosB = math.degrees(math.acos(cosB))
    ans = acosB
else:
    c = 2*x/a**2-b
    c2 = b-c
    d = math.sqrt(a**2+c2**2)
    cosA = (c2**2+d**2-a**2)/(2*c2*d)
    acosA = math.degrees(math.acos(cosA))
    ans = 90-acosA
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N = 5050;
int main(){
	int n;
	scanf("%d",&n);
	int count=0,ans=0;
	for(int i=1;i<=n;i+=2){
		count=0;
	    for(int j=1;j<=i;j++){
	    	if(i%j==0)
	    	    count++;
		}
		if(count==8)
		    ans++;
	}
	printf("%d\n",ans);
    return 0;
}

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

int main() {
  int N, P = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) P += vec.at(i);
    if (i % 2 == 1) P -= vec.at(i);
  }
  
  cout << P << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int d, n, m;

main(){
	while(scanf("%d%d%d", &d, &n, &m), d){
		vi st(n+1);
		REP(i, n-1) scanf("%d", &st[i+1]);
		sort(st.begin()+1, st.begin()+n);
		st[n] = d;
		st[0] = 0;
		ll ans = 0;
		REP(i, m){
			int q;
			scanf("%d", &q);
			auto it = lower_bound(ALL(st), q);
			ans += min(*it-q, q-*(it-1));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1524
n = gets.to_i
f = []
p = []
for i in 0..(n - 1) do
  f << gets.split.map(&:to_i)
end

for i in 0..(n - 1) do
  p << gets.split.map(&:to_i)
end

reps = []
[0, 1].repeated_permutation(10).to_a.each do |a|
  cnt = []
  for i in 0..(n - 1) do
    cnt[i] = 0
    for j in 0..9 do
      if a[j] == 1 && a[j] == f[i][j]
        cnt[i] += 1
      end
    end
  end

  ans = []
  for i in 0..(n - 1) do
    ans << p[i][cnt[i]]
  end
  reps << {ans.reduce(:+) => a}
end

reps.map(&:keys).flatten.uniq.sort.reverse.each do |k|
  flg = 0
  reps.each do |rep_array|
    v = rep_array.keys.first
    if v == k && !rep_array.values.flatten.all? {|e| e == 0 }
      puts v
      flg = 1
      break
    end
  end
  break if flg == 1
end

Measured memory_bytes: 4220
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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, a: [u64; n]];
    let mut result: u64 = 1;
    let mut overflow = false;
    for i in a {
        if i == 0 {
            println!("0");
            return ();
        }

        if let Some(_result) = result.checked_mul(i) {
            result = _result;
        } else {
            overflow = true;
        }
    }

    if overflow == true || result > 1_000_000_000_000_000_000u64 {
        println!("-1");
    } else {
        println!("{}", result);
    }
}


Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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 qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    int n;
    cin >> n;
    vector<int> vec;
    rep(i, n-1) {
        int x;
        cin >> x;
        vec.push_back(x);
    }

    map<int, int> mp;
    for (const auto &v : vec) {
        mp[v] += 1;
    }

    rep(i, 1, n+1) {
        cout << mp[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 13204
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main()
{
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int p=-200,k=200;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        p=max(p,a[i]);
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
        k=min(b[i],k);
    }
    int flag=1;
    for(int i=x+1;i<=y;i++)
    {
        if(p<i&&k>=i)
        {
            flag=0;break;
        }
    }
    if(flag) printf("War\n");
    else printf("No War\n");
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
 
    int a,b,c;
    cin>>a>>b>>c;
    int u=100*a+10*b+c;
    if(u%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
 
return 0;
}


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

long long int A[200001] = {0};
long long int sum[300000] = {0};

int main(){

  string s;

  getline(cin , s);

  while(s[0] != '.'){
    string ans = "yes";

    stack<char> ST;
    for(int i = 0; i < (int)s.size(); i++){
      if(s[i] == '(' or s[i] == '[')ST.push(s[i]);
      else if(s[i] == ')'){
        if(!(ST.empty()) and ST.top() == '(')ST.pop();
        else ans = "no";
      }else if(s[i] == ']'){
        if(!(ST.empty()) and ST.top() == '[')ST.pop();
        else ans = "no";
      }
    }
    if(!(ST.empty()))ans = "no";

    cout <<ans<<endl;
    getline(cin , s);
  }

  return 0;
}



Measured memory_bytes: 3164
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  ll mn = 1000000000000000000LL;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,1,101){
    ll b = 0;
    rep(j,0,v.sz){
      b += (v[j]-i)*(v[j]-i);
    }
    mn = min(mn,b);
  }
  cout << mn << endl;
  return 0;
}

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

using namespace std;

struct node
{
    int parent;
    int depth;
    string type;
    vector<int> children;
} Node;

void adjustDepth(vector<node> &v, int id, const int depth)
{
    v[id].depth = depth;
    int len = v[id].children.size();
    for (int i = 0; i < len; i++)
    {
        adjustDepth(v, v[id].children[i], depth + 1);
    }
}

int main()
{
    int n;
    scanf("%d\n", &n);
    vector<node> t(n);
    vector<bool> isRoot(n);
    for (int i = 0; i < n; i++)
    {
        t[i].parent = -1;
        t[i].depth = 0;
        isRoot[i] = true;
    }

    for (int i = 0; i < n; i++)
    {
        int id, chN;
        scanf("%d %d", &id, &chN);

        t[id].children.resize(chN);
        if (chN > 0)
            t[id].type = "internal node";
        else
            t[id].type = "leaf";

        for (int j = 0; j < chN; j++)
        {
            int ch;
            scanf("%d", &ch);
            t[id].children[j] = ch;
            t[ch].parent = id;
            isRoot[ch] = false;
        }
    }

    int rootId = 0;
    for (int i = 0; i < n; i++)
    {
        if (isRoot[i])
        {
            rootId = i;
            break;
        }
    }

    adjustDepth(t, rootId, 0);

    for (int i = 0; i < n; i++)
    {
        printf("node %d: parent = %d, depth = %d, %s, [",
               i,
               t[i].parent,
               t[i].depth,
               t[i].parent == -1
                   ? "root"
                   : t[i].type.c_str());
        int chSize = t[i].children.size();
        for (int j = 0; j < chSize; j++)
        {
            printf("%d", t[i].children[j]);
            if (j != chSize - 1)
                printf(", ");
        }
        printf("]\n");
    }

    return 0;
}



Measured memory_bytes: 11852
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n;
    let xn;
    let ans;
    // init
    n = Number(input.shift());
    xn = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = Number.MAX_SAFE_INTEGER;
    for (var px = 1; px <= 100; px++) {
        let w = 0;
        for (var nx = 0; nx < n; nx++) {
            w += (xn[nx] - px) * (xn[nx] - px);
        }
        ans = Math.min(ans, w);
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29672
N = int(input())
shoplist = []
for i in range(0, N):
	inpt = input().split()
	shoplist.append([i+1, inpt[0], int(inpt[1])])
shoplist.sort(key = lambda v: v[2], reverse = True)
shoplist.sort(key = lambda v: v[1])
for i in range(0, N):
	print(shoplist[i][0])

Measured memory_bytes: 38512
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int gate[100005]={0};
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int left,right;
    cin>>left>>right;
    gate[left]++;
    gate[right+1]--;
  }

  int cnt=0;
  for(int i=1;i<=n;i++){
    gate[i]+=gate[i-1];
    if(gate[i]==m){
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 3948
# gcd: 最大公約数
def gcd(x,y):
  while y:
    x, y = y, x%y
  return x
# lcm: 最小公約数
def lcm(x,y):
  return x*y//gcd(x,y)
a,b,c,d=map(int,input().split())
a-=1
e=lcm(c,d)
tc=b//c-a//c
td=b//d-a//d
te=b//e-a//e
print(b-a-tc-td+te)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int ret[10101];

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	for(x=1;x<=100;x++) for(y=1;y<=100;y++) for(z=1;z<=100;z++) {
		i=x*x+y*y+z*z+x*y+y*z+z*x;
		if(i<=10000) ret[i]++;
	}
	for(i=1;i<=N;i++) cout<<ret[i]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3616
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
    }
    println!("{}", n * n * 3);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-8
#define fastIO ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define N 10000


using namespace std;

long double w,h,x,y;

inline void init()
{
    cin >> w >> h >> x >> y;

    cout << w*h/2 << " ";
    if(abs(x-w/2)<=eps && abs(y-h/2)<=eps)
        cout << 1;
    else
        cout << 0;
    cout << endl;
}

inline void solve()
{

}

int main()
{
    fastIO;
    cout << fixed << setprecision(8);
    init();
    solve();

    cout << flush;

	return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
odd = []
even = []

cnt = 1
for i in v:
	if cnt % 2 != 0:
		odd.append(i)
	else:
		even.append(i)
	cnt += 1

x = Counter(even).most_common()
y = Counter(odd).most_common()

if x[0][0] != y[0][0]:
	print(n - x[0][1] - y[0][1])
elif len(x) == 1 and len(y) == 1:
	print(int(n/2))
else:
	print(n - max(x[0][1] + y[1][1], x[1][1]+y[0][1]))

Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

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

int main()
{
    ciosup;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll g, h, y;
    y = gcd(c, d);
    ll x = y * (c / y) * (d / y);
    //cout << "x" << x << endl;
    g = (b / c) + (b / d) - (b / x);
    h = ((a-1) / c) + ((a-1) / d) - ((a-1) / x);
    //cout << "h" << h << endl;
    cout << (b -g) - ((a-1) - h) << endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n;
vector<int> g[maxn];
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    p--;
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

int p[maxn];
int cnt[maxn];

void dfs0(int v, int p1) {
  if (a[v]) {
    p[v] = p1;
    cnt[v] = 0;
    p1 = v;
  } else {
    cnt[p1]++;
    cnt[v] = -1;
  }
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    dfs0(u, p1);
  }
}

struct T {
  int b, w;

  T(int _b, int _w): b(_b), w(_w) {}

  bool operator < (const T &t) const {
    return (long long) b * t.w < (long long) t.b * w;
  }
};

long long res;
int ts[maxn];
set<T> *st[maxn];

void dfs(int v) {
  ts[v] = 1;
  int maxu = -1;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    dfs(u);
    ts[v] += ts[u];
    if (maxu == -1 || ts[u] > ts[maxu]) {
      maxu = u;
    }
  }
  res += cnt[v];
  if (maxu == -1) {
    st[v] = new set<T>();
    st[v]->insert(T(1, cnt[v]));
    return;
  }
  st[v] = st[maxu];
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (u == maxu) {
      continue;
    }
    for (auto it = st[u]->begin(); it != st[u]->end(); it++) {
      auto cur = *it;
      auto it1 = st[v]->lower_bound(*it);
      if (it1 != st[v]->end() && !(cur < *it1)) {
        res += (long long) cur.b * it1->w;
        cur.b += it1->b;
        cur.w += it1->w;
        st[v]->erase(it1);
      }
      st[v]->insert(cur);
    }
  }
  T cur(1, cnt[v]);
  while (!st[v]->empty() && !(cur < *(st[v]->begin()))) {
    res += (long long) cur.b * st[v]->begin()->w;
    cur.b += st[v]->begin()->b;
    cur.w += st[v]->begin()->w;
    st[v]->erase(st[v]->begin());
  }
  st[v]->insert(cur);
}

void solve() {
  int root = a[0];
  a[0] = 1;
  dfs0(0, -1);
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n; i++) {
    if (cnt[i] != -1 && p[i] != -1) {
      g[p[i]].push_back(i);
    }
  }
  res = 0;
  dfs(0);
  T cur(0, 0);
  while (!st[0]->empty()) {
    res += (long long) cur.b * st[0]->begin()->w;
    cur.b += st[0]->begin()->b;
    cur.w += st[0]->begin()->w;
    st[0]->erase(st[0]->begin());
  }
  if (!root) {
    res -= cur.w;
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main() {
   int r;
   cin >> r;

   cout << 2 * r * 3.14159 << endl;
}

Measured memory_bytes: 3744
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
struct Node{
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;

void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(z->key < x->key){
			x=x->left;
		}
		else
			x=x->right;
	}
	z->parent=y;
	if(y==NIL){
		root=z;
	}else{
		if(z->key < y->key){
			y->left=z;
		}else{
			y->right=z;
		}
	}
}
void inorder(Node *u){
	if(u==NIL)	return ;
	inorder(u->left);
	cout<<" "<<u->key;
	inorder(u->right);
}
void preorder(Node *u){
	if(u==NIL)	return ;
	cout<<" "<<u->key;
	preorder(u->left);
	preorder(u->right);
}
int main(){
	int n, i, x;
	string com;
	cin>>n;
	while(n--){
		cin>>com;
		if(com=="insert"){
			cin>>x;
			insert(x);
		}
		else if(com=="print"){
			inorder(root);
			cout<<endl;
			preorder(root);
			cout<<endl;
		}
	}
	return 0;
}


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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> dp(3);
	for (int x = 0; x < n; x++) {
		vector<int> ndp(3);
		vector<int> a(3);
		for (int i = 0; i < 3; i++) {
			cin >> a[i];
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i != j) {
					ndp[i] = max(ndp[i], dp[j] + a[i]);
				}
			}
		}
		dp = ndp;
	}
	cout << max({ dp[0], dp[1], dp[2], }) << '\n';

	return 0;
}



Measured memory_bytes: 256
N = long(raw_input())
def dig(A,B):
        if A > B:
                return A
        else:
                return B
A = 0
B = 0 
X = []
i = long(1)
while N >= A*A:
        A = long(i)
        if N%i == 0:
                B = long(N/i)
                X.append(dig(A,B))
        if A in X:
                break
        i+=1
print len(str(min(X)))

Measured memory_bytes: 2568
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
	vector<double> ans;
	while (1){
		int n;
		cin >> n;
		if (n==0) break;
		double s[n];
		double avg = 0;
		for (int i = 0; i < n; i++){
			cin >> s[i];
			avg += s[i];
		}
		avg /= n;
		double a = 0;
		for (int i = 0; i < n; i++) a += pow((s[i] - avg), 2);
		a /= n;
		ans.push_back(sqrt(a));
	}

	for (auto x : ans){
		printf("%.10lf\n", x);
	}

}




Measured memory_bytes: 3336
#include<stdio.h>

main()
{
    long long int N,A[200000],i,hat=0;
    scanf("%lld",&N);

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

    if(hat==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}



Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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


signed main(){
	ll n,k;
	string s;
	
	cin >> n >> s >> k;
	
	char memo = s[k-1];
	
	rep(i,0,s.size()){
		if(memo != s[i]) s[i] = '*';
	}
	
	cout << s << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

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


Measured memory_bytes: 3924
import sys
for s in sys.stdin:
  a=map(int,s.split(" "))
  w=a[0]
  a=sorted(a[1:])
  n=len(a)
  A=[]
  A.append(a.pop(0))
  while a:
    A=[a.pop()]+A
    if a==[]: break
    A+=[a.pop()]
    if a==[]: break
    A=[a.pop(0)]+A
    if a==[]: break
    A+=[a.pop(0)]
  a=A[0]+A[-1]
  for i in range(n-1): a+=2*(A[i]*A[i+1])**.5
  print ["OK","NA"][a>w]

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c;
  int A,B;
  cin>>a>>b>>A>>B>>c;
  if(a==c){
    cout<<A-1<<" "<<B;
  }
  else{
    cout<<A<<" "<<B-1;
  } 
}

Measured memory_bytes: 256
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    int K;
    cin >> N >> K;
    vecl res(N);
    REP(i,N) cin >> res[i];
    sort(res.begin(),res.end());
    ll ans = 1e9;
    for(int i = 0; i <= N-K; i++) chmin(ans,(ll)(res[i+K-1]-res[i]));
    cout << ans << endl;
}


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

int n,pd;
char s[100010],ji[5];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	ji[2]=s[1];
	for(int i=2;i<=n;++i)
	{
		if(s[i]==ji[2])
		{
			pd=1;
			printf("%d %d\n",i-1,i);
			break;
		}
		if(s[i]==ji[1])
		{
			pd=1;
			printf("%d %d\n",i-2,i);
			break;
		}
		ji[1]=ji[2];
		ji[2]=s[i];
	}
	if(pd==0)
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n, x;
int a[55];
int dp[55][55][2530];//i枚目までで今までj枚とってて合計がKのときの通り数
signed main() {
	cin >> n >> x;
	rep(i, n)cin >> a[i];
	for (int i = 0; i <= n; i++)dp[i][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 0; k <= 2525; k++) {
				if (i < j)continue;
				if (k < a[i - 1])dp[i][j][k] = dp[i - 1][j][k];
				else dp[i][j][k] = (dp[i - 1][j][k] + dp[i - 1][j - 1][k - a[i - 1]]);
			}
		}
	}
	int ans = 0;
	for (int j = 1; j <= n; j++) {
		for (int k = 0; k <= 2525; k++) {
			if (k == x * j) {
				ans += dp[n][j][k];
			}
		}
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 55552
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // ??\????????°?????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // ?????°????¨????
        int cnt = Integer.parseInt(br.readLine());
        // ????????????
        String[] sarray = br.readLine().split(" ",cnt);
        // ?????\??????????????????
        selectionSort(sarray,cnt);
    }
    
    public static void selectionSort(String[] sarray, int cnt){
        int chgNum = 0;
        // ???????????????????????????
        for(int i = 0; i < cnt; i++){
            // ????°????????????????
            int minj = i;
            // ?????????????????§??????
            for(int j = i; j < cnt; j++){
                if(Integer.parseInt(sarray[j]) < Integer.parseInt(sarray[minj])){
                    minj = j;
                }
            }
            // ????°?????????\?????????
            if(minj != i){
                String v = sarray[i];
                sarray[i] = sarray[minj];
                sarray[minj] = v;
                chgNum = chgNum + 1;
            }
        }
        outPrint(sarray,cnt);
        System.out.println(chgNum);
    }

    public static void outPrint(String[] sarray, int cnt){
        StringBuilder sb = new StringBuilder();
        for(int n = 0; n < cnt ; n++){
            if(n>0)sb.append(" ");
            sb.append(sarray[n]);
        } 
        System.out.println(sb);
        sb.setLength(0);
    }
};


Measured memory_bytes: 25292
# -*- coding: utf-8 -*-

N = int(input())

A = []
i = 1
while 6 ** i <= 100000:
    A.append(6 ** i)
    i += 1
j = 1
while 9 ** j <= 100000:
    A.append(9 ** j)
    j += 1
A.sort(reverse=True)  # 引き出せる金額のリスト

# i番目以降の金額を使ってj円を作るときの最小操作数
dp = [[-1 for j in range(N + 1)] for i in range(len(A) + 1)]


def func(i, j):
    # 1円しか選択肢がないなら
    if i == len(A):
        dp[i][j] = j
        return dp[i][j]

    # 探索済みなら計算量を減らせる
    if dp[i][j] >= 0:
        return dp[i][j]

    # その他の場合
    # 目いっぱい引き出すのが最適とは限らない
    # 引き出す回数を増やしていく
    # 8*11回くらいで十分だろう
    ret = 100001
    for times in range(88):
        if A[i] * times <= j:
            # dp[i][j]に代入すると再計算されてしまうことに注意
            ret = min(ret, func(i+1, j-A[i]*times) + times)
        else:
            break
    dp[i][j] = ret
    return ret


print(func(0, N))


Measured memory_bytes: 107756
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;


int main(){
  int n, m; cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  rep(i, 0, n){
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  sort(all(a), greater<int>());
  long double th = 1.0 / (4 * m);
  // cout << th << endl;
  for(int i=0; i<m; i++){
    if((long double)a[i] / sum < th){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
     


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define sf scanf
#define pf printf
#define pi acos(-1)
#define time_save ios_base::sync_with_stdio(false); cin.tie(NULL);

ll vis[200005],n,m,mx,cnt=0;
vector<ll>vec[200005];
void dfs(ll src)
{
    vis[src]=1;
    cnt++;
    for(ll i=0;i<vec[src].size();i++)
    {
        ll v=vec[src][i];
        if(vis[v]==0)
        {
            vis[v]=1;
            //cnt++;
            dfs(v);
        }
    }
}
int main()
{
    //time_save;
    sf("%lld%lld",&n,&m);
    ll x,y;
    for(ll i=0;i<m;i++)
    {
        sf("%lld%lld",&x,&y);
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    for(ll i=1;i<=n;i++)
    {
        cnt=0;
        if(vis[i]==0)
        {
            dfs(i);
            mx=max(mx,cnt);
        }
    }
    cout<<mx<<endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  string ans;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0') {
      ans += '0';
    } else if (S[i] == '1') {
      ans += '1';
    } else if (S[i] == 'B' && ans.size() > 0) {
      ans.pop_back();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s;
    int n;
    cin>>s>>n;
    for(int i=0;i<s.size();i++)
        if((i+1)%n==1)
            cout<<s[i];
    if(n==1)
        cout<<s;
    return 0;
}


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

const int N = 100 + 5;
const int M = 1e5 + 5;
int n, we;
ll w[N], v[N];
ll dp[N][M];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> we;
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    for (int i = 0; i <= n; i++)
        for (int j = 0; j < M; j++)
            dp[i][j] = INT_MAX;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = 0;
        for (int j = 1; j < M; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i - 1] >= 0)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
        }
    }

    for (int i = 1e5; i >= 1; i--) {
            if (dp[n][i] <= we)
                return cout << i, 0;
    }
    return 0;
}


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

int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
int dfs(int i, int j, vector<string> &g){
    int res=0;
    if(g[i][j] == '#') return res;
    g[i][j] = '#';
    int h=g.size()-2, w=g[0].size()-2;
    if((i==1 or i==h) and (j==1 or j==w)){
        res++;
    }
    for(int d=0; d<4; d++){
        res += dfs(i+di[d], j+dj[d], g);
    }
    return res;
}
bool check(vector<string> &g){
    int h=g.size()-2, w=g[0].size()-2;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if((i==1 or i==h) and (j==1 or j==w)){
                continue;
            }
            auto tmp = g;
            tmp[i][j] = '#';
            if(dfs(1, 1, tmp) != 4){
                return false;
            }
        }
    }
    return true;
}

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h == 0) break;
        vector<string> g(h+2, string(w+2, '#'));
        for(int i=1; i<=h; i++){
            cin >> g[i];
            g[i] = "#" + g[i] + "#";
        }
        if(check(g)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a+b);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a-b);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	string s;
	cin>>s;
	int val=0,x,i,n=s.length();
	for(i=0;i<n;i++)
	{
		x=s[i]-'0';
		val=(val+x)%9;
	}
	if(val)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3708
#include<iostream>

using namespace std;

int main(){
  int A,B,X;
  cin>> A >> B ;
  if(13 <= A){
  X = B;
  }
  if(6<=A && A<=12){
    X = B/2;
  }
  if(A<=5){
    X = 0;
  }
  cout << X <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
   string A,B,C;
   int N,cou;
   cou=0;
   cin>>N>>A>>B>>C;
   for(int i=0;i<N;i++){
       if(A.substr(i,1)==B.substr(i,1)&&B.substr(i,1)==C.substr(i,1)){
           
       }else if(A.substr(i,1)==B.substr(i,1)||B.substr(i,1)==C.substr(i,1)||A.substr(i,1)==C.substr(i,1)){
           cou+=1;
       }else cou+=2;
        
   }

    cout<<cou<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

def main():
    #N, M = map(int, input().split())
    N, K = map(int, input().split())
    Vs = list(map(int, input().split()))

    max_value = None
    for l in range(min([K+1, N+1])):
        for r in range(min([K+1-l, N-l+1])):
            for b in range(K - l - r + 1):
                values = list(Vs[:l])
                if r > 0:
                    values += list(Vs[-r:])
                values = sorted(values)
                for i in range(b):
                    if values and values[0] < 0:
                        values.pop(0)
                    else:
                        break
                value = sum(values)
                if max_value is None or max_value < value:
                    max_value = value

    print(max_value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int x;
		Scanner sc=new Scanner(System.in);
		for(int i=1;i<=10000;i++){
			x=sc.nextInt();
			if(x==0)break;
			System.out.println("Case "+i+": "+x);
		}
    }
}


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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q,p,x;

vector<ll> A;
vector<ll> B;

vector<ll> nxtl;
vector<ll> nxtr;

vector<ll> P;
vector<ll> Q;
vector<ll> ind;

ll MA[2001] = {0};

bool comp(ll i, ll j){
    return Q[i] < Q[j];
}

ll solve(){

    sort(all(ind), comp);
    m = sz(ind);
    MA[m] = 0;
    for(ll c1 = m-1; c1 >= 0; c1--){
        MA[c1] = max(MA[c1+1], P[ind[c1]]);
    }
    ll ans = 2*MA[0];

    for(ll c1 = 0; c1 < m; c1++){
        ans = min(ans, 2*Q[ind[c1]] + 2*MA[c1+1]);
    }
    return ans;
}

int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    string s;
    string s2;

    cin >> s;
    cin >>  s2;
    n = s.length();

    for(ll c1 = 0; c1 < n; c1++){
        a = ll(s[c1])-ll('0');
        A.push_back(a);
    }

    bool eq = 1;
    bool zb = 1;
    for(ll c1 = 0; c1 < n; c1++){
        a = ll(s2[c1])-ll('0');
        if(a != 0)zb = 0;
        if(a != A[c1])eq = 0;
        B.push_back(a);
    }

    if(eq){
        cout << "0\n";
        return 0;
    }
    if(zb){
        cout << "-1\n";
        return 0;
    }

    for(ll c1 = 0; c1 < n; c1++){
        ll i = c1;
        ll dl = 0;
        while(B[i] == 0){
            i = (i+n-1)%n;
            dl++;
        }
        nxtl.push_back(dl);
        ll dr = 0;
        i = c1;
        while(B[i] == 0){
            i = (i+n+1)%n;
            dr++;
        }
        nxtr.push_back(dr);
    }

    ll ans = big;
    for(ll c1 = 0; c1 < n; c1++){
        ll mism = 0;
        vector<ll> X;
        for(ll c2 = 0; c2 < n; c2++){
            mism += B[c2]^A[(c2+c1)%n];
            if(B[c2] == 0 && A[(c2+c1)%n] == 1){
                X.push_back((c2+c1)%n);
            }
        }
        //LEFT SHIFT
        ll dl = c1;
        P.clear();
        Q.clear();
        ind.clear();
        for(ll c2 = 0; c2 < sz(X); c2++){
            if(nxtl[X[c2]] > dl){
                P.push_back(nxtr[X[c2]]);
                Q.push_back(nxtl[X[c2]]-dl);
                ind.push_back(sz(ind));
            }
        }
        ll temp = dl + mism + solve();
        ans = min(ans, temp);
        // RIGHT SHIFT
        ll dr = (n-c1)%n;
        P.clear();
        Q.clear();
        ind.clear();
        for(ll c2 = 0; c2 < sz(X); c2++){
            if(nxtr[X[c2]] > dr){
                P.push_back(nxtr[X[c2]]-dr);
                Q.push_back(nxtl[X[c2]]);
                ind.push_back(sz(ind));
            }
        }
        temp = dr + mism + solve();
        ans = min(ans, temp);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cout<<n/3;
	return 0;
}

Measured memory_bytes: 256