akhauriyash/Code-Regression huggingface dataset:
package main
import (
  "fmt"
)
func main() {
  cnt5 := 2
  cnt7 := 1
  var a, b, c string
  fmt.Scanf("%s %s %s", &a, &b, &c)
  ss := [3]string{a, b, c}
  for _, x := range(ss) {
    if 0 < cnt5 && x == "5" {
      cnt5 -= 1
    }else if 0 < cnt7 && x == "7" {
      cnt7 -= 1
    }else {
      fmt.Print("NO")
      return
    }
  }
  fmt.Print("YES")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int n, m;

int G[50][50];
bool visited[50];

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {      // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}

int main() {
  int ans = 0;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a, b);
  }
  rep(i, m) {
    rep(i, 50) rep(j, 50) G[i][j] = 10000007;
    rep(j, m) {
      if (j == i) continue;
      G[p[j].first][p[j].second] = G[p[j].second][p[j].first] = 1;
    }
    warshall_floyd(n);
    rep(j, n) rep(k, n) {
      if (G[j][k] == 10000007) {
        ans++;
        goto loop;
      }
    }
  loop:;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int ketawa(int a) {
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	int n, m;
	cin >> n >> m;
	ll sum = 0; rep(i, m) { cin >> a; sum += a; }
	if (sum > n)cout << -1 << endl;
	else cout << n - sum << endl;

	return 0;
}


Measured memory_bytes: 3636
#include"stdio.h"
#include"stdlib.h"
int ct( int N, int* L){
  int i,j,k,count=0;
  for( i=0; i<N; i++){
    for( j=i+1; j<N; j++){
      for( k=j+1; k<N; k++){
        if( L[k]<L[j]+L[i] ){
          count++;
        }
      }
    }
  }
  return count;
}
int main(void){
  int N,i,j;
  scanf("%d",&N);
  int L[N];
  int count;
  for( i=0; i<N; i++){
    scanf("%d",&L[i]);
  }
  for( i=0; i<N; i++){
    for( j=i+1; j<N; j++){
      if( L[j]<L[i] ){
        int tmp=L[j];
        L[j]=L[i];
        L[i]=tmp;
      }
    }
  }
  count=ct( N, L);
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
while true
    h,w = gets.chomp.split.map(&:to_i)
    
    if h==0 && w==0 then
        break
    end
    
    h.times do |y|
        if y==0 || y==h-1 then
            puts "#"*w
        else
            print("#","."*(w-2),"#\n")
        end
    end
    print("\n")
end

Measured memory_bytes: 8788
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
    stack<int> st;
    int i;
    while (cin >> i) {
        if (i != 0) {
            st.push(i);
        } else {
            cout << st.top() << endl;
            st.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll N, P, Q;
    cin >> N >> P >> Q;
    vector<ll> C(N);
    priority_queue<ll> que;
    ll csum = 0;
    for (ll i = 0; i < N; i++)
    {
        cin >> C[i];
        que.push(-(P * i + C[i]));
        csum += C[i];
    }
    ll ret = csum, sum = 0;
    for (ll i = 1; i <= N; i++)
    {
        sum += que.top();
        que.pop();
        ll tmp = csum + i * P * Q + P * i * (i - 1) + sum;
        ret = max(ret, tmp);
    }
    cout << ret << endl;
}



Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>

signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
string s;
std::cin >> x>>y;
priority_queue<int> v;
rep(i,x){
  std::cin >> z;
  v.push(z);
}
rep(i,y){
  n=v.top();v.pop();
v.push(n/2);
}
rep(i,x){
  m+=v.top();v.pop();
}
std::cout <<m << '\n';
}


Measured memory_bytes: 1400
/*
*author: rits1272	
*/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };  
double PI = acos(-1); 

int32_t main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	int n, cnt = 0, ans = 0;
	cin >> n;
	FOR(0, n){
		int a, b; cin >> a >> b;
		if(a == b)
			cnt++;
		else
			cnt = 0;
		ans = max(cnt, ans);
	}
	ans = max(ans, cnt);
	cout << (ans >= 3 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
  int H,  N;
  int tmp;
  cin >> H;
  cin >> N;
  int A[N];
    for(int i = 0; i <  N;i++){
      cin >> A[i];
      tmp += A[i];
    }
    if ((H - tmp) <= 0)
      cout << "Yes";
    else
      cout << "No";
    return 0;
  }



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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    priority_queue<int, vector<int>, greater<>> q;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (a >= b) {
            ++cnt;
        } else {
            q.push(n - a);
        }
    }
    int cost = 0;
    while (cnt < m - 1) {
        int p = q.top();
        q.pop();
        cost += p;
        ++cnt;
    }
    cout << cost << '\n';
    return 0;
}


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

