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

int main(){
    int N;  cin >> N;
    vector<vector<vector<vector<ll>>>> dp(N+1, vector<vector<vector<ll>>>(4, vector<vector<ll>>(4, vector<ll>(4, 0))));
    int A = 0, G = 1, C = 2, T = 3;
    for(int i=0; i<4; i++)for(int j=0; j<4; j++)for(int k=0; k<4; k++){
        if(i==A && j == G && k == C){
            dp[3][i][j][k] = 0;
        }else if(i==A && j == C && k == G){
            dp[3][i][j][k] = 0;
        }else if(i==G && j == A && k == C){
            dp[3][i][j][k] = 0;
        }else{
            dp[3][i][j][k] = 1;           
        }
    }
    ll mod = 1e9+7;
    for(int n=3; n<N; n++)for(int i=0; i<4; i++)for(int j=0; j<4; j++)for(int k=0; k<4; k++){
        if(i==G && k==C){
            dp[n+1][G][G][j] = (dp[n+1][G][G][j] + dp[n][G][j][C])%mod;
            dp[n+1][C][G][j] = (dp[n+1][C][G][j] + dp[n][G][j][C])%mod;
            dp[n+1][T][G][j] = (dp[n+1][T][G][j] + dp[n][G][j][C])%mod;
        }else if(j==G && k==C){
            dp[n+1][G][i][G] = (dp[n+1][G][i][G] + dp[n][i][G][C])%mod;
            dp[n+1][C][i][G] = (dp[n+1][C][i][G] + dp[n][i][G][C])%mod;
            dp[n+1][T][i][G] = (dp[n+1][T][i][G] + dp[n][i][G][C])%mod;
        }else if(i==G && j==C){
            dp[n+1][G][G][C] = (dp[n+1][G][G][C] + dp[n][G][C][k])%mod;
            dp[n+1][C][G][C] = (dp[n+1][C][G][C] + dp[n][G][C][k])%mod;
            dp[n+1][T][G][C] = (dp[n+1][T][G][C] + dp[n][G][C][k])%mod;
        }else if(i==C && j==G){
            dp[n+1][G][C][G] = (dp[n+1][G][C][G] + dp[n][C][G][k])%mod;
            dp[n+1][C][C][G] = (dp[n+1][C][C][G] + dp[n][C][G][k])%mod;
            dp[n+1][T][C][G] = (dp[n+1][T][C][G] + dp[n][C][G][k])%mod;
        }else if(i==A && j==C){
            dp[n+1][A][A][C] = (dp[n+1][A][A][C] + dp[n][A][C][k])%mod;
            dp[n+1][C][A][C] = (dp[n+1][C][A][C] + dp[n][A][C][k])%mod;
            dp[n+1][T][A][C] = (dp[n+1][T][A][C] + dp[n][A][C][k])%mod;
        }else{
            for(int l = 0; l<4; l++){
                dp[n+1][l][i][j] = (dp[n+1][l][i][j] + dp[n][i][j][k])%mod;
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<4; i++)for(int j=0; j<4; j++)for(int k=0; k<4; k++){
        ans = (ans + dp[N][i][j][k])%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;
#define PI 3.141592653589793


double CCC(double a,double b,double c){
  double x=((c*2)/a)-b;
  return b-x;
}

double CC(double a,double b,double c){
  return c/b*2;
}

int main(){
  cout << setprecision(20) << std::fixed;
  double a,b,x,tana,min;
  cin>>a>>b>>x;
  if(a*a*b<x*2){
    double xmin=CCC(a,b,x/a);
    tana=a/xmin;
    min=-90.0000000000000000000;
  }
  else{
    double xmin =CC(a,b,x/a);
    tana=b/xmin;
    min=0.0000000000000000000000;
  }
  cout<<abs(min + atan(tana) * 180.0 / PI);
}





Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {

	string res = "Good";
	string S; cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) res = "Bad";

	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100005];
	long long ans=0;
	long long c=0;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i-1];
		if(a[i-1]!=0)
			c+=a[i-1];
		if(a[i-1]==0 or i==n)
		{
			ans+=c/2;
			c=0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
long long f1(long long X1,long long C1,long long D1){
  long long G1=GCD(C1,D1);
  long long L1=C1/G1*D1;
  return X1-X1/C1-X1/D1+X1/L1;
}
int main(){
  long long A,B,C,D;cin>>A>>B>>C>>D;
  cout<<f1(B,C,D)-f1(A-1,C,D)<<endl;
}
  


Measured memory_bytes: 256
while 1:
	try:
		n = input()
		x = 0
		if n < 37:
			for a in range(10):
				for b in range(10):
					for c in range(10):
						for d in range(10):
							if a + b + c + d == n:
									x += 1
		print x
	except EOFError:
		break

Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k,x,y,s;
   cin>>n>>k>>x>>y;
   if(n<=k)
   {
       cout<<x*n<<"\n";
   }
   else
   {
       s=(k*x)+(n-k)*y;
       cout<<s<<"\n";

   }
return 0;}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,p;
  cin >> n >> p;
  ll ev=0,od=0;
  REP(i,n){
    ll ai;
    cin >> ai;
    if(ai%2==1) od++;
    else ev++;
  }
  ll ans = 0;
  while(p<=od){
    ll tmp = 1;
    ll pl = min(p,od-p);
    REP(i,pl) tmp *= od-i;
    REP(i,pl) {
      tmp /= i+1;
    }
    ans += tmp;
    //cout << od << "C" << p << " = " << tmp << endl;
    p += 2;
  }
  REP(i,ev) ans *= 2;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
import copy

def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    global N
    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])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
