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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int m, k;
	cin>>m>>k;
	int mask=1;
	REP(i, m){
		mask<<=1;
	}
	if(k>=mask){
		cout<<-1<<'\n';
		return 0;
	}
	if(m==0){
		cout<<0<<' '<<0<<'\n';
		return 0;
	}
	if(m==1){
		if(k==0){
			cout<<0<<' '<<0<<' '<<1<<' '<<1<<'\n';
		}
		else{
			cout<<-1<<'\n';
		}
		return 0;
	}
	REP(i, mask){
		if(i!=k){
			cout<<i<<' ';
		}
	}
	cout<<k<<' ';
	FORR(i, 0, mask){
		if(i!=k){
			cout<<i<<' ';
		}
	}
	cout<<k<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#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 u, int k){
  while(u!=NIL && k!=u->key){
 
  if(k < u->key) u=u->left;
 
  else u=u->right;
  }
  return u;
   
}
 
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->left;
  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;
  free(y);
}
 
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 u){
  if(u == NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
   
}
void preorder(Node u){
  if(u ==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->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: 25100
# C - Traveling Salesman around Lake
def main():
    K, N, *A = map(int, open(0).read().split())
    A.append(K + A[0])
    longest_dist = max(j - i for i, j in zip(A, A[1:]))
    ans = K - longest_dist
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25124
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, m, p[11];
vector<int> s[11];

bool lit(int j, int i){
	int cnt = 0;
	for(auto x: s[j]){
		if(i&(1<<(x - 1))) cnt ^= 1;
	}

	return (cnt == p[j]);
}

signed main()
{

 	FLASH

 	cin>>n>>m;
 	fr(i, 1, m + 1){
 		int k;
 		cin>>k;
 		fr(j, 1, k + 1){
 			int x;
 			cin>>x;
 			s[i].pb(x);
 		}
 	}

 	fr(i, 1, m + 1) cin>>p[i];

 	int ans = 0;
 	fr(i, 0, (1<<n)){

 		bool ok = 1;
 		fr(j, 1, m + 1){
 			if(!lit(j, i)) {ok = 0; break;}
 		}
 		ans += ok;
 	}
 	
 	cout<<ans;
}

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


int n;

#define MAX 38

char buf[MAX];

string s;

#define MOD 1007
#define MODD 1000000009
long long int ans = 0;
map<pair<long long int, long long int>, int> mp;
void solve(string t,bool mode=false){
	for (int i = 0; i < (1 << t.size()); i++){
		long long int f[] = { 0, 0 };
		for (int j = 0; j < t.size(); j++){
			if ((i >> j) & 1){
				f[(i >> j) & 1] *= MOD;
				f[(i >> j) & 1] += t[j];
				if (f[(i >> j) & 1] >= MODD)f[(i >> j) & 1] %= MODD;
			}
		}
		for (int j = t.size()-1; j >=0; j--){
			if (!((i >> j) & 1)){
				f[(i >> j) & 1] *= MOD;
				f[(i >> j) & 1] += t[j];
				if (f[(i >> j) & 1] >= MODD)f[(i >> j) & 1] %= MODD;
			}
		}
		if(mode==false)mp[make_pair(f[0], f[1])]++;
		else ans += mp[make_pair(f[1], f[0])];
	}

}
int main(){
	cin >> n;
	scanf("%s", buf);
	s = buf;
	solve(s.substr(0, n), false);
	solve(s.substr(n, n), true);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 33024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Keta[] keta = new Keta[m];
		for(int i = 0; i < m; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();
			keta[i] = new Keta(s, c);
		}
		sc.close();
		// Mが0の場合
		if(m == 0) {
			// Nが0または1の場合、最小値は0
			if(n == 0 || n == 1) System.out.println(0);
			else System.out.println((int)Math.pow(10, n - 1));
			return;
		}
		// 桁順に並び替える
		Arrays.sort(keta);
		// 桁の最小値
		int min = n > 1 ? (int)Math.pow(10, n - 1) : 0;
		// 条件値の取得
		int k = 0;
		for(int i = 1; i <= n; i++) {
			int check = 0;
			boolean checkF = false;
			for (int j = k; j < m; j++) {
				if(keta[j].S == i) {
					// N > 1の場合、桁1の条件に0が設定されていた場合-1
					if(n > 1 && i == 1 && keta[j].C == 0) {
						System.out.println(-1);
						return;
					}
					// 桁の配列に入力された条件値を取得
					int c = keta[j].C;
					// 条件に同じ桁に対する異なる値が指定されていた場合-1
					if(checkF && check != c) {
						System.out.println(-1);
						return;
					}
					// 1桁目の場合、移行
					if(i == 1) {
						if(n == 1) min = c;
						else min = (int)Math.pow(10, n - i) * c;
					} else {
						// 1桁目以外の場合、加算
						if(n == 1) min += c;
						else min += (int)Math.pow(10, n - i) * c;
					}
					check = c;
					checkF = true;
				} else {
					k = j;
					break;
				}
			}
		}
		System.out.println(min);
	}
}

class Keta implements Comparable<Keta>{
	public int S; 
	public int C;
	public Keta(int S, int C){
		this.S = S;
		this.C = C;
	}
	@Override
	public int compareTo(Keta o) {
		return this.S - o.S;
	}	
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

#define ll long long
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  int k, x;
  cin >> k >> x;
  if (500*k >= x) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	rep(i,n) {
		int a;
		cin >> a;
		q.push(a);
	}
	while (m > 0) {
		int a = q.top();
		q.pop();
		a /= 2;
		q.push(a);
		m--;
	}
	ll ans = 0;
	while (!q.empty()) ans += q.top(), q.pop();
	cout << ans << endl;
}

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

Measured memory_bytes: 3940
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	ans := 0
	prev := -1
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		if prev == a {
			ans++
			a = -1
		}
		prev = a
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i+100*j+50*k:
                ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    int n;
    cin >> n;
    ll origin[n];
    for(int i = 0; i < n;i++) cin >> origin[i];
    map<ll,ll> m;
    ll ans = 0;
    for(int i = n-1; i >= 0 ; i--){
        ll id = i + 1;
        ll plus = id + origin[i];
        auto ite = m.find(plus);
        if(ite != m.end()){
            ans += ite -> second;
        }
        ll temp = id - origin[i];
        ite = m.find(temp);
        if(ite != m.end()){
            ite -> second = ite -> second + 1;
        }
        else m.insert(make_pair(temp,1));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16656
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,r;cin>>n>>r;
  int res=r;
  if(n<10){
    res+=100*(10-n);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int check = 0;
    
    int[] P = new int[N];
    for(int i = 0; i < N; i++){
      P[i] = scanner.nextInt();
      
      if(P[i] != i+1){
        check++;
      }
    }
    
    //異なる箇所が なし もしくは 2か所 ならばYESとなる
    if(check == 0 || check == 2){
      System.out.println("YES");
    } else{
      System.out.println("NO");
    }
  }
}

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

using namespace std;

using ll = long long;

// https://kopricky.github.io/code/String/kmp.html
// res に文字列 text の中にある検索文字列 pattern のすべての一致箇所の開始位置が入る(0_indexed).
class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;

    KMP(const string& s) : pattern(s), plen((int)pattern.size()), table(plen+1) {
        table[0] = -1;
        int j = -1;
        for (int i = 0; i < plen; i++) {
            while (j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if (pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }

    void search(const string& text, vector<int>& res) {
        int head = 0, j = 0, tlen = (int)text.size();
        while (head + j < tlen){
            if (pattern[j] == text[head + j]) {
                if (++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    vector<ll> ans(n, 0);
    for (int i = 0; i < 30; ++i) {
        string as = "", bs = "", bs2 = "";
        for (int j = 0; j < n; ++j) {
            as += (a[j] >> i & 1 ? '1' : '0');
            bs += (b[j] >> i & 1 ? '1' : '0');
            bs2 += (b[j] >> i & 1 ? '0' : '1');
        }
        as += as;

        KMP kmp(bs);
        vector<int> ids;
        kmp.search(as, ids);
        vector<int> hoge(n, -1);
        for (int j : ids) {
            if (j >= n) break;
            if (ans[j] == -1) continue;
            hoge[j] = 0;
        }

        ids.clear();
        KMP kmp2(bs2);
        kmp2.search(as, ids);
        for (int j : ids) {
            if (j >= n) break;
            if (ans[j] == -1) continue;
            hoge[j] = 1;
        }

        for (int j = 0; j < n; ++j) {
            if (ans[j] == -1) continue;
            if (hoge[j] == -1) ans[j] = -1;
            else {
                ans[j] |= ((ll)hoge[j] << i);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        if (ans[i] != -1) {
            cout << i << " " << ans[i] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 10424
n = int(input().strip())
a = list(map(int, input().split()))
dic = {}
ans = 0
for i in range(len(a)):
    if dic.get(i - a[i]):
        ans += dic[i - a[i]]
    if dic.get(a[i] + i):
        dic[a[i] + i] += 1
    else:
        dic[a[i] + i] = 1
print(ans)


Measured memory_bytes: 111576
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(m);
    vector<string> s(m);
    vector<int> acmemo(n,0);
    vector<int> wamemo(n,0);
    for(ll i=0;i<m;i++){
        int pi;
        cin>>pi>>s[i];
        p[i]=pi-1;
    }
    int acnum=0;
    int wanum=0;
    for(int i=0;i<m;i++){
        if(0==acmemo[p[i]]){
            if("AC"==s[i]){
                acnum++;
                acmemo[p[i]]=1;
                wanum+=wamemo[p[i]];
            }else{
                wamemo[p[i]]++;
            }
        }
    }
    
    cout<<acnum<<" "<<wanum<<endl;
    
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define PI 3.141592
typedef long long ll;
using namespace std;
int main()
{
	ll N; cin >> N;
  	cout << N * (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int fir = 0;
	int sec = 0;
	sort(a.begin(),a.end());
	for (int i = n -1 ; i > -1; i--){
		if ( i % 2 == 0) {
			fir += a[i];
		}
		else {
			sec += a[i];
		}
	}
	cout << abs(sec - fir);

}

Measured memory_bytes: 3520
#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 INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
}


int solve(){
    input();
    ll ans;
    if(K==1){
        ans = pow(N,3);
        cout << ans << endl;
        return 0;
    }
    if(K%2==1){
        ans = pow(N/K,3);
        cout << ans << endl;
        return 0;
    }
    else{
        if((N%K)>=(K/2)){
            ans = pow(N/K,3) + pow((N/K+1),3);
            cout << ans << endl;
            return 0;
        }
        else{
            ans = pow(N/K,3) + pow(N/K,3);
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n,i;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		getline(cin,str);
		string::size_type pos;
		for(pos = str.find("Hoshino"); pos != string::npos; pos = str.find("Hoshino",pos+7)){
			str.replace(pos,7,"Hoshina");
		}
		cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int d;
        int w;

        cin >> d >> w;
        if (d == 0 && w == 0) {
            break;
        }

        vector<vector<int>> v;
        v.resize(static_cast<size_t>(d));
        for (auto i = 0; i < d; ++i) {
            v[i].resize(static_cast<size_t>(w));
            for (auto j = 0; j < w; ++j) {
                cin >> v[i][j];
            }
        }

        int maxCount{0};
        for (int i1 = 0; i1 < d - 2; ++i1) {
            for (int i2 = i1 + 2; i2 < d; ++i2) {
                for (int j1 = 0; j1 < w - 2; ++j1) {
                    for (int j2 = j1 + 2; j2 < w; ++j2) {
                        // find min of edge
                        int mine{999999999};
                        for (int x = i1; x <= i2; ++x) {
                            mine = min(mine, v[x][j1]);
                            mine = min(mine, v[x][j2]);
                        }
                        for (int y = j1; y <= j2; ++y) {
                            mine = min(mine, v[i1][y]);
                            mine = min(mine, v[i2][y]);
                        }
                        int count{0};
                        bool invalid{false};
                        for (int x = i1 + 1; x < i2; ++x) {
                            for (int y = j1 + 1; y < j2; ++y) {
                                if (mine <= v[x][y]) {
                                    invalid = true;
                                    break;
                                }
                                count += mine - v[x][y];
                            }
                            if (invalid) {
                                break;
                            }
                        }
                        if (!invalid) {
                            maxCount = max(maxCount, count);
                        }
                    }
                }
            }
        }
        cout << maxCount << endl;
    }
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  if(s=="SUN") ans = 7;
  else if(s=="MON") ans = 6;
  else if(s=="TUE") ans = 5;
  else if(s=="WED") ans = 4;
  else if(s=="THU") ans = 3;
  else if(s=="FRI") ans = 2;
  else if(s=="SAT") ans = 1;

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


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        int ans = INF;
        for(int i = 0; i < n - 1; i++){
            ans = min(ans, (int)abs(a[i + 1] - a[i]));
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3144
N, A, B, K = map(int, input().split())
MOD = 998244353

if K == 0:
    print(1)
    exit()

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

comb = Combination(N + 100, MOD)

ans = 0
for a in range(K // A + 2):
    b = (K - a * A) // B

    if b >= 0 and a * A + b * B == K:
        ans += comb.ncr(N, a) * comb.ncr(N, b)
        ans %= MOD

print(ans)

Measured memory_bytes: 40972
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;
int cnt[1000005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		for (int j=i;j<=n;j+=i)  cnt[j]++;
	}
	int ans=0;
	for (int i=1;i<=n;i++)  ans+=cnt[n-i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 11444
n=int(input())
p = input().split()
p = [int(x) for x in p]

ans = 0
i = 0
while (ans < 3 and i < n):
    if (p[i] != i+1):
        ans += 1
    i += 1

if (ans < 3):
    print("YES")
else:
    print("NO")


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

int		is_echo()
{
	int		N, i, n;
	char	*S;

	scanf("%d\n", &N);
	S = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s\n", S);
	if (N % 2)
		return (0);
	i = 0;
	n = N / 2;
	while (S[n])
	{
		if (S[i] != S[n])
			return (0);
		i++;
		n++;
	}
	return (1);
}

int		main()
{
	if (is_echo())
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}


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

int main(){
    int N,sum=0,Nsum=0;
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+N);
    sum-=a[N-1]/2;
    cout<<sum<<endl;

    return 0;
}


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

#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;


int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll binomialCoeff(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    for(ll i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            cout<<"Yes";
            br;
        }
        else
        {
            cout<<"No";
            br;
        }
    }

	return 0;
}


Measured memory_bytes: 5208
#include <iostream>
#include <set>

using namespace std;

set<pair<int, int>> used;
set<pair<int, int>> to_check;

long long ans[10];

int main() {
  ios_base::sync_with_stdio(false);

  long long w, h, n;
  cin >> h >> w >> n;
  for (int i = 0; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    used.insert(make_pair(u, v));
    for (int ii = -2; ii < 3; ++ii) {
      for (int jj = -2; jj < 3; ++jj) {
        to_check.insert(make_pair(u + ii, v + jj));
      }
    }
  }

  for (const pair<int, int> it : to_check) {
    if (it.first + 2 <= h && it.second + 2 <= w && it.first >= 1 && it.second >= 1) {
      int cnt = 0;
      for (int ii = 0; ii < 3; ++ii) {
        for (int jj = 0; jj < 3; ++jj) {
          if (used.find(make_pair(it.first + ii, it.second + jj)) != used.end())
            ++cnt;
        }
      }
      ++ans[cnt];
    }
  }

  ans[0] = (w - 2) * (h - 2);
  for (int i = 1; i < 10; ++i)
    ans[0] -= ans[i];

  for (int i = 0; i < 10; ++i)
    cout << ans[i] << "\n";

  return 0;
}


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

using namespace std;
using ll = long long;

const int INF = 0x3f3f3f3f;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    vector<vector<int>> dp((1 << N), vector<int>(N, INF));
    // dp[mask][i]: the minimum operation when cards in mask are in leftmost and the ith card is in the end
    for (int i = 0; i < N; ++i) {
        dp[1 << i][i] = 0;  // there is no card in leftmost whose id larger than i
    }
    for (int s = 0; s < (1 << N); ++s) {
        for (int i = 0; i < N; ++i) {
            if (((s >> i) & 1) == 0)
                continue;                  // i is not in state
            int c = __builtin_popcount(s); // card number in s
            int value_i = (c % 2) == (i % 2) ? B[i] : A[i];
            int cost = c; // the number of card in s, whose id is larger than j
            for (int j = 0; j < N; ++j) {
                if (((s >> j) & 1) == 1) {
                    --cost;
                    continue; // j is in state already
                }
                int value_j = (j % 2) == (c % 2) ? A[j] : B[j];
                if (value_j >= value_i) {
                    dp[s | (1 << j)][j] =
                        min(dp[s | (1 << j)][j], dp[s][i] + cost);
                }
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < N; ++i) {
        ans = min(ans, dp[(1 << N) - 1][i]);
    }
    ans = ans >= INF ? -1 : ans;
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N, M, K; cin >> N >> M >> K;
	vector<int> A(N), B(M);
	rep(i, N)cin >> A[i];
	rep(i, M)cin >> B[i];
	int maxB = 0;
	int ans = 0;
	rep(i, M) {
		if (maxB + B[i] <= K) {
			maxB += B[i];
			++ans;
		}
		else break;
	}
	long long sum = maxB;
	int countA = 0;
	int countB = ans;
	rep(i, N) {
		++countA;
		sum += A[i];
		rep(j, countB) {
			if (sum <= K)break;
			else {
				--countB;
				sum -= B[countB];
			}
		}
		if (sum <= K && ans < countA + countB)ans = countA + countB;
	}
	cout << ans;
}



Measured memory_bytes: 4776
/* 
  ╔╗         ╔╗              ╔═══╗                                  
  ║║        ╔╝╚╗             ║╔═╗║                                  
  ║║╔╗╔╗╔══╗╚╗╔╝    ╔══╗     ║╚═╝║╔═╗╔══╗╔══╗╔═╗╔══╗ ╔╗╔╗╔╗╔╗╔══╗╔═╗
╔╗║║║║║║║══╣ ║║     ╚ ╗║     ║╔══╝║╔╝║╔╗║║╔╗║║╔╝╚ ╗║ ║╚╝║║╚╝║║╔╗║║╔╝
║╚╝║║╚╝║╠══║ ║╚╗    ║╚╝╚╗    ║║   ║║ ║╚╝║║╚╝║║║ ║╚╝╚╗║║║║║║║║║║═╣║║ 
╚══╝╚══╝╚══╝ ╚═╝    ╚═══╝    ╚╝   ╚╝ ╚══╝╚═╗║╚╝ ╚═══╝╚╩╩╝╚╩╩╝╚══╝╚╝ 
                                         ╔═╝║                       
                                         ╚══╝                       */


//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#include<Personal/debug.h>
#else
#define debug(x...)
#endif

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)
#define repr(i,start,end) for(int i=(int)start;i>(int)end;i--)
#define all(x) (x).begin(), (x).end()

//Constants
const int mod = 1e9+7;

//Some useful functions
ll binpow(ll num,ll pow);
inline int mul(int a,int b) {return (a*1ll*b)%mod;}
inline int add(int a,int b) {return (a+0ll+b)%mod;}
inline int sub(int a,int b) {return ((a+0ll-b)%mod+mod)%mod; }
/*------------------------------------------------------Code Starts------------------------------------------------------*/
inline bool possible(int a[3])
{
	sort(a,a+3);
	if(a[0]==a[1] || a[1]==a[2]) return false;
	if(a[0]+a[1]>a[2]) return true;
	return false;
}
inline void solve()
{
	int n;
	cin>>n;
	vi a(n);
	for(int &i:a) cin>>i;
	int ans=0;
	rep(i,0,n-2)
	{
		rep(j,i+1,n-1)
		{
			rep(k,j+1,n)
			{
				int p[]={a[i],a[j],a[k]};
				if(possible(p))
				{
					debug(i+1,j+1,k+1);
					ans++;
				}
			}
		}
	}
	cout<<ans<<'\n';
}

int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}
/*------------------------------------------------------Code ends------------------------------------------------------*/
ll binpow(ll num,ll pow)
{
	if(pow==0)
		return 1;
	ll val=binpow(num,pow/2);
	val*=val;
	if(pow&1) val*=num;
	return val;
}



Measured memory_bytes: 3656
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int>v(n+1,0);
    for(int i=0;i<m;i++)
    {
        int element;
        cin>>element;
        v[element]=1;
    }
    int count=0;
    for(int i=1;i<x;i++)
    {
        count+=v[i];
    }
    cout<<min(count,m-count);
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
// #include <string>
// #include <map>
// #include <set>
// #include <cmath>

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;

    ull power = 1;
    for (int i = 1; i <= N; ++i) {
        power = (power * i) % MOD;
    }
    cout << power << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main()
{
int a=0,b=0,w=0,i,str1=0,str2=0,flag;

scanf("%d%d",&a,&b);
if(a!=1 && b!=1)
{
    if(a>b)
   {
       printf("Alice\n");
   }
   if(b>a){
       printf("Bob\n");
   }
   if(a==b)
   {
       printf("Draw\n");
   }
}else{
    if(a==1 && b!=1)
    {
         printf("Alice\n");
    }
      if(b==1 && a!=1)
    {
        printf("Bob\n");
    }
     if(a==b)
   {
       printf("Draw\n");
   }
    
}

    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#include<vector>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define pb push_back

using namespace std;
const int N=305,M=4510005,mod=1000000007;
int n,m,id[N][N][N],tp,f[2][M],vis[M],nw,tot,ans;
struct data{int l,x;};
vector <data> vt[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void inc(int x,int y)
{
	if(vis[x]!=nw) f[tp][x]=0,vis[x]=nw;
	f[tp][x]=(f[tp][x]+y)%mod;
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,m)
	{
		int l=getint(),r=getint(),x=getint();
		vt[r].pb((data){l,x});
	}
	memset(vis,-1,sizeof(vis));
	rep(i,0,n) rep(j,0,max(0,i-1)) rep(k,0,max(0,j-1)) id[i][j][k]=++tot;
	f[0][id[0][0][0]]=1,vis[id[0][0][0]]=0;
	rep(i,1,n)
	{
		tp^=1,nw=i;
		rep(x,0,i-1)
			rep(y,0,max(0,x-1))
				rep(z,0,max(0,y-1))
					if(vis[id[x][y][z]]==i-1)
					{
						int tmp=f[tp^1][id[x][y][z]];
						inc(id[i][y][z],tmp);
						inc(id[i][x][z],tmp);
						inc(id[i][x][y],tmp);
					}
		rep(x,0,i)
			rep(y,0,max(0,x-1))
				rep(z,0,max(0,y-1))
				{
					int sz=vt[i].size();
					bool jdg=0;
					rep(j,0,sz-1)
					{
						int l=vt[i][j].l;
						int t=(x>=l)+(y>=l)+(z>=l);
						if(t!=vt[i][j].x) {jdg=1; break;}
					}
					if(jdg) vis[id[x][y][z]]=-1;
				}
	}
	rep(i,1,tot) if(vis[i]==n) ans=(ans+f[tp][i])%mod;
	printf("%d\n",ans);			
	return 0;
}

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

int gcd(long long int m,long long int n){
	m=abs(m);
	n=abs(n);
	if(m*n==0){
		return max(m,n);
	}else {
		return gcd(min(m,n),max(m,n)%min(m,n));
	}
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	vector<int> l(n),r(n);
	l[0]=0;
	r[n-1]=0;
	for (int i = 0; i < n-1; i++) {
		l[i+1]=gcd(l[i],a[i]);
		r[n-i-2]=gcd(r[n-i-1],a[n-i-1]);
	}
	int ans=0;
	for (int i = 0; i < n; i++) {
		ans=max(ans,gcd(l[i],r[i]));
	}
	cout<<ans<<endl;
}

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

const int maxn = 5000+10;

int d[maxn];
int t[maxn];

int main() {
    int k, q;
    scanf("%d%d", &k, &q);
    for(int i=0; i<k; i++)
        scanf("%d", &d[i]);
    while(q--) {
        int n, x, mod;
        scanf("%d%d%d", &n, &x, &mod);
        x %= mod;
        ll tot = 0;
        int tmp = 0;
        for(int i=0; i<k; i++) {
            t[i] = d[i]%mod;
            if(t[i]==0)
                tmp++;
            tot += t[i];
        }
        ll mx = x+(n-1)/k*tot;
        int lim = (n-1)%k;
        int ans = n-1-(n-1)/k*tmp;
        for(int i=0; i<lim; i++) {
            mx += t[i];
            if(t[i]==0)
                ans--;
        }
        ans -= mx/mod-x/mod;
//        printf("mx=%lld x=%d\n", mx, x);
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define mod 1000000007
#define ll long long 
int main(){
    ll n, k, ans = 0;
    scanf("%lld%lld",&n,&k);
    for(; k <= n + 1; k++){
        ans += (n - k + 1) * k + 1;
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
#define MAX int(1e5+10)
#define INF ll(1e9)
ll n, k, h[MAX], v[MAX];
void solve() {
	cin >> n >> k;
	rep(i, 0, n) cin >> h[i];
	fill(v, v + n, INF);
	v[0] = 0;
	rep(i, 1, n) {
		rep(j, 1, min(ll(i) + 1, k + 1)) {
			chmin(v[i], abs(h[i] - h[i - j]) + v[i - j]);
		}
	}
	print(v[n - 1]);
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
B= [0] * N

for i in range(0, N):
	bb = int(input())
	B[bb-1] = i

m = 1
mx = 1
for i in range(1, N):
	if B[i] > B[i-1]:
		m = m + 1
		mx = max(mx, m)
	else:
		m = 1

print(N - mx)


Measured memory_bytes: 11380
#include <iostream>
#include <cmath>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
	int n,q,time;
	string name;

	queue<pair<string,int> > Q;

	cin>>n>>q;

	for(int i=0;i<n;i++){
		cin>>name>>time;
		Q.push(make_pair(name,time));
	}


	pair<string,int> u;
	int total_time=0;
	int a;


	while(!Q.empty()){
		u=Q.front();
		Q.pop();

		a=min(u.second,q);

		u.second-=a;

		total_time+=a;
		if(u.second>0){
			Q.push(u);
		}else{
			cout<<u.first<<" "<<total_time<<endl;
		}
	}

	return 0;
}

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

int main(){
	int m,f,r;
	for(;;){
		cin>>m>>f>>r;
		int sum=m+f;
		if(m==-1&&f==-1&&r==-1) break;
		if(m==-1||f==-1) cout<<"F";
		if(sum>=80) cout<<"A";
		if(sum>=65&&sum<80) cout<<"B";
		if(sum>=50&&sum<65) cout<<"C";
		if(sum>=30&&sum<50){
			if(r>=50) cout<<"C";
			if(r<50&&m!=-1&&f!=-1) cout<<"D";
		}
		if(sum<30) cout<<"F";
		cout<<endl;		
	}
	return 0;
}

Measured memory_bytes: 1152
n, k = map(int, input().split())
x = list(int(i) for i in input().split())
inf = 10**9
max_x = x[-1]
min_x = x[0]
if min_x >= 0:
    print(x[k-1])
elif max_x <= 0:
    print(abs(x[-k]))
else:
    for i in range(n-1):
        if x[i]<0 and x[i+1]>=0:
            key = i+1
            break
    if n-key>=k:
        ans1 = sum(x[key:key+k])
    else:
        ans1 = inf
    if key>=k:
        ans2 = abs(sum(x[key-k:key]))
    else:
        ans2 = inf
    ans3 = inf
    for i in range(max(0, key-k+1), min(n-k+1, key+k-1)):
        a, b = abs(x[i]), abs(x[i+k-1])
        t = max([a, b])+min([a, b])*2
        if t < ans3:
            ans3 = t
    print(min([ans1, ans2, ans3]))

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

struct UnionFind {
  vll d;
  UnionFind(ll n=0): d(n,-1) {}
  ll find(ll x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(ll x, ll y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  ll size(ll x) {
    return -d[find(x)];
  }
};


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

  ll n,m;
  cin>>n>>m;
  vll a(m),b(m);
  REP(i,m)cin>>a[i]>>b[i];

  UnionFind uf(n);
  REP(i,m){
    a[i]--;
    b[i]--;
    uf.unite(a[i],b[i]);
  }

  ll ans=0;
  REP(i,n)ans=max(ans,uf.size(i));
  cout<<ans<<endl;
}



Measured memory_bytes: 7908
#include <cstdio>
#include <iostream>

using namespace std;

const int N = 100;

int num[N];

void swap(int &a, int &b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int selectionSort(int num[], int n) {//???????????? 
	int cnt = 0; //?????蔵?測???属 
	for (int i=0; i<n; ++i) {
		int k = i;
		for (int j=i+1; j<n; ++j) {
			if (num[k] > num[j]) k = j;
		}
		if (k != i) swap(num[k], num[i]), ++cnt;
	}
	return cnt;
}

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		for (int i=0; i<n; ++i) scanf ("%d", &num[i]);
		int cnt = selectionSort(num, n);
		for (int i=0; i<n; ++i) printf (i ? " %d" : "%d", num[i]);
		printf ("\n%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 998244353;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n,k;
        cin>>n>>k;
        lld ans[n+1];
        memset(ans,0,sizeof(ans));
        ans[0]=0;
        ans[1]=1;
        vector<lld>v;
        v.push_back(0);
        v.push_back(1);
        lld ar[k],br[k];
        for(i=0;i<k;i++)
        cin>>ar[i]>>br[i];
        for(i=2;i<=n;i++)
        {
            for(j=0;j<k;j++)
            {
             ans[i]=add(ans[i],v[max(0ll,i-ar[j])]-v[max(0ll,i-br[j]-1)]);
            }
            v.push_back(add(v[v.size()-1],ans[i]));;
        }
        cout<<ans[n]<<endl;
    }
}





Measured memory_bytes: 6864
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  int ans = INF;
  for (int i = 0; i < S.size() - 2; i++) {
    int x = S[i] - '0';
    int y = S[i+1] - '0';
    int z = S[i+2] - '0';
    ans = min(ans, abs(100*x + 10*y + z - 753));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int input_seconds,output_seconds,output_minutes,output_hour;
	scanf("%d",&input_seconds);
	if (input_seconds <60){
		output_seconds = input_seconds;
	}else{
		output_seconds = input_seconds % 60;
	}
	if (input_seconds<3600){
		output_minutes = input_seconds / 60;
	}else{
		output_minutes = (input_seconds/60)%60;
	}
	output_hour = input_seconds /3600;
	printf("%d:%d:%d\n",output_hour,output_minutes,output_seconds);

}



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

int main()
{

    long long x,y;
    scanf("%lld%lld",&x,&y);
    for(long long i=y-(x-1);i<=y+(x-1);i++)
    {
        printf("%lld ",i);
    }
    printf("\n");
    return 0;
}


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

int main(){
	int n,num,k,maxk;
	while(cin >> n,n){
		maxk = 0;
		num = n;
		for(int i = 0;i < n;i++) {
			cin >> k;
			if(k == 0) num--;
			maxk = max(maxk,k);
		}
		if(maxk < 2) cout << "NA" << endl;
		else cout << num + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<ctype.h>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
    int n=read(),m=read();--n,--m;
    printf("%d",n*m);
    return 0;
}

Measured memory_bytes: 256