int main() {
	int a, b,t,total;
	cin >> a >> b>>t;
  total=0;
	for(int i=1;i<21;i++){
    if(i*a<=t){
      total+=b;
    }
    else{
      break;
    }
  }
  cout<<total<<endl;
}


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

int query(int i) {
  cout << i << endl;
  string s;
  cin >> s;
  if (s[0] == 'V') {
    exit(0);
    return 0;
  }
  else if (s[0] == 'M') return 1;
  else return 0;
}

int main() {
  int n;
  cin >> n;
  int p = 0;
  int k = n - 1;
  int vp = query(p);
  int vk = query(k);
  
  while (p + 1 < k) {
    int s = (p + k) / 2;
    int vs = query(s);
    if ((s - p) % 2 == (vs - vp + 4) % 2) {
      vp = vs;
      p = s;
    }
    else {
      vk = vs;
      k = s;
    }
  }
  
  assert(false);
  return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  string s; cin >> s;
  if (s == "RRR") cout << 3 << endl;
  else if (s == "RRS" || s == "SRR") cout << 2 << endl;
  else if (s == "SSS") cout << 0 << endl;
  else cout << 1 << endl;


  return 0;
}

// EOF

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	ee := make([][]edge, n)
	for i := 0; i < m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		appendEdge(a, b, i, ee)
		appendEdge(b, a, i, ee)
	}

	pp := make([]int, n)
	dis := make([]int, n)
	for i := 0; i < n; i++ {
		dis[i] = math.MaxInt32
		pp[i] = -1
	}
	dd := &daikes{}
	heap.Init(dd)
	heap.Push(dd, newDaike(0, 0, 0))
	for dd.Len() > 0 {
		p := heap.Pop(dd).(daike)
		if dis[p.i] <= p.c {
			continue
		}
		dis[p.i] = p.c
		pp[p.i] = p.p
		for _, e := range ee[p.i] {
			if pp[e.to] != -1 {
				continue
			}
			if dis[e.to] <= p.c+1 {
				continue
			}
			heap.Push(dd, newDaike(p.i, e.to, p.c+1))
		}
	}
	for i := 0; i < n; i++ {
		if pp[i] == -1 {
			fmt.Fprintln(writer, "No")
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
	for i := 1; i < n; i++ {
		fmt.Fprintln(writer, pp[i]+1)
	}
}

func appendEdge(from, to, id int, ee [][]edge) {
	ee[from] = append(ee[from], edge{
		to: to,
		id: id,
	})
}

type edge struct {
	to, id int
}

type daike struct {
	p, i, c int
}

func newDaike(p, i, c int) daike {
	return daike{
		p: p,
		i: i,
		c: c,
	}
}

type daikes []daike

func (h daikes) Len() int { return len(h) }
func (h daikes) Less(i, j int) bool {
	return h[i].c < h[j].c
}
func (h daikes) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *daikes) Push(x interface{}) {
	*h = append(*h, x.(daike))
}
func (h *daikes) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


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


