akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"






int max_weight(int n,int w,vector<pair<int,int>>&v,int i,vector<vector<int>>&dp)
{
    if(i==n)
    {
        return 0;
    }
    if(w==0) return 0;
 if(dp[i][w]!=-1) return dp[i][w];

    int option1=INT_MIN;
    int option2=INT_MIN;
   if(w-v[i].first>=0)  option1=v[i].second+max_weight(n,w-v[i].first,v,i+1,dp);
     option2= max_weight(n,w,v,i+1,dp);
     //cout<<option1<<" "<<option2<<" "<<i<<" "<<w<<endl;
     dp[i][w]=max(option1,option2);
       return max(option1,option2);



}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n,w;
   cin>>n>>w;
 vector<pair<int,int>> v(n);
 vector<vector<int>> dp(n+1,vector<int>(w+1,-1));
 for(int i=0;i<n;i++)
 {
     int m,n;
     cin>>m>>n;
     v[i]={m,n};
 }


 cout<<max_weight(n,w,v,0,dp)<<endl;










}

Measured memory_bytes: 83024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

long long gcd(long long a, long long b){
	if (b == 0)return a;
	return gcd(b, a%b);
}

void solve(){
	long long N;
	cin>>N;
	for (long long h=1;h<=3500;h++){
		for (long long n = 1; n <= h; n++){
			long long x, y;
			x = n*(4 * h - N) - N*h;
			y = N*h*n;
			long long g = gcd(x,y);
			x /= g;
			y /= g;
			if (x == 1 && 0<y){
				cout << h << ' ' << n << ' '<<y<<endl;
				return;
			}

		}
	}
}


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

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define MOD 1000000007
//#define PI 3.14159265358979

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

using namespace std;

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;