graph = copy.deepcopy(A)
# for a in A:
#     print(a)
# 余分な辺を消去する問題
A = warshal_floyd(A)
for i in range(N):
    for j in range(N):
        if A[i][j] != graph[i][j]:
            print(-1)
            exit()

# 最短経路であることは分かった
flag = [[True]*N for _ in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph[i][j] == graph[i][k] + graph[k][j] and i != k and k != j:
                flag[i][j] = False

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if flag[i][j] == True:
            ans += graph[i][j]
print(int(ans))


Measured memory_bytes: 58076
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;




int main(void){
	string S;
	cin>>S;
	ll digit = S.length();
	ll ans = 9*(digit-1);
	ans += S[0]-'0'-1;
	bool can=true;
	reg(i,1,digit-1){
		if(S[i]!='9'){
			can=false;
			break;
		}
	}
	if(can)ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N): a.append(int(input()))
lis = [float("inf") for _ in range(N)]
reva = a[: : -1]

for i in range(N):
  j = br(lis, reva[i])
  lis[j] = reva[i]

res = N
for i in range(N):
  if lis[i] == float("inf"):
    res = i
    break
print(res)

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

int main() {
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	while (a[0] < a[1]) {
		a[0] += 2;
		ans++;
	}
	if (a[0] != a[1]) ans++;
	while (a[1] < a[2]) {
		a[2]--;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 

////////////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    ll ans = 0;
    rep(i, 0, sz(s)-1){
        if(s[i]!=s[i+1]) ans++;
    }
    co(ans);

    return 0;
}


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

int main() {
    vector<int> result; // 結果を出力するための配列
    bool tf = true; // ループを抜けるためのフラグ
    while (tf) {
        int n,x;
        scanf("%d%d", &n,&x);
        if (n == 0 && x == 0) {
            tf = false;
            continue;
        }
        int count = 0; // カウンター
        for (int a = 1; a <= n-2; a++) {
            for (int b = a+1; b <= n-1; b++) {
                for (int c = b+1; c <= n; c++) {
                    if (a + b + c == x) {
                        count++;
                    }
                }
            }
        }
        result.push_back(count);
    } 
    for (int x : result) {
        printf("%d\n", x);
    }
}


Measured memory_bytes: 3248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>
typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}


int main(void) {
	string s;
	cin >> s;
	int a[4];
	for (int i = 0; i < 4; i++) {
		a[i] = s[i] - '0';
	}
	if (a[0] + a[1] + a[2] + a[3] == 7) {
		cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] + a[1] + a[2] - a[3] == 7) {
		cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] + a[1] - a[2] + a[3] == 7) {
		cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=" << 7; 
		return 0;
	}
	if (a[0] - a[1] + a[2] + a[3] == 7) {
		cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] + a[1] - a[2] - a[3] == 7) {
		cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] - a[1] - a[2] + a[3] == 7) {
		cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] - a[1] + a[2] - a[3] == 7) {
		cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=" << 7;
		return 0;
	}
	if (a[0] - a[1] - a[2] - a[3] == 7) {
		cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=" << 7;
		return 0;
	}
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n;lint tim;
int val[_],fir[_]={0},las[_]={0},to[_]={0};
int ed[_]={0},stk[_]={0},top=0;
int ans[_]={0},lans=0;

