akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=2005;
const int MOD=924844033;

int n,k,jc[N],a[N];
LL f[N][N][2][2];
bool vis[N];

int main()
{
	scanf("%d%d",&n,&k);
	jc[0]=1;
	for (int i=1;i<=n;i++) jc[i]=(LL)jc[i-1]*i%MOD;
	int tot=0;
	for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			a[++tot]=i;
			for (int j=i+k;j<=n;j+=k) vis[j]=1,a[++tot]=j;
		}
	f[0][0][0][0]=1;a[0]=-k-1;a[n+1]=k-1;
	for (int i=1;i<=n;i++)
	{
		f[i][0][0][0]=1;
		for (int j=1;j<=i;j++)
		{
			f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%MOD;
			f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%MOD;
			f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%MOD;
			f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%MOD;
		}
	}
	int ans=0;
	for (int i=0;i<=n;i++)
	{
		int s=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%MOD;
		if (i&1) (ans+=MOD-(LL)s*jc[n-i]%MOD)%=MOD;
		else (ans+=(LL)s*jc[n-i]%MOD)%=MOD;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 123776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int cnt = 0;
    while(A >= B) B *= 2, cnt++;
    while(B >= C) C *= 2, cnt++;
    if(cnt <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<algorithm>

unsigned GCD(unsigned u, unsigned v) {
    while ( v != 0) {
        unsigned r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main(){
  int N,X,maxD=0;
  std::cin>>N>>X;
  int a[N];

  for(int i=0;i<N;i++) std::cin>>a[i];

  for(int i=0;i<N;i++) maxD=std::max(maxD,a[i]);

  int minD=std::abs(X-maxD);

  for(int i=0;i<N;i++)
      minD=std::min(minD,std::abs(X-a[i]));

  for(int i=0;i<N;i++)
         minD=GCD(std::abs(X-a[i]),minD);

  std::cout<<minD<<std::endl;

  return 0;
  }

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }

ll n, a, b, c;
ll L[10];
ll dfs(ll i, ll j, ll k, ll l) {
    if (i == n) {
        if (j != 0 && k != 0 && l != 0) {
            return abs(a - j) + abs(b - k) + abs(c - l);
        } else {
            return 1000000000000;
        }
    }
    ll A = dfs(i + 1, j + L[i], k, l) + 10;
    ll B = dfs(i + 1, j, k + L[i], l) + 10;
    ll C = dfs(i + 1, j, k, l + L[i]) + 10;
    ll D = dfs(i + 1, j, k, l);
    ll E = min(A, B);
    ll F = min(C, D);
    return min(E, F);
}
int main(void) {
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++) {
        cin >> L[i];
    }
    ll ans = dfs(0, 0, 0, 0) - 30;
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
from collections import deque

N,M = [int(x) for x in input().split()]
next =[set() for _ in range(N+1)]

for i in range(M):
    A,B = [int(x) for x in input().split()]
    next[A].add(B)
    next[B].add(A)

opened = deque()
opened.append(1)

prev = [-1] * (N+1)
prev[1] = 1

while len(opened) != 0:
    target = opened.popleft()
    for n in next[target]:
        if prev[n] == -1:
            opened.append(n)
            prev[n] = target


print('Yes')
# for i in range(2,N+1):
#     print(prev[i])
print(" ".join([str(x) for x in prev[2:]]))

Measured memory_bytes: 70660
def f_c():
    def gcd(a, b):
        if a==0:
            return b
        return gcd(b%a, a)

    n, *a = map(int, open(0).read().split())

    l, r = [0], [0]
    for i in range(n-1):
        l.append(gcd(l[i], a[i]))
        r.append(gcd(r[i], a[-1-i]))
    m = 0
    for i in range(n):
        m = max(m, gcd(l[i], r[-1-i]))
    print(m)

if __name__ == "__main__":
    f_c()

Measured memory_bytes: 14092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAXN=2e5+50,INF=1e9;
struct Maxflow{
	struct edge{
		int to,cap,flow,rev;
	};
	vector<edge> G[MAXN];
	int dis[MAXN],cur[MAXN],s,t;
	int dfs(int u,int cap){
		if(u==t||!cap) return cap;
		for(int &i=cur[u];i<G[u].size();++i){
			auto &e=G[u][i];
			if(dis[e.to]==dis[u]+1&&e.flow!=e.cap){
				int df=dfs(e.to,min(cap,e.cap-e.flow));
				if(df){
					e.flow+=df,G[e.to][e.rev].flow-=df;
					return df;
				}
			}
		}
		dis[u]=-1;
		return 0;
	}
	bool bfs(){
		MEM(dis,-1);
		queue<int> q;
		q.push(s),dis[s]=0;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(auto e:G[u])
				if(!~dis[e.to]&&e.flow!=e.cap)
					q.push(e.to),dis[e.to]=dis[u]+1;
		}
		return dis[t]!=-1;
	}
	int maxflow(int _s,int _t){
		s=_s,t=_t;
		int flow=0,df;
		while(bfs()){
			MEM(cur,0);
			while(df=dfs(s,INF)) flow+=df;
		}
		return flow;
	}
	void init(int n){
		for(int i=0;i<n;++i) G[i].clear();
	}
	void add_edge(int a,int b,int cap){
		G[a].pb(edge{b,cap,0,G[b].size()});
		G[b].pb(edge{a,0,0,G[a].size()-1});
	}
}Dinic;

int match[200005],n,ans[100005];
vector<int> G[100005];
bitset<100005> vis;

void dfs(int u,int f)
{
	vis[u]=1,ans[u]=f;
	for(int i:G[u])
		if(!vis[i])
			dfs(i,u);
}

int main()
{jizz
	int t,x,s;
	cin >> n,Dinic.init(2*n+1);
	for(int i=1;i<n;++i)
	{
		cin >> t;
		while(t--)
			cin >> x,Dinic.add_edge(i+n,x,1);
	}
	for(int i=1;i<n;++i)
		Dinic.add_edge(2*n,i+n,1);
	for(int i=1;i<=n;++i)
		Dinic.add_edge(i,0,1);
	if(Dinic.maxflow(2*n,0)!=n-1)
		return cout << "-1\n",0;
	for(int i=1;i<n;++i)
		for(auto e:Dinic.G[i+n])
			if(e.cap==e.flow&&e.to<=n)
			{
				match[i+n]=e.to,match[e.to]=i;
				//cout << i << "-" << e.to << "\n";
				break;
			}
	for(int i=1;i<=n;++i)
		if(!match[i])
		{
			s=i,match[i]=n,match[n+n]=i;
			break;
		}
	for(int i=1;i<n;++i)
		for(auto e:Dinic.G[i+n])
		if(e.to<=n&&match[e.to]!=i)
				G[match[e.to]].pb(i);//,cout << "add edge " << match[e.to] << "->" << i << "\n";
	dfs(n,-1);
	for(int i=1;i<=n;++i)
		if(!vis[i])
			return cout << "-1\n",0;
	for(int i=1;i<n;++i)
		cout << match[i+n] << " " << match[ans[i]+n] << "\n";
}

Measured memory_bytes: 35952
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool is_acgt(char c) {
  if(c == 'A') return true;
  if(c == 'C') return true;
  if(c == 'G') return true;
  if(c == 'T') return true;
  return false;
}

int main() {
  string S; cin>>S;
  int cnt = 0, ans = 0;
  REP(i, S.length()) {
    if(is_acgt(S[i])) {
      cnt++;
    } else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

//typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
//typedef vector<ll> vl;
//typedef vector<vl> vll;
typedef pair<int,int> pii;
//typedef pair<ll,ll> pll;




int main(){
	double t=3.305785;
	int a,b;
	cin>>a>>b;
	double ans=a*b/t;
	printf("%.15lf\n", ans);
}

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

int count_digits(const std::string& s)
{
    return std::count_if(s.begin(), s.end(), 
                      // static_cast<int(*)(int)>(std::isdigit)         // wrong
                      // [](int c){ return std::isdigit(c); }           // wrong
                      // [](char c){ return std::isdigit(c); }          // wrong
                         [](unsigned char c){ return std::isdigit(c); } // correct
                        );
}

int main () {

  string   S;
  
  cin >> S ;
 
  if (S.length() != 4 || count_digits(S) != 4) {
	cout << "Bad\n";
        return 0;
  }

  for (int i = 1; i < 4; ++i) {
	if (S[i] == S[i-1]) {
		cout << "Bad\n";
        	return 0;
	}
  }
  
  cout << "Good\n";
       
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

bool search(int A[], int n, int key) {
    A[n] = key;
    int i = 0;
    while (A[i] != key) i++;
    return i != n;
}

int main() {
    int n, S[10001], q, key;
    int i;
    int sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(S, n, key)) sum++;
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 2740
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
struct rect{
  int w,h,v;
  bool operator<(const rect& a) const{
    return v==a.v ? h < a.h : v < a.v;
  }
};
int main(){
  int i,j,k,w,h;
  vector <rect> rs;
  rect r;
  for(i=1;i<151;i++){
    for(j=1;j<i;j++){
      r.w=i;
      r.h=j;
      r.v=i*i+j*j;
      rs.push_back(r);
    }
  }
  sort(rs.begin(),rs.end());
  cin >> h >> w;
  while(h!=0){
    for(i=0;i<rs.size();i++){
      if(rs[i].w==w&&rs[i].h==h) cout << rs[i+1].h << " " << rs[i+1].w << endl;
    }
    cin >> h >> w;
  }
  return 0;
}

Measured memory_bytes: 1348
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	x := scanInt()
	i := x / 500
	j := x % 500 / 5
	fmt.Println(i*1000 + j*5)
}


Measured memory_bytes: 1772
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String num[] = sc.nextLine().split(" ");
    int xdiff = Integer.parseInt(num[2])-Integer.parseInt(num[0]);
    int ydiff = Integer.parseInt(num[3])-Integer.parseInt(num[1]);
    System.out.println(String.valueOf(Integer.parseInt(num[2])-ydiff)+ " "+ String.valueOf(Integer.parseInt(num[3])+xdiff) + " "+ String.valueOf(Integer.parseInt(num[0])-ydiff)+ " " + String.valueOf(Integer.parseInt(num[1])+xdiff));
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

vector<int> tree[100001];
int dp[100001][2];

int solve(int u, bool constr, int pr)
{
  if (dp[u][constr] != -1)
    return dp[u][constr];
  int ans = 0;
  int w1 = 1;
  for (int child : tree[u]) {
    if (child != pr)
    {
      w1 = (w1 * solve(child, 0, u)) % MOD;
    }
  }
  ans = (ans + w1) % MOD;
  if (!constr)
  {
    int w2 = 1;
    for (int child : tree[u]) {
      if (child != pr)
      {
        w2 = (w2 * solve(child, 1, u)) % MOD;
      }
    }
    ans = (ans + w2) % MOD;
  }
  return dp[u][constr] = ans;
}

int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    int n;
    cin >> n;
    n--;
    memset(dp, -1, sizeof(dp));
    while (n--)
    {
      int x, y;
      cin >> x >> y;
      tree[x].pb(y);
      tree[y].pb(x);
    }
    cout << solve(1, 0, -1);
  }
}



Measured memory_bytes: 17540
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

template<typename T>bool chkmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool chkmin(T &a,T b){return (a>b)?a=b,1:0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int he[100005],ne[200005],cost[200005],to[200005],e;
int n,m;
int fa[100005],col[100005];
int vis[100005],pd[100005];
long long ans;
int fi,se,tri;
int flag,top,cnt,maxn;
void add(int x,int y,int z){
     to[++e]=y;
	 ne[e]=he[x];
	 he[x]=e;
	 cost[e]=z;
}
void dfs(int x){
   vis[x]=1;
   top++;
   if(!col[x])fi++;
   else if(col[x]==1)se++;
   else tri++;
   maxn=max(maxn,col[x]);
   for(int i=he[x];i;i=ne[i]){
	   int v=to[i];
       if(!pd[(i+1)/2]){
            pd[(i+1)/2]=1;
            cnt++;
            if(!vis[v]){
                col[v]=(col[x]+cost[i]+3)%3;
                dfs(v);
            }
            else{
                if(col[v]!=(col[x]+cost[i]+3)%3)flag=1;
            }
        }
   }
}
int main () {

    n=read();
	m=read();
	F(i,1,m){
	   int x=read(),y=read();
	   add(x,y,1);
	   add(y,x,-1);
	}
	F(i,1,n){
	   if(!vis[i]){
	      flag=top=fi=se=tri=cnt=maxn=0;
	      dfs(i);
		  if(flag){
		    ans+=1ll*top*top;
			continue;
		  }
		  else if(!fi||!se||!tri){
		     ans+=cnt;
			 continue;
		  }
		  else{
		     ans+=1ll*fi*se;
			 ans+=1ll*se*tri;
			 ans+=1ll*tri*fi;
		  }
	   }
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7296
#include<iostream> 
#include<vector>
#include<numeric>
#include<string>
using namespace std;

int main()
{
        int t;
        cin>>t;
        int ac=0,wa=0,tle=0,re=0;
        while(t--)
        {
                string s;
                cin>>s;
                if(s=="AC")
                        ac++;
                if(s=="WA")
                        wa++;
                if(s=="TLE")
                        tle++;
                if(s=="RE")
                        re++;
        }
        cout<<"AC x "<<ac<<endl;
         cout<<"WA x "<<wa<<endl;
         cout<<"TLE x "<<tle<<endl;
         cout<<"RE x "<<re<<endl; 
                    
}


Measured memory_bytes: 3620
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<Pll> a(n);
    rep(i,0,n){
        cin >> a[i].first >> a[i].second;
    }
    sort(all(a), greater<Pll>());
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    rep(i,0,n){
        auto [d, c] = a[i];
        if(m-d+1 <= 0)continue;
        if(pq.size() < m-d+1) pq.emplace(c);
        else{
            ll t = pq.top();pq.pop();
            if(t > c)pq.emplace(t);
            else pq.emplace(c);
        }
    }

    ll ans = 0;
    while(!pq.empty()){
        ll t = pq.top();pq.pop();
        ans += t;
    }
    cout << ans << "\n";
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint X;
    cin >> X;
    lint ans = 0;
    ans += (X / 500) * 1000;
    d(ans);
    X -= (X / 500) * 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
string s;
void check(int l,int r){
	for(int i=l,j=r-1;i<r/2;i++,j--)
			if(s[i]!=s[j]){
				cout<<"No"<<endl;
				exit(0);
			}
}
void solve(){
	int n=sz(s);
	check(0,n);
	check(0,(n-1)/2);
	check(n-(n+3)/2,n);
	cout<<"Yes"<<endl;
}
int main() {
	cin>>s;
	solve();
}


Measured memory_bytes: 764
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String name = sc.next();
		int namenumber=name.length();
		int count = 0;
		int flag;
		for(int i=0;i<n;i++){
			String kanban = sc.next();
			int kanbannumber=kanban.length();
			for(int p=0;p<kanbannumber;p++){
				for(int q=1;;q++){
					if(p+q*(namenumber-1)>=kanbannumber){
						break;
					}
					flag = 1;
					for(int r=0;r<namenumber;r++){
						if(name.charAt(r)!=kanban.charAt(p+q*r)){
							flag = 0;
							break;
						}
					}
		  			if(flag==1){
					    count++;
					    p = kanbannumber;
					    break;
					}
				}
			}
		}
		System.out.println(count);
	}	
}

Measured memory_bytes: 20604
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	ll n; cin >> n;
	ll res = 0;
	res += pow(n, 2) + pow(n, 3) + n;
	cout << res;
	return 0;
}

Measured memory_bytes: 4020
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct str {
    int c;
    int cnt;
    str() {}
    str(int c, int cnt) : c(c), cnt(cnt) {}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    auto check=[&](int x) {
        stack<str> sta;
        sta.emplace(1,A[0]);
        for (int i = 1; i < N; i++) {
            str s = sta.top();
            if (s.cnt < A[i]) {
                if (s.c==1) sta.pop();
                sta.emplace(1,A[i]);
                continue;
            }
            sta.pop();
            while (!sta.empty() and sta.top().cnt >= A[i]) {
                s = sta.top();
                sta.pop();
            }
            s.cnt = A[i];

            if (s.c==x) {
                s.c = 1;
                if (sta.empty()) return false;
                str t = sta.top(); sta.pop();
                t.cnt--;
                if (sta.empty()) {
                    if (t.cnt) sta.emplace(t);
                } else {
                    if (t.cnt != sta.top().cnt) sta.emplace(t);
                }
                t.c++; t.cnt++;
                if (!sta.empty() and sta.top().c==t.c) sta.pop();
                sta.emplace(t);
                sta.emplace(s);
            } else {
                s.cnt--;
                if (sta.empty()) {
                    if (s.cnt) sta.emplace(s);
                } else {
                    if (s.cnt != sta.top().cnt) sta.emplace(s);
                }
                s.c++; s.cnt++;
                if (!sta.empty() and sta.top().c==s.c) sta.pop();
                sta.emplace(s);
            }
        } 

        return true;
    };
    int ng = 0;
    int ok = N;
    while (ok - ng > 1) {
        int mid = (ng+ok)/2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << ln;
}

Measured memory_bytes: 1024
#include <stdio.h>

main() {
    unsigned short a, b;
    char o;
    for(;;) {
        scanf("%d %c %d", &a, &o, &b);
        if(o == '?') break; 
        else if(o == '+') printf("%d\n", a+b);
        else if(o == '-') printf("%d\n", a-b);
        else if(o == '*') printf("%d\n", a*b);
        else if(o == '/') printf("%d\n", a/b);
    }
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b;
  cin >> a >> b;

  if(a>=b+2)cout << a+a-1 << endl;
  else if(a+2<=b)cout << b+b-1 << endl;
  else cout << max(a,b)+min(a,b) << endl;

}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        int[][] pair = new int[n][2];
        for (int i = 0; i < n; i++) {
            pair[i][0] = in.nextInt();
            pair[i][1] = in.nextInt();
        }

        Arrays.sort(pair, Comparator.comparingInt(o -> o[1]));

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += pair[i][0];
            if(sum > pair[i][1]){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }
}

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

int main(void) {
  int d,g;
  cin >> d >> g;

  vector<int> p(d+1),c(d+1);
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }

  int ans = numeric_limits<int>::max();
  for (int i = 0; i < 1<<d; i++) {
    int score=0;
    int count=0;
    for (int j = 0; j < d; j++) {
      if(i>>j & 1) {
	score+=p[j]*100*(j+1)+c[j];
	count += p[j];
      }
    }
    
    bool b = false;
    int count2=numeric_limits<int>::max();
    for (int j = 0; j < d; j++) {
      if((i>>j & 1) == 0) {
	if(score+100*(j+1)*(p[j]-1)>=g){
	  b = true;
	  if(0<g-score){
	    count2 = min(count2, (g-score+100*j)/(100*(j+1)));
	  } else {
	    count2=0;
	    break;
	  }
	}
      }
    }
    if(i==(1<<d)-1){
      b=true;
      count2=0;
    }

    if(b){
      ans = min(ans, count+count2);
    }
  }

  cout << ans << 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) begin(v),end(v)
#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; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, M;
vector<pii> g[50];
int U[20], V[20];
int ins[50]; // iを黒くしたときに満たされる制約の集合
ll dp[50][1<<20];
pii par[50];

void dfs(int u, int p) {
	for (pii e : g[u]) {
		int v = e.fi;
		if (v == p) continue;
		par[v] = pii(u, e.se);
		dfs(v, u);
	}
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		g[a].emplace_back(b, i);
		g[b].emplace_back(a, i);
	}
	cin >> M;
	REP(i, M) scanf("%d %d", U + i, V + i), --U[i], --V[i];
	
	REP(i, M) {
		// U[i] -> V[i]
		fill(par, par + N, pii(-1, -1));
		dfs(U[i], -1);
		
		int u = V[i];
		while (par[u].fi != -1) {
			ins[par[u].se] |= 1<<i;
			u = par[u].fi;
		}
	}
	
	dp[0][0] = 1;
	REP(i, N - 1) {
		REP(s, 1<<M) {
			if (dp[i][s] == 0) continue;
			dp[i + 1][s | ins[i]] += dp[i][s];
			dp[i + 1][s] += dp[i][s];
		}
	}
	
	cout << dp[N - 1][(1<<M)-1];
	return 0;
}


