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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> vec(h+2,vector<char>(w+2));
  for(int i = 1; i < h+1;i++){
  for(int j = 1; j < w+1;j++){
  cin >>vec.at(i).at(j);
  }
  }
  for(int i = 0; i < w + 2;i++){
  vec.at(0).at(i) = '#';
  vec.at(h+1).at(i) = '#';
  }
  for(int i = 0; i < h + 2;i++){
  vec.at(i).at(0) = '#';
  vec.at(i).at(w+1) = '#';
  }
for(int i = 0; i < h+2;i++){
  for(int j = 0; j < w+2;j++){
  cout << vec.at(i).at(j);
  }
  cout << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 10000
#define TOSEC(h,m,s) ((h)*3600+(m)*60+(s))
struct Train{
	int st;
	int ed;
	bool operator<(const Train &t)const{
		return ed > t.ed;
	}
};
bool CompTrainForSort(const Train &a, const Train &b){
	return a.st < b.st;
}
int main(){
	/*priority_queue<int> test;
	test.push( 100 );
test.push( 101 );
test.push( 102 );
test.push( 103 );
test.push( 10 );
test.push( 49 );

cout << test.top() << endl;*/

	while(true){
		Train vt[MAX];
		unsigned int ans = 0;
		int n;
		priority_queue< Train > pq;
		scanf("%d", &n);

		if( n == 0 ) break;

		for(int i = 0; i < n; ++i){
			int sh,sm,ss;
			int eh,em,es;
			Train t;
			
			scanf("%02d:%02d:%02d %02d:%02d:%02d",
				&sh,&sm,&ss,
				&eh,&em,&es);
			t.st = TOSEC(sh,sm,ss);
			t.ed = TOSEC(eh,em,es);

			vt[i] = t;
		}

		sort( vt, vt + n, CompTrainForSort );
		
		for(int i = 0; i < n; ++i){
			if( pq.size() == 0 )
				pq.push( vt[i] );
			else{
				Train tt = pq.top();
				if( tt.ed <= vt[i].st ){
					pq.pop();
					pq.push( vt[i] );
				}else{
					pq.push( vt[i] );
				}
			}
			ans = max(ans, pq.size());
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	int g[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
	cin>>x>>y;
	cout<<(g[x]==g[y]?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

map<PLL,ll> ma;
ll h,w,n;
vector<PLL> v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>h>>w>>n;
    vector<PLL> ck;
    ll aa,bb;
    rep(i,n){
        cin>>aa>>bb;
        v.pb(mp(bb,aa));
    }
    rep(i,v.size()){
        PLL tmp = v[i];
        repi(j,tmp.first-2,tmp.first+1){
            repi(k,tmp.second-2,tmp.second+1){
                if(k<=0||j<=0)continue;
                if(k>h-2||j>w-2)continue;
                if(ma[mp(j,k)]==0)ck.pb(mp(j,k));
                ma[mp(j,k)]++;
            }
        }
    }
    ll al = (h-2)*(w-2);
    Vi ans(10,0);
    rep(i,ck.size()){
        //cout<<ck[i].first<<" "<<ck[i].second<<" "<<ma[ck[i]]<<endl;
        ans[ ma[ck[i]] ]++;
    }
    rep(i,9){
        al -= ans[i+1];
    }
    print(al);
    rep(i,9){
        print(ans[i+1]);
    }
    return 0;
}

Measured memory_bytes: 74084
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, b;

int main(){
	cin >> n >> a >> b;
	if(abs(a-b)%2){cout << "Borys" << endl;}
	else{cout << "Alice" << endl;}
	return 0;
}

Measured memory_bytes: 256
/**
 * @author karayuu
 */
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ")

    /* 下手なことせず頭文字をとって並べるのが楽 */
    print(a[0].toString() + b[0].toString() + c[0].toString())
}

Measured memory_bytes: 37752
#include <stdio.h>
#include <math.h>
#define P 3
int main(void)
{
	int n, x[1000], y[1000], i, j;
	double D, DD;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", x+i);
	}
	for(i=0; i<n; i++){
		scanf("%d", y+i);
	}
	for(j=1; j<=P; j++){
		D=0;
		for(i=0; i<n; i++){
			D += pow(fabs(*(x+i)-*(y+i)), j);
		}
		printf("%.8f\n", pow(D, 1.0/j));
	}
	D=0;
	for(i=0; i<n; i++){
		DD = fabs(*(x+i)-*(y+i));
		D = (D<DD ? DD : D);
	}
	printf("%.8f\n", D);
	return 0;
}

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

using namespace std;

#define rep(a, b) for(int i = a; i <= b; i++)

const int MAX = 1e2 + 10;
bool s[MAX][MAX];

int main()
{
	int n;
	while(~scanf("%d", &n))
	{
		rep(1, n)
		{
			int row;
			scanf("%d", &row);
			int num;
			scanf("%d", &num);
			for(int j = 1; j <= num; j++)
			{
				int column;
				scanf("%d", &column);
				s[row][column] = true;
			}
		}
		rep(1, n)
		{
			for(int j = 1; j <= n; j++)
			{
				printf("%d", s[i][j]);
				if(j != n)
					printf(" ");
				else
					printf("\n");
			}
		}
	}
	return 0;
}



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

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

    vector<ll> x(n+1), y(n+1);
    rep(i,n) cin >> x.at(i+1);
    rep(i,n) y.at(i+1) = x.at(i+1);
    sort(y.begin(), y.end());

    int mid = n/2;

    for(int i=1; i<=n; i++){
        if(x.at(i)<=y.at(n/2)) cout << y.at(n/2+1) << endl;
        else cout << y.at(n/2) << endl;
    }


}


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

struct rtree{
  int org;
  int sib;
  int chd;
};

int main(){
  vector<rtree> node;
  int n;

  cin >> n;
  node.resize(n);
  for(int i=0;i<n;i++){
    node[i].org = node[i].sib = node[i].chd = i;
  }

  for(int i=0;i<n;i++){
    int id,id_,k,c;
    cin >> id >> k;
    id_ = id;
    for(int j=0;j<k;j++){
      cin >> c;
      if(j==0){
	node[id_].chd = c;
	node[c].org = id;
	id_ = c;
      }else{
        node[id_].sib = c;
	node[c].org = id;
	id_ = c;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << "node " << i;
    
    if(i==node[i].org){
      cout << ": parent = -1";
    }else{
      cout << ": parent = " << node[i].org;
    }

    if(i == node[i].org){
      cout << ", depth = 0";
    }else{
      int j=i,counter=0;
      
      while(j != node[j].org){
	j = node[j].org;
        counter++;
      }
      cout << ", depth = " << counter;
    }

    if(i==node[i].org){
      cout << ", root, [";
    }else if(i==node[i].chd){
      cout << ", leaf, [";
    }else{
      cout << ", internal node, [";
    }

    if(i!=node[i].chd){
      int j=i;

      cout << node[j].chd;
      j = node[j].chd;
      while(j!=node[j].sib){
        j = node[j].sib;
        cout << ", " << j;
      }
    }
    cout << "]" << endl;
  }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  vector<pair<int,int>> v(5);
  int ans = 0;
  for(int i=0;i<5;i++){
    int x ;
    cin >> x;
    int y = x%10;
    if(y == 0)
      y=10;
    v.at(i) = make_pair(y,x);
  }
  
  sort(all(v));
  reverse(all(v));

  for(int i=0;i<4;i++){
    int x,y;
    tie(x,y) = v.at(i);
    ans += y +10 -x;
  }
  int x,y;
  tie(x,y) = v.at(4);
  ans += y;
  
  cout << ans;
   
  
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
$count_3 = (int)floor($n / 3);
$end_3 = 3 * $count_3;
$sum_3 = ($count_3 * (3 + $end_3)) / 2;

$count_5 = (int)floor($n / 5);
$end_5 = 5 * $count_5;
$sum_5 = ($count_5 * (5 + $end_5)) / 2;

$count_15 = (int)floor($n / 15);
$end_15 = 15 * $count_15;
$sum_15 = ($count_15 * (15 + $end_15)) / 2;

$sum = ($n * ($n + 1)) / 2;

echo $sum - $sum_3 - $sum_5 + $sum_15;

Measured memory_bytes: 16168
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
#define X first
#define Y second
using namespace std;
typedef unsigned long long ull;
typedef pair<ull,ull> pii;
int n;
string s,t;
map<pii,ull> cnt;
ull pw[22],ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	for(int i=pw[0]=1;i<=n;i++)pw[i]=pw[i-1]*MOD;
	for(int i=0;i<(1<<n);i++){
		pii ha(0,0);
		int lenb=0;
		for(int j=0;j<n;j++){
			if(i>>j&1)ha.X=ha.X*MOD+s[j];
			else ha.Y+=pw[lenb++]*s[j];
		}
		cnt[ha]++;
	}
	t=s.substr(n,n);
	reverse(t.begin(),t.end());
	for(int i=0;i<(1<<n);i++){
		pii ha(0,0);
		int lenb=0;
		for(int j=0;j<n;j++){
			if(i>>j&1)ha.X=ha.X*MOD+t[j];
			else ha.Y+=pw[lenb++]*t[j];
		}
		ans+=cnt[ha];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 33024
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	public static class Pair implements Comparable<Pair> {
		public final int first;
		public final int second;
	
		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}
	
		@Override
		public int compareTo(Pair o) {
			int ord = Integer.compare(this.first, o.first);
			if (ord != 0) return ord;
			ord = Integer.compare(this.second, o.second);
			return ord;
		}
	}
	
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] C = new int[M];
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			A[i] = a;
			int bits = 0;
			for (int j = 0; j < b; j++) {
				int c = sc.nextInt();
				bits |= 1 << (c - 1);
			}
			C[i] = bits;
		}
		// int[] cost = new int[(1 << N)];
		// for (int i = 0; i < M; i++) {
		// 	int price = A[i];
		// 	int bits = C[i];
		// 	cost[bits] = Math.min(cost[bits], price);
		// 	for (int j = 1; j < cost.length; j++) {
		// 		if (j == bits) continue;
		// 	}
		// }
		int ans = -1;
		int ALL = (1 << N) - 1;
		boolean[] visited = new boolean[1 << N];
		PriorityQueue<Pair> que = new PriorityQueue<Pair>();
		que.add(new Pair(0, 0));
		// System.err.println("start");
		while (que.size() > 0) {
			Pair p = que.poll();
			int price0 = p.first;
			int bits0 = p.second;
			if (visited[bits0]) continue;
			visited[bits0] = true;
			if (bits0 == ALL) {
				ans = price0;
				break;
			}
			for (int i = 0; i < M; i++) {
				int price1 = A[i];
				int bits1 = C[i];
				if (visited[bits0 | bits1]) continue;
				que.add(new Pair(price0 + price1, bits0 | bits1));
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65640
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Easy Linear Programming
 */

#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() {
  int a, b, c, k;
  scanf("%d%d%d%d", &a, &b, &c, &k);

  int sum = min(k, a) - max(k - (a + b), 0);
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 3228
#include <iostream>
using namespace	std;
int main(){

  for(int n;cin>>n&&n;){
    int a[5000],r;
    cin>>a[0];
    r=a[0];
    for(int i=1,b;i<n;i++){
      cin>>b;
      a[i]=a[i-1]+b;
      r=max(r,max(a[i],b));
    }
    for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) r=max(r,a[j]-a[i]);
    cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<queue<int>> A(N);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N-1; ++j) {
            int a;
            cin >> a;
            A[i].push(a-1);
        }
    }

    int ans = 0;
    set<int> updated_idxs;
    for (int i = 0; i < N; ++i) {
        updated_idxs.insert(i);
    }

    while (true) {
        // print("ans", ans);
        // print("A", A);
        // print("updated_idxs", updated_idxs);
        vector<bool> updated(N, false);
        set<int> new_updated_idxs;

        for (int i : updated_idxs) {
            if (!A[i].empty() && new_updated_idxs.count(i) == 0) {
                int j = A[i].front();
                if (!A[j].empty() && new_updated_idxs.count(j) == 0 && A[j].front() == i) {
                    A[i].pop(); A[j].pop();
                    new_updated_idxs.insert(i); new_updated_idxs.insert(j);
                }
            }
        }

        if (new_updated_idxs.empty()) {
            break;
        }
        updated_idxs = new_updated_idxs;
        ans += 1;
    }

    bool nonempty_any = false;
    for (int i = 0; i < N; ++i) {
        if (!A[i].empty()) {
            nonempty_any = true;
        }
    }

    if (nonempty_any) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 vector<double>C(N);
 for(int i=0;i<N;i++){
     cin>>A[i];
     C[i]=1/(double)(A[i]);
 }
 double sum=0;
 for(int i=0;i<N;i++){
     sum+=C[i];
 }
 cout << fixed << setprecision(7);
 cout<<1/sum<<endl;
 return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  set<ll> se;
  se.insert(a);
  se.insert(b);
  se.insert(c);
  if(se.sz==2){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 764
#pragma once
#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>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
int n;
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}

void Solve() {
	
	int n, k;
	cin >> n >> k;
	int c = 0;
	for (size_t i = 1; i <= n; i += 2)
	{
		c += 1;
	}

	if (c >= k) {
		cout << "YES" << endl;
	}else 
		cout << "NO" << endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define mod 1000000007
#define nl cout<<"\n"
#define fr(n) for(int i = 0; i<n; i++)
#define frr(j, n) for(int i = j; i<n; i++)
#define Mem(x) memset(x, 0, sizeof(x))
using namespace std;
typedef long long int lli;
int main(){
    lli n;
    cin>>n;
    lli a[n];
    lli ans = 0;
    fr(n){
        cin>>a[i];
        ans += a[i];
    }
    lli ans2 = 0, k;
    fr(n-1){
        ans -= a[i];
        k = ans%mod;
        k *= a[i];
        k %= mod;
        ans2 += k;
    }
    cout<<ans2%mod;
    return 0;
}

Measured memory_bytes: 5168
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000]
,d[110000][3];
string str;
bool f;
char c[1100][1100];
void dijkstra(vector<vector<Edge>>&g, int s) {
	rep(i, n)rep(j, 3)d[i][j] = INF;
	priority_queue<Ppll, vector<Ppll>, greater<Ppll>> q;
	d[s][0] = 0;
	q.emplace(Ppll(d[s][0], Pll(s, 0)));
	while (!q.empty()) {
		LL cost=q.top().first;
		LL idx=q.top().second.first,flag=q.top().second.second;
		q.pop();
		if (d[idx][flag] < cost) continue;
		for (auto &e : g[idx]) {
			auto next = cost + e.cost;
			if (d[e.to][(flag + 1) % 3] <= next) continue;
			d[e.to][(flag + 1) % 3] = next;
			q.push(Ppll(d[e.to][(flag + 1) % 3], Pll(e.to,(flag + 1) % 3 )));
		}
	}
}
int main() {
	cin >> n >> m;
	g.resize(n);
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		g[x].push_back(Edge{ y,1 });
	}
	cin >> s >> t;
	s--, t--;
	dijkstra(g, s);
	cout << (d[t][0]!=INF?d[t][0]/3:-1) << endl;
	return 0;
}

Measured memory_bytes: 8948
H, w, k = map(int, input().split())
sw = [list(input()) for _ in range(H)]

r = []
h = 0
c = 1
for i in range(H):
    hh = []
    h = 0
    if all(x == '.' for x in sw[i]):
        r.append([-1 for _ in range(w)])
    else:
        for j in range(w):
            if sw[i][j] == '.':
                hh.append(c)
            elif h == 0 and sw[i][j] == '#':
                hh.append(c)
                h = 1
            else:
                c += 1
                hh.append(c)
        c += 1
        r.append(hh)
for i in range(H):
    if r[i][0] < 0:
        j = i+1
        while j < H and all(x < 0 for x in r[j]):
            j += 1
        if j < H:
            for ii in range(w):
                r[i][ii] = r[j][ii]
        else:
            j = i-1
            while j >= 0 and all(x < 0 for x in r[j]):
                j -= 1
            for ii in range(w):
                r[i][ii] = r[j][ii]


for i in r:
    print(*i)

Measured memory_bytes: 8272
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B  = inputIL()

if A%2 == B%2 :
  print((A+B)//2)
  exit()
print("IMPOSSIBLE")

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

int main() {
    int a, n, m;
    cin >> a >> n >> m;
    
    int ans = 0;
    for(int i = 1; pow(i, n) <= m; ++i) {
        int num = pow(i, n), y = i - a;
        int s = 0;
        while(num) {
            s += num % 10;
            num /= 10;
        }
        if(y == s) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

int calc(int a, vector<int>& ls) {
	int ans = (ls.size() - 1 ) * 10;
	int total = 0;
	for(int l : ls) {
		total += l;
	}
	return (ls.size() - 1 ) * 10 + abs(total - a);

}

int main() {
	int n,a,b,c;
	cin >> n >> a >> b >> c;
	vector<int> l(n);

	rep(i, n) {
		cin >> l[i];
	}
	
	int size = 1 << (n * 2);
	int min_v = 1e9;
	rep(i, size) {
		vector<int> ia;
		vector<int> ib;
		vector<int> ic;

		int bit = i;
		int cur = 0;

		while(bit > 0) {
			int b = bit & 3;

			if (b == 3) {
				ia.push_back(l[cur]);
			} else if (b == 2) {
				ib.push_back(l[cur]);
			} else if (b == 1) {
				ic.push_back(l[cur]);
			}
			cur++;
			bit /= 4;
		}

		if (ia.size() == 0 || ib.size() == 0 || ic.size() == 0) {
			continue;
		}
		/*
		cout << "****" << endl;
		for(int ta: ia) {
			cout << ta << " ";
		}
		cout << endl;
		for(int tb: ib) {
			cout << tb << " ";
		}
		cout << endl;

		for(int tc: ic) {
			cout << tc << " ";
		}
		cout << endl;
		*/

		min_v = min(min_v, calc(a, ia) + calc(b, ib) + calc(c, ic));
	}
	cout << min_v << endl;

	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int i,n,k,a[105],b[105],c[105],s,j,x,m[105];
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i<=k;i++){
		scanf("%d",&b[i]);
		for(j=1;j<=b[i];j++){
			scanf("%d",&a[j]);
			for(x=1;x<=n;x++){
				c[x]=x;
				if(c[x]==a[j]) m[x]++;
			}
		}
	}
	for(x=1;x<=n;x++){
		if(m[x]==0) s=s+1;
	}
	printf("%d",s);
	return 0; 
} 

Measured memory_bytes: 3816
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  let count = 0;
  let max_count = 0;
  let ans = 1;
  for (var n = 1; n <= N; n++) {
    let work_n = n;
    count = 0;
    while (work_n % 2 === 0 && work_n > 0) {
      work_n = work_n / 2;
      count++;
    }
    if (max_count < count) {
      ans = n;
      max_count = count;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

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 vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const int MAX_N = 1000010;
int n;
bool vis[MAX_N];
int cnt = 0;

void dfs(int k) {
    vis[k] = 1;
    cnt++;
    if(k == 0) return;
    if(!vis[(10*k+7)%n]) dfs((10*k+7)%n);
}

int main() { FAST
    cin >> n;
    dfs(7%n);
    cout << (vis[0] ? cnt : -1) << "\n";
}



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

int main(){
	int n,m;
	cin >> n >> m;
	int two = 1;
	rep(i,m){
		two *= 2;
	}
	int ans = (m*1900+(n-m)*100)*two;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
def counting(tar_word,tar_list):
	count = 0
	for i in range(len(tar_list)):
		if tar_word == tar_list[i]:
			count += 1
	return count

# 青いカード(1円加算)
N = int(input())
s = list()
for i in range(N):
	s.append(str(input()))
# 赤いカード(1円損失)
M = int(input())
t = list()
for i in range(M):
	t.append(str(input()))
target = s+t
target = set(target)
target = list(target)

ans = list()
for tar in target:
	count = 0
	count += counting(tar,s)
	count -= counting(tar,t)
	ans.append(count)

print(max(ans)) if max(ans) >= 0 else print(0)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int a[12] = {1,3,5,7,8,10,12,4,6,9,11,2};
	int x,y,i,b,c;
	scanf("%d %d",&x,&y);
	for(i = 0;i < 12;i++)
	{
		if(x == a[i])
			b = i;
		if(y == a[i])
			c = i;
	}
	if((b >= 0 && b <= 6) && (c >= 0 && c <= 6))
		printf("Yes\n");
	else if((b >= 7 && b <= 10) && (c >= 7 && c <= 10))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


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

int main()
{	
	string s, t;
	map<string, int> p;

	while (cin >> s) {
		if (p.find(s) != p.end())
			p[s]++;
		else
			p[s] = 1;

		if (s.size() > t.size())
			t = s;
	}

	int m = 0;

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		m = max(m, itr->second);

	for (map<string, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		if (itr->second == m)
			cout << itr->first << " " << t << endl;

	return 0;
}



Measured memory_bytes: 3148
import math
if __name__ == '__main__':
    a, b, h, m = map(int, input().split())
    h_y = a * math.sin(math.pi* (0.5+(-2)*(h*3600+m*60)/43200))
    h_x = a * math.cos(math.pi* (0.5+(-2)*(h*3600+m*60)/43200))
    m_y = b * math.sin(math.pi* (0.5+(-2)*m/60))
    m_x = b * math.cos(math.pi* (0.5+(-2)*m/60))
    print(math.sqrt((h_y-m_y)**2 + (h_x-m_x)**2))

Measured memory_bytes: 9388
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin(), K = Cin();
    vector<LLONG> Hs(N);
    for (auto &i : Hs) i = Cin();
    if (K >= N)
    {
        cout << 0 << endl;
    }
    else
    {
        sort(Hs.rbegin(), Hs.rend());
        LLONG ans = 0;
        for (int i = K; i < N; ++i) ans += Hs[i];
        cout << ans << endl;
    }
}


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

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

    int n;
    cin >> n;
    bool flag=false;
    rep(i,1,10) rep(j,1,10){
    	if(i*j==n) flag=true; 
    }
    if(flag)cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int i, j;
    int p[8], q[8];
    for(i = 0; i < n; i++){scanf("%d", &p[i]);}
    for(i = 0; i < n; i++){scanf("%d", &q[i]);}
    for(i = 0; i < n; i++){p[i]--; q[i]--;}
    
    int a_temp[8];

    for(i = 0; i < n; i++){
        a_temp[i] = i;
    }
    int cnt = 1;
    int a, b;
    int flag_a = 0, flag_b = 0;
    int flag;
    int go_next;
    while(1){
        for(i = 0; i < n; i++){
            if(a_temp[i] != p[i]){
                break;
            }
            if(i == n - 1){
                a = cnt;
                flag_a = 1;
            }
        }

        for(i = 0; i < n; i++){
            if(a_temp[i] != q[i]){
                break;
            }
            if(i == n - 1){
                b = cnt;
                flag_b = 1;
            }
        }
        
        if(flag_a == 1 && flag_b == 1){
            break;
        }

        go_next = 0;
        //a_tempを1つ進める処理を書く
        do{
            a_temp[n - 1] += 1;
            for(i = 1; i < n; i++){
                if(a_temp[n - i] == n){
                    a_temp[n - i] = 0;
                    a_temp[n - i - 1]++;
                }
            }
            for(i = 0; i < n; i++){
                flag = 0;
                for(j = 0; j < n; j++){
                    if(a_temp[j] == i){
                        flag = 1;
                        break;
                    }
                }
                if(flag == 0){
                    break;
                }
                if(i == n - 1){
                    go_next = 1;
                }
            }
        }while(go_next == 0);
        cnt++;
    }
    printf("%d\n", a > b ? a - b : b - a);
    
    

}

Measured memory_bytes: 1728
N=int(input())
L=[0]+list(map(int, input().split()))+[10**9+7]
ct=0
ans=0
for i in range(1,N+2):
  if L[i-1]>=L[i]:
    ct+=1
  else:
    ans=max(ans,ct)
    ct=0
print(ans)

Measured memory_bytes: 87168
# -*- coding: utf-8 -*-
"""
Created on Sat Jan  5 22:46:09 2019
DPL3A
@author: maezawa
"""
h, w = list(map(int,input().split()))
c = []
for _ in range(h):
    ci = list(map(int, input().split()))
    c.append(ci)

sq = [[0]*w for _ in range(h)]
for j in range(w):
    if c[0][j] == 1:
        sq[0][j] = 0
    else:
        sq[0][j] = 1
        
for i in range(h):
    if c[i][0] == 1:
        sq[i][0] = 0
    else:
        sq[i][0] = 1
        
if sq[0][0] == 1:
    maxsq = 1
else:
    maxsq = 0  
        
for i in range(1, h):
    for j in range(1, w):
        if c[i][j] == 1:
            sq[i][j] = 0
        else:
            thissq = min([sq[i-1][j], sq[i-1][j-1], sq[i][j-1]]) + 1
            sq[i][j] = thissq

for i in range(h):
    for j in range(w):
        maxsq = max([maxsq, sq[i][j]])
    
print(maxsq**2)
            
                       


Measured memory_bytes: 55200
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

import math

n = ni()
a = nin(5)

print(math.ceil(n / min(a)) + 4)

Measured memory_bytes: 3064
<?php
$N = intval(fgets(STDIN));
for($i = 1; $i <= $N;$i++){
    $map[$i] = 0;
}
for($i = 1; $i <= $N; $i++){
    $I = $i;
    for($j = 2; $j <= $N; $j++){
        if($I%$j == 0){
            $map[$j]++;
            $I/=$j;
            $j--;
        }
    }
}
$c75=$c25=$c15=$c5=$c3=0;
foreach($map as $num => $count){
    if($count >= 75-1)$c75++;
    if($count >= 25-1)$c25++;
    if($count >= 15-1)$c15++;
    if($count >= 5-1)$c5++;
    if($count >= 3-1)$c3++;
}
echo $c75 + $c25 * ($c3-1) + $c15 * ($c5-1) + $c5*($c5-1)/2*($c3-2);

Measured memory_bytes: 4856
import itertools

D, G = map(int, input().split())
PC = [list(map(int,input().split())) for i in range(D)]

## i種類の問題を解いた時、(i-1)種類は完答してボーナス点をもらっている
## 完答する or それ以外 で分離することができて、状態数2**Dの全探索
## 完答するもので目標点を達成できていればOK.
## 完答するものだけで達成できていなければ、残っているうちで一番高い問題を解く

complete = [100*(i+1)*PC[i][0]+PC[i][1] for i in range(D)]

cost = 1000000000 ## Inf
for state in itertools.product(range(2), repeat=D): ## K**N 通りの全探索
  score = 0
  pre_cost = 0
  not_complete = []
  for i in range(D):
    if state[i] == 0:
      not_complete.append(i)
    else:
      score += 100*(i+1)*PC[i][0] + PC[i][1]
      pre_cost += PC[i][0]
  if score < G:
    idx = max(not_complete)
    if (G - score) > 100*(idx+1)*(PC[idx][0]-1):
      continue
    else:
      n_not_complete = ((G - score) + 100*(idx+1)-1) // (100*(idx+1))
      pre_cost += n_not_complete
  cost = min(cost, pre_cost)
  
print(cost)

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

enum Process {
    pushBack = 0, randomAccess = 1, popBack = 2,
};

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

    vector<long int> vli;
    int loops, query, num;
    cin >> loops;

    for (int i = 0; i < loops; i++) {
        cin >> query;
        switch (query) {
            case pushBack:
                cin >> num;
                vli.push_back(num);
                break;
            case randomAccess:
                cin >> num;
                cout << vli.at(num) << endl;
                break;
                
            case popBack:
                vli.pop_back();
                break;
        }
    }
}


Measured memory_bytes: 5048
#include<stdio.h>

int main()
{
    char s[6];
    scanf("%s",s);
    int i;
    for(i=0;s[i]!='\0';i++)
    {
        if(s[2]==s[3] && s[4]==s[5])
        {
            printf("Yes");
            break;
        }
        else
        {
            printf("No");
            break;
        }


    }
}


Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
    };
    let ans = if n == 1 && m == 1 {
        1
    } else if n == 1 && m > 1 {
        m - 2
    } else if n > 1 && m == 1 {
        n - 2
    } else if n > 1 && m > 1 {
        n * m - (n * 2 + (m - 2) * 2)
    } else {
        unreachable!();
    };
    println!("{}", ans);
}


Measured memory_bytes: 2036
fn main() {
    let n = read::<usize>();
    let mut v: Vec<usize> = Vec::new();
    let mut i_ma = 0;
    let mut ma = 0;
    for i in 0..n {
        let a = read::<usize>();
        if ma < a {
            ma = a;
            i_ma = i;
        }
        v.push(a);
    }

    v.sort();
    for i in 0..n {
        if i == i_ma {
            println!("{}", v[v.len()-2]);
        } else {
            println!("{}", v[v.len()-1]);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


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

int main(){
    
    int N, A[100];
    
    cin >> N;
    for ( int i = 0; i < N; i++) cin >> A[i];
    
    int minj, a, count = 0;
    for ( int i = 0; i < N-1; i++){
        minj = i;
        for ( int j = i; j < N; j++){
            if ( A[j] < A[minj] ) minj = j;
        }
        if ( i != minj) count++;
        a = A[i];
        A[i] = A[minj];
        A[minj] = a;
        
    }
    for ( int i = 0; i < N; i++){
        if ( i == N-1) {
            cout << A[i] << endl;
            break;
        }    
        cout << A[i] << " " ;
    }
    cout << count <<endl;

}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
int main(){
  int k,ans=0;
  cin>>k;
  vector<int>a(3,1);
  for(int i=0;i<k;i++){
    for(int j=0;j<k;j++){
      for(int l=0;l<k;l++){
        ans+=boost::math::gcd(a[0],a[1],a[2]);
        a[0]++;
      }
      a[0]=1;
      a[1]++;
    }
    a[1]=1;
    a[2]++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll h,w,n;
  cin >> h >> w >> n;
  mat maze(h,vec(w));
  for(ll i=0;i<n;i++) {
    ll H,W,V;
    cin >> H >> W >> V;
    H--,W--;
    maze[H][W]=V;
  }
  vector<mat> dp(h,mat(w,vec(4,0)));
  dp[0][0][1]=maze[0][0];
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(i==0&&j==0) continue; 
      for(ll k=0;k<4;k++) {
        if(i) {
          dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
          dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+maze[i][j]);
        }
        if(j) {
          dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
          if(k) {
            dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+maze[i][j]);
          }
        }
      }
    }
  }
  ll ans=0;
  for(ll k=0;k<4;k++) {
    ans=max(ans,dp[h-1][w-1][k]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 706076
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

string res;

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

    ll A, V, B, W,T;
    cin >> A >> V >> B >> W >> T;
    res = "NO";
    if (abs(B - A) <= (V-W) *T)
    {
        res = "YES";
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#define ll long long int
using namespace std;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

int main() {
	ll n, m;
	cin >> n >> m;
	ll left[n];
	ll right[m];
	ll spacer[n-1];
	ll spacec[m-1];
	for(int i = 0; i < n; i++) {
		cin >> left[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> right[i];
	}
	for(int i = 0; i < n-1; i++) {
		spacer[i] = left[i+1]-left[i];
	}
	for(int i = 0; i < m-1; i++) {
		spacec[i] = right[i+1]-right[i];
	}
	ll rtotal = 0;
	ll ctotal = 0;
	for(int i = 0; i < n-1; i++) {
		ll to_add = ((i+1) * (n-1 - i)) % 1000000007;
		to_add *= spacer[i];
		rtotal += to_add;
		rtotal %= 1000000007;
	}
	for(int i = 0; i < m-1; i++) {
		ll to_add = ((i+1) * (m- 1 - i)) % 1000000007;
		to_add *= spacec[i];
		ctotal += to_add;
		ctotal %= 1000000007;
	}
	cout << (rtotal * ctotal) % 1000000007 << endl;
}


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

const int N = 1e5 + 9;

int n, k, p, d[N], c, f[N];
vector<int>V[N];

void Dfs (int x) {
	d[x] = 1;
	for (auto v : V[x]) {
		Dfs(v);
		if (d[v] >= d[x]) d[x] = d[v] + 1;
	}
	if (f[x] > 1 && d[x] >= k)
	d[x] = 0, ++c;
}

int main () {
	scanf("%d%d%d", &n, &k, &p); f[1] = 1;
	for (int i = 2; i <= n; ++i) {
		scanf("%d", &f[i]);
		V[f[i]].emplace_back(i);
	}
	Dfs(1);
	if (p != 1) ++c;
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int, int>;
using Data = tuple<int, int, int, int, int>;
const int INF = 1 << 30;

// → ↑ ← ↓
const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    int y1, x1, y2, x2;
    cin >> y1 >> x1 >> y2 >> x2;
    y1--, x1--, y2--, x2--;
    vector<string> graph(H);
    for(auto &e : graph) cin >> e;

    vector<vector<Pair>> dist[4];
    for(int i = 0; i < 4; ++i) dist[i].assign(H, vector<Pair>(W, {INF, INF}));
    priority_queue<Data, vector<Data>, greater<Data>> que;
    for(int i = 0; i < 4; ++i) que.emplace(1, 0, y1, x1, i);

    auto push = [&](int cost, int n, int y, int x, int d) {
        if(n > K) cost++, n = 1;
        auto ndist = make_pair(cost, n);
        if(dist[d][y][x] > ndist) {
            dist[d][y][x] = ndist;
            que.emplace(cost, n, y, x, d);
        }
    };

    while(!que.empty()) {
        auto[cost, n, y, x, d] = que.top(); que.pop();
        for(int i = 0; i < 4; ++i) push(cost + 1, 0, y, x, i);
        int ny = y + dy[d], nx = x + dx[d];
        if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
        if(graph[ny][nx] == '@') continue;
        push(cost, n + 1, ny, nx, d);
    }

    int ans = INF;
    for(int i = 0; i < 4; ++i) ans = min(ans, dist[i][y2][x2].first);
    if(ans == INF) ans = -1;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 46308
N,Y = [int(i) for i in input().split()]
x,y,z = [0,0,0]
x+=Y//10000 ; Y2=Y%10000
y+=Y2//5000 ; Y3=Y2%5000
z+=Y3//1000
if x+y+z>N:
    print("-1 -1 -1")
elif x+y+z==N:
    print(*[x,y,z])
else:
    N-=(x+y+z)
    while x>=1 and 9<=N:
        x-=1 ; z+=10
        N-=9
    while x>=1 and 5<=N:
        x-=1 ; y+=1 ; z+=5
        N-=5
    while y>=1 and 4<=N:
        y-=1 ; z+=5
        N-=4    
    while x>=1 and 1<=N:
        x-=1 ; y+=2
        N-=1
    if N!=0:
        print("-1 -1 -1")
    else:
        print(*[x,y,z])

Measured memory_bytes: 3064