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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double m5,m10;
  while(cin>>m5>>m10){
    if(m5 < 35.50 && m10 < 71.0){
      cout << "AAA"<<endl;
    }
    else if(m5 < 37.50 && m10 < 77.0){
      cout << "AA"<<endl;
    }
    else if(m5 < 40.0 && m10 < 83.0){
      cout << "A"<<endl;
    }
    else if(m5 < 43.0 && m10 < 89.0){
      cout << "B" <<endl;
    }
    else if(m5 < 50.0 && m10 < 105.0){
      cout << "C"<<endl;
    }
    else if(m5 < 55.0 && m10 < 116.0){
      cout << "D"<<endl;
    }
    else if(m5 < 70.0 && m10 < 148.0){
      cout << "E"<<endl;
    }
    else cout << "NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Point { internal double x, y; }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] c = Array.ConvertAll(input.Trim().Split(' '), int.Parse);

                string mgr = "1414121214141212";
                int min = int.MaxValue;
                string minPos = "";

                for (int i = 0; i < 8; i++)
                {
                    int sum = 0;

                    for (int j = 0; j < 8; j++)
                    {
                        int p = int.Parse(mgr[i + j].ToString());

                        if (c[j] > p) sum += (c[j] - p);
                    }

                    if (sum < min)
                    {
                        min = sum;
                        minPos = mgr.Substring(i, 8);
                    }
                    else if (sum == min)
                    {
                        string temp = mgr.Substring(i, 8);

                        minPos = Math.Min(int.Parse(minPos), int.Parse(temp)).ToString();
                    }
                }

                for (int i = 0; i < 7; i++)
                {
                    sb.Append(minPos[i] + " ");
                }
                sb.AppendLine(minPos[7].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <map>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

ll ans[10];
pair<ll, ll> g[100005];
map<pair<ll, ll>, bool> m;
ll H, W, N;

int num(ll h, ll w)
{
	int n = 0;

	h--; w--;
	REP(i, 3)
	{
		ll th = h + i;
		if (th < 0 || th >= H)return -1;
		REP(j, 3)
		{
			ll tw = w + j;
			if (tw < 0 || tw >= W)return -1;

			pair<ll, ll> p(th, tw);
			if (m[p])
			{
				n++;
			}
		}
	}

	return n;
}

int main()
{
	cin >> H >> W >> N;
	REP(i, N)
	{
		cin >> g[i].first >> g[i].second;
		g[i].first--; g[i].second--;
	}

	sort(g, g + N, [](pair<ll, ll> a, pair<ll, ll> b) {return a.first == b.first ? a.second < b.second:a.first < b.first; });

	REP(i, 10)
	{
		ans[i] = 0;
	}
	ans[0] = (H - 2)*(W - 2);

	REP(i, N)
	{
		pair<ll, ll> p = g[i];
		ll h = p.first - 1;
		ll w = p.second - 1;
		REP(j, 3)
		{
			ll th = h + j;
			if (th < 0 || th >= H)continue;
			REP(k, 3)
			{
				ll tw = w + k;
				if (tw < 0 || tw >= W)continue;

				int n = num(th, tw);
				if (n == -1)continue;
				ans[n]--;
				ans[n + 1]++;
			}
		}
		m[p] = true;
	}

	REP(i, 10)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 158080
import java.util.*;

public class Main{
    int N,M,L,K,A,H;
    int[] d;
    List<Edge>[] adj;
    int INF = 1000000000;
    List<String> f;

    public static void main(String[] args){
	new Main().solve();
    }

    class Edge{
	int t, c;
	public Edge(int t, int c) {
	    this.t = t;
	    this.c = c;
	}
    }

    @SuppressWarnings("unchecked")
    void solve(){
	Scanner sc = new Scanner(System.in);
	N = sc.nextInt();
	while(N!=0){
	    M = sc.nextInt();
	    L = sc.nextInt();
	    K = sc.nextInt();
	    A = sc.nextInt();
	    H = sc.nextInt();
	    f = new ArrayList<String>();
	    for(int i=0; i<L; i++){
		f.add(sc.nextInt()+"");
	    }
	    f.add(A+"");
	    f.add(H+"");
	    
	    adj = new List[N];
	    for(int i=0; i<N; i++)adj[i] = new ArrayList<Edge>();
	    for(int i=0; i<K; i++){
		int x = sc.nextInt();
		int y = sc.nextInt();
		int t = sc.nextInt();
		adj[x].add(new Edge(y,t));
		adj[y].add(new Edge(x,t));
	    }

	    d = new int[N*(M+1)];

	    dijkstra(A);

	    if(d[H*(M+1)+M]==INF){
		System.out.println("Help!");
	    }else{
		System.out.println(d[H*(M+1)+M]+Math.max(0,d[H*(M+1)+M]-M));
	    }

	    N = sc.nextInt();
	}
    }

    void dijkstra(int s){
	Arrays.fill(d,INF);
	d[s*(M+1)+M] = 0;
	PriorityQueue<Integer> q = new PriorityQueue<Integer>(N, new Comparator<Integer>() {
		public int compare(Integer o1, Integer o2) {
		    return d[o1]-d[o2];
		}
	    });

	q.add(s*(M+1)+M);
	while(!q.isEmpty()){
	    int v = q.poll();
	    int town = v/(M+1);
	    int left = v%(M+1);
	    for(Edge e:adj[town]){
		if(left-e.c<0)continue;
		int w = d[town*(M+1)+left]+e.c;
		if(f.contains(e.t+"")){
		    if(w<d[e.t*(M+1)+M]){
			q.remove(e.t*(M+1)+M); 
			d[e.t*(M+1)+M] = w; 
			q.add(e.t*(M+1)+M);
		    }
		}else{
		    if(w<d[e.t*(M+1)+left-e.c]){
			q.remove(e.t*(M+1)+left-e.c); 
			d[e.t*(M+1)+left-e.c] = w; 
			q.add(e.t*(M+1)+left-e.c);
		    }
		}
	    }
	}
    }
}

Measured memory_bytes: 14000
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 200010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,a[N],l1,r1,mx[N][20],mn[N][20],lg[N],ans,s[N],tmp;
int Qmn(int l,int r){
	int k=lg[r-l+1];
	return min(mn[l][k],mn[r-(1<<k)+1][k]);
}
int Qmx(int l,int r){
	int k=lg[r-l+1];
	return max(mx[l][k],mx[r-(1<<k)+1][k]);
}
int main(){
	n=read(),m=read();
	memset(mn,0x3f,sizeof(mn));
	for(int i=1;i<=n;++i){
		a[i]=mn[i][0]=mx[i][0]=read();
	}
	for(int i=2;i<=n;++i){
		s[i]=s[i-1]+(a[i]>a[i-1]);
	}
	for(int j=1;j<=19;++j){
		for(int i=1;i+(1<<j)-1<=n;++i){
			mx[i][j]=max(mx[i][j-1],mx[i+(1<<j-1)][j-1]);
			mn[i][j]=min(mn[i][j-1],mn[i+(1<<j-1)][j-1]);
		}
	}
	for(int i=2;i<=n;++i){
		lg[i]=lg[i>>1]+1;
	}
	ans=1,tmp=0;
	for(int i=1;i<=n-m;++i){
		if(!(a[i]==Qmn(i,i+m-1)&&a[i+m]==Qmx(i+1,i+m))){
			++ans;
			if(s[i+m-1]-s[i]==m-1)++tmp;
		}
	}
	tmp+=(s[n]-s[n-m+1]==m-1);
	ans-=max(0,tmp-1);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 37360
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> f(6);
  for (int i = 0; i < 6; i++){
    cin >> f[i];
  }
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
    vector<int> f2(6);
    if (s[i] == 'E'){
      f2[0] = f[3];
      f2[1] = f[1];
      f2[2] = f[0];
      f2[3] = f[5];
      f2[4] = f[4];
      f2[5] = f[2];
    }
    if (s[i] == 'N'){
      f2[0] = f[1];
      f2[1] = f[5];
      f2[2] = f[2];
      f2[3] = f[3];
      f2[4] = f[0];
      f2[5] = f[4];
    }
    if (s[i] == 'S'){
      f2[0] = f[4];
      f2[1] = f[0];
      f2[2] = f[2];
      f2[3] = f[3];
      f2[4] = f[5];
      f2[5] = f[1];
    }
    if (s[i] == 'W'){
      f2[0] = f[2];
      f2[1] = f[1];
      f2[2] = f[5];
      f2[3] = f[0];
      f2[4] = f[4];
      f2[5] = f[3];
    }
    for (int i = 0; i < 6; i++){
      f[i] = f2[i];
    }
  }
  cout << f[0] << endl;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e5+7;
int n;vector<int> vec1,vec2;
set<int> se;
int a[maxn];
const int N=5e5+10;
char s[N];
int ans[N];
ll res;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int i,j;
	ans[0]=0;
	for(i=1;i<=n;)
	{
		if(s[i]=='<')
		{
			ans[i]=ans[i-1]+1;
			i++;
			continue;
		}
		j=i;
		while(j<=n&&s[j]=='>')j++;
		j--;
		ans[j]=0;
		for(int k=j-1;k>=i;--k)
		ans[k]=ans[k+1]+1;
		ans[i-1]=max(ans[i-1],ans[i]+1);
		i=j+1;
	}
	for(i=0;i<=n;++i)
	res+=ans[i];
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

const int N = 2e5 + 5;
int a[N], mini[N], maxi[N];
int lol[N];
int n, k;

void solve() {
	cin >> n >> k;
	int pt = 1;
	int ans = n - k + 1;
	bool bb = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i]++;
	}
	for(int i = 1; i <= n; i++) {
		pt = max(pt, i);
		while(pt < n && a[pt + 1] > a[pt]) pt++;
		lol[i] = pt;
		if(pt - i + 1 >= k) {
			bb = 1;
			ans--;
		}
	}
	k++;
	ans += bb;
	deque<int> d, d1;
	for(int i = 1; i <= n; i++) {
		while(!d.empty() && a[d.back()] > a[i]) {
			d.pop_back();
		}
		d.push_back(i);
		while(d.front() <= i - k) d.pop_front();
		mini[i] = a[d.front()];
		while(!d1.empty() && a[d1.back()] < a[i]) {
			d1.pop_back();
		}
		d1.push_back(i);
		while(d1.front() <= i - k) d1.pop_front();
		maxi[i] = a[d1.front()];
	}
	for(int i = k; i <= n; i++) {
		if(mini[i] == a[i - k + 1] && maxi[i] == a[i] && (lol[i - k + 1] < i - 1 && lol[i - k + 2] < i)) ans--;
	}
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		// cout << "Case #" << tt << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4224
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

#####
a,b = gim
if a<=9 && b<=9
  puts a*b
else
  puts -1
end

Measured memory_bytes: 1912
#include <stdio.h>

int main(void) {
	int A, B;
	int asumikana;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	asumikana = A + B;
	printf(asumikana >= 10 ? "error\n" : "%d\n", asumikana);
	return 0;
}


Measured memory_bytes: 128
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

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

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

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

const MOD: usize = 998244353;

fn main() {
    input!(n: usize, a: usize, b: usize, k: usize);

    let mut candidates = vec![];
    for x in 0..(n + 1) {
        if a * x > k {
            break;
        }
        let rest = k - a * x;
        if rest % b != 0 {
            continue;
        }
        let y = rest / b;
        if y > n {
            continue;
        }
        candidates.push((x, y));
    }

    let combination = Combination::new(n + 1, MOD);
    let mut ans = 0;
    for &(x, y) in candidates.iter() {
        let x = combination.get(n, x);
        let y = combination.get(n, y);
        ans = (ans + (x * y) % MOD) % MOD;
    }
    println!("{}", ans);
}

pub struct Combination {
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    modulo: usize,
}

impl Combination {
    pub fn new(max: usize, modulo: usize) -> Combination {
        let mut inv = vec![0; max + 1];
        let mut fact = vec![0; max + 1];
        let mut inv_fact = vec![0; max + 1];
        inv[1] = 1;
        for i in 2..(max + 1) {
            inv[i] = inv[modulo % i] * (modulo - modulo / i) % modulo;
        }
        fact[0] = 1;
        inv_fact[0] = 1;
        for i in 0..max {
            fact[i + 1] = fact[i] * (i + 1) % modulo;
        }
        for i in 0..max {
            inv_fact[i + 1] = inv_fact[i] * inv[i + 1] % modulo;
        }
        Combination {
            fact: fact,
            inv_fact: inv_fact,
            modulo: modulo,
        }
    }

    pub fn get(&self, x: usize, y: usize) -> usize {
        assert!(x >= y);
        self.fact[x] * self.inv_fact[y] % self.modulo * self.inv_fact[x - y] % self.modulo
    }
}


Measured memory_bytes: 21752
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String X = sc.next();
      if(X.equals("7")||X.equals("5")||
         X.equals("3")){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
}

Measured memory_bytes: 35556
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 998244353

ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(char *a,char *b) {
    char temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
vector<ll> isprime;
void seive(){
    isprime = vector<ll>(2000001,-1);
    for(int i=2;i*i<=2000000;i++){
        if(isprime[i]==-1){
            for(int j=i*i;j<=2000000;j+=i){
                if(isprime[j]==-1) isprime[j]=i;
            }
        }
    }
    for(int i=2;i<=2000000;i++){
        if(isprime[i]==-1) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==-1) return p;
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r1]=r2;
}
void solve() {
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h+(m/60.0);
    setprecision(16);
    ld pi= 3.141592653589793238;
    ld angleH=h*(pi/6);
    ld angleM=m*(pi/30);
    ld angle=abs(angleM-angleH);
    if(angle>pi) angle=2*pi-angle;
    ld ans=a*a+b*b-2*a*b*cos(angle);
    ans=sqrt(ans);
    cout<<setprecision(16)<<ans;

}




int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 4188
#include <stdio.h>
#include <string.h>

int main(void)
{
	char cfi[15], c[8], a[15];
	int fi, n;
	int i, j, k,len;
	
	scanf ("%d", &n);
	
	for (i = 0; i < n; i++){
		
		scanf("%d", &fi);
		printf("Case %d:\n", i + 1);
		
		for (j = 0; j < 10; j++){
			
			fi *= fi;
			sprintf(cfi,"%d", fi);
			
			len = strlen(cfi);
			if (len != 8){
				len = 8 - len;
				for (k = 0; k < len; k++){
					c[k] = '0';
				}
				c[len] = '\0';
				
				sprintf(a,"%s%s",c,cfi);
			}
			else {
				strcpy(a,cfi);
			}
			fi = 0;
			for (k = 2; k < 6; k++){
				fi = fi * 10 + a[k] - '0';
			}
			printf("%d\n", fi);
		}
	}
	return (0);
}
				
		

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 200002;
int n,a[N];
ll sum;

int main(){
    readi(n);
    lp(i,1,n) readi(a[i]), sum += a[i];

    ll curr = 0, ans = infll;
    lp(i,1,n-1){
        sum -= a[i];
        curr += a[i];
        ans = min(ans, abs(sum - curr));
    }
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ios::sync_with_stdio(0);cin.tie(0);
*/


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x[n], y[n], a[n];
    rep(i, n) {
        cin >> x[i] >> y[i] >> a[i];
    }
    bool E[w][h];
    rep(i, w) {
        rep(k, h) {
            E[i][k] = true;
        }
    }

    rep(i, n) {
        if (a[i] == 1) {
            rep(k, x[i]) {
                rep(l, h) {
                    E[k][l] = false;
                }
            }
        } else if (a[i] == 2) {
            for (int k = x[i]; k < w; k++) {
                rep(l, h) {
                    E[k][l] = false;
                }
            }
        } else if (a[i] == 3) {
            rep(k, y[i]) {
                rep(l, w) {
                    E[l][k] = false;
                }
            }
        } else {
            for (int k = y[i]; k < h; k++) {
                rep(l, w) {
                    E[l][k] = false;
                }
            }
        }
    }
    int ans = 0;
    rep(i, w) {
        rep(k, h) {
            if (E[i][k])
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W,N;
vector<int> vec[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W>>N;
    
    rep(i,N){
        int x,y; cin>>x>>y;
        if(x<y) continue;
        vec[y].push_back(x);
    }
    
    rep1(i,W) sort(all(vec[i]));
    
    int mn=H, nowx=1;
    rep1(i,W){
        nowx++;
        if(nowx>mn) break;
        for(auto x:vec[i]){
            if(x<nowx) continue;
            chmin(mn,x-1);
            if(x==nowx){
                cout1(mn)
                return 0;
            }
            break;
        }
        
        bool f=true;
        if(i<W&&vec[i+1].size()){
            f=false;
            vec[i+1].push_back(H+1);
            for(auto x:vec[i+1]){
                if(x<nowx) continue;
                if(x==nowx) nowx++;
                else{
                    f=true;
                    break;
                }
                if(nowx>=mn) break;
            }
        }
        if(!f) break;
    }
    cout1(mn)
}


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

using namespace std;

const string ord = "AB?O";

int main() {
    int no, ans[4] = {};
    char blood[3];
    while (scanf("%d,%s", &no, blood) != EOF) {
        if (strlen(blood) > 1) ans[2]++;
        else ans[ord.find(blood[0])]++;
    }

    for (int i = 0; i < 4; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

const int high_val = N;
int main()
{
	int n, W, w[N], v[N];
	vector <ll> dp(N, INF), tmp;
	cin >> n >> W;
	for (int i = 1; i <= n; ++i)
	{
		cin >> w[i] >> v[i];
	}
	dp[0] = 0;
	for (int item = 1; item <= n; ++item)
	{
		tmp = dp;
		for (int val = 1; val <= high_val; ++val)
		{
			if(v[item] <= val)
				dp[val] = min(tmp[val], tmp[val - v[item]] + w[item]);
		}
	}
	for (int i = N - 1; i >= 0; --i)
	{
		if(dp[i] <= W)
		{
			cout << i;
			return 0;
		}
	}
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
long long T;
int cnt = 0;
void dfs(long long x,unsigned char flag){
    if(x <= T){
        if(flag==07) cnt ++;
        dfs(x*10+3,flag|01);//001
        dfs(x*10+5,flag|02);//010
        dfs(x*10+7,flag|04);//100
    }
}
int main(){
    scanf("%d",&T);
    dfs(0,0);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout <<(a<=9&&b<=9?a*b:-1) <<"\n";
}

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

int main() {
    int n, d; cin >> n >> d;
    vector<int> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    int ans = 0;
    Int D = (Int)d*d;
    rep(i, n) {
        Int tmp;
        tmp = (Int)x[i]*x[i] + (Int)y[i]*y[i];
        if (tmp <= D) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4828
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

ans = []
str = gc
t = gc
rep str.size-t.size+1 do |i|
  flag = true
  repl i, i+t.size-1 do |j|
    unless str[j] == t[j-i] || str[j] == '?'
      flag = false
      break
    end
  end
  if flag
    tmp = str.dup
    repl i, i+t.size-1 do |j|
      tmp[j] =t[j-i]
    end
    ans << tmp.map{|tm| tm = 'a' if tm == '?'; tm }.join
  end
end
ans.sort!
puts ans.size > 0 ? ans.first : 'UNRESTORABLE'


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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e6+7;
int n;
int a[maxn];

//has 1 => can be 0 or 1
//contribution of parity to see is 0 or 1
//no 1 => can be 0 or 2, see a/2 is 0 or 1 to decide

//parity of C(n,k) can be found by lucas theorem
//my first thought is remember how much 2 factor u have with least significant bit function
//and use C(n, k) = C(n, k-1)*k/(n-k+1)

//such a beautiful problem
//learned : lucas theorem is useful, contribution thinking, stay orginized!

//bool C(int n, int k){ return (n&k) == k;} //corollary of Lucas theorem
// =>　(ni, ki), ki = 1 => ni = 1, ki = 0 => ni = 0or1 => no 2
bool C(int n, int k){ return ((n-k)^k) == n;}
// => n has all k's bit => odd 

//check T
void solve()
{
	int cur = 0;
	string s;
	bool noone = 1;
	cin >> n; cin >> s; rep(i, 0, n) a[i] = s[i]-'0'-1, noone &= a[i]!=1;
	if(noone) rep(i, 0, n) a[i] >>= 1;
	int par = 0;
	rep(i, 0, n) par ^= C(n-1, i)*(a[i]&1);
	cout << par*(noone+1) << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


/*
15
132123321111222
*/


Measured memory_bytes: 5404
#include<bits/stdc++.h>
using namespace std;
 
constexpr int calc(int n, int c1, int c2, int s1, int s2, int options[],
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return diff1 * c1 - diff2 * c2 + s1 - s2;
}

static unsigned int myrand() {
	static unsigned int x=192047155,y=392751284,z=194681846,w=193571838;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return w=(w^(w>>19))^(t^(t>>8));
}

constexpr bool check(int diff, int time) {
  return diff >= 0 || myrand() >= (-diff) * (clock()-time) * 1.4;
}

int main() {
  int n;
  cin >> n;
  int c[26], last[26], s[n][26], op[n];
  
  for (int i = 0; i < 26; ++i) {
    cin >> c[i];
    last[i] = -1;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  int total(0);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1), max_score(-1e9);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    op[i] = test;
    last[test] = i;
  }
  
  // stochastic
  time_t time = clock();
  while ((clock()-time)<=1.96*CLOCKS_PER_SEC) {
    if (myrand() & 1) {
      int dd(myrand() % n), ot(op[dd]), tt;
      do { tt = myrand() % 26; } while (ot == tt);
      
      op[dd] = tt;
      int ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot], op, dd, tt, ot);
      
      if (check(ns,time)) {
        total += ns;
      } else {
        op[dd] = ot;
      }
    } else {
      int dd1(myrand() % n), ot1(op[dd1]), dd2, ot2;
      do { dd2 = myrand() % n; ot2 = op[dd2]; } while (ot1 == ot2);
      
      op[dd1] = ot2;
      int ns1 = calc(n, c[ot2], c[ot1], s[dd1][ot2], s[dd1][ot1], op, dd1, ot2, ot1);
      op[dd2] = ot1;
      int ns2 = calc(n, c[ot1], c[ot2], s[dd2][ot1], s[dd2][ot2], op, dd2, ot1, ot2);
      
      if (check(ns1+ns2,time)) {
        total += ns1 + ns2;
      } else {
        op[dd1] = ot1;
        op[dd2] = ot2;
      }
    }
  }
  
  for (const int& i: op) cout << i + 1 << endl;
  
  return 0;
}

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

bool judge(string& s)
{
    for(auto c : s)
    {
        if(c != '7') return false;
    }
    return true;
}

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

    int amari = 0;
    int ans = -1;
    for(int i=1; i<10000000; i++)
    {
        amari += 7;
        amari %= K;
        if(amari==0)
        {
            ans = i;
            break;
        }
        amari *= 10;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3684
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def size(self,x):
        return -self.parents[self.find(x)]

N,M=map(int,input().split())
X=[]
for i in range(M):
    X.append(list(map(int,input().split())))
UF=UnionFind(N)
for i in range(M):
    UF.union(X[i][0]-1,X[i][1]-1)
print(max(UF.size(i) for i in range(N)))  

Measured memory_bytes: 50060
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int[][] field = new int[10][10];
		int max = 0, count=0;

		while(cin.hasNext()){
			String str = cin.next();
			String[] s = str.split(",");
			int x = Integer.parseInt(s[0]);
			int y = Integer.parseInt(s[1]);
			int size = Integer.parseInt(s[2]);
			int[] v11={1,0,-1,0};
			int[] v12={0,1,0,-1};
			int[] v21={1,-1,1,-1};
			int[] v22={1,1,-1,-1};
			int[] v31={2,0,-2,0};
			int[] v32={0,2,0,-2};
			field[x][y]++;
			for(int i = 0; i < 4;i++){
				if(inRange(x+v11[i], y+v12[i])){
					field[x+v11[i]][y+v12[i]]++;
				}
			}
			if(size==1){
				continue;
			}
			for(int i = 0; i < 4;i++){
				if(inRange(x+v21[i], y+v22[i])){
					field[x+v21[i]][y+v22[i]]++;
				}
			}
			if(size==2){
				continue;
			}
			for(int i = 0; i < 4;i++){
				if(inRange(x+v31[i], y+v32[i])){
					field[x+v31[i]][y+v32[i]]++;
				}
			}
		}
		for(int i = 0; i < 10;i++){
			for(int j = 0; j < 10;j++){
				if(max < field[i][j]){
					max = field[i][j];
				}
				if(field[i][j] == 0){
					count++;
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
	static boolean inRange(int i , int j){
		if(i >= 0 && i < 10 && j >= 0 && j < 10){
			return true;
		}
		else{
			return false;
		}
	}
}

Measured memory_bytes: 12000
n = int(input())
s = input()
res = 2000000 
aw=s.count('W')
ar=s.count('R')
if (aw == 0 or ar == 0):
	res=0
pw=0
pr=0
for i in range(n-1):
	if (s[i] == 'R'):
		pr=pr+1
	else:
		pw=pw+1
	if (max(pw,ar-pr) < res):
		res = max(pw,ar-pr)

print(str(res))

Measured memory_bytes: 9368
ang = 0
x = 0
y = 0

while inNum = gets
	inArr = inNum.split(',')
	inArr[0] = inArr[0].to_i
	break if (inArr[0] == 0 && inArr[1] == 0)

	x += inArr[0] * Math.cos(ang)
	y += inArr[0] * Math.sin(ang)
	
	ang += inArr[1].to_i * Math::PI / 180
end

puts y.to_i
puts x.to_i

Measured memory_bytes: 6164
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    print(sum(a_list)-n)

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  int sum = 0;
  string n;
  while(cin >> n && n != "0") {
    for(int i = 0; i < n.size(); i++) {
      sum += (n[i] - '0');
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod=1e9+7;

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

    long long ans=1;
    for(int i = 0; i < N; ++i) {
        ans*=(i+1);
        ans%=mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#coding:utf-8
#1_10_D 2015.4.14

def distance(p,vectorX,vectorY):
    d = sum([abs(vectorX[i] - vectorY[i]) ** p for i in range(len(vectorX))]) ** (1/p)
    return d

n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))
print('{:.10f}'.format(distance(1,x,y)))
print('{:.10f}'.format(distance(2,x,y)))
print('{:.10f}'.format(distance(3,x,y)))
print('{:.10f}'.format(max([abs(x[i] - y[i]) for i in range(len(x))])))

Measured memory_bytes: 6796
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<ll> tree;

void max_heap(ll i){
    ll l=i*2;
    ll r=i*2+1;
    ll largest=i;
    if(l<tree.size() && tree[l]>tree[i]){largest=l;}
    if(r<tree.size() && tree[r]>tree[largest]){largest=r;}
    if(largest!=i){
        swap(tree[i],tree[largest]);
        max_heap(largest);
    }
}

void build(){
    for(ll i=(tree.size()-1)/2;i>=1;i--){
        max_heap(i);
    }
}



int main(){
    ll h;
    cin>>h;
    tree.resize(h+1);
    for(int i=0;i<h;i++){
        cin>>tree[i+1];
    }
    build();
    for(int i=1;i<tree.size();i++){
        cout<<" "<<tree[i];
    }
    cout<<endl;
    
    
    return 0;
}




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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

const int N = 200;
const int V = 2e5;
const int M = 1e9 + 7;

typedef long long ll;

int n, k;

ll dp[N][V];

ll a[N];


int main() {
    cin >> n >> k;
    fore(i, 0, n) cin >> a[i];

    fore(j, 0, k + 1) dp[0][j] = 0;
    fore(i, 0, n + 1) dp[i][0] = 1;

    fore(i, 1, n + 1) {
        ll s[k + 2];
        s[0] = 0;
        fore(j, 1, k + 2) s[j] = s[j - 1] + dp[i - 1][j - 1];
        fore(j, 1, k + 1) {
            dp[i][j] = s[j + 1] - s[max(0ll, j - a[i - 1])];
            dp[i][j] %= M;
        }
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 157952
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	string s,t;
	ll n,hana=0,taro=0,i;
	char w;
	
	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>s>>t;
		if(s.compare(t)==0) hana++,taro++;
		  else if(s.compare(t)>0) hana+=3;
		    else taro+=3;
	}
	
	cout<<hana<<" "<<taro<<"\n";
}


Measured memory_bytes: 3152
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut a: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();

    let mut b = Vec::new();
    b.push(0);
    for i in 0..n {
        if i % 2 == 0 {
            b.push(a[i]);
        } else {
            b.push(24 - a[i]);
        }
    }

    let mut ans = 24;
    for i in 0..b.len() {
        for j in i + 1..b.len() {
            ans = min(ans, (b[i] - b[j]).abs());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
}
set<char> s;

int count_[5];

signed main() {
  int n;
  cin >> n;
  while (n--) {
    string name;
    cin >> name;
    char head = name.front();
    if (head == 'M') {
      count_[0]++;
    } else if (head == 'A') {
      count_[1]++;
    } else if (head == 'R') {
      count_[2]++;
    } else if (head == 'C') {
      count_[3]++;
    } else if (head == 'H') {
      count_[4]++;
    }
  }

  int ans = 0;

  for (int i = 0; i < 5; i++) {
    for (int p = i + 1; p < 5; p++) {
      for (int s = p + 1; s < 5; s++) {
        ans += count_[i] * count_[p] * count_[s];
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
	int N; cin >> N;
	int a[100];
	for(int i=0; i<N; ++i) cin >> a[i];
	int P=1000000000, S;
	for(int i=-100; i<101; ++i){
	    S=0;
	    for(int j=0; j<N; ++j){
	        S += (a[j]-i)*(a[j]-i);
	    }
	    P=min(P, S);
	}
	cout << P << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll left = 0, right = 0;
  ll toleft = 0, toright = 0;
  rep(i, N){
    if(S[i] == ')'){
      if(toright > 0){
	toright--;
      } else{
	toleft++;
      }
    } else{
      toright++;
    }
  }

  left = toleft;

  toleft = 0;
  toright = 0;

  rep_inv(i, N - 1, -1){
    if(S[i] == '('){
      if(toleft > 0){
	toleft--;
      } else{
	toright++;
      }
    } else{
      toleft++;
    }
  }

  right = toright;

  rep(i, left) cout << '(';
  cout << S;
  rep(i, right) cout << ')';

  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bl = [int(input()) for _ in range(n)]
bingo = [[False, False, False] for _ in range(3)]
for b in bl:
    for i in range(3):
        if b in a[i]:
            bingo[i][a[i].index(b)] = True
# print(*bingo, sep='\n')

# yoko
yoko = [all(i) for i in bingo]

# tate
for i in range(3):
    for j in range(3):
        if bingo[j][i] == False:
            break
    else:
        tate = True
        break
else:
    tate = False

# naname
naname1 = False
for i in range(3):
    if bingo[i][i] == False:
        break
else:
    naname1 = True

naname2 = False
for i in range(3):
    if bingo[i][2-i] == False:
        break
else:
    naname2 = True

if True in yoko or tate or naname1 or naname2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

vector<int> g[N];

void solve(int) {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    g[x - 1].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cout << g[i].size() << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 16872
import java.util.*;

public class Main{
	public static void main(String[]args){
		
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int a=n%10;
		int b=n/10;
		if(a==9 || b==9){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 3005;
f80 dp[N][2 * N];
f80 p[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n)
		cin >> p[i];
	dp[0][N] = 1;
	fr(i, 0, n - 1){
		fr(j, N - i, N + i){
			dp[i + 1][j + 1] += p[i + 1] * dp[i][j];
			dp[i + 1][j - 1] += (1 - p[i + 1]) * dp[i][j];
		}
	}
	f80 ans = 0;
	fr(j, 0, n){
		ans += dp[n][j + N];
	}
	cout << setprecision(15) << fixed << ans;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 280192
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
using namespace std;

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

long long A, B, C, X, Y;

int main() {
  cin >> A >> B >> C >> X >> Y;

  long long p = min(A+B,C*2);
  long long q = min(C*2, A);
  long long r = min(C*2, B);

  long long cost = 0;

  if(X >= Y) {
    cost = p * Y + q * (X - Y);
  } else {
    cost += p * X;
    cost += r * (Y - X);
  }

  cout << cost << endl;

  return 0;
}

Measured memory_bytes: 888
N,s,t = map(int,input().split())
Nod = []
print("?",s,t)
print(end = '',flush=True)
K = int(input())
for i in range(1,N+1):
    if i != s and i != t:
        print("?",s,i)
        print(end = '',flush=True)
        A = int(input())
        print("?",t,i)
        print(end = '',flush=True)
        B = int(input())
        if A+B == K:
            Nod.append([A,B,i])
Nod.sort()
ans = [s]
for a,b,c in Nod:
    ans.append(c)
print("!",end =" ")
for i in ans:
    print(i,end = " ")
print(t)


Measured memory_bytes: 5636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
long long w;
vector< long long > weight( 110 );
vector< int > value( 110 );
long long dp[ 100005 ][ 105 ];

long long solve( int v, int n )
{
	if( v < 0 )
	{
		return 1e15;
	}
	if( n == 0 )
	{
		if( v == 0 )
		{
			return 0;
		}
		else
		{
			return 1e15;
		}
	}
	if( dp[ v ][ n ] != -1 )
	{
		return dp[ v ][ n ];
	}
	dp[ v ][ n ] = min( weight[ n ] + solve( v - value[ n ], n - 1 ), solve( v, n - 1 ) );
	return dp[ v ][ n ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	cin >> n >> w;
	for( int i = 1; i <= n; ++i )
	{
		cin >> weight[ i ] >> value[ i ];		
	}
	for( int i = 100000; i >= 0; --i )
	{
		if( solve( i, n ) <= w )
		{
			cout << i << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 82304