akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//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")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:i32,p:[i32;N]);
    let mut p:Vec<i32> = p;
    p.sort();
    print!("{}",p.iter().sum::<i32>() - p.last().unwrap() + p.last().unwrap()/2);
}

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

int main(){
  int n,count=0;
  cin >> n;
  vector<int> data(n+1);
  vector<int> map(n+1);
  for(int i=1; i<=n; i++){
    cin >> data.at(i);
  }
  
  for(int i=n; i>0; i--){
    int tmp=0;
    for(int j=i; j<=n; j += i){
      tmp += map.at(j);
    }
    if(tmp%2 != data.at(i)) {
      count++;
      map.at(i)++;
    }
  }
  
  cout << count << endl;
  for(int i=1; i<=n; i++){
    if(map.at(i) == 1){
      cout << i << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		while(N < 2 || 200 < N){
			System.out.println("2から200までの数を入力してください。");
			N = sc.nextInt();
		}
		int[][] num = new int[N][3];
		int[] point = new int[N];
		int ptswt = 0;
		for(int i = 0; i < N; i++){
			point[i] = 0;
		}
		for(int i = 0; i < N; i++){
			num[i][0] = sc.nextInt();
			while(num[i][0] < 1 || 100 < num[i][0]){
				System.out.println("1から100までの数を入力してください。");
				num[i][0] = sc.nextInt();
			}
			num[i][1] = sc.nextInt();
			while(num[i][1] < 1 || 100 < num[i][1]){
				System.out.println("1から100までの数を入力してください。");
				num[i][1] = sc.nextInt();
			}
			num[i][2] = sc.nextInt();
			while(num[i][2] < 1 || 100 < num[i][2]){
				System.out.println("1から100までの数を入力してください。");
				num[i][2] = sc.nextInt();
			}
		}
		for(int j = 0; j < N; j++){ //参照するプレイヤー
			for(int i = 0; i < 3; i ++){ //ゲームの回数
				ptswt = 1;
				for(int k = 0; k < N; k++){ //その他のプレイヤー
					if(j != k){
						if(num[j][i] == num[k][i]){
							ptswt = 0;break;
						}
					}
				}
				if(ptswt == 1){
					point[j] += num[j][i];
				}
			}
		}
		for(int i = 0; i < N; i++){
			System.out.println(point[i]);
		}
		return;
	}
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(-a+b<=0) cout << "delicious" << endl;
    else if(-a+b<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}


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

using namespace std;

#define M 16777216 // 4^12
#define L 14

int H[M][L] = { 0 };

int getChar(char ch) {
	if (ch == 'A') return 0;
	else if (ch == 'C') return 1;
	else if (ch == 'G') return 2;
	else if (ch == 'T') return 3;
}

/* convert a string into an integer value */
long long getKey(string str) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < str.size(); i++) {
		sum += p * (getChar(str[i]));
		p *= 4;
	}
	return sum;
}

int find(string str) 
{
	return H[getKey(str)][str.size()];
}

int insert(string str) 
{
	return ++H[getKey(str)][str.size()];
}