Measured memory_bytes: 128
while True:
	n, x = map(int, input().split())
	if n == 0 and x == 0:
		break
	ans = 0
	for i in range(1, n + 1):
		for j in range(1, i):
			for k in range(1, j):
				if i + j + k == x:
					ans += 1
	print(ans)


Measured memory_bytes: 5592
H, W, K = map(int, input().split())
c = []
for _ in range(H):
    c.append(input())
ans = 0
for i in range(2**H):
    bin_i = format(i, f'0{H}b')
    for j in range(2**W):
        bin_j = format(j, f'0{W}b')
        count = 0
        for ii in range(H):
            if bin_i[ii] == '1':
                continue
            for jj in range(W):
                if bin_j[jj] == '1':
                    continue
                if c[ii][jj] == '#':
                    count+=1
        if count == K:
            ans+=1
print(ans)

Measured memory_bytes: 9216
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int A, B;
	cin >> A >> B;
	if (B == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	int n = A, count = 1;
	for (; n < B; n += A - 1, ++count);
	cout << count << endl;
	return 0;
}


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

long long a[1005];

int main()
{
    long long i, n, ck=0;

    cin>>n;

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

        if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0)
            ck=1;
    }

    if(!ck) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<vector<int>> group;
public:
    UnionFind(int n = 1) {
        par.resize(n + 1);
        rank.resize(n + 1);
        size.resize(n + 1);
        group.resize(n + 1);
        for (int i = 0; i <= n; ++i) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
            group[i].push_back(i);
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = find(par[x]);
            return par[x] = r;
        }
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        } else {
            if (rank[x] < rank[y]) {
                swap(x, y);
            }
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
            par[y] = x;
            size[x] += size[y];
            return true;
        }
    }

    int get_size(int x) {
        return size[find(x)];
    }

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (group[x].size() > group[y].size()) {
            swap(x, y);
        }
        copy(group[y].begin(), group[y].end(), back_inserter(group[x]));
        group[y].clear();
        par[y] = x;
    }
};


void solve() {
    ll N, M;
    cin >> N >> M;
    UnionFind unionFind(N);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        unionFind.unit(a, b);
    }
    int ans = 0;
    rep(i, N) {
        ans = max(ans, unionFind.get_size(i + 1));
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 16384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            var input1 = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            var H = input1[0];
            var W = input1[1];
            var input2 = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            var h = input2[0];
            var w = input2[1];
            Console.WriteLine((H - h) * (W - w));
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p;
   cin>>n>>m>>p;
  if(abs(n-m)<abs(n-p))
  {
      cout<<"A"<<endl;
  }
  if(abs(n-m)>abs(n-p))

  {
      cout<<"B"<<endl;
  }
  
}


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

int main(){
	int N; cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; ++i) cin>>A[i];
	sort(A.begin(), A.end());
	int n = A[N-1], r = 0;
	int mindiff = INT_MAX;
	for(int i=N-2; i>=0; --i){
		// int diff = abs(n/2 - A[i]);// |⌊n/2⌋ - ai|
		// if(mindiff > diff){ mindiff = diff; r = A[i]; }
		int diff = abs((n+2-1)/2 - A[i]);// |⌊n/2⌋ - ai|
		if(mindiff >= diff){ mindiff = diff; r = A[i]; }
	}
	cout<< n <<" "<< r <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
    
    int A, B;
    cin >> A >> B;

    if (B == 1) {
        cout << 0 << endl;
    } else {
        for (int i = 1; i <= B; i++) {
            if (A*i - (i-1) >= B) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main() {
  int l, r, x; cin >> l >> r >> x;
  int cnt = 0;
  loop(i,l,r+1) {
    cnt += i%x == 0;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	string s,a="",b="";
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			a+="0";
			b+="1";
		}
		else{
			a+="1";
			b+="0";
		}
	}
	int cnt1=0,cnt2=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=a[i])cnt1++;
		if(s[i]!=b[i])cnt2++;
	}
	cout<<min(cnt1,cnt2)<<endl;

}


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

