akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main(){
    ll n,a,b,ans=1,MOD=mod-1;
    cin>>n;
    map<pair<ll,ll>,pair<ll,ll>>m;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        if(!a&&!b) MOD++;
        else{
            ll g=__gcd(a,b);
            a/=g,b/=g;
            if(b<0) a=-a,b=-b;
            if(a<=0) m[{b,-a}].second++;
            else m[{a,b}].first++;
        }
    }
    for(auto u:m) ans=ans*(power(2,u.second.first)+power(2,u.second.second)-1+mod)%mod;
    cout<<(ans+MOD)%mod;
}


Measured memory_bytes: 19184
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

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

const int N = 3e3 + 10;
int dp[N];

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int64 inv2 = (MOD + 1) / 2;
  dp[0] = 1;
  for (int i = 0; i < n; ++i) dp[0] = dp[0] * 2 % MOD;
  for (int i = 0; i < n; ++i) {
    for (int j = m; j >= a[i]; --j) {
      add(dp[j], dp[j - a[i]] * inv2 % MOD);
    }
  }
  printf("%d\n", dp[m]);
  return 0;
}


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

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

  int cnt = -1, ans = 0;
  int hh = 1001001001;
  rep(i, n){
    int h;
    cin >> h;
    if(hh >= h){
      cnt++;
    }
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }
    hh = h;
  }

  ans = max(ans, cnt);
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int W = in.nextInt();
	int H = in.nextInt();
	int x = in.nextInt();
	int y = in.nextInt();
	int r = in.nextInt();

	if(0<=x-r && 0<=y-r && y+r<=H && x+r<= H){
	    System.out.println("Yes");

	}else System.out.println("No");

    }
}



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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}


int func(long long n, std::vector<long long> d){
    // cout << fixed << setprecision(8);

	ll ans=0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			ans+=d[i]*d[j];
		}
	}

	cout << ans	 << endl;

	return 0;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }

    func(N, std::move(d));


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long n = 0;
  long long a[5] = {};
  long long i = 0;
  long long min = -1;
  long long time = 0;
  scanf("%lld",&n);
  for(i=0;i<5;i++){
    scanf("%lld",&a[i]);
    if(a[i] < min || min == -1){
      min = a[i];
    }
  }
  time = 4 + (n+min-1)/min;
  printf("%lld",time);
  return 0;
}

Measured memory_bytes: 128
// ABC 081

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n")
  var n = input[0]; //個数
  var tmp = input[1].split(" ") //数値
  var count = 0;

  var flag = check(tmp)
  while(flag==0) {
    tmp = caculation(tmp)
    count++;
    flag = check(tmp)
  }
  console.log(count)
}

function check(tmp) {
  var flag = 0;
  for(var i=0;i<tmp.length;i++) {
    if(tmp[i]%2 == 1) flag = 1;
  }
  return flag;
}

