akhauriyash/Code-Regression huggingface dataset:
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> ps(n); cin >> ps;
    vector<int> minis(n), maxis(n);
    vector<int> sorted(n);
    {
        set<int> st;
        for(int i = 0; i < k - 1; i++){
            st.insert(ps[i]);
        }
        for(int i = k - 1; i < n; i++){
            st.insert(ps[i]);
            maxis[i] = *st.rbegin() == ps[i];
            printde(st, *st.rbegin(), ps[i]);
            st.erase(ps[i - k + 1]);
        }
    }
    {
        set<int> st;
        for(int i = 0; i < k - 1; i++){
            st.insert(ps[n - 1 - i]);
        }
        for(int i = k - 1; i < n; i++){
            st.insert(ps[n - 1 - i]);
            minis[n - 1 - i] = *st.begin() == ps[n - 1 - i];
            printde(st, *st.begin(), ps[i]);
            st.erase(ps[n - 1 - i + k - 1]);
        }
    }
    {
        set<int> st;
        int idx = 0;
        for(int i = 0; i < n; i++){
            st.insert(ps[i]);
            while(*st.rbegin() != ps[i]){
                st.erase(ps[idx++]);
            }
            printde(i, st);
            sorted[i] = (int)st.size() >= k;
        }
    }
    // vector<int> ps2 = ps;
    // sort(ps2.begin(), ps2.end());
    // int cnt = 0;
    // for(int i = 0; i < k - 1; i++){
    //     cnt += ps[i] == ps2[i];
    // }
    // for(int i = k - 1; i < n; i++){
    //     cnt += ps[i] == ps2[i];
    //     sorted[i] = cnt == k;
    //     printde(i, cnt);
    //     cnt -= ps[i - k + 1] == ps2[i - k + 1];
    // }
    printde(maxis);
    printde(minis);
    printde(sorted);
    int ans = (bool)accumulate(sorted.begin(), sorted.end(), 0ll);
    ans += !sorted[k - 1];
    for(int i = 0; i < n - k; i++){
        ans += !(minis[i] && maxis[i + k]) && !sorted[i + k];
        // ans += !(minis[i] && maxis[i + k]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  ll N, A, B;

  cin >> N >> A >> B;
  A--; B--;

  if (A % 2 == B % 2) {
    cout << abs(A - B) / 2 << endl;
    return 0;
  }

  ll ans = LLINF;

  if (A > B) swap(A, B);

  //

  ans = min(ans, A + 1 + (B - A - 1) / 2);

  ll t = (N - 1) - B;

  ans = min(ans, t + 1 + ((N - 1) - (A + t + 1)) / 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    ll n,m;
    cin >> n >> m;
    if(n*m==1){
        cout << 1 << endl;
    }else if(n==1 or m == 1){
        cout << max(n,m)-2 << endl;
    }else{
        cout << (n-2)*(m-2) << endl;
    }
}

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

int main() {
	int x; cin >> x; x %= 7;
	switch (x) {
	case 1: cout << "fri" << endl; break;
	case 2: cout << "sat" << endl; break;
	case 3: cout << "sun" << endl; break;
	case 4: cout << "mon" << endl; break;
	case 5: cout << "tue" << endl; break;
	case 6: cout << "wed" << endl; break;
	case 0: cout << "thu" << endl; break;
	}
	return 0;
}


Measured memory_bytes: 3096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

main(){
  int n,k;
  int x,y;
  cin >> n;
  cin >> k;
  for(int i=0;i<k;i++){
    cin >> x >> y;

    if(n/2>=y){
      if(y<=x && x<=n-(y-1)){
	cout << (y+2)%3+1 <<endl;
	continue;
      }
    }
    else{
      if((n-y)<x && x<n-(n-y-1)){
	cout << ((n-y)%3)+1 << endl;
	continue;
      }
    }

    if(n/2>=x){
      if(x<=y && y<=n-(x-1)){
	cout << (x+2)%3+1 <<endl;
	continue;
      }
    }
    else{
      if((n-x)<y && y<n-(n-x-1)){
	cout << ((n-x)%3)+1 << endl;
	continue;
      }
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
ll dp[20001];
void pre()
{
    dp[0]=0;
    dp[1]=0;
    dp[2]=0;
    dp[3]=1;
    for(int i=4; i<=2000; i++)
    {
        dp[i] = (dp[i-1]%MOD+dp[i-3]%MOD)%MOD;
    }
}
int main()
{
    pre();
    int n;
    cin >> n;
    cout << dp[n] << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15;
const ll N=700+10;

int main()
{
	boost;
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	cout << fixed << setprecision(10) <<((long double)(w*h))/2;
	if((w%2==0 and w/2 ==x ) and (h%2==0 and h/2==y))
	{
		
		cout<<" 1";
	}
	else cout<<" 0";
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n,i;
  char s[110];
  scanf("%d%s",&n,s);
  if(n%2==1){
    printf("No\n");
  }
  else{
    for(i=0;i<n/2;i++)
      if(s[i]!=s[n/ 2+i]){
        printf("No\n");
        return 0;
      }
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

typedef struct result {
    int exchange;
    vector<int> a;
} result;

result selection_sort(vector<int> v) {
    int tmp, min_i;
    result res;
    
    res.exchange = 0;
    
    for(int i = 0;i < v.size();i++) {
        min_i = i;
        
        for(int j = i;j < v.size();j++) {
            if(v[j] < v[min_i]) {
                min_i = j;
            }
        }
        
        if(i != min_i) {
            res.exchange++;
            
            tmp = v[i];
            v[i] = v[min_i];
            v[min_i] = tmp;
        }
    }
    
    res.a = v;
    
    return res;
}

void print_attr(result res) {
    for(int i = 0;i < res.a.size();i++) {
        cout << res.a[i];
        
        if(i < res.a.size() - 1) {
            cout << " ";
        }
    }
    
    
    cout << endl << res.exchange << endl;
}

int main() {
    int n;
    vector<int> v;
    result res;
    
    cin >> n;
    
    v.resize(n);
    
    for(int i = 0;i < n;i++) {
        cin >> v[i];
    }
    
    res = selection_sort(v);
    
    print_attr(res);
    
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  bool UP   = false ;
  bool DOWN = false ;
  int ans =  0 ;
  vector<int> v(n) ;
  rep(i,n) cin >> v.at(i) ;
  
  rep(i,n-1){
    if( !UP && !DOWN){
      if(v.at(i) > v.at(i+1)) DOWN = true ;
      if(v.at(i) < v.at(i+1)) UP   = true ;
    }
    if(UP){
      if(v.at(i) > v.at(i+1)){
        ans ++ ;
        UP = false ;
      }
    }
    if(DOWN){
      if(v.at(i) < v.at(i+1)){
        ans ++ ;
        DOWN = false ;
      }
    }
  }
    cout << ans + 1  << endl ;
    
  

}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define endll "\n"
#define show(a) cerr<<""#a""<<" is "<<a<<endll;
int caseno=0;
#define print_case cout<<"Case "<<++caseno<<": ";
#define fout freopen("output.txt","w",stdout);
#define fin freopen("input.txt","r",stdin);
#define srt(v) sort(v.begin(),v.end());
#define greatersrt(v) sort(v.begin(),v.end(),greater<ll>())
#define pb push_back
#define mp make_pair
#define here cerr<<"here\n";
#define PI acos(-1.0)
#define ll long long
#define ld long double
#define reto exit(0);
#define sspace <<" "<<
#define print(arr,xx) for(int i=0;i<xx;i++)cerr<<arr[i]<<" \n"[i==n];
bool sortbysec(pair<int,int>a,pair<int,int>b){return a.second>b.second;}
ll gc(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lc(ll a,ll b){return a/gc(a,b)*b;}
const int primemod=1e9+7;
const ld eps=1e-9;
#define inl(x) scanf("%lld",&x)
#define in(x) scanf("%d",&x)
#define pii pair<int,int>
/**Code Goes Here**/
#define maxsize 200000+9
#define rshuffle(r...)rshuffle(r,[](int _){return rand()%_;})
int arr[maxsize];
int main()
{
    int n;
    in(n);
    int arr[n+1],dp[n+1];
    memset(dp,INT_MAX, sizeof dp);
    dp[0]=0;
    for(int i=1;i<=n;i++){
        in(arr[i]);
    }
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    //print(dp,n+1);
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
P = [int(x) for x in input().split()]

def main(N, K, P):
    S = [0] * N
    E = [0] * N
    for i in range(N):
        n = P[i]
        S[i] = n * (n+1)/2/n
    if K == N:
        return sum(S)
    a = 0
    E[K-1] = sum(S[:K])
    for i in range(K, N):
        E[i] = E[i-1] - S[i-K] + S[i]
        a = max(a, E[i])
    return a
print(main(N, K, P))


Measured memory_bytes: 25060
//In the name of "ALLAH"//
#include<stdio.h>
int main()
{
    char c;
    scanf("%c", &c);

    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
    {
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}


Measured memory_bytes: 1560
#include "stdio.h"
#include "math.h"

#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0081 : A Symmetric Point **/
int main()
{
	double x1, y1, x2, y2, xq, yq; char c;
	while (cin >> x1 >> c >> y1 >> c >> x2 >> c >> y2 >> c >> xq >> c >> yq) {
		if (x1==x2)
			printf("%.6f %.6f\n", 2*x1-xq , yq);
		else if (y1==y2)
			printf("%.6f %.6f\n", xq , 2*y1-yq);
		else {
			double a = (y2-y1)/(x2-x1);
			double aa = -1/a;
			double b = y1 - a*x1;
			double bb = yq - aa*xq;
			double xm = (bb - b)/(a - aa);
			printf("%.6f %.6f\n", 2*xm-xq , aa*(2*xm-xq)+bb);
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{

    string S, T;
    cin >> S >> T;

    int ans = T.size();

    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i])
            {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ins insert
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int N=220;

int n,qlist[N];

char rd[10],ans[N];

bool inl[N];

void query(int u){
	int l=u,r=u+n-1;
	printf("? ");
	for(int i=l;i<=r;i++){
		printf("%d%c",i," \n"[i==r]);
	}
	fflush(stdout);
}

void querylist(){
	printf("? ");
	for(int i=1;i<=n;i++){
		printf("%d%c",qlist[i]," \n"[i==n]);
	}
	fflush(stdout);
}

void answer(){
	printf("! %s\n",ans+1);fflush(stdout);
	exit(0);
}

void work(int u){
	int poss=1;
	for(int i=1;i<=n;i++){
		qlist[i]=u-1+i;
	}
	for(int i=1;i<=n;i++){
		if(ans[qlist[i]]==ans[u]){
			poss=i;break;
		}
	}
	for(int i=2;i<=n;i++){
		inl[qlist[i]]=1;
	}
	swap(qlist[poss],qlist[1]);
	for(int i=1;i<=(n<<1);i++){
		if(ans[i]^'U'||inl[i]){
			continue;
		}
		qlist[1]=i;
		querylist();
		scanf(" %s",rd);
		ans[i]=rd[0];
	}
	int pos[2][N]={0,0},cnt[2]={0,0};
	for(int i=1;i<=(n<<1);i++){
		if(ans[i]^'U'){
			if(ans[i]=='R'){
				pos[0][++cnt[0]]=i;
			}
			else{
				pos[1][++cnt[1]]=i;
			}
		}
	}
	memset(inl,0,sizeof inl);
	int cntq=1;
	for(int i=1;i<=(n>>1);i++){
		qlist[++cntq]=pos[0][i];
		inl[pos[0][i]]=1;
		qlist[++cntq]=pos[1][i];
		inl[pos[1][i]]=1;
	}
	for(int i=1;i<=(n<<1);i++){
		if(ans[i]^'U'||inl[i]){
			continue;
		}
		qlist[1]=i;
		querylist();
		scanf(" %s",rd);
		ans[i]=rd[0];
	}
	answer();
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=(n<<1);i++){
		ans[i]='U';
	}
	int lc=0,rc=0,l=1,r=n+1;
	query(1);
	scanf(" %s",rd);
	if(rd[0]=='B'){
		lc=1;
	}
	else{
		rc=1;
	}
	while(l+1<r){
		int mid=(l+r)>>1;
		query(mid);
		scanf(" %s",rd);
		int col=(rd[0]=='B'?1:0);
		if(rc^col){
			l=mid;
		}
		else{
			r=mid;
		}
		if(l>r){
			swap(l,r);swap(lc,rc);
		}
	}
	work(l);
	answer();
	return 0;
} 

Measured memory_bytes: 724
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            long[] countArr = new long[n + 1];
            for (int i = 0; i < n; i++) {
                countArr[arr[i]]++;
            }

            long ans = 0;
            for (int i = 1; i <= n; i++) {
                if (countArr[i] <= 1) {
                    continue;
                }

                ans += (countArr[i] - 1) * countArr[i] / 2;
            }

            for (int i = 0; i < n; i++) {
                if (countArr[arr[i]] <= 1) {
                    out.println(ans);
                } else {
                    out.println(ans - (countArr[arr[i]] - 1));
                }
            }
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 50804
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,ans=0;
  cin>>N;
  vector<int> A(N+1),B(N,0);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  for(int i=0;i<N;i++){
    if(A[i]>B[i])
      ans+=B[i];
    else{
      ans+=A[i];
      B[i]-=A[i];
      if(A[i+1]>B[i])
        ans+=B[i],A[i+1]-=B[i];
      else
        ans+=A[i+1],A[i+1]=0,B[i]-=A[i+1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	int n;
	std::cin >> n;
	V<mint> a(n);
	fill(a);
	mint sum=0;
	rep(i,n) sum+=a[i];
	mint ans=0;
	rep(i,n) {
		sum-=a[i];
		ans+=a[i]*sum;
	}
	print(ans);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){vector<ll> div;
	for(int i=1;i*i<=x;i++){if(i*i!=x && x%i==0){div.pb(i);div.pb(x/i);}else if(x%i==0) div.pb(i);}
	sort(div.bg,div.ed);return div;}
vector<ll> vectorprime(ll x){vector<bool> is_prime(x+1);vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){if(is_prime[i]){prime.pb(i);}for(int j=i*2;j<=x;j+=i) is_prime[j]=false;}
	return prime;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
    ll A,B; cin>>A>>B;
	ll cnt=0;
	for(int i=A;i<=B;i++){
		ll tmp=i,t1,t2,t3,t4,t5;
		t1=tmp/10000;
		tmp%=10000;
		t2=tmp/1000;
		tmp%=1000;
		t3=tmp/100;
		tmp%=100;
		t4=tmp/10;
		tmp%=10;
		t5=tmp;
		if(t5!=0 && t1==t5 && t2==t4) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d; cin >> a >>b >> c >> d;
    if(abs(a - c) <= d ||  abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	int N, max, out;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		long long int x = i * (i + 1) / 2;
		if (x - i < N && N <= x) {
			max = i;
			out = x - N;
			break;
		}
	}
	for (int i = 1; i <= max; i++) {
		if (i != out) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])
    ans = 0
    for h in range(H):
        for a in A[h]:
            if a >= 0:
                ans += C[a][1]
    print(ans)


main()


Measured memory_bytes: 3316
package main

import "fmt"

func main(){
  // line := make([]int, 3)
  // arr := make([][]int, 3)
  // arr[0] = line
  // arr[1] = line
  // arr[2] = line
  arr := make([][]int, 3)
  for i:=0; i<3; i++{
    arr[i] = make([]int, 3)
  }
  // fmt.Println(arr)
  fmt.Scan(&arr[0][0], &arr[0][1], &arr[0][2])
  fmt.Scan(&arr[1][0], &arr[1][1], &arr[1][2])
  fmt.Scan(&arr[2][0], &arr[2][1], &arr[2][2])
  // fmt.Println(arr)
  line1 := make([]int, 3)
  line2 := make([]int, 3)
  line3 := make([]int, 3)
  line4 := make([]int, 3)

  for i:=0; i<3; i++{
    line1[i] = arr[0][i] - arr[1][i]
    line2[i] = arr[1][i] - arr[2][i]
  }
  for i:=0; i<3; i++{
    line3[i] = arr[i][0] - arr[i][1]
    line4[i] = arr[i][1] - arr[i][2]
  }
  result := 1
  val1 := line1[0]
  val2 := line2[0]
  val3 := line3[0]
  val4 := line4[0]

  for i:=0; i<3; i++{
    if line1[i] != val1{
      result = 0
    }
    if line2[i] != val2{
      result = 0
    }
    if line3[i] != val3{
      result = 0
    }
    if line4[i] != val4{
      result = 0
    }
  }
  if result == 0{
    fmt.Println("No")
  }else{
    fmt.Println("Yes")
  }

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string S;
	cin >> S;
	S += "$";
	int s = 0, r = 0;
	for (char c : S) {
		if (c == 'R') {
			r = max(r, ++ s);
		} else {
			s = 0;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
vec<i32> a;

i32 main()
{
    cin >> n;
    a.resize(n);
    times(n, i) {
        cin >> a[i];
    }
    sortall(a);
    i64 sum = 0; times(n-1, i) sum += a[i];
    i64 acc = 0, ans = 1;
    downto(n-2, 0, i) {
        sum -= a[i];
        if (a[i+1] <= (a[i] + sum)*2) {
            acc += a[i+1];
        } else {
            acc = 0;
        }
        if ((sum + acc)*2 >= a[n-1]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

bool isOK(int &itr, int &key, vector<int> &v) {
  if(v[itr] >= key) return true;
  return false;
}

int bynary_search(int &key, vector<int> &v) {
  int ng = -1; int ok = (int)v.size();
  while(ok - ng > 1) {
    int mid = (ng + ok) / 2;
    if(isOK(mid, key, v)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  int N; cin >> N;
  long long cnt = 0; 
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  for(int i = 0; i < N; i++) cin >> B.at(i);
  for(int i = 0; i < N; i++) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  for(int i = 0; i < N; i++) {
    int b = B[i] + 1;
    int a = bynary_search(B[i], A);
    int c = bynary_search(b, C);
    c = N - c;
    cnt += (long long)a * (long long)c;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  double ave = (a + b) / 2.0;
  cout << ceil(ave) << endl;
  //cout << ave << endl;
}


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





int main(){
  int N,K,P;
  int ans;

  cin >> N;
  for(int i = 0; i<N; ++i){
    cin >> K >> P;

    ans = K % P;

    if(ans == 0){
      cout << P << endl;
    }else{
      cout << ans << endl;
    }
  }
  

  
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n;
    cin >> n;
    
    auto digits = [](lint n) -> lint {
        lint ans = 0;
        while (n > 0) {
            n /= 10;
            ++ans;
        }
        return ans;
    };
    
    auto bigger = [](lint n, lint m) -> lint {
        if (n > m) return n;
        else return m;
    };
    
    lint ans = 1e5;
    repeat_from_to (i, 1, sqrt(n)) {
        if (n % i == 0) {
            ans = min(ans, bigger(digits(n/i), digits(i)));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    ll k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    int keta = 1;
    int a = k;
    while (a >= 10) {
        a /= 10;
        keta++;
    }
    ll seven = 7;
    rep(i, 10) {
        if (seven % k == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        seven *= 10;
        seven += 7;
    }
    ll se = 0;
    rep(i, keta) {
        se *= 10;
        se += 7;
    }
    ll sese = 7;
    rep(i, 1000000) {
        if (sese % k == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        else {
            sese = (sese % k) * 10 + 7;
        }
    }
    cout << -1 << endl;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

ll p[10];

int main() {
    ll n, m, i, j, k;
    ll q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q), d(q);
    for(i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    ll ret = 0;
    function<void(ll,ll)> dfs = [&](ll pos,ll now) {
        if(pos == n) {
            ll tmp = 0;
            for(ll i = 0; i < q; i++) {
                if(p[b[i] - 1] - p[a[i] - 1] == c[i]) {
                    tmp += d[i];
                }
            }
            ret = max(ret, tmp);
        } else {
            for(ll i = now; i <= m; i++) {
                p[pos] = i;
                dfs(pos + 1,i);
            }
        }
    };
    dfs(0,1);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
std::vector<int> edge[100005];
int f(int pa,int idx){
  int res=0;
  for(int p:edge[idx]){
    if(p==pa)continue;
    res^=f(idx,p);
  }
  return res+1;
}
//main
signed main(){
  int N;cin>>N;
  for(int i=1;i<N;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if(f(-1,0)==1)fin("Bob");
  fin("Alice");
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n,k;cin >> n >> k;
    vector<LL> a(n);
    vector<long double> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = logl(a[i]);
    }
    vector<long double> c(n + 1, 0.0);
    for (int i = 0; i < n; i++) {
        c[i + 1] = c[i] + b[i];
    }
    long double t = c[k];
    for (int i = k + 1; i <= n; i++) {
        long double nt = c[i] - c[i - k];
        if(t + 1e-10 < nt) puts("Yes");
        else puts("No");
        t = nt;
    }
    return 0;
}


Measured memory_bytes: 11268
#include <iostream>
#include <map>
using namespace std;
using ll = long long;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  map<ll, ll> arr;
  ll a, b;
  for(int i = 0; i < N; ++i) {
    cin >> a >> b;
    arr[a] += b;
  }
  for(auto a : arr) {
    K -= a.second;
    if(K <= 0) {
      cout << a.first << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
from itertools import combinations_with_replacement as cmb

n,m,q=map(int,input().split())
abcd=[]
for i in range(q):
    ll=map(int,input().split())
    ll=[ww-1 for ww in ll]
    abcd.append(ll)
ans=0
for li in cmb(range(1,m+1),n):
    kari=0
    for i in abcd:
        if li[i[1]]-li[i[0]]==i[2]+1:
            kari+=i[3]+1
    ans=max(ans,kari)

print(ans)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long A,B;
  cin >> A >> B;

  long long n = B - A + 1;
  long long ans;

  if(A % 2 == 0) {
    if(n % 2 == 0) {
      if((n/2)%2 == 0) ans = 0;
      else ans = 1;
    }else {
      int c = (n-1)/2;
      if(c % 2 == 0) ans = B;
      else ans = B^1;
    }
  }else {
    if(n % 2 == 0) {
      int c = (n-2)/2;
      if(c%2 == 0) ans = A^B;
      else ans = A^B^1;
    }else {
      int c = (n-1)/2;
      if(c%2 == 0) ans = A;
      else ans = A^1;
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	long double n,k;
	cin>>n>>k;
	long double ans=0.0;
	for(int i=0;i<n;i++){
		long double d=1.0,ii=double(i)+1.0;
		while(k-ii>1e-18){
			ii*=((double)(2.0));
			d=d/((double)(2.0));
		}
		ans+=d;
	}
	printf("%.10Lf",(ans/n) );
}
int main()
{
	//waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  vi X(N);
  for (auto& x : X) {
    cin >> x;
  }

  int ret = INF;
  REP(i, N-K+1) {
    int a = X[i];
    int b = X[i+K-1];

    if (b<=0) {
      chmin(ret, -a);
    } else if (a<=0) {
      chmin(ret, -a*2+b);
      chmin(ret, -a+b*2);
    } else {
      assert(0<a);
      chmin(ret, b);
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e6+5;
int a[maxn];
int main(){
	int k,n;
	int ans=0;
	cin>>k>>n;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n-1;i++){
		ans=max(ans,abs(a[i]-a[i+1]));
	}
	ans=max(a[0]+k-a[n-1],ans);
	cout<<k-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;
typedef long long ll;

int n;
int x, y;
int cnt[100002];
const ll MOD = 1000000007;
ll frac[100002], frac_inv[100002];

ll modpow(ll a, ll b) {//a^b
	ll ans = 1, tmp = a;
	while (b > 0) {
		if (b & 1)ans *= tmp, ans %= MOD;
		tmp *= tmp;
		tmp %= MOD;
		b >>= 1;
	}
	return ans;
}



ll Comb(ll a, ll b) {
	if (a < b)return 0;
	ll ans = frac[a] * frac_inv[b];
	ans %= MOD;
	ans *= frac_inv[a - b], ans %= MOD;
	return ans;
}

int main() {
	//入力処理
	cin >> n;
	for (int i = 1; i <= n + 1; i++) {
		int tmp;
		cin >> tmp;
		if (cnt[tmp] == 0)cnt[tmp] = i;
		else x = cnt[tmp], y = i;
	}
	
	//逆元計算
	frac[0] = 1, frac_inv[0] = 1;
	ll tmp = 1;
	for (int i = 1; i <= 100001; i++) {
		tmp *= i, tmp %= MOD;
		frac[i] = tmp;
	}
	frac_inv[100001] = modpow(frac[100001], MOD - 2), frac_inv[100001] %= MOD;
	for (int i = 100000; i > 0; i--) {
		frac_inv[i] = frac_inv[i + 1] * (i + 1);
		frac_inv[i] %= MOD;
	}
	//計算部分
	cout << n << endl;
	for (int k = 2; k <= n + 1; k++) {
		ll ans = 0;
		ans = Comb(n + 1, k);
		ans -= Comb(x + (n - y), k - 1);
		ans += MOD;
		ans %= MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
bool is_second(int a, int b, int c){
  vi p = {a,b,c};
  sort(all(p));
  return p[1]==b;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  vi p(n);
  rep(i,n) cin >> p[i];
  int ret=0;
  rep(i,1,n-1){
    if(is_second(p[i-1],p[i],p[i+1])) ret++;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int rect1, rect2;
	rect1 = a * b;
	rect2 = c * d;
	if(rect1 >= rect2)
		printf("%d\n", rect1);
	else
		printf("%d\n", rect2);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7);

int main(void) {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int a, b, xmax = -10000, ymin = 10000;
	for (int i = 0;i < n;i++) {
		cin >> a;
		xmax = max(a, xmax);
	}
	for (int i = 0;i < m;i++) {
		cin >> a;
		ymin = min(a, ymin);
	}
	if (xmax >= ymin) {
		cout << "War" << endl;
	}
	else {
		for (int i = y;i > x;i--) {
			if (i <= ymin&&i > xmax) {
				cout << "No War" << endl;
				return 0;
			}
		}
		cout << "War" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
mod = int(1e9+7)
def pot(a, b):
    result = 1
    while(b):
        if(b%2):
            result=(result*a)%mod
        a=(a*a)%mod
        b//=2
    return result

n = int(input())
print((2*(pot(10,n)-pot(9,n))-(pot(10,n)-pot(8,n)))%(mod))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<P> xy(N);
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    xy[i] = P(x, y);
  }
  vector<P> d;
  FOR(i, 0, N) FOR(j, 0, N) {
    if(i == j) continue;
    d.push_back(P(xy[i].first - xy[j].first, xy[i].second - xy[j].second));
  }
  int mx = 0;
  for(auto p : d) {
    int tmp = 0;
    for(auto p2 : d) {
      if(p == p2) { tmp++; }
    }
    mx = max(mx, tmp);
  }
  cout << N - mx << endl;

  return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int d;
	for (int i = 0; i < 5; ++i){
	cin >> d;
	if (d == 0){
		cout << i+1 << "\n";
	}
	}	
	return 0;
}


Measured memory_bytes: 3652
n,x = map(int,input().split())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

k = gcd(n,x)
if k == 1:
    print((n-1)*3)
else:
    print((int(n/k)-1)*3*k)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, K, Q;
int cnt[112345];

int main() {
	cin >> N >> K >> Q;
	REP(i, Q) {
		int A;
		scanf("%d", &A);
		A--;
		cnt[A]++;
	}
	
	REP(i, N) {
		puts(K <= Q - cnt[i] ? "No" : "Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1024
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
ss = [ns() for _ in range(h)]

for i in range(2*h):
    print(ss[i//2])

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

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

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int p, int q){ 
  if(p % q == 0)return q;  
  return gcd(q, p % q); 
  }
int main(){
	int N,a,b,c,S=0;
  cin >> N;
  for(a=1;a<=N;a++){
  	for(b=1;b<=N;b++){
    	for(c=1;c<=N;c++){
    	S+=gcd(gcd(a,b),c);
      }
    }
  }
  cout<<S<<endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define ite ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    map<int,int>m;
    rep(i,n){
      int a,b,c,d,e,f,g,h,i;
      cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
      m[(b+d+f+h)*60+c+e+g+i]=a;
    }
    map<int,int>ite it=m.begin();
    cout<<it->second<<endl;
    it++;
    cout<<it->second<<endl;
    it=m.end();
    it--;it--;
    cout<<it->second<<endl;
    //cout<<"!"<<endl;
  }
}

Measured memory_bytes: 1428