akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// 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())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch XORWorld | diff XORWorld.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address XORWorld.cpp && ./a.out

/*
 
 3/16/2019
 
 11:25-11:54 AC
 
 n^(n+1) = 1 for even `n`
 <=> XOR{x : x=1,..,n} = { n(n%4==0), 1(n%4==1), n^1(n%4==2), 0(n%4==3) }
 
 https://img.atcoder.jp/abc121/editorial.pdf
 http://drken1215.hatenablog.com/entry/2019/03/09/224100
 https://twitter.com/259_Momone/status/1104376943535771648
 
 */

LL A,B;

// cycle property
LL f(LL X) {
  if(X<0) return 0;
  LL cy=X/4;
//  dump(X,cy,cy*4,X);
  assert(cy*4<=X);
  LL res=0;
  for(LL i=cy*4; i<=X; ++i) res^=i;
  return res;
}

// math property
LL f_math(LL X) {
  if(X<0) return 0;
  LL rem=X%4;
  if(rem==0) return X;
  if(rem==1) return 1;
  if(rem==2) return X^1;
  return 0;
}

LL f_org(LL X) {
  if(X<0) return 0;
  LL res=0;
  REP(i,45) {
    LL cy=1LL<<(i+1);
    LL a=(X+1)/cy,b=(X+1)%cy;
    LL pow=(1LL<<i);
    LL p=pow*a+max(0LL,b-pow);
    p%=2;
//    dump(i,a,b,p);
    if(p==1LL) res|=(1LL<<i);
  }
  return res;
}
void solve() {
  LL res=f(A-1)^f(B);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


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

int main()
{
	long long H, ans = 0, e_cou = 1;
	cin >> H;

	while (H != 0)
	{
		ans += e_cou;
		H = H >> 1;
		e_cou = e_cou << 1;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    foreach(int i;1..10) foreach(int j; 1..10) {
        writeln(i, "x", j, "=", i*j);
    }
}

Measured memory_bytes: 2448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ int to, cost; edge(int t, int c) :to(t), cost(c){} };

//隣接行列版dijk
vector<int> dijkstr(int s, vector<vector<int>>& graph)
{
	int n = graph.size();
	vector<int> dists(n, INF);
	vector<bool> used(n);
	dists[0] = 0;
	while (true)
	{
		int v = -1;
		rep(i, n) if (!used[i] && (v == -1 || dists[i] < dists[v])) v = i;
		if (v == -1) break;

		used[v] = true;
		rep(i, n)
			dists[i] = min(dists[i], dists[v] + graph[v][i]);
	}
	return move(dists);
}

int dxk[] = { 1, 1, 1, 0, -1, 0 };
int dxg[] = { 0, 1, 0, -1, -1, -1 };
int dy[] = { -1, 0, 1, 1, 0, -1 };


int main()
{
	//FILE* fp_out = freopen("result.txt", "w", stdout);

	int n;
	while (cin >> n)
	{
		int k; cin >> k;
		vector<vector<int>> visitable(n, vector<int>(n, INF));
		vector<vector<int>> graph(n);
		vector<int> costs(n);
		vector<int> Rs(n);
		rep(i, n) cin >> costs[i] >> Rs[i];

		rep(i, k)
		{
			int a, b; cin >> a >> b;
			a--; b--;
			graph[a].push_back(b);
			graph[b].push_back(a);
		}

		rep(i, n)
		{
			queue<P> que;
			vector<bool> visited(n);
			que.emplace(i, Rs[i]);
			while (!que.empty())
			{
				P p = que.front(); que.pop();

				visited[p.first] = true;
				visitable[i][p.first] = costs[i];
				if (p.second == 0) continue;
				for (int x : graph[p.first]) if (!visited[x])
				{
					que.emplace(x, p.second - 1);
				}
			}
		}

		cout << dijkstr(0, visitable)[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 99428
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
	
		char [][] c = new char [h][];
		for(int i = 0; i < h; i++){
		c[i] = sc.next().toCharArray();
		}
		
		
		for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){System.out.print(c[i][j]);}System.out.println("");
		for(int j = 0; j < w; j++){System.out.print(c[i][j]);}System.out.println("");
		}
	}
}