Measured memory_bytes: 362752
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B;
    cin >> A >> B;
    if (A >= 13) {
        cout << B;
    } else if (A >= 6) {
        cout << B / 2;
    } else {
        cout << 0;
    }
    cout << endl;
}

Measured memory_bytes: 256
while True:
    try:
        s=int(input())
        result=0
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if i+j+k+l==s:
                            result+=1
        print(result)   
    except EOFError:
        break



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

const int maxn=1e5+10,mod=1e9+7;
int n,m,x[maxn],y[maxn],bit[maxn];
vector<pair<int,int> > vec;

inline void init(){
	 cin>>n>>m;
	 for(int i=1;i<=n;++i)
		 cin>>x[i];
	 for(int i=1;i<=m;++i)
		 cin>>y[i];
	 for(int i=1;i<=n;++i){
		 int t=lower_bound(y+1,y+m+1,x[i])-y;
		 if(t==1||t==m+1)
			 continue;
		 vec.push_back(make_pair(x[i]-y[t-1],t[y]-x[i]));
	 }
	 vector<pair<int,int> > tmp;
	 for(int i=0;i<vec.size();++i)
		 tmp.push_back(make_pair(vec[i].first,i));
	 sort(tmp.begin(),tmp.end());
	 for(int i=0,cnt=0;i<tmp.size();++i)
		 vec[tmp[i].second].first=i&&tmp[i].first==tmp[i-1].first?cnt:++cnt;
	 tmp.clear();
	 for(int i=0;i<vec.size();++i)
		 tmp.push_back(make_pair(vec[i].second,i));
	 sort(tmp.begin(),tmp.end());
	 for(int i=0,cnt=0;i<tmp.size();++i)
		 vec[tmp[i].second].second=i&&tmp[i].first==tmp[i-1].first?cnt:++cnt;
}
inline bool cmp(pair<int,int> a,pair<int,int> b){
	return a.first<b.first||a.first==b.first&&a.second>b.second;
}
inline void add(int x,int val){
	while(x<maxn){
		(bit[x]+=val)%=mod;
		x+=x&-x;
	}
}
inline int sum(int x){
	int res=0;
	while(x){
		(res+=bit[x])%=mod;
		x-=x&-x;
	}
	return res;
}

