akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

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

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

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

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string n;
	cin>>n;
	bool flag=false;
	rep(i,3)if(n.at(i)=='7')flag=true;
	cout<<(flag?"Yes":"No")<<endl;
}


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

int main()
{
	int64_t n, m, x;
	cin >> n >> m >> x;
	vector<int64_t> cs(n);
	vector<vector<int64_t>> ass(n, vector<int64_t>(m));
	for (int64_t i = 0; i < n; i++)
	{
		cin >> cs[i];
		for (auto &&a : ass[i])
		{
			cin >> a;
		}
	}

	int64_t inf = (1LL << 60);

	int64_t ans = inf;

	for (int64_t i = 0; i < (1LL << n); i++)
	{
		int64_t tmp = 0;

		vector<int64_t> bs(m, 0);

		for (int64_t j = 0; j < n; j++)
		{
			if (i & (1LL << j))
			{
				tmp += cs[j];
				for (int64_t k = 0; k < m; k++)
				{
					bs[k] += ass[j][k];
				}
			}
		}

		bool f = true;
		for (auto &&b : bs)
		{
			f &= (x <= b);
		}

		if (f)
		{
			ans = min(ans, tmp);
		}
	}

	if (ans == inf)
	{
		cout << -1 << endl;
		return 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<complex>
#include<vector>
#include<queue>
#include<stack>
#include<functional>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;

const ll INF = 1ll<<60;

struct Edge {
    int end;
    ll cost;
};

struct Vertex {
    ll dist[3];
    bool used[3];
    vector<Edge> edges;
    Vertex() {
        REP(i, 3) {
            dist[i] = INF;
            used[i] = false;
        }
    }
};

struct Node {
    int index;
    int state; // 0, 1, 2
};

ll solve() {
    int N, M;
    scanf("%d%d", &N, &M);
    if (N==0 && M==0) return -1;

    Vertex vertices[N];
    REP(i, M) {
        int a, b; ll c;
        scanf("%d%d%lld", &a, &b, &c);
        a--; b--;
        vertices[a].edges.push_back((Edge){b, c});
        vertices[b].edges.push_back((Edge){a, c});
    }

    priority_queue<Node, vector<Node>, function<bool(Node&, Node&)>> queue([&](Node& a, Node& b){
        if (a.state==b.state) return vertices[a.index].dist[a.state] > vertices[b.index].dist[b.state];
        return a.state > b.state;
    });
    vertices[0].dist[0] = 0;
    queue.push((Node){0, 0});
    while(!queue.empty()) {
        Node n = queue.top(); queue.pop();
        if (vertices[n.index].used[n.state]) continue;
        vertices[n.index].used[n.state] = true;
        for(auto& edge: vertices[n.index].edges) {
            if (n.state==0 || n.state==2) {
                if (vertices[n.index].dist[n.state]+edge.cost < vertices[edge.end].dist[n.state]) {
                    vertices[edge.end].dist[n.state] = vertices[n.index].dist[n.state]+edge.cost;
                    queue.push((Node){edge.end, n.state});
                }
            }
            if (n.state==0 || n.state==1) {
                if (vertices[n.index].dist[n.state] < vertices[edge.end].dist[n.state+1]) {
                    vertices[edge.end].dist[n.state+1] = vertices[n.index].dist[n.state];
                    queue.push((Node){edge.end, n.state+1});
                }
            }
        }
    }
    return min(vertices[N-1].dist[0], vertices[N-1].dist[2]);
}

int main() {
    ll ans;
    while((ans=solve())>=0) {
        printf("%lld\n", ans);
    }
    return 0;
}

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

int main(){
  int n,x[100],y[100];
  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<n;i++) cin>>y[i];

  double d[4]={};

  for(int p=1;p<=3;p++){
    for(int i=0;i<n;i++){
      d[p] +=pow(fabs(x[i]-y[i]),p);
    }
    d[p]=pow(d[p],1.0/p);
  }
  for(int i=0;i<n;i++){
    d[0]=(d[0]<fabs(x[i]-y[i])?fabs(x[i]-y[i]):d[0]);
  }
  printf("%lf\n",d[1]);
  printf("%lf\n",d[2]);
  printf("%lf\n",d[3]);
  printf("%lf\n",d[0]);
  
  return 0;
}
    



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

vector<int> fact[1000005];
int vis[1000005];
int cnt[1000005];

void pre()
{
    ffor(i,1,1000005)
    {
        for(int j=i;j<1000005;j+=i) fact[j].pb(i);
    }
}

int main()
{
    

    pre();

    int n;
    cin>>n;
    int a[n];
    ffor(i,0,n) { cin>>a[i]; cnt[a[i]]++; }
    sort(a,a+n);
    int ans=0;
    ffor(i,0,n)
    {
        int f=0;
        if(cnt[a[i]]>1)
        {
            vis[a[i]]=1;
            continue;
        }
        for(auto j:fact[a[i]]) if(vis[j]) f=1;
        if(!f) ans++;
        vis[a[i]]=1;;
    }
    cout<<ans;
    
    return 0;
}



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

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    int N;
    cin >> N;
    vector<vector<string> > vec(10, vector<string>(0));
    vec[0].push_back("0");
    rep(i,9){
        for (int j = 0; j < vec[i].size(); j++){
            int x = 0;
            rep(k,i + 1){
                x = max(x, ctoi(vec[i][j][k]));
            }
            for (int k = 0; k <= x + 1; k++){
                vec[i + 1].push_back(vec[i][j] + to_string(k));
            }
        }
    }
    rep(i, vec[N - 1].size()){
        rep(j, N){
            if (ctoi(vec[N - 1][i][j]) == 0) cout << 'a';
            if (ctoi(vec[N - 1][i][j]) == 1) cout << 'b';
            if (ctoi(vec[N - 1][i][j]) == 2) cout << 'c';
            if (ctoi(vec[N - 1][i][j]) == 3) cout << 'd';
            if (ctoi(vec[N - 1][i][j]) == 4) cout << 'e';
            if (ctoi(vec[N - 1][i][j]) == 5) cout << 'f';
            if (ctoi(vec[N - 1][i][j]) == 6) cout << 'g';
            if (ctoi(vec[N - 1][i][j]) == 7) cout << 'h';
            if (ctoi(vec[N - 1][i][j]) == 8) cout << 'i';
            if (ctoi(vec[N - 1][i][j]) == 9) cout << 'j';
        }
        cout << endl;
    }
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(n,b-1);
    cout<<a*x/b-a*(x/b);
    return 0;
}



