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


int get_height(int node, int left[], int right[], int height[]);
int get_depth(int node, int parent[], int depth[]);
void show_info(int node, int parent[], int sibling[], int degree[], int depth[], int height[]);


int main()
{
    int parent[26];
    int sibling[26];
    int degree[26];
    int depth[26];
    int height[26];
    int left[26];
    int right[26];
    int n, node, L, R;
    cin >> n;
    for (int i = 0; i != n; ++i){
        parent[i] = -1;
        sibling[i] = -1;
        degree[i] = 0;
        depth[i] = -1;
        height[i] = -1;
    }
    for (int i = 0; i != n; ++i){
        cin >> node >> L >> R;
        left[node] = L;
        right[node] = R;
        if (L != -1){
            parent[L] = node;
            sibling[L] = R;
            degree[node] += 1;
        }
        if (R != -1){
            parent[R] = node;
            sibling[R] = L;
            degree[node] += 1;            
        }
    }
    int root = -1;
    for (int i = 0; i != n; ++i){
        if (parent[i] == -1){
            root = i;
            break;
        }
    }
    depth[root] = 0;
    for (int i = 0; i != n; ++i) get_depth(i, parent, depth);
    get_height(root, left, right, height);
    for (int i = 0; i != n; ++i) show_info(i, parent, sibling, degree, depth, height);
    return 0;
}

int get_depth(int node, int parent[], int depth[]){
    if (depth[node] != -1) return depth[node];
    depth[node] = get_depth(parent[node], parent, depth) + 1;
    return depth[node];
}

int get_height(int node, int left[], int right[], int height[]){
    if (node == -1) return -1;
    if (height[node] != -1) return height[node];
    int left_height = get_height(left[node], left, right, height);
    int right_height = get_height(right[node], left, right, height);
    height[node] = max(left_height, right_height) + 1;
    return height[node];
}

void show_info(int node, int parent[], int sibling[], int degree[], int depth[], int height[]){
    cout << "node " << node << ": parent = " << parent[node] << ", ";
    cout << "sibling = " << sibling[node] << ", degree = " << degree[node] << ", ";
    cout << "depth = " << depth[node] << ", height = " << height[node] << ", ";
    if (parent[node] == -1){
        cout << "root" << endl;
    }else if (degree[node] == 0){
        cout << "leaf" << endl;
    }else{
        cout << "internal node" << endl;
    }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
        cout.tie(0);
	ll a;
	cin>>a;
	ll k;
	k=a+a*a+a*a*a;
	cout<<k<<endl;
}

Measured memory_bytes: 3648
// https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll A, B, C;
  cin >> A >> B >> C;

  bool ok = A < C && C < B || A > C && C > B;
  string res = ok ? "Yes" : "No";
  cout << res << "\n";
}


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