int main()
{
	n=ty(),tim=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	for(int i=n;i>=1;i--)fir[val[i]]=i;
	to[n+1]=1;
	for(int i=n;i>=1;i--)
	{
		if(!las[val[i]])to[i]=fir[val[i]]+1;
		else to[i]=to[las[val[i]]+1];
		las[val[i]]=i;
	}
	for(int x=1;!ed[x];x=to[x])stk[++top]=x,ed[x]=1;

	memset(ed,0,sizeof(ed));
	for(int i=stk[(tim-1)%top+1];i<=n;i++)
	{
		if(!ed[val[i]])ans[++lans]=val[i],ed[val[i]]=1;
		else do{ed[ans[lans]]=0,lans--;}while(ans[lans+1]!=val[i]);
	}

	for(int i=1;i<=lans;i++)printf("%d%c",ans[i]," \n"[i==lans]);

	return 0;
}


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

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

  string s,t;
  for (int i=0; i<b; i++) s += to_string(a);
  for (int i=0; i<a; i++) t += to_string(b);

  cout << ( s < t ? s : t ) << endl;
}

Measured memory_bytes: 256
require 'prime'

def valid(nums)
  nums.combination(5).all? {|nums| nums.inject(:+).prime_division.length!=1 }
end

random = Random.new


n = gets.strip.to_i

correct_primes = (2..55555).to_a.select(&:prime?).select {|e| e%5==1 }

puts correct_primes[0..n-1].join(' ')