vector< vector< vector< pii > > > G;
vector< vector< int > > dp;
set< pii > s;
int dfs(pii p) {
	if (dp[p.first][p.second] != -1)
		return dp[p.first][p.second];
	if (s.find(p) != s.end())
		return -1;
	s.insert(p);
	int ret = 0;
	rep(i, G[p.first][p.second].size()) {
		int tmp = dfs(G[p.first][p.second][i]);
		if (tmp == -1) {
			return -1;
		}
		chmax(ret, tmp);
	}
	s.erase(p);
	return dp[p.first][p.second] = ret + 1;
}
int main() {
	cin >> N;
	G = vector< vector< vector< pii > > >(N, vector< vector< pii > >(N));
	vector< vector< int > > A(N, vector< int >(N - 1));
	dp = vector< vector< int > >(N, vector< int >(N, -1));
	s = set< pii >();
	rep(i, N) {
		rep(j, N - 1) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	rep(i, N) {
		pii prev;
		prev.first = min(i, A[i][0]);
		prev.second = max(i, A[i][0]);
		for (int j = 1; j < N - 1; j++) {
			pii now;
			now.first = min(i, A[i][j]);
			now.second = max(i, A[i][j]);
			G[prev.first][prev.second].push_back(now);
			prev = now;
		}
	}
	int ans = 0;
	rep(i, N) {
		rep(j, N) if (i < j) {
			int tmp = dfs(make_pair(i, j));
			if (tmp == -1) {
				ans = -1;
				break;
			} else
				chmax(ans, tmp);
		}
		if (ans == -1)
			break;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 16;
const int MSK = 1 << N;
int a[N + 3][N + 3];
ll pre[MSK + 3];
ll dp[MSK + 3];
int n;

ll solve(int msk) {
    if (msk == 0)return 0;
    ll &ret = dp[msk];
    if (~ret)return ret;
    ret = 0;
    for (int sub = msk; sub != 0; sub = (sub - 1) & msk) {
        ret = max(ret, solve(msk & (~sub)) + pre[sub]);
    }
    return ret;
}


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    memset(dp, -1, sizeof dp);
    cin >> n;
    loop(i, n)loop(j, n)cin >> a[i][j];
    loop(msk, (1 << n)) {
        loop(i, n) {
            if (msk & (1 << i)) {
                loop(j, n) {
                    if (msk & (1 << j)) {
                        pre[msk] += a[i][j];
                    }
                }
            }
        }
        pre[msk] >>= 1;
    }

    cout << solve((1 << n) - 1) << endl;

    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll N;
  cin>>N;
  ll sum = N*(N*N+3*N+2)/6;
  for(int i(0);i<N-1;i++){
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    sum -= a*(N-b+1);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define N 200010 
#define p(x) (x==1?n:(x)-1)
#define s(x) (x==n?1:(x)+1)
#define pii pair<int,int>
#define fs first
#define sc second
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int x=0,f=1;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
priority_queue<pii ,vector<pii> > T;
int n,a[N],b[N];
ll ans;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=n;i++)
		b[i]=read();
	int cnt=n;
	for(int i=1;i<=n;i++)
		if(b[i]>a[i])	T.push(make_pair(b[i],i));
		else if(b[i]<a[i]) {puts("-1");return 0;}
		else cnt--;
	while(cnt)
	{
		pii v=T.top();T.pop();
		int t1,t2;
		t1=b[p(v.sc)]+b[s(v.sc)];
		t2=(v.fs-a[v.sc])/t1;
		//cout<<v.fs<<' '<<v.sc<<"  "<<t1<<' '<<t2<<endl;
		b[v.sc]=v.fs-t2*t1;
		if(t2<=0) {puts("-1");return 0;}
		if(b[v.sc]==a[v.sc]) cnt--;
		else T.push(make_pair(b[v.sc],v.sc));
		ans+=t2;
		
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3956
<?php
fscanf(STDIN, "%d %d %d", $h, $w, $k);

$row = array();
for ($i=0; $i < $h; $i++) {
  $row[$i] = str_split(trim(fgets(STDIN)));
}

$ans = 0;
for ($is=0; $is < (1<<$h); $is++) {
  for ($js=0; $js < (1<<$w); $js++) {

    $cnt = 0;
    for ($i=0; $i < $h; $i++) {
      for ($j=0; $j < $w; $j++) {
        if ($is>>$i&1) continue;
        if ($js>>$j&1) continue;
        if ($row[$i][$j] == '#') $cnt++;
      }
    }

    if ($cnt == $k) $ans++;
  }
}

echo $ans;


Measured memory_bytes: 16116
import heapq
n = int(input())
a = list(map(int,input().split()))

first = []
second = []
for i in range(n):
    first.append(a[i])
for i in range(2*n,3*n):
    second.append(-a[i])
heapq.heapify(first)
heapq.heapify(second)


sumfirst = [0]*(n+1)
sumsecond = [0]*(n+1)
sumfirst[0] = sum(first)
sumsecond[n] = -sum(second)

for i in range(1,n+1):
    k = 0
    k += a[n-1+i]
    heapq.heappush(first,a[n-1+i])
    k -= heapq.heappop(first)
    sumfirst[i] = sumfirst[i-1]+k

for i in range(n-1,-1,-1):
    k = 0
    k += a[n+i]
    heapq.heappush(second,-a[n+i])
    k -= -heapq.heappop(second)
    sumsecond[i] = sumsecond[i+1]+k

res = sumfirst[0]-sumsecond[0]
for i in range(n+1):
    res = max(res,sumfirst[i]-sumsecond[i])
print(res)

Measured memory_bytes: 37212
package main

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

const END = 2100000000

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	q := nextInt()
	var new_ele *element
	var front *element
	front = gene_element(END)
	var p *element = front
	for i := 0; i < q; i++ {
		switch nextInt() {
		case 0:
			x := nextInt()
			new_ele = gene_element(x)
			if front.val == END {
				front = new_ele
				new_ele.next = p
				p.prev = new_ele
				p = new_ele
			} else {
				if front == p {
					front = new_ele
					new_ele.next = p
					p.prev = new_ele
					p = new_ele
				} else {
					p.prev.next = new_ele
					new_ele.prev = p.prev
					new_ele.next = p
					p.prev = new_ele
					p = new_ele
				}
			}
		case 1:
			d := nextInt()
			if d > 0 {
				for j := 0; j < d; j++ {
					p = p.next
				}
			} else {
				for j := 0; j < -d; j++ {
					p = p.prev
				}
			}
		case 2:
			if front == p {
				p.next.prev = nil
				front = front.next
				p = front
			} else {
				p.prev.next = p.next
				p.next.prev = p.prev
				p = p.next
			}
		default:
			panic("no such operation!")
		}
	}
	p = front
	for p != nil {
		if p.val != END {
			fmt.Println(p.val)
		}
		p = p.next
	}
}

type element struct {
	val int
	next *element
	prev *element
}

func gene_element(val int) *element {
	return &element{val:val, next:nil, prev:nil}
}


Measured memory_bytes: 22328
n, m, k = map(int, input().split( ))

mod = 10**9 + 7

def chs(a,b, md):
    res = 1
    for i in range(a-b+1,a+1):
        res *=  i
        res %= md
    rev = 1
    for i in range(1,b+1):
        rev *= i
        rev %= md
    rev2 = pow(rev,md-2,md)
    
    res *= rev2
    res %= md
    
    return res

ans = 0
c = chs(n*m-2,k-2,mod)

for i in range(1,n):
    ans += i*(n-i)*m**2
    ans %= mod

        

for i in range(1,m):
    ans +=i*(m-i)*n**2
    ans %=mod
ans *= c
ans %= mod
print(ans)


Measured memory_bytes: 38896
N, K = map(int, input().split())
l = input().split()
l2 = [int(i) for i in l]

line1, line2 = 0, 10**9

while (line2-line1 > 1):
  x = int((line1 + line2) / 2)
  def f(x):
    now = 0
    for i in range(N):
      now += int((l2[i]-1)/x)
    return now <= K
  if f(x)==True:
    line2 = x
  else:
    line1 = x
    
print(line2)

Measured memory_bytes: 31136
#include<stdio.h>

int main(){
    int a,b,c,k,n=0;
    if(scanf("%d%d%d%d", &a,&b,&c,&k)==1);
    if(a>=k){n=k;}
    else if(a+b>=k){n=a;}
    else{n=2*a+b-k;}
    printf("%d", n);
    return 0;
}


Measured memory_bytes: 1728
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl



int main(){
    int n,m;cin >> n >> m;
    vector<vector<int>>v(m);
    for(int i=0;i<m;i++){
        int k;cin >>k;
        v[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    
    vector<int> p(m);
    for (int i = 0; i<m;i++) cin >> p[i];
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool ok = true;
        for (int j = 0; j < m;j++) {
            int c = 0;
            for (int id : v[j]) {
                if ((i >> id) & 1) {
                    c++;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    int i,j,k,H,W;
    scanf("%d %d", &H, &W);
    char s[H][W];
    int matrix[H][W];
    int a[H][W];
    int b[H][W];
    int cnt=0;
    int max=0;
    int temp=0;

    getchar();
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            scanf("%c", &s[i][j]);
            if(s[i][j] == '#') {
                matrix[i][j] = 1;
            }
            else{
                matrix[i][j] = 0;
            }
        }
        getchar();
    }

    cnt=0;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            if(matrix[i][j] == 1){
                a[i][j]=0;
                for(k=cnt; k>0; k--){
                    a[i][j-k] = cnt;
                }
                cnt=0;
            }
            else if(matrix[i][j] == 0 ){
                cnt++;
            }

            if(j==W-1){
                for(k=cnt-1; k>=0; k--){
                    a[i][j-k] = cnt;
                }
                cnt=0;
            }
        }
    }

    cnt=0;
    for(i=0;i<W;i++){
        for(j=0;j<H;j++){
            if(matrix[j][i] == 1){
                b[j][i]=0;
                for(k=cnt; k>0; k--){
                    b[j-k][i] = cnt;
                }
                cnt=0;
            }
            else if(matrix[j][i] == 0 ){
                cnt++;
            }

            if(j==H-1){
                for(k=cnt-1; k>=0; k--){
                    b[j-k][i] = cnt;
                }
                cnt=0;
            }
        }
    }

    max=0;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            temp = a[i][j]+b[i][j];
            if(a[i][j]>0 && b[i][j]>0) temp=temp-1;
            if(temp>max){
                max = temp;
            }
        }
    }
    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 50944
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);

      //入力
      int m =sc.nextInt();//モンスターの数
      int waza =sc.nextInt();//必殺技回数
      
      //HPリストの空箱用意
      List<Long>hp=new ArrayList<>();
      
      //HPリスト作成
      for(int i=0; i<m; i++){
      		hp.add(sc.nextLong());
      }
      
      //HPリストの中を降順に
      Collections.sort(hp, Collections.reverseOrder());
      
      long kougeki =0;//攻撃のみの回数(初期値)
      
      //必殺技だけでモンスターを倒せるとき
      if(m<waza){
        	System.out.println(0);
        	return;
      }
      
      //必殺技を除いた攻撃回数を求める
      for(int i=waza; i<m; i++){
        	kougeki += hp.get(i);
      }
      
      System.out.println(kougeki);

    }
}