int main(){
    int n ;
    cin >> n ;
    vector<int> A(1000001,0) ;
    vector<int> p(n) ;
    rep(i,n){  
        cin >> p.at(i) ;
        if( A[p.at(i)] == 0 ) for(int j = 1 ; p.at(i)*j <= 1000000 ; j++ ) A[p.at(i)*j]++ ;
        else A[p.at(i)]++ ;
    }
    int count = 0 ;
    rep(i,n) if( A[p.at(i)] == 1 ) count++ ;
    cout << count << endl; 
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(b%a==0)
        cout << a + b << endl;
        else
            cout << b - a << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int a[9], i = 0;
	for (; i < 9; i++)
		scanf("%d", &a[i]);
	if (a[0] + a[5] + a[7] == a[1] + a[3] + a[8] && a[1] + a[3] + a[8] == a[2] + a[4] + a[6])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  vector<int> tmp = a;
  sort(a.rbegin(), a.rend());
  int biggest = a[0];
  int next = a[1];
  for (auto v : tmp) {
    if (v == biggest) {
      cout << next << endl;
    } else {
      cout << biggest << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4836
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int MAX_T = 3005;
int prv[MAX_T], nxt[MAX_T];
int main()
{
	int N, T, S;
	cin >> N >> T >> S;
	
	vint A(N), B(N);
	rep(i, N) cin >> A[i] >> B[i];
	
	rep(i, N)
	{
		rep(t, T)
		{
			if((t + B[i] <= S || S <= t) && t + B[i] <= T)
			{
				nxt[t + B[i]] = max(prv[t]+ A[i], prv[t + B[i]]);
			}
			
			chmax(nxt[t], prv[t]);
		}
		
		memcpy(prv, nxt, sizeof nxt);
	}
	
	cout << *max_element(nxt, nxt + T + 1) << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M;
int k[11],p[11];
vector<int> s[11];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M;
  REP(i,M) {
    cin >> k[i];
    s[i].resize(k[i]);
    REP(j,k[i]) cin >> s[i][j],s[i][j]--;
  }
  REP(i,M) cin >> p[i];
  int ans = 0;
  REP(ms,POW(N)) {
    int cnt = 0;
    REP(i,M) {
      int sum = 0;
      REP(j,k[i]) {
        if ((ms >> s[i][j]) & 1) sum++;
      }
      if (sum%2 == p[i]) cnt++;
    }
    if (cnt == M) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define f(i,a,b) for(int i=(a); i<=(b);++i)
const unsigned int M = 1000000007;
int main()
{
    long long int n,x=100;
    int sum=0;
    cin>>n;
    while(x<n){
        x+=(x*0.01);
        sum++;
        //printf("%lf\n", x);
    }
    printf("%d\n", sum);
    return 0;
}




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

char str[10];

int main(){
    scanf(" %s", str);
    if(str[0] = 'S' && str[1] == 'U' && str[2] == 'N'){
        printf("7");
    }else if(str[0] = 'M' && str[1] == 'O' && str[2] == 'N'){
        printf("6");
    }else if(str[0] = 'T' && str[1] == 'U' && str[2] == 'E'){
        printf("5");
    }else if(str[0] = 'W' && str[1] == 'E' && str[2] == 'D'){
        printf("4");
    }else if(str[0] = 'T' && str[1] == 'H' && str[2] == 'U'){
        printf("3");
    }else if(str[0] = 'F' && str[1] == 'R' && str[2] == 'I'){
        printf("2");
    }else if(str[0] = 'S' && str[1] == 'A' && str[2] == 'T'){
        printf("1");
    }
}


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

Q=int(input())

q=[]
right=[]
left=[]

rev=1

for i in range(Q):
    q.append(input().split())
    if q[i][0]=="1":
        rev=rev*(-1)
    elif q[i][0]=="2":
        if q[i][1]=="1":
            if rev==1:
                right.append(q[i][2])
            else:
                left.append(q[i][2])
        elif q[i][1]=="2":
            if rev==1:
                left.append(q[i][2])
            else:
                right.append(q[i][2])
right.reverse()
if rev==1:
    S_list=right+S_list+left
else:
    S_list=right+S_list+left
    S_list.reverse()

S=''.join(S_list)
print(S)

Measured memory_bytes: 45940
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N;

    cin >> N;
    vec A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        sc.close();

        long aftA = a - k;
        long aftB = b;
        if (aftA < 0) {
            aftB = aftB + aftA;
            aftA = 0;
        }

        if (aftB < 0) {
            aftB = 0;
        }

        System.out.println(aftA + " " + aftB);
    }

}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
	int in1, in2, ans1, ans2;
	double ans3;
	scanf("%d %d", &in1, &in2);
	ans1 = in1 / in2;
	ans2 = in1 % in2;
	ans3 = (double)in1 / (double)in2;
	printf("%d %d %.5lf", ans1, ans2, ans3);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> X(N+1, 0);
  for(int i=0;i<N;i++) std::cin >> X[i+1];
  int L, Q;
  std::cin >> L;
  vvi ne = vv(N+1, 0, 0, int);
  for(int i=1;i<=N;i++){
    int n = upper_bound(X.begin(), X.end(), X[i]+L) - X.begin();
    ne[i].push_back(n-1);
  }
  bool flag = true;
  while(flag){
    flag = false;
    for(int i=1;i<=N;i++){
      int t = ne[i].size()-1;
      if(ne[i][t]!=N) {
        flag = true;
        int k = ne[i][t];
        ne[i].push_back(ne[k][ne[k].size()-1]);
      }
    }
  }
  /*
  for(int i=1;i<=N;i++){
    for(int j=0;j<ne[i].size();j++) std::cout << ne[i][j] << " ";
    std::cout << '\n';
  }
  */
  std::cin >> Q;
  int a, b;
  std::vector<int> T(64, 1);
  for(int i=1;i<64;i++) T[i] = T[i-1] * 2;
  for(int i=0;i<Q;i++){
    int ans = 0;
    std::cin >> a >> b;
    if(a>b) swap(a, b);
    while(a!=b){
      if(ne[a][0]>=b){
        ans++;
        break;
      }
      auto itr = upper_bound(ne[a].begin(), ne[a].end(), b);
      itr--;
      if(b==N) itr--;
      ans+=T[itr-ne[a].begin()];
      a = *itr;
    }
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 16384
#include <stdio.h>

int main()
{
	int n;
	int a,b,c,d;
	int count;
	int sum;
	
	while(scanf("%d",&n)==1){
		count=0;
		if(n<=36){
			for(a=0;a<=9;a++){
				for(b=0;b<=9;b++){
					for(c=0;c<=9;c++){
						for(d=0;d<=9;d++){
							sum=a+b+c+d;
							if(n==sum)count++;
						}
					}
				}
			}
			printf("%d\n",count);
		}
		else printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int n;
long long ans;
char str[10005];
map<pair<string,string>,int>f;

int main()
{
	scanf("%d%s",&n,str);
	int mxs = 1<<n;
	for(int s = 0; s < mxs; s++)
	{
		string a,b;
		for(int j = 0; j < n; j++)
		{
			if((s>>j)&1) a += str[j];
			else b += str[j];
		}
		f[make_pair(a,b)]++;
	}
	for(int s = 0; s < mxs; s++)
	{
		string a,b;
		for(int j = 0; j < n; j++)
		{
			if((s>>j)&1) a += str[(n<<1)-1-j];
			else b += str[(n<<1)-1-j];
		}
		ans+=f[make_pair(a,b)];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 91904
main =  do
  n <- readLn
  a1 <- (map read . words) <$> getLine
  a2 <- (map read . words) <$> getLine
  print $ maximum $ map (solve (a1, a2)) [1..n]


solve:: ([Int], [Int]) -> Int -> Int
solve x n = do
  let (x1, x2) = x
  let k = foldl (+) 0 (take n x1)
  let l = foldl (+) 0 (drop (n - 1) x2)
  k + l


Measured memory_bytes: 1020
S = input()
s_Count = 0
b_Count = 0
ans = 0

for i in range(len(S)):
  if S[i] == "<":
    s_Count += 1
    if i == len(S)-1:
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
  elif S[i] == ">":
    b_Count += 1
    if i == len(S)-1 or S[i+1] == "<":
      max_sb = max(s_Count,b_Count)
      min_sb = min(s_Count,b_Count) - 1
      ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2
      s_Count = 0
      b_Count = 0
print(int(ans))

Measured memory_bytes: 9840
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    ll i,j;
    boost;
    cin>>i>>j;
    cout<<i*j/__gcd(i,j);

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,j,k,l,m,n,a[200005],b[200005];
    cin>>j>>k>>l;
    if(j>l && l>k)
    {
        cout<<"Yes";
        return 0;
    }
    if(l>j && l<k)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, N, *AB = map(int, read().split())

    magic = [0] * N
    for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
        magic[i] = (a, b)

    dp = [[INF] * (H + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = 0

    for i in range(N):
        a, b = magic[i]
        for j in range(H + 1):
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][max(j - a, 0)] + b)

    print(dp[N][H])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 152636
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long n;
	cin >> n;
	n++;
	int x=0;
	
	while(n > 0){
		n /= 2;
		x++;
	}
	
	P(x-1);
	ret 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 200050
int n,a,b,c,d,mp[N],ans;
char w[N];
int check(int s,int t) {
	int i;
	if(mp[s]||mp[t])return 0;
	for(i=s;i<t;i++) if(mp[i]&&mp[i+1]) return 0;
	return 1;
}
int main() {
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,w+1);
	int i;	
	for(i=1;i<=n;i++) mp[i]=(w[i]=='#');
	if(c<d) ans=check(a,c)&&check(b,d);
	else {
		if(!check(b,d)||!check(a,c)) ans=0;
		else {
			for(i=b;i<=d;i++) {
				if(mp[i]) continue;
				if(mp[i-1]==0&&mp[i+1]==0) {
					ans=1; break;
				}
			}
		}
	}
	puts(ans?"Yes":"No");
	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

using gridcost = tuple<int, int, int>;

const int MAX_H = (int)(1e2 + 5);
const int MAX_W = (int)(1e2 + 5);

int h, w;
char s[MAX_H][MAX_W];

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

set<pair<int, int>> visited;

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  for (int i = 0; i < h; ++i) {
    scanf("%s", &(s[i]));
  }

  int white = 0;

  for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
    if (s[i][j] == '.') white += 1;
  }

  int length = -1;

  queue<gridcost> que;

  que.push(gridcost(0, 0, 0));
  visited.insert(make_pair(0, 0));

  while (!que.empty()) {
    gridcost tmp = que.front();
    que.pop();

    int x = get<0>(tmp);
    int y = get<1>(tmp);
    int cost = get<2>(tmp);

    // printf("%d %d\n", x, y);

    if (x == (h - 1) && y == (w - 1)) {
      length = cost;
      break;
    }

    for (int i = 0; i < 4; ++i) {
      int nx = x + dx[i];
      int ny = y + dy[i];

      if (s[nx][ny] == '#') continue;
      if (visited.find(make_pair(nx, ny)) != visited.end()) continue;

      if (0 <= nx && nx < h && 0 <= ny && ny < w) {
        que.push(gridcost(nx, ny, cost + 1));
        visited.insert(make_pair(nx, ny));
      }
    }
  }

  if (length == -1) {
    printf("%d\n", -1);
  }
  else {
    ans = white - (length + 1);
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
#define ll long long
using namespace std;

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

	if (h % a == 0) {
		cout << h / a;
	} else {
		cout << h / a + 1;
	}

	return 0;
}

Measured memory_bytes: 384
N = gets.to_i
cities = []
N.times do |c|
    cities.push(gets.chomp.split(" ").map(&:to_i))
end
path_len = []
perm = cities.permutation(N).to_a

for item in perm
    lens = []
    item.each_cons(2) do |a, b|
        lens.push(((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2.0))
    end
    path_len.push(lens.inject(:+))
end
print("#{path_len.inject(:+) / path_len.length}")

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll a,b,c,d,l;
ll gcd(ll x, ll y){
    if(x<y)swap(x,y);

    while(x%y>0){
        ll z = x%y;
        x = y;
        y = z;
    }
    return y;
}
ll lcm (ll x, ll y){
    ll g = gcd(x,y);
    ll res = (x*y)/g;
    return res;
}
ll calc(ll x){
    ll res;
    res = (x/c) + (x/d) - (x/l);
    return res;
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c>>d;
    l = lcm(c,d);
    ll ans = calc(b) - calc(a-1);
    ans = (b-a+1)-ans;
    cout<<ans<<newl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;

int main(){
    int n,m;cin >> n >> m;
    priority_queue<long long> q;
    for(int i=0;i<n;i++){
        long long tmp;
        cin >> tmp;
        q.push(tmp);
    }
    for(int i=0;i<m;i++){
        long long tmp = q.top();
        q.pop();
        tmp /=2;
        q.push(tmp);
    }
    long long ans = 0;
    for(int i=0;i<n;i++){
        long long tmp = (long long)q.top();
        ans += tmp;
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
a,b,c = [int(x) for x in input().split()]
d,e,f = [int(x) for x in input().split()]
g,h,i = [int(x) for x in input().split()]

n = int(input())
S = {int(input()) for x in range(n)}

def q(x,y,z):
    return x in S and y in S and z in S

print('Yes' if q(a,b,c) or q(d,e,f) or q(g,h,i) or q(a,d,g) or q(b,e,h) or q(c,f,i) or q(a,e,i) or q(g,e,c) else 'No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200009
#define MAXM 320
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	if (k == 0) ans = 1;

	for (ll b = 2; b <= n; b++) {
		if (k >= b) continue;
		ll bound = (n)/b;
		ans += bound*(b-k);
		ll tmp = n - bound*b;

		ans += max(0LL, tmp-k+1);

	//	printf("%lld %lld\n", b, ans);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define MSI map<string,int>
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int N,K,X,Y;
	int ans;
	cin >> N>> K>> X>> Y;
	if (N <= K)cout << N*X << endl;
	else cout << (K*X) + ((N - K)*Y) << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
S = input()
S = '*' + S + '*'
W = [x=='W' for x in S]
E = [x=='E' for x in S]
W = np.cumsum(W)
E = np.cumsum(E[::-1])[::-1]

ans = min([W[i-1] + E[i+1] for i in range(1, N+1)])
print(ans)


Measured memory_bytes: 31304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  int a,b;
  while(cin>>a>>b){
    int cnt=1,num=0;
    ans=a+b;
    while(1){
      num++;
      ans=ans/cnt;
      if(ans<10)
	break;
      ans=a+b;
      cnt*=10;
    }
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 2992
n = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
ans = 0

for i in range(n):
    candies = 0
    candies += sum(A1[:i+1]) + sum(A2[i:])
    ans = max(ans,candies)
    
print(ans)

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, sum = 0;
	cin >> n;

	vi a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}

	if(sum % 10 != 0)
	{
		cout << sum << endl;
		return 0;
	}

	int mx = 0;
	for(int i = 0; i < n; i++)
	{
		int temp = ((sum-a[i]) % 10 != 0) ?  sum-a[i] : 0;
		mx = max (mx, temp);
	}

	cout << mx << endl;

	return 0;	
}

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

int ans = 0;
int w, h;
int table[1400][1400];

int main()
{
	cin >> h >> w;

	for (int y = 0; y < h; y++)
	{
		for (int x = 0; x < w; x++)
		{
			int tmp;
			cin >> tmp;
			table[x][y] = !tmp;
			ans = max(ans, table[x][y]);
		}
	}

	for (int y = 1; y < h; y++)
	{
		for (int x = 1; x < w; x++)
		{
			if (table[x][y] == 0) continue;
			table[x][y] = min({ table[x-1][y], table[x][y-1], table[x-1][y-1]}) + 1;
			ans = max(ans, table[x][y]);
		}
	}

	cout << ans * ans << endl;

	return 0;
}

Measured memory_bytes: 10732
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int h,w ;
    cin>>h>>w;
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int x[h][w];
    int ci = 0;
    for(int i = 0 ; i< h ; i++){
        if(i % 2 == 0){
            for(int j = 0 ; j < w ; j++){
                if(a[ci] == 0)
                    ci++;
                x[i][j] = ci+1;
                a[ci]--;
            }
        }else {
            for(int j = w - 1 ; j >= 0 ; j--){
                if(a[ci] == 0)
                    ci++;
                x[i][j] = ci+1;
                a[ci]--;
            }
        }
    }
    for(int i = 0 ; i< h ; i++){
        for(int j = 0 ; j < w ; j++){
            cout<<x[i][j]<<" ";
        }
        cout<<endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 512
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	for (int a = 1; a <= 9; a++){
		for (int b = 1; b <= 9; b++){
			if(a*b == n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
using ll = long long;


int main() {
    int n; cin >> n;
    vector<int> a(n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == (cnt+1)) {
            cnt++;
        }
    }
    if (cnt == 0) cout << -1 << endl;
    else cout << n-cnt << endl;

    return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;

void solve()
{
    cin>>n;
    n>=30?prs("Yes"):prs("No");
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

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

using namespace std;


int main(){
	long long n, a, b;
	cin>>n>>a>>b;
	if (a>b) {
		cout<<0<<endl;
		return 0;
	}
	if ((n == 1)&&(a != b)) {
		cout<<0<<endl;
		return 0;
	}
	long long ans = (n-2)*b - (n-2)*a +1;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
 int a, b, c;
 int divcount = 0;
 scanf("%d %d %d", &a, &b, &c);
 for (int i = a; i <= b; i++)
 {
  if (c % i == 0)
  {
   divcount++;
  }
 }
 cout << divcount << endl;
}
 


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    ll a[n], b[n];
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> b[i];
    ll sa = 0, sb = 0;
    rep (i, n) {
        if (a[i] > b[i]) sa += (a[i] - b[i]);
        else {
            sb += (b[i] - a[i]) / 2;
        }
    }
    if (sb >= sa) cout << "Yes\n";
    else
        cout << "No\n";
}

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

int main(){
    char c ;
    cin >> c ;
    bool flag = 0 ;
    string str = "aiueo";
    rep(i,5){
        if(c == str.at(i)){
            flag = 1 ;
            break;
        }
    }
    if(flag) cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

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

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

    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int passou = 0;
    int ov = 0;
    for(int i = 0; i < n; ++i) {
        if (s[i] == 'c') {
            cout << "No\n";
        } else if (s[i] == 'a') {
            if (a + b > passou) {
                cout << "Yes\n";
                passou++;
            } else {
                cout << "No\n";
            }
        } else {
            ov++;
            if (a + b > passou and ov <= b) {
                passou++;
                cout << "Yes\n";
            } else cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=0;
ll x[100005],y[100005],z[100005];
float st;
stack <ll> ana;


ll digi(ll x){
	ll nono=0;
	while(x>0){
		nono += x%10;
		x/=10;
	}
	return nono;
}
int main(){
	cin>>n;
	x[1]=1;
	st=INF;
	for(i=1000000000000000;i>=1;i--){
		//pe("調べ中");p(i);
		if((float)(i*1.000/digi(i))<=st){
			ana.push(i);
			st = i*1.000/digi(i);
		}
		if(i>=10000000000000 && i%100000000000 == 99999999999)i-=99999999999;
		if(i>=1000000000000 && i%10000000000 == 9999999999)i-=9999999999;
		if(i>=100000000 && i%1000000 == 999999)i-=999999;
		if(i>=1000000 && i%10000 == 9999)i-=9999;
		if(i>=10000 && i%100==99)i-=98;
	}
	while(n>0){
		p(ana.top());
		ana.pop();
		n--;
	}
	return 0;
}

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

int main()
{
	long long int x,y,a,b,c,t;
	cin>>x>>y>>a>>b>>c;
	t=max(a,max(b,c));
	long long int p[t+1],q[t+1],r[t+1],i,j,k,cnt=x+y,ans=0;
	for(i=0;i<a;i++)
        cin>>p[i];
    for(i=0;i<b;i++)
        cin>>q[i];
    for(i=0;i<c;i++)
        cin>>r[i];
        sort(p,p+a, greater <int>() );
        sort(q,q+b, greater <int>() );
        sort(r,r+c, greater <int>() );
        for(i=a;i<=t;i++)
            p[i]=0;
        for(i=b;i<=t;i++)
            q[i]=0;
            for(i=c;i<=t;i++)
            r[i]=0;
        i=0;j=0;k=0;
        while(cnt>0)
        {
            if(p[i]>=q[j] && p[i]>=r[k] && x>0 )
            {
              ans+=p[i]; x--; cnt--; i++;
              if(x==0)i=a;
            }
            else if(p[i]<=q[j] && q[j]>=r[k] && y>0 )
            {
              ans+=q[j]; y--; cnt--; j++;
              if(y==0)j=b;
            }
            else if((y||x)  )
            {
              ans+=r[k]; cnt--; k++;
            }
          //  cout<<ans<<endl;
        }
        cout<<ans;
}
/*2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4*/


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
    ll n,m,q;
    cin>>n>>m>>q;
    vector<pair<int,int>> edge;
    UnionFind uf(n);
    ll nn = n;
    while(q--){
        int x,y,t;
        cin>>x>>y>>t;
        if(t){
            edge.emplace_back(x,y);
        }
        else {
            if(uf.unite(x,y)){
                --m;
                --nn;
            }
        }
    }
    vector<int> used(n);
    ll cnt = 0;
    for(auto p : edge){
        int x = uf.find(p.first), y = uf.find(p.second);
        if(x==y){
            cout<<"No"<<endl;
            return 0;
        }
        if(!used[x])++cnt;
        if(!used[y])++cnt;
        used[x]=used[y]=1;
    }
    if(cnt==0){
        ll mi = nn-1, ma = nn*(nn-1)/2;
        if(mi<=m&&m<=ma){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    else {
        ll mi = nn, ma = nn*(nn-1)/2;
        if(mi<=m&&m<=ma){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    return 0;
}

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

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323
#define debug(x) cout<<"Case "<<x<<": "
#define For(i,n) for(long long i=0;i<n;i++)
#define Frabs(i,a,b) for(long long i = a; i < b; i++)
#define Frabr(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;

//Handle:cyber_rajat


int main(int argc, char const *argv[])
{
	sync;
	ll n;
	cin>>n;
	ll arr[n+5]={0},dp[n+5]={0};
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	dp[1]=0,dp[0]=0;
	if(n>=2)
		dp[2]=abs(arr[2]-arr[1]);
	for(ll i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

int n,k,x,y,sum;
int main()
{
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        for(int i=0; i<k; i++)
        {
            sum+=x;
        }
        for(int i=0; i<n-k; i++)
        {
            sum+=y;
        }
        cout<<sum<<endl;
    }
    else
    {
        for(int i=0; i<n; i++)
        {
            sum+=x;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N;
int x=0;
int max=0;
char S[101];

int main(){
	scanf("%d",&N);
	scanf("%s",S);
	for(int i=0;i<N;i++){
		if(S[i]=='I'){
			x++;
			if(x>max){
				max=x;
			}
		}else{
			x--;
		}
	}
	printf("%d\n",max);
}

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

int main(void) {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    cout << "a > b" << endl;
  } else if (a < b) {
    cout << "a < b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3056
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll A, B, H, M;
    cin >> A >> B >> H >> M;
    double theta_h = (H / 12. + M / 12. / 60.) * 2 * M_PI;
    double theta_m = M / 60. * 2 * M_PI;
    double x_h = sin(theta_h) * A;
    double y_h = cos(theta_h) * A;
    double x_m = sin(theta_m) * B;
    double y_m = cos(theta_m) * B;
    double distance = sqrt((x_h-x_m)*(x_h-x_m) + (y_h-y_m)*(y_h-y_m));
    printf("%.12f\n", distance);
    return 0;
}



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

int main(){
    int N,M,P;
    while(1){
        cin >> N >> M >> P;
        if(N==0) break;

        int total=0,win,tmp;
        for(int i=1; i<=N; i++){
            cin >> tmp;
            total+=tmp;
            if(i==M){
                win = tmp;
            }
        }
        
        if(win==0){
            cout << 0 << endl;
            continue;
        }
        cout << total*(100-P)/win << endl;
    }    
    return 0;
}

Measured memory_bytes: 3016
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    int n,a,b; scanf("%d %d %d", &n, &a, &b);
    int res = 0;
    REP(i,1,n){
        int x; scanf("%d", &x);
        res += (x < a || b <= x);
    }
    printf("%d\n", res);
    return 0;
}


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

int main() {
  int x[4][13]={{}};
  int b,n;
  char a;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a >> b;
    b=b-1;
    if(a=='S'){
      x[0][b]=1;
    }
    else if(a=='H'){
      x[1][b]=1;
    }
    else if(a=='C'){
      x[2][b]=1;
    }
    else if(a=='D'){
      x[3][b]=1;
    }
  }
   for(int j=0; j<4; j++){
     for(int k=0; k<13; k++){
       if(x[j][k]!=1){
         if(j==0){
           cout << "S " << k+1 << endl;
         }
         else if(j==1){
           cout << "H " << k+1 << endl;
         }
         else if(j==2){
           cout << "C " << k+1 << endl;
         }
         else if(j==3){
           cout << "D " << k+1 << endl;
         }
       }
     }
   }
}


Measured memory_bytes: 2980
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    int n;
    cin>>n;
    ll ans=1;
    rep(i,n){
        ans*=i+1;
        ans%=MOD;
    }
    fin(ans);
}


Measured memory_bytes: 256