akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int>a, pair<int,int>b) {
	if (a.first == b.first) {
		return a.second > b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vint a(m);
	rep(i, m) {
		cin >> a[i];
	}
	int now = 0;
	vllint table(n + 1, 0);
	table[0] = 1;
	rep(i, n) {
		if (now < m) {
			if (a[now] == i) {
				now++;
				continue;
			}
		}
		table[i + 1] += table[i];
		table[i + 1] %= 1000000007;
		if (i + 2 <= n) {
			table[i + 2] += table[i];
			table[i + 2] %= 1000000007;
		}
	}
	cout << table[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
import heapq
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
F = list(map(int, sys.stdin.readline().split()))

if N == 1:
    a = A[0]
    f = F[0]
    ans = max(a - K, 0) * f
    print(ans)
    exit()

A = np.array(A, dtype=int)
F = np.array(F, dtype=int)
A.sort()
F.sort()
F = F[::-1]


def required_k(score):
    # score を出すために必要な K
    return np.ceil(np.maximum(A - score / F, 0)).sum()


ok = (A * F).max()
ng = -1
while abs(ok - ng) > 1:
    score = (ok + ng) // 2
    if required_k(score) <= K:
        ok = score
    else:
        ng = score
print(ok)


Measured memory_bytes: 43572
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input_string = Console.ReadLine().Split();
            for(int i = 0; i < input_string[0].Length; i++)
            {
                Console.Write(input_string[0][i]);
                Console.Write(input_string[1][i]);
            }
        }
        
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int a[100002];
int main(){
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		int p;
		cin>>p;
		a[p]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]+k-q>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
} 

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

    int N;
    int t[110000], x[110000], y[110000];

    cin >> N;
    t[0] = x[0] = y[0] = 0;

    for(int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;

    for(int i = 0; i < N; i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if(dist%2 != dt %2) can = false;
    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

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

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    ll ans=0ll;
    repA(i,1,n)
    {
      ll val;
      cin>>val;
      if(val%2 && i%2) ans++;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

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 > 0) {
		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;
}

const int INF = 1000000000;

int n, a[20], b[20];
int d[(1 << 18)][55];
vector<int> vec;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	fill(d[0] + 1, d[0] + 51, INF);
	for (int i = 1; i < (1 << n); i++) {
		vec.clear();
		for (int j = 0; j <= 50; j++)d[i][j] = INF;
		for (int j = 0; j < n; j++)if (i&(1 << j))vec.push_back(j);
		int m = (int)vec.size();
		sort(all(vec));
		for (int j = 0; j < m; j++){
			int x = 0;
			if ((vec[j] - m) % 2)x = a[vec[j]];
			else x = b[vec[j]];
			int mi = INF;
			for (int k = 0; k <= x; k++)mi = min(mi, d[i - (1 << vec[j])][k]);
			d[i][x] = min(d[i][x], mi + m - j - 1);
		}
	}
	int ans = INF;
	for (int i = 0; i <= 50; i++)ans = min(ans, d[(1 << n) - 1][i]);
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 112896
'use strict'

function Main(input) {
  const S = input.split("\n")[0].split("")
  const T = input.split("\n")[1].split("")

  let ans = 0
  for(let i=0; i<3; i++) {
    if(S[i] === T[i]) {
      ans++
    }
  }
  console.log(ans)  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())


Measured memory_bytes: 21064
import math

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

alpha = (60*A[2]+A[3])/60*30
beta = 6*A[3]

temp = abs(alpha - beta)

if temp <=180:
    theta = temp
else:
    theta = 360 - temp

#print(theta)

temp2 = A[0]*A[0]+A[1]*A[1]-2*A[0]*A[1]*math.cos(theta/180*math.pi)

print(math.sqrt(temp2))

Measured memory_bytes: 9516
#include<stdio.h>
#include<math.h>
#include<string.h>
int max(int a,int b){
   if(a>b) return a;
   return b;
}
int min(int a,int b){
   if(a<b) return a;
   return b;
}
void sort(char *a,int l){
    for(int i=0;i<l;i++){
       for(int j=i+1;j<l;j++){
          char t;
         if(a[i]>a[j]) {
            t=a[i];
            a[i]=a[j];
            a[j]=t;
         }

       }
    }


}
void rot(char *a,int l){
     char t=a[0];
   for(int i=1;i<l-1;i++){
      a[i-1]=a[i];
   }
   a[l-1]=t;
}

int main(){
    char a[1000],b[1000];
    scanf("%s%s",a,b);
    int l=strlen(a),cnt=0;
   for(int i=0;i<l;i++){
      if(!strcmp(a,b)) {
         printf("Yes");
         return 0;
      }
    char t=a[0];
    for(int i=1;i<l;i++){
      a[i-1]=a[i];
     }
   a[l-1]=t;
}

   printf("No");
}
   
   
   
   
   
   

Measured memory_bytes: 128
#include <stdio.h>
int main(int argc, const char *argv[])
{
  int n, h, max_h = 0, count = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h);
    if (h >= max_h) {
      count++;
      max_h = h;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <stdlib.h>
#include <cmath>
using namespace std;

int d, c[29], s[409][29], p[409], ap[409], cp[29], rs;
set<int> st[29];

int cc()
{
	for (int i = 0; i < 26; i++)
		cp[i] = 0;
	int ans = 0;
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++) {
			if (p[i] == j) {
				cp[j] = i;
				ans += s[i][j];
			}
			else
				ans -= (i - cp[j]) * c[j];
		}
	}
	return ans;
}

void rm(int n, int k)
{
	auto pi = st[k].find(n);
	auto l = pi; l--;
	auto r = pi; r++;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].erase(n);
	rs -= s[n][k];
	rs += pl * (pl + 1) / 2 * c[k]; rs += pr * (pr + 1) / 2 * c[k];
	rs -= plr * (plr + 1) / 2 * c[k];
}

void ins(int n, int k)
{
	auto r = st[k].lower_bound(n);
	auto l = r; l--;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].insert(n);
	rs += s[n][k];
	rs -= pl * (pl + 1) / 2 * c[k]; rs -= pr * (pr + 1) / 2 * c[k];
	rs += plr * (plr + 1) / 2 * c[k];
}

