akhauriyash/Code-Regression huggingface dataset:
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		Map<String, Integer> map = new HashMap<String, Integer>();
		try {
			sc = new Scanner(System.in);
			String[] sentence = sc.nextLine().split(" ");

			for (String s : sentence) {
				map.put(s, map.containsKey(s) ? map.get(s) + 1 : 1);
			}
			String maxFrequencyWord = "";
			int maxFrequency = Collections.max(map.values());
			for (Map.Entry<String, Integer> entry : map.entrySet()) {
				if (maxFrequency == entry.getValue()) {
					maxFrequencyWord = entry.getKey();
				}
			}

			String maxLengthWord = Collections.max(map.keySet(),
					new Comparator<String>() {
						@Override
						public int compare(String o1, String o2) {
							return o1.length() - o2.length();
						}
					});

			System.out.println(maxFrequencyWord + " " + maxLengthWord);

		} finally {
			sc.close();
		}
	}
}

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

int main() {
  int i,j,n,l;
  string s[110],tmp;
  cin>>n>>l;
  for(i=0;i<n;i++){
    cin>>s[i];
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(s[i]>s[j]){
        tmp=s[i];
        s[i]=s[j];
        s[j]=tmp;
      }
    }
  }
  for(i=0;i<n;i++){
    cout<<s[i];
  }
  cout<<endl;
}



Measured memory_bytes: 256
import heapq
(N,K) = map(int,input().split())
h = [int(x)*-1 for x in input().split()]
ans = 0
heapq.heapify(h)
if K <= N:
    for i in range(K):
        heapq.heappop(h)

    while h != []:
        ans -= heapq.heappop(h)

print(ans)

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

using namespace std;

const int64_t INF = 1e18L + 5;
const int MAX_W_V_SIZE = 105, M = 2e5 + 5;
int64_t W[105], V[105], dp[M];


int main() {
    int n, w, max_val;
    cin >> n >> w;
    max_val = 0;

    for (int i = 0; i < n; i++) cin >> W[i] >> V[i], max_val+=V[i];
    for (int i = 0; i <= M; i++) dp[i] = INF;

    dp[0] = 0;
    for (int k = 0; k < n; k++) {
        for (int x = max_val - V[k]; x >= 0; x--) {
            if(dp[x] || !dp[0]){
                dp[x + V[k]] = min(dp[x + V[k]], W[k] + dp[x]);
            }
        }
    }

    int64_t m = 0;
    for (int i = 0; i <= max_val; i++) {
        //cout << dp[i] << " ";
        if (dp[i] <= w) {
            m = max(m, (int64_t)i);
        }
    }

    cout << m;

    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> pre(m+1),year(m+1),precount(n+1),city_precount(m+1);
    for(int i=0; i<=n; i++)precount[i]=1;
    map<int,int> year_city;
    for(int i=1; i<=m; i++){
        cin >> pre[i] >> year[i];
        year_city[year[i]]=i;
    }
    vector<int> sort_year=year;
    sort(sort_year.begin(),sort_year.end());
    for(int i=1; i<=m; i++){
        int city_num=year_city[sort_year[i]];
        city_precount[city_num]=precount[pre[city_num]]++;
    }
    for(int i=1; i<=m; i++){
        printf("%06d%06d\n",pre[i],city_precount[i]);
    }
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a>b){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }
    if(a>b){
        ans += a;
        a--;
    }else{
        ans += b;
        b--;
    }
    cout << ans;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
P_list=[int(p) for p in input().split()]

class Unionfind:
  def __init__(self,n):
    self.Tree=[i for i in range(n)]
    self.rank=[0]*n

  def find(self,x):
    if x==self.Tree[x]:
      return x
    else:
      root=self.find(self.Tree[x])
      self.Tree[x]=root
      return root

  def unite(self,x,y):
    s1=self.find(x)
    s2=self.find(y)
    if s1==s2:
      pass
    else:
      if self.rank[s1]>self.rank[s2]:
        self.Tree[s2]=s1
      elif self.rank[s1]<self.rank[s2]:
        self.Tree[s1]=s2
      else:
        self.Tree[s2]=s1
        self.rank[s1]+=1
        