int main(){
	init();
	sort(vec.begin(),vec.end(),cmp);
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	add(1,1);
	for(int i=0;i<vec.size();++i)
		add(vec[i].second+1,sum(vec[i].second));
	cout<<sum(maxn-1)<<endl;
	return 0;
}

Measured memory_bytes: 3316
a[100],l,r,p;main(c){for(;scanf(p="%d",&r)*r;printf("%d\n",c)){for(c=++r;c;)l=scanf(p,--c+a);for(;l<r&&!++c|a[p=l+r>>1]-*a;)a[p]<*a?r=p:(l=p+1);}}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define int long long
typedef long long ll;
using namespace std;

ll N, K, A[15], M[16], mincount=100000000000;

void dfs(ll id, ll k, vector<ll> v){
    if(k>K) return;
    if(id==N){
        if(k!=K) return;
        ll ms[N+1];
        ll count=0;
        for(ll i=0;i<N+1;i++) ms[i] = M[i];
        for(ll i=0;i<v.size();i++) {
            if(v[i]==1) {
                if(A[i]-ms[i]-1<0) {
                    count+= ms[i]+1-A[i];
                    for(ll j=i+1;j<N+1;j++) ms[j] = max(ms[i]+1, ms[j]);
                }
            }
        }
        mincount = min(mincount, count);
        /*
        cout << maxcount;
        for(ll i=0;i<as.size();i++) cout << " " << as[i];
        cout << endl;
        */
        return;
    }
    v[id] = 0;
    dfs(id+1, k, v);
    v[id] = 1;
    dfs(id+1, k+1, v);
}