void up(int n, int k)
{
	rm(n, p[n]);
	p[n] = k;
	ins(n, p[n]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> d;
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		st[i].insert(0); st[i].insert(d + 1);
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++)
			cin >> s[i][j];
		p[i] = rand() % 26;
		st[p[i]].insert(i);
	}
	rs = cc();
	double k = 1, sc = 3500, kt = 0.9997, mx = rs;
	for (int i = 0; i < 3000000; i++) {
		double e1 = rs;
		int n = (rand() % d) + 1, kp = (rand() % 25) + 1;
		int hk = p[n], tk = (hk + kp) % 26;
		up(n, tk);
		int e2 = rs;
		double pb = exp((e2 - e1) / (k * sc));
		if (pb < rand() / (double)RAND_MAX)
			up(n, hk);
		k *= kt;
		if (mx < rs) {
			mx = rs;
			for (int j = 1; j <= d; j++)
				ap[j] = p[j];
		}
	}
	for (int i = 1; i <= d; i++)
		cout << ap[i] + 1 << '\n';
	return 0;
}

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

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

using namespace std;

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

	vector<int> pos={-1};
	rep(i,n) if(s[i]=='0') pos.emplace_back(i);
	pos.emplace_back(n);

	vector<vector<int>> Ev(n); // right endpoint -> left endpoint
	for(int i=1;i<n-1;i++) if(s[i-1]=='1' && s[i]=='0' && s[i+1]=='1') {
		for(int x=i-1;x>=0&&s[x]=='1';x--) Ev[i+1].emplace_back(x);
		for(int x=i+2;x< n&&s[x]=='1';x++) Ev[x].emplace_back(i-1);
	}

	vector<int> dp(n+1);
	rep(x,n){
		dp[x+1]=dp[x];
		for(int l:Ev[x]){
			dp[x+1]=max(dp[x+1],dp[l]+x-l-1);
		}
	}
	cout<<dp[n]<<'\n';

	return 0;
}


Measured memory_bytes: 35644
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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