function caculation(tmp) {
  for(var i=0;i<tmp.length;i++) {
    tmp[i] = tmp[i] / 2;
  }
  return tmp;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(void)
{
	int n;

	while(cin >> n,n){
		int max_no=-1,max_val=-1;
		int no,a,b;
		while(--n, n >= 0){
			cin >> no >> a >> b;

			if(max_val < a+b){
				max_no = no;
				max_val = a+b;
			}
		}

		cout << max_no << ' ' << max_val << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N = sc.nextInt();
        List <R> r = new ArrayList<>();
        for(int i=0;i<N;i++){
            r.add(new R(sc.next(),sc.nextInt(),i+1));
        }
        Collections.sort(r);
        for(R t:r){
            System.out.println(t.i);
        }
    }
}
class R implements Comparable<R>{
    String city;
    int point;
    int i;
    public R(String city, int point, int i){
        this.city = city;
        this.point = point;
        this.i = i;
    }
    public int compareTo(R o){
        int t = city.compareTo(o.city);
        if(t!=0){
            return t;
        }
        return Integer.compare(o.point, point);
    }
}

Measured memory_bytes: 35892
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    int c = 0;
    FORE(e, S) {
        if (e == "A") c++;
        else c--;
        if (c < 0) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << (c == 0 ? "YES" : "NO") << endl;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    while (cin >> n, n) {
        solve(n);
        return 0;
    }
}

Measured memory_bytes: 3164
class UnionFind():
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self._table[x] += self._table[y]
        self._table[y] = x
    
    def same(self, x, y):
        return self._root(x) == self._root(y)

    def count_members(self, x):
        return -self._table[self._root(x)]
    
    def count_groups(self):
        return len({self._root(i) for i in range(n)})
    
    def __str__(self):
        return str([self._root(i) for i in range(n)])
    
    def __repr__(self):           
        return repr([self._root(i) for i in range(n)])

n, m, k, *ABCD = map(int, open(0).read().split())
AB = zip(ABCD[:2*m][::2], ABCD[:2*m][1::2])
CD = zip(ABCD[2*m:][::2], ABCD[2*m:][1::2])

uf = UnionFind(n)

friends = [set() for _ in range(n)]
for a, b in AB:
    a, b = a-1, b-1
    uf.unite(a, b)
    friends[a].add(b)
    friends[b].add(a)
    
blocks = [set() for _ in range(n)]
for c, d in CD:
    c, d = c-1, d-1
    if uf.same(c, d):
        blocks[c].add(d)
        blocks[d].add(c)

candidates = []
for i in range(n):
    candidates.append(uf.count_members(i)-len(friends[i])-len(blocks[i])-1)
print(*candidates)

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

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

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

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

    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string str;
  string sts;
  cin >> str >> sts;
  int ans=0;
  for(int i=0; i<3; i++){
    if(str[i]==sts[i]) ans++;
  }
  cout << ans<<endl;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int W[2], q;
    cin >> W[0] >> W[1];
    vector<pair<int, int>> p(0);
    rep(i, 2) {
        rep(j, W[i]) {
            cin >> q;
            p.push_back(make_pair(q, i));
            //cout << q << " " << i << endl;
        }
    }
    sort(p.begin(), p.end());
    int r[2];
    r[0] = 0;
    r[1] = 0;
    ll ans = 0;
    rep(i, W[0] + W[1]) {
        int x = p[i].first, y = p[i].second;
        ans += (W[1 - y] - r[1 - y] + 1L) * x;
        //cout << x << " " << y << " " << ans << endl;
        r[y]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P,int>PP;
vector<int>G[100005];
int dis1[100006], dis2[100006],dis3[100006];
void dfs(int now, int par, int *dis) {
	for (int e : G[now]) {
		if (e == par)continue;
		dis[e] = dis[now] + 1;
		dfs(e, now, dis);
	}
}

void fkg(int now, vector<int>&V,int *dis) {
	if (dis[now] == 0)return;
	for (int e : G[now]) {
		if (dis[e] == dis[now] - 1) {
			V.push_back(e);
			fkg(e, V, dis);
		}
	}
}

void dfs2(int now,int jama, int par, int *dis) {
	for (int e : G[now]) {
		if (e == par)continue;
		if (e == jama)continue;
		dis[e] = dis[now] + 1;
		dfs2(e, jama, now, dis);
	}
}

signed main() {
	int n, u, v; cin >> n >> u >> v;
	u--; v--;
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(u, -1, dis1);
	dfs(v, -1, dis2);
	int O = dis1[v] & 1;//奇数ならO=1
	vector<int>V;
	V.push_back(v);
	fkg(v, V, dis1);
	int ans = 0;
	ans += (dis1[v] - 1) / 2;

	v = V[ans];
	u = V[V.size() - ans-1];

	if (G[u].size() == 1) {
		if (dis1[v] & 1)cout << ans << endl;
		else cout << ans + 1 << endl;
	}
	else {
		dfs2(u, v, -1, dis3);
		int res = 0;
		rep(i, n)res = max(res, dis3[i]);
		res+=1-O;
		cout << ans + res << endl;
	}
}

Measured memory_bytes: 14208
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		boolean[][] cards = new boolean[4][13];
		for (int i = 0; i < n; i++) {
			String s = stdIn.next();
			switch (s.charAt(0)) {
			case 'S':
				cards[0][stdIn.nextInt() - 1] = true;
				break;
			case 'H':
				cards[1][stdIn.nextInt() - 1] = true;
				break;
			case 'C':
				cards[2][stdIn.nextInt() - 1] = true;
				break;
			case 'D':
				cards[3][stdIn.nextInt() - 1] = true;
				break;
			}
		}
		char[] c = { 'S', 'H', 'C', 'D' };
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (!cards[i][j]) {
					System.out.println(c[i] + " " + (j + 1));
				}
			}
		}
    }
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15



