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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF =  1e9;
const ll LINF = 1e18;
const ll MOD = 1e9+7;
const int SIZE = 100;

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll n;
	ll ans;
	ans = 0;
	scanf ("%lld", &n);
	vector<ll> a(n);
	vector<bool> flg(n);
	for (ll i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		if (a[i] == i+1) {
			flg[i] = true;
		} else {
			flg[i] = false;
		}
	}

	for (ll i = 0; i < n; i++) {
		if (flg[i] == true) {
			ans++;
			if (i+1 < n) {
				if (flg[i+1] == true) {
					i++;
				}
			}
		}
	}
	
	printf("%lld\n", ans);

	
	return 0;
}


Measured memory_bytes: 1024
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabCout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headCout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabHeadCout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int n;
	cin >> n;

	vector<ll> dp(n + 10, INF);
	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		chmin(dp[i + 1], dp[i] + 1);

		for (int m6 = 6; i + m6 <= n; m6 *= 6)
		{
			chmin(dp[i + m6], dp[i] + 1);
		}
		for (int m9 = 9; i + m9 <= n; m9 *= 9)
		{
			chmin(dp[i + m9], dp[i] + 1);
		}
	}

	cout << dp[n];
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/*while (true)
	{
		Main();
		cout << endl;
	}//*/

	Main();

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int d[100][100];
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int a=0;
  for(int i=N-1;i>=0;i--){
    int k=v[i];
    if(i%2)k*=-1;
    a+=k;
  }
  a/=2;
  for(int i=0;i<N;i++){
    if(i)cout<<" ";cout<<a*2;
    a=v[i]-a;
  }
  cout<<endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll ans_a, ans_b = b;
  ans_a = max(a - k, 0LL);
  if (k > a) ans_b = max(b - (k - a), 0LL);
  cout << ans_a << " " << ans_b << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	ll N,H;
	cin>>N>>H;
	vector<pll> C;
	for(int i=0;i<N;i++){
		ll a,b;
		cin>>a>>b;
		C.pb(mp(a,0));
		C.pb(mp(b,1));
	}
	bool flag=0;
	sort(C.begin(),C.end(),greater<pll>());
	for(ll i=0;i<C.size();i++){
		if(C[i].second==0){
			cout<<i+((H+C[i].first-1)/C[i].first)<<endl;
			return 0;
		}
		H-=C[i].first;
		if(H<=0){
			cout<<++i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 6512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val y = sc.nextInt()
    val z = sc.nextInt()
    println(problem078b(x, y, z))
}

fun problem078b(x: Int, y: Int, z: Int): Int {
    var space = x - z
    var count = 0
    while (true) {
        if (space >= y + z) {
            space -= y + z
            count++
        } else {
            break
        }
    }
    return count
}

Measured memory_bytes: 29592
using System;

namespace B___Friendly_Rabbits
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var a = Console.ReadLine ().Split (' ');
            var count = 0;
            for (var i = 0; i < n; i++)
            {
                if (a[int.Parse (a[i]) - 1] == (i + 1).ToString ())
                {
                    count++;
                }
            }
            Console.WriteLine (count / 2);
        }
    }
}

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

using namespace std;