int main(void) {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int num = 0;
	cin >> num; cin.ignore();

 	vector<int> input(num);

	for(int i = 0; i < num; i++) {
		cin >> input[i];
	}

	vector<int> L(num, 0);
	for(int i = 0; i < num; i++) {
		if(i!=0)L[i] = gcd(L[i-1],input[i]);
		else L[i] = input[i];
	}

	vector<int> R(num, 0);
	for( int i = num - 1; i >= 0; --i ) {
        if( i != num - 1 ) R[i] = gcd( R[i + 1], input[i] );
		else R[i] = input[i];
	}

    int ans = R[1];
    for( int i = 1; i < num - 1; ++i ) {
        ans = max( gcd( L[i - 1], R[i + 1] ), ans );
 
    }
	ans = max( ans, L[num - 2] );
	cout << ans;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while(A>0 && B>0) {
        C -= B;
        if(C<=0) {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A<=0) {
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

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

	if (a < 6) {
		cout << 0 << endl;
	}
	else if (a < 13) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b;
    cin >> a >> b;
    cout << (b % a ? b - a : a + b) << endl;
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut coord = Vec::with_capacity(n);
	for i in 0..n {
		let x: i64 = s.next().unwrap().parse().unwrap();
		let y: i64 = s.next().unwrap().parse().unwrap();
		coord.push((x, y, i as u32));
	}
	let mut graph = Graph::new(n);
	coord.sort_by_key(|a| a.0);
	for w in coord.windows(2) {
		let a = w[0];
		let b = w[1];
		let d = b.0 - a.0;
		graph.add_edge(a.2 as usize, b.2 as usize, d);
		graph.add_edge(b.2 as usize, a.2 as usize, d);
	}
	coord.sort_by_key(|a| a.1);
	for w in coord.windows(2) {
		let a = w[0];
		let b = w[1];
		let d = b.1 - a.1;
		graph.add_edge(a.2 as usize, b.2 as usize, d);
		graph.add_edge(b.2 as usize, a.2 as usize, d);
	}
	println!("{}", graph.prim());
}

pub mod mst {
	use super::*;

	impl<T> Graph<T>
	where
		T: Clone + Ord + num::Zero,
	{
		pub fn prim(&self) -> T {
			let mut r = T::zero();
			let mut used = vec![false; self.size()];
			let mut q = std::collections::BinaryHeap::new();
			use std::cmp::Reverse;
			q.push((Reverse(T::zero()), 0));
			while let Some((Reverse(cost), v)) = q.pop() {
				let v = v as usize;
				if used[v] {
					continue;
				}
				used[v] = true;
				r = r + cost;
				for Edge { dst, cost, .. } in self.edges[v].iter() {
					q.push((Reverse(cost.clone()), *dst));
				}
			}
			r
		}
	}
}

#[derive(Clone, Copy)]
pub struct Edge<T> {
	dst: u32,
	cost: T,
}

impl<T> Edge<T> {
	pub fn new(dst: u32, cost: T) -> Self {
		Self { dst, cost }
	}
}

pub struct Graph<T> {
	edges: Vec<Vec<Edge<T>>>,
}

impl<T> Graph<T>
where
	T: Clone,
{
	pub fn new(n: usize) -> Self {
		Self {
			edges: vec![vec![]; n],
		}
	}

	pub fn size(&self) -> usize {
		self.edges.len()
	}

	pub fn add_edge(&mut self, src: usize, dst: usize, cost: T) {
		self.edges[src].push(Edge {
			dst: dst as u32,
			cost,
		});
	}
}


Measured memory_bytes: 21404
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;cin>>n>>k;
	vector<int> h(n,0);
	vector<int> dp(n+1,0);
	for(int i=0;i<n;i++)	cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	//~ dp[2]=min(dp[1]+abs(h[2]-h[1]),abs(h[2]-h[0]));
	
	if(n==2)	{cout<<abs(h[1]-h[0])<<endl;return 0;}
	
	for(int i=2;i<n;i++)
	{
		int mini=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)	mini=min(dp[i-j]+abs(h[i]-h[i-j]),mini);
		}
		dp[i]=mini;
	}
	
 
	cout<<dp[n-1]<<endl;
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    int n = s.size();
    cout<<s;
    if(s[n-1]=='s') cout << "es" << endl;
    else cout << "s" << endl;

    return 0;
}