signed main()
{
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i,0,n) cin >> a[i];
        sort(all(a));
        int ans = 0;
        int cnt = 1;
        ans = a.back();
        int i = n-2;
        int f = 0;
        while(cnt < n - 1){
            ans += a[i];
            f++;
            cnt++;
            if(f == 2){
                f = 0;
                i--;
            }
            // trace(ans);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
#define nmax 100005
using namespace std;
typedef unsigned long long ull;

int main(){
  ull n,d,k,s=0;
  cin>>n>>d;
  k=2*d+1;
  s=n/k;
  if(n%k!=0){
      s++;
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 #include<iostream>
 using namespace std;
 
 int main()
 {
 	int a,b;
 	while(cin>>a>>b)
 	{
 		if(a%2==0||b%2==0) cout<<"Even"<<endl;
 		else cout<<"Odd"<<endl;
	 }
 	return 0;
 }

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2824.cc: Coastline
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int t, d, l;
    scanf("%d%d%d", &t, &d, &l);
    if (t == 0) break;

    int sum = 0, c = 0;
    for (int i = 0; i < t; i++) {
      if (c > 0) sum++, c--;
      int xi;
      scanf("%d", &xi);
      if (xi >= l) c = d;
    }

    printf("%d\n", sum);
  }
  return 0;
}



Measured memory_bytes: 3188
N, D = map(int, input().split())
Xss = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    Xi = Xss[i]
    for j in range(i+1, N):
        Xj = Xss[j]
        dist = 0
        for k in range(D):
            dist += (Xi[k]-Xj[k])**2
        if dist**0.5 == int(dist**0.5):
            ans += 1

print(ans)


Measured memory_bytes: 3188
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		s := sc.Text()
		arr := strings.Split(s, " ")
		a, _ := strconv.Atoi(arr[0])
		b, _ := strconv.Atoi(arr[1])
		fmt.Printf("%d %d %.5f\n", a/b, a%b, float64(a)/float64(b))
	}
}



Measured memory_bytes: 1144
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

char func(int m, int f, int r)
{
    if (m == -1 || f == -1 || m + f < 30)
        return 'F';
    else if (m + f >= 80)
        return 'A';
    else if (m + f >= 65)
        return 'B';
    else if (m + f >= 50)
        return 'C';
    else 
        return (r >= 50 ? 'C' : 'D');
}

int main()
{
    int m, f, r;
    while (cin >> m >> f >> r)
    {
        if (m == -1 && f == -1 && r == -1)
            return 0;
        cout << func(m, f, r) << endl;
    }
}



Measured memory_bytes: 3088
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0 
# left
for i in range(min(n, k) + 1):
    # right
    for j in range(min(n, k) - i + 1):
        # print(i,j)
        par_seq = sorted(v[:i] + v[-j:] if j != 0 else v[:i])
        par_seq_sum = sum(par_seq)
        if par_seq_sum > ans:
            ans = par_seq_sum
        ope = k - (i + j)
        # print(par_seq, par_seq_sum)
        for _ in range(min(ope, len(par_seq))):
            rm = par_seq.pop(0)
            if rm < 0 and sum(par_seq) > ans:
                ans = sum(par_seq)