int main(){
	int a, b; cin >> a >> b;
	int res = 0;
	while (a--){
		int sayi; cin >> sayi;
		if (sayi >= b) res++;
	}
	cout << res;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define INF 100000000;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int yymm;
	cin >> yymm;
	int yy = yymm / 100, mm = yymm % 100;
	//cout << yy << " " << mm;
	bool can1, can2; can1 = can2 = false;
	//YYMMの判定
	if (1 <= mm && mm <= 12) {
		if (1 <= yy && yy <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else
			cout << "YYMM" << endl;
	}
	else {
		if (1 <= yy && yy <= 12) {
			cout << "MMYY" << endl;
		}
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int sum=0;
  cin>>a>>b;
  for(int i=0;i<2;i++){
   if(a>=b){
     sum+=a;
     a--;
   }else{
     sum+=b;
     b--;
   }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 384
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >>a[i];
    }
    sort(a,a+n);
    int k=0;
    k = a[n/2] - a[n/2-1];
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int a,b,c;
cin >> a >> b >> c;

int M = max(a,max(b,c));
int sum = a + b + c;
int ans;

if((M*3 - sum) % 2 == 0) ans = (M*3 - sum)/2;
else ans = (M*3 + 3 - sum)/2;

cout << ans << endl;


return 0;
}

Measured memory_bytes: 384
from collections import deque

def main():
    n = int(input())
    commands = [input() for _ in range(n)]

    l = deque()
    for command in commands:
        op = command.split(' ')[0]
        
        if op == 'insert':
            x = command.split(' ')[1]
            l.appendleft(x)
        elif op == 'delete':
            x = command.split(' ')[1]
            if (x in l):
                l.remove(x)
        elif op == 'deleteFirst':
            l.popleft()
        elif op == 'deleteLast':
            l.pop()
        
    print(' '.join(l))
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 212432
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static final char[] BEGINS = { 'M', 'A', 'R', 'C', 'H' };

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

        int N = sc.nextInt();
        String[] S = new String[N];
        for (int i = 0; i < S.length; ++i) {
            S[i] = sc.next();
        }

        System.out.println(solve(S));

        sc.close();
    }

    static long solve(String[] S) {
        Map<Character, Integer> beginToCount = new HashMap<>();
        for (String name : S) {
            char begin = name.charAt(0);

            beginToCount.put(begin, beginToCount.getOrDefault(begin, 0) + 1);
        }

        long result = 0;
        for (int i = 0; i < BEGINS.length; ++i) {
            for (int j = i + 1; j < BEGINS.length; ++j) {
                for (int k = j + 1; k < BEGINS.length; ++k) {
                    result += (long) beginToCount.getOrDefault(BEGINS[i], 0) * beginToCount.getOrDefault(BEGINS[j], 0)
                            * beginToCount.getOrDefault(BEGINS[k], 0);
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 51492
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
struct P{int x,y;}p[MN*2+5];
bool cmp(const P&a,const P&b){return a.x<b.x;}
int u[MN+5],n,i,x,y;
long long ans;
int main()
{

	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",&p[i].x,&p[i+n].x),p[i].y=i,p[i+n].y=-i;
	sort(p+1,p+n+n+1,cmp);
	for(i=1;i<=n;++i)ans+=p[i].x,x|=u[abs(p[i].y)]++,y|=1LL*p[i].y*p[i-1].y<0;
	printf("%lld",x||!y?ans:p[n].y==-p[n+1].y?ans+min(p[n+2].x-p[n].x,p[n+1].x-p[n-1].x):ans-p[n].x+p[n+1].x);
}

Measured memory_bytes: 2176
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
E = []
for _ in range(M):
    x, y = map(int, input().split())
    E.append((x-1, y-1))
ans = [0 for _ in range(M)]
ans[M-1] = (N*(N-1))//2
tre = UnionFind(N)

for i in range(M-1)[::-1]:## ansのi番目について答える
    a, b = E[i+1]
    if tre.same(a, b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - (tre.size(a))*(tre.size(b))        
    tre.union(a, b)

for an in ans:
    print(an)

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


int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    forn(i,n) cin >> a[i];
    vector<int> s = a;
    sort(s.rbegin(), s.rend());
    forn(i, n) {
        int ans = s[0];
        if (a[i] == s[0]) ans = s[1];
        cout << ans << endl;
        }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  cin >> N;
  vector<ll> A;
  rep (i, pow(2, N)) {
    ll v0;
    cin >> v0;
    A.push_back(v0);
  }

  // dp[k]: i | j | k == k となる i, j のうち A[i] + A[j] が最大となる i, j
  vector<set<tuple<ll, ll>>> dp(pow(2, N));
  repr (k, 1, pow(2, N)) {
    dp[k] = set<tuple<ll, ll>>{make_tuple(A[0], 0), make_tuple(A[k], k)};
  }

  repr (k, 1, pow(2, N)) {
    dp[k] = set<tuple<ll, ll>>{*prev(dp[k].end()), *prev(dp[k].end(), 2)};
    ll mask = k;
    while (mask < pow(2, N) - 1) {
      // kに立ってないビットを1つだけ立てる
      ll next_k = (mask + 1) | k;
      mask |= next_k;
      dp[next_k].insert(all(dp[k]));
    }
  }

  vector<ll> ans(pow(2, N), 0);
  ll m = 0;
  repr (k, 1, pow(2, N)) {
    ll a1, a2, _;
    tie(a1, _) = *prev(dp[k].end());
    tie(a2, _) = *prev(dp[k].end(), 2);
    ans[k] = m = max(m, a1 + a2);
  }

  repr (k, 1, pow(2, N)) {
    cout << ans[k] << "\n";
  }
}

Measured memory_bytes: 74096
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int no_of_steps, no_of_broken_steps;
    cin >> no_of_steps >> no_of_broken_steps;

    vector <int> is_broken(no_of_steps + 1, 0);
    for(int i = 1; i <= no_of_broken_steps; i++)
    {
        int step;
        cin >> step;
        is_broken[step] = true;
    }

    const int MOD = 1e9 + 7;
    vector <long long> no_of_ways_till(no_of_steps + 1, 0);
    no_of_ways_till[0] = 1;
    for(int i = 1; i <= no_of_steps; i++)
    {
        if(is_broken[i])
        {
            no_of_ways_till[i] = 0;
            continue;
        }

        if(i == 1)
        {
            no_of_ways_till[i] = 1;
            continue;
        }

        no_of_ways_till[i] = (no_of_ways_till[i - 1] + no_of_ways_till[i - 2])%MOD;
    }

    cout << no_of_ways_till[no_of_steps];
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
n = n % 10

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<ll> que;
    for(int i=0;i<N;i++){
        ll A; cin >> A;
        que.push(A);
    }
    for(int i=0;i<M;i++){
        ll tmp=que.top(); que.pop();
        tmp = tmp/2;
        que.push(tmp);
    }
    ll ss = 0;
    for(int i=0;i<N;i++){
        ss += que.top(); que.pop();
    }
    cout << ss << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 2e5, MaxM = 4e5;
int n, all, Q, K;
int pre[MaxM + 5], last[MaxN + 5], other[MaxM + 5];
int seq[MaxN * 20 + 5];
bool Inseq[MaxN + 5];
LL cost[MaxM + 5], dis[MaxN + 5];

void Build(int x, int y, int w)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}

void Init()
{
	all = -1; memset(last, -1, sizeof(last));
	for (int i = 1; i <= n - 1; i++) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		Build(u, v, w); Build(v, u, w);
	}
}

void Spfa(int s) 
{
	int head = 1, tail = 0;
	memset(Inseq, 0, sizeof(Inseq));
	for (int i = 1; i <= n; i++) dis[i] = 1LL << 60;
	dis[s] = 0; seq[++tail] = s; Inseq[s] = true;
	while (head <= tail) {
		int now = seq[head];
		int ed = last[now], dr;
		while (ed != -1) {
			dr = other[ed];
			if (dis[now] + cost[ed] < dis[dr]) {
				dis[dr] = dis[now] + cost[ed];
				if (!Inseq[dr]) {
					Inseq[dr] = true;
					seq[++tail] = dr;
				}
			}
			ed = pre[ed];
		}	
		head++;
		Inseq[now] = 0;
	}
}


void Solve()
{
	scanf("%d%d", &Q, &K);
	Spfa(K);
	for (int i = 1; i <= Q; i++) {
		int u, v; scanf("%d%d", &u, &v);
		printf("%lld\n", dis[u] + dis[v]);
	}
}

int main()
{
	while (~scanf("%d", &n)) {
		Init();
		Solve();
	}
	return 0;	
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<array<int64_t, 2>>> E(n);

    for (int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        E[l].push_back({r, d});
        E[r].push_back({l, -d});
    }

    vector<int> A(n, -1);
    int k = 0;
    vector<map<int, int64_t>> D(n);
    auto dfs = [&](auto i, auto self) -> bool{
        if (A[i] != -1)
            return true;
        A[i] = k;
        if (D[k].empty())
            D[k][i] = 0;

        bool res = true;
        for (const auto &e: E[i]){
            int r = e[0];
            int64_t d = e[1];
            if (D[k].count(r) != 0 and D[k][r] != D[k][i] + d)
                return false;
            D[k][r] = D[k][i] + d;
            res &= self(r, self);
        }
        return res;
    };

    for (int i = 0; i < n; i++){
        if (!dfs(i, dfs)){
            puts("No");
            return 0;
        }
        k++;
    }

    puts("Yes");
}


Measured memory_bytes: 29952
#include <stdio.h>
 
int main(void){
  int x,i,n,min,max;
  long int sum;
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d",&x);
    if(i == 1){
      min = x;
      max = x;
      sum = x;
    }
    else{
      if(min > x){
	min = x;
      }
      if(max < x){
	max = x;
      }
      sum += x;
    }
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	vector<int> n(26, 0);
	for (int i = 0; s[i] != '\0'; ++i) {
		n[s[i]-'a']++;
		if (n[s[i] - 'a'] > 1) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}



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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

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

    int ans = 0;
    ans += x/500 * 1000;
    x %= 500;
    ans += x/5 * 5;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll f(ll x, ll n){
    if(n==-1)
        return 0;
    else{
        return n/x+1;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

const int N = 50 + 5;

ll c[N][N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	rep(i,0,N)c[i][0] = 1;
	rep(i,1,N){
		rep(j,1,i+1){
			c[i][j] = c[i-1][j] + c[i-1][j-1];
		}
	}
	int n,a,b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	rep(i,0,n)cin >> v[i];
	sort(all(v));
	ll sum = 0, cnt = a;
	rep(i,0,a)sum += v[n-i-1];
	
	ll ans = 0;
	rep(i,a,b+1){
		ll tsum = 0, tcnt = i;	
		rep(j,0,i)tsum += v[n-j-1];	
		if(tsum * cnt == sum * tcnt){
			int totcnt = 0, used = 0;
			rep(j,0,n){
				totcnt += v[n-i] == v[j];
				used += (v[n-i] == v[j] && j >= n - i);
			}
			ans += c[totcnt][used];
		}
		else{
			break;
		}
	}
	double res = double(sum)/double(cnt);
	cout.precision(13);
	cout << res << '\n' << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1==0)
  {
  cout << 1 << endl;
    return 0;
  }
  if (x2==0)
  {
  cout << 2 << endl;
    return 0;
  }
  if (x3==0)
  {
  cout << 3 << endl;
    return 0;
  }
  if (x4==0)
  {
  cout << 4 << endl;
    return 0;
  }
  if (x5==0)
  {
  cout << 5 << endl;
    return 0;
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
const long long MOD = 1e9+7;
//最大公約数
long long gcd(long long a,long long b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        swap(a,b);
        b = b%a;
    }
    return b;
}
long long lcm(long long a,long long b){
    long long ret = a*b;
    ret/=gcd(a,b);
    return ret;
}
int main(){
    int n;
    long long m;
    cin >> n >> m;
    long long a[n];
    rep(i,n){
        cin >> a[i];
        a[i]/=2;
    }
    long long llcm = a[0];
    for(int i = 1;i<n;i++){
        llcm = lcm(llcm,a[i]);
        if(llcm>m) break;
    }
    if(m<llcm){
        cout << 0 << endl;
        return 0;
    }
    bool fl = false;
    rep(i,n) if((llcm/a[i])%2==0) fl = true;
    if(fl){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1+((m-llcm)/(2*llcm));
    cout << ans << endl;
}

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

ll MOD = 998244353;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

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

	int N; cin >> N;
	vector<ll> D(N);
	rep(i, N) cin >> D[i];
	map<ll, ll> mp;
	rep(i, N) {
		ll d = D[i];
		mp[d] += 1;
	}
	if (mp[0] != 1 || D[0] != 0) {
		cout << 0 << endl;
	} else {
		ll ans = 1;
		for(const auto& m: mp) {
			// cout << m.first << endl;
			if (m.first < 1) continue;
			ans *= modpow(mp[m.first-1ll], m.second, MOD);
			ans %= MOD;
		}
		cout << ans % MOD << endl;
	}
}


Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if((a - 2*b) > 0){
        	System.out.println(a - 2*b);
        }else{
        	System.out.println(0);
        }
	}        
}

Measured memory_bytes: 21844
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d = map(int, readline().split())
if a + b > c + d:
    print('Left')
elif a + b < c + d:
    print('Right')
else:
    print('Balanced')

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

int main(){
    string s;
    cin >> s;

    int ans = 1000;
    for(int i = 0; i < s.length()-2; i++){
        int tmp = 100*(s[i]-'0') + 10*(s[i+1]-'0') + s[i+2]-'0';
        ans = min(ans, abs(tmp-753));
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
	string a("Sunny");
	string b("Cloudy");
	string c("Rainy");
	string d;
	while(cin>>d)
	{
	if(d==a)
		cout<<b<<endl;
	else if(d==b)
		cout<<c<<endl;
	else
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; 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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み
  vector<ll> parent;

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    parent.resize(N);
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
  }

  ll dijkstra(ll s,ll g){
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que; //ansが小さい順に出る
    que.push(P(0,s)); // P < ans , Node >
    while(!que.empty()){
      P p = que.top(); que.pop(); //pに <ans,Node> 入れる
      ll v = p.second; //vに Node 入れる
      if(d[v] < p.first) continue; //すでに良い数値が入っているならパス
      rep(i,G[v].size()){
        edge& E = G[v][i];
        if(d[E.to] > d[v] + E.cost){ //更新するなら
          d[E.to] = d[v]+ E.cost;
          parent[E.to] = v; //親を記録,goalから遡れば道順
          que.push(P(d[E.to], E.to));
        }
      }
    }
    return(d[g]);
  }
};

void Main(){

  ll K;
  cin>>K;

  graph g(K);

  rep(i,K){
    g.add_edge(i,(i+1)%K,1);
  }

  rep(i,K){
    g.add_edge(i,(i*10)%K,0);
  }

  cout<<g.dijkstra(1,0)+1<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 10044
N,M = map(int,input().split())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]

parent = [i for i in range(N)]
rank = [0] * N
def root(a):
    if parent[a] == a:
        return a
    else:
        parent[a] = root(parent[a])
        return parent[a]
def is_same(a,b):
    return root(a) == root(b)
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb: return
    if rank[ra] < rank[rb]:
        parent[ra] = rb
    else:
        parent[rb] = ra
        if rank[ra] == rank[rb]: rank[ra] += 1

ans = 0
for i in range(M):
    parent = [i for i in range(N)]
    rank = [0] * N
    for j,(a,b) in enumerate(src):
        if i == j: continue
        unite(a,b)
    if len(set([root(i) for i in range(N)])) > 1:
        ans += 1
print(ans)


Measured memory_bytes: 3064
def gcd(a, b):
    return b if a % b == 0 else gcd(b, a % b)


def lcm(a, b):
    return a // gcd(a, b) * b


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
ans = a[0]
for x in range(1, n):
    ans = lcm(ans, a[x])

print(ans)


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

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

    int h[N+1], DP[N+1];
    for(int i = 1; i <= N; i++) cin >> h[i];

    DP[1] = 0;
    for(int i = 2; i <= N; i++)
    {
        DP[i] = 2000000000;
        for(int j = max(1, i-K); j < i; j++) DP[i] = min(DP[i], DP[j] + abs(h[i]-h[j]));
    }
    cout << DP[N] << '\n';
}

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

using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll mypow(ll a,ll b){ 
    ll ans=1;
    while(b){ 
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int main(){ 
    ll n;
    cin>>n;
    cout<<(((mypow(10,n)-2*mypow(9,n))%mod+mod)+mypow(8,n))%mod;
    return 0;
}


Measured memory_bytes: 3552
A = list(input())
B = list(input())
C = list(input())
A.append("0")
B.append("0")
C.append("0")
x = A[0]
del A[0]
while x != "0":
    if x == "a":
        x = A[0]
        del A[0]
    elif x == "b":
        x = B[0]
        del B[0]
    else:
        x = C[0]
        del C[0]

if "0" not in A:
    print("A")
elif "0" not in B:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int maxtime(int x){
  return (x + 9) / 10 * 10;
}
int remtime(int x){
  return maxtime(x) - x;
}
  
int main() {
  vector<int>a(5);
  vector<int>b(5);
  vector<int>c(5);
  int sum;
  sum = 0;
  for(int i = 0; i < 5; i++){
    cin >> a.at(i);
    b.at(i) = remtime(a.at(i));
    c.at(i) = maxtime(a.at(i));
    sum = sum + c.at(i);
  }
  
  sum = sum - max({b.at(0), b.at(1), b.at(2), b.at(3), b.at(4)});
  cout << sum << endl;
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main()
{
	ll n;
	cin>>n;
	vector<int> p(n);
	vector<int> q(n);
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	vector<int> a(n);
	rep(i,n)a[i]=i+1;
	map<vector<int>, int> mp;
	int cnt=1;
	do{
		mp[a]=cnt;
	//	mp[a]=mp.size();
	cnt++;
	}while (next_permutation(a.begin(),a.end()));
	int ans=abs(mp[p]-mp[q]);
	cout<<ans;




}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vvl a(n, vl(n));
  rep(i,0,n)  rep(j,0,n) cin >> a[i][j];

  const ll inf = 1e18;
  vl dp(1<<n, -inf);
  dp[0] = 0;

  vl cst(1<<n);
  rep(msk,0,1<<n) {
    rep(i,0,n) rep(j,i+1,n) if ((msk&(1<<i)) and (msk&(1<<j))) cst[msk] += a[i][j];
  }

  rep(msk,0,1<<n) {
    int rmsk = ((1<<n)-1)^msk;
    for (int smsk = rmsk; smsk; smsk = (smsk-1)&rmsk) {
      ckmax(dp[msk|smsk], dp[msk]+cst[smsk]);
    }
  }

  cout << dp[(1<<n)-1] << '\n';
}

Measured memory_bytes: 1280