Measured memory_bytes: 66396
n,m = map(int,input().split())
a = list(map(int,input().split()))

x = max(a)
s = 0
for i in a:
    s += i
y = [l for l in a if l >=s/4/m]
if len(y) >=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc147/tasks/abc147_f
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll a,b,k;
    std::cin >> a>>b>>k;
    ll taka,ao;
    
    if(a<=k){
        taka = 0;
        ao = max((ll)0,b-(k-a));
    }else{
        taka = a-k;
        ao = b;
    }
    
    std::cout << taka<<" "<<ao << std::endl;
    
    
}


Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl

int main(){
    ll n;cin >> n;
    vector<ll>v(5);
    rep(i,5){
        cin >> v[i];
    }
    ll m=*min_element(v.begin(),v.end());
    ll time=(n-1)/m+5;
    out(time);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向
const int MAX_N = 100001;

int n;
int t[MAX_N],x[MAX_N],y[MAX_N];

void input(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> t[i] >> x[i] >> y[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool flg = true;
    for(int i=0;i<n;i++){
        if (t[i] < x[i] + y[i]){
            flg = false;
            break;
        }
        else if((x[i]+y[i]-t[i])%2){
            flg = false;
            break;
        }
    }
    if(flg) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
string s;
int k;


int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>k;
    cin>>s;
    //getline(cin,s);
    if (s.size()<=k)
    {
        cout<<s;
    }
    else
    {
        s.resize(k);
        for (int i=0; i<3; i++)
        {
            s.push_back('.');
        }
        cout<<s;
    }

    return 0;
}


Measured memory_bytes: 3580
;; -*- coding:utf-8 -*-

(defparameter *file-path* *load-pathname*)

(defun clip-to-string ()
  (with-output-to-string (out)
    (sb-ext:run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (clip-to-string))
    (load *file-path*)))

(defun manhattan-dist (x1 y1 x2 y2)
  (+ (abs (- x1 x2)) (abs (- y1 y2))))

(defun same-parity-p (m n)
  (or (and (evenp m) (evenp n))
      (and (oddp m) (oddp n))))

(defun reachable-p (t1 t2 x1 y1 x2 y2)
  (let ((dist (manhattan-dist x1 y1 x2 y2))
	(duration (- t2 t1)))
    (and (>= duration dist)
	 (same-parity-p duration dist))))

(defun main ()
  (let ((num (read)))
    (loop for i from 0 below num
       for current-time = 0 then dest-time
       for current-x = 0 then dest-x
       for current-y = 0 then dest-y
       for dest-time = (read)
       for dest-x = (read)
       for dest-y = (read)
       do (unless (reachable-p current-time dest-time current-x current-y dest-x dest-y)
	    (write-line "No")
	    (return))
       finally (write-line "Yes"))))

(main)


Measured memory_bytes: 57956
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<vector<bool>> S(N, vector<bool>(K, false));
	for (int i = 0; i < K; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int A;
			cin >> A;
			S[A-1][i] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		bool f = true;
		for (int j = 0; j < K; j++)
		{
			if (S[i][j] == true)
				f = false;
		}
		if (f)
			ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3636
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7

if __name__ == "__main__":
    n = int(input())
    all0 = (10**n)
    no0 = (9**n)
    no9 = (9**n)
    no0and9 = (8**n)
    ans = (all0 - no0 - no9 + no0and9)%mod
    print(ans)

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

using namespace std;

int dp[2001][2001];
int sz[2001];
int tmp[2001];
int ans[2001];
vector<int> edge[2001];

int n, k, a, b;

void dfs(int x, int last = -1){

  dp[x][0] = 0;
  sz[x] = 1;
  for(int i = 0;i < edge[x].size();i++){
    int to = edge[x][i];
    if(to == last)continue;
    dfs(to, x);
    for(int j = 0;j < sz[x] + sz[to];j++)tmp[j] = 1 << 29;
    for(int j = 0;j < sz[x];j++){
      tmp[j] = min(tmp[j], dp[x][j] + sz[to]);
      for(int l = 0;l < sz[to];l++){
	if(j + l + 1 > k)continue;
	tmp[max(j, l + 1)] = min(tmp[max(j, l + 1)], dp[x][j] + dp[to][l]);
      }
    }
    sz[x] += sz[to];
    for(int j = 0;j < sz[x];j++)dp[x][j] = tmp[j];
  }
  ans[x] = 1 << 29;
  for(int j = 0;j < sz[x];j++)ans[x] = min(dp[x][j], ans[x]);
  ans[x] = n - 1 - (sz[x] - 1 - ans[x]);
}

int main(){
  cin >> n >> k;
  for(int i = 0;i < n-1;i++){
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for(int i = 1;i <= n;i++)
    for(int j = 0;j <= k;j++)
      dp[i][j] = 1 << 29;
  dfs(1);
  
  int res = 1 << 29;
  for(int i = 1;i <= n;i++)res = min(res, ans[i]);
  
  cout << res << endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N) {
    vector<int> a;
    while (N != 0) {
        int t = N % 2;
        a.push_back((t + 2) % 2);
        N /= -2;
        if (t < 0) N++;
    }
    if (a.size() == 0) a.push_back(0);
    reverse(a.begin(), a.end());
    for (auto i : a) cout << i;
    cout << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    solve(N);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
def comb_list(n, r, mod):
    ret = [1]
    for i in range(1, r+1):
        ret.append(ret[-1] * (n+1-i) * pow(i, mod-2, mod) % mod)
    return ret

n,k = map(int,input().split())
mod = 10**9+7

r = min(k,n-1)
ans = 0
nCl = comb_list(n, r, mod)
n1Cl = comb_list(n-1, r, mod)

for i in range(r+1):
    ans = (ans + nCl[i] * n1Cl[i]) % mod

print(ans)


Measured memory_bytes: 83588
(def a (read))
(def b (read))
(def c (read))
(def d (read))

(def ac (Math/abs (- a c)))
(def ab (Math/abs (- a b)))
(def bc (Math/abs (- b c)))
(defn check [target] (if (<= target d) true false))
(def resultac (check ac))
(def resultab (check ab))
(def resultbc (check bc))
(if (or resultac (and resultab resultbc)) (println "Yes") (println "No"))

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  ll N;cin >> N;
  ll dp[110][4][4][4];
  dp[0][3][3][3] = 1;
  for(int i = 0;i < N;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        for(int l = 0;l < 4;l++){
          if((j == 0 && k == 1 && l == 2) ||
             (j == 0 && k == 2 && l == 1) ||
             (j == 2 && k == 0 && l == 1)
          ){
            continue;
          } 
          for(int m = 0;m < 4;m++){
            if((j == 0 && l == 2 && m == 1) ||
               (j == 0 && k == 2 && m == 1) ||
               (k == 0 && l == 1 && m == 2) ||
               (k == 0 && l == 2 && m == 1) ||
               (k == 2 && l == 0 && m == 1)
            ){
              continue;
            }
            dp[i+1][k][l][m] += dp[i][j][k][l];
            dp[i+1][k][l][m] %= MOD;
          }
        }
      }
    }
  }
  ll ans = 0;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        ans += dp[N][i][j][k];
      }
    }
  }
  cout << ans % MOD << endl;
}