int main() {
	int n, x;
	cin >> n >> x;

	vector<int> a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (x < a[i]) break;
		if (i == n - 1 && a[i] < x)break;
		x = x - a[i];
		if (x < 0) break;
		
		
		ans++;
	}

	cout << ans;


	return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string str;
	cin >> str;
	int n=(int)str.size();
	
	for(int i=0;i<n;i++){
		if(str[i]=='?') cout << "D";
		else cout << str[i];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3752
/*
 * status: AC
 */
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

vector<vector<ll>> find(vector<ll> &A, int s, int t) {
	int l = s, u = t;
	ll sum = A[t] - A[s];
	while (u - l > 1) {
		int c = (l + u) / 2;
		if(A[c] - A[s] > sum / 2) {
			u = c;
		} else {
			l = c;
		}
	}
	vector<vector<ll>> res;
	if(l > s) {
		vector<ll> tmp(2);
		tmp[0] = A[l] - A[s];
		tmp[1] = A[t] - A[l];
		res.push_back(tmp);
	}
	if(u < t) {
		vector<ll> tmp2(2);
		tmp2[0] = A[u] - A[s];
		tmp2[1] = A[t] - A[u];
		res.push_back(tmp2);
	}

	return res;
}

ll solve(vector<ll> &A, int p) {
	int N = A.size()-1;
	auto v1 = find(A, 0, p);
	auto v2 = find(A, p, N);

	/*
	cout << p << endl;
	for(auto a: v1) {
		for(auto b: a) {
			cout << b << ",";
		}
		cout << endl;
	}
	cout << "-" << endl;
	for(auto a: v2) {
		for(auto b: a) {
			cout << b << ",";
		}
		cout << endl;
	}
	cout <<  "<" << endl;
	*/

	ll res = (ll) 1e18;
	for(auto u1: v1) {
		for(auto u2: v2) {
			vector<ll> tmp = u1;
			tmp.insert(tmp.end(), ALL(u2));
			sort(ALL(tmp));
			res = min(res, tmp.back() - tmp.front());
		}
	}
	return res;
}

signed main(){
	int N;
	cin >> N;
	vector<ll> A(N+1);
	for(int i = 1; i <= N; ++i) {
		cin >> A[i];
		A[i] += A[i-1];
	}

	ll res = (ll)1e18;
	for(int i = 2; i < N; ++i) {
		res = min(res, solve(A, i));
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
  int n,m,p[100000],y[100000],l,r,mid;
  vector<int> v[100001];
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d",&p[i],&y[i]);
    v[p[i]].push_back(y[i]);
  }
  for(int i=0;i<=n;i++)
    sort(v[i].begin(),v[i].end());
  for(int i=0;i<m;i++){
    for(int j=100000;j>0;j/=10){
      if(p[i]/j==0)
        printf("0");
      else
        break;
    }
    printf("%d",p[i]);
    l=0;
    r=v[p[i]].size();
    mid=(l+r)/2;
    while(v[p[i]][mid]!=y[i]){
      if(v[p[i]][mid]>y[i])
        r=mid-1;
      else
        l=mid+1;
      mid=(l+r)/2;
    }
    mid++;
    for(int j=100000;j>0;j/=10){
      if(mid/j==0)
        printf("0");
      else
        break;
    }
    printf("%d\n",mid);
  }
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string S,T,U;
ll K;
string n;
ll N[101];
ll ans;
ll M;
ll dp[101][101];
int cnt;
ll cntt;
 
 
 
int main(){
    cin >> n>>K;
    ll a = n.size();
    for (int i=0;i<a;i++){
        N[i] = n[i] -'0';
    }
    cnt = 0;
    for(int i=0;i<a;i++){
        cntt = max(cnt,i);
        dp[i][0] = 1;
        for(int j=0;j<=cntt;j++){
            if(cnt==j){
               dp[i+1][j+1] = dp[i][j+1] +N[i]+(dp[i][j]-1)*9;
            } else {
                dp[i+1][j+1] = dp[i][j+1] + dp[i][j]*9;
            }
        }
        if(N[i]!=0){
            cnt++;
        }
        
    }
    cout << dp[a][K] << endl;
//    }else if(a==K){
//        int b=1;
//        for(int i = 0;i<K;i++){
//            M += b*N[K-i-1];
//            b *= 10;
//        }
//        ans = M - (b/10 - 1)-M/10;
//        cout << ans << endl;
//    }else{
//        int b=1;
//        for(int i = 0;i<K;i++){
//            M += b*N[K-i-1];
//            b *= 10;
//        }
//        ans = M - (b/10 - 1)-M/10 + (b - 1)*(a-K);
//        cout << ans << endl;
//    }
    
 
    
}
 
 


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

struct Cost {
	int cost, index;
	bool is_a{};
};

std::vector<Cost> costs;
int n;

bool connected();
bool divided();

int main()
{
	scanf("%d", &n);
	costs.resize(2 * n);
	for (int i{}; i < n; i++)
	{
		scanf("%d%d", &costs[2 * i].cost, &costs[2 * i + 1].cost);
		costs[2 * i].index = costs[2 * i + 1].index = i;
		costs[2 * i].is_a = true;
	}
	std::sort(costs.begin(), costs.end(),
		[](const auto& a, const auto& b) { return a.cost < b.cost; }
	);
	if (!connected())
	{
		if (costs[n - 1].index != costs[n].index)
			std::swap(costs[n - 1], costs[n]);
		else if (costs[n].cost - costs[n - 2].cost < costs[n + 1].cost - costs[n - 1].cost)
			std::swap(costs[n], costs[n - 2]);
		else
			std::swap(costs[n + 1], costs[n - 1]);
	}
	long long sum{};
	for (int i{}; i < n; i++)
		sum += costs[i].cost;
	
	printf("%lld\n", sum);

	return 0;
}

bool connected()
{
	if (divided()) return true;
	std::vector<bool> used(n);
	for (int i{}; i < n; i++)
		if (used[costs[i].index])
			return true;
		else
			used[costs[i].index] = true;
	return false;
}

bool divided()
{
	for (int i{1}; i < n; i++)
		if (costs[0].is_a ^ costs[i].is_a)
			return false;
	return true;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll         long long
#define max(a,b)    (a>b?a:b)
#define min(a,b)    (a<b?a:b)
#define endl        '\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


signed main(){
    FAST
	
	{
        string s,t;
        bool flag =true;
        cin>>s;
        cin>>t;
        for(int i=0;i<s.size();i++){
            if(s[i]==t[i]) flag=true;
            else{
                flag=false;
                break;
            }
        }
        if(flag==true) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    int n,ans;

    cin >> n;
    ans = n;

    FORQ(i,0,n){
        int t = i;
        int c = 0;
        while(t > 0){
            c += t%6;
            t /= 6;
        }
        t = n - i;
        while(t > 0){
            c += t%9;
            t /= 9;
        }
        if(ans > c)ans = c;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import re
n = int(input())
vs = list(map(int, input().split()))
edic = {}
odic = {}

for i in range(n):
    item = vs[i]
    if i % 2 == 0:
        if item in edic:
            edic[item] += 1
        else:
            edic[item] = 1
    else:
        if item in odic:
            odic[item] += 1
        else:
            odic[item] = 1

elist = sorted(edic.items(), key=lambda x: -x[1])
olist = sorted(odic.items(), key=lambda x: -x[1])

if elist[0][0] != olist[0][0]:
    print(len(vs) - elist[0][1] - olist[0][1])
else:
    ogain = egain = 0
    if len(elist) >= 2:
        egain = elist[1][1]
    if len(olist) >= 2:
        ogain = olist[1][1]
    print(min(len(vs) - elist[0][1] - ogain, len(vs) - olist[0][1] - egain ))


Measured memory_bytes: 21020
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    int sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    bitset<4000001> b(0);
    b.set(0);
    rep(i,0,n){
        bitset<4000001> bb=b<<a[i];
        b|=bb;
    }
    sum=(sum+1)/2;
    for(int i=sum;;i++){
        if(b[i]==1){
            cout<<i<<endl;
            return 0;
        }
    }
}










Measured memory_bytes: 1920
N, M, C = map(int, input().split())
b = list(map(int, input().split()))
a = []
for x in range(N):
    a.append(list(map(int, input().split())))

sm = 0
ans = 0

for x in a:
    for y, z in zip(x, b):
        sm += y*z
    sm += C
    if sm > 0:
        ans += 1
    sm = 0

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <tuple>
using namespace std;

using vec = complex<double>;
using line = pair<vec,vec>;
const double eps = 0.0000001;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}

vec reflection(line l,vec p){
    return 2.0*projection(l,p)-p;
}

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = cross_product(ab,ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(inner_product(ab,ac)<0){
        return 2; //C-A-B
    }else{
        if(inner_product(ab,ab)<inner_product(ac,ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

bool isIntersect(line l0, line l1){
    int s = ccw(l0.first,l0.second,l1.first)*ccw(l0.first,l0.second,l1.second);
    if(s!=0&&s!=-1&&s!=-4) return false;
    s=ccw(l1.first,l1.second,l0.first)*ccw(l1.first,l1.second,l0.second);
    if(s!=0&&s!=-1&&s!=-4) return false;
    else return true;
}

vec interSection(line l0, line l1){
    vec s0, t0, s1, t1;
    tie(s0,t0)=l0; tie(s1,t1)=l1;
    double k = cross_product(t1-s1,s1-s0)/cross_product(t1-s1,t0-s0);
    return s0+(t0-s0)*k;
}

double segLength(line l){
    return abs(l.first-l.second);
}

double distLine2point(line l, vec p){
    return abs(cross_product(l.second-l.first,p-l.first))/abs(l.second-l.first);
}

double distSeg2Point(line l, vec p){
    vec x = projection(l,p);
    double L = segLength(l);
    if(abs(x-l.first)<L&&abs(x-l.second)<L){
        return abs(x-p);
    }else{
        return min(abs(l.first-p),abs(l.second-p));
    }
}

double distSeg2Seg(line l1, line l2){
    if(isIntersect(l1,l2)) return 0;
    double ret = 1e20;
    ret = min(ret,distSeg2Point(l1,l2.first));
    ret = min(ret,distSeg2Point(l1,l2.second));
    swap(l1,l2);
    ret = min(ret,distSeg2Point(l1,l2.first));
    ret = min(ret,distSeg2Point(l1,l2.second));
    return ret;
}

//???????????§???????????????
int main(void){
    int q;
    cin >> q;
    cout.precision(10);
    cout << fixed;
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y; vec p0(x,y);
        cin>>x>>y; vec p1(x,y);
        cin>>x>>y; vec p2(x,y);
        cin>>x>>y; vec p3(x,y);
        cout<<distSeg2Seg(line(p0,p1),line(p2,p3))<<endl;
    }
    return 0;
}

Measured memory_bytes: 3308
#include<cstdio>
#include<algorithm>
int a[101]; 
int main()
{
	int n,i,x,ans=0;
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	std::sort(a+1,a+n+1);
	for(i=1;i<n&&a[i]<=x;i++)
	{
		x-=a[i];
		ans++;
	}
	if(x==a[n])ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

bool is_rechable(vector<string>& maze, vector<vector<int>>& dis, int a, int b) {
    int H = maze.size(), W = maze[0].size();
    if (a < 0 || a > H - 1 || b < 0 || b > W - 1)return false;
    if (maze[a][b] == '#')return false;
    return true;
}
void maze_toki(vector<string>& maze, vector<vector<int>>& dis, int a, int b,int kyori) {
    
    dis[a][b] = kyori;
    if (is_rechable(maze, dis, a - 1, b)) {
        if (dis[a - 1][b] > dis[a][b] + 1)maze_toki(maze, dis, a - 1, b, kyori + 1);
    }
    if (is_rechable(maze, dis, a, b + 1)) {
        if(dis[a][b + 1] > dis[a][b] + 1)maze_toki(maze, dis, a, b + 1, kyori + 1);
    }    
    if (is_rechable(maze, dis, a + 1, b)) {
        if (dis[a + 1][b] > dis[a][b] + 1)maze_toki(maze, dis, a + 1, b, kyori + 1);
    }
    if (is_rechable(maze, dis, a, b - 1)) {
        if(dis[a][b - 1] > dis[a][b] + 1)maze_toki(maze, dis, a, b - 1, kyori + 1);
    }
        
}

int dis_max(vector<string>& maze,vector<vector<int>>& dis) {
    int H = dis.size(), W = dis[0].size();
    int ans = -1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '.')
                ans = max(ans, dis[i][j]);
        }
    }
    return ans;
}
int main() {
    int H, W;
    cin >> H >> W;

    vector<string> maze(H);
    for (int i = 0; i < H; i++)
        cin >> maze[i];

    int ans = -1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            vector<vector<int>> dis(H, vector<int>(W, 500));
            if (maze[i][j] == '#') continue;
            maze_toki(maze,dis, i, j, 0);
            ans = max(ans, dis_max(maze,dis));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Code-->**RAJESH_KUMAR**//

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define endl "\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
const int M = 1e9 + 7;


signed  main() {

    //*************************************//
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);

    //*************************************//
    
    int t ;  cin >> t;
    
    string s;  cin>>s;

    if(s.length()<=t)
      cout<<s<<endl;
    else{
      for(int i=0;i<t;i++)
        cout<<s[i];

      cout<<"...";
    }

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 1000000000
using namespace std;
int N,M;
int po3[20],rei[2];
int res[15000000];

void pow3(){
	int tmpo=1;
	for(int i=0;i<20;i++){
		po3[i]=tmpo;
		tmpo*=3;
	}
}

void solv(int m){
	int abc[3]={-1,-1,-1},re[2];
	int tmp;
	for(int i=0;i<N;i++){
		tmp=(m/po3[i])%3;
		abc[tmp]=max(abc[tmp],i);
	}
	re[0]=re[1]=m;
	if(abc[0]>abc[1]){
		if(abc[0]>=0)re[0]=m+po3[abc[0]];
	}
	else{
		if(abc[1]>=0)re[0]=m-po3[abc[1]];
	}
	if(abc[1]>abc[2]){
		if(abc[1]>=0)re[1]=m+po3[abc[1]];
	}
	else{
		if(abc[2]>=0)re[1]=m-po3[abc[2]];
	}
	rei[0]=re[0];
	rei[1]=re[1];
}

int main(){
	pow3();
	int hog,piy,cnt,tmp,ress;
	queue<int> que;
	while(true){
		cin>>N>>M;
		if(N==0&&M==0) break;
		fill(res,res+15000000,INF);
		cnt=0;
		for(int i=0;i<3;i++){
			cin>>hog;
			for(int j=0;j<hog;j++){
				cin>>piy;piy--;
				cnt+=po3[piy]*i;
			}
		}

		ress=INF;
		while(!que.empty()) que.pop();
		que.push(cnt);
		res[cnt]=0;
		while(!que.empty()){
			tmp=que.front();que.pop();
			if(tmp==0||tmp==po3[N]-1||res[tmp]>M){
				break;
			}
			solv(tmp);
			if(res[rei[0]]>res[tmp]+1){
				res[rei[0]]=res[tmp]+1;
				que.push(rei[0]);
			}
			if(res[rei[1]]>res[tmp]+1){
				res[rei[1]]=res[tmp]+1;
				que.push(rei[1]);
			}
		}
		ress=min(ress,min(res[0],res[po3[N]-1]));
		if(ress<=M)cout<<ress<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n+1];
    int b[n+1];
    int c[n];
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=1; i<=n; i++) cin >> b[i];
    for(int i=1; i<=n-1; i++) cin >> c[i];
    int ans=0;
    for(int i=1; i<=n-1; i++){
        ans+=b[a[i]];
        if(a[i+1]==a[i]+1)
            ans+=c[a[i]];
    }
    ans+=b[a[n]];

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,k;
int main(){FAST;
cin>>n>>k;
ll x = n;

if(n == 0){
  cout<<1;
  return 0;
}
ll ans = 0;
while(x){
  x/=k;
  ans++;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n_a_b = lines.next().unwrap().unwrap();
    let mut n_a_b = n_a_b.split_whitespace();
    let n = n_a_b.next().unwrap().parse::<u64>().unwrap();
    let a = n_a_b.next().unwrap().parse::<u64>().unwrap();
    let b = n_a_b.next().unwrap().parse::<u64>().unwrap();

    let ans = (b - a) / 2
        + if (b - a) % 2 == 0 {
            0
        } else if a < n - b + 1 {
            a
        } else {
            n - b + 1
        };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

ll dp[110][100100];

int main(void){
    ll N,W;
    cin >> N >> W;
    ll w[110],v[110];
    REP(i,N) cin >> w[i] >> v[i];
    REP(i,110)
        REP(j,100100)
            dp[i][j]=1e10;
    dp[0][0]=0;

    for(int i=0;i<N;i++){
        for(int sum_v=0;sum_v<100100;sum_v++){
            if(sum_v-v[i]>=0)
                chmin(dp[i+1][sum_v],dp[i][sum_v-v[i]]+w[i]);
            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }


    ll res=0;
    for(int sum_v=0;sum_v<100100;sum_v++){
        if(dp[N][sum_v]<=W)res=sum_v;
    }
    cout << res <<endl;
    return 0;
}

Measured memory_bytes: 89668
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;

int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
int main(void){
	char a,b;
	cin >> a >> b;
	if(a == 'H'){
		cout << b << endl;
	}else{
		cout << (b == 'H'?'D':'H') << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;





int main(){

string s; cin>>s;

if(s[0] == s[1] and s[1] == s[2]) cout<<"No"<<endl;
else cout<<"Yes"<<endl;

return 0;
  

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

ll N;cin>>N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
    
  }
  int cnt=1;
  vsort(vec);
  for(int i=0;i<N-1;i++){
    if(vec[i]!=vec[i+1]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 9596
#include<stdio.h>

int main(void)
{
  int N;
  scanf("%d",&N);
  int h[N];
  int i,j,k=0;
  for(i = 0; i < N; i++)
  {
    scanf("%d",&h[i]);
  }
  
  for(i = 1; i < N; i++)
  {
    for(j = 0; j < i; j++)
    {
      if(h[i]<h[j]) 
      {
        k ++;
        break;
      }
    }
  }
  int ans = 0;
  ans = N - k;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    REP(i,N){
        char c; cin>>c;
        if(c=='Y'){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
}


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

int main() {
	int h, w, a, b; cin >> h >> w >> a >> b;
	if (a > (w - a) || b > (h - b)) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (i < b)
				if (j < a)cout << "0";
				else cout << "1";
			else
				if (j < a)cout << "1";
				else cout << "0";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  ll x;
  cin >> x;

  for(ll i = 1;; i++){
    if(x*i % 360 == 0){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3592
def warshall_floyd(graph):
    # 頂点数
    n_nodes = len(graph)

    froms = []
    # fromsの初期化
    for i in range(len(graph)):
        froms.append([])
        for j in range(len(graph[i])):
            if i == j:                          # 同じ点にかえって来る場合  
                froms[i].append(0)
            elif graph[i][j] < float("inf"):    # i -> j間に辺がある場合、ひとまずiをdestに行く直前のnodeとしておく
                froms[i].append(i)
            else:
                froms[i].append(None)

    # 更新
    for k in range(n_nodes):
        for i in range(n_nodes):
            for j in range(n_nodes):
                adj_cost = graph[i][k] + graph[k][j]
                if adj_cost < graph[i][j]:
                    # i -> jの最短経路は i -> k -> jであることを意味する
                    # よってjの直前に立ち寄る頂点は k -> j の最短経路においてjの直前に寄る点である
                    graph[i][j] = adj_cost
                    froms[i][j] = froms[k][j]
    
    has_negative_loop = False
    for i in range(n_nodes):
        if graph[i][i] < 0:
            has_negative_loop = True
            break

    return graph, froms, has_negative_loop


def resolve():
    H, W = list(map(int, input().split()))
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    C, _, __ = warshall_floyd(C)
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == -1:
                continue
            ans += C[A[i][j]][1]
    print(ans)

        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3444
import sys

input = sys.stdin.readline


def main():
    K, S = map(int, input().split())

    ans = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - (X + Y)
            if 0 <= Z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32
    }
    let p = std::cmp::max(a, c);
    let q = std::cmp::min(b, d);
    println!("{}", std::cmp::max(0, q - p));
}

// fn main() {
//     input! {
//         h: usize,
//         w: usize,
//         s: [chars; h]
//     }
//     let xy = [
//         // [-1i32, 1i32],
//         [0i32, 1i32],
//         // [1i32, 1i32],
//         [-1i32, 0i32],
//         [1i32, 0i32],
//         // [-1i32, -1i32],
//         [0i32, -1i32],
//         // [1i32, -1i32],
//     ];
//     let mut s = s;
//     for y in 0..h {
//         for x in 0..w {
//             if s[y][x] == '.' {
//                 continue;
//             }
//             let mut b = false;
//             for i in 0..4 {
//                 let xx = x as i32 + xy[i][0] as i32;
//                 let yy = y as i32 + xy[i][1] as i32;
//                 if xx < 0 || w as i32 <= xx {
//                     continue;
//                 }
//                 if yy < 0 || h as i32 <= yy {
//                     continue;
//                 }
//                 if s[yy as usize][xx as usize] == '#' {
//                     b = true;
//                 }
//             }
//             if !b {
//                 println!("No");
//                 return;
//             }
//         }
//     }
//     println!("Yes")
// }


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    Console.WriteLine(i + "x" + j + "=" + i * j);
                }
            }
        }
    }
}

Measured memory_bytes: 9080
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,M = II()
P,Y = Line(M)

a = defaultdict(list)
for i in range(M):
    a[P[i]].append([Y[i],i])

for p in a.keys():
    a[p].sort(key = lambda x:x[0])

b = []
for p in a.keys():
    for i,y in enumerate(a[p]):
        b.append([str(p).zfill(6)+str(i+1).zfill(6),y[1]])

b.sort(key = lambda x: x[1])
for i in range(M):
    print(b[i][0])

Measured memory_bytes: 118748
n = int(input())
a = list(map(int,input().split()))

x = [ aa + i  for i,aa in enumerate(a,start = 1)]
y = [ i - aa  for i,aa in enumerate(a,start = 1)]

from collections import Counter
c = Counter(y)
ans = 0
for xx in x:
    ans += c[xx]
print(ans)





Measured memory_bytes: 50256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int num[ 11 ]; REP( i, 11 ) num[ i ] = 0;
	REP( i, 3 )
	{
		int n;
		cin >> n;
		++num[ n ];
	}
	cout << ( num[ 5 ] == 2 && num[ 7 ] == 1 ? "YES" : "NO" ) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] nums=new int[n];
for(int i=0;i<n;i++)nums[i]=sc.nextInt();nums[0]--;
for(int i=1;i<n;i++){
if(nums[i-1]<nums[i])nums[i]--;
else if(nums[i-1]>nums[i]){System.out.println("No");
return;}
}
System.out.println("Yes");
}}

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

int main(void){
    int n,m,x,a,lx=0,mx=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        cin>>a;
        if(a<x) lx++;
        else mx++;
    }
    cout<<min(lx,mx)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`  

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (cur == 1) {
            cout << i << "\n";
            return 0;
        }
        cur = a[cur];
    }
    cout << -1;
}
/*

*/  


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
A = LIST()[::-1]

if A[0] != 2:
	print(-1)
	exit()

N_min = 2
N_max = 3
for a in A[1:]:
	if (N_min-1)//a ==  N_max//a:
		print(-1)
		exit()

	N_min = ((N_min-1)//a+1)*a
	N_max = N_max//a*a + a - 1

print(N_min, N_max)


Measured memory_bytes: 21572
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;

int main(){
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}





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 m = sc.nextInt();
		int x = sc.nextInt();
		
		int costLeft = 0;
		int costRight = 0;
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			if (a < x) costLeft++;
			if (x < a) costRight++;
		}
		
		System.out.println(Math.min(costLeft, costRight));
		
		sc.close();
	}
}




Measured memory_bytes: 27200
#include <iostream>

using namespace std;

int Fairfield(int y,int m,int d){
  if(m<=2){y--;m+=12;}
  return 365*y+y/4-y/100+y/400+153*(m+1)/5+d-428;
}

int main() {
  int y1, m1, d1, y2, m2, d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
    if(y1 == -1) break;
    cout << Fairfield(y2,m2,d2)-Fairfield(y1,m1,d1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n){
		vd a(n);
		rep(i,n)cin>>a[i];
		auto d=accumulate(all(a),0.0)/n;
		cout<<count_if(all(a),[&](double e){return e<=d;})<<endl;
	}
	return 0;
}


Measured memory_bytes: 3368