akhauriyash/Code-Regression huggingface dataset:
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define int ll 
using namespace std;             
 
const int N = (int)5e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int a[N];
int n;
pii d[N * 4];
void update (int v, int l, int r, int pos, int x) {
	if (l == r) {
		d[v].S += x;
		d[v].F = d[v].S * (d[v].S - 1) / 2;
		return;	
	}
	int mid = l + r >> 1;
	if (pos <= mid) update (v * 2, l, mid, pos, x);
	else update (v * 2 + 1, mid + 1, r, pos, x);
	d[v].F = d[v * 2].F + d[v * 2 + 1].F;
}
void solve () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		update (1, 1, n, a[i], 1);
	}
	for (int i = 1; i <= n; i ++) {
		if (i != 1) update (1, 1, n, a[i - 1], 1);
		update (1, 1, n, a[i], -1);
		cout << d[1].F << endl;
	}
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 16000
import array
import time

class UnionFind :
    def __init__(self, n):
        self.par = array.array('i', range(n))
        self.sizes = array.array('i', [1]*n)
        self.rank = array.array('i', [0]*n)


    def root(self, i):
        if i == self.par[i]:
            return i
        else:
            r = self.root(self.par[i])
            self.par[i] = r
            return r

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        srx = self.sized(x)
        sry = self.sized(y)
        if rx != ry:
            if self.rank[rx] < self.rank[ry]:
                self.par[rx] = ry
            else:
                self.par[ry] = rx
                if self.rank[rx] == self.rank[ry]:
                    self.rank[rx] = self.rank[rx] + 1
            self.sizes[self.root(rx)] = srx + sry

    def same(self, x, y) :
        return self.root(x) == self.root(y)

    def sized(self, x):
        return self.sizes[self.root(x)]

    def debug(self):
        print(self.par)
        print(self.sizes)

def calsc(x):
    return (x * (x-1)) // 2

def main():
    (n,m) = map(int, input().split())
    ab = []
    for _ in range(m):
        (p,q) = map(int, input().split())
        ab.append((p-1,q-1))
    uf = UnionFind(n)
    res = []
    prev = 0
    while len(ab) > 0:
        (a,b) = ab.pop()
        #uf.debug()
        res.append(prev)
        score = prev
        if not uf.same(a,b):
            score = score - calsc(uf.sized(a)) - calsc(uf.sized(b))
            uf.unite(a,b)
            score = score + calsc(uf.sized(a))
        prev = score
    for i in range(len(res)):
        res[i] = calsc(n) - res[i]
    res = res[::-1]
    for r in res:
        print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18568
n,m=map(int,input().split())
su=input()
rev=su[::-1]
if "1"*m in su:
	print(-1)
	exit()
dist_f_n=[float('inf')]*(n+1)
dist_f_n[0]=0
for i in range(1,m+1):
	if rev[i]=="0":
		dist_f_n[i]=1
		last=i
		if i==n:
			break
while last<n:
	for i in range(last+1,last+m+1):
		if rev[i]=="0":
			dist_f_n[i]=dist_f_n[last]+1
			_last=i
			if i==n:
				break
	last=_last
cur=dist_f_n[-1]
_i=0
ans=[]
for i,x in enumerate(dist_f_n[::-1]):
	if x==cur-1:
		ans.append(i-_i)
		cur-=1
		_i=i
print(" ".join(map(str,ans)))


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  const Int M=1e6+100;
  vector<Int> v;
  for(Int i=1;i*(i+1)*(i+2)/6<=M;i++)
    v.emplace_back(i*(i+1)*(i+2)/6);

  const Int INF = 1e8;
  vector<Int> dp(M,INF),dp2(M,INF);
  dp[0]=dp2[0]=0;
  for(Int i=0;i<(Int)v.size();i++){
    for(Int j=0;j<M;j++){
      if(j+v[i]<M){
	chmin(dp[j+v[i]],dp[j]+1);
	if(v[i]&1) chmin(dp2[j+v[i]],dp2[j]+1);
      }
    }
  }
  
  Int n;
  while(cin>>n,n) cout<<dp[n]<<" "<<dp2[n]<<endl;
  return 0;
}



Measured memory_bytes: 18196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


int ar[sz];