Measured memory_bytes: 3616
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string

	fmt.Scan(&s)
	var a, _ = strconv.ParseUint(s, 10, 32)

	var count int = 0

	if a/100 == 1 {
		count++
		a -= 100
	}
	if a/10 == 1 {
		count++
		a -= 10
	}
	if a == 1 {
		count++
	}

	fmt.Printf("%d\n", count)
}

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

int main() {
	int A = 0, B = 0, C = 0;
	cin >> A >> B >> C;

	int m = 0, day = 0;
	while(m < C) {
		day++;
		m += A;
		if(day%7 == 0) m += B;
	}
	cout << day << endl;
}


Measured memory_bytes: 3088
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


H,W,K = inpl()

MAX = H*W+5
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

ans = 0
ruiseki = [0]
tmp = 0
for i in range(1,max(H,W)+5):
    tmp += i
    ruiseki.append(tmp)

for y in range(H):
    ans += (ruiseki[y] + ruiseki[H-y-1])*W*W

for x in range(W):
    ans += (ruiseki[x] + ruiseki[W-x-1])*H*H

ans //= 2
ans *= Comb(H*W-2,K-2)

print(ans%mod)


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


def main():
    from bisect import bisect
    from itertools import accumulate

    n, x = map(int, input().split())
    a = sorted([0] + list(map(int, input().split())))
    summed_a = list(accumulate(a))
    count = bisect(summed_a, x)

    if count >= n + 1:
        count -= 1

    if summed_a[count] == x:
        print(count)
    else:
        print(count - 1)


if __name__ == '__main__':
    main()


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

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