signed main(){
    cin >> N >> K;
    ll mh = 0;
    for(ll i=0;i<N;i++) {
        M[i] = mh;
        cin >> A[i];
        mh = max(mh, A[i]);
    }

    vector<ll> vemp;
    vemp.resize(N);
    dfs(0, 0, vemp);
    cout << mincount << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

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


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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
using ll  = long long;
using vi  = vector<ll>;
using pii = pair<ll,ll>;
#define int ll

int n;
vi a;

template<typename T> class BIT{
  vector<T> vec;
  const ll n;
  
public:
  BIT(T _n) : vec(_n + 1), n(_n) {}

  T query(ll x) { /* query for [1, x] */
    T ret = 0;
    for(ll i = x; i > 0; i -= i & (-i)) ret += vec[i];
    return ret;
  }

  void update(ll x, T k) { /* update for [1, x] */
    for(ll i = x; i <= n; i += i & (-i)) vec[i] += k;
  }
};

bool solve(int mid){
  vi s(n+1);
  rep(i,n){
    s[i+1] = (a[i] >= mid) ? 1 : -1;
    s[i+1] += s[i];
  }

  BIT<ll> bit(n*3);
  int inv = 0;
  rep(i,n+1){
    // cout << i << endl;
    inv += bit.query(s[i]+n*2);
    bit.update(s[i]+n*2, 1);
  }

  int tmp = (n+1) * n / 2;
  // cout << (inv >= (tmp+1)/2) << endl;
  if(inv >= (tmp+1) / 2) return true;
  else return false;
}

int bs(int _ok, int _ng){
  int ok = _ok;
  int ng = _ng;

  while(abs(ok - ng) > 1){
    int mid = (ok + ng) / 2;
    if(solve(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  return ok;
}

main(){
  cin >> n;
  a.resize(n); rep(i,n) cin >> a[i];
  int ans = bs(0,1e9+1);
  cout << ans << endl;
}


Measured memory_bytes: 4180
import math
import sys
import bisect

S1 = input()
T = input()

candidates = []


def check(sStart):
    for i in range(len(T)):
        sIdx = sStart + i
        if sIdx < len(S1) and (S1[sIdx] == T[i] or S1[sIdx] == "?"):
            pass
        else:
            return False
    return True


for i in range(len(S1)):
    s = ""
    if check(i):
        c = S1[0:i] + T +S1[i+len(T):]
        # print(c)
        candidates.append(c)

clist = list(set(candidates))
clist = sorted(clist)


if len(clist) == 0:
    print("UNRESTORABLE")
else:
    ret = clist[0]
    ret = ret.replace("?","a")
    print(ret)


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

using namespace std;

vector<int> arr;

int main(){

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

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

    int n;

    cin >> n;

    for(int i = 0; i < n; ++i){
        int val;
        cin >> val;
        arr.push_back(val);
    }

    for(int i = 0; i < n; ++i){
        int j;
        cin >> j;
        arr[i] -= j;
    }

    int s = 0;

    for(int i : arr)
        if(i > 0)
            s += i;

    cout << s;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = scanner.nextInt();

        int people = 0;
        if (x >= z) x -= z;
        else {
            System.out.println(0);
            return;
        }
        while (true){
            if (x >= y) {
                x = x - y;
                people++;
            }                         
            else break;
            if (x >= z) x -= z;
            else {
                people--;
                break;
            }
        }
        System.out.println(people);
    }
}


Measured memory_bytes: 23124
K, N = map(int, input().split())
coordinate = list(map(int, input().split()))

distance = list()

for a in range(0, N):
    if a == N - 1:
        num = K - coordinate[a] + coordinate[0]
    else:
        num = coordinate[a+1] - coordinate[a]
    distance.append(num)

print(K - max(distance))


Measured memory_bytes: 26444
MOD = 10 ** 9 + 7
N, K = map(int, input().split())

def comb(n, k):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % MOD        
        ret = ret * pow(i, MOD - 2, MOD) % MOD
    return ret

for i in range(1, K + 1):
    n = i - 1 + 2
    k = N - K - (i - 1)
    if k < 0:
        print(0)
    else:
        ans = comb(n + k - 1, k) * comb(K - 1, i - 1) % MOD
        print(ans)



Measured memory_bytes: 42864
#include <cstdio>
#include <algorithm>
using namespace std;
int m[107], dp[107][107];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
    	scanf("%d%d", &m[i], &m[i + 1]);
	}
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			dp[i][j] = 1e9 + 7;
			for (int k = i; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + m[i - 1] * m[k] * m[j]);
			}
		}
	}
	printf("%d\n", dp[1][n]);
    return 0;
}