Measured memory_bytes: 3644
from itertools import product
from collections import Counter
N, A, B, C = map(int, input().split())
h = {1: A, 2: B, 3: C}
l = [int(input()) for i in range(N)]
ans = float('inf')
for p in product([0, 1, 2, 3], repeat=N):
    c = Counter(p)
    if c[1] == 0 or c[2] == 0 or c[3] == 0:
        continue
    t = {1: 0, 2: 0, 3: 0}
    for i, v in enumerate(p):
        if v == 0:
            continue
        t[v] += l[i]
    mp = 0
    for i in range(1, 4):
        if c[i] >= 2:
            mp += (c[i] - 1) * 10
        mp += abs(h[i] - t[i])
    ans = min(ans, mp)
print(ans)

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

int h, w, c, Max;
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
vector<vector<int>>a;
void mark(int x, int y, int b, int c) {
	a[x][y] = c;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&a[nx][ny] == b)mark(nx, ny, b, c);
	}
}
int cnt = 0;
void dfs(int t) {
	if (t == 0) {
		rep(i, h)rep(j, w) {
			int d = a[i][j];
			if (d != c)continue;
			mark(i, j, d, 10);
			int cnt = 0;
			rep(l, h)rep(k, w)if (a[l][k] == 10)Max = max(Max, ++cnt);
			mark(i, j, 10, d);
		}
		return;
	}
	vector<vector<int>>b = a;
	rep(i, 6) {
		if (a[0][0] == i)continue;
		mark(0, 0, a[0][0], i);
		dfs(t - 1); a = b;
	}
}
int main() {
	while (scanf("%d%d%d", &h, &w, &c), h) {
		a = vector<vector<int>>(h, vector<int>(w)); c--;
		rep(i, h)rep(j, w)scanf("%d", &a[i][j]), a[i][j]--;
		Max = 0; dfs(5);
		printf("%d\n", Max);
	}
}

Measured memory_bytes: 3252
import java.util.Scanner

object Main {