T=Unionfind(N)
for m in range(M):
  x,y=map(int,input().split())
  T.unite(x-1,y-1)
ans=0
for i in range(N):
  if T.find(P_list[i]-1)==T.find(i):
    ans+=1
print(ans)
        
        
      
        


Measured memory_bytes: 13880
#define NODE 0
#define WEIGHT 1
#define COST_IDX 0
#define TIME_IDX 1
#define P_IDX 0
#define Q_IDX 1
#define R_IDX 2
#include <iostream>
#include <cstring>
using namespace std;

int n, m, k;
int weights[101][101][2];
int min_w[101][101][2];
int requests[200][3];

bool read_input() {
  cin >> n >> m;
  if (n*m == 0) 
    return false;
  memset(weights, 0, sizeof(int)*101*101*2);
  memset(min_w, 0, sizeof(int)*101*101*2);
  for (int i = 0; i < n; i++) {
    int a, b, c, t;
    cin >> a >> b >> c >> t;
    weights[a][b][COST_IDX] = weights[b][a][COST_IDX] = c;
    weights[a][b][TIME_IDX] = weights[b][a][TIME_IDX] = t;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> requests[i][P_IDX] >> requests[i][Q_IDX] >> requests[i][R_IDX];
  }
  return true;
}

int resolve_request(int i_th) {
  int p, q, r;
  p = requests[i_th][P_IDX];
  q = requests[i_th][Q_IDX];
  r = requests[i_th][R_IDX];

  if (min_w[p][q][r])
    return min_w[p][q][r];

  int weight_sum_map[101];
  int in_queue[101] = {}; // set all to 0
  memset(weight_sum_map, -1, sizeof(int)*101);
  
  /* starting node has weight_sum of 0 */
  weight_sum_map[p] = 0;
  in_queue[p] = 1;
  int current_node = p; // first in queue is p

  while (current_node != q) {
    int weight_sum = weight_sum_map[current_node];
    in_queue[current_node] = 0;
    min_w[p][current_node][r] = weight_sum;
    
    for (int i = 1; i < 101; i++) {
      if (!weights[current_node][i][r]) 
	continue;
      int adj_node = i;
      int w = weights[current_node][adj_node][r];
      int new_weight_sum =  weight_sum + w;
      if (weight_sum_map[adj_node] == -1 || new_weight_sum < weight_sum_map[adj_node]) {
	weight_sum_map[adj_node] = new_weight_sum;
	in_queue[adj_node] = 1;
      }
    }
    
    int min_sum = -1;
    for (int i = 1; i < 101; i++) {
      if (in_queue[i] && (min_sum == -1 || weight_sum_map[i] < min_sum)) {
	min_sum = weight_sum_map[i];
	current_node = i;
      }
    }
  }
  return weight_sum_map[q];
}