Measured memory_bytes: 2744
//
// Created by Hideaki Imamura on 2020-03-28.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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 EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll x;

int main() {
    cin >> x;
    cout << 1000 * (x / 500) + 5 * ((x % 500) / 5) << endl;
    return 0;
}

Measured memory_bytes: 256
S = list(str(input()))
T = list(str(input()))

l = len(S) - len(T)
f = len(T)

for i in range(l+1):
    temp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            temp += 1
    if f > temp:
        f = temp

print(f)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#include <deque>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, q, query, t, x;
	cin >> n >> q;
	vector<deque<int> > S(n);
	
	rep(i, q)
	{
		cin >> query >> t;
		if (query == 0)
		{
			cin >> x;
			S[t].push_back(x);
		}
		else if (query == 1)
		{
		    if (S[t].size())
		    {
			    cout << S[t].front() << endl;
		    }
		}
		else
		{
		    if (S[t].size())
			{
			    S[t].pop_front();
			}
		}
	}
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n,W;
ll w[100100];
ll v[100100];

ll Dp[110][100100];

int main()
{
    cin>>n>>W;

    for(ll i=0;i<n;i++)    scanf("%I64d%I64d",w+i,v+i);

    for(ll R=0;R<=W;R++)    Dp[n][R] = 0;

    for(ll i=n-1;i>=0;i--)
        for(ll R=0;R<=W;R++)
            Dp[i][R] = max( Dp[i+1][R] , R>=w[i] ? Dp[i+1][R-w[i]] + v[i] : 0 );

    cout<<Dp[0][W];
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  ll a, b;
  cin >> a >> b;
  if(a % 2 != b % 2){
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()
using namespace std;


const int maxn=1e6+7;
int a[maxn],x,y,z;

int main (){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=2;i<n;i++){
        if(a[i]>min(a[i-1],a[i+1])&&a[i]<max(a[i-1],a[i+1])) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    int a,b,c;
    a=b=c=0;
    int next=0;
    while(sa.size()+1!=a&&sb.size()+1!=b&&sc.size()+1!=c){
        if(next==0){
            next=sa[a]-'a';
            a++;
        }else if(next==1){
            next=sb[b]-'a';
            b++;
        }else{
            next=sc[c]-'a';
            c++;
        }
    }
    if(sa.size()+1==a)cout << "A" << endl;
    else if(sb.size()+1==b)cout << "B" << endl;
    else cout << "C" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d",&a);
    scanf("%d",&b);
    if (a<b){
         printf("a < b\n");
    } else if (a>b){
         printf("a > b\n");
    } else {
         printf("a == b\n");
    }
    return 0;
}     


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

int main() {
    int N,sum=0;
    vector<int> V(N), C(N);
    cin >> N;
    
    for(int i=0;i<N;i++){
        cin >>V[i];
    }
    for(int i=0;i<N;i++){
        cin >>C[i];
    }
    for(int i=0;i<N;i++){
        if(V[i]-C[i] > 0){
            sum += V[i]-C[i];
        }
    }

    cout << sum << endl;

}




Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let a: i32 = sc.read();
        let op: String = sc.read();
        let op = op.as_bytes()[0] as char;
        let b: i32 = sc.read();
    
        match op {
            '+' => println!("{}", a + b),
            '-' => println!("{}", a - b),
            '*' => println!("{}", a * b),
            '/' => println!("{}", a / b),
            _ => break,
        }
    }
}

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}