int main() {
	int i, n;
	string str, cmd;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> cmd >> str;
		if (cmd == "insert") {
			insert(str);
		}
		else if (cmd == "find")
		{
			if (find(str)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 60548
n,x=map(int,input().split())
a=list(map(int,input().split()))
cnt=max(a[0]-x,0)
a[0]=min(a[0],x)
for i in range(n-1):
    p,q=a[i:i+2]
    if p+q>x:
        cnt+=p+q-x
        a[i+1]=x-p
print(cnt)

Measured memory_bytes: 14252
#include <stdio.h>
int main(void)
{
    int k,s;
    scanf("%d%d", &k, &s);
    int x,y,z,ans=0;
    for(z=0; z<=k; z++)
    {
        if(2*k<s-z) ans+=0;
        else
        {
            if(s-z<0) ans+=0;
            else if(k>=s-z) ans+=s-z+1;
            else ans+=2*k-s+z+1;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
AB = [() for i in range(N)]
for i in range(N):
    A, B = map(int, input().split())
    AB[i] = (A, B)
AB.sort()
ans = 0
drink_num = 0
for i in range(N):
    A, B = AB[i]
    if drink_num + B >= M:
        ans += A * (M - drink_num)
        drink_num += (M - B)
        break
    else:
        ans += A * B
        drink_num += B
print(ans)

Measured memory_bytes: 16904
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int MAX = 303030;
const ll MOD = 1000000007;
const ll mod = MOD;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};

ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	ll N, K;
	cin >> N >> K;
	combinit();
	vector<ll>A(N);
	map<ll, ll>mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]]++;
	}
	sort(all(A));


	mint ans = 0;
	//minについて
	set<ll>smin;
	ll cursum = 0;
	for (int i = 0; i < N; i++) {
		if (smin.count(A[i]))continue;
		mint temp = comb(N - cursum, K) - comb(N - cursum - mp[A[i]], K) + 3LL*mod;
		temp *= A[i] + mod;
		ans -= temp;

		smin.insert(A[i]);
		cursum += mp[A[i]];
	}

	set<ll>smax;
	cursum = 0;
	reverse(all(A));
	for (int i = 0; i < N; i++) {
		if (smax.count(A[i]))continue;
		mint temp = comb(N - cursum, K) - comb(N - cursum - mp[A[i]], K) + 3LL*mod;
		temp *= A[i] + mod;
		ans += temp;

		smax.insert(A[i]);
		cursum += mp[A[i]];
	}
	puts(ans.x);



	return 0;
}

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

using namespace std;

typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

int main(){
    int n;
    cin >> n;
    rep(p, n){
        vector<pair<string, int>> v;
        vector<int> a(9);
        vector<string> b(9);
        rep(i, 9) cin >> a[i];
        rep(i, 9) cin >> b[i];
        rep(i, 9) v.push_back(make_pair(b[i], a[i]));
        sort(all(v));

        bool possible = false;
        do{
            vector<pair<string, int>> vv = v;
            while(true){
                bool is = false;
                if(v[0] == v[1] && v[1] == v[2]){vector<pair<string, int>> t; rep(i, v.size()-3) t.push_back(v[i+3]); v=t; is = true;}
                if(v.size() == 0) break;
                if(v[0].first == v[1].first && v[1].first == v[2].first && v[0].second == v[1].second-1 && v[1].second == v[2].second-1){vector<pair<string, int>> t; rep(i, v.size()-3) t.push_back(v[i+3]); v=t; is = true;}
                if(!is || v.size() == 0) break;
            }
            if(v.size() == 0){possible = true; break;}
            v = vv;
        }while(next_permutation(all(v)));
        cout << (possible?"1":"0") << endl;
    }
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		 Scanner sc=new Scanner(System.in);  
	
		 String S = sc.next();

		


			 if(S.equals("Sunny")) {
				 System.out.println("Cloudy");
			 }
			 else if(S.equals("Cloudy"))
					 System.out.println("Rainy");
			 else if(S.equals("Rainy"))
				 System.out.println("Sunny");


			 

		 }
	}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1e5+5;