typedef long long ll;
typedef long double ld;

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fast() {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
#define eb emplace_back
#define pb push_back
#define deb(a) cerr << #a << " = " << a << '\n';

int main()
{
    fast();
    ll a, b, k;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++)
        if(i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    cout << "NG";
    return 0;
}


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

using namespace std;

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

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back


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


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

/// --- modulo Library {{{ ///
constexpr ll extgcd(ll a, ll b, ll& x, ll& y) {
  if(b==0) {
    x = 1; y = 0;
    return a;
  }
  ll d = extgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
constexpr ll modpow(ll a, ll b, ll mod = 1e9 + 7) {
  a = (a % mod + mod) % mod;
  ll r = 1;
  while(b){
    if(b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
constexpr ll modinv(ll a, ll mod = 1e9 + 7) {
  a = (a % mod + mod) % mod;
  ll x = 0, y = 0;
  extgcd(a, mod, x, y);
  return (x % mod + mod) % mod;
}
template<int N, int mod = int(1e9 + 7)> struct Factorial {
  int arr[N+1], inv[N+1];
  int operator[](int i) const { return arr[i]; }
  constexpr Factorial(): arr(), inv() {
    arr[0] = 1;
    for(int i = 1; i <= N; i++) {
      arr[i] = (ll) i * arr[i - 1] % mod;
    }
    inv[N] = modinv(arr[N], mod);
    for(int i = N-1; i >= 0; i--) {
      inv[i] = (ll) (i + 1) * inv[i + 1] % mod;
    }
  }
  int C(int n, int r) const {
    if(n < 0 || r < 0 || n < r) return 0;
    return (((ll) arr[n] * inv[r]) % mod * inv[n - r]) % mod;
  }
};
/// }}}--- ///

constexpr int N = 1e6 + 10;
constexpr Factorial<N> fact;

ll mod = 1e9 + 7;

// これは天才
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  if(n == 2) return (cout << 1 << endl, 0);
  ll ans = 0;
  ll prev = 0;
  for(int k = 1; k <= n - 1; k++) {
    ll patterns = fact.C(k - 1, n - 1 - k);
    patterns = (patterns * fact[k]) % mod;
    patterns = (patterns * fact[n - 1 - k]) % mod;

    // ここでpatternsは k "以下" の場合を数えている.
    // つまりこれは数え上げテクニックとして,
    // a_k - a_(k-1)
    // などで just k回目 の値を数えられる.

    ans = (((ans + (patterns - prev) * k)) % mod + mod) % mod;
    prev = patterns;
  }
  cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int& x : p) {
		cin >> x;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += i+1 != p[i];
	}

	cout << (cnt <= 2 ? "YES" : "NO") << endl;
	return 0;
}



Measured memory_bytes: 256
n,m = map(int, input().split())
lst = [[]]*n
num = 0
price = 0

for i in range(n):
    lst[i] = list(map(int, input().split()))
lst.sort(key=lambda x:x[0])

i = 0
while num < m:
    num += lst[i][1]
    price += lst[i][0]*lst[i][1]
    i += 1

print(price - (num-m)*lst[i-1][0])

Measured memory_bytes: 29028
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    rrep(i,n,0) cin>>a[i]>>b[i];
    ll ans=0;
    rep(i,0,n){
        if(a[i]%b[i]!=0) ans+=b[i]-a[i]%b[i];
        if(i+1<n) a[i+1]+=ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll K,N;cin>>K>>N;
  ll A[N];REP(i,N)cin>>A[i];
  ll B[N];
  ll m=0;
  REP(i,N){
    if(i!=N-1){
      B[i]=A[i+1]-A[i];
      m=max(m,B[i]);
    }else{
      B[i]=K+A[0]-A[i];
      m=max(m,B[i]);
    }
  }
  ll sum=accumulate(ALL(B,N),0LL);
  sum-=m;
  cout<<sum;
  return 0;
}


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

using namespace std;

struct pos {
  int x;
  int y;
  int t;
};

int main() {
  int N;
  cin >> N;
  vector<pos> poss(N + 1);
  poss.at(0) = {0, 0, 0};
  for (int i = 1; i <= N; ++i) {
    cin >> poss.at(i).t >> poss.at(i).x >> poss.at(i).y;
  }
  for (int i = 0; i < N; ++i) {
    int dist = abs(poss.at(i).x - poss.at(i + 1).x) + 
               abs(poss.at(i).y - poss.at(i + 1).y);
    int time = poss.at(i + 1).t - poss.at(i).t;
    if ((time - dist) < 0 || (time - dist) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  
  int ans = inf;
  for (int i = 0; i <= N; i++)
  {
    int n6 = i;
    int n9 = N - i;

    int a = 0;
    while (n6 > 0)
    {
      a += n6 % 6;
      n6 /= 6;
    }
    while (n9 > 0)
    {
      a += n9 % 9;
      n9 /= 9;
    }
    
    chmin(ans, a);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+5;
const long long mod = 1e9+7;
long long Sort[maxn];
long long ans[maxn];
int dir[9][2]={-2,-2,-2,-1,-2,0,-1,-2,-1,-1,-1,0,0,-2,0,-1,0,0};
int tot;
int main()
{
	long long H,W,N;
	scanf("%lld%lld%lld",&H,&W,&N);
	long long Ans=(long long)(H-2)*(long long)(W-2);
	for(int i=0;i<N;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		for(int j=0;j<9;j++)
		{
			int xx=x+dir[j][0];
			int yy=y+dir[j][1];
			if(xx>=1 && xx<=H-2 &&yy>=1 && yy<=W-2)
			{
				Sort[tot++] = xx * mod + yy;
			}
		}
	}
	sort(Sort,Sort+tot);
	int cnt=1;
	for(int i=0;i<tot;i++)
	{
		if(Sort[i]==Sort[i+1])
			cnt++;
		else
		{
			ans[cnt]++;
			cnt=1;
			Ans--;
		}
	}
	printf("%lld\n",Ans);
	for(int i=1;i<10;i++)
		printf("%lld\n",ans[i]);
	
	
	return 0;
}


Measured memory_bytes: 8960
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000

int main(){
  int n,k;
  cin >> n >> k;
  int ma = (n-1)*(n-2)/2;
  if(k > ma){
    cout << -1 << endl;
    return 0;
  }
  int e = ma - k;
  cout << n-1+e << endl;
  for(int i=2;i<n+1;i++){
    cout << 1 << ' ' << i << endl;
  }
  int count = 0;
  for(int i=2;i<n+1;i++){
    if(count == e) break;
    for(int j=i+1;j<n+1;j++){
      if(count == e) break;
      count += 1;
      cout << i << ' ' << j << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX_INDEX 51
#define MAX_SUM 2505

ll dp[MAX_INDEX][MAX_SUM][MAX_INDEX];

ll waysutil(ll index, ll sum, ll count,
             vector<ll>& arr, ll K)
{
        if (index < 0)
        return 0;

    if (index == 0) {

            if (count == 0)
            return 0;
        int remainder = sum % count;


        if (remainder != 0)
            return 0;
        ll average = sum / count;

             if (average == K)
            return 1;
    }

    if (dp[index][sum][count] != -1)
        return dp[index][sum][count];


    ll dontpick = waysutil(index - 1,
                            sum, count, arr, K);


    ll pick = waysutil(index - 1,
                        sum + arr[index],
                        count + 1, arr, K);
    ll total = pick + dontpick;

        dp[index][sum][count] = total;
    return total;
}


ll ways(ll N, ll K, ll* arr)
{
    vector<ll> Arr;


    Arr.push_back(-1);
    for (ll i = 0; i < N; ++i) {
        Arr.push_back(arr[i]);
    }


    memset(dp, -1, sizeof dp);
     ll answer = waysutil(N, 0, 0, Arr, K);
    return answer;
}


int main()
{
    ll n,K;
    cin >> n >> K;
    ll arr[n+10];
    for(ll i=0; i<n; i++)cin >> arr[i];

    cout << ways(n, K, arr);

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N), v(N);
  for(int i=0; i<N; i++){
    cin >> P[i];
  }
  for(int i=0; i<N; i++){
    cin >> Q[i];
    v[i] = i+1;
  }  
  
  int a,b;
  int num = 1;
  int flag = 0;
  sort(v.begin(), v.end());
  do {
    if(equal(P.begin(),P.end(),v.begin(),v.end())) {
      a = num;
      flag++;
    }
    if(equal(Q.begin(),Q.end(),v.begin(),v.end())) {
      b = num;
      flag++;
    }
    if( flag==2){
      cout << abs(a-b) << endl;
      return 0;
    }
    num++;
  } while (next_permutation(v.begin(), v.end()));
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();
        int w[] = new int[n];
        int total = 0;
        int sum = 0;
        int a = 0;
        for (int i = 0; i < w.length; i++)
            w[i] = stdIn.nextInt();
        for (int i = 0; i < w.length; i++)
            total += w[i];
        for (int i = 0; i < w.length; i++) {
            sum += w[i];
            if (sum > total / 2) {
                a = i;
                break;
            }
        }
        if (sum * 2 - total < total - (sum - w[a]) * 2)
            System.out.println(sum * 2 - total);
        else
            System.out.println(total - (sum - w[a]) * 2);
    }
}

Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    int ans = 0;
    cin >> S;
    for (int i=0; i<S.size(); i++)
    {
        if (S[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AtCoder Beginners Contest 175
// B - Making Triangle

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;

int main()
{
    //steady_clock::time_point start = steady_clock::now();
	int N;
	cin >> N;

	long long L[N];
	for (int i=0; i<N; i++) cin >> L[i];
	/*
	cout << N << endl;
	for (int i=0; i<N; i++) cout << L[i];
	cout << endl;
	*/
	bool sub1, sub2, sub3;
	bool isRect = true;
	int cnt = 0;
	for (int i=0; i<N-2; i++) {
		for (int j=i+1; j<N-1; j++) {
			if (L[i] == L[j]) continue;
			for (int k=j+1; k<N; k++) {
				//cout << "(i,j,k)=" << i << j << k << endl;
				//cout << "(L[i],L[j],L[k])=" << L[i] << L[j] << L[k] << endl;
				if (L[k] == L[i] || L[k] == L[j]) continue;
				sub1 = (L[i]+L[j]>L[k]);
				sub2 = (L[k]+L[i]>L[j]);
				sub3 = (L[j]+L[k]>L[i]);
				isRect = sub1 && sub2 && sub3;
				if (isRect) cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3520
n, m = [int(i) for i in input().split(' ')]
h_s = [int(i) for i in input().split(' ')]
good_s = [1 for i in range(n)]
for i in range(m):
  p1, p2 = [int(i) - 1 for i in input().split(' ')]
  h1 = h_s[p1]
  h2 = h_s[p2]
  if h1 > h2:
    good_s[p2] = 0
  elif h1 < h2:
    good_s[p1] = 0
  else:
    good_s[p1] = 0
    good_s[p2] = 0

ans = 0
for i in range(n):
  if good_s[i] == 1:
    ans += 1

print(ans)

Measured memory_bytes: 20128
_, rates = readlines.map(&:chomp)
rates = rates.split(' ').map(&:to_i)
normal, genius = rates.partition {|v| v < 3200}
min_colors = normal.map {|v| v / 400}.uniq.length
max_colors = min_colors + genius.length
puts "#{[min_colors, 1].max} #{max_colors}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n,maxval=0;
  cin>>n;
  map<string,ll> map;
  vector<string> vec(n);
  for(ll i=0;i<n;i++){
    string s;
    cin>>s;
    map[s]++;
  }
  for(auto it = map.begin(); it != map.end(); it++){
    ll val = (*it).second;
    if(val>maxval){maxval=val;}
  }
  for(auto it = map.begin(); it != map.end(); it++){
    if((*it).second==maxval){
      cout<<(*it).first<<endl;
    }
  }
}

Measured memory_bytes: 26752
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        a: isize,
        v: isize,
        b: isize,
        w: isize,
        t: isize,
    }

    let ans = {
        if a < b {
            if a + v * t >= b + w * t {
                true
            } else {
                false
            }
        } else {
            if a - v * t <= b - w * t {
                true
            } else {
                false
            }
        }
    };
    
    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 2200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=300007;
const int mod=998244353;
long long n,a,b,k,num[maxn],ans;
void init(){
    num[0]=1;
    for (int i=1; i<=n; i++) num[i]=(num[i-1]*i) % mod;
}
long long qpow(long long x,long long y) {  //x^y
    x %= mod;
    long long now=x,ret=1;
    while (y) {
        if (y & 1) ret=(ret*now) % mod;
        y >>= 1;
        now=(now*now) % mod;
    }
    return ret;
}
long long C(long long x,long long y){  
    if (x==0) return 1;
    long long ret=num[y] % mod;
    long long cnt=(num[x] * num[y-x]) % mod;
    ret=(ret*qpow(cnt,mod-2)) % mod;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>a>>b>>k;
    init();
    for (int i=0; i<=min(n,k/a); i++) {
        if ((k-i*a)%b==0 && ((k-i*a)/b)<=n) 
            ans=(ans+((C(i,n)*C(((k-i*a)/b),n)) % mod)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
$><<x=y=[0,2].zip(*P=$<.map{|l|l.split.map(&:to_i)<<l}).all?{|f,w,j|l=w,0
(1..P[0][2]).all?{|k|4.times{|i|P[~h=i/2][1][~k]==:UDLR[f+i&=1]&&l[h^=i]=1+4[g=i*2-l[h]]-g-1[w+g]}
x,y=l
y<x}&&y<j&&j<=x}?:YES: :NO

Measured memory_bytes: 4604
#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 A, B;
	cin >> A >> B;
	int ans;
	if ((A == 1 && B == 2) or (A == 2 && B == 1)) {
		ans = 3;
	} else if ((A == 1 && B == 3) or (A == 3 && B == 1)) {
		ans = 2;
	} else {
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}


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


int main(){
    string S;
    cin >> S;
    
    bool c=0;
    if(S[0]=='B') c=0;
    else c=1;
    
    int cnt=0;
    for(int i=1; i<S.length(); i++){
        if(c==1){
            if(S[i]=='B'){
                cnt++;
                c=0;
            }
        }
        else {
            if(S[i]=='W'){
                cnt++;
                c=1;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
int a[200005], cnt[200005];
ll ans;

int main(void)
{
	int n; cin >> n;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++) {
		ans += (ll)cnt[i] * (cnt[i] - 1) / 2;
	}
	for(int i=1;i<=n;i++)
		cout << ans + 1 - cnt[a[i]] << endl;

	return 0;
}

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

int main(){
  const int N_max = 100;
  int N;
  int a[N_max];
  cin >> N;
  for(int i = 0; i<N ; ++i){
    cin >> a[i];
  }
  
  //sort
  int num_swaps=0;
  for(int i=0; i<N-1; ++i){
    for(int j=N-2; j>=i; --j){
      //swap a[j] and a[j+1]
      if (a[j] > a[j+1]){
	int t = a[j];
	a[j] = a[j+1];
	a[j+1] = t;
	++num_swaps;
      }
    }
  }

  //output
  for(int i = 0; i<N ; ++i){
    cout << ( i==0 ? "" : " ") << a[i];
  }
  cout << endl;
  cout << num_swaps <<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };

int main() {
	int n, m;
	cin >> n >> m;
	vi num(n,0);
	REP(i,m) {
		int a, b;
		cin >> a >> b;
		num[a - 1]++;
		num[b - 1]++;
	}
	string s = "YES";
	REP(i, n) {
		if (num[i] % 2 == 1) {
			s = "NO";
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
#xa=c(modb)なるx⊂Zはあるか？
#y=xmodb:xa=ya(modb)
#x<b
A,B,C=map(int,input().split())
ans=False
for x in range(B):
	if x*A%B==C:
		ans=True
print('NYOE S'[ans::2])

Measured memory_bytes: 2940
import numpy as np
n,m,q=map(int,input().split())
s=np.zeros((n,n))
for i in range(m):
    l,r=map(int,input().split())
    s[n-l][r-1]+=1
s=np.cumsum(np.cumsum(s,axis=0),axis=1)
for i in range(q):
    d,t=map(int,input().split())
    print(int(s[n-d][t-1]))

Measured memory_bytes: 18268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void) {
	int N, a, mod4=0, mod2=0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a);
		if (a % 4 == 0) {
			mod4++;
		}
		else if (a % 2 == 0) {
			mod2++;
		}
	}
	if (mod2 > 1) {
		N -= (mod2 - 1);
	}
	//printf("N:%d, mod4:%d\n", N, mod4);
	printf("%s\n", (mod4 >= N/2) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int h, w; cin >> h >> w;
  string s[h];
  queue<pair<int, int>>Q;
  rep(i, h){
    cin >> s[i];
  }
  int dis[h][w];
  rep(i, h){
    rep(j, w){
      dis[i][j]=inf;
      if(s[i][j]=='#'){
        Q.push({i, j}); dis[i][j]=0;
      }
    }
  }
  int nx[4] = {-1, 0, 0, 1};
  int ny[4] = {0, 1, -1, 0};
  while(!Q.empty()){
    int a = Q.front().first; int b = Q.front().second; Q.pop();
    rep(i, 4){
      int dx = a+nx[i]; int dy = b+ny[i];
      if(dis[dx][dy]==inf && dx!=-1 && dy!=-1 && dx!=h && dy!=w){
        dis[dx][dy] = dis[a][b]+1;
        Q.push({dx, dy});
      }
    }
  }
  int ans =0;
  rep(i, h){
    rep(j, w){
      ans = max(ans, dis[i][j]);
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 13456
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)

int main(){
    int a,b;
    char c;
    bool flag=0;
    cin>>a>>b;
    if(a>5||b>5||a<1||b<1);
    else {
        rep(i,a+b+1){
            cin>>c;
            if(c=='-'){
                if(i!=a){flag=0;break;}
                else flag=1;
            }
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int k,n;
    cin>>k>>n;
    int ans=0;
    vector<int> A(n);
    for(int i=0; i<n; i++) {
        cin>>A[i];
    }
    vector<int> dist;
    for(int i=1; i<n; i++) {
        dist.push_back(A[i]-A[i-1]);
    }
    dist.push_back(k-A.back()+A[0]);
    ans = accumulate(dist.begin(), dist.end(), 0);
    ans -= *max_element(dist.begin(), dist.end());

    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

string s;
ll H, N;
ll dp[202020];

int main() {
    cin >> H >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    REP (i, 202020) dp[i] = 1e17; 
    dp[0] = 0;
    REP (i, N) {
        FOR (k, A[i], 20202) {
            dp[k] = min(dp[k], dp[k - A[i]] + B[i]);
        }
    }
    ll res = 1e17;
    FOR(i, H, 20202)res = min(dp[i], res);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}
	int m;
	cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++) {
		cin >> t.at(i);
	}
	vector<int> resultPoint(0);

	while (s.size() > 0) {
		string first = s.at(0);
		s.erase(s.begin());
		int count = 1;
		while (true) {
			auto it = find(s.begin(), s.end(), first);
			if (it != s.end()) {
				count++;
				s.erase(it);
			}
			else {
				break;
			}
		}
		while (true) {
			auto it = find(t.begin(), t.end(), first);
			if (it != t.end()) {
				count--;
				t.erase(it);
			}
			else {
				break;
			}
		}
		resultPoint.emplace_back(count);
	}
	while (t.size() > 0) {
		string first = t.at(0);
		t.erase(t.begin());
		int count = -1;
		while (true) {
			auto it = find(t.begin(), t.end(), first);
			if (it != t.end()) {
				count--;
				t.erase(it);
			}
			else {
				break;
			}
		}
		resultPoint.emplace_back(count);
	}
	
	int max = resultPoint.at(0);
	for (int i = 1; i < resultPoint.size();i++) {
		if (max < resultPoint.at(i)) {
			max = resultPoint.at(i);
		}
	}
	if (max < 0) {
		max = 0;
	}
	cout << max;

}

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

if x < 600:
  print(8)
elif x < 800:
  print(7)
elif x < 1000:
  print(6)
elif x < 1200:
  print(5)
elif x < 1400:
  print(4)
elif x < 1600:
  print(3)
elif x < 1800:
  print(2)
else:
  print(1)
        


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> se(13);
vector<int> he(13);
vector<int> ce(13);
vector<int> de(13);
for(int i=0;i<n;i++){
char t;
int y;
cin>>t;
cin>>y;
if(t=='S'){
se[y-1]=1;
}
else if(t=='H'){
he[y-1]=1;
}
else if(t=='C'){
ce[y-1]=1;
}
else if(t=='D'){
de[y-1]=1;
}
}
for(int i=0;i<13;i++){
if(se[i]==0){
cout<<'S'<<" "<<i+1<<endl;
}
}
for(int i=0;i<13;i++){
if(he[i]==0){
cout<<'H'<<" "<<i+1<<endl;
}
}
for(int i=0;i<13;i++){
if(ce[i]==0){
cout<<'C'<<" "<<i+1<<endl;
}
}
for(int i=0;i<13;i++){
if(de[i]==0){
cout<<'D'<<" "<<i+1<<endl;
}
}
}


Measured memory_bytes: 3092
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


ll me(ll x,ll n )
{
  ll res=1;

  while(n)
  {
    if(n&1)
      res=res*x;

    x=x*x;

    n/=2;
  }

  return res;

}


int main() 
{ 

  int n;
  scf(n);

  int a[n];

  rep(i,0,n)
  scf(a[i]);

  int mx=mod,p=-1;

  rep(i,1,101)
  {

    ll ans=0;
    rep(j,0,n)
    ans+=pow((a[j]-i),2);

    if(ans<mx)
      mx=ans,p=i;
  }

  prin(mx);


}

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

int a[105];

bool cmp(int a,int b)
{
	return a > b;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	double sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	sum /= 4 * m;
	sort(a+1,a+1+n,cmp);
	if( a[m] >= sum ) cout << "Yes" << '\n';
	else cout << "No" << '\n'; 
	return 0;
}


Measured memory_bytes: 256
/*
author : nit1n
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;
const int N = 1e5 +5 ;
set<int> gr[N] ;     
struct DSU
{
	int par[N] ; 
	int rnk[N] ; 
	int sz[N] ; 
	DSU(int n)
	{
		for(int i = 0; i <= n ; ++i)
		{
			par[i] = i ; 
			rnk[i] = 1; 
			sz[i] = 1  ;
		}
	}
	int findp(int x )
	{
		if(par[x] != x)
		{
			par[x] = findp(par[x]) ; 
		}
		return par[x] ; 
	}
	void unite(int x ,int y)
	{
		int p = findp(x) ,q = findp(y) ;
		if(p ==q)
			return ;  
		if(rnk[q] > rnk[p])
		{
			par[p] = q ; 
			sz[q] += sz[p]  ;
			
		}
		else 
		{
			par[q] = p ;
			if(rnk[p] == rnk[q])
			{
				rnk[p]++ ; 
			}
			sz[p] += sz[q] ;
			
		}

	}

} ; 

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

	int n , m , k ;
	cin >> n >> m >> k  ; 
	DSU dsu(n)  , block(n); 
	vector<int> cnt(n+1 ,0) ; 
	for(int i = 0 ; i < m ; ++i)
	{
		int u , v ; 
		cin >> u >> v ; 
		gr[u].insert(v) ; 
		gr[v].insert(u) ; 
		dsu.unite(u ,v) ; 
	}
	for(int i = 0 ; i < k ; ++i)
	{
		int u , v ; 
		cin >> u >> v  ; 
		if(dsu.findp(u) == dsu.findp(v))
		{
			cnt[u]++ ; 
			cnt[v]++ ; 
		}
	}
	for(int i =1 ; i <= n ; ++i)
	{
		dsu.findp(i) ; 
	  	 
	}

	for(int i =1 ; i <= n ; ++i)
	{
		cout << dsu.sz[dsu.par[i]] -cnt[i] - gr[i].size() -1 << " " ; 
	}

}


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

int main(){
  int N;cin>>N;
  vector<vector<pair<int,int>>>A(N);
  for(int i=0;i<N-1;i++){
    int u,v,w;cin>>u>>v>>w;
    A[u-1].push_back(pair<int,int>(v-1,w));
    A[v-1].push_back(pair<int,int>(u-1,w));
  }
  vector<int>col(N,-1);
  queue<int> q;q.push(0);
  while(q.size()){
    int f=q.front();q.pop();
    for(auto n:A[f]){
      if(col[n.first]==-1){
        col[n.first]=(col[f]+n.second)%2;
        q.push(n.first);
      }
    }
  }
  for(int i=0;i<N;i++)cout<<col[i]<<endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL s;
  cin >> s;
  LL l=0,r=INF/10,mid;
  LL now;
  LL count;
  int i;
  while(r-l>1){
    mid=(l+r)/2;
    i=0,now=1,count=0;
    for(;now*10<mid;i++,now*=10){
      count+=((now*10-1)/3-(now-1)/3)*4;
      count+=((now*10-1)/5-(now-1)/5)*4;
      count+=((now*10-1-(now*10-1)/3-(now*10-1)/5+(now*10-1)/15)-(now-1-(now-1)/3-(now-1)/5+(now-1)/15))*(i+1);
    }
    count+=(mid/3-(now-1)/3)*4;
    count+=(mid/5-(now-1)/5)*4;
    count+=((mid-mid/3-mid/5+mid/15)-(now-1-(now-1)/3-(now-1)/5+(now-1)/15))*(i+1);
    if(count<s){
      l=mid;
    }else{
      r=mid;
    }
  }
  i=0,now=1,count=0;
  mid=l;
  for(;now*10<mid;i++,now*=10){
    count+=((now*10-1)/3-(now-1)/3)*4;
    count+=((now*10-1)/5-(now-1)/5)*4;
    count+=((now*10-1-(now*10-1)/3-(now*10-1)/5+(now*10-1)/15)-(now-1-(now-1)/3-(now-1)/5+(now-1)/15))*(i+1);
  }
  count+=(mid/3-(now-1)/3)*4;
  count+=(mid/5-(now-1)/5)*4;
  count+=((mid-mid/3-mid/5+mid/15)-(now-1-(now-1)/3-(now-1)/5+(now-1)/15))*(i+1);
  string t="";
  for(int i=1;i<=10;i++){
    if((l+i)%3==0){
      t+="Fizz";
      if((l+i)%5==0){
        t+="Buzz";
      }
    }else if((l+i)%5==0){
      t+="Buzz";
    }else{
      t+=to_string(l+i);
    }
  }
  cout << t.substr(s-count-1,20) << endl;
  return 0;
}



Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 0; i*4 <= n; i++){
			if((n - i*4) % 7 == 0){
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}

}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int count = 0;
  int previous = -1;
  for (int i=0; i<N; i++) {
    if (vec[i] != previous) count += 1;
    previous = vec[i];
  }
  cout << count << endl;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	for (int i=0; i<sz(s); i++){
		if (s[i]=='?') s[i]='D';
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3744
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)       for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b; cin >> a >> b;
    if(a == 1 && b == 2){
        cout << 3 << endl;
        return 0;
    }
    if(a == 1 && b == 3){
        cout << 2 << endl;
        return 0;
    }
    if(a == 2 && b == 1){
        cout << 3 << endl;
        return 0;
    }
    if(a == 2 && b == 3){
        cout << 1 << endl;
        return 0;
    }
    if(a == 3 && b == 1){
        cout << 2 << endl;
        return 0;
    }
    if(a == 3 && b == 2){
        cout << 1 << endl;
        return 0;
    }

}

Measured memory_bytes: 3536
#include <iostream>
#include <string>

using namespace std;

#define MOD 1000000007

long long dp[10002][100][2] = {};

int main() {
	string K; cin >> K;
	int D; cin >> D;
	int sz = K.size();
	dp[0][0][0] = 1;
	for (int i = 0; i < sz; ++i) {
		int c = K[i] - '0';
		for (int j = 0; j < D; ++j)
			for (int smaller = 0; smaller < 2; ++smaller)
				for (int k = 0; k < 10; ++k)
					if (k < c) (dp[i + 1][(j + k) % D][1] += dp[i][j][smaller]) %= MOD;
					else if (k == c) (dp[i + 1][(j + k) % D][smaller] += dp[i][j][smaller]) %= MOD;
					else if (smaller) (dp[i + 1][(j + k) % D][1] += dp[i][j][1]) %= MOD;
	}
	cout << (dp[sz][0][0] + dp[sz][0][1] - 1 + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 15872
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let mut s = 0;
    for x in a {
        s += x;
    }

    let res = if s > n {
        -1
    } else {
        (n - s) as isize
    };

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


Measured memory_bytes: 2288