print(ans)

Measured memory_bytes: 3064
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
ans=0
for i in range(N):
  if D<=X:
    ans+=1
    D+=L[i]
  else:
    print(ans)
    exit()
if D<=X:
  ans+=1
  print(ans)
else:
  print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

struct node{
    int value;
    struct node *left,*right;
};

typedef struct node node;

node *build(){
    if(getchar()==')')return NULL; //skip (
    node *res = (node *)malloc(sizeof(node));
    if((res->left = build()))getchar(); //skip )
    scanf("[%d](",&res->value);
    if((res->right = build()))getchar(); //skip )
    return res;
}

node *unite(node *a, node *b){
    if(a==NULL || b==NULL)return NULL;
    node *res = (node *)malloc(sizeof(node));
    res->value = a->value+b->value;
    res->left = unite(a->left, b->left);
    res->right = unite(a->right, b->right);
    return res;
}

void output(node *n){
    if(n==NULL)return;
    printf("(");
    output(n->left);
    printf(")[%d](", n->value);
    output(n->right);
    printf(")");
}

int main(){
    node *a = build();
    getchar(); //skip \n
    node *b = build();
    getchar(); //skip \n
    output(unite(a,b));
    printf("\n");
    return 0;
}



Measured memory_bytes: 2104
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    x = y = 0
    for _ in range(N):
        A, B = map(int, input().split())
        if A > x:
            x = A
            y = B

    ans = x + y
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int count = 1;
    string str, check;
    cin >> str;
    check = str[0];
    for(int i = 1; i < str.length(); i++){
        if(str[i] != check[0]){
            count++;
            check[0] = str[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d[ohara],tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n>>m;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    rep(i,m){
        cin>>c[i]>>d[i];
    }
    rep(i,n){
        cnt=LINF;
        rep(j,m){
            if(cnt>abs(a[i]-c[j])+abs(b[i]-d[j])){
                cnt=abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans=j+1;
            }
        }
        Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 6400
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int N, E;
struct Edge
{
  int s, t, w;
  Edge() {}
  Edge(int s, int t, int w): s(s), t(t), w(w) {}
};
vector<Edge> edges;

class DisjointSet
{
  public:
  vector<int> ranks, p;
  DisjointSet(int N)
  {
    ranks.resize(N, 0);
    p.resize(N, 0);
    for(int i=0; i<N; i++) makeSet(i);
  }
  void makeSet(int i)
  {
    p[i] = i; ranks[i] = 0;
  }

  int findp(int x)
  {
    if(x != p[x])
    {
      p[x] = findp(p[x]);
    }
    return p[x];
  }

  bool same(int x, int y)
  {
    return findp(x) == findp(y);
  }

  void link(int x, int y)
  {
    if(ranks[x] < ranks[y])
    {
      p[x] = y;
    }
    else
    {
      p[y] = x;
      if(ranks[x] == ranks[y])  ranks[x]++;
    }
  }

  void unit(int x, int y)
  {
    link(findp(x), findp(y));
  }
};
bool cmp(Edge e1, Edge e2)
{
  return e1.w < e2.w;
}

void kruskal()
{
  int ans = 0; int v=0;
  DisjointSet Dst = DisjointSet(N);
  for(int i=0; i<edges.size(); i++)
  {
    if(v == N-1) break;
    int s, t, w;
    Edge e = edges[i];
    s = e.s; t = e.t; w = e.w;
    if(!Dst.same(s, t))
    {
      Dst.unit(s, t); ans += w; v++;
    }
  }
  printf("%d\n", ans);
}

int main()
{
  scanf("%d%d", &N, &E);
  int s, t, w;
  for(int i=0; i<E; i++)
  {
    scanf("%d%d%d", &s, &t, &w);
    edges.push_back(Edge(s, t, w));
  }
  sort(edges.begin(), edges.end(), cmp);
  kruskal();
  return 0;
}



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

const int W = 1e5+10;

//head

int n, w;
ll dp[W];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w;
  rep(i, n) {
    int ww, vv;
    cin >> ww >> vv;
    for(int j = w; j >= ww; j--) {
      chmax(dp[j], dp[j-ww] + vv);
    }
  }
  cout << dp[w] << endl;
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
    int i,n,d1,d2,cnt,flg;
    scanf("%d",&n);
    cnt=0; flg=0;
    for(i=0;i<n;i++){
        scanf("%d%d",&d1,&d2);
        if(d1==d2) cnt++;
        else cnt=0;
        if(cnt==3) flg=1;
    }
    if(flg==1) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	int a, b, c, k;

	scanf("%d %d %d %d", &a, &b, &c, &k);

	if (k <= a)
		printf("%d", k);
	else if (k <= b)
		printf("%d", a);
	else
		printf("%d", a - (k - a - b));
	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;






ll i,j,k;


int main(){
    ll X,Y;
    cin>>X>>Y;
    if(Y%2==0&&(Y-2*X)/2>=0&&(4*X-Y)/2>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3632
n = int(input())
cnt, ans = 0, 0
if n == 105:
    print(1)
elif n <= 104:
    print(0)
else:
    for x in range(107,n+1,2):
        cnt = 0
        for y in range(1,x+1):
            if x % y == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans+1)

Measured memory_bytes: 63712
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    while(true){
        int n,x,cnt=0;
        cin>>n>>x;
        if(n==0&&x==0){
            return 0;
        }
        for(int i=1;i<=n;++i){
            for(int j=i+1;j<=n;++j){
                for(int k=j+1;k<=n;++k){
                    if(i+j+k==x){
                        ++cnt;
                    }
                }
            }
        }
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;
  std::cout << (1+N-1)*(N-1)/2 << std::endl;
  return 0;
}


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

int main() {
	int m1, d1, m2, d2;
	cin >> m1 >>d1;
	cin >> m2 >>d2;
	if (m1 != m2)cout << 1 << endl;
	else cout << 0 << endl;
}

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

bool F;
vector<int> e[100000];

bool dfs(int i,int p)
{
  int t=0;
  for(int x=0;x<e[i].size();x++){
    int j=e[i][x];
    if(j==p)continue;
    if(dfs(j,i)){
      t++;
    }
  }
  //printf("%d %d %d\n",i,t,F);
  if(t==0){
    return 1;
  }
  else if(t==1){
    return 0;
  }
  F=1;
  return 0;
}

int main()
{
  int n;
  scanf("%d",&n);
  for(int i=0;i<n-1;i++){
    int u,v;
    scanf("%d%d",&u,&v);
    u--,v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  int r;
  for(int i=0;i<n;i++){
    if(e[i].size()==1){
      r=i;
      break;
    }
  }
  F=0;
  bool t=dfs(0,-1);
  puts(F||t?"First":"Second");
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9 + 7)
#define PI 3.14159265358979323846264338327950L
// ------------------ Debugging ------------------
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
// -----------------------------------------------

signed main(){

    fastIO

    int t = 1;
    // cin >> t;
    while (t--){
   		int n;
   		cin >> n;
   		vector<int> a(n), pre(n, 0);
   		for (int i = 0; i < n; i++) {
   			cin >> a[i];
   			pre[i] = a[i];
   		}
   		for (int i = n-2; i >= 0; i--) {
   			pre[i] += pre[i+1];
   			pre[i] %= mod;
   		}

   		int ans = 0;
   		for (int i = 0; i < n-1; i++) {
   			int val = a[i] * pre[i+1];
   			val %= mod;

   			ans += val;
   			ans %= mod;
   		}
   		cout << ans << endl;
    }	
    
    return 0;
}

Measured memory_bytes: 6336
#include <stdio.h>

void printDate(int num)
{
        switch(num)
        {
                case 0:
                        printf("Thursday\n");
                        break;
                case 1:
                        printf("Friday\n");
                        break;
                case 2:
                        printf("Saturday\n");
                        break;
                case 3:
                        printf("Sunday\n");
                        break;
                case 4:
                        printf("Monday\n");
                        break;
                case 5:
                        printf("Tuesday\n");
                        break;
                case 6:
                        printf("Wednesday\n");
                        break;
        }
}

int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
        int month, day;
        while(scanf("%d%d", &month, &day), month != 0)
        {
                int i,d;
                for(i = 1,d = 0; i < month; i++) {
                        d += days[i-1];
                }
                d += day - 1;
                printDate(d%7);
        }
        return 0;
}

Measured memory_bytes: 584
import sys
# -*- Coding: utf-8 -*-
n = int(input())
sentence = list(input())
i=0
s=0
s=n//2
#print(s)
if n%2 == 1:
    print('No')
    sys.exit()
#ここまで大丈夫
else:
    #print(k)
    for i in range(s):
       if sentence[i] == sentence[s+i]:
           pass
       else:
           print('No')
           sys.exit()

print('Yes')

#競技プログラミングは人の誤りを仮定しない幸せな世界


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(void){
	int h,w,i,i2;
	scanf("%d %d",&h,&w);
	while(h!=0&&w!=0){
		for(i=0;i<h;i++){
			for(i2=0;i2<w;i2++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&h,&w);
	}
	return 0;
}

Measured memory_bytes: 2648
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;

typedef struct _Stack{
    long long stack[200];
    unsigned int top;
    unsigned int bottom;
    unsigned num;
    unsigned max_num;
}Stack;

Stack *stack=NULL;

void init(){
    stack = (Stack*)malloc(sizeof(Stack));
    stack->bottom = 0;
    stack->top    = 0;
    stack->num  = 0;
    stack->max_num = 200;
    return;
}

bool empty(){
    if(stack->num==0){
        return true;
    }else{
        return false;
    }
}

bool full(){
    if(stack->top==stack->max_num){
        return true;
    }else{
        return false;
    }
}

void push(long long data){
    if(full()){
        cout << "追加できませんでした。\n";
        return;
    }
    stack->num++;
    stack->stack[stack->top] = data;
    stack->top++;
}

long long pop(){
    if(empty()){
        cout << "空です。\n";
        return -1;
    }
    stack->num--;
    stack->top--;
    return stack->stack[stack->top];
}

int main() {
    init();
    char s[100];
    long long a,b;
    while(scanf("%s", s)!=EOF){

        if(s[0]=='+'){
            b = pop();
            a = pop();
            push(a+b);
            continue;
        }
        if(s[0]=='*'){
            b = pop();
            a = pop();
            push(a*b);
            continue;
        }
        if(s[0]=='-'){

            b = pop();
            a = pop();
            push(a-b);
            continue;
        }
        a = atoi(s);
        push(a);
    }
    cout << pop() << endl;
}





Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc147/abc147_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<vector<P>> a(N, vector<P>(0));
  rep(i, N) {
    int A;
    cin >> A;
    rep(j, A) {
      int x, y;
      cin >> x >> y;
      x--;
      a[i].push_back(make_pair(x, y));
    }
  }

  int ans = 0;
  for (int i = pow(2, N) - 1; i >= 0; i--) {
    bool ok = true;
    vector<int> c(N);
    rep(j, N) { c[j] = (i & (1 << j)) ? 1 : 0; }
    rep(j, N) {
      if (c[j]) {
        rep(l, a[j].size()) {
          int x = a[j][l].first;
          int y = a[j][l].second;
          if (c[x] != y) {
            // 矛盾がある発言が見つかった
            ok = false;
            break;
          }
        }
      }
    }
    if (ok) {
      int tmp = 0;
      rep(j, N) { tmp += (i & (1 << j)) ? 1 : 0; }
      ans = max(ans, tmp);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define ALL(x) (x).begin(), (x).end()

int bfs(int n, vector<vector<int>> M, int pcol, int N);

vector<int> colors, check;

int main()
{
    char x;
    cin >> x;
    x++;
    cout << x << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    private static List<List<Integer>> permutations(int N) {
        List<List<Integer>> lst = new ArrayList<>();
        boolean[] used = new boolean[N];
        int[] acm = new int[N];
        for (int i = 0; i < N; i++) {
            acm[0] = i;
            used[i] = true;
            dfs(lst, N, 1, used, acm);
            used[i] = false;
        }
        return lst;
    }

    private static void dfs(List<List<Integer>> lst, int N, int idx, boolean[] used, int[] acm) {
        if (idx >= N) {
            lst.add(Arrays.stream(acm).boxed().collect(Collectors.toList()));
            return;
        }

        for (int i = 0; i < N; i++) {
            if (used[i]) continue;

            acm[idx] = i;
            used[i] = true;
            dfs(lst, N, idx+1, used, acm);
            used[i] = false;
        }
    }

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

        int N = sc.nextInt();
        int[] px = new int[N];
        int[] py = new int[N];
        IntStream.range(0, N).forEach(i -> {
            px[i] = sc.nextInt();
            py[i] = sc.nextInt();
        });

        List<List<Integer>> routes = permutations(N);
        List<Double> distances = routes.stream().map(route ->
            IntStream.range(1, N).asDoubleStream().reduce(0, (r, i) -> {
                int x1 = px[route.get((int)i)];
                int y1 = py[route.get((int)i)];
                int x2 = px[route.get((int)i-1)];
                int y2 = py[route.get((int)i-1)];
                double distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
                return r + distance;
            })
        ).collect(Collectors.toList());

        Double sum = distances.stream().reduce(0.0, Double::sum);

        System.out.println(sum / distances.size());
    }

}


Measured memory_bytes: 49024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n;
  cin >> n;
  int ara[n+10];
  for(int i=0; i<n; i++)
    cin >> ara[i];
  int cnt = 0;

  for(int i=0; i<n-2; i++)
  {
      for(int j=i+1; j<n-1; j++)
      {
          for(int k=j+1; k<n; k++)
          {
              ll a = ara[i];
              ll b = ara[j];
              ll c = ara[k];
              if(a+b>c && b+c>a && a+c>b && a!=b && b!=c && c!=a)
                {cnt++;
               // cout << i << " " << j << " " << k << endl;

                }
          }
      }
  }
  cout << cnt << endl;


}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	map<long long, int> cnt;
	fr(i, 0, n){
		int a;
		cin >> a;
		cnt[a]++;
	}
	long long a = 0, b = 0;
	for(auto x : cnt){
		if(x.second >= 2){
			a = max(a, x.first);
		}
	}
	for(auto &x : cnt){
		if(x.first == a){
			x.second -= 2;
		}
	}
	for(auto x : cnt){
		if(x.second >= 2){
			b = max(b, x.first);
		}
	}
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 6528
n=int(input())
a=list(map(int,input().split()))
aDict={}
for key in set(a):
    aDict[key]=0
for ai in a:
    aDict[ai]+=1

canPuton=False
if len(aDict)==1:
    if 0 in aDict.keys():
        canPuton=True

elif len(aDict)==2:
    if 0 in aDict.keys():
        if n%3==0:
            canPuton=True
            for key in aDict:
                if key==0:
                    if aDict[key]!=n//3:
                        canPuton=False
                else:
                    if aDict[key]!=2*n//3:
                        canPuton=False

elif len(aDict)==3:
    a,b,c=aDict.keys()
    if n%3==0:
        if (a^b)==c:
            canPuton=True
            for key in aDict.keys():
                if aDict[key]!=n//3:
                    canPuton=False
if canPuton:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14212
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int c, r, b;
    for (c = 0, r = 1, b = 0; n; c += (n % 5) * b, n /= 5, b += r, r *= 5)
      ;
    cout << c << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll k;
  cin >> k;
  vector<ll> s = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i = 1;
  while (s.size() <= k + 1){
    ll a = s[i] % 10;
    ll b = s[i] * 10;
    if(a==0){
      s.push_back(b);
      s.push_back(b + 1);
    }
    else if(a==9){
      s.push_back(b + 8);
      s.push_back(b + 9);
    }
    else{
      s.push_back(a + b - 1);
      s.push_back(a + b);
      s.push_back(a + b + 1);
    }
    i++;
  }
  cout << s[k] << endl;
}

Measured memory_bytes: 1656
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll M=998244353;
int h[1000005],n,i;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&h[i]);
	h[1]--;
	for(i=2;i<=n;i++)
		if(h[i]>h[i-1])
			h[i]--;
	for(i=1;i<n;i++)
		if(h[i]>h[i+1])
		{
			printf("No");
			return 0;
		}
	printf("Yes");
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 058_arc_a / Link: https://arc058.contest.atcoder.jp/tasks/arc058_a?lang=en ----- */
/* ------問題------

いろはちゃんはこだわりもので、嫌いな数字が K 個あり、それぞれ D1,D2,…,DK です。
いろはちゃんはお店でお買い物をしていて、 N 円の品物を買おうとしています。
もちろん、この品物は N 円以上のお金を支払えば買うことができます。
しかし、先ほど述べたようにいろはちゃんは強いこだわりがあるので、
自分がお店に支払う金額の 10 進表記にいろはちゃんの嫌いな数字が出現しないような最も少ない金額を支払おうとします。
いろはちゃんが支払う金額を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, K;

LL ans = 0LL;

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

	cin >> N >> K;
	VI a(10, 1);
	FOR(i, 0, K) {
		int v; cin >> v;
		a[v] = 0;
	}

	ans = N;
	while (true)
	{

		int ok = 1;
		set<int>se;
		LL ret = N;
		while (ret) {
			se.insert(ret % 10);
			ret /= 10;
		}
		FOR(i, 0, 10) {
			if (a[i]==0&&se.count(i))ok = 0;
		}
		if (ok) {
			cout << N << endl; return 0;
		}
		N++;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int A, B, X;

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

  cin >> A >> B >> X;
  bool flag = true;
  if (A+B < X) flag = false;
  if (A > X) flag = false;
  string ans = flag?"YES":"NO"; 

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    REP(r, 3001) REP(g, 3001){
        int n = N - R * r - G * g;
        if(n >= 0 && n % B == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll>x(n),y(n),h(n);
  for(int i=0; i<n; i++ ) cin >> x[i] >> y[i] >> h[i];
  
  for(int Y=0; Y<=100; Y++){
   for(int X=0;X<=100; X++){
     ll judge=-1;
     for(int i=0; i<n; i++){
       if(h[i]>0){
         ll tmp = pow(pow(X-x[i],2),0.5)+pow(pow(Y-y[i],2),0.5)+h[i];
         if(judge==-1){
           judge=tmp;
         }
         else{
           if(judge!=tmp) judge=-2;
         }
       }
     }
     
     if(judge==-2) continue;
     
     for(int i=0; i<n; i++){
       if(h[i]==0){
         if(judge>pow(pow(X-x[i],2),0.5)+pow(pow(Y-y[i],2),0.5)){
           judge=-2;
         }
       }
     }
     
     if(judge==-2) continue;
     cout << X << " " <<  Y << " " << judge << endl;
   } 
  }
}
  
  
  


Measured memory_bytes: 256
import heapq
import math
def heapqmax(n):
    return n * -1

N,M = map(int,input().split())
A = list(map(heapqmax,map(int,input().split())))

heapq.heapify(A)
for i in range(M):
    heapq.heappush(A,math.ceil(heapq.heappop(A)/2))
    # print(A)

print(sum(A)*-1)


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

long int fact(int n){
  if(n==2) return 2;
  else return (long int)n*fact(n-1);
}

int main()
{
  int n;
  long int f;
  cin >> n;
  f=fact(n);
  cout << f << endl;
  return 0;
}

Measured memory_bytes: 3076