int dp[N][13];char s[N];
int main()
{
	scanf("%s",s);
	dp[0][0]=1;int l=strlen(s);
	for(int i=0;i<l;i++)
		for(int j=0;j<13;j++)
			if(s[i]=='?')
				for(int k=0;k<=9;k++)(dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;else
				(dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j])%=mod;
	printf("%d\n",dp[l][5]);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

const ll mod = 1e9+7;

int main()
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll mn=((i-1)*(i)/2);
        ll ma=((n+n-i+1)*(i)/2);
        ans=(ans+ma-mn+1)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typedef vector<pair<ll, ll>> vpl;
typedef pair<ll, ll> pl;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
bool dp[100010];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin >> n >> k;
	vl a(n);
	For(i, n) cin >> a[i];
	for (ll i = 1; i <= k; i++) {
		bool fl = false;
		For(j, n) {
			if (a[j] <= i && !dp[i - a[j]]) {
				fl = true;
			}
		}
		dp[i] = fl;
	}
	if (dp[k]) {
		cout << "First";
	}
	else {
		cout << "Second";
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  vector<string> S(N), T(N), U(N);
  rep(i, N) cin >> S.at(i) >> P.at(i);
  rep(i, N) T.at(i)=S.at(i)+to_string(999-P.at(i));
  rep(i, N) U.at(i)=T.at(i);
  sort(T.begin(), T.end());
  rep(i, N){
    rep(j, N){
      if(T.at(i)==U.at(j)) cout << j+1 << endl;
    }
  }
}

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

using namespace std;

int main()
{
    int x,n;
    cin>>x>>n;
    int sum=0;
    for (int i=0;i<n;i++)
    {
        int h;
        cin>>h;
        sum+=h;
    }
    if (sum>=x)cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    long long r = 0, g = 0, b = 0;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            r++;
        else if (s[i] == 'G')
            g++;
        else if(s[i] == 'B')
            b++;
    }

    sum = r * g * b;

    for (int i = 0; i < n; i++)
    {
        for (int k = i + 1; k < n; k++)
        {
            if ((i + k + 2) % 2 == 0)
            {
                int j = (i + k + 2) / 2 - 1;

                if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i] && i < j && j < k)
                {
                    sum--;
                }
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    deque<char> c;
    rep(i,s.length())c.push_back(s[i]);
    int q;
    cin >> q;
    ll memo = 0;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){//t=1のとき
            //reverse(c.begin(),c.end());
            memo++;
        }else{
            int f = 0;
            cin >> f;
            if(f == 1){
                char ch;
                cin >> ch;
                if(memo%2 == 0)c.push_front(ch);
                else c.push_back(ch);
            }else{
                char ch;
                cin >> ch;
                if(memo%2 == 1)c.push_front(ch);
                else c.push_back(ch);
            }
        }
    }
    if(memo%2 != 0)reverse(c.begin(),c.end());
    rep(i,c.size())cout << c[i];
    cout << "\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 976
#include <cstdint>
#include <iostream>

using namespace std;

int main()
{
    int64_t wanted;
    cin >> wanted;

    auto moves = 2 * (wanted / 11);
    wanted %= 11;

    if (wanted > 0) {
        moves += 1;
    }
    if (wanted > 6) {
        moves += 1;
    }

    cout << moves << "\n";
    return 0;
}



