akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> oks(n + 1, 1);
  for (int i = 0; i < m; i++){
    int tmp;
    cin >> tmp;
    oks[tmp] = 0;
  }
  vector<long long int> ans(n + 5, 0);
  int b = 0;
  ans[0] = 1;
  //ans[1] = 1;

  for (int i = 0; i < n; i++){
    for (int j = i + 1; j <= min(n, i+2); j++){
      if(oks[j] == 1){
        ans[j] += ans[i];
        ans[j] %= mod;
      }
    }
    //        1000000007 
  }
  cout << ans[n] << "\n";
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin >>A >> B;
  C=A*B;
  if(A<10&&B<10){
  cout << C <<endl;
  }
  else if(A>=10||B>=10){
  cout << "-1" <<endl;
  }
  
}

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

Measured memory_bytes: 128
import fractions

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

LCM = [T[0]]
for i in range(1, N):
    gcd = fractions.gcd(LCM[i-1], T[i])
    lcm = LCM[i-1] * T[i] // gcd
    LCM.append(lcm)

print(LCM[-1])

Measured memory_bytes: 5088
table = [[[0]*10 for i in range(0,3)] for k in range(0,4)]

N = int(input())

for loop in range(N):
    house_id, floor, room, add = map(int, input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print('#'*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(' %d' % table[i][a][b], end ='')
        print()



Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,p[10000],sum,d,kk,ans,lsg;
bool flag[10000];
void write(int x){if (x)write(x/10),putchar(x%10+'0');} 
signed main(){
	cin>>n;lsg=1e9+7;for (int i=2;i<=n;i++){
		if (!flag[i])p[++kk]=i;
		for (int j=1;j<=kk;j++){
			if (p[j]*i>n)break;
			flag[p[j]*i]=1;
			if (i%p[j]==0)break;
		}
	}ans=1;
	for (int i=1;i<=kk;i++){
		d=0;sum=n;while (sum){
			sum/=p[i];d+=sum;
		}(ans*=d+1)%=lsg;
	}cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long int n,m,x,a;
	cin>> n>>m;
	x=n;
	a=m-2*n;
	if(n*2<m)n+=(m-(2*x))/4,m-=(m-(2*x))/4*2;
	if(n*2<=m)cout << n;
	else cout << m/2<<"\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define int long long
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FORR(i, a, b) for (int i = (a); i >= (b); i--)
 
#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()
 
#define INT_INF 200000000
 
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)
 
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
 
//the end of library zone

int N, A, B;

int lev1;
int lev2;
int lev3;

signed main(){
	cin >> N;
	cin >> A >> B;
	
	REP(i, N){
		int h = 0;
		cin >> h;
		if(h <= A){
			lev1++;
		}
		else if(h <= B){
			lev2++;
		}
		else{
			lev3++;
		}
	}
	
	cout << min(lev1, min(lev2, lev3)) << endl;
	
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
xlis = list(map(int, input().split()))
ret = 10 ** 100
for i in range(n-k+1):
    min_val = xlis[i]
    max_val = xlis[k+i-1]
    if min_val * max_val >= 0:
        tmp = max(abs(min_val), abs(max_val))
        ret = min(ret, tmp)
    else:
        fst = min(abs(min_val), abs(max_val))
        lst = max(abs(min_val), abs(max_val))
        tmp = fst * 2 + lst
        ret = min(ret, tmp)

print(ret)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int X, N;
    cin >> X >> N;

    vector<int> V(102, 1);
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        V.at(p) = 0;
    }

    int ans = 1e9;
    for (int i = 0; i <= 101; ++i) {
        if (V.at(i) == 0) continue;
        if (abs(X - i) == abs(X - ans)) {
            ans = min(ans, i);
        } else if (abs(X - i) < abs(X - ans)) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <cstring>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int m ,n;

int main()
{
    int a,b,c;
    int k = 0;
    cin>>a>>b>>c>>k;
    int temp = 0;
    if(a>temp)temp = a;
    if(b>temp)temp = b;
    if(c>temp)temp = c;
    int sum = a+b+c;
    while(k--)
    {
        sum += temp;
        temp*=2;
    }
    cout<<sum<<endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005

int a[maxn] ;
int n ;

bool check(int x, int y)
{
    int initX = x , initY = y ;
    multiset< int > ms ;
    for(int i=1;  i<=n ; i++) ms.insert(a[i]) ;

    ms.erase(ms.find(x)) ; ms.erase( ms.find(y) ) ;

    for(int i=3 ; i<=n ; i++)
    {
        if( ms.find( x^y ) == ms.end() ) return false ;
        ms.erase( ms.find(x^y) ) ;
        int temp = x^y ;
        x = y ;
        y = temp ;
    }
  //  printf("%d %d\n",x,y) ;
  //  printf("%d %d %d %d\n",initX,initY,x^y,y^initX) ;
    if( (x^y) != initX || (y^initX)!=initY ) return false ;
    return true ;
}

int main()
{
    scanf("%d",&n) ;

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

    sort(a+1,a+n+1) ;

    bool fl1 = check(a[1],a[2]) ;
    bool fl2 = check(a[1],a[n]) ;

  //  cout<<fl1<<fl2<<endl ;

    bool fl3 = false ;

    for(int i=2 ; i<n ; i++)
    {
        if( a[i]!=a[1] && a[i]!=a[n] )
        {
            fl3 = check(a[1],a[i]) ;
            break ;
        }
    }

  //  cout<<fl1<<fl2<<fl3<<endl ;

    if(fl1|fl2|fl3) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}


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

int main() {
  int K; cin >> K; //何番目か？
  queue<ll> que;  // ルンルン数を下から入れていくキュー
  int C=0;  // 今何番目のルンルン数か？
  ll wk_1,wk_2;

  // １から９は常にルンルン数
  rep1(i,9){
    wk_1 = i;
    if(K==++C){ cout << wk_1 << endl; return 0; } // 判定して
    que.push(wk_1);                               // 終わらなかったら、溜める
  }

  ll Y; // 剰余用
  while(C<K){
    wk_2 = que.front();que.pop(); // que の先頭を取得して削除
    Y = wk_2%10;  // 末尾の値を取得

    // －１のルンルン数
    if(Y>0){
      wk_1 = wk_2*10 + Y - 1;
      if(K==++C){ cout << wk_1 << endl; return 0; } // 判定して
      que.push(wk_1);                               // 終わらなかったら、溜める
    }
    // そのまま同じルンルン数
    wk_1 = wk_2*10 + Y;
    if(K==++C){ cout << wk_1 << endl; return 0; } // 判定して
    que.push(wk_1);                               // 終わらなかったら、溜める
    // ＋１のルンルン数
    if(Y<9){
      wk_1 = wk_2*10 + Y + 1;
      if(K==++C){ cout << wk_1 << endl; return 0; } // 判定して
      que.push(wk_1);                               // 終わらなかったら、溜める
    }
  }
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s, t;
	cin >> s >> t;

	for (int i = 0; i < n; ++i) {
		if (s.substr(i, n - i) == t.substr(0, n - i)) {
			cout << n + i << "\n";
			return 0;
		}
	}

	cout << 2 * n << "\n";

	return 0;

}

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

void print_vec(vector<int> A)
{
	for(int i = 0 ; i < A.size() ; i++)
	{
		cout<<A[i]<<" ";
	}
	cout<<endl;
}


int main()
{
  int n;
  cin>>n;
  vector<int> A(n-1);
  
  for(int i = 0 ; i < (n-1) ; i++)
  {
  	cin>>A[i];
  }
  int ans = A[0];
  for(int i =0 ; i< (n-2) ; i++)
{
	ans += min(A[i],A[i+1]);
}
ans += A[n-2];
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i,sum;
	sum=0;
	for(i=1;i<=5;i++){
		scanf("%d",&a);
		if(a<40){
			a=40;
		}
		sum+=a;
	}
	printf("%d\n",sum/5);
	return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1005;
#define M 1000000007
#define double long double
#define BINF 1000000000001
#define init(a,val) memset(a,val,sizeof(a))
const int LG = 22;


 
#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0); 
 
    


    int n;
    cin >> n;
    n--;

    cout << (n * (n + 1)) / 2;



 
return 0;
}

Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	
	int count = 0;
	bool flag = 0;
	do {
		flag = 0;
		REP(i, n-1){
			int tmp;
			if (a[i] > a[i+1]){
				tmp = a[i];
				a[i] = a[i+1];
				a[i+1] = tmp;
				count++;
				flag = 1;
			}
		}
	} while (flag);

	REP(i, n){
		if (i < n-1) cout << a[i] << " ";
		else cout << a[i] << endl;
	}

	cout << count << endl;
}


Measured memory_bytes: 3100
#include<iomanip>
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<set>
using namespace std;
int s[200005],c[200005]={1};
char str[200005];
long long ans=0;
int main(){
	cin>>(str+1);
	int n=strlen(str+1); 
	for(int i=n,t=1;i>=1;i--,t=t*10%2019){
		s[i]=(s[i+1]+(str[i]-'0')*t)%2019;
		ans+=c[s[i]];
		//cout<<s[i]<<' '<<c[s[i]]<<endl;
		c[s[i]]++;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 4600
s = input()
t = input()
x,y,f = [-1]*26,[-1]*26,1
for i in range(len(s)):
	if x[ord(s[i])-97]!=y[ord(t[i])-97]: f=0
	else: x[ord(s[i])-97],y[ord(t[i])-97] = i,i
if f: print("Yes")
else: print("No")

Measured memory_bytes: 3632
/*input
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
#define endl '\n'
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
int dp[1001][1001];
char some[1001][1001];
signed main()
{
	speed
	int h,w;
	cin>>h>>w;
	rep(i,h)
	{
		rep(j,w)
		{
			cin>>some[i][j];
		}
	}
	dp[0][0]=1;
	for(int i=1;i<w;i++)
	{
		if(some[0][i]=='#')
		{
			dp[0][i]=0;
		}
		else
		{
			dp[0][i]=dp[0][i-1];
		}
	}
	for(int i=1;i<h;i++)
	{
		if(some[i][0]=='#')
		{
			dp[i][0]=0;
		}
		else
		{
			dp[i][0]=dp[i-1][0];
		}
	}
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			if(some[i][j]=='#')
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modd;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

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

#define x 0
#define y 1

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;

    int vec12[2] = {x2 - x1, y2 - y1};
    int vec23[2] = {-1 * vec12[y], vec12[x]}, vec34[2] = {-1 * vec12[x], -1 * vec12[y]};
    x3 = x2 + vec23[x];
    y3 = y2 + vec23[y];
    x4 = x3 + vec34[x];
    y4 = y3 + vec34[y];

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
bool nooverflow(int a, int b) {
  return a < LLONG_MAX / b;
}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  int nums[n];
  bool flag = false;
  for(int i = 0; i < n; ++i) {
    cin >> nums[i];
    if(nums[i] == 0) flag = true;
  }
  if(flag) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1;
  for(int i = 0; i < n; ++i) {
    if(!nooverflow(ans, nums[i])) {
      cout << -1 << endl;
      return 0;
    }
    if(ans * nums[i] > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
    ans *= nums[i];
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 4372
#include <cstdio>

#include <algorithm>

using namespace std;

const int N = 110;

int n;
int sie[N], cnt[N], dp[N][N];

int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    if (!sie[i]) {
      int x = n;
      while (x) {
        cnt[i] += x / i;
        x /= i;
      }
      for (int y = i + i; y <= n; y += i)
        sie[y] = 1;
    }
  }
  dp[0][1] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= cnt[i]; ++j)
      for (int v = 1; v * (j + 1) <= 75; ++v)
        dp[i][v * (j + 1)] += dp[i - 1][v];
  }
  printf("%d\n", dp[n][75]);
  return 0;
}


Measured memory_bytes: 256
n = str(input())
one_idx = []
nine_idx = []
for idx in range(len(n)):
	if n[idx]=='1':
		one_idx.append(idx)
	if n[idx]=='9':
		nine_idx.append(idx)

out = ''
for idx in range(len(n)):
	if idx in one_idx:
		out += '9'
	if idx in nine_idx:
		out += '1'
          
print(out)

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

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    string ans = s + t;
    for (int i = 0; i <= t.size(); i++) {
        string str = s + t.substr(i);
        if (str.substr(str.size() - t.size()) == t) {
            ans = str;
        }
    }
    cout << ans.size() << endl;
    return 0;
}

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

int64_t fib(int x) {
	int64_t a = 1;
	int64_t b = 1;
	if (x <= 0) 
		return 0;
	else {
		for (int i = 0; i < x - 1; i++) {
			int64_t c = a;
			a = b;
			b = c + b;
			b = b % 1000000007;
		}
	}

	return a;
}
int main() {
	int N, M;
	int64_t ans = 1;
	cin >> N >> M;
	vector<int>v(M + 2);
	for (int i = 0; i < M + 2; i++) {
		if (i == 0)
			v.at(i) = -1;
		else  if (i == M + 1)
			v.at(i) = N + 1;
		else
			cin >> v.at(i);
	}
	for (int i = 0; i < M + 1; i++) {
		ans = (ans * fib(v.at(i+1)-v.at(i)-1)) % 1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]

import collections
e = collections.Counter(a)
#for i in e:　print(i,e[i])

for i in range(1,1+n):
  if k - q + e[i] > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 11920
X, Y, A, B, C = map(int, input().split())
p = [int(c) for c in input().split()]
q = [int(c) for c in input().split()]
r = [int(c) for c in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:X]
q = q[:Y]
a = X-1
b = Y-1
for i in range(C):
  if p[a]<q[b]:
    if p[a]<r[i]:
      p[a] = r[i]
      a -= 1
    else:
      break
  else:
    if q[b]<r[i]:
      q[b] = r[i]
      b -= 1
    else:
      break
print(sum(p)+sum(q))

Measured memory_bytes: 104548
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
    if H[i] - H[i+1] > 1:
        print("No")
        quit()

for i in range(1, N-1):
    if H[i] > H[i+1] or H[i-1] < H[i]:
        H[i] -= 1
        if H[i-1] > H[i] or H[i] > H[i+1]:
            print("No")
            break
    else:
        continue
else:
    print("Yes")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long A, long long B)
{
    cout << max(0LL,(N - 1) * B + A - (N - 1) * A - B + 1) << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
int n,a[MAX];
void maxHeapify(int); 
int main(){
  int i;
  scanf("%d",&n);
for(i=1;i<=n;i++){
  scanf("%d",&a[i]);
 }
for(i=n/2;i>=1;i--){
  maxHeapify(i);
 }
for(i=1;i<=n;i++){
    printf(" %d",a[i]);
 }
 printf("\n");
return 0;
}

void maxHeapify(int x){
  int l,r,largest,z;
  l=x*2;
  r=x*2+1;
  if(l<=n&&a[l]>a[x])
    largest=l;
  else
    largest=x;
  if(r<=n&&a[r]>a[largest])
    largest=r;
  if(largest!=x){
    z=a[x];
    a[x]=a[largest];
    a[largest]=z;
    maxHeapify(largest);
  }   
}



Measured memory_bytes: 3656
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<ll> cnt(60,0);
ll n;
ll k;

ll dfs(ll i,bool f){
    if(i==0){
        if(f && k%2==0){return cnt[i];}
        else{return max(cnt[i],n-cnt[i]);}
    }
    if(f && (k>>i)%2==0){
        return dfs(i-1,f)+(1LL<<i)*cnt[i];
    }
    if(f){
        return max(dfs(i-1,f)+(1LL<<i)*(n-cnt[i]),dfs(i-1,false)+(1LL<<i)*cnt[i]);
    }
    return dfs(i-1,f)+(1LL<<i)*max(cnt[i],n-cnt[i]);
}


int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll A;
        cin>>A;
        for(ll t=59;t>=0;t--){
            cnt[t]+=(A>>t&1);
        }
    }
    cout<<dfs(59,true)<<endl;
    
    
    return 0;
}


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

template<class T>
struct SegTree {
  using FX = function<T(T, T)>;
  int n, _n;
  FX fx;
  const T ex;
  vector<T> dat;
  SegTree(int n_, FX fx_, T ex_):fx(fx_), ex(ex_), n(1), _n(n_) {
    while(n < n_) n <<= 1;
    dat.assign((n<<1)-1, ex);
  }
  SegTree(vector<T> &v, FX fx_, T ex_):fx(fx_), ex(ex_), n(1), _n(int(v.size())) {
    int n_ = int(v.size());
    while(n < n_) n <<= 1;
    dat.assign((n<<1)-1, ex);
    copy(v.begin(), v.end(), dat.begin()+n-1);
    for(int i = n-2; i >= 0; i--) dat[i] = fx(dat[chld(i)], dat[chrd(i)]);
  }
  inline int chld(int k) {return (k<<1)+1;}
  inline int chrd(int k) {return (k<<1)+2;}
  void update(int i, T x) {
    i += n-1;
    dat[i] = x;
    while(i) {
      i = (i-1)>>1;
      dat[i] = fx(dat[chld(i)], dat[chrd(i)]);
    }
  }
  inline T query(int a, int b) {return query(a, b, 0, 0, n);}
  T query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return ex;
    if(a <= l && r <= b) return dat[k];
    T vl = query(a, b, chld(k), l, (l+r)>>1);
    T vr = query(a, b, chrd(k), (l+r)>>1, r);
    return fx(vl, vr);
  }
  template<class F>
  int max_right(int l, F f) {
    assert(f(ex));
    if(l == _n) return _n;
    l += n;
    T now = ex;
    do {
      while(~l&1) l >>= 1;
      if(!f(fx(now, dat[l-1]))) {
        while(l < n) {
          l <<= 1;
          if(f(fx(now, dat[l-1]))) {
            now = fx(now, dat[l++ - 1]);
          }
        }
        return l-n;
      }
      now = fx(now, dat[l++ - 1]);
    } while((l & -l) != l);
    return _n;
  }
  template<class F>
  int min_left(int r, F f) {
    assert(f(ex));
    if(r == 0) return 0;
    r += n;
    T now = ex;
    do {
      r--;
      while(r > 1 and r&1) r >>= 1;
      if(!f(fx(dat[r-1], now))) {
        while(r < n) {
          r = chld(r);
          if(f(fx(dat[r-1], now))) {
            now = fx(dat[--r], now);
          }
        }
        return r+1-n;
      }
      now = fx(dat[r-1], now);
    } while((r & -r) != r);
    return 0;
  }
  const T &operator[](int idx) const {return dat[idx+n-1];}
};



int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  vector<int> a(n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  reverse(a.begin(), a.end());
  SegTree<int> seg(a, [](int i, int j)->int {return max(i, j);}, INT_MIN);
  while(q--) {
    int type, x, y;
    scanf("%d%d%d", &type, &x, &y);
    x = n-x+1;
    if(type == 1) {
      seg.update(x-1, y);
    }
    if(type == 2) {
      y = n-y;
      printf("%d\n", seg.query(y, x));
    }
    if(type == 3) {
      printf("%d\n", n+1-seg.min_left(x, [y](int X)->bool{return X < y;}));
    }
  }
}

Measured memory_bytes: 6080
#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll h,n;
  cin >> h >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];

  REP(i,n){
    h-=a[i];
  }
  if(h<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;

int main()
{   
    int K,S;
    int count = 0;
    cin >> K >> S;

    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            int res = S-i-j;
            if(res>=0 && res<=K){
                count++;
            }
        }
    }
    cout << count;
  
    return 0;
}

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

int main() {
	// your code goes here
	int n,x,t;
	cin>>n>>x>>t;
	int k=n/x;
	if(n%x==0)
	{
		cout<<(n/x)*t;
	}
	else
	cout<<((n/x)*t)+t;
	return 0;
}

Measured memory_bytes: 3608
#coding:utf-8
#1_8_C
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
class Tree:
    def __init__(self):
        self.root = None

    def insert(self, node):
        y = None # set parent
        x = self.root
        while x is not None:
            y = x
            if node.key < x.key:
                x = x.left
            else:
                x = x.right
    
        if y is None:
            self.root = node
        elif node.key < y.key:
            y.left = node
            node.parent = y
        else:
            y.right = node
            node.parent = y

    def find(self, node, key):
        if node is None:
            return None

        if key == node.key:
            return node
        elif key < node.key:
            return self.find(node.left, key)
        else:
            return self.find(node.right, key)

    def delete(self, key):
        del_node = self.find(self.root, key)
        if del_node.right and del_node.left:
            # del_node has two children
            right_min = del_node.right
            while right_min.left:
                right_min = right_min.left
            tmp = right_min.key
            self.delete(right_min.key)
            del_node.key = tmp
        elif del_node.right or del_node.left:
            # del_node has only one children
            child = del_node.right if del_node.right else del_node.left
            if del_node.parent.right == del_node:
                del_node.parent.right = child
                child.parent = del_node.parent
            else:
                del_node.parent.left = child
                child.parent = del_node.parent
        else:
            # del_node has no child
            if del_node.parent.right == del_node:
                del_node.parent.right = None
            else:
                del_node.parent.left = None


def inorder(node):
    if node is None:
        return
    inorder(node.left)
    print(" {}".format(node.key), end = "")
    inorder(node.right)

def preorder(node):
    if node is None:
        return
    print(" {}".format(node.key), end = "")
    preorder(node.left)
    preorder(node.right)

def execute(tree, cmd):
    if cmd[0] == 'insert':
        t.insert(Node(int(cmd[1])))
    elif cmd[0] == 'find':
        if tree.find(tree.root, int(cmd[1])):
            print('yes')
        else:
            print('no')
    elif cmd[0] == 'delete':
        tree.delete(int(cmd[1]))
    else:
        inorder(t.root)
        print()
        preorder(t.root)
        print()

m = int(input())
t = Tree()
for i in range(m):
    execute(t, input().split())

Measured memory_bytes: 124432
using System;

class Program {
  const int BUCKET_SIZE = 100010;
  static void Main(string[] args) {
    int N = int.Parse(Console.ReadLine());
    string[] A = Console.ReadLine().Split();
    int[] B = new int[BUCKET_SIZE];

    for (int i = 0; i < N; ++i) {
      ++B[int.Parse(A[i])];
    }

    int ans = 0;
    for (int i = 1; i < BUCKET_SIZE - 1; ++i) {
      ans = Math.Max(ans, B[i-1] + B[i] + B[i + 1]);
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 18784
#include<stdio.h>
void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
#define MAX 500000
int Right[MAX/2+2],Left[MAX/2+2];
int count;
int main(){
  int data[MAX],n,i,key;
  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&data[i]);
  mergeSort(data,n,0,n);

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

void mergeSort(int data[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(data,n,left,mid);
    mergeSort(data,n,mid,right);
    merge(data,n,left,mid,right);
  }
}

void merge(int data[],int n,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++)Right[i]=data[left+i];
  for(int i=0;i<n2;i++)Left[i]=data[mid+i];
  Right[n1]=Left[n2]=1000000000;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    count++;
    if(Left[i]<=Right[j])data[k]=Left[i++];
    else data[k]=Right[j++];
  }
}



Measured memory_bytes: 5636
/*
Code Author: ADITYA SHETH (^_^)
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 998244353
#define endl "\n" 
#define int long long // remove when constraints are tight.
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ar[7];
	memset(ar,0,sizeof(ar));
	ar[0]=n;
	int ans=1;
	
	for(int i=0;i<3*n;i++)
	{
		if(s[i]=='R')
		{
			int cur=1;
			int cc=6;
			int cp1=2;
			int cp2=3;
			int cpp1=4;
			int cpp2=5;
			if(ar[cc])
			{
				ans=ans*ar[cc];
				ans%=MOD;
				ar[cc]--;
			}
			else if(ar[cp1])
			{
				ans*=ar[cp1];
				ans%=MOD;
				ar[cp1]--;
				ar[cpp1]++;
			}
			else if(ar[cp2])
			{
				ans*=ar[cp2];
				ans%=MOD;
				ar[cp2]--;
				ar[cpp2]++;
			}
			else
			{
				ans*=ar[0];
				ar[0]--;
				ans%=MOD;
				ar[cur]++;
			}	
		}
		else if(s[i]=='B')
		{
			int cur=2;
			int cc=5;
			int cp1=1;
			int cp2=3;
			int cpp1=4;
			int cpp2=6;

			if(ar[cc])
			{
				ans=ans*ar[cc];
				ans%=MOD;
				ar[cc]--;
			}
			else if(ar[cp1])
			{
				ans*=ar[cp1];
				ans%=MOD;
				ar[cp1]--;
				ar[cpp1]++;
			}
			else if(ar[cp2])
			{
				ans*=ar[cp2];
				ans%=MOD;
				ar[cp2]--;
				ar[cpp2]++;
			}
			else
			{
				ans*=ar[0];
				ar[0]--;
				ans%=MOD;
				ar[cur]++;
			}	
		}
		else
		{
			int cur=3;
			int cc=4;
			int cp1=1;
			int cp2=2;
			int cpp1=5;
			int cpp2=6;

			if(ar[cc])
			{
				ans=ans*ar[cc];
				ans%=MOD;
				ar[cc]--;
			}
			else if(ar[cp1])
			{
				ans*=ar[cp1];
				ans%=MOD;
				ar[cp1]--;
				ar[cpp1]++;
			}
			else if(ar[cp2])
			{
				ans*=ar[cp2];
				ans%=MOD;
				ar[cp2]--;
				ar[cpp2]++;
			}
			else
			{
				ans*=ar[0];
				ar[0]--;
				ans%=MOD;
				ar[cur]++;
			}	
		}
		//t(i,ans);
	}
	cout<<ans<<endl;
}


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

int cup[100],stat[100],sum[100],wat[200];
int N,SET;

int search(int cc,int left,int look,int num){
	int i;

	if(look<N)stat[look]=1;

	if(left==0){
		if(cc<N)stat[cc]=2;
		//for(i=N-1;i>=0;i--){if(stat[i]==0)break;}
		if(num==0)return 1;
		for(i=N-1;i>=0;i--){
			if(stat[i]==0)break;
			if(stat[i]==1 && search(i,cup[i],99,num))return 1;
		}
		if(look<N)stat[look]=0;
		stat[cc]=1;
		return 0;
	}

	int ccc=(look<N) ? look:cc;

	for(i=ccc-1;i>=0;i--){
		if(left<cup[i])continue;
		if(sum[i]<left)break;
		if(stat[i]==0 && search(cc,left-cup[i],i,num-1))return 1;
		if(i==cc-1 && stat[i]==0)break;
	}

	if(look<N)stat[look]=0;

	return 0;
}

int main(){
    int i,j,k;

    while(scanf("%d",&N)*N){
		SET++;

		for(i=0;i<=100;i++)wat[i]=0;
		for(i=0;i<N;i++){
			scanf("%d",&k);
			wat[k]++;
		}
		for(i=0,j=0,k=0;i<=100,j<N;i++){
			for(;wat[i]>0;wat[i]--){
				k+=i;
				cup[j]=i;
				stat[j]=0;
				sum[j]=k;
				j++;
			}
		}

		if(search(99,0,N-1,N-1))printf("YES\n"); else printf("NO\n");

    }
 
    return 0;
}

Measured memory_bytes: 588
N = input()
A = list(map(int, input().split()))

k = 1
if 0 in A:
    print(0)
else:
    for i in A:
        k = k * i
        if k > 10 ** 18:
            print(-1)
            break
        
    if k <= 10 ** 18:
            print(k)

Measured memory_bytes: 21716
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	
	s1[0] -= 0x20;
	s2[0] -= 0x20;
	s3[0] -= 0x20;

	cout << s1[0] << s2[0] << s3[0] << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,H,in[411],out[411];
bool e[411][411],d[411];
void dfs(int w){
	d[w]=1;
	for(int i=0;i<=H*2;++i)if(e[w][i]&&!d[i])dfs(i);
}
void ae(int x,int y){
	++out[x],++in[y];
	e[x][y]=1;
}
int main(){
	scanf("%d%d",&n,&H);
	for(int i=0,a,b,c,d;i<n;++i){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		ae(c?H+c:a,d?d:H+b);
	}
	for(int i=1;i<=H;++i){
		int w=i;
		if(in[w]>out[w])return puts("NO"),0;
		while(in[w]<out[w])ae(0,w);
		w=H+i;
		if(in[w]<out[w])return puts("NO"),0;
		while(in[w]>out[w])ae(w,0);
	}
	if(in[0]!=out[0])return puts("NO"),0;
	dfs(0);
	for(int i=1;i<=H*2;++i)if((in[i]|out[i])&&!d[i])return puts("NO"),0;
	return puts("YES"),0;
}

Measured memory_bytes: 384
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }

const int MOD = 1e9+7;
// }}}

int chk(LL v) {
    cout << "? " << v << endl;
    fflush(stdout);
    char c;
    R(c);
    return c == 'Y';
}

int main() {
    if (chk(1e9)) {
        LL v = 999999999ll, p=1000000000;
        while (v && chk(v)) v/=10, p/=10;
        cout << "! " << p << endl;
        return 0;
    }
    LL p=1;
    while (chk(p)) p*=10;

    LL l=p/10, r=p-1, m;
    while (l<r) {
        m = (l+r)/2;
        if (chk(m*10)) r=m;
        else l=m+1;
    }

    cout << "! " << l << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,g,b; cin>>r>>g>>b;
    if ((g*10+b)%4==0){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
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;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k, a = 0; cin >> n >> k;
	rep(i, n){
		int x; cin >> x;
		a += x >= k;
	}
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]


def checknum(x,y):
    count = 0
    for i in range(-1,2):
        for j in range(-1,2):
            nx = x+i
            ny = y+j
            if 0 <= nx < h and 0 <= ny < w and l[nx][ny] == "#":
                count += 1
    return count

for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            l[i][j] = checknum(i,j)
for i in range(h):
    for j in range(w):
        print(l[i][j],end="")
    print()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i).first;
        a.at(i).second = i + 1;
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << a.at(i).second;
        if (i == n - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 3952
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

int n;
int min_cnt[26], curr_cnt[26];

int main(void) {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    memset(curr_cnt, 0, sizeof curr_cnt);

    for (char c : s)
      curr_cnt[c - 'a']++;

    for (int j = 0; j < 26; ++j)
      if (i == 0)
        min_cnt[j] = curr_cnt[j];
      else
        min_cnt[j] = min(min_cnt[j], curr_cnt[j]);
  }

  for (int i = 0; i < 26; ++i)
    for (int j = 0; j < min_cnt[i]; ++j)
      cout << (char) ('a' + i);

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
   int n, k, sum = 0;

   cin >> n >> k;
   vector<int> ve(n);

   for(int i = 0; i < n; i++) cin >> ve.at(i); 
   sort(ve.begin(), ve.end());
   for(int i = n - 1; i > n - 1 - k; i--) sum += ve.at(i);

   cout << sum << endl;
}

Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(4100000)

N = int(input())
root = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    root[u-1].append([v-1,w%2])
    root[v-1].append([u-1,w%2])

ans = [-1 for i in range(N)]

def dfs(index):
    if ans[index]==-1:
        ans[index] = 0
    for i in root[index]:
        if ans[i[0]] == -1:
            ans[i[0]] = (ans[index]+i[1])%2
            dfs(i[0])

for i in range(N):
    dfs(i)

for i in ans:
    print(i)

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

struct UnionFind {
    vector<size_t> parents;
    UnionFind(size_t n) : parents(n) {
        iota(parents.begin(), parents.end(), 0ul);
    }
    size_t root(size_t x) {
        if (parents[x] == x) return x;
        return parents[x] = root(parents[x]);
    }
    bool same(size_t x, size_t y) {
        return root(x) == root(y);
    }
    void unite(size_t x, size_t y) {
        x = root(x); y = root(y);
        if (x != y) parents[x] = y;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edges(m);
    cin >> edges;
    int ans = 0;
    for (const auto& del : edges) {
        UnionFind uf(n+1);
        for (const auto& e : edges) {
            if (e != del) uf.unite(e.first, e.second);
        }
        if (!uf.same(del.first, del.second)) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
import time
import random
d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [random.choice(range(26)) for i in range(d)]

score = 0
start = time.time()
while True:
    now = time.time()
    if now - start > 1.5:
        break
    p = random.choice(range(d))
    q = random.choice(range(26))
    memo = T[p]
    T[p] = q
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    new_score = 0
    for i in range(d):
        new_score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        new_score -= C[j] * (dd - X[j])
    temp = 20000 * (1 - (now - start) / 2)
    prob = 2**(max(min(new_score - score, 0), -10**4) / temp)
    u = random.random()
    if u < prob:
        score = new_score
    else:
        T[p] = memo

for t in T:
    print(t + 1)


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

int main(void)
{
	int n;
	double xa,ya,ra,xb,yb,rb;
	double dist;
	
	scanf("%d",&n);
	for(; n>0; n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		dist=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if(dist>ra+rb){
			printf("%d\n",0);
		}else if(dist<ra-rb){
			printf("%d\n",2);
		}else if(dist<rb-ra){
			printf("%d\n",-2);
		}else{
			printf("%d\n",1);
		}
	}
	return 0;
}

Measured memory_bytes: 636