akhauriyash/Code-Regression huggingface dataset:
let n = Int(readLine()!)!
let h=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var p : Int = h[0]
var c = 0
var max_c = 0
for i in 1..<n {
  //print( h[i] )
  if( h[i] <= p ) {
    c += 1
    if( c > max_c ) {
      max_c = c
    }
  } else {
    c = 0
  }
  
  p = h[i]
}

print( max_c )

Measured memory_bytes: 7608
#include<stdio.h>
int main(){
    int a,b,c,i,g;
    float t;
    g=0; 
    scanf("%d%d%d",&a,&b,&c);
for  (i=a;i<=b;i++) 
{t=c%i;
if (t==0){g=g+1;}
}
    printf("%d\n",g);
    return 0 ;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	string s;
	cin >> s;
	int ans = 0;
	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 ans = 1;
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <map>
#include <set>
#include <ctime>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
 
#define mod 1000000007
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define log(x) cout << (x) << endl;
 


int mod_pow(ll n, ll x, int m) {
	int r = 1;
	while (x) {
		if (x&1) {
			r = (r * n)%m;
			--x;
		} else {
			n = (n * n)%m;
			x >>= 1;
		}
	}
	return r;
}



int main() {
	fast();
 
	int n,x;
	cin >> n;
	map<int,int> freq;
	rep(i,n) cin>>x, freq[x]++;

	ll r = 1;

	if (freq[0] > 1)
		r = 0;
	else
		// r = mod_pow(2, n>>1, mod);
		for (int i=0,k=n-1; i<(n>>1); ++i, k-=2) {
			r = ((r%mod) * (freq[k]%mod))%mod;
		}

	cout << r << endl;
 
	return 0;
}




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

ll power(ll a,ll b){
  ll ans=1;
  for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

int main(){
string S;
  cin>>S;
  ll  K;
  cin>>K;
  
  for(ll i=0;i<S.size();i++){
    if(S[i]=='1'){
      K--;
       
    if(K<=0){
      cout<<S[i]<<endl;
      break;
    }
    }

    else{
      if(S.size()==1){
        cout<<S[i]<<endl;
        break;
      }
else{
cout<<S[i]<<endl;
  break;
}
    }
   
  }

}
    
    


Measured memory_bytes: 256
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
ans = 0
for i in range(1,N):
  ans += N//i
  if N%i == 0:
    ans -= 1
print(ans)

Measured memory_bytes: 63132
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    bool f=false;
    for(int i=0;i<=n;i++) {
        for(int j=0;j<=m;j++)
            if(i*m+j*n-2*i*j==k) f=true;
    }
    puts(f?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0,low;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    low=arr[0];
    for(i=0;i<n;i++){
        if(arr[i]<=low)
            ans+=1;
        low=min(low,arr[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int MAX_N = 1e5 + 5;
const int INF = 0x7fffffff;
const double eps = 1e-6;


int n, m;
int l, r, d;
struct Edge
{
    int to;
    int w;
    int next;
}edge[4*MAX_N];

int head[MAX_N];
int cnt;

void addedge(int u, int v, int w)
{
    edge[cnt].w = w;
    edge[cnt].to = v;
    edge[cnt].next = head[u];
    head[u] = cnt++;
}
int x[MAX_N];
bool flag;
bool vis[MAX_N];
bool ex[MAX_N];
bool ed[4*MAX_N];

void dfs(int u)
{
    vis[u] = true;

    for(int i=head[u]; ~i && !ed[i]; i=edge[i].next) {
        ed[i] = true;
        int v = edge[i].to, w = edge[i].w;
        //cout << u << " " << v << " " << w << endl;
        int tmp = x[u] + w;
        if(!vis[v]) {
            x[v] = tmp;
        } else {
            if(x[v] != tmp) {
                flag = false;
                return;
            }
        }
        dfs(v);
    }
}

int main()
{
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    ios::sync_with_stdio(false);
    flag = true;
    memset(head, -1, sizeof(head));
    cin >> n >> m;
    REP(i, 1, m+1) {
        cin >> l >> r >> d;
        addedge(l, r, d);
        addedge(r, l, -d);
        ex[l] = ex[r] = true;
    }

    REP(i, 1, n+1) {
        if(!vis[i] && ex[i] && flag) dfs(i);
    }

    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main(void)
{
    int i,j,k,l;
    int count;
    int min,max;
    long sum=0;

    int *a=NULL;

    scanf("%d",&count);

    a =(int *)malloc(count*sizeof(int));
    if(a == NULL){
        return 0;
    }

    for(i=0;i<count;i++){
        if(i==0){
            scanf("%d",&a[i]);
        }
        else{
            scanf(" %d",&a[i]);
        }
    }

    /* 最小値を求める */
    min = a[0];

    for(j=1;j<count;j++){
        if(min > a[j]){
            min = a[j];
        }
    }

    /* 最大値を求める */
    max = a[0];

    for(k=1;k<count;k++){
        if(max < a[k]){
            max = a[k];
        }
    }

    /* 合計値 */
    for(l=0;l<count;l++){
        sum += a[l];
    }

    printf("%d %d %ld\n",min,max,sum);

    free(a);
    return 0;
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll A, B, C;
  ll K;
  cin >> A >> B >> C;
  cin >> K;

  while(A >= B){
    if(K == 0){
      cout << "No" << endl;
      return 0;
    }
    K--;
    B *= 2;
  }
  while(B >= C){
    if(K == 0){
      cout << "No" << endl;
      return 0;
    }
    K--;
    C *= 2;
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){

  char numbers[4] = {};
  
  cin >> numbers;
  
    if(numbers[1] == numbers[2] && (numbers[1] == numbers[0] || numbers[1] == numbers[3]) ){
        
        cout << "Yes" << endl;
        
    }else{
        
        cout << "No" << endl;
        
    }
  
  
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    ll R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

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

int main(){
  string S;
  cin >> S;
  int slen = S.length();
  int rlen = 1;
  int llen = 1;
  vector<int> A(slen,0);
  for(int i=0;i<slen;i++){
    if(S[i]=='R'){
      if(S[i+1]=='L'){
        A[i] += (rlen+1)/2;
        A[i+1] += rlen/2;
        rlen = 1;
      }
      else if(S[i+1]=='R'){
        rlen ++;
      }
    }
  }
  for(int j=slen-1;j>=0;j--){
    if(S[j]=='L'){
      if(S[j-1]=='R'){
        A[j] += (llen+1)/2;
        A[j-1] += llen/2;
        llen = 1;
      }
      else if(S[j-1]=='L'){
        llen ++;
      }
    }
  }
  for(int k=0;k<slen;k++){
    cout << A[k];
    if(k!=slen-1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n ;
    cin >> n ;
    if (n >= 30)    cout << "Yes\n" ;
    else    cout << "No\n" ;

    return 0 ;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int a, b, c;
  char p, q;
  cin >> a >> p >> b >> q >> c;
  if(b >= 5) cout << "TBD";
  else cout << "Heisei";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - a + b) << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int r=scan.nextInt();
    String n=scan.next();
    String[] echo=n.split("");
    int flag=1;
    if(r%2==1){
      flag=0;
    }else{
      for(int a=0; a<r/2; a++){
        if(!echo[a].equals(echo[a+r/2])){
          flag=0;
        }
      }
    }
    if(flag==1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))


def func(a, judge):
    sum_list = list(accumulate(a))
    x = 0
    num = 0

    length = len(sum_list)

    for i in range(length):
        if judge and sum_list[i] + x <= 0:
            num += 1 - (sum_list[i] + x)
            x += 1 - (sum_list[i] + x)

        if (not judge) and sum_list[i] + x >= 0:
            num += 1 + (sum_list[i] + x)
            x -= 1 + (sum_list[i] + x)

        judge = not judge

    return num


ans = min([func(A, True), func(A, False)])

print(ans)


Measured memory_bytes: 14340
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

vector<int> dig;

bool ok(int x) {
    while(x) {
        ll curr = x % 10;
        x /= 10;
        for(auto it : dig) {
            if(it == curr) {
                return false;
            }
        }
    }
    return true;
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i ++) {
        int a;
        cin >> a;
        dig.push_back(a);
    }
    while(!ok(n)) {
        n ++;
    }
    cout << n << endl;
    return 0;
}




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

bool compare(pair<ll,ll> a, pair<ll,ll> b)
{
  if (a.first != b.first) {
    return a.first > b.first;
  }
  return a.second > b.second;
}

int main()
{
  ll N;
  scanf("%lld",&N);
  ll M;
  scanf("%lld",&M);
  vector<vector<ll>> t(100010);
  for(int i=0; i<N; i++){
    ll a,b;
    scanf("%lld",&a);
    scanf("%lld",&b);
    t[a].push_back(b);
  }

  ll ans = 0;
  priority_queue<ll> pq;
  for (int i=1; i<=M; i++) {
    for (auto v:t[i]) pq.push(v);
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <cmath>

using namespace std;

int debt(int a){
    if (a == 0){
        return 100000;
    }
    else{
        float b;
        b = ceil(debt(a-1)*1.05/1000);
        return int(b*1000);
    }
}

int main(){
    int n;
    cin >> n;
    cout << debt(n) << endl;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , a[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        int cnt = 0;
        for( int i = 1; i <= n; i++ ) if( i != a[i] ) cnt++;
        if( cnt == 0 || cnt == 2 ) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
}





Measured memory_bytes: 256
function main()
  
  S = chomp(readline())
  T = chomp(readline())
  N = length(S)

  dict1 = Dict()
  dict2 = Dict()
  
  for i in 1:N
    dict1[S[i]] = get(dict1, S[i], 0 + i)
    dict2[T[i]] = get(dict2, T[i], 0 + i)
  end
  
  check1 = []
  check2 = []
  
  for i in 1:N
    push!(check1, dict1[S[i]])
    push!(check2, dict2[T[i]])
  end

  if check1 == check2
    println("Yes")
  else
    println("No")
  end
  
end

main()

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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, cnt[maxn], deg[maxn];
vector <ll> adj[maxn];
bool mark[maxn];
vector <ll> q1, q2;
string ans = "Second";

void print() {
	for (auto i : q1)
		cout << i << " ";
	cout << endl;
}

int main() {
	fio();
	cin >> n;
	for (int i = 1; i < n; i++) {
		ll fr, to;
		cin >> fr >> to;
		fr--;
		to--;
		adj[fr].pb(to);
		adj[to].pb(fr);
		deg[fr]++;
		deg[to]++;	
	}
	for (int i = 0; i < n; i++) {
		if (deg[i] == 1)
			q1.pb(i);	
	}
	while (true) {
		for (int i = 0; i < q1.size(); i++) {
		//	cout << "1: " << q1[i] << endl;
			mark[q1[i]] = true;
			for (auto u : adj[q1[i]]) {
				if (!mark[u]) {
					cnt[u]++;
					q2.pb(u);	
				}
			}
		}
		q1.clear();
		for (int i = 0; i < q2.size(); i++) {
	//		cout << "2: " << q2[i] << endl;
			mark[q2[i]] = true;
			if (cnt[q2[i]] > 1) {
				cout << "First" << endl;
				return 0;	
			}
			for (auto u : adj[q2[i]]) {
				if (!mark[u]) {
					deg[u]--;
					if (deg[u] == 1) {
						q1.pb(u);	
					}
					if (deg[u] < 1) {
						cout << "First" << endl;
						return 0;	
					}
				}
			}
		}
		q2.clear();
		if (q1.empty())
			break;
	}
	cout << "Second" << endl;
}


Measured memory_bytes: 9084
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

typedef struct
{
    ll u, v, w;
} Edge;

int N;
vector<vector<P>> adj;
vector<ll> d;

void dfs(int n, int dist)
{
    d[n] = dist;
    REP(i, adj[n].size())
    {
        if(d[adj[n][i].first] == INF) dfs(adj[n][i].first, dist+adj[n][i].second);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    cin >> N;
    adj.resize(N+1);
    REP(i, N-1)
    {
        int u, v, w; cin >> u >> v >> w;
        w %= 2;
        adj[u].push_back(make_pair(v, w));
        adj[v].push_back(make_pair(u, w));
    }
    d.resize(N+1, INF);
    dfs(1, 0);
    REPS(i, N) cout << d[i]%2 << endl;
}

Measured memory_bytes: 7808
import math

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

N,D= map(int,input().split())
X = []
for i in range(N):
    x = list(map(int,input().split()))
    X.append(x)

count = 0
Dis = 0
Dis2 = 0
for i in range(N-1):
    for j in range(i+1,N):
        for d in range(D):
            Dis2+=(X[i][d]-X[j][d])**2
        Dis = math.sqrt(Dis2)
        if is_integer_num(Dis):
            count+=1
        Dis2 = 0
print(count)

Measured memory_bytes: 3064
fn main() {
    let n = read::<usize>();

    let p1 = Cordinate {x: 0.0, y: 0.0};
    let p2 = Cordinate {x: 100.0, y: 0.0};

    println!("{:.8} {:.8}", p1.x, p1.y);
    kock(n, &p1, &p2);
    println!("{:.8} {:.8}", p2.x, p2.y);
}

#[derive(Debug)]
struct Cordinate{
    x: f64,
    y: f64,
}

fn kock(n: usize, p1: &Cordinate, p2: &Cordinate) {
    if n == 0 {
        return;
    }

    let s = cul_s(&p1, &p2);
    let t = cul_t(&p1, &p2);
    let u = cul_u(&t, &s);

    kock(n - 1, &p1, &s);
    println!("{:.8} {:.8}", s.x, s.y);
    kock(n - 1, &s, &u);
    println!("{:.8} {:.8}", u.x, u.y);
    kock(n - 1, &u, &t);
    println!("{:.8} {:.8}", t.x, t.y);
    kock(n - 1, &t, &p2);
}

fn cul_s(p1: &Cordinate, p2: &Cordinate) -> Cordinate {
    Cordinate { 
        x: (2.0 * p1.x + p2.x) / 3.0,
        y: (2.0 * p1.y + p2.y) / 3.0
    }
}

fn cul_t(p1: &Cordinate, p2: &Cordinate) -> Cordinate {
    Cordinate {
        x: (p1.x + 2.0 * p2.x) / 3.0,
        y: (p1.y + 2.0 * p2.y) / 3.0
    }
}

fn cul_u(t: &Cordinate, s: &Cordinate) -> Cordinate {
    let num = std::f64::consts::PI / 3.0;
    let cos60 = num.cos();
    let sin60 = num.sin();
    Cordinate {
        x: (t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x,
        y: (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y
    }
}

/// 標準入力から一行を読み取り、指定の型に変換する関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 5032
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] variation = new int[N];
		int count = 0;
		int i,j,k =0;
		int[] max = new int[N];
		
		for(i=0;i<N;i++){
			variation[i] = sc.nextInt();
		}
		
		for(j=0;j<N;j++){
			X = X - variation[j];
			count++;
		}
		
		for(k=0;k<N;k++){
			max[k]=X/variation[k];
		}
		
		for(j=0;j<N;j++){
			for(k=j+1;k<N;k++){
				if(max[k]>max[j]){
					int t = max[k];
					max[k] = max[j];
					max[j] = t;
				}
			}
		}
		
		count = count + max[0];
		
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 1e5 + 10101;

int n;
int a[N];

int main() {		
	scanf ("%d", &n);
	rep(i, 1, n) scanf ("%d", a + i);
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	int x = 0;
	int y = 0;
	while (true) {
		if (x + 2 > n || a[x + 2] <= y + 1) break;
		x++;
		y++;
	}
	int q = a[x + 1] - y;
	int w = 0;
	while (x + 1 <= n && y < a[x + 1]) {
		w++;
		x++;
	}
	if (q % 2 == 0 || w % 2 == 0) printf ("First\n");
	else printf ("Second\n");
	
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    
    ll ans=0;
    ans+=(N-M)*100;
    ans+=M*1900;
    ans*=pow(2,M);
    cout1(ans)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int a, b, c, x;
  int count = 0;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k == x) count++;
      }
    }
  }
  cout << count << endl;
}

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

using namespace std;
struct UnionFind{
	vector<long long>data;
	UnionFind(long long sz){
		data.assign(sz,-1);
	}
	bool unite(long long x,long long y){
		x=find(x),y=find(y);
		if(x==y)return (false);
		if(data[x]>data[y])swap(x,y);
		data[x]+=data[y];
		data[y]=x;return (true); 
	}
	long long find(long long k){
    	if(data[k]<0)return (k);
		return (data[k]=find(data[k]));
	}
	long long size(int k){
    	return (-data[find(k)]);
	}
};
int main(){
	long long a[100005],b[100005];
	long long n,m;
	cin>>n>>m;
	UnionFind u(n);
	for(long long i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--; 
	}
	long long res=0;
	vector<long long>ans(m);
	for(long long i=0;i<m;i++)ans[i]=0;
	for(long long i=m-1;i>=0;i--){
		ans[i]=1LL*n*(n-1)/2-res;
		if(u.find(a[i])!=u.find(b[i])){
			res+=1LL*u.size(a[i])*u.size(b[i]);
    		u.unite(a[i],b[i]);
		}
	}
	for(long long i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4480
// in the name of god 
// vaght hast vali kam ast !

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

const int MAXN = 1e6 + 100 ;

int a[MAXN] ; 
int32_t main(){
	ios_base::sync_with_stdio(0) ;
	cin . tie(0) ; cout . tie(0) ; 

	int n , m ; cin >> n >> m ; 
	for(int i = 0 ; i < m ; i ++){
		int x , y ; cin >> x >> y ; 
		x -- , y -- ; 
		a[x] ++ ; 
		a[y] ++ ; 
	}
	for(int i = 0 ; i < n ; i ++)
		if(a[i] % 2)return cout << "NO" , 0 ; 
	cout << "YES" ; 
}

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

using namespace std;

vector<vector<int>> v(50);

bool dfs(vector<int> u, int n, int p, int s);

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		v[a].emplace_back(b);
		v[b].emplace_back(a);
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		vector<int> u(n);
		if (dfs(u, i, i, i)) {
			ans++;
		}
	}

	cout << (ans == n ? ans - 1 : ans) << endl;

	return 0;
}

bool dfs(vector<int> u, int n, int p, int s)
{
	if (n != p && n == s) {
		return false;
	}

	if (u[n] != 0) {
		return true;
	}
	u[n] = 1;

	for (auto & i : v[n]) {
		if (i == p) {
			continue;
		}

		if (!dfs(u, i, n, s)) {
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n;
    cin >> n;
    nfor(i, 1, 10)nfor(j, 1, 10)if(n == i * j){Yes;return 0;}
    No;
    return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N,T= map(int,input().split())

c=[]
t=[]
m=10000
cnt=0
C=[list(map(int,input().split())) for _ in range(N)]

for j in range(N):
	if C[j][1]>T:
		cnt+=1
	else:
		m=min(C[j][0],m)
		

	

if cnt==N:
	print("TLE")
else:
	print(m)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    while((b > 0) && (c > 0)){
        --c;
        --b;
        ans += 2;
    }
    if(b == 0){
        while((a > 0) && (c > 0)){
            --c;
            --a;
            ++ans;
        }
        if(c > 0) ++ans;
    }
    else {
        ans += b;
    }

    printf("%d\n", ans);
    return 0;
}

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

for i in range(1, n + 1):
    if i % 3 == 0:
        print(" {}".format(i), end="")
    else:
        x = i
        while x:
            if x % 10 == 3:
                print(" {}".format(i), end="")
                break
            x //= 10
print()


Measured memory_bytes: 5868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);
    int z = Integer.parseInt(sl[1]);


    System.out.println(z + ((100 * (10 - n)) > 0 ? (100 * (10 - n)) : 0));
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  int ans = 10e9;
  rep(i,n){
    cin >> w[i];
  }
  rep1(i,n){
    int l=0,r=0;
    for(int j=0;j<i;j++)l+=w[j];
    for(int j=i;j<n;j++)r+=w[j];
    ans = min(ans,abs(l-r));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	map<string,int> mp;
	for(int i=0;i<N;i++){
		string S;
		cin>>S;
		mp[S]++;
	}
	
	int maxi = 0;
	
	for(auto a:mp){
		maxi = max(maxi,a.second);
	}
	
	for(auto a:mp){
		if(a.second==maxi){
			cout<<a.first<<endl;
		}
	}
	
    return 0;
}



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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, root, first;
char s[max_n];
vector<int> g[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%s", s + 1);
    n = strlen(s + 1);
    if (s[1] == '0' || s[n] == '1') {
        puts("-1");
        return 0;
    }
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[n - i]) {
            puts("-1");
            return 0;
        }
    }
    s[n] = '1';
    root = 1;
    int sz = 1;
    first = 2;
    for (int i = 2; i <= n; ++i) {
        if (s[i] == '1') {
            g[first].push_back(root);
            root = first;
            ++first;
            ++sz;
            while (sz < i) {
                g[root].push_back(first);
                ++first;
                ++sz;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int to : g[i]) {
            printf("%d %d\n", i, to);
        }
    }
    return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long int lli;

int main()
{
	int n;
	cin>>n;
	if (n%2==0)
		cout<<n/2<<endl;
	else
		cout<<(n/2)+1<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2e5+500;
const long long INF=1e18;
int head,tail,n,E,T,x[N],q[N];
long long f[N],g1[N],g2[N];
int main()
{
    scanf("%d%d%d",&n,&E,&T);
    long long mi=INF;
    for(int i=1;i<=n;i++)scanf("%d",x+i);
    int j=0;g1[0]=-2*x[1],g2[0]=T;
    int head=1,tail=1;q[1]=0;
    for(int i=1;i<=n;i++)
    {
        while(j<i&&2*x[j+1]<=2*x[i]-T)mi=min(mi,g1[j]),++j;
        while(head<=tail&&q[head]<j)++head;
        f[i]=3ll*x[i]+mi;
        if(head<=tail)f[i]=min(f[i],x[i]+g2[q[head]]);
        g1[i]=f[i]-x[i]-2*x[i+1];
        g2[i]=f[i]+T-x[i];
        while(head<=tail&&g2[i]<=g2[q[tail]])--tail;q[++tail]=i;
    }
    cout<<f[n]+E-x[n]<<endl;
}

Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a+b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
//    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#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++)
const long long INF =  ll(1e18)+1;
ll a[200020];

int main(){
  ll N,K;
  cin>>N>>K;
  rep(i,N)cin>>a[i];
  sort(a,a+N);
  ll l=-INF,r=INF;
  while(l+1<r){
    ll x=(l+r)/2;
    bool ok =[&]{
      ll tot=0;
      rep(i,N){
        if(a[i]<0){
          int l=-1,r=N;
          while(l+1<r){
            int m=(l+r)/2;
            if(a[m]*a[i]<x)r=m;
            else l=m;
          }
          tot+=N-r;
        }
        else{
          int l=-1,r=N;
          while(l+1<r){
            int m=(l+r)/2;
            if(a[m]*a[i]<x)l=m;
            else r=m;
          }
          tot+=r;
        }
        if(a[i]*a[i]<x)tot--;
      }
      tot=tot/2;
      //条件を満たす数のペアがk未満ならok//
      return tot<K;
    }();
    if(ok)l=x;
    else r=x;
  }
  cout<<l<<endl;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


blue = K
red = N - K

for i in range(1, K+1):
    try:
        pos = i 
        red_c = combinations_count(red+1, pos)


        blue_c =  combinations_count(blue - 1, i - 1)
        #print(red_c, blue_c)
        print(red_c * blue_c % (10 ** 9 + 7))
    except:
        print(0)
    
    
    

Measured memory_bytes: 68056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N; cin>>N;
  vector<pair<string,pair<int,int> > > V(N);
  rep(i,N){
    string S; cin>>S;
    int P; cin>>P;
    V[i]={S,{-P,i+1}};
  }
  sort(V.begin(),V.end());
  rep(i,N) cout<<V[i].second.second<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K;
int main(){

    cin >> N >> K;
    double sum = 0;
    for(int i = 1; i <= N; i++){
        double tmp = 1;
        for(int j = 0; ; j++){
            if(i * (1 << j) >= K){
                break;
            }
            tmp *= 0.5;
        }
        sum += tmp * (1.0/N);
    }
    printf("%.10f\n", sum);

    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveB2();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();

			if (numN % numK == 0) {
				System.out.println(0);
			} else {
				System.out.println(1);
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int isPurchase(int numN, int num) {

		if (numN <= 0) {
			return numN;
		}
		if (bWkMap.get(numN) != null) {
			return bWkMap.get(numN);
		}

		int val1 = isPurchase(numN - 7, 4);
		int val2 = isPurchase(numN - 7, 7);
		int val3 = isPurchase(numN - 4, 4);
		int val4 = isPurchase(numN - 4, 7);

		val1 = val1 < 0 ? 999999999 : val1;
		val2 = val2 < 0 ? 999999999 : val2;
		val3 = val3 < 0 ? 999999999 : val3;
		val4 = val4 < 0 ? 999999999 : val4;

		int wk = Math.min(Math.min(val1, val2), Math.min(val3, val4));

		bWkMap.put(numN, wk);
		return wk;
	}

	private Map<Integer, Integer> bWkMap = new HashMap<Integer, Integer>();

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int val = isPurchase(numN, 0);

			System.out.println(val == 0 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB2() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			for (int i = 0; i < 25; i++) {
				for (int j = 0; j < 15; j++) {
					if (4 * i + 7 * j == numN) {
						System.out.println("Yes");
						return;
					}
				}
			}
			System.out.println("No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			long wk = 0;
			while (wk == numN) {

			}

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 3e5 + 5;

int main()
{
    fastRead;
    int n;
    cin>>n;
    vector<int>vec(n+1);
    for(int i =1 ; i < n ; i++ ) {
        int tmp;
        cin>>tmp;
        vec[tmp]++;
    }
    
    for(int i = 1 ; i <=n ; i++ ) cout<<vec[i]<<'\n';
    return 0;
}

Measured memory_bytes: 3984
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        IEnumerable<int> Div(int a, int b)
        {
            for (int i = 100; i > 0; i--)
            {
                if (a % i == 0 && b % i == 0)
                    yield return i;
            }
        }
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var A = line[0];
            var B = line[1];
            var K = line[2];

            var divs = Div(A, B).ToArray();

            return divs[K - 1];
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


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

int main() {
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define fi first
#define se second
signed main(){
  int k,n,s=0;
  int a[1000000];
  int b[1000000];
  cin>>k>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i!=0){
      b[i-1]=a[i]-a[i-1];
      s+=b[i-1];
    }
  }
  b[n-1]=(k-a[n-1])+a[0];
  s+=b[n-1];
  int q=10000000;
  for(int i=0;i<n;i++){
    q=min(q,s-b[i]);
  }
  cout<<q<<"\n";
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

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

Measured memory_bytes: 256
import sys
import heapq

N, M = list(map(int, input().split()))
possiblyValidJobs = {}
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue

    if A in possiblyValidJobs:
        possiblyValidJobs[A].append(B)
    else:
        possiblyValidJobs[A] = [B]

validJobsOnThisDay = []
ans = 0
for daysBeforeDeadline in range(1, M + 1):
    if daysBeforeDeadline in possiblyValidJobs:
        for wage in possiblyValidJobs[daysBeforeDeadline]:
            heapq.heappush(validJobsOnThisDay, -wage)
    if validJobsOnThisDay:
        ans += -heapq.heappop(validJobsOnThisDay)
print(ans)


Measured memory_bytes: 26020
import Control.Monad (mapM_)
import Data.List (intercalate)

main =
  getLine >>
    getLine >>=
      mapM_ putStrLn . solve . map (read :: String -> Int) . words

solve :: [Int] -> [String]
solve xs = [intercalate " " (map show ys), show c]
  where
    (c, ys) = bsort (0, xs)

bsort :: (Ord a) => (Int, [a]) -> (Int, [a])
bsort (c, []) = (c, [])
bsort (c, xs) = (nnc, y : zs)
  where
    (nnc, zs) = bsort (nc, ys)
    (nc, (y:ys)) = bsort' (c, xs)

bsort' :: (Ord a) => (Int,[a]) -> (Int,[a])
bsort' (c, [x]) = (c, [x])
bsort' (c, (x:xs))
  | x <= y = (nc, x:y:ys)
  | otherwise = (nc+1, y:x:ys)
  where
    (nc, (y:ys)) = bsort' (c, xs)



Measured memory_bytes: 4372
s = input()
first = int(s[0:2])
second = int(s[2:4])
if 1 <= first <= 12 and 1 <= second <= 12:
    print('AMBIGUOUS')
elif 1 <= first <= 12:
    print('MMYY')
elif 1 <= second <= 12:
    print('YYMM')
else:
    print('NA')

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n; cin >> n;
    vvl A(n, vl(n));
    rep(i,n) rep(j,n) cin >> A[i][j];
    vvl dp(n+1, vl(1<<n));

    rep(i,n) dp[i][0] = 1;
    rep(i,n){
        rep(k,1<<n){
            if(i != __builtin_popcountll(k)) continue;
            rep(j,n){
                int mask = 1 << j;
                if(A[i][j] && !(k & mask)){
                    dp[i+1][k|mask] += dp[i][k];
                    dp[i+1][k|mask] %= mod;
                }
            }
        }
    }
    cout << dp[n][(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 377216