Measured memory_bytes: 3000
#include <iostream>
using namespace std;
int main(){
int n, t, a[3]={0};
cin >> n;
for(int i=0;i<n;i++){
cin >> t;
a[t%2==0?t%4==0?2:1:0]++;
}
if((a[1] && a[0] <= a[2]) || (!a[1] && a[0] <= a[2] +1))
cout <<"Yes";
else
cout << "No";
cout << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

ll f2(ll a) {
	if (a % 4 == 0) return a;
	if (a % 4 == 1) return 1;
	if (a % 4 == 2) return a + 1;
	return 0;
}

ll f(ll a, ll b) {
	return f2(b) ^ f2(a - 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll ans = f(a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    vl sum(n+1),pl(n+1);
    rep(i,n) sum[i+1] = sum[i]+a[i];
    rep(i,n) pl[i+1] = pl[i]+max(a[i],0);
    ll ans = 0;
    rep(i,n-k+1) {
        ll nans = 0;
        nans += pl[i];
        nans += pl[n]-pl[i+k];
        nans += max(sum[i+k]-sum[i],0LL);
        chmax(ans,nans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5292
import math

A,B,H,M = map(int, input().split())

ax = A * math.cos((180-(H*60+M))/720*2*math.pi)
ay = A * math.sin((180-(H*60+M))/720*2*math.pi)
bx = B * math.cos(((15-M)/60)*2*math.pi)
by = B * math.sin(((15-M)/60)*2*math.pi)

# print(ax,ay,bx,by)
print(math.sqrt((ax-bx)**2+(ay-by)**2))

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

int n, v, a[2][100010];
pair<int, int> p[2][2];

int main(){
	cin >> n;
	memset(a, 0, sizeof(a));
	for (int i = 0; i < n; ++i){
		cin >> v;
		a[i%2][v]++;
	}
	for (int j = 0; j < 2; ++j){
		for (int i = 0; i < 2; ++i){
			p[j][i] = {-1, 0};
		}
	}
	for (int j = 0; j < 2; ++j){
		for (int i = 0; i < 100010; ++i){
			if (p[j][0].second <= a[j][i]){
				p[j][1] = p[j][0];
				p[j][0] = {i, a[j][i]};
			}
			else if (p[j][1].second <= a[j][i]){
				p[j][1] = {i, a[j][i]};
			}
		}
	}
	if (p[0][0].first != p[1][0].first) cout << (n - p[0][0].second - p[1][0].second);
	else{
		if (p[0][1].second < p[1][1].second) cout << (n - p[0][0].second - p[1][1].second);
		else cout << (n - p[0][1].second - p[1][0].second);
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll k;
    cin >> k;
    ll a, b;
    a = k / 50;
    b = k % 50;
    cout << 50 << endl;
    for (int i = 0; i < 50; i++) {
        cout << 49+a-b + (i<b)*50 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n;

signed main(){
    char c; cin >> c;
    cout << ++c << endl;
    return 0;
}

Measured memory_bytes: 256
ss=input().split(" ")
N=int(ss[0])
M=int(ss[1])
x=1
y=N
for i in range(M):
  tt=input().split(" ")
  if int(tt[0])>x:
    x=int(tt[0])
  if int(tt[1])<y:
    y=int(tt[1])
last=int(y-x+1)
if last>0:
  print(last)
else:
  print(0)

  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (1000000007)
#define N (10010)
int n,a[N],ans;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=2;i<n;i++) 
		if ((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1])) ++ans;
	printf("%d",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

const ll INF = 1e18;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n;
	cin >> n;
	vll v(n + 1), mx_nodes(n + 1), actual_nodes(n + 1);
	for(int i = 0; i <= n; i++)
		cin >> v[i];
	bool poss = 1;
	ll cur = 1;
	if(n == 0){
		if(v[0] == 1){
			cout << 1 << endl;
			return 0;
		}
		cout << -1 << endl;
		return 0;
	}
	for(ll i = 0; i <= n; i++){
		if(v[i] > cur){
			cout << -1 << endl;
			return 0;
		}
		cur -= v[i];
		mx_nodes[i] = cur;
		cur *= 2;
		cur = min(cur, INF);
		actual_nodes[i] = v[i];
	}
	ll ans = 1;
	for(ll i = n; i >= 1; i--){
		ans += actual_nodes[i];
		actual_nodes[i - 1] += min(actual_nodes[i], mx_nodes[i - 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5580
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
#include<complex>
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep2(i, j, n) for (int i = j; i < (int)(n); i++)

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


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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n;
  string a, b;
  cin >>n >> a >> b;
  for (int i = 0; i < n; i++) {
    cout << a[i] << b[i];
  }
  cout <<endl;
} 


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

int count(int n, map<int, int> mp)
{
  int ret = 0;
  for (auto m : mp)
  {
    if (n <= m.second)
      ret++;
  }
  return ret;
}

int main()
{
  int N;
  cin >> N;
  map<int, int> prime;
  for (int i = 2; i <= N; i++)
  {
    int value = i;
    for (int j = 2; j * j <= value; j++)
    {
      while (value % j == 0)
      {
        if (prime.find(j) == prime.end())
          prime[j] = 1;
        else
          prime[j] = prime[j] + 1;
        value /= j;
      }
    }
    if (value != 1)
    {
      if (prime.find(value) == prime.end())
        prime[value] = 1;
      else
        prime[value] = prime[value] + 1;
    }
  }
  int ans = 0;
  // p^74
  ans += count(74, prime);
  // p^24 * q^2
  ans += count(24, prime) * (count(2, prime) - 1);
  // p^14 * p^4
  ans += count(14, prime) * (count(4, prime) - 1);
  // p^4 * q^4 * r^2
  ans += count(4, prime) * (count(4, prime) - 1) * (count(2, prime) - 2) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
m = 10**9+7
N = int(input())
A = list(map(int,input().split()))
B = (N+1)*[0]

for n in range(N+1):
  if B[A[n]]==0:
    B[A[n]]=n+1
  else:
    S = B[A[n]]+N-n-1
    break

p = 1
q = 1

for n in range(1,N+2):
  p = ((p*(N+2-n))*pow(n,m-2,m))%m
  q = (1 if n==1 and S>=n-1 else(0 if S<n-1 else ((q*(S-n+2))*pow(n-1,m-2,m)))%m)
  print((p-q)%m)

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  string S;
  int n=0;
  cin >> S;
  
  REP(i,4){
    if(S.at(i) == '+') n++;
    else n--;
  }
  
  cout << n << endl;
  
  return 0;
}

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

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d",&n);
    while(n>0){
        if(n%10==7){
            printf("Yes");
            return  0;
        }
        n/=10;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    ll n,m; cin >> n >> m;
    ll v,p; cin >> v >> p;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a),greater<ll>());
    // print(a);
    auto check = [&](int ind){
        bool ret = true;
        // vector<ll> plus(n,0);
        ll cnt = 0;
        ll to = m+a[ind];
        // debug(ind);debug(to);debug(a[p-1]);
        if(to < a[p-1])return false;
        rep(i,n){
            if(i < p-1)cnt += m;
            else cnt += min(m,to - a[i]);
        }
        if(cnt < m*v)ret = false;
        return ret;
    };
    ll ok = 0;
    ll ng = n-1;
    assert(check(ok));
    if(check(ng)){
        cout << n << endl;
        return 0;
    }
    while(abs(ok - ng) > 1){
        ll x = (ok + ng) / 2;

        if(check(x))ok = x;
        else ng = x;
    }

    cout << ok+1 << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    StringBuilder sb = new StringBuilder();
    int count = 0;
    int cb = 0;
    for (int i = 0; i < N; i++) {
      if ((S[i] == 'a' && count < A + B) || (S[i] == 'b' && count < A + B && cb < B)) {
        count++;
        if (S[i] == 'b') cb++;
        sb.append("Yes").append('\n');
      } else {
        sb.append("No").append('\n');
      }
    }
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 28292
N = int(input())
X = [list(map(int,input().split())) for i in range(2*N)]

Alist = []
Blist = []

for i in range(N):
	Alist.append(X[i]+[0])
	Blist.append(X[i+N])

Alist.sort(key=lambda Alist:[-Alist[1],Alist[0]])
Blist.sort(key=lambda Blist:[Blist[0],-Blist[1]])
ans = 0
j = 0
while j<N:
	i = 0
	while i < len(Alist):
		if (Alist[i][0]<Blist[j][0] and Alist[i][1]<Blist[j][1]):
			ans += 1
			del Alist[i]
			break
		i+=1
	j+=1

print(ans)

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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N;
vi A;
int F, S;

signed main() {

    in(N);
    A.resize(N);
    in(A);
    for (auto e:A) {
        if (e > F) {
            S = F;
            F = e;
        }else if (e > S) {
            S = e;
        }
    }
    rep(i, N) {
        if (A[i] == F) {
            out(S);
        } else {
            out(F);
        }
    }


    return 0;
}


Measured memory_bytes: 3200
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

 
int main(int argc, char *argv[]){
    int N, D;

    scanf("%d %d", &N, &D);
    printf("%d\n", (int)ceil((float)N/((float)D*2+1)));
 
    return 0;
}





Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int a, N, i ,j ,minj ,n = 0;
  int A[100] = {0};
  
  scanf("%d", &N);
  
  for (i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }
  
  for (i = 0; i < N; i++){
    minj = i;
    for (j = i; j < N; j++){
      if (A[j] < A[minj]){
        minj = j;
      }
    }
    if (i != minj){
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      n++;
    }
  }
  
  
  for (i = 0; i < N - 1; i++){
    printf("%d ", A[i]);
  }
  
  
  printf("%d\n%d\n",A[i] ,n);
  
  
  return 0;
}

Measured memory_bytes: 600
// id: ALDS1_2_D
// 注：使用cin cout 01:27sec 使用scanf printf sec
//#include <iostream>
#include <cstdio>
#include <vector>

//using std::cin;
//using std::cout;
//using std::endl;
using std::vector;

//static const int MAX_N = 1000000;
vector<int> sequence;

int shell_sort(int a[], int n);

int main()
{
	int n, *arr;
	// int arr[MAX_N];  错误：声明在main函数里，栈空间约1M，所需空间4M左右，溢出。
	int move_times;
	vector<int>::size_type m;

	//cin >> n;
	scanf("%d", &n);

	arr = new int[n];
	for ( int i = 0; i < n; ++i )
		scanf("%d", &arr[i]);
		//cin >> arr[i];

	move_times = shell_sort(arr, n);
	m = sequence.size();
	
	//cout << m << endl;
	printf("%d\n", m);

	//cout << sequence[m - 1];
	printf("%d\n", sequence[m - 1]);
	for ( int i = m - 2; i >= 0; --i ) //i的类型不能声明成auto
		printf(" %d", sequence[i]);
		//cout << " " << sequence[i];
	//cout << endl;
	printf("\n");

	//cout << move_times << endl;
	printf("%d\n", move_times);
	
	for ( int i = 0; i < n; ++i )
		printf("%d\n", arr[i]);
		//cout << arr[i] << endl;

	delete[] arr;

	return 0;
}

int shell_sort(int a[], int n)
{
	int cnt = 0;
	int h = 1;

	do {
		sequence.push_back(h);
		h = 3 * h + 1;
	} while ( h < n );

	for ( int i = sequence.size() - 1; i >= 0; --i ) { // i的类型不能声明成auto
		int increment = sequence[i];
		int k, tmp;

		for ( int j = increment; j < n; ++j ) {
			tmp = a[j];

			for ( k = j; k >= increment && a[k - increment] > tmp; k -= increment ) {
				a[k] = a[k - increment];
				++cnt;
			}

			a[k] = tmp;
		}
	}

	return cnt;
}


Measured memory_bytes: 6360
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int ans = 0;
        for (int i = A; i <= B; i++) {
        	String s = String.valueOf(i);
        	if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) {
        		ans++;
        	}
        }
        
        
        System.out.println(ans);
    }
}




Measured memory_bytes: 26452
import java.util.*;
public class Main{


	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

		long s  =sc.nextLong();
		long w  =sc.nextLong();
			if(w>=s) {
				System.out.println("unsafe");
			}else {
				System.out.println("safe");

			}
		
	}

}


Measured memory_bytes: 35832
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int wascolor;
	cin>>wascolor;
	int ans = 0;
	for(int i=1;i<N;++i){
		int iscolor;
		cin>>iscolor;
		if(wascolor==iscolor){
			++ans;
			wascolor = 10001;
		}else{
			wascolor = iscolor;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
# |i - j| = A[i] + A[j] を i > j として絶対値を外して
# 式変形すると i - A[i] = j + A[j]
# dp[s] を j + A[j]が、sであるjの個数、ただし j < i とする
# iのペア候補の数はdp[i - A[i]] になるので、dpを更新しながら、足し上げる

N = gets.to_i
A = gets.split.map(&:to_i)
dp = Hash.new(0)
ans = 0
A.each_with_index do |a,i|
  ans += dp[i - a]
  dp[i + a] += 1
end
puts ans

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

int main() {
    
    
 int n;
 cin>>n;
 
 
 cout<<48-n;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	int a=0;
	int oddcount=0;
	int evencount = 0;
	int b4count=0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 != 0) { oddcount++; }
		else if (a % 4 == 0) { b4count++; }
		if (a % 2 == 0 && a%4!=0) { evencount++; }
	}
	if (b4count >= oddcount) { cout << "Yes" << endl; }
	else if (b4count + 1 == oddcount && evencount % 2 == 0) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

struct edge{
    int to,cost;
    edge(int t,int c){
        to = t;
        cost = c;
    }
};

template<typename T>
void dijkstra(int s,vector<vector<edge>>& path,vector<T>& d){
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));
    d[s] = 0;
    while(!q.empty()){
        P p = q.top();
        q.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        REP(i,path[v].size()){
            edge e = path[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                q.push(P(d[e.to],e.to));
            }
        }
    }
    return ;
}

int main(){
    int k;
    cin >> k;
    vector<vector<edge>> p(k);
    REP(i,k){
        int temp = i*10%k;
        //if(temp!=i){
            p[i].push_back(edge(temp,0));
        //}
        p[i].push_back(edge((i+1)%k,1));
    }
    vector<int> d(k,INT_MAX/2);
    int s = 1;
    dijkstra(s, p, d);
    put(d[0]+1);
    return 0;
}


Measured memory_bytes: 6780
num=int(input())

a=num//1000
b=(num-a*1000)//100
c=(num-a*1000-b*100)//10
d=(num-a*1000-b*100-c*10)

op=["+","-"]
flg = 0


for i in range(2):
    if flg == 1:break
    for j in range(2):
        if flg == 1:break
        for k in range(2):
            if flg == 1:break
            out = str(a)+op[i]+str(b)+op[j]+str(c)+op[k]+str(d)
            if eval(out) == 7:
                out += "=7"
                flg = 1

print(out)
            

Measured memory_bytes: 3064
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
for i in range(x):
    print('R',end='')
for i in range(y):
    print('U',end='') 
for i in range(x):
    print('L',end='') 
for i in range(y):
    print('D',end='')
print('D',end='')
for i in range(x+1):
    print('R',end='')
for i in range(y+1):
    print('U',end='')
print('L',end='')
print('U',end='')
for i in range(x+1):
    print('L',end='')
for i in range(y+1):
    print('D',end='')
print('R',end='')

Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using Bool = bool;
using Int = long long int;
using String = std::string;
template <class T>
using Vector = std::vector<T>;

struct {
    Int h, w;
    Vector<String> s, t;
    Bool possible;
    Vector<Int> col;

    void check(Int b) {
        Int x;
        for (x = 0; x < w; ++x) {
            if (!((b >> x) & 1)) break;
        }

        if (x == w) {
            possible = true;
            return;
        }

        String z = t[x];
        std::reverse(z.begin(), z.end());

        for (Int y = x + 1; y < w; ++y) {
            if (!((b >> y) & 1)) {
                if (t[y] == z) {
                    check(b | (1 << x) | (1 << y));
                    return;
                }
            }
        }
    }

    void check_lonely() {
        if (w % 2 == 0) {
            check(0);
        } else {
            for (Int x = 0; x < w; ++x) {
                String z = t[x];
                std::reverse(z.begin(), z.end());
                if (z == t[x]) check(1 << x);
            }
        }
    }

    void align() {
        for (Int y = 0; y < w; ++y) {
            for (Int x = 0; x < h; ++x) {
                t[y][x] = s[col[x]][y];
            }
        }
        check_lonely();
    }

    void enumcol(Int b, Int i) {
        Int x;
        for (x = 0; x < h; ++x) {
            if (!((b >> x) & 1)) break;
        }
        if (x == h) {
            align();
            return;
        }

        for (Int y = x + 1; y < h; ++y) {
            if (!((b >> y) & 1)) {
                col[i] = x;
                col[h - i - 1] = y;
                enumcol(b | (1 << x) | (1 << y), i + 1);
            }
        }
    }

    void enumcol_lonely() {
        if (h % 2 == 0) {
            enumcol(0, 0);
        } else {
            for (Int x = 0; x < h; ++x) {
                col[h / 2] = x;
                enumcol(1 << x, 0);
            }
        }
    }

    void operator()() {
        possible = false;
        std::cin >> h >> w;

        s.resize(h), t.resize(w);
        for (auto& x : s) std::cin >> x;
        for (auto& y : t) y.resize(h);

        col.resize(h);
        enumcol_lonely();
    }
} solve;

int main() {
    solve();
    std::cout << (solve.possible ? "YES" : "NO") << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
for e in sys.stdin:
 a=float(e)
 t=[a,
 a*2,
 a*2/3,
 a*2/3*2,
 a*2/3*2/3,
 a*2/3*2/3*2,
 a*2/3*2/3*2/3,
 a*2/3*2/3*2/3*2,
 a*2/3*2/3*2/3*2/3,
 a*2/3*2/3*2/3*2/3*2]
 print(sum(t))


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int N, K, C;
string S;

void solve() {
    vi L(K+2), R(K+2);

    L[0] = -1e9;
    R[K+1] = 1e9;

    int k = 0;
    REP (i, N) if (S[i] == 'o') {
        if (L[k] + C < i + 1) {
            k++;
            L[k] = i+1;
            if (k == K) break;
        }
    }
    k = K+1;
    REPR (i, N) if (S[i] == 'o') {
        if (i + C + 1 < R[k]) {
            k--;
            R[k] = i+1;
            if (k == 1) break;
        }
    }

    FOR (k, 1, K+1) {
        if (L[k] == R[k]) cout << L[k] << endl;
    }
}

int main() {
    cin >> N >> K >> C >> S;
    solve();
}

Measured memory_bytes: 4996
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
print(sum(sorted(NextIntList())[:k]))

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

int main() {
  int a,b;
  cin >> a >> b;
  vector<int> t(a);
  for(int i = 0; i < a; i++){
    cin >> t[i];
  }
  for(int i = b; i < a; i++){
    if(t[i] > t[i-b]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4048
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *,const void *);
int fun(int *,int );
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int fun(int *a,int n)
{
    int i;
    qsort(a,n,sizeof(a[i]),cmp);
    return a[n-1]-a[0];
}
int main()
{
    int a[1000],n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("%d\n",fun(a,n));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin>>N;
  
  long long dp[101][4][4][4];
  dp[0][3][3][3]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        for(int l=0;l<4;l++){
          if(j==0 && k==1 && l==2) dp[i+1][j][k][l]=0;
          else if(j==1 && k==0 && l==2) dp[i+1][j][k][l]=0;
          else if(j==0 && k==2 && l==1) dp[i+1][j][k][l]=0;
          else if(j==1 && l==2)  dp[i+1][j][k][l]=(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%1000000007;
          else if(k==1 && l==2)  dp[i+1][j][k][l]=(dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%1000000007;
          else dp[i+1][j][k][l]=(dp[i][0][j][k]+dp[i][1][j][k]+dp[i][2][j][k]+dp[i][3][j][k])%1000000007;
        }
      }
    }
  }
  
  long long ans=0;
  for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        for(int l=0;l<4;l++){
          ans+=dp[N][j][k][l];
          ans=ans%1000000007;
        }
      }
  }
  if (ans<0) ans+=1000000007;
  cout<<ans<<endl;
}
  
          

Measured memory_bytes: 256