Measured memory_bytes: 5040
import re

def cha(s):
    s_ = []
    for i in s:
        s_.append(len(i))
    return s_
def sum_all(n):
    return n*(n-1)//2

if __name__=="__main__":
    s = input()
    top = s[0]
    c = 0
    if top == "<":
        s = re.split('(>+)',s)
        if s[-1] == "":
            s = s[:-1]
    else:
        s = re.split('(<+)',s)
        if s[-1] == "":
            s = s[:-1]
    s = cha(s)
    sum_top = 0
    sum_end = 0
    if top == ">":
        sum_top = sum_all(s[0]) + s[0]
        s = s[1:]
    if len(s)%2 == 1:
        sum_end = sum_all(s[-1])+s[-1]
        s = s[:-1]
    for i in range(0,len(s),2):
        c += sum_all(s[i])
        if s[i] >= s[i+1]:
            c += s[i] + sum_all(s[i+1])
        else:
            c += s[i+1]+sum_all(s[i+1])
    c += sum_end + sum_top

    print(c)


Measured memory_bytes: 92872
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

// vector<int> a(5);
map<char,long long> counter;
int n;
string temp;
string s = "MARCH";

int main(void){
    cin >> n;
    REP(i,0,n) {
        cin >> temp;
        if (s.find(temp[0]) != string::npos) {
            // cout << "test" << endl;
            counter[temp[0]]++;
        }
    }
    
    long long ans = 0;
    REP(a,0,5) REP(b,a+1,5) REP(c,b+1,5) {
        ans += counter[s[a]]*counter[s[b]]*counter[s[c]];
    }
    cout << ans << endl;
   
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x.at(i) >> y.at(i) >> h.at(i);
  }

  int ii = 0;
  for (ii = 0; ii < N; ii++)
  {
    if (h.at(ii) > 0) break;
  }
  
  int Cx, Cy, H;
  for (int Cx = 0; Cx <= 100; Cx++)
  {
    for (int Cy = 0; Cy <= 100; Cy++)
    {
      H = h.at(ii) + abs(x.at(ii) - Cx) + abs(y.at(ii) - Cy);
      if (H <= 0) continue;

      bool ok = true;
      for (int i = 0; i < N; i++)
      {
        if (h.at(i) != max(H - abs(x.at(i) - Cx) - abs(y.at(i) - Cy), (int)0))
        {
          ok = false;
          break;
        }
      }

      if (ok)
      {
        cout << Cx << " " << Cy << " " << H;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
/*input
13 7 2
*/
/**
    Author: Kristopher Paul
    Date Created: 08-12-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int s = 0;
    FOR(i,0,3){
        int x;
        cin >> x;
        s += x;
    }
    if(s >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC044B_BeautifulStrings
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.ReadLine().ToCharArray();

            string result = "Yes";

            Dictionary<string, int> charCount = new Dictionary<string, int>();

            foreach (char value in input)
            {
                string key = value.ToString();

                if (charCount.ContainsKey(key))
                {
                    charCount[key]++;
                }
                else
                {
                    charCount.Add(key, 1);
                }
            }

            foreach (var value in charCount)
            {
                if (value.Value % 2 != 0)
                {
                    result = "No";
                }

            }


            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140