void solve() {
  for (int i = 0; i < k; i++)
    cout << resolve_request(i) << endl;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  while(read_input()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3264
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            double[] s = ReadLine().Split(' ').Select(double.Parse).ToArray();
            var ls = new List<double>();
            ls.AddRange(s);
            for (int i = 0; i < n-1; i++)
            {
                ls.Sort();
                ls.Add(Func(ls[0], ls[1]));
                ls.Remove(ls[0]);
                ls.Remove(ls[0]);
            }
            WriteLine(ls[0]);
        }

        static double Func(double x,double y)
        {
            return (x + y) / 2;
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli a[110] = {};

int main(void) {

	lli N, x;
	cin >> N >> x;

	FOR(N)
		cin >> a[i];

	sort(a, a + N);

	lli ans = 0;

	for (int i = 0; i < N && a[i] <= x; i++) {
		x -= a[i];
		ans++;
		if (i == N - 1 && x != 0)
			ans--;
	}



	COUT(ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;

int dy[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx[8] = { 1,-1,1,-1,2,-2,2,-2 };



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 998244353;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }



int dp[100005];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string S;
	cin >> S;

	dp[0] = 0;
	for (int i = 0; i < N; i++)
	{
		if (i + 1 < N && S[i] != S[i + 1]) {
			dp[i + 2] = max(dp[i + 2], dp[i] + 1);
		}
		else
		{
			dp[i + 1] = max(dp[i + 1], dp[i]);
		}

	}

	cout << dp[N] << endl;






}


Measured memory_bytes: 3704
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
#define ll long long
int main()
{
    ll a,b,c,d;
    ll area1,area2,area;
    cin>>a>>b>>c>>d;
    area1=a*b;
    area2=c*d;
    area=max(area1,area2);
    cout<<area;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000005
#define int long long
#define ll long long
using namespace std;
struct edge {
	int v, nxt, c;
} e[N << 1];
int p[N], eid;
void init() {
	memset(p, -1, sizeof p);
	eid = 0;
}
void insert(int u, int v, int c) {
	e[eid].v = v;
	e[eid].c = c;
	e[eid].nxt = p[u];
	p[u] = eid ++;
}
int l, r, a[N], size[N], msize[N], vis[N], w[N], dis[N], szz;
void dfs(int u, int fa) {// printf(" %lld %lld\n", u, fa);
	msize[u] = 0;
	a[++ r] = u; size[u] = 1;
	for(int i = p[u]; i + 1; i = e[i].nxt) {
		int v = e[i].v, c = e[i].c;
		if(vis[v] || v == fa) continue;
		dfs(v, u);
		size[u] += size[v];
		if(size[v] > msize[u]) msize[u] = size[v];
	}
}
void dfss(int u, int fa, ll sum) {
	dis[u] = sum; 
	for(int i = p[u]; i + 1; i = e[i].nxt) {
		int v = e[i].v, c = e[i].c;
		if(v == fa || vis[v]) continue;
		dfss(v, u, sum + c);
	}
}
struct AA {
	int u, v; ll c;
} ee[N << 3];
void solve(int u) { 
	l = 1, r = 0;
	dfs(u, u);
	int sz = size[u];
	for(int i = 1; i <= r; i ++) {
		int v = a[i];
		if(max(msize[v], sz - size[v]) < max(msize[u], sz - size[u])) u = v;
	}
	dis[u] = 0;
	vis[u] = 1;
	for(int i = p[u]; i + 1; i = e[i].nxt) {
		int v = e[i].v;
		if(vis[v]) continue;
		dfss(v, u, e[i].c);
	}
	int ma = u;
	for(int i = l; i <= r; i ++) {
		int v = a[i];
		if(dis[v] + w[v] < dis[ma] + w[ma]) ma = v;		
	}
	for(int i = l; i <= r; i ++) {
		int v = a[i];
		if(v == ma) continue;
		ee[++ szz] = {ma, v, w[ma] + w[v] + dis[v] + dis[ma]};
	}
	
	for(int i = p[u]; i + 1; i = e[i].nxt) {
		int v = e[i].v;
		if(vis[v]) continue;
		solve(v);
	}
}
int cmp(AA x, AA y) {
	return x.c < y.c;
}
int fa[N], n;
int get(int x) {
	return fa[x] == x ? x : fa[x] = get(fa[x]);
}
signed main() {
	init();
	scanf("%lld", &n);
	for(int i = 1; i <= n; i ++) scanf("%lld", &w[i]), fa[i] = i;
	for(int i = 2; i <= n; i ++) {
		int u, v, c;
		scanf("%lld%lld%lld", &u, &v, &c);
		insert(u, v, c);
		insert(v, u, c);
	}
	solve(1); 
	sort(ee + 1, ee + 1 + szz, cmp);
	ll ans = 0;
	for(int i = 1; i <= szz; i ++) {
		int u = ee[i].u, v = ee[i].v; ll c = ee[i].c;
		u = get(u), v = get(v);
		if(u == v) continue;
		fa[u] = v; ans += c;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 138112
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1e9)
#define LINF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second
#define MOD 1000000007

int main() {
	int n, T;
	cin >> n >> T;
	vector<int> c(n), t(n);
	REP(i, n) cin >> c[i] >> t[i];
	int m = INF;
	REP(i, n) {
		if (t[i] > T) continue;
		m = min(m, c[i]);
	}
	if (m == INF) {
		cout << "TLE" << endl;
	}
	else {
		cout << m << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a*b % 2 == 0) System.out.println("No");
        else System.out.println("Yes");
    }
}

Measured memory_bytes: 26860
function main(arg) {
  var str = arg.trim();
  if (str == "ABC") {
    console.log("ARC");
    return;
  } else if (str == "ARC") {
    console.log("ABC");
    return;
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//https:/ / atcoder.jp / contests / abc166 / tasks / abc166_a;


Measured memory_bytes: 29680
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s, t; cin >> s >> t;
    int ans = 100000;
    for (int i = 0; i < s.size()-t.size()+1; i++) {
        int tmp = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    int n; cin >> n;
    vector<ll> A(n); rep(i, n) cin >> A[i];
    map<ll, ll> L, R;
    rep(i, n){
        int l = A[i] + i + 1;
        int r = i + 1 - A[i];
        L[l]++, R[r]++;
    }
    ll sum = 0;
    auto begin = L.begin(), end = L.end();
    for (auto iter = begin; iter != end; iter++) {
       sum +=  L[iter->first] * R[iter->first];
    }
    cout << sum << ln;
}



Measured memory_bytes: 39092
import sys
        
def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


        

N, Q = map(int, input().split())
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

P = getpar(Edge, 0)
L = topological_sort_tree(Edge, 0)
C = getcld(P)

dp1 = [0]*N

for q in range(Q):
    p, x = map(int, sys.stdin.readline().split())
    dp1[p-1] += x

for l in L:
    d = dp1[l]
    for c in C[l]:
        dp1[c] += d

print(' '.join(map(str, dp1))) 


Measured memory_bytes: 130664
#include <stdio.h>

int main()
{
  int N, M, A, t;
  A=0;
  
  scanf("%d %d\n", &N, &M);
  
  for(int i=0; i<M; i++)
  {
    scanf("%d",&t);
    A+=t;
  }
  t=N-A;
  if(t>=0)
    printf("%d\n",t);
  else
    printf("%d\n",-1);
  
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;

void solve(istream& cin, ostream& cout) {
	cin >> n>>m;
	vector<int> A(m);
	cin >> A;
	ll sum = 0;
	REP(i, m) sum += A[i];
	if(sum > n) cout << -1 <<endl;
	else cout << n-sum << endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


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

int main()
{
	int n,k,h,count=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (h >= k) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/4/2018
 
 13:30-14:30 give up
 14:30-16:00 read editorials
 
 I tried to count rectangles though, I couldn't move forward AT ALL.
 
 Editorials:
  - https://youtu.be/HAxMNuhoQ3E?t=1813
 
 2D -> 1D (independence). Fxck.
 N<=1e5, M<=1e5. That means we MUST solve something for `x` and `y` separtely. Fxck.
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N,M;
LL X[MAX_N],Y[MAX_N];
const LL MOD=1e9+7;
LL f(vector<LL> ns) {
  LL res=0;
  int L=SZ(ns);
  REP(i,L) res+=((1LL*(i+1)*(L-i)%MOD)*ns[i])%MOD,res%=MOD;
  return res;
}
void solve() {
  vector<LL> A(N-1),B(M-1);
  REP(i,N-1) A[i]=X[i+1]-X[i];
  REP(i,M-1) B[i]=Y[i+1]-Y[i];
  LL res=f(A);
  res*=f(B),res%=MOD;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,N) cin>>X[i];
  REP(i,M) cin>>Y[i];
  solve();
  return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>


using namespace std;



int main() {
	
	int mod = 1000000007;
	int N,M;
	cin >> N >> M;

	vector<int> a(M);
	for (int i = 0; i < M; i++)
		cin >> a[i];

	vector<int> count(N + 1);
	count[0] = 1;


	fill(count.begin(), count.end(), 1);
	for (int i = 0; i < M; i++)
		count[a[i]] = 0;



	for (int i = 2; i <= N; i++) {
		if (count[i]) {
			count[i] = (count[i - 1] + count[i - 2]) % mod;
		}
		else {
			continue;
		}
	}

	cout << count[N];
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, a, b, m = 1e9;
  cin >> n >> k;
  v1i v(n);
  rep(i, n) cin >> v[i];
  rep(i, n-k+1){
    m = min(m, abs(v[i])+v[i+k-1]-v[i]);
    m = min(m, abs(v[i+k-1])+v[i+k-1]-v[i]);
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n],sum[n+1];
    sum[0]=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
        sum[i+1]=sum[i]+a[i];
    }
    sortup(sum,n+1);
    ll q=1;
    rep(i,0,n){
        if(sum[i]==sum[i+1]){
            q++;
        }else{
            ans+=q*(q-1)/2;
            q=1;
        }
    }
    ans+=q*(q-1)/2;
    // ll sum;
    // rep(i,0,n){
    //     sum=a[i];
    //     if(sum==0){
    //         ans++;
    //     }
    //     rep(j,i+1,n){
    //         sum+=a[j];
    //         if(sum==0) ans++;
    //     }
    // }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4860
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

struct edge{
    int f, t;
};

const int V_MAX = (int)1e5 + 10;
vector<int> edges[V_MAX];
int ord[V_MAX];
int low[V_MAX];
bool used_v[V_MAX];
vector<edge> ans;

bool comp(edge e1, edge e2){
    if(e1.f == e2.f){
        return e1.t < e2.t;
    } else {
        return e1.f < e2.f;
    }
}

void dfs(int u, int prev, int k){
    low[u] = ord[u] = k;
    k += 1;
    used_v[u] = true;

    for(int i=0; i<edges[u].size(); i++){
        int next = edges[u][i];

        if(not used_v[next]){
            dfs(next, u, k);
            low[u] = min(low[u], low[next]);

            if(low[next] > ord[u]){
                edge e;
                e.f = min(u, next); e.t = max(u, next);
                ans.push_back(e);
            }
        } else if(prev != next){
            low[u] = min(low[u], ord[next]);
        }
    }
    return ;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int v, e; 
    cin >> v >> e;

    for(int i=0; i<e; i++) {
        int a, b;
//        scanf("%d %d", &a, &b);
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    dfs(0, -1, 1);

    sort(ans.begin(), ans.end(), comp);
    for(int i=0; i<ans.size(); i++){
        cout << ans[i].f << " " << ans[i].t << "\n";
    }

    return 0;
}

Measured memory_bytes: 7132
N, M, X, Y = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]


for z in range (-150, 150):
    f = True
    if X >= z:
        f = False
    if Y < z:
        f = False
    
    for a in A:
        if a >= z:
            f = False
    
    for b in B:
        if b < z:
            f = False
    
    if f:
        print("No War")
        break
else:
    print("War")
    


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

/*
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 a
1011 b
1100 c
1101 d
1110 e
1111 f
*/

const unsigned char BIT_DATA[10] = {
	0x3f,
	0x06,
	0x5b,
	0x4f,
	0x66,
	0x6d,
	0x7d,
	0x27,
	0x7f,
	0x6f
};

void showAsBinary(unsigned char num){
	for(int i = 0;i < 7;i++){
		if(num & (0x40 >> i)) cout << '1';
		else cout << '0';
	}
	cout << endl;
}

int main(){
	
	int n;
	while(1){
		cin >> n;
		if(n == -1) break;
		unsigned char data = 0;
		for(int i = 0;i < n;i++){
			int num;
			cin >> num;
			showAsBinary(data ^ BIT_DATA[num]);
			data = BIT_DATA[num];
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, M;
  while(cin>>N>>M && N){
    vector<int> v1(N);
    vector<int> v2(M);
    REP(i, N) cin>>v1[i];
    REP(i, M) cin>>v2[i];
    int ans = 0;
    REP(s, M){
      int g = s;
      REP(i, N){
        if(v1[i] == v2[g]) g++;
        if(g == M) break;
      }
      ans = max(ans, g - s);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 904
<?php
  
  $a = explode(" ",fgets(STDIN));
  $b = explode(" ",fgets(STDIN));

  $count = 0;

  for($i= 0; $i <= $a[0]; $i += 2){
   	if($b[$i] % 2 !== 0){
      $count++;
    }
  }

  echo $count;

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

int main(){
  string s;
  cin>>s;
  ll sum=0;
  rep(i,s.size()){
    int a = s[i]-'0';
    sum+=a; 
  }
  if(sum%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Edge
    {
        internal int u, v, cost;
    }

    class UnionFindNode
    {
        internal UnionFindNode parent;
        internal int rank;
    }

    class UnionFind
    {
        Dictionary<object, UnionFindNode> _dict;

        public UnionFind()
        {
            _dict = new Dictionary<object, UnionFindNode>();
        }

        public void Unite(IComparable x, IComparable y)
        {
            var xRoot = Root(x);
            var yRoot = Root(y);

            if (xRoot == yRoot) return;

            if (xRoot.rank < yRoot.rank)
            {
                xRoot.parent = yRoot;
            }
            else
            {
                yRoot.parent = xRoot;

                if (xRoot.rank == yRoot.rank) xRoot.rank++;
            }
        }

        public bool IsSame(IComparable x, IComparable y)
        {
            return Root(x) == Root(y);
        }

        UnionFindNode Root(object obj)
        {
            if (!_dict.ContainsKey(obj))
            {
                var node = new UnionFindNode();
                _dict.Add(obj, node);
                return node;
            }
            else
            {
                var node = _dict[obj];
                return Find(node);
            }
        }

        UnionFindNode Find(UnionFindNode node)
        {
            if (node.parent == null) return node;

            return node.parent = Find(node.parent);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List<Edge> es = new List<Edge>();

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Trim().Split(' ');
                Edge temp;

                for (int j = 0; j < n; j++)
                {
                    int cost = int.Parse(input[j]);

                    if (cost != -1)
                    {
                        temp.u = i;
                        temp.v = j;
                        temp.cost = cost;
                        es.Add(temp);
                    }
                }
            }
            Console.WriteLine(Kruskal(es, n));
        }

        static int Kruskal(List<Edge> es, int n)
        {
            es.Sort((a, b) => a.cost - b.cost);
            UnionFind uf = new UnionFind();

            int res = 0;

            for (int i = 0; i < es.Count; i++)
            {
                Edge e = es[i];

                if (!uf.IsSame(e.u, e.v))
                {
                    uf.Unite(e.u, e.v);
                    res += e.cost;
                }
            }
            return res;
        }
    }
}

Measured memory_bytes: 9740
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int ans = 0, cur = 0, n;
    cin >> n;
    loop(i, n) {
        int x; cin >> x;
        if (x < cur)
            ans += cur - x;
        else
            cur = x;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3604
N = int(input())
from operator import itemgetter
ls = [[]]*N
for i in range(N):
    ls[i]  = list(input().split())
    ls[i].append(i+1)
    ls[i][1] = int(ls[i][1])
ls = sorted(ls,key=itemgetter(1))
ls = sorted(ls,reverse=True,key=itemgetter(0))
for p,q,r in reversed(ls):
    print(r)


Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline int isVowel(const char c){
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    return 1;
  }
  if(c=='A'||c=='I'||c=='U'||c=='E'||c=='O'){
    return 1;
  }
  return 0;
}
int main(){
  char C;
  rd(C);
  if(isVowel(C)){
    wt_L("vowel");
    wt_L('\n');
  }
  else{
    wt_L("consonant");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   char C;
//   rd(C);
//   wt( if[isVowel(C), "vowel", "consonant"] );
// }


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

const int N=400005;
int n,q,a,b,d;
long long c[N],ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a),c[a]++,ans+=a;
	scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&a,&b);
		ans+=1ll*c[a]*(b-a);
		printf("%lld\n",ans);
		c[b]+=c[a],c[a]=0;
	}
}

Measured memory_bytes: 4496
def main():
    N, K = [int(v) for v in input().split()]
    H = sorted([-int(input()) for _ in range(N)])

    min_diff = 10 ** 10
    for i in range(K - 1, N):
        min_diff = min(min_diff, -H[i - K + 1] + H[i])
    print(min_diff)

main()



Measured memory_bytes: 8280
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s-1):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int main() {
    int n, ans = 0, num = 0, a;
    cin >> n;
    vector<vector<int>> as(n), bs(n);
    for (int i = 0; i < n; i++){
        cin >> a;
        for (int j = 0; j < a; j++){
            int x, y;
            cin >> x >> y;
            x--;
            if (y == 0) bs[i].push_back(x);
            else as[i].push_back(x);
        } 
    }
    for (int i = 0; i < 1 << n; i++){
        bool ok = true;
        num = 0;
        for (int j = 0; j < n; j++){
            if (i >> j & 1){
                num++;
                for (int a : bs[j]) {
                    if (i >> a & 1) {
                        ok = false;
                    }
                }
                for (int a : as[j]) {
                    if ((i >> a & 1) == 0) {
                        ok = false;
                    }
                }
            }
        }
        if (ok){
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
}

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector <T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    v a = ga(n);

    ll total = 0;
    for (auto x : a) total += x;
    ll c = 0;
    ld lim = (ld) total / (4 * m);
    for (auto x : a) {
        if (lim <= x) c++;
    }
    if (c >= m) cout << "Yes";
    else cout << "No";
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string str;
	cin >> str;
	for(ll i=0;i<(int)str.size();++i)
	{
		if(str[i] == '?') cout << 'D';
		else cout << str[i];
	}
	cout << "\n";
}

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int re= 0;
    bool boo[N];
    for(int i=0; i<N; i++){
        boo[i] = true;
    }

    
    vector<int> b, c;
    for(int i = 0; i<N; i++){
        int a;
        cin >> a;
        b.push_back(a);
        
    }
    

    for(int i=0; i<N; i++){
        if(b[i] == i+1){
            boo[i] = false;
        }
    }

    for(int i = 0; i<N; i++){
        if(boo[i] == false){
            re++;
            boo[i] = true;
            boo[i+1] = true;
        }
    }
    
    cout << re << endl;
    
    return 0;
}



Measured memory_bytes: 1020
#include<cstdio>
#include<cstring>
#include<algorithm>
#define clr(x) memset(x,0,sizeof(x))
#define MN 2005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
struct edge{
	int to,nxt;
}e[MN<<1];
int h[MN],dep[MN],siz[MN],fa[MN],dep2[MN];
int n,k,x,y,cnt,res,t,tot;
bool vis[MN],vis2[MN],mk;
inline void ins(int x,int y){
	e[++cnt].to=y;e[cnt].nxt=h[x];h[x]=cnt;
}
inline void init(){
	clr(vis);clr(siz);clr(dep);clr(dep2);clr(vis2);t=tot=0;mk=0;
}/*
inline void dfs1(int u){
	if (dep[u]>mxd) mxd=dep[u],d=u;
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (vis[v]) continue;
		vis[v]=1;dep[v]=dep[u]+1;dfs1(v);
	}
}
inline void dfs2(int u){
	if (dep[u]>mxd) mxd=dep[u],t=u;
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (vis[v]) continue;
		vis[v]=1;dep[v]=dep[u]+1;fa[v]=u;dfs2(v);
	}
}*/
inline void dfs(int u){
	siz[u]=1;if (dep[u]==k) {t=u;mk=1;return;}
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;if (vis[v]) continue;
		dep[v]=dep[u]+1;vis[v]=1;dfs(v);siz[u]+=siz[v];
	}
}
inline void dfs3(int u){
	if (dep2[u]==k) return;
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;if (vis2[v]||!vis[v]) continue;
		dep2[v]=dep2[u]+1;vis2[v]=1;dfs3(v);
	}
}
int main()
{
	n=in();k=in();
	for (int i=1;i<n;++i){
		x=in();y=in();ins(x,y);ins(y,x);
	}res=n;
	for (int i=1;i<=n;++i){
		init();vis[i]=1;dep[i]=0;dfs(i);
		if (!mk) continue;
		vis2[t]=1;dep2[t]=0;dfs3(t);
		for (int j=1;j<=n;++j) if (vis2[j]) ++tot;
		res=min(res,n-tot);
	}printf("%d",(res==n)?0:res);return 0;
}

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

const int INF = 1e9+7; 

int main(){
    int n,d;cin>>n>>d;
    int sol = 0;
    while(n--){
    	int x,y;
    	cin>>x>>y;
    	if(sqrt(pow(x,2)+pow(y,2))<=d) sol++;
    }
    cout<<sol<<endl;
    
}

Measured memory_bytes: 3612
let f x = x*x
let last_x = 600

let () =
    try
        while true do
            let sum = ref 0 in
            let d   = read_int () in
            for i   = 1 to last_x / d - 1 do
                let y    = f (i * d) in
                let area = d * y in
                sum := !sum + area
            done ;
            Printf.printf "%d\n" !sum
        done
    with
        End_of_file -> ()

Measured memory_bytes: 2288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll k=1,n,a,b;cin>>n>>a>>b;
    if(n<a+b-1 || n>a*b)return cout<<"-1" , 0;
    vector<ll> arr;
    for(ll i=0;i<a;i++){
        for(ll j=0;j<b && a-i-1+k<=n;j++)arr.push_back(k++);
        while(!arr.empty())cout<<arr.back()<<" ",arr.pop_back();
    }
}

Measured memory_bytes: 3568
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = input()
    flag = False
    for l in N:
        if l == '7':
            flag = True
        else:
            pass
    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()



Measured memory_bytes: 10304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		long c[] = new long[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(str[i]);
			c[i] = a - (i + 1);
		}

		Arrays.sort(c);
		long b = c[n / 2];

		long ans = 0;

		for (int i = 0; i < n; i++) {
			ans += Math.abs(b - c[i]);
		}

		System.out.println(ans);
	}

}

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

int main() {
  int N;
  int a,b,c,d;
  c = 0;
  d = 0;
  cin >> N;
    
   for (int i=0;i < N;i++){
     cin >> a >> b;
     c = b - a + 1;
     d += c;
    
     }
   cout << d << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var abn = s.Split(' ');
				double a = double.Parse(abn[0]), b = double.Parse(abn[1]);
				int n = int.Parse(abn[2]);

				var d = (a / b).ToString("F15").Split('.')[1].Take(n).Select(c => c - '0').Sum();
				Console.WriteLine(d);
			}
		}
	}
}

Measured memory_bytes: 5972
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
#pragma GCC optimize(2)
static const int maxn = 100005;
int a[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i = 0;i < n; ++i)
	{
		cin>>a[i];
	}
	int ret = 0,sum = 1;
	ret += k;
	k--;
	while(ret < n)
	{
		ret += k;
		sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  (x:y:s) <- getLine
  let t = zip3 (x:y:s) (y:s) s
      u = map (\(a, b, c) -> if [a, b, c] == "ABC" then 1 else 0) t
  print $ sum u

Measured memory_bytes: 508