  def solve(sc: Scanner): String = {
    val n = sc.nextInt()
    val ds = Vector.fill(n)(sc.nextInt()).sorted

    val (_lows, _highs) = ds.zipWithIndex.partition { case (_, i) => i < n / 2 }
    val lows = _lows.map(_._1)
    val highs = _highs.map(_._1)
    (highs.head - lows.last).toString
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 59352
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int x; cin >>x; cout <<1-x;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3636
N,M = map(int, input().split())
inp = []
for i in range(M):
    a,b,c = map(int,input().split())
    inp.append( (a-1, b-1, c) )

inf = float("inf")
dist  =  [[inf] * N for _ in range(N)]

for i in range(M):
    dist[inp[i][0]][inp[i][1]] = inp[i][2]
    dist[inp[i][1]][inp[i][0]] = inp[i][2]

for mid in range(N):
    for start in range(N):
        for end in range(N):
            dist[start][end] = min(dist[start][end],
                    dist[start][mid] + dist[mid][end])


ans = 0
for ai,bi,ci in inp:
    if dist[ai][bi] != ci:
        ans += 1

print(ans)



Measured memory_bytes: 46700
def gcd(a, b):
   while True:
       x = a % b
       if x==0:
           return b
       else:
           a = b
           b = x

def lcm(a, b):
    gcd_ab = gcd(a, b)
    ans = a * b // gcd_ab
    return ans

A,B,C,D = (int(x) for x in input().split())
lcmCD = lcm(C, D)
A -= 1
ans = B - A
anstmp = B // C
anstmp -= A // C
ans -= anstmp
anstmp = B // D
anstmp -= A // D
ans -= anstmp
anstmp = B // lcmCD
anstmp -= A // lcmCD
ans += anstmp
print('%d' % ans)

Measured memory_bytes: 3064
n = int(input())
a = map(int, input().split())
a = sorted(a)
count = 0
for i in range(len(a)):
    if i==0 or i==1:
        count += a[i] / 2**(len(a)-1)
    else:
        count += a[i] / 2**(len(a)-i)
print(count)


Measured memory_bytes: 2940
s = input()
t = input()

s_list = [i for i in s]
t_list = [i for i in t]
s_list.sort()
t_list.sort()
t_list.reverse()
s = ''.join(s_list)
t = ''.join(t_list)

if s < t:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 8872
/**
  *  Worg
  */
#include <vector>
#include <iostream>
#include <algorithm>

int main() {
	//  Toate starile care au valori mai mici decat a[1] sunt pierzatoare.
	//  Daca prin recurenta ajungem la macar o stare care este pierzatoare, atunci starea curenta este castigatoare.
	//  Daca nu ajungem la nicio astfel de stare, atunci starea curenta este pierzatoare.
	int n, k; std::cin >> n >> k;
	std::vector<int> a(n);
	for (auto& x: a) {
		std::cin >> x;
	}


	std::vector<bool> winnable(k + 1, false);
	for (int i = 0; i <= k; i++) {
		for (auto& x: a) {
			if (i - x >= 0 && !winnable[i - x]) {
				winnable[i] = true;
			}
		}
	}

	if (winnable[k]) {
		std::cout << "First\n";
	} else {
		std::cout << "Second\n";
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vi A(n);
	take(A,0,n);
	vi B(n);
	int X=0;
	for(int i=1;i<n;i++)
	{
		X^=(A[i]^A[0]);
	}

	for(int i=0;i<n;i++)
	{
		B[i]=A[i]^X;
	}
	prin(B);
}		

Measured memory_bytes: 5308
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,X;cin>>N>>X;
	int m; int t = inf;
	rep(i,0,N){
		cin>>m;
		X -= m;
		t = min(t,m);
	}cout<<N + X/t<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_d

"""
import sys
from sys import stdin
from math import ceil, floor
input = stdin.readline


def create_prime_list(limit):
    """ エラトステネスの篩でlimitまでの素数リストを求める
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    #print('x={0}'.format(x))
    nums = [x for x in range(2, limit+1)]
    while nums[0]<=x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x%current_prime != 0]
    primes.extend(nums)
    return primes



def solve(queries):
    primes = set(create_prime_list(10**5))
    dp = [0] * (100000 + 1)

    p_num = 0
    for i in range(1, 100000, 2):
        if i in primes and ((i+1)//2) in primes:
            p_num += 1
        dp[i] = p_num

    for l, r in queries:
        if l == 1:
            ans = dp[r]
        else:
            ans = dp[r] - dp[l-2]
        print(ans)



def main(args):
    queries = []
    Q = int(input())
    # Q = 0
    # for _ in range(100000):
    #     queries.append((1, 99999))
    for _ in range(Q):
        l, r = map(int, input().split())
        queries.append((l, r))

    solve(queries)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){
  for(int i = 1;i < 10;i++){
    for(int j = 1;j < 10;j++){
      printf("%dx%d=%d\n",i,j,i*j);
    }
  }
  return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dp[100010][13];
int main() {
	string s;
	cin>>s;
	dp[0][0]=1;
	for(ll i=0;i<s.size();i++){
		char now=s[i];
		if(now=='?'){
			for(ll j=0;j<=9;j++){
				for(ll k=0;k<=12;k++){
					dp[i+1][(k*10+j)%13]+=dp[i][k];
					dp[i+1][(k*10+j)%13]%=inf;
				}
			}
			//for(ll k=0;k<=s.size();k++){
			//	for(ll j=0;j<=12;j++){
			//		cout << dp[k][j]<< " ";
			//	}
			//	cout <<endl;
			//}
		}
		else{
			ll num=now-'0';
			for(ll k=0;k<=12;k++){
				dp[i+1][(k*10+num)%13]+=dp[i][k];
				dp[i+1][(k*10+num)%13]%=inf;
			}
		}
	}
	cout << dp[s.size()][5]%inf;
	// your code goes here
	return 0;
}

Measured memory_bytes: 10752
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var l = G();
		int N = l[0], K = l[1];
		l = G();
		Array.Sort(l, (x, y) => y.CompareTo(x));
		WriteLine(l.Take(K).Sum());
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

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

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           int((x).size())
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T>
T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b != 0) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
// @formatter:on


class APainting {
public:
  
  void solveOne(istream& cin, ostream& cout) {
  
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n, h, w;
    cin >> h >> w >> n;
    if (h > w) swap(h, w);
    // w >= H
    cout << (n / w + (n % w != 0)) << '\n';
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	APainting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
v = []
for i in range(n+1):
    v.append([])

colorv = [None] * (n+1)

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

for cur in range(1, n+1):

    #print("cur", cur)

    used = dict()

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is None:
            continue
        #print(" line", linenum, "is", colorv[linenum])
        used[colorv[linenum]] = True

    ncolor = 1

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is not None:
            continue
        while ncolor in used:
            ncolor += 1
        colorv[linenum] = ncolor
        #print(" set line", linenum, "is", ncolor)
        used[ncolor] = True

print(max(colorv[:-2]))
for i in range(n-1):
    print(colorv[i])

Measured memory_bytes: 106036
#include<bits/stdc++.h>
using namespace std;
long long a,b,x;
long long s,e;
int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin>>a>>b>>x;
    if(a%x==0)s=a/x;
    else s=a/x+1;
    e=b/x;
    cout<<e-s+1<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        int evenCount = 0;
        int oddCount = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            if (a % 2 == 0) {
                evenCount++;
            } else {
                oddCount++;
            }
        }
        sc.close();

        // 主処理
        long result = 0;
        if (p == 0) {
            for (int i = 0; i <= n; i++) {
                long count = combination(evenCount, i);
                result += count;
                for (int j = 2; j <= n; j += 2) {
                    result += count * combination(oddCount, j);
                }
            }
        } else {
            for (int i = 0; i <= n; i++) {
                long count = combination(evenCount, i);
                for (int j = 1; j <= n; j += 2) {
                    result += count * combination(oddCount, j);
                }
            }
        }

        // 出力
        System.out.println(result);
    }

    public static long combination(int n, int m) {
        if (n < m || m < 0) {
            return 0;
        }
        long c = 1;
        m = (n - m < m ? n - m : m);
        for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
            c *= ns;
            c /= ms;
        }
        return c;
    }
}