Measured memory_bytes: 15680
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
	string S;
	cin >> S;

	map<char, int> mp;
	for(auto& c : S) mp[c]++;

	int MAX = 0, MIN = S.size();
	for(auto& p : mp){
		MAX = max(MAX, p.second);
		MIN = min(MIN, p.second);
	}

	bool ok = (mp.size() > 2 && MAX - MIN <= 1);
	ok |= (S.size() == 2 && mp.size() == 2);
	ok |= (S.size() == 1);
	Cout(YES(ok));
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>

using namespace std;


int cmp(char* a,int al,char* b,int bl,int n){
	int i = n > 0 ? n : 0;
	int max = 0;
	int s = 0;
	bool f = false;
	for(;i < al && i < bl + n;i++){
		if(a[i] == b[i - n]){
			//("HIT:%c a[%d]==b[%d]\n",a[i],i,i-n);
			if(f){
				s++;
			}else{
				f = true;
				s++;
			}
		}else if(f){
			if(max < s){ max = s; }
			s = 0;
		}
	}
	if(f){
		if(max < s){max = s;}
	}
	//printf("%d -> %d\n",n,max);
	return max;
}

int main(){
	char aa[4096];
	char bb[4096];
	char ss[4096];
	char *a,*b;
	//printf("%d\n",cmp(a,5,b,5,0));
	int al,bl;
	int max;
	int s;
	while(scanf("%s %s",aa,bb) != EOF){
		al = sprintf(ss,"%s",aa);
		bl = sprintf(ss,"%s",bb);
		max = 0;
		a = aa;
		b = bb;
		for(int i = 1 - bl;i < al;i++){
			s = cmp(a,al,b,bl,i);
			if(s > max){
				max = s;
			}
		}
		b = aa;
		a = bb;
		for(int i = 1 - al;i < bl;i++){
			s = cmp(a,bl,b,al,i);
			if(s > max){
				max = s;
			}
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 784
// https://atcoder.jp/contests/abc123/tasks/abc123_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define DUMPLL(a, n) REP(_i, n) printf("%lld%c", a[_i], _i + 1 == n ? '\n' : ' ')

const int X_MAX = 1000;
const int Y_MAX = 1000;
const int Z_MAX = 1000;
const ll A_I_MAX = 10000000000;
const ll B_I_MAX = 10000000000;
const ll C_I_MAX = 10000000000;

int X, Y, Z, K;
ll A[X_MAX];
ll B[Y_MAX];
ll C[Z_MAX];

int YZ;
ll BC[Y_MAX * Z_MAX];
vector<ll> ans;

bool check(ll v) {
  int ret = 0;
  REP(i, X) {
    int lb = lower_bound(BC, BC + YZ, v - A[i]) - BC;
    ret += YZ - lb;
  }
  return ret < K;
}

void calc(ll v) {
  REP(i, X) {
    int lb = lower_bound(BC, BC + YZ, v - A[i]) - BC;
    FOR(j, lb, YZ - 1) ans.push_back(A[i] + BC[j]);
  }
}

void solve() {
  YZ = Y * Z;
  REP(i, Y) REP(j, Z) BC[i * Z + j] = B[i] + C[j];
  sort(BC, BC + YZ);

  ll hi = 3e10;
  ll lo = -1;
  while (hi - lo > 1) {
    // printf("hi: %lld, lo :%lld\n", hi, lo);
    ll mi = (hi + lo) / 2;
    if (check(mi)) hi = mi;
    else lo = mi;
  }

  calc(lo);
  sort(ans.begin(), ans.end(), greater<ll>());
  REP(i, min(K, (int)ans.size())) printf("%lld\n", ans[i]);
}

void input() {
  scanf("%d%d%d%d", &X, &Y, &Z, &K);
  REP(i, X) scanf("%lld", A + i);
  REP(i, Y) scanf("%lld", B + i);
  REP(i, Z) scanf("%lld", C + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 141020
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main() {

  int a, b;
  int area, length;

  cin >> a >> b;

  area = a * b;
  length = 2 * ( a + b );

  cout << area << " " << length << endl;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3084
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int i,n,j=0;
  char s;
  cin>>n;
  
  for(i=0;i<n;i++){
    cin>>s;
    if(s=='Y'){
 	j++;
      break;
    }
  }
    if(j==0)cout<<"Three"<<endl;
   else cout<<"Four"<<endl;
    return 0;
  }

Measured memory_bytes: 256
<?php
$nl=(int)trim(fgets(STDIN));

$node=array($nl);

for($i=0;$i<$nl;$i++){
	$node[$i]=array('ca'=>-1,'cb'=>-1,'pa'=>-1,'si'=>-1,'dg'=>0,'he'=>-1);
}

for($i=0;$i<$nl;$i++){
	$ls=explode(' ',trim(fgets(STDIN)));#lines

	$id=(int)array_shift($ls);
	$ca=(int)array_shift($ls);
	$cb=(int)array_shift($ls);

	if($ca!=-1){
		++$node[$id]['dg'];#degree
		$node[$id]['ca']=$ca;#left

		$node[$ca]['pa']=$id;#parent
		$node[$ca]['si']=$cb;#sibling
	}
	if($cb!=-1){
		++$node[$id]['dg'];#degree
		$node[$id]['cb']=$cb;#right

		$node[$cb]['pa']=$id;
		$node[$cb]['si']=$ca;
	}
}

$root=-1;
for($i=0;$i<$nl;$i++){
	if($node[$i]['pa']==-1){
		$root=$i;
		break;
	}
}

getHe($root);

for($i=0;$i<$nl;$i++){
	$ni=$node[$i];

	$de=0;#depth
	for($j=$ni['pa'];$j!=-1;$j=$node[$j]['pa']){++$de;}

	$ty=($i==$root)? 'root':(($ni['dg'])? 'internal node':'leaf');#type

	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n"
		,$i
		,$ni['pa']
		,$ni['si']
		,$ni['dg']
		,$de
		,$ni['he']
		,$ty
	);
}

function getHe($id){
	global $node;

	if($id==-1){return -1;}

	$ni=$node[$id];

	return $node[$id]['he']=1+max(getHe($ni['ca']),getHe($ni['cb']));
}

Measured memory_bytes: 15556
while(1):
    a,op,b=input().split()
    if(op=="?"):
        break
    if(op=="+"):
        print(int(a)+int(b))
    elif(op=="-"):
        print(int(a)-int(b))
    elif(op=="*"):
        print(int(a)*int(b))
    else:
        print(int(a)//int(b))



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll s = 0, t = 0, asum = 0, xsum = 0, ans = n;
    while(s < n)
    {
        while(t < n && asum + a[t] == (xsum ^ a[t]))
        {
            asum += a[t];
            xsum ^= a[t];
            t++;
        }
        ans += t-1-s;
        asum -= a[s];
        xsum ^= a[s];
        s++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3532
N, W = list(map(int,input().split()))
v = []
w = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    v.append(in1)
    w.append(in2)

dp = [-1 for _ in range(W + 1)]
dp[0] = 0

for weight in range(1, W + 1):
    ret = 0
    for i in range(N):
        if weight - w[i] >= 0:
            ret = max(ret, dp[weight - w[i]] + v[i])
    dp[weight] = ret

print(dp[W])


Measured memory_bytes: 5924
//h
#include<stdio.h>
#include<algorithm>
typedef long long ll;

int n;
ll a[100005];

bool cmp(const ll &a, const ll &b)
{
	return a>b;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	ll l=0ll, w=0ll;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%lld", a+i);
	}
	std::sort(a, a+n, cmp);
	for(i=1; i<n; i++)
	{
		if(a[i-1]==a[i])
		{
			l=a[i];
			break;
		}
	}
	for(i+=2; i<n; i++)
	{
		if(a[i-1]==a[i])
		{
			w=a[i];
			break;
		}
	}
	printf("%lld\n", l*w);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  if(S=="Sunny") cout<<"Cloudy"<<endl;
  else if(S=="Cloudy") cout<<"Rainy"<<endl;
  else if(S=="Rainy") cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const ll INF=2e15;
const double PI=acos(-1);


map<ll,int> prime_factor(ll n) {
    map<ll,int> res;
    repr(i,2,sqrt(n)+1) {
        while (n%i==0) {
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) ++res[n];
    return res;
}


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

    string s;
    cin >> s;
    int n=s.size();
    int scnt=0,tcnt=0;
    int ans=n;
    rep(i,n) {
        if (s[i]=='S') ++scnt;
        else if (scnt>0) {
            ans-=2;
            --scnt;
        }
    } 
    cout << ans << endl;

    return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    cout << ((n+1)*n) / 2 << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
typedef pair<int, ll> pill;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD = 998244353;
vector<pair<pii,ll> > datas;
bool check=true;

const int BT = 1 << 17 ;
int H,W,K;
string cake[305];
int ans[305][305]={0};
int main(){
    cin>>H>>W>>K;
    rep(i,H)cin>>cake[i];
    vi memo[305];
    int num=1;
    vi aru;
    rep(i,H){
        rep(j,W){
            if(cake[i][j]=='#'){
                memo[i].pb(j);
            }
        }
        int sz=memo[i].size();
        if(sz>0)aru.pb(i);
        if(sz==1){
            rep(k,W)ans[i][k]=num;
            num++;
        }else if(sz>1){
            int lef=0;
            rep(k,sz-1){
                for(int kk=lef;kk<=memo[i][k];kk++){
                    ans[i][kk]=num;
                }
                lef=memo[i][k]+1;
                num++;
            }
            for(int kk=lef;kk<W;kk++)ans[i][kk]=num;
            num++;
        }
    }
    int cur=-1;
    rep(i,aru.size()){
        //cout<<aru[i]<<endl;
        for(int x=cur+1;x<=aru[i]-1;x++){
            rep(j,W)ans[x][j]=ans[aru[i]][j];
        }
        cur=aru[i];
    }
    for(int x=cur+1;x<H;x++){
            rep(j,W)ans[x][j]=ans[cur][j];
    }
    rep(i,H){
        rep(j,W)cout<<ans[i][j]<<" ";
        cout<<endl;
    }

}

Measured memory_bytes: 1920
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
    fac[i] = fac[i-1]*i%p; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


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

lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;
vector< vector <lld > > v(100001);

void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*
lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}
*/

void solve()
{
     cin>>n>>m;
     x=0;
     for(i=0;i<m;i++)
     {
        cin>>l;
        x+=l;
     }
     if(x>n)
     {
        cout<<"-1";
     }
     else cout<<n-x;

}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
//    cin>>t;
    for(int i=0;i<t;i++)
    {
    //    cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }

    return 0;
}


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

const ll INF=1e9;

int main(){
    ll n;
    cin>>n;
    vector<ll> dp(n+1,INF);
    dp[0]=0;
    for(ll i=1;i<=n;i++){
        dp[i]=min(dp[i],dp[i-1]+1);
        for(ll j=6;j<=i;j*=6) dp[i]=min(dp[i],dp[i-j]+1);
        for(ll j=9;j<=i;j*=9) dp[i]=min(dp[i],dp[i-j]+1);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#######################################
def csi(s=gets,spst=" ")
  if s==nil
    return 0
  end
  return s.chomp.split(spst).map(&:to_i)
end
def css(s=gets,spst=" ")
  if s == nil
    raise "nil!"
  end
  return s.chomp.split(spst).map(&:to_s)
end
def ml(n,datatype=:int)
  t = []
  case datatype
  when :int
    n.times do
      t.push(gets.to_i)
    end
  when :str
    n.times do
      t.push(gets.chomp.to_s)
    end
  else
    raise "n!"
  end
end
#######################################

K,X = csi(gets)

if (500*K) >= X
  puts "Yes"
else
  puts "No"
end


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

int main() {
  string s,t;
  cin>>s>>t;
  set<char>p,g;
  set<pair<char,char>>q,r;
  for(int i=0;i<s.size();i++){
    char k,l;
    k=s.at(i);
    l=t.at(i);
   p.insert(k);
    g.insert(l);
   q.insert(make_pair(k,l));
    r.insert(make_pair(l,k));
  }
  if(p.size()==q.size()&&p.size()==r.size()&&p.size()==g.size())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m, cnt=0, c[100005];
vector<int> g[100005];

void dfs(int cur, int col) {
	if (c[cur] == 0) {
		c[cur] = col;
		if (col == 1) cnt++;
		FOR(i, g[cur].size()) {
			dfs(g[cur][i], -col);
		}
	}
	else if (c[cur] == -col) {
		cout << 1LL*n*(n-1)/2-m << endl;
		exit(0);
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, m) {
		int u, v;
		cin >> u >> v;
		g[u-1].push_back(v-1);
		g[v-1].push_back(u-1);
	}
	dfs(0, 1);
	cout << 1LL*cnt*(n-cnt)-m << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll V, T;
string S;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

class imos1D {
public:
    vector<int> data;
    bool is_build = false;
    imos1D(int n) : data(n + 1) {}
    //[l,r)
    void add(int l, int r, int val) {
        if (is_build) {
            fill(data.begin(), data.end(), 0);
            is_build = false;
        }
        data[l]++;
        data[r]--;
    }
    int get(int index) {
        if (!is_build) {
            for (int i = 0; i < N; i++) {
                data[i + 1] += data[i];
            }
            is_build = true;
        }
        return data[index];
    }
};

signed main() {
    cin >> N >> K;
    vector<int> a(N), b(N + 1);
    cin >> a;
    int cnt = 0;
    int k = 0;
    imos1D im(N);
    while (cnt != N && k < K) {
        cnt = 0;
        k++;
        REP(i, N) {
            int l = max(i - a[i], 0);
            int r = min(i + a[i] + 1, int(N));
            im.add(l, r, 1);
        }
        REP(i, N)
        a[i] = im.get(i);
        cnt = count(ALL(im.data), N);
    }
    REP(i, N) {
        cout << a[i] << " ";
    }
}


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

int main() {
    using namespace std;

    constexpr unsigned long MOD = 1000000007;

    unsigned long N;
    cin >> N;

    auto pw = [&MOD](unsigned long a, unsigned long n = 1000000005){
        unsigned long ret = 1;
        while(n){
            if(n & 1)(ret *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return ret;
    };

    vector<unsigned long> fact(N + 1), ifact(N + 1);
    fact[0] = 1;
    for(unsigned long i = 1; i <= N; ++i)fact[i] = fact[i - 1] * i % MOD;
    ifact[N] = pw(fact[N]);
    for(unsigned long i = N; i > 0; --i)ifact[i - 1] = ifact[i] * i % MOD;

    unsigned long A, B, C, D;
    cin >> A >> B >> C >> D;

    vector<vector<unsigned long>> dp(B + 1, vector<unsigned long>(N + 1));
    dp[A - 1][N] = 1;

    for(unsigned long i = A; i <= B; ++i){
        for(unsigned long j = 0; j <= N; ++j){
            dp[i][j] = dp[i - 1][j];
            for(unsigned long k = C, l = j + C * i, m = pw(ifact[i], C); k <= D && l <= N; ++k, l += i, (m *= ifact[i]) %= MOD)dp[i][j] += ((((dp[i - 1][l] * fact[l]) % MOD * ifact[j]) % MOD * m) % MOD * ifact[k]) % MOD;
            dp[i][j] %= MOD;
        }
    }

    cout << dp[B][0] << endl;

    return 0;
}

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

int main() {
	int A, B, X;
	cin >> A >> B >> X;
	int ans = INT_MAX;
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			if (X <= 1000 * i + 500 * j) ans = min(A * i + B * j, ans);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3112
n,m=(int(i) for i in input().split())
p = int(m**(1/2))
divisors = []
for i in range(1,p+1):
    if m%i == 0:
        if n*i<=m:
            divisors.append(i)
        if n<=i:
            divisors.append(int(m/i))
print(max(divisors))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    int ans=n*n*n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

// verified
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

class Dinic {
    const int INF = 1 << 30;
    struct Edge {
        int to, cap, rev;
    };

    int n;
    vector<vector<Edge>> G;
    vector<int> level; // sからの距離
    vector<int> iter; // どこまで調べ終わったか

    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue <int> q;
        level[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (Edge &e : G[v]) {
                if (level[e.to] < 0 && e.cap > 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < G[v].size(); i++) {
            Edge &e = G[v][i];
            if (level[e.to] > level[v] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    Dinic(int n) : n(n), G(n), level(n), iter(n) {}

    void add_edge(int from, int to, int cap) {
        G[from].push_back({to, cap, (int)G[to].size()});
        G[to].push_back({from, 0, (int)G[from].size() - 1});
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            int f = dfs(s, t, INF);
            while (f > 0) {
                flow += f;
                f = dfs(s, t, INF);
            }
        }
    }
};

int main() {
    int V, E;
    cin >> V >> E;

    Dinic dinic(V);
    for (int e = 0; e < E; e++) {
        int u, v, c;
        cin >> u >> v >> c;
        dinic.add_edge(u, v, c);
    }

    cout << dinic.max_flow(0, V - 1) << "\n";
    return 0;
}


Measured memory_bytes: 3188
#!/usr/bin/env python3
#ABC70 C

n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

t.sort()
t.reverse()
ans = t[0]
for i in range(1,n):
    ans = lcm(ans,t[i])
print(ans)


Measured memory_bytes: 40628
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=5050;
int fa[maxn],sz[maxn];
int n,lft,k;
int p[maxn],pw[maxn],fac[maxn];
inline int getfa(int x){return x==fa[x]?x:fa[x]=getfa(fa[x]);}
inline void Union(int x,int y)
{
	x=getfa(x),y=getfa(y);
	if(x==y)return;
	sz[x]+=sz[y];
	fa[y]=x;
	lft--;
}
inline void add(int &a,int b)
{
	a+=b;
	if(a>=MOD)a-=MOD;
}
vector<int> td;
int dp[2][maxn];
int main()
{
	scanf("%d",&n);
	lft=n;
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		sz[i]=1;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		if(p[i]>0)
		{
			Union(i,p[i]);
		}
		else
		{
			k++;
			td.push_back(i);
		}
	}
	pw[0]=1;
	fac[0]=1;
	for(int i=1;i<=n;i++)
	{
		pw[i]=pw[i-1]*1ll*(n-1)%MOD;
		fac[i]=fac[i-1]*1ll*i%MOD;
	}
	int p=0,q=1;
	dp[p][0]=1;
	int mns=(lft-k)*1ll*pw[k]%MOD;
	for(int i=0;i<k;i++)
	{
		int cur=sz[getfa(td[i])];
		add(mns,(cur-1)*1ll*pw[k-1]%MOD);
		memset(dp[q],0,sizeof(dp[q]));
		for(int j=0;j<=k;j++)
		{
			add(dp[q][j],dp[p][j]);
			add(dp[q][j+1],dp[p][j]*1ll*cur%MOD);
			if(1<=j&&j<=k-1)
			{
				add(mns,dp[p][j]*1ll*cur%MOD*1ll*fac[j]%MOD*1ll*pw[k-j-1]%MOD);
			}
		}
		swap(p,q);
	}
	int ans=n*1ll*pw[k]%MOD;
	add(ans,(MOD-mns)%MOD);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4012
#include <iostream>
using namespace std;
int main(){

	int n;
	cin >> n;
	int j = 1;
	int m = 1;

	for(int i=0;i<n;i++){
		int a;
		cin >> a;

		if( a == 1 ){
			j++;
			m = max(m,j);
		}
		else{
			j = 1;
		}
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
#define N 200002
using namespace std;
struct ball{
	int x,y;
}a[N];
int n,i,maxx,minx=1<<30,r[N],b[N];
int my_comp(const ball &a,const ball &b)
{
	return a.x<b.x;
}
signed main()
{
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
		if(a[i].x>a[i].y) swap(a[i].x,a[i].y);
		maxx=max(maxx,a[i].y);
		minx=min(minx,a[i].x);
	}
	int rmax=0,bmin=1<<30,bmax,tmp=1<<30;
	for(i=1;i<=n;i++){
		rmax=max(rmax,a[i].x);
		bmin=min(bmin,a[i].y);
	}
	int ans=(maxx-bmin)*(rmax-minx);
	sort(a+1,a+n+1,my_comp);
	for(i=1;i<=n;i++) b[i]=a[i].x,r[i]=a[i].y;
	bmax=b[n];
	for(i=1;i<n;i++){
		bmax=max(bmax,r[i]);
		tmp=min(tmp,r[i]);
		bmin=min(tmp,b[i+1]);
		ans=min(ans,(maxx-minx)*(bmax-bmin));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
using namespace std;
long long INF = 1e18;
struct edge{
    int from;
    int to;
    long long cost;
};
void solve(int N, int M, vector<edge> &es, int s, int t){
    vector<long long> d(N);//各頂点までの距離
    for(int i = 0; i < N; i++) d[i] = INF;
    d[s] = 0;
    long long k = 0;
    while(true){
        bool flag = false;
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                flag = true;
            }
        }
        if(!flag || k == N) break;
        k++;
    }
    long long ans = d[t];
    k = 0;
    while(true){
        for(int i = 0; i < M; i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = -INF;
            }
        }
        k++;
        if(k == N) break;
    }
    if(d[t] == -INF) cout << "inf" << endl;
    else cout << -ans << endl;
}
int main(){
    int N, M;
    cin >> N >> M;
    vector<edge> es(M);
    for(int i = 0; i < M; i++){
        int x, y;
        long long c;
        cin >> x >> y >> c;
        x--;
        y--;
        edge e = {x, y, -c};
        es[i] = e;
    }
    solve(N, M, es, 0, N - 1);
}

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

int main() {
  
  string S; int64_t K; cin >> S >> K;
  
  int64_t sumF = 0, sumS = 0, sumT = 0;
  
  string tmpF = S, tmpS = S + S, tmpT = S + S + S;
  
  for (int i = 0; i < tmpF.size() - 1; i++) {
    
    if (tmpF.at(i) == tmpF.at(i + 1)) {
      sumF++;
      tmpF.at(i + 1) = '0';
    }
    
  }
  
  for (int i = 0; i < tmpS.size() - 1; i++) {
    
    if (tmpS.at(i) == tmpS.at(i + 1)) {
      sumS++;
      tmpS.at(i + 1) = '0';
    }
    
  }
  
  for (int i = 0; i < tmpT.size() - 1; i++) {
    
    if (tmpT.at(i) == tmpT.at(i + 1)) {
      sumT++;
      tmpT.at(i + 1) = '0';
    }
    
  }
  
  int64_t addS = sumS - sumF, addT = sumT - sumS;
  
  if (K == 1) { cout << sumF << endl; return 0; }
  
  if ((K - 1) % 2 == 0) cout << sumF + (addS + addT) * ((K - 1) / 2) << endl;
  
  else cout << sumF + (addS + addT) * ((K - 1) / 2) + addS << endl;
  
}

Measured memory_bytes: 3636
import collections
import heapq

x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
q = [(-sum([ls[i][0] for i in range(3)]), 0, 0, 0)]
res = []
used = collections.defaultdict(lambda: False)
while len(res) < k:
    s, i, j, l = heapq.heappop(q)
    res.append(-s)
    if i + 1 < x and not used[(i + 1, j, l)]:
        heapq.heappush(q, (-(ls[0][i + 1] + ls[1][j] + ls[2][l]), i + 1, j, l))
        used[(i + 1, j, l)] = True
    if j + 1 < y and not used[(i, j + 1, l)]:
        heapq.heappush(q, (-(ls[0][i] + ls[1][j + 1] + ls[2][l]), i, j + 1, l))
        used[(i, j + 1, l)] = True
    if l + 1 < z and not used[(i, j, l + 1)]:
        heapq.heappush(q, (-(ls[0][i] + ls[1][j] + ls[2][l + 1]), i, j, l + 1))
        used[(i, j, l + 1)] = True
print(*res, sep='\n')

Measured memory_bytes: 5264
import math
N, D = map(int,input().split())
X=[]
for i in range(N):
    X.append(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        nijo = 0
        for k in range(D):
            nijo += (X[i][k]-X[j][k])**2 
        cnt += int(math.sqrt(nijo)==int(math.sqrt(nijo)))
print(cnt)  

Measured memory_bytes: 3064
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

struct SelectionGenerator {
    n: usize,
    curr: usize,
    ubound: usize,
}

impl SelectionGenerator {
    fn new(n: usize) -> SelectionGenerator {
        SelectionGenerator{n: n, curr: 0, ubound: 1<<n*2}
    }
}

impl Iterator for SelectionGenerator {
    type Item = Vec<usize>;

    fn next(&mut self) -> Option<Self::Item> {
        let n = self.n;
        let curr = self.curr;

        if curr < self.ubound {
            let mut ret = Vec::with_capacity(n);

            for i in 0..n {
                ret.push(curr >> i*2 & 0x00000003);
            }

            self.curr += 1;

            Some(ret)
        } else {
            None
        }
    }
}

fn calc(targets: [isize; 3], ls: &Vec<isize>, sels: Vec<usize>)
        -> Option<isize> {
    let mut selected: Vec<Vec<isize>> = vec![Vec::new(); 3];

    for (i, &l) in ls.into_iter().enumerate() {
        let sel = sels[i];
        if sel < 3 {
            selected[sel].push(l);
        }
    };

    if selected.iter().any(|sel| sel.is_empty()) {
        return None;
    }

    let ret = targets.into_iter().zip(selected).map(|(tgt, sel)| {
        let sum: isize = sel.iter().sum();
        (tgt - sum).abs() + (sel.len() as isize - 1) * 10
    }).sum();

    Some(ret)
}

fn main() {
    input! {
        n: usize,
        a: isize,
        b: isize,
        c: isize,
        ls: [isize; n],
    }

    let ans = SelectionGenerator::new(n).filter_map(|sels| {
        calc([a, b, c], &ls, sels)
    }).min().unwrap();

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


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n==25) cout << "Christmas" << endl;
  if (n==24) cout << "Christmas Eve" << endl;
  if (n==23) cout << "Christmas Eve Eve" << endl;
  if (n==22) cout << "Christmas Eve Eve Eve" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n,m,a,s=0;
    cin>>n>>m;
    vector<int >v;
    for(int i =0;i<m;i++){
        cin>>a;
        v.push_back(a);
        s+=a;
    }
    if(n>=s) {
        cout << abs(s - n);
    }
    else cout<<-1;
    return 0;
}

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

const int INF = 1000000007;

bool isprime[10000];
int prime[10000];
int lim = 0;

void eratosthenes(){
    for(int i = 0; i < 10000; i++){
        isprime[i] = true;
    }
    isprime[0] = isprime[1] = false;
    for(int x = 2; x < 10000; x++){
        if(isprime[x]){
            prime[lim++] = x;
            for(int y = x * x; y < 10000; y += x){
                isprime[y] = false;
            }
        }
    }
}

int main(){
    eratosthenes();
    int N, a, ans;
    ans = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &a);
        bool flg = true;
        for(int i = 0; i < lim; i++){
            if(prime[i] >= a) break;
            if(a % prime[i] == 0){
                flg = false;
                break;
            }
        }
        if(flg) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1208
n, k = map(int,input().split())
s = list(input())

cl = 0
cr = 0
a = []
ans = 0
if s[0] == '1':
    ck = 0
    ans = 1
else:
    ck = 1
    a.append([0,0])
while True:
    while ck <= k and cr < n-1:
        cr += 1
        if s[cr-1] == '1' and s[cr] == '0':
            if ck < k:
                ck += 1
                a.append([cr, cr])
            else:
                break
        elif s[cr-1] == '0' and s[cr] == '1':
            a[-1][1] = cr
        ans = max(ans, cr - cl + 1)
    if cr < n-1:
        tl, tr = a.pop(0)
        cl = tr
        cr -= 1
        ck -= 1
    else:
        break
print(ans)

Measured memory_bytes: 79852
#include <iostream>
using namespace std;
class Dice {
private:
  int dice[6];
 public:
  Dice() {
	for(int i = 0; i < 6; ++i) {
	  dice[i] = i + 1;
	}
  }
  void move(string str) {
	if(str == "North") {
	  rollN();
	}
	else if(str == "South") {
	  rollS();
	}
	else if(str == "East") {
	  rollE();
	}
	else if(str == "West") {
	  rollW();
	}
	else if(str == "Left") {
	  spinL();
	}
	else {	// Right
	  spinR();
	}
  }
  void rollN() {
	swap(dice[0], dice[1]);
	swap(dice[1], dice[5]);
	swap(dice[5], dice[4]);
  }
  void rollS() {
	swap(dice[0], dice[4]);
	swap(dice[4], dice[5]);
	swap(dice[5], dice[1]);
  }
  void rollE() {
	swap(dice[0], dice[3]);
	swap(dice[3], dice[5]);
	swap(dice[5], dice[2]);
  }
  void rollW() {
	swap(dice[0], dice[2]);
	swap(dice[2], dice[5]);
	swap(dice[5], dice[3]);
  }
  void spinL() {
	swap(dice[3], dice[4]);
	swap(dice[4], dice[2]);
	swap(dice[2], dice[1]);
  }
  void spinR() {
	swap(dice[1], dice[2]);
	swap(dice[2], dice[4]);
	swap(dice[4], dice[3]);
  }
  int top() {
	return dice[0];
  }
};

int main() {
  int n, sum;
  string str;
  while(cin >> n, n) {
	Dice d1;
	sum = 1;
	for(int i = 0; i < n; ++i) {
	  cin >> str;
	  d1.move(str);
	  sum += d1.top();
	}
	cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
int n;
P<int, int> p[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int x, l;
    cin >> x >> l;
    p[i].fi=x+l;
    p[i].se=x-l;
  }
  sort(p, p+n);
  int a = -IINF, ans=n;
  FOR(i, 0, n){
    if(p[i].se<a){
      ans--;
    }else{
      a = p[i].fi;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024