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

void test(int64_t n);
int main(void) {
    int64_t n;
    int64_t cnt=0;
    int64_t centor;
    int64_t diff;
    int64_t sign;
    int64_t temp;
    cin >> n;

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

    // 奇数の場合
    // centor: n/2 + 1
    // c, c+1, c-1, c+2, c-2, c+3,...

    // 偶数の場合
    // centor: n / 2
    // c+1, c-1, c+2, c-2, c+3, c-3,...

    vector<int64_t> b(n);
    if(n % 2) {
        centor = n/2;
        b[centor] = a[cnt++];
        sign = 1;
        diff = 1;
        for(cnt=1;cnt<n;cnt++) {
            b[centor + (sign * diff)] = a[cnt];
            if(sign < 0) diff++;
            sign *= -1;
        }
    } else {
        centor = n/2;
        b[centor] = a[cnt++];
        sign = -1;
        diff = 1;
        for(cnt=1;cnt<n;cnt++) {
            b[centor + (sign * diff)] = a[cnt];
            if(sign > 0) diff++;
            sign *= -1;
        }
        
    }

    cout << b[0];
    for(int i=1;i<n;i++) {
        cout << " " << b[i];
    }
    cout << "\n";
    return 0;
}

//void test(int64_t n) {
//    vector<int64_t> a(n);
//printf("##input##\nn:%ld\n",n);
//    for(int i=0;i<n;i++) {
//        a[i] = i+1;
//printf("%ld ",a[i]);
//    }
//printf("\n");
//
//    vector<int64_t> b;
//    for(int i=0;i<n;i++) {
//        b.push_back(a[i]);
//
////printf("debug: a[%d]:%ld, b.size():%ld\n", i, a[i], b.size());
//        reverse(b.begin(),b.end());
//    }
//    
//printf("##output##\n");
//    for(int i=0;i<n;i++) {
//        printf("%ld ", b[i]);
//    }
//printf("\n");
//}


Measured memory_bytes: 5248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	hs := getIntSlice(n)
	hs[0]--

	ans := "Yes"
	for i := 1; i < n; i++ {
		if hs[i]-1 >= hs[i-1] {
			hs[i]--
		} else if hs[i] < hs[i-1] {
			ans = "No"
		}
	}

	fmt.Println(ans)
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 3072
#include <iostream>