Measured memory_bytes: 35760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin>>q;
  for(int j=0;j<q;j++){
    int a[4];
    for(int i=0;i<3;i++)cin>>a[i];
    int temp=min(a[0],min(a[1],a[2]));
    for(int i=0;i<3;i++){
      a[i]-=temp;
    }
    int temp2=min(a[0]/2,a[1]);
    a[0]-=temp2*2;
    a[1]-=temp2;
    cout<<temp+temp2+a[0]/3<<endl;
  }
  return(0);
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define MAX 500000
#define INF 1e9

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0;i<n1;i++) L[i] = A[left + i];
    for(int i=0;i<n2;i++) R[i] = A[mid + i];
    L[n1] = R[n2] = INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k] = L[i++];
        }
        else A[k] = R[j++];
    }
}

void mergeSort(int A[],int n,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int main(){
    int A[MAX],n;
    cnt = 0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    mergeSort(A,n,0,n);
    for(int i=0;i<n;i++){
        cout<<A[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 7012
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<vector<int>> T(N);
    REP(i, N-1){
        int a,b;
        cin >> a >> b;
        T[--a].pb(--b);
        T[b].pb(a);
    }
    vector<int> c(N);
    ll total = 0;
    for (int i = 0; i < N; i++) {
        cin >> c[i];
        total += c[i];
    }

    RSORT(c);
    total -= c.front();

    queue<int> q;
    vector<bool> ok(N);
    vector<int> ans(N);
    int id = 0;
    q.push(0);
    while(!q.empty()){
        auto f = q.front();q.pop();
        ans[f] = c[id++]; 
        ok[f] = true;
        for(auto&& ci : T[f]){
            if(ok[ci])continue;
            q.push(ci);
        }
    }

    pr(total);
    for(auto&& i : ans) pr(i);
}

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

int N;
long long s[100000];


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    long long ans = 0;
    for(int d = 1; d < N - 1; d++){ // d = A - B
        long long tmp_score = 0;
        for(int k = 1; N - 1 - k * d > d; k++){
            if((N - 1) % d == 0 && (N - 1 - k * d) <= k * d){
                continue;
            }
            tmp_score += s[k * d] + s[N - 1 - k * d];
            ans = max(ans, tmp_score);
        }
    }
    cout << ans << endl;
        

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 1000000000
#define mod 1000000007
#define vi vector <int>
#define vll vector<long long>
#define ii pair<int,int>
#define vii vector<pair<int,int>>
#define ll long long 
#define ld long double
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
/*struct item{
    int m,c;
};					// change item according to the question;
struct segtree{
	int size;
	vector<item>values;
	void intit(int n){
		size=1;
		while(size<n)size*=2;
		values.resize(2*size);
	}
    item merge(item a,item b){
        if(a.m<b.m)return a;
        if(b.m<a.m)return b;
        if(a.m==b.m)return {a.m,a.c+b.c}; 
    }
    item single(int v){
        return {v,1};
    }
    item NEUTRAL_ELEMENT={INF,1};
    void build(vi &a,int x,int lx,int rx){
        if(rx-lx==1){
            if(lx<sz(a)){
                values[x]=single(a[lx]);
            }
            return;
        }
        int m=(lx+rx)/2;
        build(a,2*x+1,lx,m);
        build(a,2*x+2,m,rx);
        values[x]=merge(values[2*x+1],values[2*x+2]);
    }
    void build(vi &a){
        build(a,0,0,size);
    }
    void set(int i,int v,int x,int lx,int rx){
        if(rx-lx==1){
            values[x]=single(v);
            return;
        }
        int m=(lx+rx)/2;
        if(i<m){
            set(i,v,2*x+1,lx,m);
        }else{
            set(i,v,2*x+2,m,rx);
        }
        values[x]=merge(values[2*x+1],values[2*x+2]);
    }
    void set(int i,int v){
        set(i,v,0,0,size);
    }
    item calc(int l,int r,int x,int lx,int rx){
        if(lx>=r||rx<=l)return NEUTRAL_ELEMENT;
        if(l<=lx && rx<=r)return values[x];
        int m=(lx+rx)/2;
        item s1=calc(l,r,2*x+1,lx,m);
        item s2=calc(l,r,2*x+2,m,rx);
        return merge(s1,s2);
    }
    item calc(int l,int r){
        return calc(l,r,0,0,size);
    }
};*/
int main(){
	int n,d;
    cin>>n>>d;
    ld x[n],y[n],cnt=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        ld c=sqrt(x[i]*x[i]+y[i]*y[i]);
        if(c<=d)cnt++;
    }
    cout<<cnt;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2001;
const int INF=1e9+10;

int h,w,ans;
bool p[maxn][maxn],a[maxn][maxn];
char c[maxn];
int height[maxn][maxn];
int l[maxn][maxn],r[maxn][maxn];

int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",c+1);
		for(int j=1;j<=w;j++)
			if (c[j]=='#') p[i][j]=true; else p[i][j]=false;
	}
	
	for(int i=1;i<h;i++)
		for(int j=1;j<w;j++)
			a[i][j]=!(p[i][j]^p[i][j+1]^p[i+1][j]^p[i+1][j+1]);
	
	for(int i=1;i<h;i++)
		for(int j=1;j<w;j++)
			height[i][j]=a[i][j]?height[i-1][j]+1:0;
	
	for(int i=1;i<w;i++) l[0][i]=r[0][i]=INF;
	for(int i=1;i<h;i++)
	{
		int last=0;
		for(int j=1;j<w;j++)
		{
			if (a[i][j]) l[i][j]=min(l[i-1][j],j-last);
			else
			{
				last=j;
				l[i][j]=INF;
			}
		}
		
		last=w;
		for(int j=w-1;j>=1;j--)
		{
			if (a[i][j]) r[i][j]=min(r[i-1][j],last-j);
			else
			{
				last=j;
				r[i][j]=INF;
			}
		}
	}
	
	ans=max(w,h);
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
			if (a[i][j]) ans=max(ans,(height[i][j]+1)*(l[i][j]+r[i][j]));
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 54912
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    String ans = "";
    for(int i = 0; i < n; i++) {
      String s1 = String.valueOf(s.charAt(i));
      String s2 = String.valueOf(t.charAt(i));
      ans += s1;
      ans += s2;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int MAXN=1e5+10;
const ll mod=1e9+7;
ll f[MAXN],inv[MAXN],ans,x,s[MAXN];
int n;
ll poww(ll x,ll y)
{
	ll ans=1;
	for (;y;y>>=1,x=(x*x)%mod) if (y&1) ans=(ans*x)%mod;
	return ans;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&x); s[i]=(s[i-1]+x)%mod;
	}
	for (int i=1;i<=n;i++) f[i]=(f[i-1]+s[i])%mod;
	ll fac=1;
	for (int i=1;i<=n;i++) fac=(fac*(ll)i)%mod;
	for (int i=1;i<=n+3;i++) inv[i]=poww((ll)i,mod-2);
	for (int i=1;i<n;i++) 
	{
		ans=(ans+(s[i])%mod*inv[i+1]%mod*fac%mod)%mod;
		ans=(ans+(s[n]-s[n-i]+mod)%mod*inv[i+1]%mod*fac%mod)%mod;
		if (i+1<=n-1) {
			ans=(ans+((f[n-1]-f[i]-f[n-i-1])%mod+mod)%mod*2%mod*inv[i+1]%mod*inv[i+2]%mod*fac%mod)%mod;
		}
	}
	ans=(ans+(s[n]+mod)%mod*fac%mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
x1,y1,x2,y2=map(int,input().split())
X = x2 - x1
Y = y2 - y1
x3 = x2 - Y
y3 = y2 + X
x4 = x1 - Y
y4 = y1 + X
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int L,R;
 
int main() {
  cin >> L >> R;
 
  if(R-L > 2019) { puts("0"); return 0; } 
 
  L %= 2019;
  R %= 2019;
 
  if(L >= R) { puts("0"); return 0; }
 
  int ans = 2019;
  for(int i=L; i<=R; i++) for(int j=i+1; j<=R; j++) {
    ans = min(ans, (i*j)%2019);
  }
  cout << ans << endl;
  return 0;
}

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

int n,f=0;

int main()
{
 cin >> n;
 for(int i=1;i<=9;i++)
  if(n%i==0&&n/i>=1&&n/i<=9) f=1;
 if(f==1) cout << "Yes" << endl;
 else cout  << "No" << endl;
 return 0;
}

Measured memory_bytes: 256
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in xrange(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            else:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        else:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,raw_input().strip().split())
ices = []
while True:
    ice = int(raw_input().strip())
    ices.append(ice)
    if len(ices) == N:
        break

orderN(N,L,ices)

Measured memory_bytes: 12508
#include<iostream>

using namespace::std;

int ar[200005],b[200005];

int main(){
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>ar[i];
	// for(int i=0;i<n;cout<<'\n',i++)
	// 	for(int j=0;j<n;j++)
	// 		cout<<(ar[i]^ar[j])<<' ';
	for(int i=0;i<n;i+=2)
		ans^=ar[i]^ar[(i-1+n)%n];
	b[0]=ar[0]^ans;
	for(int i=1;i<n;i++)
		b[i]=ar[i]^ar[0]^b[0];
	for(int i=0;i<n;i++)
		cout<<b[i]<<' ';
	cout<<'\n';
}

Measured memory_bytes: 5148
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    cout << a[2] * 10 + a[1] + a[0] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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


int main() {
	int n,j,i,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int& x:a)
	{
	    scanf("%d",&x);
	}
	
	vector<bool>dp(k+1);
	for(i=0;i<k+1;++i)
	{
	    for(int x : a)
	{
	    if(i>=x  &&  !dp[i-x])
	    dp[i] = true;
	}
	}
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second";
	return 0;
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    ll ans = INF;
    REP(i, 1 << n){
        if(__builtin_popcount(i) != k) continue;
        
        
        ll t = 0, s = 0;
        REP(j, n){
            if(i & (1 << (n - 1 - j))){
                if(t < a[j]){
                    t = a[j];
                }
                else{
                    s += t - a[j] + 1;
                    t = t + 1;
                }
            }
            else{
                t = max(t, a[j]);
            }
        }
        
        ans = min(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256