akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n&&j>=n;--i)
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 100000000
#define mem(p,v) memset(p,v,sizeof(p))
#define present(c,x)    ((c).find(x) != (c).end())
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define debug4(x,y,z,a) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<#a<<" "<<a<<endl;
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
const long long inf = 9e18;
double pie = 2*acos(0.0);
void show(vector<lli> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(vector<int> v){fr(i,0,v.size())cout<<v[i]<<" ";cout<<endl;}
void show(int a[], int arraysize){for (int i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(lli a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(bool a[], lli arraysize){for (lli i = 0; i < arraysize; ++i)cout << a[i] << " ";cout<<endl;}
void show(set<int> s){for (auto it = s.begin(); it != s.end(); it++){cout << *it << " ";}cout<<endl;}
void show(map<lli,lli> mp){for (auto it = mp.begin(); it != mp.end(); it++){cout << it->first << " "<<it->second<<endl;}cout<<endl;}

lli modpow(lli x,lli n){lli res=1;while(n>0){if(n&1) res=((res%MOD)*(x%MOD))%MOD;x=((x%MOD)*(x%MOD))%MOD;n>>=1;}return res;}
lli power(lli x, lli n){lli res=1;while(n>0){if(n&1) res=res*x;x=x*x;n>>=1;}return res;}

/////// ------ Main code starts here ------ /////
#define N 3001
lli dp[N][N];
lli a[N];
void solve()
{
    lli n,k;
    cin>>n;
    fr(i,0,n)
    {
        cin>>a[i];
    }
    for(int i=n-1;i>=0;--i)
    {
        for(int j=i;j<n;++j)
        {
            if(j==i)
            {
                dp[i][j]=a[i];
            }
            else
            {
                dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}
int main()
{
    run;cout<<fixed<<setprecision(12);
    int t;
    t=1;
    while(t){solve();t--;}
    return 0;
}


Measured memory_bytes: 49776
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n,W;
ll dp[100010][110],w[110],v[110];
int main(int argc,char** argv){
	cin>>n>>W;
	forn(i,n){
		cin>>w[i]>>v[i];
	}
	forn(j,n){
		forn(i,W){
			if(w[j]>i){
				dp[i][j]=dp[i][j-1];
				continue;
			}
			dp[i][j]=max(dp[i-w[j]][j-1]+v[j],dp[i][j-1]);
		}
	}
	cout<<dp[W][n];
	return 0;
}

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

int n,a[10000];
int sum,min;
int main(){
	cin >>n;
	for(int i = 0; i<n; i++)cin >>a[i];
	int res = 0;
	for(int i = 0; i<n; i++){
		if(res < a[i]) res = a[i];}
		
		int min = 0;
		int sum = 0;
		for(int i = 0; i<n; i++){
			if(min != a[i]) sum+=a[i];}
	
	cout<<sum-(res/2)<<endl;
}


Measured memory_bytes: 256
#define pb push_back

#include<iostream>
using namespace std;


int main()
{
    ios::sync_with_stdio(false);
   long long n,x,r,i,j,k,l,s1,s2,ans,d,te,s,sum1,p,q,wd,sum,lim,t,m,c,y;




    sum1=0;k=0;sum=0;
c=0;
//   set<long long >se;
//  stack<long long>st;stack<long long > ::itetator it;
//   map<
        cin>>n;
          //long long a[n];
s=0;
while(c==0)
{ s=s+1000;
if(s>=n)
{
    break;
}
}
x=s-n;
cout<<x<<endl;







 /*    for(i=0;i<n;i++)
{
    if(){            ;}
 */


   /*     for(i=0;i<n;i++)
{
    cout<<a[i];
}  */

}











Measured memory_bytes: 3124
s=str(input())
q=int(input())

right=[]
left=[]
flag=0

for i in range(q):
    a = input()
    if int(a[0]) == 1:
        if flag == 0:
            flag=1
        else:
            flag=0
    else:
        if int(a[2]) == 1:
            if flag == 0:
                left.append(a[4])
            else:
                right.append(a[4])
        elif int(a[2]) ==2:
            if flag ==0:
                right.append(a[4])
            else:
                left.append(a[4])

right_result="".join(right)
left_result="".join(left)

if flag==0:
    print(str(left_result[::-1]+s+right_result))
else:
    print(str(right_result[::-1]+s[::-1]+left_result))


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N; cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    }
    else {
        cout << (ll)2 * (ll)N << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int cnt=0;
  ll n; cin>>n;
  ll m=n; vector<int> pos;
  m--;
  // if(n<=26)
  //   return cout<<(char)(n-1+'a'), 0;
  // while(m){
  //   pos.eb(m%26);
  //   m/=26;
  //   m--;
  //   cnt++;
  // }
  // reverse(all(pos));
  // for(auto i:pos)
  //   cout<<i<<" ";
  int k=pos.size();
  vector<char> ans;
  while(n){
    n--;
    char ch='a'+(n%26);
    ans.eb(ch);
    n/=26;
  }
  reverse(all(ans));
  for(auto i:ans)
    cout<<i;
  // for(int i=0;i<k;i++)
  //     cout<<(char)(pos[i]+'a');

  return 0;
}

Measured memory_bytes: 3600
import math

q = int(input())
for i in range(q):
    a, b = list(map(int, input().split()))

    c = int(math.sqrt(a * b))
    
    ans = 2 * (c - 1)
    
    if (a * b - 1) // c > c:
        ans += 2
    elif a * b == c * c:
        pass
    else:
        ans += 1

    if not (a == b == c):
        ans -= 1

    print(max(0, ans))

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

const int _ = 1 << 16 , MOD = 1e9 + 7;
int N , M , Ed[18] , c1[_] , cl[_] , ng1[_] , ng2[_] , p2[_] , lk[_] , ano[_]; bool lk1[_] , lk2[_];

int main(){
	cin >> N >> M; for(int i = 1 ; i <= M ; ++i){int p , q; cin >> p >> q; --p; --q; Ed[p] |= 1 << q; Ed[q] |= 1 << p;}
	p2[0] = 1; for(int i = 1 ; i <= M ; ++i) p2[i] = (p2[i - 1] * 2) % MOD;
	for(int i = 1 ; i < 1 << N ; ++i) c1[i] = c1[i >> 1] + (i & 1);
	queue < int > q; q.push(1); lk1[1] = 1; ng1[1] = Ed[0] | 1;
	while(!q.empty()){
		int t = q.front(); q.pop();
		for(int i = 0 ; i < N ; ++i)	
			if((ng1[t] >> i & 1) && !lk1[t | (1 << i)]){int x = t | (1 << i); ng1[x] = ng1[t] | Ed[i]; lk1[x] = 1; q.push(x);}
	}
	q.push(2); lk2[2] = 1; ng2[2] = Ed[1] | 2;
	while(!q.empty()){
		int t = q.front(); q.pop();
		for(int i = 0 ; i < N ; ++i)	
			if((ng2[t] >> i & 1) && !lk2[t | (1 << i)]){int x = t | (1 << i); ng2[x] = ng2[t] | Ed[i]; lk2[x] = 1; q.push(x);}
	}
	for(int i = 1 ; i < 1 << N ; ++i){
		int t = log2((i & -i) + 0.1); cl[i] = cl[i - (1 << t)] + c1[Ed[t] & i];
		lk[i] = p2[cl[i]]; int p = i;
		while(p){p = (p - 1) & i; if(p >> t & 1) lk[i] = (lk[i] - 1ll * p2[cl[i ^ p]] * lk[p] % MOD + MOD) % MOD;}
	}
	for(int i = 1 ; i < 1 << N ; ++i)
		for(int j = 0 ; j < N ; ++j) if(!(i >> j & 1)) ano[i] += c1[Ed[j] & i];
	int ans = 0;
	for(int i = 1 ; i < 1 << N ; ++i)
		if(lk1[i]){
			int s = ((1 << N) - 1) ^ ng1[i] , p = s;
			while(p){
				if(lk2[p]) ans = (ans + 1ll * p2[M - cl[i] - cl[p] - ano[i] - ano[p]] * lk[i] % MOD * lk[p]) % MOD;
				p = (p - 1) & s;
			}
		}
	cout << (p2[M] - ans + MOD) % MOD; return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;

int main(){

  int N,A,B;
  int sum = 0;

  cin >> N >> A >> B;

   for(int i = 1;i <= N;i++){

	   int t;
	   t = i;

	   int s = 0;

	   for(int j = 0;j < 5;j++){

		   s += t%10;
		   t/=10;

	   }

	   if(A <= s && s <= B){
		   sum += i;
	   }

   }

   cout << sum << endl;

   return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
struct Edge{
	int to,corlor,w;
};
const int maxn =3e5+10,maxlogv = 20;
vector<Edge> G[maxn];
int id[maxn],dis[maxn];
int vs[maxn*2],depth[maxn*2];
int dp[maxn*2][maxlogv];
void dfs(int node,int fa,int d,int &k){
   	id[node] = k;
   	vs[k] = node;
 	depth[k++] = d;
 	// dis[node] = distance;
 	for(int i = 0;i < G[node].size(); ++i){
 		Edge &t = G[node][i];
 		if(t.to == fa) continue;
 		dis[t.to] = dis[node]+t.w;
 		dfs(t.to,node,d+1,k);
        vs[k] = node;
        depth[k++] = d;
 	}
}

void init_rmq(int n){
	
	for(int i = 0;i < n ; ++i) dp[i][0] = i;
    for(int j = 1;(1<<j) <= n; ++j){
    	for(int i = 0;i + (1<<j)-1 < n; ++i){
    		if(depth[dp[i][j-1]]< depth[dp[i+(1<<(j-1))][j-1]])
    			dp[i][j] = dp[i][j-1];
    		else
    			dp[i][j] = dp[i+(1<<(j-1))][j-1];

    	}
    }
}
int query(int l,int r){
	int k = 0;
	while((1<<(k+1)) <= r-l+1) k++;
 	if(depth[dp[l][k]] < depth[dp[r-(1<<k)+1][k]])
 		return dp[l][k];
 	else 
 		return dp[r-(1<<k)+1][k];
}
int lca(int u,int v){
	return vs[query(min(id[u],id[v]),max(id[u],id[v]))];
}
void init(int n){
	int k = 0;
	dfs(0,-1,0,k);
	init_rmq(2*n-1);
}
struct que{
	int corlor,w,coe,id;
};
vector<que> Query[maxn];
int ans[maxn],num[maxn],value[maxn];// num[i] 个数，value 值
void dfs(int u,int fa){
	for(auto qu:Query[u]){
		// cout<<dis[u]<<endl;
		ans[qu.id] +=(dis[u]+num[qu.corlor]*qu.w-value[qu.corlor])*qu.coe;
	}
	for(auto p: G[u]){
		int to = p.to;
		if(to == fa) continue;
		num[p.corlor]++;
		value[p.corlor] += p.w;
		dfs(to,u);
		num[p.corlor]--;
		value[p.corlor] -= p.w;
	}
}
int main(void)
{
	int n,q;
    cin>>n>>q;
    for(int i = 1;i < n;++i){

    	int u,v,c,w;
    	scanf("%d%d%d%d",&u,&v,&c,&w);
    	u--,v--;
    	G[u].Pb(Edge{v,c,w});
    	G[v].Pb(Edge{u,c,w});
    }
    init(n);
    for(int i = 1;i <= q; ++i){
    	int x,y,u,v;
    	scanf("%d%d%d%d",&x,&y,&u,&v);
    	u--,v--;
    	int fa = lca(u,v);
    	// cout<<fa<<endl;
    	Query[u].Pb(que{x,y,1,i});
    	Query[v].Pb(que{x,y,1,i});
    	Query[fa].Pb(que{x,y,-2,i});
    }
    dfs(0,-1);
    for(int i  = 1;i <= q; ++i){
    	printf("%d\n",ans[i]);
    }

   return 0;
}

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

#define int long long

signed main() {
  int N;
  cin >> N;

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

  int ans = -1;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = i+1; j < N; j++ ) {
      int pro = a[i]*a[j];      
      int tmp = pro/10;      
      int pre = pro%10;      
      while ( tmp ) {
	if ( tmp%10 != pre-1 ) break;
	pre = tmp%10;	
	tmp /= 10;	
      }
      if ( !tmp ) ans = max(ans, pro);
    }
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef struct {
	double x,y;
}point;
void koch_curve(int,point,point);
int main(void){
	point p1,p2;
	int num;
	cin >> num;

	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;

	cout.precision(8);
	cout << p1.x <<" "<< p1.y << endl;
	koch_curve(num,p1,p2);
	cout << p2.x <<" "<< p2.y << endl;
	return 0;
}
void koch_curve(int num,point p1,point p2){
	if(num==0) return;

	point s,t,u;
	double theta =  1.0 / 3  * M_PI;

	//内分点の公式を用いて計算
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;

	//原点以外の場合の点の回転の行列式の公式を用いて計算
	u.x = (t.x - s.x) * cos(theta) - (t.y - s.y) * sin(theta) + s.x;
	u.y = (t.x - s.x) * sin(theta) + (t.y - s.y) * cos(theta) + s.y;
	
	koch_curve(num-1,p1,s);
	cout << s.x << " " << s.y << endl;
	koch_curve(num-1,s,u);
	cout << u.x << " " << u.y << endl;
	koch_curve(num-1,u,t);
	cout << t.x << " " << t.y << endl;
	koch_curve(num-1,t,p2);

}
	




	

Measured memory_bytes: 1252
import sys

inp = sys.stdin
# inp = open("testdata.txt", "r")
def input():
	return inp.readline().strip()

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

def warshall_floyd(d):
	for k in range(n):
		for i in range(n):
			for j in range(n):
				d[i][j] = min(d[i][j],d[i][k] + d[k][j])
	return d

adjl = [[float('inf') for j in range(n)] for i in range(n)]
for i in range(n):
	adjl[i][i] = 0

for _ in range(m):
	a, b, c = map(int, input().split())
	adjl[a-1][b-1] = c
	adjl[b-1][a-1] = c

adjl = warshall_floyd(adjl)

for i in range(n):
	for j in range(n):
		if i==j: adjl[i][j] = 0
		else: adjl[i][j] = 1 if adjl[i][j] <= l else float("inf")

adjl = warshall_floyd(adjl)

q = int(input())

for _ in range(q):
	a, b = map(int, input().split())
	ans = adjl[a-1][b-1]
	print(-1 if ans==float("inf") else ans-1)

Measured memory_bytes: 128092
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int n;
int a[100010], b[100010];
int bit[100010];
void add(int i, int x) {
    while(i <= n+1) {
        bit[i] += x;
        i += i&-i;
    }
}
int sum(int i) {
    int res = 0;
    while(i) {
        res += bit[i];
        i &= i-1;
    }
    return res;
}
ll bb(int x) {
    memset(b, 0, sizeof(b));
    int mi = 0;
    rep(i, n) {
        if(a[i] < x) b[i+1] = 1;
        else b[i+1] = -1;
        b[i+1] += b[i];
        chmin(mi, b[i+1]);
    }
    mi = -mi+1;
    memset(bit, 0, sizeof(bit));
    ll res = 0;
    rep(i, n+1) {
        res += sum(mi+b[i]-1);
        add(mi+b[i], 1);
    }
    return res;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];

    ll cc = ll(n+1)*n>>2;
    int left = 0, mid, right = 1e9+10;
    while(right-left != 1) {
        mid = (left+right)>>1;
        if(bb(mid) > cc) right = mid;
        else left = mid;
    }
    cout << left << endl;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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


    int main()
    {
        int n; llong k;
        cin>>n>>k;
        llong odd=0;
        llong even=0;
        for(int i=1; i<=n; i++)
        {
            if(i%k==0) {++odd; }
        }
        if(k%2==0)
        {
            for(int i=1; i<=n; i++ )
            {
                if(i%k==k/2) {++even;}
            }
        }
        llong ans=0;
        ans+=odd*odd*odd;
        if(k%2==1) cout<<ans<<endl;
        else cout<<ans+even*even*even<<endl;
    }

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <algorithm> 
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a))
		printf("Yes");
	else printf("No");
		 
	return 0;
}

Measured memory_bytes: 256
# 解説見て書く

N, K = [int(x) for x in input().split()]
td = [0] * (N)
for i in range(N):
    td[i] = [int(x) for x in input().split()]

# ネタ種類降順でソート
# 同じネタの中ではおいしいものから順に並ぶ
td = sorted(td, reverse = True)

var_p1 = [0] * N   # 種類数を増やす寿司のリスト
var_p0 = [0] * N   # 種類数を増やさない寿司のリスト

n_p1 = 0
n_p0 = 0
for i in range(N):
    if i == 0 or (i > 0 and td[i][0] != td[i - 1][0]):  # 種類が変わる
        var_p1[n_p1] = td[i][1]  # おいしさを追加
        n_p1 += 1
    else:
        var_p0[n_p0] = td[i][1]  # おいしさを追加
        n_p0 += 1

var_p1.sort(reverse = True)
var_p0.sort(reverse = True)

val_taste = sum(var_p0[0 : K])
val_vars = 0
ans = 0

for j in range(1, K + 1):  # 種類数1〜Kを試す
    val = var_p1[j - 1]
    if val <= 0: break  # これ以上種類を増やせない
    # var_p1からn_p1個選び、var_p0からK - n_p1個選ぶ
    val_taste = val_taste + val - var_p0[K - j]
    val_vars = j * j
    ans = max(ans, val_taste + val_vars)

print(ans)

Measured memory_bytes: 23472
import heapq

n = int(input())
a = list(map(int, input().split()))

red, blue = a[:n], [-1*i for i in a[2*n:]]
sr, sb = sum(red), sum(blue)

results = [0] * (n + 1)
results[0] = sr
results[-1] = sb

heapq.heapify(red)
heapq.heapify(blue)

for k in range(n, 2*n):
    v = a[k]
    p = heapq.heappushpop(red, v)
    sr += v - p
    results[k-n+1] += sr

for k in range(2*n-1, n-1, -1):
    v = -1 * a[k]
    p = heapq.heappushpop(blue, v)
    sb += v - p
    results[k-n] += sb

print(max(results))


Measured memory_bytes: 38148
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * n秒待てばnまで1回で行けるので最大n.
 * nをすぎて戻ることがあるか？距離はより大きいので、一度すぎるとnにはつかない.
 * 1 + 2 + 3 = 6 のようにn未満で戻れるケースが考察が必要.
 * 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5
 */
int main() {
  double n; cin >> n;
  cout << (int)floor(sqrt(2 * n) + 0.5) << endl;
  return 0;
}


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

using namespace std;

int n, A, B, C, D;
string s;
string solve() {
    for(int i = A; i < C; i++) 
        if (s[i] == '#' && s[i + 1] == '#')
            return "No";
    for(int i = B; i < D; i++) 
        if (s[i] == '#' && s[i + 1] == '#')
            return "No";
    if (C < D) return "Yes";

    for(int i = B; i <= D; i++) {
        if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') 
            return "Yes";
        }
    return "No";
}
int main() {
    cin >> n >> A >> B >> C >> D >> s;
    s = "." + s;

    cout << solve();
}


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

int main() {
int n;
string s;
cin >>n>>s;
int cnt=0;
for(int i=0;i<n-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')cnt++;
}
cout << cnt;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
int n;
cin >> n;
int R[n];
for (int i = 0; i < n; i++){
cin >> R[i];
}
int maxv = -10000000000000;
int minv = R[0];


for (int i = 1; i < n; i++){
maxv = max(maxv, R[i]-minv);
minv = min(minv, R[i]);
}

cout << maxv << endl;
return 0;
}



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

int main()
{
    ll n,x;
    ll a,b,y;
    cin>>a>>b>>x>>y;
    int flag=0;
        double ans=a*b;
        ans/=2;
        if(2*x==a && 2*y==b) flag=1;
         cout<<fixed<<setprecision(9)<<ans<<" "<<flag<<endl;
            return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100100;
struct edge{
  ll cost,u,v;
  bool operator<(const edge &o)const{return cost < o.cost;}
  bool operator>(const edge &o)const{return cost > o.cost;}
};
int main(){
  ll n,i,j,k,c,l,r,ans = 0,MIN;bool noneed;
  scanf("%lld",&n);
  ll D[n][n];vector<edge> V;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) scanf("%lld",&D[i][j]);
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++) V.push_back(edge{D[i][j],i,j});
  }
  sort(V.begin(),V.end());
  for(i=0;i<V.size();i++){
    c = V[i].cost;l = V[i].u;r = V[i].v;
    MIN = inf;noneed = false;
    for(j=0;j<n;j++){
      MIN = min(MIN,D[l][j]+D[j][r]);
      if(j != l && j != r && c == D[l][j]+D[j][r]) noneed = true;
    }
    if(MIN < c){
      printf("-1\n");return 0;
    }
    if(!noneed) ans += c;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2552
#include<stdio.h>

int main(){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
  tmp=a;
  a=b;
  b=tmp;}

  if(b>c){
  tmp=b;
  b=c;
  c=tmp;}
    
  if(a>b){
  tmp=a;
  a=b;
  b=tmp;}
  printf("%d %d %d\n",a,b,c);


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
int dp[11000];

int main(){
	dp[1] = 2;
	for (int i = 2; i <= 10000; i++){
		dp[i] = dp[i - 1] + i;
	}
	while (cin >> n){
		cout << dp[n] << endl;
	}
}

Measured memory_bytes: 1204
def d_xor_world(A, B):
    # 解説pdfにおけるfを定義
    def f(n):
        if n % 2 == 0:
            # nが偶数だと、0からn-1までの数を2つずつペアにしてxorを取った値に対し
            # nとのxorを取った値は、n//2個の1をxorした値とnとのxorを取った値に等しい
            return int((n // 2) % 2 == 1) ^ n
        else:
            # nが奇数だと、(n+1)//2個の1をxorした値が出力である
            return int(((n + 1) // 2) % 2 == 1)
    return f(A - 1) ^ f(B)

A, B = [int(i) for i in input().split()]
print(d_xor_world(A, B))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    ll maxv = max(a,b);
    ll minv = min(a,b);

    if(maxv % minv == 0) return minv;
    else return gcd(maxv - minv, minv);
}

int main() {
    ll K, N;
    cin >> K >> N;

    vector<int> v(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    vector<int> r(N);
    r[0] = K - v[N-1] + v[0];
    for(int i = 1; i < N; i++) {
        r[i] = abs(v[i] - v[(i-1)%N]);
       // cout << i << ":" << r[i] << endl;
    }



    int maxv = 0;
    for(int i = 0; i < N; i++) {
        maxv = max(maxv, r[i]);
    }

    cout << K - maxv << endl;
    return 0;
}

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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n, k, x, y; cin >> n >> k >> x >> y;
    int i = 0, ans = 0;
    while (i < min(n, k)) {
        ans += x;
        ++i;
    }
    while (i < n) {
        ans += y;
        ++i;
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3508
from fractions import gcd
from functools import reduce


N = int(input())
T = [int(input()) for _ in range(N)]


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(ns):
    return reduce(lcm_base, ns, 1)


print(lcm(T))


Measured memory_bytes: 5076
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();

		int d = a / b;
		int r = a % b;
		double f = (double) a / b;

		System.out.printf("%d %d %f", d, r, f);
	}
}

Measured memory_bytes: 17376
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()

d=7%k

ans=1
nanawaruk=d
zyuwaruk=10%k

for i in range(10**6):
    if d==0:
        print(ans)
        exit()
    d=((nanawaruk*zyuwaruk)%k+d)%k
    zyuwaruk*=10
    zyuwaruk%=k
    ans+=1
print(-1)

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

int main() {
    int m, d, cnt = 0;
    cin >> m >> d;

    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            if ( (j%10) * (j/10) == i && j%10 >= 2 && j/10 >= 2) {
                cnt++;
            }
        }
        
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int A, B;
int main(){

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


    return 0;
}


Measured memory_bytes: 256
def Z_algorithm(s):
    n = len(s)
    A = [n] + [0] * (n-1)
    i, j = 1, 0
    while i < n:
        while i + j < n and s[j] == s[i+j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < n and k + A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
AA = [A[i] ^ A[i-1] for i in range(N)]
BB = [B[i] ^ B[i-1] for i in range(N)]

T = Z_algorithm(AA + BB + BB)
for i in range(N, 0, -1):
    if T[N+i] >= N:
        print(N-i, A[-i%N] ^ B[0])

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

using namespace std;
#define ll long long

int main()
{
	ll n, k;
	cin >> n >> k;
	ll arr[n], val[n];
	for(ll i = 0; i < n; i++)
	{
		cin >> arr[i];
		val[i] = 100000000000000;
	}
	val[n-1] = 0;
	for(ll i = n-1; i>=0; i--)
		for(ll j = i+1; j<min(n, i+k+1); j++)
			val[i] = min(abs(arr[i]-arr[j]) + val[j], val[i]);

	cout << val[0];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = 2e5 + 5, MAXM = 2e6 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f, inv2 = 500000004;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-6;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define lc(x) c[x][0]
#define PII pair<int,int>
#define rc(x) c[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
char gdffsaw;
#define G gdffsaw=getchar()
#define GO G;while(gdffsaw<'-')G
#define in(z) GO;z=gdffsaw&15;G;while(gdffsaw>'-')z*=10,z+=gdffsaw&15,G
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, a, b, v[1 << 17];

void solve(int a, int b, int m, int v[]) {
	int n = __builtin_popcount(m);
	if (n == 1) {
		v[0] = a; v[1] = b;
		return;
	}
	int x = __lg(a^b);
	bool f = a >> x & 1;
	a ^= f << x;
	b ^= (!f) << x;
	m ^= 1 << x;
	int c = a ^ (m&-m);
	solve(a, c, m, v);
	solve(c, b, m, v + (1 << (n - 1)));
	rep(i, 0, (1 << (n - 1)) - 1) {
		v[i] ^= f << x;
	}
	rep(i, (1 << (n - 1)), (1 << n) - 1) {
		v[i] ^= (!f) << x;
	}
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> a >> b;
	if (__builtin_popcount(a^b) & 1) {
		solve(a, b, (1 << n) - 1, v);
		cout << "YES\n";
		rep(i, 0, (1 << n) - 1) {
			cout << v[i] << " \n"[i + 1 == (1 << n)];
		}
	}
	else {
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	string s;
	cin>>s;
	int cnt = 0;
	int len = s.length()-1;
	for(int i=0;i<=len/2;i++){
		if(s[i]!=s[len-i])
			cnt++;
	}
	cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    sort(a.rbegin(), a.rend());
    ll sum = 0, index = 0;
    rep(i, n){
        if(i == 0){
            continue;
        }else{
            sum += a[i/2];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi t(N);
  int sum = 0;
  rep(i,N) {
    cin >> t[i];
    sum += t[i];
  }
  int M;
  cin >> M;
  rep(i,M) {
    int p,x;
    cin >> p >> x;
    p--;
    cout << sum-(t[p]-x) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		if (S.matches("^[\\d]{"+A+"}-[\\d]{"+B+"}$")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include<climits>
using namespace std;
int main() {
int n;
cin>>n;
int arr[n]={0};
for(int i=0;i<n;i++)
 cin>>arr[i];

int dp[n]={0};
dp[0]=0;
dp[1]=abs(arr[0]-arr[1]);
for(int i=2;i<n;i++)
{
    int min1=dp[i-1]+abs(arr[i]-arr[i-1]);
    int min2=dp[i-2]+abs(arr[i]-arr[i-2]);
  
    dp[i]=min(min1,min2);
   
} 

cout<<dp[n-1];

return 0;
}


Measured memory_bytes: 1024
N = int(input())
li = list(map(int,input().split()))	
res = 0
for i in range (0,N+1,2):
    res += li[i]
for i in range(1,N,2):
    res -= li[i]
a = res 
ans = [a]
for i in range(N-1):
    b = int(2 * (li[i] - a / 2))
    ans.append(b)
    a = b
for s in ans:
  print(s, end =" ")

Measured memory_bytes: 14032
#include <iostream>
using namespace std;
int main() {

  int a,b,c,d;
  cin>>a>>b>>c;
  if (c<a) {
    d=c;
    c=a;
    a=d;
  }
  if (a>b) {
    d=a;
    a=b;
    b=d;
  }
  if (b>c) {
    d=b;
    b=c;
    c=d;
  }

  cout<<a<<" "<<b<<" "<<c<<"\n";

  return 0;
}

Measured memory_bytes: 1168
# -*- coding: utf-8 -*-

from fractions import gcd
import math
from math import ceil,floor
import collections

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

def func(a):
   return tmp

A = [list(map(int, input().split())) for _ in range(3)]
N=int(input())
B = [int(input()) for _ in range(N)]

ans="No"

for i in range(0,N):
    for j in range(0,3):
        for k in range(0,3):
            if B[i]==A[j][k]:
                A[j][k]=0
                
for i in range(0,3):
    if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
        ans = "Yes"

for i in range(0,3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        ans = "Yes"

if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans = "Yes"

if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans = "Yes"

print(ans)


Measured memory_bytes: 66028
#include<stdio.h>

int main(void){
  char s[20];
  scanf("%s", &s);
  for(int i=0; i<19; i++){
    if(i==5 || i==13){
      printf(" ");
    }else{
      printf("%c", s[i]);
    }
  }
  return 0;
}

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

int v[750][750];

int main(){
    int w, h, t, p;
    while(cin >> w >> h >> t >> p, w+h+t+p){
        int oi = 0, oj = 0;
        memset(v, 0, sizeof(v));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                v[i][j] = 1;
            }
        }
        while(t-- > 0){
            int d, c;
            cin >> d >> c;
            if(d == 1){
                for(int add = 0; add < c; add++){
                    for(int i = oi; i < oi+h; i++){
                        v[i][oj+2*c-1-add] += v[i][oj+add];
                        v[i][oj+add] = 0;
                    }
                }
                oj += c;
            }else{
                for(int add = 0; add < c; add++){
                    for(int j = oj; j < oj+w; j++){
                        v[oi+2*c-1-add][j] += v[oi+add][j];
                        v[oi+add][j] = 0;
                    }
                }
                oi += c;
            }
        }

        while(p-- > 0){
            int x, y;
            cin >> x >> y;
            cout << v[oi+y][oj+x] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5224
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;



int main(){
  int n,i;
  cin >> n;
  int p[n];
  for(i=0;i<n;i++){
    cin >> p[i];
  }
  int count = 0;
  for(i=0;i<n-2;i++){
    if(((p[i] < p[i+1]) && (p[i+1] < p[i+2])) || ((p[i] > p[i+1]) && (p[i+1] > p[i+2]))){
      count++;
    }
  }
  cout << count << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll a[100005];

int main() {
  int n;
  cin >> n;
  
  for(int i = 0; i < n; i++) cin >> a[i];
  
  ll low = 2;
  ll ans = (a[0] - 1);
  for(int i = 1; i < n; i++) {
    if(a[i] < low) continue;
    if(a[i] == low) {
      low++;
      continue;
    }
    ll tmp = (a[i] - 1) / low;
    ans += tmp;
  }
 
  cout << ans << endl;
}
  


Measured memory_bytes: 1024
s = gets.chomp.split('').map(&:to_i)
array = []
sum = 0

[0, 1].repeated_permutation(s.length - 1) do |bits|
  array.clear
  array << s[0]
  
  (s.length - 1).times do |i|
    if bits[i] == 0
      array << s[i + 1]
    else
      array << "+ #{s[i + 1]}"
    end
  end
  sum += eval(array.join)
end

puts sum

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
int main(){
  ll n, over, index;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (ll i = 1; i <= n; i++) {
    if (n <= i*(i+1)/2) {
      index = i;
      over = i*(i+1)/2 - n;
      break;
    }
  }
  if (over == 0) {
    for (ll i = 1; i <= index; i++) {
      cout << i << endl;
    }
  }
  else {
    for (ll i = 1; i <= index; i++) {
      if (i == over) continue;
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int N,M,a,i,j,k,c;
int main(void){
        scanf("%d%d",&N,&M);
        int tar[M],ans,X[N];
        for(a=0;a<N;a++){
            X[a]=0;
        }
        for(i=0;i<M;i++){
            scanf("%d",&tar[i]);
        }
        for(j=0;j<M;j++){
            for(k=0;k<N;k++){
                scanf("%d",&ans);
                if(ans==tar[j]){
                    X[k]=X[k]+1;
                }else{
                    X[tar[j]-1]=X[tar[j]-1]+1;
                }
            }
        }
        for(c=0;c<N;c++){
            printf("%d\n",X[c]);
        }
return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3652
n = 5
l = [int(input()) for _ in range(n)]
ans = sum(l)
times = []
for i in l:
    num = i - (int(i / 10) * 10)
    times.append((10 - num) % 10)

times.sort()
for i in range(n - 1):
    ans += times[i]
print(ans)


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

long double rad(long double x){
    return (x*acos(-1))/180.0;
}

int main(){
    //abs((60H + M)*0.5 - 6M) <= 180 ok varna 360 - this
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double deg = abs((60*h + m)*0.5 - 6.0*m);
    deg = (deg <= 180.0) ? deg : 360.0 - deg;
    cout<<fixed<<setprecision(12)<<sqrt(a*a + b*b - 2.0*a*b*cos(rad(deg)))<<endl;
    return 0;
}

Measured memory_bytes: 4168
from collections import deque
N, Q = map(int, input().split())  # N頂点の木, Q回の操作
tree = [[] for _ in range(N)]  # N頂点の木を構築する
visited = [False]*N
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)
counter = [0]*N  # その頂点がもともと持っている力
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    counter[p] += x
# print(counter)
# exit()
q = deque([0])
visited[0] = True
while len(q):
    v = q.pop()
    for e in tree[v]:  # 親の値を伝播させていく
        if visited[e]:
            continue
        visited[e] = True
        counter[e] += counter[v]
        q.append(e)

print(*counter)


Measured memory_bytes: 56168
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
 int n,k;
 cin>>n>>k;
 int ar[n];
 for(int i=0;i<n;++i)
 {
   cin>>ar[i];
 }
 int ans[n];
 ans[0]=0;
 ans[1]=abs(ar[1]-ar[0]);
 for(int i=2;i<n;++i)
 {
   ans[i]=ans[i-1]+abs(ar[i]-ar[i-1]);
   for(int j=i;j>=max(0,i-k);--j)
   ans[i]=min(ans[i],ans[j]+abs(ar[i]-ar[j]));
 }
 
 cout << ans[n-1]<<'\n';

 }
    
  





  



Measured memory_bytes: 4404
#include <iostream>
#include <queue>
#define FIN freopen("inputs.txt", "r", stdin)
using namespace std;
#define MAX_H 20
#define MAX_W 20
char maze[MAX_H][MAX_W];
typedef pair<int, int> P;
#define INF 0x7fffffff
int d[MAX_H][MAX_W];
int h, w;
int res = 0;
int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0};
void bfs(int sx, int sy)
{
    if(maze[sx][sy] == '#') return;
    queue<P> q;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            d[i][j] = INF;
        }
    }
    q.push(P(sx, sy));
    d[sx][sy] = 0;
    while(!q.empty()){
        P p = q.front(); q.pop();
        // if(p.first == gx && p.second == gy) break;
        res = max(d[p.first][p.second] ,res);
        for (int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(nx >= 0 && nx < h && ny >= 0 && ny < w
            && maze[nx][ny] != '#' && d[nx][ny] == INF){
                q.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
}
// search for the shortest path, diganoally
int main(){
// FIN;
    cin>>h>>w;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin>>maze[i][j];
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            bfs(i, j);            
        } 
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    #
    t = sum(int(i) for i in A) / (4 * M)
    ans = 0
    for a in A:
        if a >= t:
            ans += 1
        if ans == M:
            print("Yes")
            return 0
    print("No")
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i])ans++;
    }
    cout << ans << endl;
    //cin >> s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define MAXN 10000

int isprime(int);

int main(){
  int i, j, k, n[10000], count=0;

  for(i=0; scanf("%d",&n[i]) == 1; i++);

  for(j = 0; j < i; j++){
    if(isprime(n[j])){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int x){
  int i = 3;
  
  if(x == 2) return 1;
  if(x < 2 || x%2 == 0) return 0;
  
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i+2;
  }
  
  return 1;
}

Measured memory_bytes: 628
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(long long I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  FOR(n,1,3501) {
    FOR(w,1,3501) {
      if(4 * n * w > N * (w + n)) {
        if((N * n * w) % (4 * n * w - N * (w + n)) == 0) {
          cout << (N * n * w) / (4 * n * w - N * (w + n)) << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int i, c=700;
    char S[10];

    gets(S);
    for(i=0; i<3; i++)
    {
        if(S[i]=='o')
            c=c+100;
    }
    printf("%d\n", c);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	cout << (n+k-3)/(k-1) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N, R;
  cin >> N >> R;
  if (N >= 10)
  {
    cout << R << endl;
  }
  else
  {
    cout << R + 100 * (10 - N) << endl;
  }
}

Measured memory_bytes: 3616
m = input().split()
K = int(m[0])
N = int(m[1])

A = input().split()
a = [0] * N

for i in range(N):
  a[i] = int(A[i])

#import pdb; pdb.set_trace()
Sum = 0
n = N -1
for x in range(N):
  if x == n:
    Sum += (K - a[n]) + a[0]
  else:
    Sum += a[x+1] - a[x]

ans = [0] * N
for k in range(N):
  if k == n:
    ans[k] = (K - a[n]) + a[0]
  else:
    ans[k] = a[k+1] - a[k]

l = max(ans)

min_road = Sum - l
print(min_road)

Measured memory_bytes: 26484
#include<bits/stdc++.h>
using namespace std;
long long rep(int i,long long cur,long long sum,const string s) {
	if(i==s.size()) {
		return sum;
	}
	int d=s[i]-'0';
	long long res=0;
	if(i+1 != s.size())
	res+=rep(i+1,cur*10+d,sum,s);
	res+=rep(i+1,0,sum+cur*10+d,s);
	return res;
}
int main()
{
	string S;
	while(cin>>S) {
		long long ans=rep(0,0,0,S);
		cout<<ans;
	}
	return 0;	
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        var red = new int[n][];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Split(' ');
            red[i] = new[] { int.Parse(s[0]), int.Parse(s[1]) };
        }

        var blue = new int[n][];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Split(' ');
            blue[i] = new[] { int.Parse(s[0]), int.Parse(s[1]) };
        }

        Array.Sort(red, (a, b) => b[1] - a[1]);
        Array.Sort(blue, (a, b) => a[0] - b[0]);

        var ans = 0;
        var v = new bool[n];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (!v[j])
                {
                    if (red[j][0] < blue[i][0] &&
                        red[j][1] < blue[i][1])
                    {
                        ans++;
                        v[j] = true;
                        break;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220