using namespace std;
int main(){
    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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


signed main() {
  int n; cin >>n;
  string s; cin >> s;
  if(n%2 == 1) {cout << "No" <<endl; return 0;}
  for(int i = n/2; i < n;i++) {
    if(s[i] != s[i-n/2]) {cout << "No" <<endl; return 0;}
  }
  cout << "Yes" << endl;
}


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

template<unsigned mod, unsigned prim = 0> struct ModInt {
    int64_t x;
    ModInt() : x(0) {}
    ModInt(int64_t a) : x(a >= 0 ? a % mod : (a % mod + mod) % mod) {}
    inline unsigned getmod() const { return mod; }
    inline ModInt getprim() const { return ModInt(prim); }
    inline ModInt &operator+=(const ModInt &rhs) {
        x = x + rhs.x < mod ? x + rhs.x : x + rhs.x - mod;
        return *this; 
    }
    inline ModInt &operator-=(const ModInt &rhs) {
        x = x - rhs.x < 0 ? mod + x - rhs.x : x - rhs.x;
        return *this; 
    }
    inline ModInt &operator*=(const ModInt &rhs) {
        x = x * rhs.x % mod;
        return *this;
    }
    inline ModInt &operator/=(const ModInt &rhs) {
        return *this *= rhs.inv();
    }
    inline ModInt modpow(uint64_t n) {
        ModInt ret(1), mul(x); 
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    inline ModInt inv() const { return ModInt(x).modpow(mod - 2); }
    inline ModInt operator-() const { return ModInt(-x); }
    inline ModInt operator+(const ModInt &rhs) const { return ModInt(x) += rhs; }
    inline ModInt operator-(const ModInt &rhs) const { return ModInt(x) -= rhs; }
    inline ModInt operator*(const ModInt &rhs) const { return ModInt(x) *= rhs; }
    inline ModInt operator/(const ModInt &rhs) const { return ModInt(x) /= rhs; }
    inline bool operator==(const ModInt &rhs) const { return x == rhs.x; }
    inline bool operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { int64_t i; is >> i; rhs = ModInt(i); return is; }
};

using Mod = ModInt<1000000007>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long h, w, k; cin >> h >> w >> k;
    Mod a(1), b, c;
    for (long long i = h + w - 2; i > h + w - k; i--) {
        a *= Mod(i);
    }
    b = a * (h + w - 1); c = b * (h + w);
    a *= Mod(k - 1) * Mod(k) * Mod(k + 1) / Mod(3) * Mod(h * w);
    b *= Mod(k) * Mod(k + 1) / Mod(2) * Mod(h + w);
    c *= Mod(k);
    cout << a + b + c << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N){
    string t = to_string(N);
    int i = t.size()-1;
    string ans = "";
    if(t[i] == '2' || t[i] == '4' || t[i] == '5' || t[i] == '7' || t[i] == '9') ans = "hon";
    if(t[i] == '0' || t[i] == '1' || t[i] == '6' || t[i] == '8') ans = "pon";
    if(t[i] == '3') ans = "bon";
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int x;
    cin>>x;
    long int ans=0;
    while(x>=500)
    {
        x=x-500;
        ans+=1000;
    }
    x=x/5;
    x*=5;
    ans+=x;
    cout<<ans<<endl;
        
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpii;

const int MAXN=1e5;

int p[MAXN],rnk[MAXN];
int N,X[MAXN],Y[MAXN];
vpii v1,v2;
vector<pair<int,pair<int,int> > > V;

int find(int v) {
	if(p[v]==v) return v;
	else return p[v]=find(p[v]);
}

void merge(int v, int u) {
	v=find(v);
	u=find(u);
	if(rnk[v]>rnk[u]) p[u]=v;
	if(rnk[v]<rnk[u]) p[v]=u;
	if(rnk[v]==rnk[u])p[u]=v,rnk[v]++;
}

ll f() {
	ll ans=0;
	int cnt=0;
	FOR(i,0,N) p[i]=i;
	FOR(i,0,N) rnk[i]=0;
	sort(V.begin(),V.end());
	FOR(i,0,V.size()) {
		int c=V[i].first;
		int v=V[i].second.first;
		int u=V[i].second.second;
		if(find(v)!=find(u)) {
			merge(v,u);
			ans+=c;
			cnt++;
			if(cnt==N-1) return ans;
		}
	}
}

int main() {
	ri(N);
	FOR(i,0,N) {
		rii(X[i],Y[i]);
		v1.pb({X[i],i});
		v2.pb({Y[i],i});
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	FOR(i,0,N-1) {
		int v=v1[i].second;
		int u=v1[i+1].second;
		int d=v1[i+1].first-v1[i].first;
		V.pb({d,{v,u}});
	}
	FOR(i,0,N-1) {
		int v=v2[i].second;
		int u=v2[i+1].second;
		int d=v2[i+1].first-v2[i].first;
		V.pb({d,{v,u}});
	}
	printf("%lld\n",f());
}


Measured memory_bytes: 7912
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <cstring>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
    return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
    return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
    return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
    return forall_a_in_P.second > forall_b_in_P.second;
}

int main()
{
    int n;
    cin >> n;
   // cout<<n<<endl;
    vector<vector<pair<int, int>>> prep(n);
    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x, y;
            cin >> x >> y;
            x--;
            prep[i].push_back(make_pair(x, y));
        }
    }
    int ans = 0;
    rep(i, pow(2, n) )
    {
        vector<bool> ishonest(n, false);
        
        int cnt = 0;
        bool ok = true;
        rep(j, n)
        {
            if (i & (1 << j))
            {
                ishonest[j] = true;
                cnt++;
            }
        }
        rep(j, n)
        {
            bool hon = ishonest[j];
            if (hon)
            {
                rep(k, prep[j].size())
                {
                    //cout<<j<<" "<<k<<endl;
                    bool cond = prep[j][k].second;
                    if (ishonest[prep[j][k].first] == cond)
                    {
                    }
                    else
                    {
                        ok = false;
                        k = prep[j].size() + 1;
                    }
                }
            }
        }
        if (ok)
        {
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}


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

int main() {

  string S;

  cin >> S;

  if(S == "RRR"){
    cout << 3 << endl;
    return 0;
  }else if(S == "SRS" || S =="SSR" || S == "RSS" || S == "RSR"){
    cout << 1 << endl;
    return 0;
  }else if(S == "RRS" || S == "SRR"){
    cout << 2 << endl;
    return 0;
  }else{
    cout << 0 << endl;
    return 0;
  }

}


Measured memory_bytes: 3616
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = InputNumList();
            var n = nk[0];
            var k = nk[1];
            double ans = 0;
            for (int i = 1; i <= n; i++)
            {
                double tmp = 1.0 / n;
                double now = i;
                while (now < k)
                {
                    now *= 2;
                    tmp *= 0.5;
                }
                ans += tmp;
            }
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    set<int> from_s;
    set<int> to_g;
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        if(a==1) from_s.insert(b);
        if(b==n) to_g.insert(a);
    }
    for(auto k:from_s){
        if(to_g.count(k)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29
int main(){

int n;
cin >> n ;
int s;
int h[n];
int pre=0;
cin >> pre;
int mini=0;
int temp=0;
for(int i=1;i<n;i++){

cin >> s;
if(pre>=s)temp++;
else temp=0;
pre=s;
mini=max(mini,temp);
}

cout << mini;



}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(n);
		rep(i,n) cin>>a[i];

		vi b(n+1),ispow(n+1);
		rep(i,n){
			b[i]=31-__builtin_clz(a[i]);
			ispow[i]=a[i]==(1<<b[i]);
		}

		int res=0;
		rep(i,n){
			if(b[i]==b[i+1]&&!ispow[i]){
				res++;
				ispow[i+1]=1;
			}
			if(b[i]>b[i+1]){
				res+=!ispow[i]+(b[i]-b[i+1]);
				ispow[i+1]=1;
			}
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 1408
import numpy as np


N = input()
N = int(N)

def make_base_list(N):
    base_list = []
    for i in range(100):
        if N == 0:
            break
        if abs(N) % 2 == 0:
            base_list.append(int(0))
        else:
            base_list.append(int(1))
            if i % 2 == 0:
                N -= 1
            else:
                N += 1
        N = int(N)
        N = N // 2

        #print(N)
    # print(base_list)
    return base_list

def base_list_to_str(list):
    list = list[::-1]
    return ''.join([str(n) for n in list])


if __name__ == '__main__':
    if N == 0:
        print(str(0))
    else:
        print(base_list_to_str(make_base_list(N)))


Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
const int N=15,M=1010;
int s[N][M];
char str[N][M];
int arr[N];
int main()
{
    int n,m,t;
    cin>>n>>m>>t;
    int ans=1e9;
    for(int i=1;i<=n;i++)scanf("%s",str[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<m;j++)s[i][j+1]=str[i][j]-'0';
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
    for(int i=0;i<(1<<(n-1));i++)
    {
        memset(arr,0,sizeof arr);
        vector<int> p;
        int cnt1=0;
        int cnt2=0;
        p.push_back(0);
        for(int j=0;j<n-1;j++)
        {
            if(i>>j&1)p.push_back(j+1),cnt1++;
        }
        p.push_back(n);
        int now[N];
        bool st=true;
        for(int j=1;j<=m;j++)
        {
            for(int k=1;k<p.size();k++)
            {
                now[k]=s[p[k]][j]-s[p[k-1]][j]-s[p[k]][j-1]
                    +s[p[k-1]][j-1];
            }
            bool h=false;
            for(int k=1;k<p.size();k++)
            {
                if(arr[k]+now[k]>t){
                    h=true;
                    break;
                }
            }
            if(h){
                cnt2++;
                for(int k=1;k<p.size();k++)
                {
                    arr[k]=now[k];
                    if(now[k]>t){
                        st=false;
                        break;
                    }
                }
            }else{
                for(int k=1;k<p.size();k++)
                {
                    arr[k]+=now[k];
                }
            }
        }
        // cout<<cnt1<<' '<<cnt2<<endl;
        if(st)ans=min(ans,cnt1+cnt2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=sc.nextInt();double d=sc.nextDouble();
        long ans=0,mod=1000000007;
        while(t-->0)
        {
         long x=sc.nextLong(),y=sc.nextLong();
         double p=Math.sqrt(x*x+y*y);
         if(p<=d) ans++;
        }
        pw.println(ans);
           pw.close();
    }
}
  

Measured memory_bytes: 54788
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a; cin >> a;
  if (a < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}


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

using namespace std;
typedef long long ll;

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

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

  if(n*a>b)
    cout << b << endl;
  else
    cout << n*a << endl;


  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
int main(){
    std::vector<int> a(4);
    rep(i,4)std::cin >> a[i];
    ll n;
    std::cin >> n;
    n*=4;
    rep(i,3){
        if(a[i]*2<a[i+1])a[i+1]=a[i]*2;
    }
    reverse(all(a));
    std::vector<ll> d{8,4,2,1};
    ll ans=0;
    //erep(i,a)std::cout << i << std::endl;
    rep(i,4){
        ans+=(n/d[i])*a[i];
        n%=d[i];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    if(c>=d&&c>=e)
    {
        cout<<c;
    }
    else if(d>=c&&d>=e)
    {
        cout<<d;
    }
    else if(e>=c&&e>=d)
    {
        cout<<e;
    }


    return 0;
}


Measured memory_bytes: 256
def isPrime(N):
	"""
	O(sqrt(N))
	"""
	if N<=1:
		return False
	for i in range(2, int(N**.5)+1):
		if N%i==0:
			return False
	return True


prime = [False]*(10**5+1)
for i in range(1,10**5+1):
	prime[i] = isPrime(i)

likely =  [False]*(10**5+1)
for i in range(1, 10**5+1):
	if i%2==1 and prime[i] and prime[(i+1)//2]:
		likely[i] = True

for i in range(1,10**5+1):
	likely[i] += likely[i-1]

Q = int(input())
l = [0]*Q
r = [0]*Q
for i in range(Q):
	l[i],r[i] = map(int, input().split())

for i in range(Q):
	print(likely[r[i]]-likely[l[i]-1])


Measured memory_bytes: 15800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long a, long long b, long long x)
{
    ll ans;
    if (a != 0)
    {
        ans = b / x - (a - 1) / x;
    }
    else
    {
        ans = b / x + 1;
    }
    cout << ans << endl;
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long x;
    scanf("%lld", &x);
    solve(a, b, x);
    return 0;
}


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

int main()
{
    int n, x;
    while (cin >> n >> x) {
        if (n == 0 && x == 0) break;
        int count = 0;
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++)
                for (int k = j + 1; k < n; k++)
                    if (i + j + k + 3 == x)
                        count += 1;
        cout << count << endl;
    }
}



Measured memory_bytes: 3088
import sys

N, M = map(int, input().split())

pm = [(i,j,k) for i in range(-1,2,2) for j in range(-1,2,2) for k in range(-1,2,2)]
lst = []

for _ in range(N):
  x,y,z = map(int, input().split())
  lst.append((x,y,z))

rlt = -sys.maxsize
for a,b,c in pm:
  tmp = []
  for x,y,z in lst:
    tmp.append(a*x+b*y+c*z)
  tmp.sort(reverse=True)
  rlt = max(rlt, sum(tmp[:M]))
  
print(rlt)

Measured memory_bytes: 9212
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

const ll V = 100000;
using P = pair<ll, ll>;
vector<P> G[V];	//pair<辺の距離, 行き先の頂点>
vector<P> GG[V];
vector<ll> dist(V); //dist[i]はsから頂点iへの最短距離が入る
vector<bool> used(V);
void dijkstra(ll s) {	//s : 始点
						//初期化
	fill(dist.begin(), dist.end(), INF);
	fill(used.begin(), used.end(), false);

	priority_queue<P, vector<P>, greater<P>> q;
	q.push(P(0, s));
	while (!q.empty()) {
		ll d;	//d : sからの距離
		ll t;	//t ; 行き先
		tie(d, t) = q.top();
		q.pop();
		if (used[t]) {	//もう探索済みか
			continue;
		}
		used[t] = true;
		dist[t] = d;
		for (P e : G[t]) {
			if (dist[e.second] <= d + e.first) {	//枝刈り
				continue;
			}
			q.push(P(d + e.first, e.second));
		}
	}
}

int main() {
	ll n, m, s, t;
	
	cin >> n >> m >> s >> t;

	vector<pair<ll, ll>> v(n, make_pair(0, 0));

	REP(i, m) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		G[u - 1].push_back(make_pair(a, v - 1));
		G[v - 1].push_back(make_pair(a, u - 1));
		GG[u - 1].push_back(make_pair(b, v - 1));
		GG[v - 1].push_back(make_pair(b, u - 1));
	}

	dijkstra(s - 1);

	REP(i, n) {
		v[i].first += dist[i];
	}

	REP(i, V) {
		G[i] = GG[i];
	}

	dijkstra(t - 1);

	REP(i, n) {
		v[i].first += dist[i];
		v[i].second = i;
	}

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

	ll now = 0;

	REP(i, n) {
		FOR(j, now, n) {
			if (i > v[j].second) {
				now++;
			}
			else {
				cout << 1000000000000000 - v[j].first << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 20704
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let s = Set(Array(readLine()!))
    
    if s.count == 1 {
        print("No")
    } else {
        print("Yes")
    }
}

main()


Measured memory_bytes: 7996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;


#define MAX_N 100ll 
#define COUT(str) cout << str << endl

//入力
char s1[MAX_N+1], s2[MAX_N+1], s3[MAX_N+1];

int main() {

	scanf("%s %s %s", &s1,&s2,&s3);
	printf("%c%c%c\n",s1[0],s2[0],s3[0]);  
	return 0;
}


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

const int N=2010;
bool mp[N][N],good[N][N];
int deep[N][N];
int L[N],R[N];
int s[N],top;
char ss[N];
int H,W,ans=0;

int main()
{
    scanf("%d%d",&H,&W);
    for(int i=1;i<=H;i++)
    {
        scanf("%s",ss+1);
        for(int j=1;j<=W;j++)
            mp[i][j]=(ss[j]=='#');
    }
    for(int i=1;i<H;i++)
        for(int j=1;j<W;j++)
        {
            int cnt=mp[i][j]+mp[i+1][j]+mp[i][j+1]+mp[i+1][j+1];
            good[i][j]=!(cnt&1);
        }
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
            deep[i][j]=good[i][j]?deep[i-1][j]+1:0;
    for(int i=1;i<=H;i++)
    {
        s[top=1]=0;
        for(int j=1;j<W;j++)
        {
            while(top&&deep[i-1][s[top]]>=deep[i-1][j]) top--;
            L[j]=s[top];s[++top]=j;
        }
        s[top=1]=W;
        for(int j=W-1;j>=1;j--)
        {
            while(top&&deep[i-1][s[top]]>=deep[i-1][j]) top--;
            R[j]=s[top];s[++top]=j;
        }
        for(int j=1;j<W;j++)
            ans=max(ans,(deep[i-1][j]+1)*(R[j]-L[j]));
    }
    ans=max(ans,max(H,W));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 23936
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d=a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y -= (a/b)*x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (x%m+m)%m;
}

int main(){
    int n;
    cin >> n;
//    ll m1 = 99989, m2 = 99991;
    ll m1 = 2077753, m2 = 2077769;
    ll t1=0,t2=0;
    int op,y;
    for(int i=0;i<n;i++){
        cin >> op >> y;
        if(op == 1){
            t1 = (t1+y)%m1;
            t2 = (t2+y)%m2;
        }else if(op == 2){
            t1 = (t1-y%m1+m1)%m1;
            t2 = (t2-y%m2+m2)%m2;
        }else if(op == 3){
            t1 = (t1*y)%m1;
            t2 = (t2*y)%m2;
        }else{
            t1 = (t1*mod_inverse(y,m1))%m1;
            t2 = (t2*mod_inverse(y,m2))%m2;
        }
    }
    ll a,b;
    extgcd(m1,m2,a,b);
    ll res = (m1*t2*a+m2*t1*b)%((ll)m1*m2);
    while(res >= (1ll<<31)){
        res -= (ll)m1 * m2;
    }
    cout << res << endl;
}

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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define print_vec(vec) for(int i=0;i<sz(vec);i++) cout << vec[i] << " ";
#define FORin(vec) for(int& x : vec) cin>>x;

void go(){
	char c;cin>>c;
	c++;
	cout << c;
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main() {
  int N, H, W;
  cin >> N >> H >> W;

  int A, B;
  int C = 0;
  for (int i = 1; i <= N; i++) {
   cin >> A >> B;
   if (A >= H && B >= W) C++;
  }

  cout << C << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;

long long cnt[300];
char c[] = {'M', 'A', 'R', 'C', 'H'};

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("input.in", "r", stdin);
	int n; cin >> n;
	for(int i = 0; i < n; i++)
	{
		string s; cin >> s;
		cnt[s[0]]++;
	}
	long long res = 0;
	for(int i = 0; i < 5; i++)
		for(int j = i+1; j < 5; j++)
			for(int k = j+1; k < 5; k++)
				res += cnt[c[i]]*cnt[c[j]]*cnt[c[k]];

	cout << res << "\n";
}






Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int a,b;
  char s[10];
  scanf("%d %d %s",&a,&b,s);

  for(int i=0; i<a+b+1; i++){
    if(i<a || i>a){
      if(s[i] == '-'){
       printf("No");
       return 0;
      }
    }

    if(i == a){
      if(s[i] != '-'){
       printf("No");
       return 0;
      }
    }
  }
  printf("Yes");
  return 0;

}



Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%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;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    string s;
    cin >> s;
    map<char,int> seen;
    rep(i,s.size()){
        seen[s[i]]++;
    }
    rep(i,26){
        if(seen[(char) ('a' + i)]%2 ==1){
            cout << "No"; rn 0;
        }
    }
    cout << "Yes";
}


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

using namespace std;


long long int yuku(long long int x,long long int y){
	long long int t=x%y;
	x=y;
	y=t;
	if(y==0)return x;
	else yuku(x,y);


};
long long int yu(long long int x,long long int y,long long int sum){
	long long int t=x%y;
	x=y;
	y=t;
	sum++;
	if(y==0)return sum;
	else yu(x,y,sum);


};
 
int main(){

long long int x,y;
while(1){
cin>>x>>y;if(x==y&&x==0)break;
if(y>x)swap(x,y);
long long int R=yuku(x,y);
long long int sum=0;
sum=yu(x,y,sum);

cout<<R<<" "<<sum<<endl;
}
return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>

using namespace std; using ll=long long; const int INF=1e2; using P=pair<int,int>;

int main() {
  ll n; cin>>n;
  ll a[n], b[n], c[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) cin>>c[i];
  sort(a,a+n); sort(b,b+n); sort(c,c+n);

  ll d[n]={}, e[n]={};

  for(int i=0;i<n;i++) {
    auto it = upper_bound(b,b+n,a[i]);
    if (it == b+n) continue;
    d[it-b]++;
  }

  for(int i=1;i<n;i++) {
    d[i] += d[i-1];
  }

  for(int i=0;i<n;i++) {
    auto it = upper_bound(c,c+n,b[i]);
    if (it == c+n) continue;
    e[it-c]+=d[i];
  }

  for(int i=1;i<n;i++) {
    e[i] += e[i-1];
  }

  ll an=0;
  for(int i=0;i<n;i++) {
    an += e[i];
  }
  cout<<an<<endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll dp[3333][3333];
ll n,a[3333];

ll dfs(ll l,ll r) {
  if(dp[l][r]!=MAXL) return dp[l][r];
  if(r<l) return 0;
  if((n-abs(l-r))%2) {
    ll x=dfs(l+1,r)+a[l];
    ll y=dfs(l,r-1)+a[r];
    dp[l][r]=max(x,y);
  } else {
    ll x=dfs(l+1,r)-a[l];
    ll y=dfs(l,r-1)-a[r];
    dp[l][r]=min(x,y);
  }
  return dp[l][r];
}

void Main() {
  rep(i,3333)rep(j,3333) dp[i][j]=MAXL;
  R n;
  rep(i,n) R a[i];
  pr(dfs(0,n-1));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 87168
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No");





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,d=0,e=0;
	cin>>a>>b;
	int c[b+1];
	for(int i=1;i<=b;i++)
	cin>>c[i];
	for(int i=0;i<=b;i++)
	{
		d=0;
		e=0;
		for(int k=1;k<=b;k++)
		{
			if(a+i==c[k])
			{
				d++;
 			}
			if(a-i==c[k])
			{
				e++;
			}
		}
		if(e==0)
		{ 
			cout<<a-i<<endl;
			return 0; 
		} 
		if(d==0)
		{
			cout<<a+i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#define N 50000

int main()
{
  int i,j,n;
  int prime[N];
  for (i=0;i<N;i++){
    prime[i]=1;
  }
  prime[0]=0;
  for (i=1;i<(int)sqrt(N);i++){
    if (prime[i]==1){
      for (j=i+1;(i+1)*j<=N;j++){
        prime[(i+1)*j-1]=0;
      }
    }
  }
  while(scanf("%d",&n)){
    if (n==0)
      break;
    int cnt=0;
    for (i=1;i<n;i++){
      if (i>=n/2)
        break;
      if (prime[i]==1)
        if (prime[n-(i+2)]==1)
          cnt++;
    }
    printf("%d\n",cnt);
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans = INT_MAX;
  for(int i=1;i<=100;i++){
    int cnt=0;
    for(int j=0;j<n;j++){
      cnt+=(i-a[j])*(i-a[j]);
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	int N, M;
	int citys[128];

	while (cin >> N >> M)
	{
		memset(citys, 0, sizeof (citys));
		for (int i=0; i<M; ++i)
		{
			int a, b;
			cin >> a >> b;
			++ citys[a];
			++ citys[b];
		}

		for (int i=1; i<=N; ++i)
		{
			cout << citys[i] << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, c = 0;
    cin >> n;
    ll arr[n + 5];
    for(int i = 1;i <= n;++i)
    {
        ll x;
        cin >> x;
        c += (x != i);
    }
    cout << (c <= 2 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
L = []
for i in range(N):
    c, p = input().split()
    p = int(p)
    L.append([i+1, c, p])
L = sorted(L, key=lambda x: (x[1], -x[2]))
for i in range(N):
    print(L[i][0])


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    set<int> ss;
    int q;
    cin >> q;
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            cout << ss.count(x) << endl;
        } else if (t == 0) {
            ss.insert(x);
            cout << ss.size() << endl;
        } else if (t == 2) {
            ss.erase(x);
        } else {
            int r;
            cin >> r;
            auto it = ss.lower_bound(x);
            for (; it != ss.end(); it++) {
                if (x <= *it && *it <= r) {
                    cout << *it << endl;
                }
                if (*it > r) break;
            }
        }
    } 
}


Measured memory_bytes: 12436
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main (){
    int n,l;
    string ans;
    cin >> n >> l;
    vector<string> a(n);
    rep(i,n){
        string s;
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    rep(i,n){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <math.h>

using namespace std;

int N,i;
int main() {
    cin >> N;
    long A[100005],B[100005];
    long long point = 0;
    long C[100005];
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    for (int i = 0; i < N; ++i){
        C[i] = A[i] + B[i];

    }
    sort(C, C + N, greater<int>());
    for (int i = 0; i < N; i+=2){
        point += C[i];
    }
    for (int i = 0; i < N; ++i){
        point -= B[i];
    }
    cout << point << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ma = A[N - 1];
  vector<int> diff;
  for (int i = N - 2; i >= 0; i--) {
    if (ma < A[i]) {
      ma = A[i];
    } else {
      diff.emplace_back(ma - A[i]);
    }
  }
  sort(diff.begin(), diff.end(), greater<int>());
  int res = 1;
  for (int i = 0; i < diff.size() - 1; i++) {
    if (diff[i] == diff[i + 1])
      res++;
    else
      break;
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
  int an[3];rep(i,3)cin>>an[i];
  sort(an, an+3);
  int c=3;
  if (an[0]==an[1])c--;
  if (an[1]==an[2])c--;
  cout << c;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=1e9+7;
map<ll,ll>m;
ll solve(ll n)
{
    if(m[n])return m[n];
    return m[n]=(solve(n/2)+solve((n-1)/2)+solve((n-2)/2))%mod;
}
int main()
{
    ll n;scanf("%lld",&n);
    m[0]=1,m[1]=2;
    printf("%lld\n",solve(n));
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let max_n = 10e5 as usize + 1;
    let q = read();

    let mut is_prime = vec![true; max_n];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..max_n {
        if i * i > max_n {
            break;
        } 
        if is_prime[i] {
            let mut j = 2;
            while i * j < max_n {
                is_prime[i * j] = false;
                j += 1;
            }
        }    
    }

    let is_2017like: Vec<i32> = (0..max_n).map(|n| (n % 2 == 1 && is_prime[n] && is_prime[(n + 1) / 2]) as i32).collect();
    let acc_sum = accumulate_each(is_2017like.iter(), add, 0);

    for _ in 0..q {
        let (l, r) = read_tuple::<usize>();
        println!("{:?}", acc_sum[r + 1] - acc_sum[l]);
    }
}

fn add<T: std::ops::Add<Output=T>>(a: T, b: T) -> T{
    a + b
}

fn accumulate_each<T: std::clone::Clone>(iterable: std::slice::Iter<T>, func: fn(T, T) -> T, init: T) -> Vec<T> {
    let mut res = Vec::new();
    let mut acc = init.clone();
    res.push(acc.clone());
    for element in iterable {
        acc = func(acc, element.clone());
        res.push(acc.clone());
    }
    res
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 15092
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<utility>

using namespace std;

int main(){
	long long h, w, n;
	cin >> h >> w >> n;
	map<pair<long long, long long>, long long> mp;
	for(int i = 0; i < n; i++){
		long long a, b, c, d;
		cin >> a >> b;
		c = min(a, h - 2);
		d = min(b, w - 2);
		for(int j = max(a - 2, 1LL); j <= c; j++){
			for(int k = max(b - 2, 1LL); k <= d; k++){
				mp[{j, k}]++;
			}
		}
	}
	vector<long long> ans(10);
	for(auto&& i : mp){
		ans[i.second]++;
	}
	ans[0] = (h - 2) * (w - 2);
	for(int i = 1; i < 10; i++){
		ans[0] -= ans[i];
	}
	for(int i = 0; i < 10; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];

  int i=0,r=0; int dp[n];
  dp[0]=0; dp[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
  	dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024