Measured memory_bytes: 256
($H,$W)=glob<>;
$%=1e16;
for(1,2){
	$t=($H/3|0);
	for($t-1,$t,$t+1){
		if($_>0){
			@_=sort{$a-$b}$_*$W,($H-$_)*($W>>1),($H-$_)*($W-($W>>1));
			$%-=$-=$%-($_[2]-$_[0]);
			@_=sort{$a-$b}$_*$W,($H-$_>>1)*$W,($H-$_-($H-$_>>1))*$W;
			$%-=$-=$%-($_[2]-$_[0]);
		}
	}
	($H,$W)=($W,$H);
}
print$%,$/


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
long long w,h,s,a,b,c,d,e,ans=1e10;
int main()
{
	cin>>h>>w;
	if(h%3==0||w%3==0)
	{cout<<0;return 0;}
	for(int i=1;i<=h/2;i++)
	{
		a=w*i;b=(h-i)*(w/2);c=w*h-a-b;
		s=max(max(a,b),c)-min(min(a,b),c);
		ans=min(ans,s);
		d=(h-i)/2*w;e=w*h-d-a;
		s=max(max(a,d),e)-min(min(a,d),e);
		ans=min(ans,s);
	}
	for(int i=1;i<=w/2;i++)
	{
		a=h*i;b=(w-i)*(h/2);c=w*h-a-b;
		s=max(max(a,b),c)-min(min(a,b),c);
		ans=min(ans,s);
		d=(w-i)/2*h;e=w*h-d-a;
		s=max(max(a,d),e)-min(min(a,d),e);
		ans=min(ans,s);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 05.10.2019 15:52:34       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  int n = (int) s.size();
  if (s == string(n, s[0])) {
    cout << n * k / 2 << '\n';
  } else {
    int ans1 = 0;
    for (int i = 0; i + 1 < n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans1;
        ++i;
      }
    }
    int ans2 = 0;
    for (int i = 0; i + 1 < 2 * n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans2;
        ++i;
      }
    }
    cout << ans1 + (ans2 - ans1) * (k - 1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int k = scan.nextInt();
        int s = scan.nextInt();


        // search
        int count = 0;
        for(int x = 0; x <= k; x++){
            for(int y = 0; y <= k; y++){
                int z = s - x - y;
                if(z >= 0 && z <= k){
                    count++;
                }
            }
        }


        // answer
        System.out.println(count);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

const int INF = 1000000007;

int main(void){
    ll n, a[100001];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int next = 1;
    for(int i=0;i<n;i++){
        if(a[next-1] == 2){
            cout << i+1 << endl;
            return 0;
        }
        next = a[next-1];
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mod 1000000007
//#define max 100007
#define itr ::iterator it
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define repp(X,a,Y) for (int (X) = a;(X) < (Y);++(X))
#define set(a, b) memset(a, b, sizeof(a));
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<pii> vii;
typedef vector<string> vs;
#define endl '\n'
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<vector<int> > a(n,vector<int>(3,0));
  vector<int> dp_curr(3,0);
  vector<int> dp_prev(3,0);

  for(int i=0; i<n; i++)
    for(int j=0; j<3; j++)
      cin>>a[i][j];

  for(int i=0; i<n; i++)
  {
      dp_curr[0] = max(dp_prev[1],dp_prev[2]) + a[i][0];
      dp_curr[1] = max(dp_prev[0],dp_prev[2]) + a[i][1];
      dp_curr[2] = max(dp_prev[0],dp_prev[1]) + a[i][2];

      dp_prev = dp_curr;
  }

  cout<<max(dp_curr[0],max(dp_curr[1], dp_curr[2]))<<endl;
  return 0;
}


Measured memory_bytes: 5760
n = int(input())
S = [int(input()) for i in range(n)]
S.sort()
if sum(S) % 10 == 0:
	flag = 0
	for s in S:
		if s % 10 != 0:
			flag = 1
			break
	if flag == 1:
		print(sum(S) - s)
	else:
		print(0)
else:
	print(sum(S))


Measured memory_bytes: 3064
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m)
    {
		ll sum = 0;

		for(ll i = 1; i <= m; i++)
		{
			cin >> input;
			sum += input;
		}

		cout << max(-1LL, n - sum);
    }


}





Measured memory_bytes: 3568
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] v = new int[N];
		for (int i = 0; i < N; ++i) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		ArrayList<Integer> vs = new ArrayList<Integer>();
		for (int i = 0; i < Math.min(4, N); ++i) {
			for (int j = 0; j < Math.min(4, N); ++j) {
				if (i == j) continue;
				vs.add(connect(v[i], v[j]));
			}
		}
		Collections.sort(vs);
		System.out.println(vs.get(2));
	}

	static int connect(int a, int b) {
		int digits = ("" + b).length();
		for (int i = 0; i < digits; ++i) {
			a *= 10;
		}
		return a + b;
	}

}

