akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
const int maxn = 1e5 + 7;
int parent[maxn];
int sum[maxn];
int ans[maxn];
int n, m, k, x, y;

int find_parent(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find_parent(parent[x]);
}

void _union(int a,int b){
    a = find_parent(a), b = find_parent(b);
    if(a != b) parent[b] = a, sum[a] += sum[b];
}

void init(){
    for(int i=0;i<=n;i++)
        parent[i]=i, sum[i]=1;
}
int main() {

    cin >> n >> m >> k;
    init();
    while(m--){
        cin >> x >> y;
        ans[x]++, ans[y]++;
        _union(x, y);
    }
    while(k--){
        cin >> x >> y;
        if(find_parent(x) == find_parent(y)) ans[x]++, ans[y]++;
    }
    for(int i=1;i<=n;i++){
        cout << sum[find_parent(i)]-ans[i]-1 << " ";
    }
    cout << endl;
    return 0;
}


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



int main() {
	int N;

	cin >> N;
	vector<double>A(N);
	rep(0,N) {
		cin >> A[i];
		}
	double ans = 0;
	rep(0, N) {
		ans += 1 / A[i];
		
	}
		
	cout << 1/ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

typedef pair<int, char> P;

void exchange(vector<P> &v, int a, int b) {
    P temp = v[a];
    v[a] = v[b];
    v[b] = temp;
}

int partition(vector<P> &v, int p, int r) {
    int x = v[r].first;
    int i = p-1;
    for (int j = p; j < r; j++) {
        if (v[j].first <= x) {
            i++;
            exchange(v, i, j);
        }
    }
    exchange(v, i+1, r);
    return i+1;
}

bool stable(vector<P> v, vector<P> w) {
    REP(i,v.size()) {
        if (v[i].second != w[i].second) return false;
    }
    return true;
}

void quicksort(vector<P> &v, int p, int r) {
    if (p < r) {
        int q = partition(v, p, r);
        quicksort(v, p, q-1);
        quicksort(v, q+1, r);
    }
}

void merge3(vector<P> &arr, int left, int mid, int right) {
    int leftlen = mid - left;
    int rightlen = right - mid;
    vector<P> L, R;
    REP(i,leftlen) L.push_back(arr[left+i]);
    REP(i,rightlen) R.push_back(arr[mid+i]);
    L.push_back(make_pair(2e9, 'A'));
    R.push_back(make_pair(2e9, 'A'));
    int i = 0, j = 0;
    FOR(k, left, right) {
        if (L[i].first <= R[j].first) {
            arr[k] = L[i];
            i++;
        }else {
            arr[k] = R[j];
            j++;
        }
    }
}

void mergesort3(vector<P> &arr, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergesort3(arr, left, mid);
        mergesort3(arr, mid, right);
        merge3(arr, left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    vector<P> v;
    REP(i,n) {
        char s;
        int j;
        cin >> s >> j;
        v.push_back(make_pair(j, s));
    }
    vector<P> w(v);
    mergesort3(w, 0, n);
    quicksort(v, 0, n-1);
    
    if (stable(v, w)) {
        cout << "Stable" << endl;
    }else {
        cout << "Not stable" << endl;
    }
    
    for(P p: v) {
        cout << p.second << " " << p.first << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5904
#include <iostream>
#include <vector>
#include <string>
using namespace std;
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; }

// MOD
const int MOD = 1000000007;

// 入力
int H, W;
vector<string> a;

// DP テーブル
int dp[1100][1100] = {0};

// add
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main() {
    cin >> H >> W;
    a.resize(H);
    for (int i = 0; i < H; ++i) cin >> a[i];
    
    // DP 初期化: すでに配列全体が 0 に初期化されているので OK
    
    // DP 初期条件
    dp[0][0] = 1;
    
    // DP ループ
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i+1 < H && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if (j+1 < W && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5632
import sys

n = int(input())
a_L = list(map(int,input().split()))
counter = 0


while True:
    for val in a_L:
        if val % 2 != 0:
            print(counter)
            sys.exit(0)
    counter +=1
    a_L = [i/2 for i in a_L]

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

using namespace std;

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

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	int ans = inf;
	rep(i, s.size() - 2){
		int x = 0;
		rep(j, 3) x *= 10, x += s[i + j] - '0';
		ans = min(ans, abs(753 - x));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
bool abc(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	return a.second>b.second && a.first<b.first;
	//else 0;
}
map<ll,ll>p;
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		p[x]++;
	}
	ll cnt=0;
	for(auto xx:p)
	{
		if(xx.ff>xx.ss) cnt+=xx.ss;
		else if(xx.ss>xx.ff) cnt+=(xx.ss-xx.ff);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 9588
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int p[m],y[m];
  vector<int>vec[n+1];
  map<int,int>mp;
  rep(i,m) {
    cin>>p[i]>>y[i];
    mp[y[i]]=p[i];
    vec[p[i]].push_back(y[i]);
  }
  rep(i,n) {
    sort(vec[i+1]);
  }
  rep(i,m) {
    printf("%06Ld",mp[y[i]]);
    printf("%06Ld\n",low(all(vec[p[i]]),y[i])-vec[p[i]].begin()+1);
  }
}


Measured memory_bytes: 14720
int main(void){
  int n,i,minNo;
  float h,w,min,diff;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    min = 999999;
    while(n--){
      scanf("%d%f%f",&i,&h,&w);
      h /= 100.0;
      diff = 22.0 - w / (h*h);
      if(diff<0) diff *= -1;
      if(min>diff || min==diff && minNo>i){
	min = diff;
	minNo = i;
      }
    }
    printf("%d\n",minNo);
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    char S[10001],S2[10001]={};
    int N,l;
    scanf("%d",&N);
    scanf("%s",S);
    l = strlen(S);
    for(int i = 0; i < l; i++)
    {
        S2[i] = (S[i]+N>90)? S[i]+N-26:S[i]+N;
    }
    printf("%s\n",S2);
}


Measured memory_bytes: 256
n = int(input())

results = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(n):
    result = input()
    results[result] += 1

print("AC x {}".format(results["AC"]))
print("WA x {}".format(results["WA"]))
print("TLE x {}".format(results["TLE"]))
print("RE x {}".format(results["RE"]))


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

int main() {
	int n;

	while(cin >> n, n) {
		int table[16][16];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				cin >> table[i][j];
			}
		}

		for(int i = 0; i < n; i++) {
			table[i][n] = 0;
			for(int j = 0; j < n; j++) {
				table[i][n] += table[i][j];
			}
		}
		for(int i = 0; i < n + 1; i++) {
			table[n][i] = 0;
			for(int j = 0; j < n; j++) {
				table[n][i] += table[j][i];
			}
		}

		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < n + 1; j++) {
				printf("%5d", table[i][j]);
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1192
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	one, two, three := 0, 0, 0
	for i := 0; i < N; i++ {
		a := sc.nextInt()
		if a == 1 {
			one++
		} else if a == 2 {
			two++
		} else {
			three++
		}
	}
	var dp [310][310][310]float64
	var flag [310][310][310]bool
	var rec func(i, j, k int) float64
	rec = func(i, j, k int) float64 {
		if flag[i][j][k] {
			return dp[i][j][k]
		}
		flag[i][j][k] = true
		if i == 0 && j == 0 && k == 0 {
			return 0.0
		}
		res := 0.0
		if i > 0 {
			res += rec(i-1, j, k) * float64(i)
		}
		if j > 0 {
			res += rec(i+1, j-1, k) * float64(j)
		}
		if k > 0 {
			res += rec(i, j+1, k-1) * float64(k)
		}
		res += float64(N)
		res *= 1.0 / float64(i+j+k)
		dp[i][j][k] = res
		return res
	}

	fmt.Fprintln(wtr, rec(one, two, three))
	wtr.Flush()
}


Measured memory_bytes: 266880
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

int main(void)
{
	int m;

	cin >> m;

	cout << 48 - m << '\n';
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	unsigned int a[105] = {0};
	int res = 0;
	for (int i = 1; i <= N; ++i){
		cin >> a[i];
		if (i%2 && a[i]%2)
			res++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if(abs(a-c) <=d)
cout<<"Yes"<<endl;
else if(abs(a-b)<=d && abs(b-c)<=d)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0061
"""
import sys


def calc_rank(data):
    scores = {}                 #  ?????????key, ???????????????id???????????????value??¨?????????????????????
    for id, point in data:
        if point in scores:
            scores[point].append(id)
        else:
            scores[point] = [id]

    ranks = [k for k in scores.keys()] #  ranks.index(point) ???????????????????????????????????????????????????
    ranks.sort(reverse=True)
    ranks.insert(0, -1)          #  index???1?????????????????????????????????????????????????????\
    return scores, ranks


def check_rank(scores, ranks, id):
    for k, v in scores.items():
        if id in v:
            return ranks.index(k)


def main(args):
    data = []
    id, point = [int(x) for x in input().strip().split(',')]
    while id != 0 or point != 0:
        data.append((id, point))
        id, point = [int(x) for x in input().strip().split(',')]
    scores, ranks = calc_rank(data)

    for line in sys.stdin:
        id = int(line.strip())
        result = check_rank(scores, ranks, id)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7652
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
t = [list(map(int, input().split()))+[1] for _ in range(n)]

ss = sorted(s, key=lambda x:x[1], reverse=True)
tt = sorted(t, key=lambda x:x[0])
cnt = 0

for i in range(n):
  for j in range(n):
    if ss[i][0] < tt[j][0] and ss[i][1] < tt[j][1] and tt[j][2] == 1:
      cnt += 1
      tt[j][2] -= 1
      break
    
print(cnt)

Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();
    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    if b <= a {
        return "delicious".to_string();
    }

    if b <= a + x {
        return "safe".to_string();
    }

    "dangerous".to_string()
}


Measured memory_bytes: 2080
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int b;
  int mi=1000;
  rep(i,s.size()-2) {
    int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    b = abs(a-753);
    mi = min(mi,b);
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
graph = [[] for _ in range(N)]
ans = {}
tmp = []
flag = [False] * N  # そのノードに到達済みか判定する
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)
    tmp.append((a, b))  # 最後に出力する時に使う
    ans[(a, b)] = -1
q = deque([0])  # 開始のノード
colors = [-1]*N
now_color = 0
while len(q):
    v = q.pop()
    flag[v] = True
    color = 1
    # vからeへの辺の色を塗る
    for e in graph[v]:

        if flag[e]:
            continue
        q.append(e)
        if color == colors[v]:
            color += 1
        ans[(v, e)] = color
        colors[e] = color
        color += 1
print(max(colors))
for a, b in tmp:
    print(ans[(a, b)])


Measured memory_bytes: 44160
#include <stdio.h>
#define MAX 2000000000
typedef struct{
  int x;
  char c;
}card;
card M[100000];
int Partition(int, int);
void Quicksort(int, int);
void merge(int, int, int,card[]);
void mergeSort(int, int, card[]);
int main(){
  int i, p, n;
  char c;
  card N[100000];
  scanf("%d%c", &n, &c);
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &N[i].c, &N[i].x, &c);
    M[i] = N[i];
}
  p = 0;
  mergeSort(0, n, N);
  Quicksort(0, n-1);
  for(i = 0; i < n; i++){
    if(N[i].c != M[i].c){
      printf("Not stable\n");
break; }
    if(i == (n - 1))
      printf("Stable\n");
}
  for(i = 0; i < n; i++){
    printf("%c %d\n", M[i].c, M[i].x);
    }
return 0; }
int Partition(int e, int s){
  card tmp;
  int i, j, x;
  x = M[s].x;
i = e - 1;
  for(j = e; j < s; j++){
    if (M[j].x <= x){
      i++;
      tmp = M[i];
      M[i] = M[j];
      M[j] = tmp;
} }
  tmp = M[i + 1];
  M[i + 1] = M[s];
  M[s] = tmp;
	  return (i + 1);
}
void Quicksort(int e, int s){
  int w;
  if(e < s){
     w = Partition(e, s);
     Quicksort(e, w-1);
     Quicksort(w+1, s);
} }
void merge(int left, int mid, int right, card K[]){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  card L[100001], R[100001];
  for(i = 0; i < n1; i++){
    L[i] = K[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = K[mid+i];
  }
  L[n1].x = MAX;
  R[n2].x = MAX;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i].x <= R[j].x)
      K[k]=L[i++];
    else
      K[k]=R[j++];
} }
void mergeSort(int left, int right, card K[]){
  if((left + 1) < right){
    int mid = (left + right) / 2;
    mergeSort(left, mid, K);
    mergeSort(mid, right, K);
    merge(left, mid, right, K);
} 
}

Measured memory_bytes: 2960
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(int argc, char const *argv[]) {
  int n,a,minv,maxv;
  bool flg=false;
  cin>>n;
  cin>>minv;
  REP(i,n-1){
    cin>>a;
    if(flg){
      maxv=max(maxv,a-minv);
    }
    else{
      maxv=a-minv;
      flg=true;
    }
    minv=min(minv,a);
  }
  cout << maxv << '\n';
  return 0;
}



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

int n;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= 9; i++)
    	if(n % i == 0 && n / i <= 9){
    		cout << "Yes\n";
    		return 0;
    	}
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long n, c[401][4], hush[401][4], mask[16], num[16], num2[16], H[4][4] = { {0,1,2,3},{1,2,3,0},{2,3,0,1},{3,0,1,2} }, po[4] = { 1,1000,1000000,1000000000 };
long long dp[17][16], P[16][16][5][16], Q[16][16][5];
long long I[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++)cin >> c[i][j];
		for (int j = 0; j < 4; j++) { long long T = 0; for (int k = 0; k < 4; k++)T += c[i][H[j][k]] * po[k]; hush[i][j] = T; }
	}
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			for (int k = 0; k < 5; k++) {
				for (int l = 0; l < 16; l++) {
					if ((i&l) == l && (j&l) == 0) {
						int B = 0; for (int m = 0; m < 4; m++)B += ((l / (1 << m)) % 2);
						if (B <= k) { P[i][j][k][Q[i][j][k]] = l; Q[i][j][k]++; }
					}
				}
			}
		}
	}
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int o = 0; o < 4; o++) {
				for (int l = 0; l < 16; l++) { mask[l] = 0; num[l] = 0; num2[l] = 0; for (int m = 0; m < 17; m++)dp[m][l] = 0; }
				vector<long long>A[4] = {
					{ c[i][0],c[i][3],c[j][(o + 2) % 4],c[j][(o + 1) % 4] },
					{ c[i][3],c[i][2],c[j][(o + 3) % 4],c[j][(o + 2) % 4] },
					{ c[i][2],c[i][1],c[j][(o + 0) % 4],c[j][(o + 3) % 4] },
					{ c[i][1],c[i][0],c[j][(o + 1) % 4],c[j][(o + 0) % 4] }
				};
				long long hush2[4] = { 0,0,0,0 };
				for (int k = 0; k < 4; k++) {
					for (int l = 0; l < 4; l++)hush2[k] += A[k][l] * po[l];
				}
				for (int k = i + 1; k < n; k++) {
					if (k == j)continue;
					int bit = 0, K = 0;
					for (int l = 0; l < 4; l++) {
						int J = 0;
						for (int m = 0; m < 4; m++) { if (hush[k][m] == hush2[l])J++; }
						if (J >= 1) { K = J; bit += (1 << l); }
					}
					mask[bit] += K; num[bit]++; num2[bit] = K;
				}
				for (int k = 0; k < 16; k++)num[k] = min(num[k], 4LL);
				dp[0][0] = 1;
				for (int k = 0; k < 16; k++) {
					for (int l = 0; l < 16; l++) {
						if (dp[k][l] == 0)continue;
						dp[k + 1][l] += dp[k][l];
						for (int m = 0; m < Q[k][l][num[k]]; m++) {
							long long J = mask[k]; for (int p = 1; p < I[P[k][l][num[k]][m]]; p++) { J *= (mask[k] - num2[k] * p); }
							dp[k + 1][l | P[k][l][num[k]][m]] += dp[k][l] * J;
						}
					}
				}
				ret += dp[16][15];
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
#define length(arr) sizeof arr / sizeof arr[0];
#define printArr(arr) REP(i, (sizeof arr / sizeof arr[0])){print(arr[i])}
#define printVec(vec) REP(i, vec.size()){print(vec[i])}

using namespace std;

//右隣の動物の種類を返す関数
//x:左隣の動物の種類, y: 着目する位置の動物の種類
//S: sheap, W: walf
//ans = 'o' or 'x'
char Next(char ans, char x, char y){
    if(x == 'S' && y == 'S'){
       if(ans == 'o'){
            return 'S';
       }else{
            return 'W';           
       }
    }else if(x == 'W' && y == 'S'){
       if(ans == 'o'){
            return 'W';
       }else{
            return 'S';           
       }
    }else if(x == 'S' && y == 'W'){
       if(ans == 'o'){
            return 'W';
       }else{
            return 'S';           
       }
    }else if(x == 'W' && y == 'W'){
       if(ans == 'o'){
            return 'S';
       }else{
            return 'W';           
       }
    }
    return 'x';
}

string func(string s, char first, char last, char checkF, char checkL){
    char next;
    string ans = "";
    ans.push_back(first); 
    REP(i, s.size()){
        next = Next(s[i], last, first);
        if(i != s.size()-1){
            ans.push_back(next);
        }
        last = first;
        first = next;
    }
    if(first == checkF && last == checkL){
        return ans;
    }else{
        return "-1";
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string s;
    cin >> N >> s;
    
    string ans;
    ans = func(s, 'S', 'S', 'S', 'S');
    if(ans != "-1"){
        print(ans);
        return 0;
    }
    
    ans = func(s, 'S', 'W', 'S', 'W');
    if(ans != "-1"){
        print(ans);
        return 0;
    }
    
    ans = func(s, 'W', 'S', 'W', 'S');
    if(ans != "-1"){
        print(ans);
        return 0;
    }
    
    ans = func(s, 'W', 'W', 'W', 'W');
    if(ans != "-1"){
        print(ans);
        return 0;
    }
    
    print("-1");
    return 0;
}


Measured memory_bytes: 840
#include <stdio.h>
#include <string.h>
#define N 100000

int height(int);
int depth(int);

typedef struct{
  int parent;
  int left;
  int right;
} data;
data node[N];


int main(){
  int n,i,j,c,t,l,x,d[20],h[20],le,ri,sib[N],f1=0,f2=0,deg[N];
  char typ[N][20],a[] = "root",b[] = "leaf",e[] = "internal node";

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    node[i].parent = node[i].left = node[i].right = sib[i] = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d%d",&x,&le,&ri);
    node[x].left = le;
    node[x].right = ri;
    if(le != -1){
      node[le].parent = x;
      f1++;
    }
    if(ri != -1){
      node[ri].parent = x;
      f2++;
    }
    if(le != -1 && ri != -1){
      sib[ri] = le;
      sib[le] = ri;
    }
    deg[x] = f1 + f2;
    f1 = f2 = 0;
  }
  for(i = 0;i < n;i++){

    if(node[i].parent == -1) strcpy(typ[i], a);
    else if(node[i].left == -1 && node[i].right == -1) strcpy(typ[i], b);
    else strcpy(typ[i], e);
    h[i] = height(i);
    d[i] = depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",i,node[i].parent,sib[i],deg[i],d[i],h[i],typ[i]);
  }
  return 0;
}

int depth(int u){
  int d=0;
  while(node[u].parent != -1){
    u = node[u].parent;
    d++;
  }
  return d;
}

int height(int u){
  int h1 = 0,h2 = 0;
  if(node[u].left != -1) h1 = height(node[u].left) + 1;
  if(node[u].right != -1) h2 = height(node[u].right) + 1;
  if(h1 > h2) return h1;
  else return h2;
}



Measured memory_bytes: 2128
N = int(input())
num = input()
list = num.split()
max = sum = min = int(list[0])
for x in range(N - 1):
    a = int(list[x + 1])
    if a > max: max = a
    elif a < min: min = a
    sum += a
print(min, max, sum)
    



Measured memory_bytes: 6340
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 1e18
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll X,Y,H,n;cin>>n;vector<ll> x(n),y(n),h(n);
  rep(i,n){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0){
      X=x[i];
      Y=y[i];
      H=h[i];
    }
  }
  ll H_cand;
  bool flg=true;
  rep(i,101){
    rep(j,101){
      H_cand=H+abs(i-X)+abs(j-Y);
      flg=true;
      rep(k,n){
        if(h[k]!=max(H_cand-abs(i-x[k])-abs(j-y[k]),0ll)){
          flg=false;
          break;
        }
      }
      if(flg){
        cout<<i<<" "<<j<<" "<<H_cand<<endl;
        return 0;
      }
    }
  }  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, P = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
even = 0
for i in range(N):
  if a[i] % 2: odd += 1
  else: even += 1
if P:
  print(int((pow(2, odd - 1) * pow(2, even) * (odd > 0))))
else:
  print(max(1, pow(2, odd - 1)) * pow(2, even))

Measured memory_bytes: 38256
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

[<EntryPoint>]
let main _ =
    let _ = stdin.ReadLine()
    let ans =
        stdin.ReadLine().Split(' ')
        |> Array.map int
        |> Array.sort
        |> Array.mapi (fun i x -> 
            if i % 2 = 0 then x else -x
            )
        |> Array.sum
        |> abs
    printfn "%d" ans
    0

Measured memory_bytes: 14812
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,k,n;
    scanf("%d",&n);
    if(n/100==9)
        n=n%100+100;
    else
    if(n/100==1)
        n=n%100+900;
    if((n/10)%10==9)
        n=n/100*100+10+n%10;
    else
    if((n/10)%10==1)
        n=n/100*100+90+n%10;
    if(n%10==1)
        n=n-1+9;
    else
    if(n%10==9)
        n=n-9+1;
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

char M[13][13];
bool p[13][13];

int main() {

    ios::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> M[i][j];
        }
    }

    if(M[1][1] == '#')
        p[1][1] = 1;

    for(int I = 1; I <= n; I++) {
        for(int J = 1; J <= m; J++) {
            if(I == 1 && J == 1)
                continue;
            if(M[I][J] == '#')
                p[I][J] = p[I-1][J]|p[I][J-1];
        }
    }

    for(int I = 1; I <= n; I++) {
        for(int J = 1; J <= m; J++) {
            if(M[I][J] == '#' && p[I][J] == false) {
                cout << "Impossible";
                return 0;
            }
        }
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(M[i][j] != '#')
                continue;
            if(M[i][j+1] == '#' && M[i+1][j] == '#') {
                cout << "Impossible";
                return 0;
            }
        }
    }

    cout << "Possible";

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,A,B,mxL,miR,ans,b[maxn];
struct chj{
	int x,y;
	bool operator <(const chj b)const{return x>b.x;}
}a[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
int main(){
	n=read();miR=1<<30;
	for (int i=1;i<=n;i++){
		a[i]=(chj){read(),read()};
		if (a[i].x>mxL) mxL=a[i].x,A=i;
		if (a[i].y<miR) miR=a[i].y,B=i;
	}
	for (int i=1;i<=n;i++) ans=max(ans,a[i].y-a[i].x+1+max(miR-mxL+1,0));
	for (int i=1;i<=n;i++) a[i].x=max(miR-a[i].x+1,0),a[i].y=max(a[i].y-mxL+1,0);
	sort(a+1,a+n+1);
	b[n]=a[n].y;for (int i=n-1;i;i--) b[i]=min(b[i+1],a[i].y);
	for (int i=1;i<n;i++) ans=max(ans,a[i].x+b[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
//#define int long long int
//Binary_Search->dp->greedy
bool is(string s){
	int n=s.length();
	int l=0,r=n-1;
	while(l<=r){
		if(s[l]!=s[r]) return false;
		l++;r--;
	}
	return true;
}
void solve(){
	double n;
	cin>>n;
	double l=(n/3);
	double ans=(l*l*l);
	cout<<setprecision(10)<<fixed<<ans<<endl;
 
 
 
 
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

constexpr long long int MOD = 1000000007;
long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp / 2) * power(base, exp % 2) % MOD;
	}
}
long long int power_set_size(int size) {
	static std::vector<long long int> memo(100001, -1);
	if (memo[size] >= 0) return memo[size];
	return memo[size] = power(2, size);
}
long long int calc(const std::vector<int>& values, int size = 20) {
	if (size == 0) return  (power_set_size(values.size()) + MOD - 1) % MOD;
	if (values.empty()) return 0;
	long long int sum{ 0 };
	std::vector<int> sub;
	for (auto i = 0; i < size; ++i) {
		sub.clear();
		for (const auto v : values) if ((v & (1 << i)) != 0) sub.push_back(v);
		sum += calc(sub, i);
	}
	return ((power_set_size(values.size()) + MOD - 1 - sum) % MOD + MOD) % MOD;
}
int count_bit(int n) {
	return (n == 0) ? 0 : (n & 1) + count_bit(n >> 1);
}
int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& a : values) std::cin >> a;
	std::vector<long long int> pattern(1 << 20, 0);
	for (const auto a : values) pattern[a]++;
	for (auto i = 0; i < 20; ++i) {
		for (auto j = 0; j < pattern.size(); ++j) 
			if ((j & (1 << i)) == 0) {
				pattern[j] += pattern[j | (1 << i)];
				pattern[j] %= MOD;
			}
	}
	long long int result = 0;
	for (auto i = 0; i < pattern.size(); ++i) {
		if (count_bit(i) % 2 == 0) {
			result += power(2, pattern[i]) - 1;
		}
		else {
			result -= power(2, pattern[i]) - 1;
		}
		result %= MOD;
	}
	std::cout << (result + MOD) % MOD << std::endl;
}


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

int main()
{
  long long n,a,b;cin>>n>>a>>b;
if ((b-a)%2 == 0) cout << (b-a)/2 << endl;
	else cout << min(a-1, n-b) + 1 + (b-a-1)/2 << endl;
}

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

struct node
{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
  while(x->left != NIL)
    x = x->left;
  
  return x;
}

Node treeMaximum(Node x)
{
  while(x->right != NIL)
    x = x->right;
  
  return x;
}

Node treeSearch(Node x, int k)
{
  if(x == NIL && k == x->key)
    return x;
  if(k < x->key)
    return treeSearch(x->left,k);
  else
    return treeSearch(x->right,k);

}

Node treeSuccessor(Node x)
{
  Node y;
  
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;
}

void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->right;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL)
    {
    y = x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }
  
  z->parent = y;
  
  if(y==NIL)
    root=z;
  else
    if(z->key < y->key)
      y->left=z;
    else
      y->right=z; 
}

void inorder(Node x)
{
  if(x != NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}
  
void preorder(Node x)
{
  if(x != NIL)
    {
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}


int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    {
    scanf("%s", com);
    if ( com[0] == 'f' )
      {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' )
      {
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' )
      {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' )
      {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25124
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

void solution(){
	int n; cin >> n;
	int a[n][n];
	for(int i = 0 ; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	// FORWARD DP solution
	// what matters is the combination of girls to be used for boys upto a certian position
	// state -- mask of girls used
	// position is not a part of state as it directly comes from the number of set bits in the current mask
	// for each mask, iterate over every girl and check if it is compatible 
	// with the ith boy, if yes, add num of ways from previous mask
	int N = (1 << n);
	vector<ll> dp(N,0LL);
	dp[0] = 1LL;
	for(int mask = 0; mask < N; mask++){
		int i = bitcnt(mask);
		for(int j = 0; j < n; j++){
			if(a[i][j] && !(mask & (1 << j))){
				int next = mask ^ (1 << j);
				dp[next] += dp[mask];
				dp[next] %= mod;
			}
		}
	}
	cout << dp.back() << endl;

}	


int main(){ 

	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}


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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

signed main(){
	IOS
	int a= 0;
	string s1,s2;cin>>s1>>s2;
	forn(i,sz(s1)){
		if(s1[i]^s2[i])
			a++;
	}
	cout<<a;
}

Measured memory_bytes: 3752
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	n%=10;
	if(n==3) cout<<"bon";
	else if(n==0 || n==1 || n==6 || n==8) cout<<"pon";
	else cout<<"hon";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3596
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string &fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);
const int N = 4444, P = 1e9 + 7;

int n, m, k;
LL f[N][N];

int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n >> m >> k;

  LL ans = 0;
  for (int i = 0; i <= n + m; i++) f[i][0] = 1;
  LL msum = m % (k - 1), nsum = (n - 1) % (k - 1);
  for (int i = 1; i <= n + m; i++) {
    LL pre = 1;
    for (int sum = 1; sum <= m; sum++) {
      if (sum > k - 1) {
        pre -= f[i - 1][sum - k];
        pre %= P;
      }
      pre += f[i - 1][sum];
      pre %= P;
      f[i][sum] = pre;

      LL rest = (k - 1) * i - sum;
      if (sum % (k - 1) == msum && rest % (k - 1) == nsum && rest >= 0 &&
          rest < n) {
        ans += f[i][sum] - f[i - 1][sum];  // erase 0
        // cerr << i << ' ' << sum << ' ' << f[i][sum] << endl;
        ans %= P;
      }
    }
  }

  cout << (ans + P) % P << endl;
  return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(long &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   std::vector<std::pair<long, long>> compress(const LI &xs) {
      std::vector<std::pair<long, long>> res;
      long n = xs.size();
      for(long i = 0; i < n; ++i) {
         if( i == 0 or xs[i-1] != xs[i] ) {
            res.push_back(std::make_pair(xs[i], 1));
         }
         else {
            res.back().second += 1;
         }
      }
      return res;
   }
   void solve() {
      long n; scan(n);
      LI xs(n); scan(xs);
      std::sort(xs.begin(), xs.end());
      auto ys = compress(xs);
      LI zs = {-1, 0};
      for(auto y : ys) {
         if( y.second >= 2 ) zs.push_back(y.first);
         if( y.second >= 4 ) zs.push_back(y.first);
      }
      std::sort(zs.begin(), zs.end());
      std::reverse(zs.begin(), zs.end());
      long res = zs[0] * zs[1];
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans=0;
	for (int i = 0; i < 4; ++i)
	{
		if (s[i]=='+')
		{
			++ans;
		}
		else
		{
			--ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256