int main()
{
  fastio;
  ll t, a, b, c, ans=0, i, n, x, y, z, cnt=0;
  
  cin>>n;
  
  for(i=1; i<=n; i++)cin>>ar[i];
  
  for(i=1; i<=n; i++)
  {
      for(int j=i+1; j<=n; j++)
      {
          if(ar[i]==ar[j])continue;
          for(int k=j+1; k<=n; k++)
          {
            x=ar[i];
            y=ar[j];
            z=ar[k];
            if(z==x or z==y)continue;
            if((x+y)>z and (x+z)>y and (y+z)>x)cnt++;
          }
      }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N];
  for (int i=0;i<N;i++){
    cin>>A[i];
    if(!(A[i]%2==0)){
      continue;
    }
    else if(!((A[i]%3==0)||(A[i]%5==0))){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
  return 0;
}

  

Measured memory_bytes: 256
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
ex_list = []
for i in range(N):
    if s[i] not in ex_list:
        if s.count(s[i]) > t.count(s[i]):
            ans = max(s.count(s[i])-t.count(s[i]),ans)
            ex_list.append(s[i])
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
#define inf 0x7fffffff
#define eps 1e-9
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline void gmin(T&a,T b) {if(a>b)a=b;}
template<class T> inline void gmax(T&a,T b) {if(a<b)a=b;}
inline int sign(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}~Initializer(){}}initializer;

#define N 200020
string s;
int f[N][3][3][2];
int pos[]={0,0,1,2,0,1,2,0,1,2};

int main() {
  while (cin>>s) {
    if (s=="#") break;
    int n=sz(s);
    memset(f,0x7f,sizeof(f));

    rep(l,0,2)
      rep(r,l,2) {
        f[0][l][r][0]=
        f[0][l][r][1]=0;
      }

    rep(i,0,n-1) {
      if (s[i]<'0'||'9'<s[i]) continue;
      rep(l,0,2)
        rep(r,l,2) {
          int p=pos[s[i]-'0'];
          if (p<=r) {
            gmin(f[i+1][p][r][0],f[i][l][r][0]+1);
            gmin(f[i+1][p][r][0],f[i][l][r][1]);
          }
          if (l<=p) {
            gmin(f[i+1][l][p][1],f[i][l][r][0]);
            gmin(f[i+1][l][p][1],f[i][l][r][1]+1);
          }
        }
    }

    int ans=inf;
    rep(l,0,2)
      rep(r,l,2) {
        gmin(ans,f[n][l][r][0]);
        gmin(ans,f[n][l][r][1]);
      }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 15448
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int h = vals[0];
        int w = vals[1];

        var countsDict = new Dictionary<char, int>();
        for (int i = 0; i < h; i++)
        {
            foreach (var c in Console.ReadLine())
            {
                if (!countsDict.ContainsKey(c))
                {
                    countsDict[c] = 1;
                }
                else
                {
                    countsDict[c]++;
                }
            }
        }

        int fourSets = (w / 2) * (h / 2);
        int twoSets = (w % 2) * (h / 2) + (h % 2) * (w / 2);
        int oneSets = h * w - (fourSets * 4 + twoSets * 2);

        var counts = countsDict.Select(kv => kv.Value).OrderByDescending(v => v).ToList();
        foreach (var i in counts)
        {
            var v = i;
            if (v >= 4 && fourSets > 0)
            {
                var f = Math.Min(v / 4, fourSets);
                fourSets -= f;
                v -= f * 4;
            }
            if (v >= 2 && twoSets > 0)
            {
                var t = Math.Min(v / 2, twoSets);
                twoSets -= t;
                v -= t * 2;
            }
            if (v >= 1 && oneSets > 0)
            {
                oneSets--;
                v--;
            }
            if (v > 0)
            {
                Console.WriteLine("No");
                return;
            }
        }


        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13524
# (lcm-1) % Ai なんだけどMLEなりそうな予感

from functools import reduce

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


def gcd(x, y):
    if x > y:
        return gcd(y, x)
    while x > 0:
        x, y = y % x, x
    return y


def lcm(x, y):
    return (x * y) // gcd(x, y)


x = reduce(lambda x, y: lcm(x, y), arr) - 1

ans = 0
for a in arr:
    ans += x % a
print(ans)


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

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

    double L;
    cin >> L;

    auto a = L / 3.0;

    cout.precision(15);
    cout << fixed << a * a * a << '\n';

    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;


int32_t main() {

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

    int n,k;
    cin >> n >> k;

    int cnt = 0;
    repA(i,1,n) {
    	int mxd = n / i;
    	int rem = n % i;

    	cnt += mxd*max(i-k, 0ll);
    	cnt += max(rem-k+1, 0ll);
    	if(k == 0 and mxd > 0)
    		cnt--;
    }

    cout << cnt << '\n';
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        long[] NAB = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long maxsum = NAB[2] * (NAB[0] - 1) + NAB[1];
        long minsum = NAB[1] * (NAB[0] - 1) + NAB[2];
        if (NAB[0] == 1)
        {
            if (NAB[1] == NAB[2])
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
        else if (NAB[1] > NAB[2]) Console.WriteLine(0);
        else
        {
            Console.WriteLine(maxsum - minsum + 1);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    rep(i, a + b + 1) {
        if (i == a && s[i] != '-') {
            cout << "No" << endl;
            return 0;
        }
        if (i != a && (s[i] < '0' || s[i] > '9')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	bool d = false;
	for(int i = 0; i < s.size(); ++i){
		if(!d && s[i] == s[i+1]){
			++i;
			d = true;
		}else{
			d = false;
		}
		ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <tuple>

using namespace std;

//#define int long long

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) begin(a), end(a)

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 
#ifdef int
#define INF 1001001001001001001LL
#else
#define INF 1001001001
#endif

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

VI D;
vector<tuple<int,int,int>> edges;

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

    int V, E, r; cin>>V>>E>>r;

    D.resize(V);
    fill(ALL(D), INF);
    edges.resize(E);

    rep(i, E){
        int s,t,d; cin>>s>>t>>d;
        edges[i]=make_tuple(s,t,d);
    }

    D[r]=0;

    rep(i, V) {
        bool updated = false;
        rep(j, E) {
            int s,t,d; s=get<0>(edges[j]);t=get<1>(edges[j]);d=get<2>(edges[j]);
            if(D[s] != INF && D[t] > D[s]+d) {
                D[t] = D[s]+d;
                updated = true;
            }
        }
        if(updated && i==V-1) {
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    }
    rep(i,V) {
        if(D[i]==INF) cout<<"INF"<<endl;
        else cout<<D[i]<<endl;
    }

	return 0;
}


Measured memory_bytes: 3232
H,W,A,B = map(int,input().split())
lis = [['0'] * W for i in range(H)]

for i in range(H):
    if i < B:
        for j in range(A,W):
            lis[i][j] = '1'
    else:
        for j in range(A):
            lis[i][j] = '1'
for i in lis:
    print(''.join(i))


Measured memory_bytes: 80948
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

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

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
ll mod=1e9+7;
vector<int>G[200000];
int dp[200000][2];
int vis[200000];
int n;
int dfs(int node,int color,int parent)
{
//    cout<<node<<" "<<color<<endl;
    if(dp[node][color]!=-1)
    {
        return dp[node][color];
    }
    ll ans=1,x;
    int f=1;
    ll res=0;
    for(int i=0;i<G[node].size();i++)
    {
        x=G[node][i];
        if(x!=parent){
            res=0;
            f=0;
            res+=dfs(x,0,node);
            res%=mod;
            if(color==0)
            {
                res+=dfs(x,1,node);
                res%=mod;
            }
            ans*=res;
            ans%=mod;
        }
    }
    return dp[node][color]=ans;
}
int main()
{
//    READ;
    int x,y;
    sf(n);
    for(int i=0;i<n-1;i++)
    {
        sf2(x,y);
        G[x].pb(y);
        G[y].pb(x);
    }
    mem(dp,-1);
    cout<<(dfs(1,0,0)+dfs(1,1,0))%mod<<endl;
    return 0;
}


Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{int m,k;
cin>>m>>k;
ll sum=0;
ll d[m];
FOR(m) cin>>d[i];
sort(d,d+m);
if(k>m)
{
    cout<<0;
}
else 
{
    sum=accumulate(d,d+(m-k),sum);
    cout<<sum;
}





return 0;
}

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

using namespace std;

int main(){
    int N, H;
    int flag = 0;
    int high = 1;
    scanf("%d", &N);
    int Cx, Cy;
    int x, y, h;
    int matrix[N + 1][4];
    for(int i = 1; i <= N; i++){
        scanf("%d %d %d", &x, &y, &h);
        matrix[i][1] = x;
        matrix[i][2] = y;
        matrix[i][3] = h;
        high = max(h, high);
    }
    // for(int i = 1; i <= N; i++){
    //     printf("%d %d %d\n", matrix[i][1], matrix[i][2], matrix[i][3]);
    // } 
    for(int i = 0; i <= 100; i++){
        Cx = i;
        for(int j = 0; j <= 100; j++){
            Cy = j;
            for(int k = 0; k <= 100; k++){
                H = high + k;
                for(int l = 1; l <= N; l++){
                    if(matrix[l][3] != max(0, H - abs(Cx - matrix[l][1]) - abs(Cy - matrix[l][2]))){
                        flag = 1;
                        break;
                    }
                }
                if(flag == 1){
                    flag = 0; 
                    continue;
                }else if(flag == 0){
                    printf("%d %d %d\n", Cx, Cy, H);
                }
            }
        }
    }

    // for(int k = 1; k < N; k++){
    //     if(matrix[k][3] == 0){
    //         continue;
    //     }else{
    //         H = matrix[k][3] + abs(Cx - matrix[k][1]) + abs(Cy - matrix[k][2]);
    //         printf("%d\n", H);
    //         break;
    //     }
    // }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int dice[2][6];
  int vector[3][4]={{0,2,5,3},{0,1,5,4},{1,2,4,3}};
  int i,j,k,l,m,c;
  for(i=0;i<2;i++)
  {
    for(j=0;j<6;j++)
    {
      scanf("%d",&dice[i][j]);
    }
  }
  for(i=0;i<2;i++)
  {
    for(j=0;j<4;j++)
    {
      int temp = dice[1][vector[i][0]];
      for(k=0;k<3;k++)
      {
	dice[1][vector[i][k]] = dice[1][vector[i][k+1]];
      }
      dice[1][vector[i][3]] = temp;
      c = 0;
      for(k=0;k<6;k++)
      {
	if(dice[0][k]==dice[1][k])c++;
      }
      //printf("First: dice[1] %d %d %d %d %d %d\n",dice[1][0],dice[1][1],dice[1][2],dice[1][3],dice[1][4],dice[1][5]);
      if(c==6)break;
      for(m=0;m<3;m++){
	for(k=0;k<4;k++)
	{
	  int temp = dice[1][vector[m][0]];
	  for(l=0;l<3;l++)
	  {
	    dice[1][vector[m][l]] = dice[1][vector[m][l+1]];
	  }
	  dice[1][vector[m][3]] = temp;
	  c=0;
	  for(l=0;l<6;l++)
	  {
	    if(dice[0][l]==dice[1][l])c++;
	  }
	  //printf("i:0 dice[1] :%d %d %d %d %d %d\n",dice[1][0],dice[1][1],dice[1][2],dice[1][3],dice[1][4],dice[1][5]);
	  if(c==6)break;
	}
	if(c==6)break;
      }
      if(c==6)break;
    }
    if(c==6)break;
  }
  if(c==6)printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a+b+c==17)&&(((a==5||a==7)+(b==5||b==7)+(c==5||c==7))==3)){
      cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
/*
2017年9月2日23:15:46 
B
简单输出 
*/ 
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int b[maxn];//b[0]代表-1的个数 
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<maxn;i++) a[i]=0;
	b[0]=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x>=1){
			a[x-1]++;
			a[x]++;
			a[x+1]++;
			ans=max(ans,max(a[x-1],max(a[x],a[x+1])));
		}else{
			b[0]++;
			a[x]++;
			a[x+1]++;
			ans=max(ans,max(b[0],max(a[x],a[x+1])));
		} 
	} 
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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 ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    string ss;
    map<string, int> mp;
    int mx = 0;
    rep(i,n) {
        cin >> ss;
        mp[ss]++;
        mx = max(mx, mp[ss]);
    }

    for(auto x: mp) {
        if (x.second == mx) {
            cout << x.first << "\n";
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll N = 3e5 + 5; 
const ll MAX = 3e5 + 5; 
const ll M = 1e6 + 5;

int main(){
    int a;
    cin>>a;
    if (a >= 30){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3660
#include<cstdio>
int main(void){
int a,b,i,s;
while(scanf("%d",&a)!=EOF){
 scanf("%d",&b);
 s=a+b;
 for(i=0;s>0;i++){
  s/=10;
 }
 printf("%d\n",i);
}
return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void visit(int);

int n, time, M[100][100], color[100], d[100], f[100];

int main()
{
  int i, j, u, k, v;

  scanf("%d", &n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j] = 0;
	  d[i] = 0; f[i] = 0;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d", &u, &k); u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d", &v); v--;
	  M[u][v] = 1;
	}
    }

  dfs();

  return 0;
}

void dfs(void)
{
  int i;
  for(i=0;i<n;i++)
    {
      color[i] = WHITE;
    }
  
  for(i=0;i<n;i++)
    {
      if(color[i] == WHITE)visit(i);
    }
  
  for(i=0;i<n;i++)
    {
      printf("%d %d %d\n", i+1, d[i], f[i]);
    }
}

void visit(int u)
{
  int v;
  
  color[u] = GRAY;
  d[u] = ++time;
  for(v=0;v<n;v++)
    {
      if(M[u][v]==1 && color[v] == WHITE)visit(v);
    }
  color[u] = BLACK;
  f[u] = ++time;
}



Measured memory_bytes: 2104
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  while(1){
    int n;
    scanf("%d",&n);
    if(n == 0)return 0;
    int color = -1, go;
    vector<int> stones;
    for(int i = 1;i <= n;i++){
      scanf("%d", &go);
      
      if(i % 2 == 1){
	if(color != go){
	  stones.push_back(1);
	}
	else{
	  stones[stones.size() - 1]++;
	}
      }
      else{
	if(color != go){
	  if(stones.size() == 1){
	    stones[stones.size() - 1]++;
	  }
	  else{
	    int tmp = stones.back();
	    stones.pop_back();
	    stones[stones.size() - 1] += tmp + 1;
	  }
	}
	else{
	  stones[stones.size() - 1]++;
	}
      }
      color = go;
    }
    int res = 0;
    for(int i = stones.size() - 1;i >= 0;i--){
      if(color == 0)res += stones[i];
      color ^= 1;
    }
    printf("%d\n", res);
  }
}

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

int main()
{
    int a[10];
for(int i=0;i<3;i++)cin>>a[i];
sort(a,a+3);
if(a[0]==5&&a[1]==5&&a[2]==7)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;


return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
template<typename T> istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec)	is >> x;
	return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
	os << "[";
	rep(i, vec.size())	os << (i ? ", " : "") << vec[i];
	os << "]";
	return os;
}
template<typename T> istream& operator >> (istream& is, pair<T, T>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T> ostream& operator << (ostream& os, pair<T, T>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e9;
const ld infl = 1e100;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

// BW -> WB
// BBW -> BWB -> WBB
int main() {
	string s;	cin >> s;
	ll ret = 0;
	ll add = 0;
	rep(i, s.size()) {
		if (s[i] == 'B')	add++;
		else if (s[i] == 'W')	ret += add;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int W[N];
    int sum[N+1];
    sum[0]=0;
    rep(i,N) {
        cin >> W[i];
        sum[i+1]=sum[i]+W[i];
    }
    int ans=INF;
    rep(i,N){
        ans=min(ans,abs(sum[N]-2*sum[i]));
    }
    cout << ans << endl;





}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << '+' << endl;
    }
    else if(a*b==15){
        cout << '*' << endl;
    }
    else{
        cout << 'x' << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

#define mod 1000000007

int main(){
		int n;scanf("%d",&n);
		int soyakusu[1001]={0};
		int i,tmp;
		long long ans=1;
		for(i=1;i<=n;i++){
				int j,flag=0;
				tmp=i;
				for(j=2;j<=tmp;j++){
		/*				if(flag==1){
								j=2;
								flag=0;
						}*/
						if(tmp%j==0){
								soyakusu[j]++;
								tmp=tmp/j;
								flag=1;
								j=1;
						}
				}
		}
		for(i=1;i<=n;i++){
	//			printf("%d,",soyakusu[i]);
				ans=(ans*(soyakusu[i]+1))%mod;
		}
//		puts("");
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin >> s;
    set<char> k(begin(s), end(s));
    int ans = s.size();
    for (char c : k) {
        string t = s;
        string u = string(s.size(), c);
        if (equal(begin(t), end(t), begin(u))) {
            ans = 0;
            break;
        }
        for (int i = s.size()-1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (t[j+1] == c) {
                    t[j] = c;
                }
            }
            if (equal(begin(t), begin(t)+i, begin(u))) {
                ans = min<int>(ans, s.size() - i);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (col[j]&&row[i]) {
				cout << a[i][j];
			}
		}
		cout << endl;
	}
}


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

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};



ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a,b;
    cin >> n >> a >> b;
    
    modular ans = quick_pow(2, n);
    

    
    
    ans -= 1;
    
    
    
    vector<int> fac(max(a,b) + 1), finv(max(a,b) + 1);
    int to = max(a,b);
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= to; ++i)
        fac[i]=(ll)fac[i-1]*i%mod;
    
    finv[to] = quick_pow(fac[to], mod-2);
    for(int i = to-1; i; --i)
        finv[i] = (ll)finv[i+1]*(i+1)%mod;
    
    auto combo = [&](int n, int k){
        modular res = 1;
        for (int i = 0; i < k; i++){
            res *= n-i;
        }
        
        res *= finv[k];
        return  res;
    };

    ans -= combo(n, a);
    ans -= combo(n, b);
    cout << ans << "\n";


    
    
    return 0;
}


Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<vector<int>>edge(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--, R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	long long int a = 1, b = 1;
	vector<int>used(N);
	for (int i = 0; i < 2; i++) {
		used[i] = 1;
		queue<int>Q;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : edge[cn]) {
				if (used[j])continue;
				used[j] = 1;
				if (i == 0)a++;
				else b++;
				Q.push(j);
			}
		}
	}
	if (a < b)swap(a, b);
	a = N - b;
	cout << a * (a - 1) / 2 + b * (b - 1) / 2 - M << endl;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
typedef double D;
const D EPS = 1e-8;
const D INF = 1e9;
const D PI = M_PI;

struct P {
    D x, y;
    P(D x, D y) : x(x), y(y) { }
    P() { }
};

P operator +(P a, P b) {
    a.x += b.x, a.y += b.y;
    return a;
}

P operator -(P a, P b) {
    a.x -= b.x, a.y -= b.y;
    return a;
}

// ???????????????
P operator *(P p, D s) {
    p.x *= s, p.y *= s;
    return p;
}

D inp(P a, P b) {
    return a.x*b.x + a.y*b.y;
}

D outp(P a, P b) {
    return a.x*b.y - a.y*b.x;
}

D norm(P p) {
    return inp(p, p);
}

D abs(P p) {
    return sqrt(norm(p));
}

D arg(P p) {
    return atan2(p.y, p.x);
}

bool eq(P a, P b) {
    return abs(a-b) < EPS;
}

P rot90(P p) {
    return P(-p.y, p.x);
}

// angle???????????????radian
P rot(P p, D angle) {
    P q;
    q.x = cos(angle)*p.x - sin(angle)*p.y;
    q.y = sin(angle)*p.x + cos(angle)*p.y;
    return q;
}

struct L : vector<P> {
    L(P a, P b) {
        this->push_back(a);
        this->push_back(b);
    }

    L() {
        this->resize(2);
    }
};

struct C {
    P p; double r;
    C(P p = P(), double r = 0) : p(p), r(r) { }
};

// ??卒???l???????????????p?????????
// (l??????p??????????????????????????即????????????????賊???????)
// norm??則?????贈?????????(abs??則??????????????????)
P projection(L l, P p) {
    P a = l[1] - l[0];
    P b = p - l[0];
    double t = inp(b, a) / norm(a);
    return l[0] + a * t;
}

// ??卒???l???????????????p???????属?
// (l????????????????則属???p??????)
P reflection(L l, P p) {
    return p + (projection(l, p) - p) * 2;
}

int ccw(P a, P b, P c) {
    b = b - a; c = c - a;

    // a - b - c ????????????????????即???
    if(outp(b, c) > EPS)  return +1; // ???????即???????
    if(outp(b, c) < -EPS) return -1; // ????即???????

    // a - b - c ??卒??????????????其??即???
    if(inp(b, c) < 0)     return +2; // c - a - b
    if(norm(b) < norm(c)) return -2; // a - b - c
    return 0;                        // a - c - b
}

int main() {
    D x, y;

    cin >> x >> y;
    P p0(x, y);

    cin >> x >> y;
    P p1(x, y);

    int Q; cin >> Q;
    while(Q--) {
        cin >> x >> y;
        P p2(x, y);
        int res = ccw(p0, p1, p2);
        switch(res) {
            case +1: puts("COUNTER_CLOCKWISE"); break;
            case -1: puts("CLOCKWISE"); break;
            case +2: puts("ONLINE_BACK"); break;
            case -2: puts("ONLINE_FRONT"); break;
            case  0: puts("ON_SEGMENT"); break;
        }
    }
}

Measured memory_bytes: 1188
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    d = sum(a)
    
    if n - d >= 0:
        print(n - d)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10076
#include<stdio.h>

int main(){
	int i, m, n, a[1000], b, c[1000], j;
	scanf("%d %d", &m, &n);
	for (i = 0; i < m; i++)	{
		scanf("%d", &a[i]);
		c[i] = 0;
	}
	for (i = 0; i < n; i++){
		scanf("%d", &b);
		for (j = 0; j < m; j++){
			if (a[j] <= b){
				c[j]++;
				break;
			}
		}
	}
	j = 0;
	for (i = 1; i < m; i++){
		if (c[j] < c[i]) j = i;
	}
	printf("%d\n", j + 1);
	return 0;
}

Measured memory_bytes: 604
// https://atcoder.jp/contests/abc087/tasks/abc087_b
"use strict"
function Main(input) {
  const params = input.split('\n').map(Number);
  const a = params[0];
  const b = params[1];
  const c = params[2];
  const x = params[3];
  let count = 0;
  for (let i = 0; i <= a; i++) {
    for (let j = 0; j <= b; j++) {
      for (let k = 0; k <= c; k++) {
        const sum = (500 * i) + (100 * j) + (50 * k);
        const price = x - sum;
        if (price === 0) {
          count++;
        }
      }
    }
  }

  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int D;
	cin >> D;
	if(D == 22){
		cout << "Christmas Eve Eve Eve" << endl;
	} else if(D == 23){
		cout << "Christmas Eve Eve" << endl;
	} else if(D == 24){
		cout << "Christmas Eve" << endl;
	} else{
		cout << "Christmas" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
X,Y,A,B,C=map(int,input().split())
*P,=sorted(map(int,input().split()))
*Q,=sorted(map(int,input().split()))
*R,=map(int,input().split())

P=P[-X:]
Q=Q[-Y:]
R=sorted(P+Q+R)
ans=sum(R[-(X+Y):])
print(ans)

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

int n;

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

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

    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>

int tab[15][15],a[15][15],fl[15][15],fi[15];
int n,m,w,l,ans;

void perm(int team,int wn,int ls,int cur){
    if(wn==0&&ls==0){
        if(team==n){
            ans++;
            return ;
        }
        int j=0;
        int il[15],ii=0;
        for(int i=1;i<=n;i++){
            if(tab[team][i]==0&&i!=team){
                il[ii++]=i;
                tab[team][i]=fl[team][j];
                tab[i][team]=fl[team][j++]%2+1;
            }
        }
        w=n/2; l=n/2;
        for(int i=1;i<=n;i++){
            if(tab[team+1][i]==1)
                w--;
            else if(tab[team+1][i]==2)
                l--;
        }
        perm(team+1,w,l,0);
        for(int i=0;i<ii;i++){
            tab[team][il[i]]=0;
            tab[il[i]][team]=0;
        }
        return ;
    }
    if(wn>0){
        fl[team][cur]=1;
        perm(team,wn-1,ls,cur+1);
    }
    if(ls>0){
        fl[team][cur]=2;
        perm(team,wn,ls-1,cur+1);
    }
}

int main(){
    while(true){
        ans=0;
        scanf("%d",&n);
        if(n==0)
            return 0;
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                tab[i][j]=0;
                a[i][j]=0;
                fl[i][j]=0;
            }
            fi[i]=0;
        }
        scanf("%d",&m);
        int tmp1,tmp2;
        for(int i=0;i<m;i++){
            scanf("%d%d",&tmp1,&tmp2);
            a[tmp1][tmp2]=tab[tmp1][tmp2]=1;
            a[tmp1][tmp2]=tab[tmp2][tmp1]=2;
        }
        w=n/2; l=n/2;
        for(int i=1;i<=n;i++){
            if(tab[1][i]==1){
                w--;
            }
            else if(tab[1][i]==2)
                l--;
        }
        perm(1,w,l,0);
        printf("%d\n",ans);
    }

}



Measured memory_bytes: 2724
#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 X;
  cin >> X;

  ll now = 100;
  ll ret = 0;
  while(true){
    ret++;
    now = now * 1.01;
    if(now >= X) break;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int,input().split())
h = ty-sy
w = tx-sx
ans = ""
def f(k, ch):
    global ans
    for i in range(k):
        ans += ch

f(h, "U")
f(w, "R")
f(h, "D")
f(w, "L")
f(1, "L")
f(h+1, "U")
f(w+1, "R")
f(1, "D")
f(1, "R")
f(h+1, "D")
f(w+1, "L")
f(1, "U")
print(ans)


Measured memory_bytes: 3064
n = int(input())
h = [int(x.strip()) for x in input().split()]
i, ch, ans = 0, 0, 0
while i < n-1:
  if h[i] >= h[i+1]:
    ch += 1
  elif h[i] < h[i+1]:
    if ch > ans:
      ans = ch
    ch = 0
  i += 1
if ch > ans:
  ans = ch
print(ans)

Measured memory_bytes: 20136
#include<stdio.h>

double n;

int main(){
	while(scanf("%lf",&n)!=EOF){
		if(n<=48.0)printf("light fly\n");
		else if(n<=51.0)printf("fly\n");
		else if(n<=54.0)printf("bantam\n");
		else if(n<=57.0)printf("feather\n");
		else if(n<=60.0)printf("light\n");
		else if(n<=64.0)printf("light welter\n");
		else if(n<=69.0)printf("welter\n");
		else if(n<=75.0)printf("light middle\n");
		else if(n<=81.0)printf("middle\n");
		else if(n<=91.0)printf("light heavy\n");
		else printf("heavy\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;

#define ran 101101

int n;
int a[ran], f[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	
	int h = 0;
	for(int i=n-1;i>=0;i--) {
		int p = upper_bound(f, f+h, a[i]) - f;
		if (p>=h) f[h++] = a[i];
		else f[p] = a[i];
	}
	printf("%d\n", h);
	
	return 0;
}

Measured memory_bytes: 896
import heapq

n, m = map(int, input().split())
A = [[] for _ in range(m)]
ans = 0

for i in range(n):
    a, b = map(int, input().split())
    if m-a < 0:
        continue
    else:
        A[m-a].append(b)

available = []

for i in range(m-1, -1, -1):
    for item in A[i]:
        heapq.heappush(available, -item)
    if available:
        ans += -heapq.heappop(available)

print(ans)

Measured memory_bytes: 24412
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long N, ans=0; cin >> N;
for(long i=2; i*i<=N; i++){ 
  int c=0, d=0;
  while(N%i==0){ 
  c++;
  if(d<c){ ans++; d++; c=0; }
  N/=i;
  }
}
if(N!=1){ ans++; }
cout << ans << "\n";
}


Measured memory_bytes: 3640
inf = 10**9 + 7
n, k = map(int, input().split())

nodes = list(map(int, input().split()))
dp = [inf] * n

dp[0] = 0

for i in range(n):
    for j in range(i+1, min(i+k+1, n)):
        dp[j] = min(dp[j], dp[i] + abs(nodes[i] - nodes[j]))
# for i in range(n):
#     for j in range(1, min(k+1, n-i)):
#         dp[i+j] = min(dp[i+j], dp[i]+abs(nodes[i]-nodes[i+j]))
print(dp[n-1])


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

double solve() {
    ll N;
    cin >> N;
    vector<double> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i];
    }
    double s = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = i+1; j < N; j++ ) {
            s += sqrt((X[i]-X[j])*(X[i]-X[j]) + (Y[i]-Y[j])*(Y[i]-Y[j]));
        }
    }
    double ans = 2*s / N;
    return ans;
}

int main() {
    cout.precision(15);
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256