Measured memory_bytes: 30136
// inputに入力データ全体が入る
function Main(input) {
	var inputs = input.split(" ");
	var a = inputs[0];
	var b = inputs[1];

	var valid = true;
	if (a > 8 || b > 8) {
		valid = false;
	}

	console.log(valid ? "Yay!" : ":(");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
int main() {
  fastio;
  string s;
  cin >> s;
  ll n = s.length();
  ll c = 0;
  vector<ll>ans(n, 0);
  for (ll i = 0; i < 2; ++i) {
    for (ll j = 0; j < n; ++j) {
      if (s[j] == 'R') ++c;
      else {
        ans[j] += (c / 2);
        ans[j - 1] += (c + 1) / 2;
        c = 0;
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    for (ll i = 0; i < n; ++i) {
      if (s[i] != 'R') s[i] = 'R';
      else s[i] = 'L';
    }
  }
  for (auto i : ans) cout << i << " ";
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find(y);
        }

        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<pair<int, int>> ap(n);
    vector<pair<int, int>> bp(n);
    REP(i, n) {
        cin >> a[i];
        ap[i] = {a[i], i};
    }
    REP(i, n) {
        cin >> b[i];
        bp[i] = {b[i], i};
    }
    sort(ALL(ap));
    sort(ALL(bp));
    REP(i, n) {
        if (ap[i].first > bp[i].first) {
            cout << "No" << EOL;
            return;
        }
    }

    UnionFind uf(n);
    REP(i, n) uf.unite(ap[i].second, bp[i].second);
    if (uf.component_count() > 1) {
        cout << "Yes" << EOL;
    } else {
        REP(i, n - 1) {
            if (ap[i].first <= bp[i + 1].first && ap[i + 1].first <= bp[i].first) {
                cout << "Yes" << EOL;
                return;
            }
        }
        cout << "No" << EOL;
    }
}


Measured memory_bytes: 2944
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    ll A,B;
    ld b;
    cin>>A>>b;
    b=b*100.0;
    B=(ll)b;
    b=b/100.0;
    cout<<max((ll)floor(A*b),(A*B)/100)<<endl;


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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

int arr[3];

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

    for(int i=0;i<3;i++) {
        cin>>arr[i];
    }
    sort(arr,arr+3);
    cout<<arr[0]+arr[1]<<"\n";
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x = abs(tx - sx)
y = abs(ty - sy)
U, D, L, R = 'U', 'D', 'L', 'R'

S = U * y + R * x + D * y + L * x + L + U * (y + 1) + R * (x + 1) + D + R + D * (y + 1) + L * (x + 1) + U
print(S)

Measured memory_bytes: 3060
<?php
$max = fgets(STDIN);
$data = str_split(trim(fgets(STDIN)));

$count = 0;
foreach( $data as $check )
{
  if( $check == "R" ) { $count++; }
  else { $count--; }
}

$result = "No";
if( $count > 0 ) { $result = "Yes"; }
echo $result;
?>

Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int a;
	cin >> a;
	int b;
	cin >> b;

	if (x + a < b)
	cout << "dangerous" << endl;

	else if (a >= b )
	cout << "delicious" << endl;

	else
    cout << "safe " << endl;
	
}

Measured memory_bytes: 256
from sys import stdin

s = stdin.readline().strip()
t = stdin.readline().strip()

def lev(t1, t2):
  cnt = 0
  for i in range(len(t1)):
    if t1[i] == t2[i]:
      cnt += 1
  return len(t1) - cnt

min_val = 9999
for i in range(len(s)-len(t)+1): # 始点
  l = lev(t, s[i:i+len(t)])
  if l < min_val:
    min_val = l

print(min_val)

Measured memory_bytes: 8996
#include <iostream>

using namespace std;

class A {
	int a, b, c, ans;
public:
	void solve()
	{
		cin >> a >> b >> c;

		ans = a + b;
		
		if (a + c < ans) ans = a + c;
		if (b + c < ans) ans = b + c;

		cout << ans << endl;

	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, x[1010], y[1010];
void solve(){
	cin >> n;
	i64 a = 1, b = 1;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		i64 e = max((a+x[i]-1)/x[i], (b+y[i]-1)/y[i]);
		a = e*x[i]; b = e*y[i];
	}
	
	cout << a + b << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int A,B,C,D;
signed main(){
    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
    int TA=C/B+(C%B!=0);
    int AO=A/D+(A%D!=0);
    //printf("%lld %lld",TA,AO);
    if(TA<=AO)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 1660
//#include<cstdio>
//#include<cstring>
//#include<algorithm>
//using namespace std;
//const int maxn = 1e5 + 10;
//int n,x,ans[maxn];
//int main()
//{
//	scanf("%d", &n);
//	for (int i = 1; i <= n; i++)
//	{
//		scanf("%d", &x);
//		ans[x] = i;
//	}
//	return 0;
//}

#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	double ans;
	if (n & 1)
	{
		ans = (n + 1) / 2.0 / n;
	}
	else
	{
		ans = n / 2.0 / n;
	}
	printf("%.10lf\n", ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v[] = new int[n];
		for(int i=0;i<n;i++)v[i] = sc.nextInt();
		int cnt0[] = new int[100010];
		int cnt1[] = new int[100010]; 
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				cnt0[v[i]]++;
			}
			else {
				cnt1[v[i]]++;			}
		}
		int max0_1 = 0, max1_1 = 0;
		int max0_2 = 0, max1_2 = 0;
		
		int max0_1v = 0, max1_1v = 0;
		int max0_2v = 0, max1_2v = 0; //これ不要だった。教訓で残しておく
		
		for(int i=0;i<cnt0.length;i++) {
			if(max0_1<=cnt0[i]) {
				max0_2=max0_1;
				max0_1=cnt0[i];
				
				max0_2v = max0_1v; 
				max0_1v = i; 
				
			}else if(max0_2<=cnt0[i]) {
				max0_2=cnt0[i];
				max0_2v = i; 

			}
			if(max1_1<cnt1[i]) {
				max1_2=max1_1;
				max1_1=cnt1[i];

				max1_2v = max1_1v; 
				max1_1v = i; 

			}else if(max1_2<=cnt1[i]) {
				max1_2=cnt1[i];
				max1_2v = i; 
			}
		}
		
		int ans = 0;
		
		if(max0_1v!=max1_1v) {
			ans = n - max0_1 - max1_1;
		}
		else {
			int tmp1 = n - max0_1 - max1_2;
			int tmp2 = n - max0_2 - max1_1;
			ans = Math.min(tmp1, tmp2);
		}
		System.out.println(ans);
		
		
	}
}



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

using namespace std;

int main()
{
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   vector<int> v(n);
  for(int i=0;i<n;i++){
    v[i]=INT_MAX;
  }
   v[0]=0;
   v[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++){
       for(int j=i-1;j>=i-k && j>=0;j--){
           v[i]=std::min(v[i],v[j]+abs(a[i]-a[j]));
       }
   }
   cout<<v[n-1];
   return 0;
}

Measured memory_bytes: 4028
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

array<array<char, 8>, 8> grid = {};

int count_black(int h, int w) {
    int cnt = 0;
    for (auto i = 0; i < h; ++i)
        for (auto j = 0; j < w; ++j)
            if (grid[i][j] == '#')
                cnt++;
    return cnt;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;

    for (auto i = 0; i < h; ++i) {
        auto b = 0;
        for (auto j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }

    int ans = 0;
    for (auto i = 0; i < (1 << h); ++i) {
        auto orig = grid;
        for (auto row = 0; row < h; ++row) {
            if ((i & (1 << row)) == 0)
                continue;
            for (auto j = 0; j < w; ++j)
                grid[row][j] = '.';
        }

        for (auto j = 0; j < (1 << w); ++j) {
            auto orig2 = grid;
            for (auto col = 0; col < w; ++col) {
                if ((j & (1 << col)) == 0)
                    continue;
                for (auto i = 0; i < h; ++i)
                    grid[i][col] = '.';
            }
            auto x = count_black(h, w);
            grid = orig2;
            if (x == k)
                ans++;
        }

        grid = orig;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
def matrix_input(a,b):

    a = int(a)
    b = int(b)

    Data = []

    while True:
        if a == 0:
            break
        temp = input().split()
        Data.append(list(map(int,temp)))
        a -= 1

    return Data

n,m,l = input().split()

n = int(n)
m = int(m)
l = int(l)

Data1 = matrix_input(n,m)
Data2 = matrix_input(m,l)

# output = [[0]*l for a in range(n)]
output = []

temp = 0
templist = []
for a in Data1:
    for i in range(l):
        count = 0
        for b in a:
            temp += b * Data2[count][i]
            count += 1
        templist.append(temp)
        if len(templist) == l:
            output.append(templist)
            templist = []
        temp = 0

for a in output:
    b = map(str,a)
    print(' '.join(b))



Measured memory_bytes: 6884
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

using VI = vector <int>;
using VVI = vector <VI>;
using VVVI = vector <VVI>;

struct QueNode {
    int qx;
    int qy;
    int dist;
    int dir;

    QueNode(int px, int py,  int pdir, int pdist) : qx(px), qy(py), dist(pdist), dir(pdir) {
    }

    bool operator<(const QueNode& q) const {
        return dist > q.dist;
    }
};

int main() {
    int H;
    int W;
    int K;

    cin >> H >> W >> K;

    vector <string> pond(H);
    VVVI dp(H, VVI(W, VI(4, -1)));
    VVVI used(H, VVI(W, VI(4, 0)));

    VI x(2);
    VI y(2);
    for (int i = 0; i < 2; ++i) {
        cin >> x[i] >> y[i];
        --x[i];
        --y[i];
    }

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

    priority_queue <QueNode> que;
    dp[x[0]][y[0]][0] = 0;
    que.push(QueNode(x[0], y[0], 0, 0));

    while (!que.empty()) {
        int qx = que.top().qx;
        int qy = que.top().qy;
        int qdir = que.top().dir;
        que.pop();

        if (used[qx][qy][qdir]) {
            continue;
        }

        used[qx][qy][qdir] = 1;

        if (qx == x[1] && qy == y[1]) {
            break;
        }

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

        for (int dir = 0; dir < 4; ++dir) {
            int nqx = qx + dx[dir];
            int nqy = qy + dy[dir];
            int nd = (dir == qdir) ? dp[qx][qy][qdir] + 1 : (((dp[qx][qy][qdir]+K-1)/K)*K) + 1;

            if (nqx >= 0 && nqx < H
                && nqy >= 0 && nqy < W) {
                if (pond[nqx][nqy] != '@' && (dp[nqx][nqy][dir] == -1 || nd < dp[nqx][nqy][dir])) {
                    dp[nqx][nqy][dir] = nd;
                    que.push(QueNode(nqx, nqy, dir, nd));
                }
            }
        }
    }

    const int MAXVAL = 1000000010;
    int ans = MAXVAL;

    for (int dir = 0; dir < 4; ++dir) {
        if (dp[x[1]][y[1]][dir] > 0) {
            ans = min(ans, dp[x[1]][y[1]][dir]);
        }
    }

    cout << (ans == MAXVAL ? -1 : (ans+K-1)/K) << endl;

    return 0;
}

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

int solve(std::vector<int> v, int n)
{
	std::vector<int> dp(n + 1);
	dp[1] = 0;
	//dp[2] = 1;
	for (int i = 2; i <= n; i++)
	{
		int op1 = abs(v[i] - v[i - 1]) + dp[i - 1];
		int op2;
		if (i == 2)
			op2 = INT_MAX;
		else
			op2 = abs(v[i] - v[i - 2]) + dp[i - 2];
		dp[i] = min(op1, op2);
	}
	return dp[n];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	cout << solve(v, n);
}

Measured memory_bytes: 4512
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N, K;
  vector<int> h;

  cin >> N >> K;
  rep(i, N) {
    int a;
    cin >> a;
    h.push_back(a);
  }

  int sum = 0;
  rep(i, N) {
    if (h.at(i) >= K) sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 892
from collections import Counter

n = int(input())
vs = list(map(int, input().split()))
a = vs[::2]
b = vs[1::2]

ca = Counter(a)
cb = Counter(b)
ca[0] = 0
cb[0] = 0
if ca.most_common(1)[0][0] != cb.most_common(1)[0][0]:
    print(n - ca.most_common(1)[0][1] - cb.most_common(1)[0][1])
else:
    print(min(
        n - ca.most_common(1)[0][1] - cb.most_common(2)[1][1],
        n - ca.most_common(2)[1][1] - cb.most_common(1)[0][1]
    ))

Measured memory_bytes: 19040
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#define EPS 1e-10
using namespace std;

double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

class P{
public:
	double x,y;
	P(double xx=0.0,double yy=0.0){
		x=xx;
		y=yy;
	}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(x*d,y*d);
	}
	P operator /(double d){
		return P(x/d,y/d);
	}
};

typedef P Vector;
typedef vector<P> Polygon;

double norm(Vector p){
	return add(p.x*p.x,p.y*p.y);
}

double abs(Vector p){
	return sqrt(norm(p));
}

double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}


int contains(Polygon g,P p){
	int n=g.size();
	bool x=false;
	for(int i=0;i<n;i++){
		P a=g[i]-p,b=g[(i+1)%n]-p;
		if(abs(cross(a,b))<EPS && dot(a,b)<EPS)return 1;
		if(a.y>b.y)swap(a,b);
		if(a.y<EPS && EPS<b.y && cross(a,b)>EPS)x=!x;
	}
	return (x?2:0);
}

int main(void){
	int n;
	scanf("%d",&n);
	Polygon g;
	for(int i=0;i<n;i++){
		P p;
		scanf("%lf %lf",&p.x,&p.y);
		g.push_back(P(p.x,p.y));
	}
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		P p;
		scanf("%lf %lf",&p.x,&p.y);
		printf("%d\n",contains(g,p));
	}
	return 0;
}

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

int n,t;
vector <pair <int, int>> v;
int main()
{
    scanf("%d %d",&n,&t);
    for (int i = 0; i<n; i++)
    {
        int ai;
        scanf("%d",&ai);
        v.push_back({ai,ai+t});
    }
    int cur_start = v[0].first;
    int cur_end = v[0].second;
    int ans = 0;
    for (int i = 1; i<n; i++)
    {
        if (v[i].first>cur_end)
        {
            ans += cur_end-cur_start;
            cur_start = v[i].first;
            cur_end = v[i].second;
        }
        else
        {
            cur_end = v[i].second;
        }
    }
    ans += cur_end-cur_start;
    printf("%d",ans);
}

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

int fonk(int r, int c, vector<vector<bool>> visited){
	int dist[visited.size()][visited[0].size()] = {};
	int res = 0;
	visited[r][c] = true;
	queue<pair<int,int>> q;
	q.push({r,c});
	while(!q.empty()){
		r = q.front().first, c = q.front().second;
		q.pop();
		for(int i = -1; i <= 1; i++){
			for(int j = -1; j <= 1; j++){
				if((i == 0 || j == 0) && !(i == 0 && j == 0)){
					if(r+i >= 0 && r+i < visited.size() && c+j >= 0 && c+j < visited[0].size() && !visited[r+i][c+j]){
						dist[r+i][c+j] = dist[r][c]+1;
						res = max(res, dist[r+i][c+j]);
						visited[r+i][c+j] = true;
						q.push({r+i, c+j});
					}
				}
			}
		}
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int h, w; cin>>h>>w;
	vector<vector<char>> vec(h, vector<char>(w));
	vector<vector<bool>> visited(h, vector<bool>(w));
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin>>vec[i][j];
			if(vec[i][j] == '.') visited[i][j] = 0;
			else visited[i][j] = 1;
		}
	}
	int res = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(vec[i][j] != '#'){
				visited[i][j] = true;
				res = max(res, fonk(i, j, visited));
				visited[i][j] = false;
			}
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0; (i) < (n); (i)++)
int main(){
  int R;
  cin >> R;
  int64_t ans = 0;
  int now = 0;
  cout << R * 2 * 3.141592653589793 << endl;
}

Measured memory_bytes: 3784
N,M=map(int,input().split())
students=[tuple(map(int,input().split())) for _ in range(N)]
points=[tuple(map(int,input().split())) for _ in range(M)]

for student in students:
    dist=10**10
    ans=0
    for i,point in enumerate(points,start=1):
        if abs(student[0]-point[0])+abs(student[1]-point[1]) < dist:
            dist=abs(student[0]-point[0])+abs(student[1]-point[1])
            ans=i
    print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    
    int n;
    cin >> n;
    int allxor = 0;
    int d[31] = {0};
    rep(i,n){
        int a;
        cin >> a;
        allxor ^= a;
        int cnt = 0;
        while(a!=0){
            if(a%2 == 1){
                d[cnt]++;
                break;
            }else{
                a /= 2;
                cnt++;
            }
        }
    }
    int han[31] = {0};
    han[0] = 1;
    for(int i = 1;i<31;i++)han[i] = 2*(han[i-1]+1)-1;
    int ans = 0;
    for(int i = 30;i >= 0;i--){
        if(allxor & (1<<i)){
            if(d[i] == 0){
                cout << -1 << endl;
                return 0;
            }else{
                ans++;
                allxor ^= han[i];
            }
        }
    }
    cout << ans << endl;
    
    return 0;   
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://cf16-exhibition-final-open.contest.atcoder.jp/tasks/cf16_exhibition_final_c


Measured memory_bytes: 384
antennas = [int(input()) for i in range(5)]

max_dist = int(input())

coords = {}

for i in range(len(antennas)):
  coords[i] = antennas[i]
flag = 1
for i in range(5):
  for j in range(i + 1, 5):
    if abs(coords[i] - coords[j]) > max_dist:
      print(':(')
      flag = 0
      break
  if flag == 0:
    break
if flag == 1:
  print('Yay!')
      

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

int main() {
  int K,X;
  cin >> K >>X;
  
  int n=-K+1;
  
  vector<int> vec(2*K-1);
  
  for (int i=0;i<2*K-1;i++){
    vec.at(i)=X+n;
    n++;
  }
  
  for (int i=0;i<2*K-1;i++){
    cout <<vec.at(i) <<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 256