Measured memory_bytes: 256
fn solve() {
    let mut n: usize = read();
    n -= 1;
    let mut base = 26;
    let mut length = 0;
    while n >= base {
        n -= base;
        base *= 26;
        length += 1;
    }
    base /= 26;
    let mut res = String::new();
    for _ in 0..length + 1 {
        res.push((b'a' + (n / base) as u8) as char);
        n %= base;
        base /= 26;
    }
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

int main(){
	int k;
	string s;
	cin>>k>>s;
	for(int i=0;i<min(int(s.size()), k);i++)
		cout<<s[i];
	if(s.size()>k)
		cout<<"...";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    vector<double> e(n + 1);
    rep(i, n)
    {
        e[i + 1] = e[i] + d[i];
    }

    double maxExp = 0;
    int from, to;
    for (int i = k; i <= n; ++i)
    {
        if (chmax(maxExp, e[i] - e[i - k]))
        {
            from = i - k;
            to = i;
        }
    }
    vector<double> s(1002);
    for (int i = 0; i < 1002; ++i)
    {
        s[i] += s[i - 1] + i;
    }

    double ans = 0;
    for (int i = from; i < to; ++i)
    {
        ans += s[d[i]] / d[i];
    }

    cout << setprecision(8) << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
using namespace std;

array<int, 1000001> table;

void init()
{
	table.fill(-1);
	for (int i = 2; i <= 1000000; ++i) {
		if (table[i] == -1) {
			for (int j = i + i; j <= 1000000; j += i) {
				table[j] = i;
			}
		}
	}
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main()
{
	int n;
	cin >> n;
	vector<int> av(n);
	for (auto& a : av) {
		cin >> a;
	}

	init();

	unordered_map<int, int> m;
	for (auto a : av) {
		unordered_map<int, int> tm;
		while (table[a] != -1) {
			if (tm.find(table[a]) == tm.end()) {
				tm[table[a]] = 1;
			}
			else {
				tm[table[a]]++;
			}
			a /= table[a];
		}

		if (tm.find(a) == tm.end()) {
			tm[a] = 1;
		}
		else {
			tm[a]++;
		}

		for (auto& i : tm) {
			if (m.find(i.first) == m.end()) {
				m[i.first] = i.second;
			}
			else {
				m[i.first] = max(m[i.first], i.second);
			}
		}
	}

	long long lcm = 1;
	for (auto& i : m) {
		for (int j = 0; j < i.second; ++j) {
			lcm = lcm * i.first % 1000000007;
		}
	}

	long long ret = 0;
	for (auto& a : av) {
		long long temp = lcm * modinv(a, 1000000007) % 1000000007;
		ret = (ret + temp) % 1000000007;
	}

	cout << ret << endl;

	return 0;
}

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

int main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    int *lst;
    lst = new int[N];
    for(int i=0;i<N;i++){
        lst[i] = K-Q;
    }
    for(int i=0;i<Q;i++){
        int a;cin>>a;
        lst[a-1] += 1;
    }
    for(int i=0;i<N;i++){
        if(lst[i] >0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

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

int main() {
  int N, C;
  int64_t D;
  cin >> N >> D;
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  vector<int64_t> L(N);
  C = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
    L.at(i) = X.at(i) * X.at(i) + Y.at(i) * Y.at(i);
    if (L.at(i) <= D * D) {
      C = C + 1;
    }
  }
  
  cout << C;
 
}


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n-1);
  rep(i,n-1) cin >> b[i];
  a[0] = b[0];
  a[n-1] = b[n-2];
  for (int i = 1; i <= (n-2); ++i){
    a[i] = min(b[i], b[i-1]);
  }
  int ans = 0;
  rep(i,n){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putintsp(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();
	sort(A, A + N);

	int saidai = A[N - 1];
	int saishou = A[0];

	int kotae1[100000], kotae2[100000];
	for (int i = 1; i < N - 1; i++) {
		if (A[i] < 0) {
			putintsp(saidai);
			putint(A[i]);
			saidai -= A[i];
		}
		else {
			putintsp(saishou);
			putint(A[i]);
			saishou -= A[i];
		}
	}
	putintsp(saidai);
	putint(saishou);

	int X = saidai - saishou;

	if (X == 0) {
		putchar_unlocked('0');
		putchar_unlocked('\n');
	}
	else {
		if (X < 0) {
			putchar_unlocked('-');
			X = -X;
		}
		int keta = 0;
		char C[10];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) putchar_unlocked(*(C + i));
		putchar_unlocked('\n');
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
ll dp[10][10];
int main(){
    rp(i,10) dp[i][0]=1;
    for(int j=1;j<10;j++){
        rp(i,10){
            if(i==0){
                dp[i][j]=dp[0][j-1]+dp[1][j-1];
            }
            else if(i==9){
                dp[i][j]=dp[8][j-1]+dp[9][j-1];
            }
            else{
                dp[i][j]=dp[i+1][j-1]+dp[i][j-1]+dp[i-1][j-1];
            }
        }
    }
    //cout<< dp[2][3] << endl;
    ll k;
    cin >> k;
    ll sum=0;
    bool ok=false;
    ll i0,j0;
    for(int i=0; i<10; i++){
        for(int j=1; j<10; j++){
            if(sum+dp[j][i]<k){
            sum += dp[j][i];
            //cout << j << i <<" " << sum<< endl;
            }
            else{
                ok=true;
                j0=j;i0=i;
                break;
            }
        }
        if(ok) break;
    }
    //cout << j0 << endl;
    //cout << i0 << endl;
    k-=sum;
    //cout << k << endl;
    sum=0;
    ll ans=j0;
    for(ll i=i0-1;i>=0;i--){
        //cout << "here2" << endl;
        for(ll j=max(j0-1,(ll)0);j<=min(j0+1,(ll)10);j++){
            //cout<<j<<endl;
            if(sum+dp[j][i]<k)
            sum+=dp[j][i];
            else{
                //cout << "here" << endl;
                ans=ans*10+j;
                j0=j;
                k-=sum;
                sum=0;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
int n,x;
ll dp[205][100005];
int s[205];
int mmin = mod;
int main() {
  cin >> n >> x;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    mmin = min(mmin,s[i]);
  }
  sort(s,s+n);
 

  dp[n][x] = 1;
  int k = x;
  for(int i = n; i > 0; i--) {
    for(int j = 0; j <= x; j++) {
      if(dp[i][j] == 0) continue;
      dp[i-1][j] = (dp[i-1][j] + dp[i][j] * (i - 1)) % mod;
    dp[i-1][j % s[i-1]] += dp[i][j];
    }
  }

  ll ans = 0;
  for(int i = 0; i < mmin; i++) {
    //   cout << "d[0]["<<i<<"] = "<<dp[0][i] << endl;
    ans = (ans + (dp[0][i] * i) % mod ) % mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 156800
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	if(n % 10 == 9 || n / 10 == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll MOD=1ll*1e9+7;

int main(){FIN;
	ll n; cin>>n;
	ll c[n];
	fore(i,0,n)cin>>c[i];
	ll res[n+1],us[200005];
	memset(res,0,sizeof res);
	memset(us,-1,sizeof us);
	res[0]=1;
	fore(i,0,n){
		if(us[c[i]]==-1){
			us[c[i]]=i+1;
			res[i+1]=res[i]%MOD;
		}else{
			res[i+1]=(res[i]+(us[c[i]]!=i)*res[us[c[i]]])%MOD;
			us[c[i]]=i+1;
		}
	}
	//fore(i,1,n+1)cout<<res[i]<<" ";
	cout<<res[n];
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
double kyori(int x,int y,int a,int b){
   double c;
  c=pow((x-a)*(x-a)+(y-b)*(y-b),0.5);
  return c;
}

int main() {
int n;
 cin>>n;
 vector<int> x(n),y(n);
  rep(i,n){
    cin>>x[i]>>y[i];
  }
  ///////////////入力
  double ans;//答え
  vector<int> ord(n);//n!
  int cnt;//n!=c
  rep(i,n){
    ord[i]=i;
  }
  do{
    cnt++;
    rep(i,n-1){
   ans+=kyori(x[ord[i]],y[ord[i]],x[ord[i+1]],y[ord[i+1]]);
    }
    //cout<<ans<<endl;
  }while(next_permutation(all(ord)));//n!全探索
  ans/=cnt; //一回あたり
  cout<<fixed<<setprecision(7);
  cout<<ans<<endl;
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;



int main(){
    double L;
    cin>>L;
    double ans;
    ans=(L/3)*(L/3)*(L/3);
    printf("%.10f",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;

signed main(){
	string s; cin >> s;
	vector<vector<lint> > dp(100010, vector<lint> (13, 0));
	dp[0][0] = 1;
	for(lint i = 0; i < s.size(); i++){
		for(lint j = 0; j < 13; j++){
			if(s[i] != '?'){
				lint x = s[i] - '0';
				dp[i + 1][(10 * j + x) % 13] += dp[i][j];
				dp[i + 1][(10 * j + x) % 13] %= MOD;
			}
			else{
				for(lint k = 0; k < 10; k++){
					dp[i + 1][(10 * j + k) % 13] += dp[i][j];
					dp[i + 1][(10 * j + k) % 13] %= MOD;
				}
			}
		}
	}
	cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 13696
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>> a>>b;
    if(a>1){
        if(b<a){
         cout<<   a-1;
        }
        else{
            cout<< a;
        }
    }
    else {
        cout << 1;
    }
    return 0;
}

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

const int MAXN = 100000;
int cnt[MAXN + 1];

int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		cnt[a]++;
		cnt[b]++;
	}
	for(int i = 1; i <= n; i++) {
		if(cnt[i] & 1) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}

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

int main(){
  long long int n, b, r; cin >> n >> b >> r;
  if(n % (b + r) <= b) cout <<  b * (n / (b + r)) + n % (b + r)<< endl;
  else cout << b * (n / (b + r)) + b << endl;
  return 0;
}


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

int main(){
    int N, d, j, all_n=0;
    cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for ( int i = 0;i<N-2;i++){
        for(j = i+1;j<N-1;j++) {
            for(int k = j+1;k<N;k++){
                if(abs(A[i]-A[j])<A[k] && abs(A[i]-A[k])<A[j] &&abs(A[k]-A[j])<A[i] && A[k]-A[j]!=0&&A[k]-A[i]!=0&&A[i]-A[j]!=0) all_n++;
            }
        }
    }
    printf("%d", all_n);
}


Measured memory_bytes: 3724
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    ll a, b; cin>>a>>b;
    cout<<max({a+b, a-b, a*b})<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
//#define int ll
#define pb push_back
#define __bp __builtin_popcount
using vint = vector<int>;
using pii = pair<int,int>;
using pdd = pair<ld,ld>;
using vpii = vector<pii>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(2) << fixed;
}

int n, a[N];

signed main()
{
	io();
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = k; i < n; ++i)
	{
		cout << (a[i] > a[i - k] ? "Yes\n": "No\n");
	}
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vi dp(3);
    for(int day=0;day<n;day++)
    {
        vi new_dp(3,0);
        vi c(3);
        for(int i=0;i<3;i++) cin>>c[i];
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(i!=j)
                {
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    int ans=max(dp[0],dp[1]);
    ans=max(ans,dp[2]);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];
 bool appear[3][3];
map<int,bool> mp;
 int main() {
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
  for(int i = 0; i < N; i++) {cin >> b[i];mp[b[i]]=1;}
 for(int i = 0; i < N; i++) {
 for(int j = 0; j < N; j++) {
 appear[i][j] = mp[A[i][j]];
 
 }
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
//>:(
void solve() {
    int n;
    cin >> n;
    vector<int> v(n),dp(n+1,0);
    for(int i=0;i<n;i++) cin >> v[i];
    set<int> s;
    for(int i=0;i<n;i++) {
        auto it = s.find(v[i]-1);
        if(it==s.end()) {
            dp[v[i]]=1;
        } else {
            dp[v[i]] = dp[v[i]-1]+1;
        }
        s.insert(v[i]);
    }

    int x = *max_element(dp.begin(),dp.end());
    cout << n-x << "\n";

}

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

    solve();
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;
const double PI = acos(-1.0);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

unsigned GetDigit(unsigned num)
{
    return std::to_string(num).length();
}

int main()
{
    int n, l, r;
    string s;
    cin >> n;

    vector<vector<int>> data(10, vector<int>(10, 0));

    for (int t = 1; t <= n; t++)
    {
        s = to_string(t);
        l = s[0] - 48;
        r = s[s.size() - 1] - 48;
        if (t <= n)
        {
            data.at(l).at(r) += 1;
        }
    }
    int ans = 0;
    rep(i, 10)
    {
        rep(j, 10)
        {
            ans += data.at(i).at(j) * data.at(j).at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
if y % 2 != 0:
    print("No")
elif y % 2 == 0:
    s  = "A"
    for i in range(0,101):
        for j in range(0,101):
            if 2*i + 4*j == y and i + j == x:
                print("Yes")
                exit()
            else:
                s = "No"
    print(s)

Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int status, m, f, r;
    string g, h;
    int const fail = -1;
    h = "EABCDF";
    g = "A";
    status = 1;
    while(status){
      cin >> r >> m >> f;
        if (r == fail && m == fail && f == fail) status = 0;
        else{
            if (m == fail || r == fail || m+r < 30) g = h[5];
            else if (m+r < 50){
                if (f >= 50) g = h[3];
                else g = h[4];
            }
            else if (m+r < 65) g = h[3];
            else if (m+r < 80) g = h[2];
		cout << g << endl;
        }
        
    }
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define MAX_V 110

int main() {
    
    vector<vector<int>> G(MAX_V);
    int n; cin >> n;
    for(int i=0; i<n; i++){
        int v, k; cin >> v >> k;

        for(int j=0; j<k; j++){
            int u; cin >> u;
            G[v].push_back(u);
        }
    }

    vector<int> dist(MAX_V, -1);
    dist[1] = 0;

    queue<int> q;
    q.push(1);
    while(!q.empty()){

        int v = q.front();
        q.pop();

        for(int i=0; i<G[v].size(); i++){
            int u = G[v][i];
            if(dist[u] == -1){
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }

    for(int i=1; i<=n; i++){
        cout << i << " " << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3132