akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define Ifor(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dfor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int a[4];

void print (int b) {
	cout << a[0];
	Ifor(i, 0, 3) {
		if (b & (1 << i)) cout << '+';
		else cout << '-';
		cout << a[i + 1];
	}
	cout << "=7\n";
}

bool check (int b) {
	int res = a[0];
	Ifor(i, 0, 3)
		if (b & (1 << i)) res += a[i + 1];
		else res -= a[i + 1];
	return res == 7;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	Ifor(i, 0, 4) a[i] = cin.get() - '0'; 
	Ifor(i, 0, (1 << 3)) if (check(i)) { print(i); break; }
}



Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
	if i == n-1:
		b[i]=k-a[i]+a[0]
	else:
		b[i]=a[i+1]-a[i]
max_a=0
for i in range(n):
	if b[i]>max_a:
		max_a=b[i]
print(k-max_a)

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long K, std::vector<long long> p){
    sort(all(p));
    i64 ans = 0;
    rep(i, K) ans += p[i];
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <deque>

using namespace::std;

int ri()
{
	int x;
	scanf("%d", &x);

	return x;
}

int64_t ri64()
{
	int64_t x;
	scanf("%lld", &x);

	return x;
}

void wi(int x)
{
	printf("%d\n", x);
}

void wvi(vector<int> &v)
{
	for (int i = 0; i < v.size(); i++)
		printf("%d ", v[i]);
	printf("\n");
}

void dbg(string &str, int x)
{
	cout << str << ": ";
	wi(x);
}

void dbg(string &str, vector<int> &x)
{
	cout << str << ": ";
	wvi(x);
}

int main()
{
	int64_t N = ri();
	int64_t X = ri64();

	vector<int64_t> A(N);
	for (int i = 0; i < N; i++)
		A[i] = ri64();

	vector<int64_t> S(N, 0);
	for (int i = 0; i < N; i++)
	{
		S[i] = A[i];
		if (i > 0)
			S[i] += S[i - 1];
	}

	int64_t ans = -1;
	for (int64_t k = 1; k <= N; k++)
	{
		int64_t s = k * X;
		
		s += 2 * S[N - 1];
		if (k < N)
			s -= 2 * S[N - 1 - k];	
		
		int64_t c = 3;
		int64_t t = N - 1;

		while (t >= 0)
		{
			if (ans != -1 && s > ans)
				break;			

			s += c * S[t];

			t -= k;			
			if (t >= 0)
				s -= c * S[t];

			c += 2;
		} 
		
		if (ans == -1 || ans > s)
			ans = s;
	}	

	ans += N * X;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <algorithm>
const int N = 405;
int n, m, ans;
bool w[N][N];
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
int main() {
	n = Get(), m = Get();
	for (int k = 1; k <= m; ++k) {
		int x = Get(), y = Get();
		if (w[x][y]) {
			for (int i = 1; i <= n; ++i) w[x][i] = w[i][x] = true;
			for (int i = 1; i <= n; ++i) w[y][i] = w[i][y] = true;
			continue;
		}
		
		w[x][y] = w[y][x] = true;
		for (int i = 1; i <= n; ++i)
			if (i != x && i != y) {
				if (w[i][x] && !w[i][y]) w[i][y] = w[y][i] = true;
				if (w[i][y] && !w[i][x]) w[i][x] = w[x][i] = true;
			}
		
	}
	
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j < i; ++j) ans += !w[i][j];
	
	printf("%d\n", ans);
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int result = gcd(a, b);
        System.out.println(result);
    }

    public static int gcd(int x, int y) {
        if (x % y == 0) {
            return x < y ? x : y;
        }
        if (x >= y) {
            return gcd(y, x % y);
        } else {
            return gcd(x, y % x);
        }
    }
}



Measured memory_bytes: 26188
n, m = map(int, input().split())
lis = list(map(int, input().split())) 
count = 0

su_li = sum(lis)
line = su_li / 4 / m
for item in lis:
  if item >= line:
    count += 1
if count >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

long long int n, help = 0, res = 0;
long long int a[100002];

int main()
{

    cin >> n;

    for (int i = 1; i <= n + 1; i++)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= n + 1; i++)
    {
        long long int b = 0;

        if (i != n + 1)
        {
            cin >> b;
        }

        if (help >= a[i])
        {
            res += a[i];
            help = b;
        }
        else
        {
            res += help;
            a[i] -= help;
            if (b >= a[i])
            {
                res += a[i];
                help = b - a[i];
            }
            else
            {
                res += b;
                help = 0;
            }
        }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N, ans = 0;
	cin >> N;
	vector<int>a(N-1);
	rep(i, N-1)
		cin >> a[i];
	ans += a[0];
	ans += a[N-2];
	rep(i, N - 2)
		ans += min(a[i], a[i + 1]);
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n , a ;
    int min = 1000001;
    int max = -1000001;
    long int sum = 0;
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; i ++){
        scanf("%d" , &a);
        if(a < min){
            min = a;
        }
        if(a > max){
            max = a;
        }
        sum += a;
    }
    printf("%d %d %ld\n" , min , max , sum);
    
    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

struct Tree {
	u32 sum;
	Tree *ch[2];
};
const int N=1<<18;
int h, l, p[N];
u32 t[N], invt[N], res;
Tree nil[1], *root[N];
Tree *make(int lv, int pos, u32 v) {
	Tree *o=new Tree;
	o->sum=v;
	o->ch[0]=o->ch[1]=nil;
	if(lv>=0) o->ch[pos>>lv&1]=make(lv-1, pos, v);
	return o;
}
Tree *merge(int id, Tree *u, Tree *v) {
	if(v==nil) return u;
	if(u==nil) return v;
	Tree *w=new Tree;
	res=(res+(1llu*u->ch[0]->sum*v->ch[1]->sum+1llu*u->ch[1]->sum*v->ch[0]->sum)%P*invt[id]%P*invt[id/2])%P;
	w->sum=(u->sum+v->sum)%P;
	w->ch[0]=merge(id*2, u->ch[0], v->ch[0]);
	w->ch[1]=merge(id*2+1, u->ch[1], v->ch[1]);
	return w;
}
int main() {
	h=rd();
	l=1<<(h-1);
	t[0]=invt[0]=1;
	for(int i=1; i<2*l; ++i) {
		t[i]=1llu*t[i/2]*i%P;
		invt[i]=power(t[i], P-2);
	}
	for(int i=0; i<l; ++i) p[i]=rd()-1;
	for(int i=0; i<l; ++i) root[l+i]=make(h-2, p[i], 1llu*t[l+i]*t[l+p[i]]%P);
	u32 ans=0;
	for(int i=l; --i; ) {
		res=0;
		root[i]=merge(1, root[2*i], root[2*i+1]);
		ans=(ans+1llu*res*invt[i]%P*invt[i/2])%P;
	}
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 147572
// AtCoder Beginner Contest 096 - Problem A: Day of Takahashi (https://atcoder.jp/contests/abc096/tasks/abc096_a) 
#include <bits/stdc++.h>

using namespace std;

int solve(int A, int B)
{
    return A <= B ? A : A - 1;
}

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

    int A, B;
    cin >> A >> B;

    auto ans = solve(A, B);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, m;
bool saw[100000];
bool ssaw[100000];
int dep[100000];
vector<int> e[100000];

void init(int v, int d){
    ssaw[v] = true;
    rep(i,e[v].size()){
        if(ssaw[e[v][i]]) continue;
        dep[e[v][i]] = d+1;
        init(e[v][i], d+1);
    }
}

bool check(int v){
    saw[v] = true;
    rep(i,e[v].size()){
        if(!saw[e[v][i]]){
            bool rec = check(e[v][i]);
            if(!rec) return false;
        } else{
            if(abs(dep[v]-dep[e[v][i]])%2 == 0){
                return false;
            }
        }
    }
    return true;
}

int main(){
    memset(saw,0,sizeof(saw));
    I(n,m);
    rep(i,m){
        int u, v;
        I(u,v); u--; v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    ll counter = 0;
    ll count = 0;
    ll ans = 0;
    ll hoge = 0;
    rep(i,n){
        if(ssaw[i] == false){
            if(e[i].size() == 0){
                ans += (n-hoge)*2-1;
                hoge++;
                continue;
            }
            dep[i] = 0;
            init(i,0);
            if(!check(i)){
                count++;
            }
            counter++;
        }
    }
    ans += count*counter;
    ans += (counter-count)*(count+(counter-count)*2);
    cout << ans << endl;
}
































Measured memory_bytes: 11264
a, b, C = gets.split.map(&:to_i)

h = b * Math.sin(C / 180.0 * Math::PI)
c = Math.sqrt(a**2 + b**2 - 2 * a * b * Math.cos(C * Math::PI / 180.0))
s = a * h / 2

puts s
puts a + b + c
puts h

Measured memory_bytes: 8904
#縦の長さx^2、横の長さ0~600
#for文で600までi-dで回す、たす

while(1):
    try:
        d = int(input())
    except:
        break
    sum = 0
    for i in range(600//d):
        y = (i*d)**2
        s = y*d
        sum += s
    print(sum)


Measured memory_bytes: 5588
#include <iostream>

using namespace std;
int N, K, h[100005], dp[100005]{0};

int main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> h[i];
    for(int i = 1; i < N; i++) {
        dp[i] = 2<<29;
        for(int j = i-1; j >= max(0, i-K); j--)
            dp[i] = min(dp[j]+abs(h[i]-h[j]), dp[i]);
    }
    cout << dp[N-1] << '\n';
    return 0;
}


Measured memory_bytes: 4332
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
bool check(string s){
	string s1,s2;
	s1=s.substr(0,s.length()/2);
	s2=s.substr(s.length()/2,s.length()/2);
	if(s1==s2)return 1;
	else return 0;
}
int main()
{
	string a;
	cin>>a;
	for(int i=a.size()-1;i>0;i++){
		a=a.substr(0,a.length()-1);
		if(a.size()%2==0&&check(a)){
			cout<<a.size();
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> guide(N);
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    guide.at(i) = make_tuple(s, -p, i+1); 
  }
 
  sort(guide.begin(), guide.end());
  for (int i = 0; i < N; i++) {
    cout << get<2>(guide[i]) << endl;
  }
 
}

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

#include <iostream>
#include <vector>
#include <iomanip>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

size_t n;
size_t t;
size_t l;
size_t b;
size_t s;
double matrix[200][200]; // [from][to]
double ans[200];

void printAns() {
	for (size_t i = 0; i < s; i++) {
		cout << fixed << setprecision(6) << ans[i] << ' ';
	}
	cout << endl;
}

void print() {
	for (size_t i = 0; i < s; i++) {
		for (size_t j = 0; j < s; j++) {
			cout << fixed << setprecision(6) << matrix[i][j] <<  ' ';
		}
		cout << endl;
	}
	cout << endl;
}

void prod() {
	double bef[200];
	for (size_t i = 0; i < s; i++) {
		bef[i] = ans[i];
	}
	for (size_t to = 0; to < s; to++) {
		double sum = 0;
		for (size_t from = 0; from < s; from++) {
			sum += bef[from] * matrix[from][to];
		}
		ans[to] = sum;
	}
}

void makeMatrix() {
	for (size_t i = 0; i < s; i++) {
		for (size_t j = 0; j < s; j++) {
			matrix[i][j] = 0;
		}
		ans[i] = 0;
	}
	ans[0] = 1;
	for (size_t i = 0; i < n - 1; i++) {
		for (size_t j = i + 1; j <= i + 6; j++) {
			if (j >= n) {
				auto key = (n - 1) - (j - (n - 1));
				matrix[i][key] += 1 / (double) 6;
				continue;
			}
			matrix[i][j] += 1 / (double) 6;
		}
	}
}

void solve() {
	n = n + 1;
	s = n + l;
	makeMatrix();
	// for l
	for (size_t i = 0; i < l; i++) {
		size_t target;
		cin >> target;
		//std::cout << "debug " << n + i << std::endl; // debug
		matrix[n + i][target] = 1;
		for (size_t from = 0; from < n; from++) {
			matrix[from][n + i] = matrix[from][target];
			matrix[from][target] = 0;
		}
	}
	// for b
	for (size_t i = 1; i <= b; i++) {
		size_t target;
		cin >> target;
		for (size_t from = 0; from < n; from++) {
			matrix[from][0] += matrix[from][target];
			matrix[from][target] = 0;
		}
	}
	// for goal
	matrix[n - 1][n - 1] = 1;
	// print();
	// cout << endl;
	for (size_t i = 0; i < t; i++) {
		// printAns();
		// cout << endl;
		prod();
	}
	// printAns();
	// cout << endl;
	cout << fixed << setprecision(6) << ans[n - 1] << endl;
}

int main() {

	while (true) {
		cin >> n >> t >> l >> b;
		if (n == 0) {
			break;
		}
		solve();
	}

	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 3480
chomp (my ($n, $m) = split / /, <STDIN>);
chomp (my @h = split / /, <STDIN>);
my @g;
for my $i (1..$m) {
  chomp (my ($a, $b) = split / /, <STDIN>);
  $g[$a - 1] = $h[$b - 1] if $g[$a - 1] < $h[$b - 1];
  $g[$b - 1] = $h[$a - 1] if $g[$b - 1] < $h[$a - 1];
}
my $cnt = 0;
for my $i (0..$n-1) {
  $cnt++ if $h[$i] > $g[$i];
}
print "$cnt\n";

Measured memory_bytes: 25008
#include <iostream>
#include <string>
using namespace std;
int main(){
  int h,w;
  cin >> h>>w;
 string s[h],t;
for(int i=0;i<h;i++){
  cin >>s[i];
  s[i]+="#";
}
for(int i=0;i<w+2;i++) t+="#";
cout <<t<<endl;
for(int i=0;i<h;i++){
  cout <<"#"<<s[i]<<endl;
}
cout <<t<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    ll N, Z, W; cin >> N >> Z >> W;
    vector<ll> A(N); for(ll i = 0; i < N; i++) cin >> A[i];
    vector<ll> ADP(N), BDP(N);
    if(N == 1){
        cout << abs(A[0] - W) << endl;
        return 0;
    }
    ADP[N-1] = abs(A[N-1]-W);
    ADP[N-2] = abs(A[N-1] - A[N-2]);
    BDP[N-2] = ADP[N-2]; 
    ll Amax, Bmin;
    Amax = max(ADP[N-2], ADP[N-1]);
    Bmin = BDP[N-2];
    for(ll i = N-3; i >= 0; i--){
        ll amax=Amax, bmin=Bmin;
        ADP[i] = min(bmin, (ll)abs(A[i]- A[N-1]));
        BDP[i] = max(amax, (ll)abs(A[i]- A[N-1]));
        Amax = max(Amax, ADP[i]);
        Bmin = min(Bmin, BDP[i]);
        //if(i != 0) BDP[i] = max(ADP[i+1], (ll)abs(A[i]- A[N-1]));
        


    }
    ll Max = 0;
    //Max = max(A[N-1], Amin);
    for(ll i = 0; i < N; i++) if(Max < ADP[i]) Max = ADP[i];
    cout << Amax << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int k; cin >> k;
   int a, b; cin >> a >> b;
   bool flag = false;
   rep(i, 1001){
       if(i % k == 0 and a <= i and i <= b){
           flag = true;
       }
   }
    if(flag) cout << "OK" << endl;
    else cout << "NG" << endl; 
}

Measured memory_bytes: 3596
//API???????????????
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str1 = br.readLine();
		String str2 = br.readLine();
		int[] x = new int[4];
		LinkedList list = new LinkedList();
		
		if(str1.length() < str2.length()){
			return;
		}else if(str1.indexOf(str2) == -1){
			return;
		}else if(str1.equals(str2)){
			System.out.println("0");
			return;
		}
		
		
		list.insert(str1.indexOf(str2));
		while(str1.indexOf(str2, list.getData() + 1) != -1){
			list.insert(str1.indexOf(str2, list.getData() + 1));
		}
		
		System.out.print(list.toString());
	}
}

class Room{
	Room prev; //????????¨?±????????????????
	Room next; //?¬??????¨?±????????????????
	int data; //??¨?±?????????????
	
	public Room(int data){
		this.data = data;
		prev = null;
		next = null;
	}

}

class LinkedList {
	Room head;
	Room leg;
	
	public LinkedList(){
		head = new Room(0);
		head.next = head;
		head.prev = head;
		leg = head;
	}
	
	//??¨?±?x?????´??????data????????\
	void insert(int data){
		Room x = new Room(data);
		x.prev = head;
		x.next = head.next;
		head.next.prev = x;
		head.next = x;
		leg = head.prev;
	}
	
	public int getData(){
		Room p = head.next;
		return p.data;
	}

	public String toString(){
		StringBuilder st = new StringBuilder();
		for(Room p=head.prev; p != head; p = p.prev){
			st.append(p.data + "\r\n");
		}
		return st.toString();
	}
} 

Measured memory_bytes: 24348
N,M=map(int,input().split())
A=[int(input()) for i in range(M)]

dp=[-1]*(N+1)
idx=0
dp[0]=1
if idx<M:
    if A[idx]==1:
        dp[1]=0
        idx+=1
if dp[1]==-1:dp[1]=1

for i in range(2,N+1):
    if idx<M:
        if A[idx]==i:
            dp[i]=0
            idx+=1
    if dp[i]==-1:
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;

    if ( (100*r + 10*g + b) % 4 == 0 ) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 3680
use std::io;

fn read_i32_exn() -> i32 {
    let mut n = String::new();
    io::stdin().read_line(&mut n).expect("Failed to input");
    (*n).trim().parse::<i32>().unwrap()
}

fn main() {
    let x = read_i32_exn();
    println!("{}", match x { 3|5|7 => "YES", _x => "NO", });
}


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define VL vector< ll >

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

  ll a, b, c;
  cin >> a >> b >> c;

  ll m = 0;
  m = max(m, (a * 10 + b + c));
  m = max(m, (b * 10 + a + c));
  m = max(m, (c * 10 + b + a));
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char cells[h][w];
    int ans[h][w] = {0};
    bool flag = false;
    
    rep(i,0,h){
        rep(j,0,w){
            cin >> cells[i][j];   
        }
    }
    
    int memo = 0;
    rep(i,0,h){
        memo = -1;
        flag = false;
        rep(j,0,w){
            if(cells[i][j] == 'c'){
                memo = -1;
                flag = true;
            }
            if(flag) memo++;
            ans[i][j] = memo;
        }
    }
    
    
    rep(i,0,h){
        rep(j,0,w){
            if(j) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
        
    }
    
    return 0;   
}


Measured memory_bytes: 3136
/*                                 ___ _____ 
  ___  _ __ ___   ___  __ _  __ _ / _ \___  |
 / _ \| '_ ` _ \ / _ \/ _` |/ _` | | | | / / 
| (_) | | | | | |  __/ (_| | (_| | |_| |/ /  
 \___/|_| |_| |_|\___|\__, |\__,_|\___//_/   
                      |___/            
*/
// Getting better at it ! ! !
#include <bits/stdc++.h>
#include <string.h>
#define int long long
#define MAX (int)(1e7 + 5)
#define MAX2D (int)(1e3 + 5)
#define itn int
#define inf 5e18
#define MOD (int)(1e9 + 7)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sitr set<int>::iterator
#define mitr map<int, int>::iterator
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define vll vector<unsigned int>
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define fast                       \
    ios_base ::sync_with_stdio(0); \
    cin.tie(NULL);                 \
    cout.tie(NULL)
using namespace std;


void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define see(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define see(x...)
#endif

signed main()
{
    fast;
    int x;
    cin>>x;
    if(x >= 30) cout<<"Yes";
    else cout<<"No";
    return 0; 
}
 
/*
max factors number = 720720 --> 240 factors
max factors number = 1441440 -->288 factors
 
Beautiful program
Please run for me.
I've tried you in BASIC,
FORTRAN and C.
Beautiful program,
You've errors galore.
And each time I run you,
You're swapped out of core.
*/

Measured memory_bytes: 3652
#define _GLIBCXX_IOSTREAM
#include<bits/stdc++.h>
using namespace std;
multiset<int> st;
int n,m,a[200100];
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;++i)
		scanf("%d",&x),st.insert(x);
	scanf("%d",&m);
	for(int i=1;i<=m;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=m;++i){
		multiset<int>::iterator it=st.find(a[i]);
		if(it==st.end())return puts("NO"),0;
		st.erase(it);
	}
	puts("YES");
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n=15,k,ans,i;
	string s;
	cin >> s;
	k = s.l_ength();
	ans = n-k;
	for(i=0; i<k; ++i){
		if(s[i]=='o'){
			++ans;
		}
	}
	cout << ((ans<8)?"NO":"YES") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
const int MOD=1000000007;
int main(){

    int n;cin>>n;
    ll ans=1;
    ll b = 1e18;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0;
            return 0;
        }
    }
    rep(i,n){
        
        if(b/ans>=a[i]){
            ans *= a[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    printf("%lld",ans);

    return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;
long long a, b, c, d;

int main() {
  cin >> n >> a >> b >> c >> d;
  long long sz = n - 1;
  // x + y == sz;
  // a + x * c - y * d <= b <= a + x * d - y * c
  // x * c - y * d <= b - a <= x * d - y * c
  range(x, 0, sz + 1) {
    int y = sz - x;
    if(a + c * x - d * y <= b && b <= a + d * x - c * y) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    unordered_set<char> US;
    string ans = "a";
    for(int i = 0; i < S.size(); ++i) US.insert(S[i]);
    for(int i = 0; i < 26; ++i){
        if(US.find('a'+i) != US.end()){
            if('a'+i == 'z') ans = "None";
            else ans = 'a'+i+1;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
    int n = 0;
    string W, T;
    
    cin >> W;
    for(int i=0;W[i]!='\0';i++)
    	W[i]=static_cast<char>(toupper(W[i]));
    	
    while (cin >> T){
        if (T== "END_OF_TEXT")
            break;

    	for(int i=0;T[i]!='\0';i++)
      	    T[i]=static_cast<char>(toupper(T[i]));
       
        if (W == T)
            n++;
    }
    cout <<n<< endl;
}

Measured memory_bytes: 1188
#include<stdio.h>

int main(){
  int i,n,F[45];


  F[0]=F[1]=1;
  for(i=2;i<45;i++){
    F[i]=F[i-1]+F[i-2];
  }
  
  scanf("%d",&n);
  printf("%d\n",F[n]);
  return 0;
}



Measured memory_bytes: 2112
#include<cstdio>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
int a[100009];
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i]%2;
	}
	if(ans%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC163
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            double men = 2 * s[0] *PI;
            WriteLine(men);
        }
    }
}


Measured memory_bytes: 28100
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for i in range(n)]
cd=[list(map(int, input().split())) for j in range(m)]

for i in range(n):
    l=[]
    for j in range(m):
        dist=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        l.append(dist)
    goal = l.index(min(l))+1
    print(goal)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}

/*!* [binsearch] *!*/
/*+* 二分探索 *+*/
// judge を満たすような(l,r]内の下限を求める
// l:[X] 定義域の下限
// r:[X] 定義域の上限
// judge:[F = X -> bool] 値 X を評価する関数
// lower:[bool] false にすると代わりに[l,r)内の上限を求める
// eps:[X] 終了距離

template <typename X, typename F>
X BinSearch(X l, X r, F judge, bool lower = true, X eps = 1) {
    while (r - l > eps) {
        X m = (r + l) / 2;
        if (judge(m) == lower) {
            r = m;
        } else {
            l = m;
        }
    }
    return lower ? r : l;
}

struct Data {
    i64 b, l, u;
    bool operator<(const Data &x) const {
        return make_tuple(b, l, u) < make_tuple(x.b, x.l, x.u);
    }
};

int main() {
    const i64 INF = 1e14;
    i64 N, X;
    cin >> N >> X;
    vector<pair<i64, Data>> data(N);
    i64 S_N = 0;

    for(int i = 0; i < N; i++) {
        i64 b, l, u;
        cin >> b >> l >> u;
        data[i] = {u * (X - b) + l * b, {b, l, u}};
        S_N += l * b;
    }

    // O(N log N)
    sort(REV_WHOLE(data));

    vector<i64> S(N);
    for(int i = 0; i < N; i++) {
        S[i] = data[i].first + (i ? S[i - 1] : 0);
    }

    // O(N log NX)
    i64 ans = BinSearch<i64>(-1, N * X, [&](i64 A) -> bool {
        // O(N)
        // (sum of a_i) <= A ?

        i64 m = A / X;
        i64 r = A - m * X;
        for(int j = 0; j < N; j++) {
            i64 e = 0;
            i64 x;
            Data d;
            tie(x, d) = data[j];
            e += max(d.l * (r - d.b), d.u * (r - d.b)) + d.l * d.b;
            if(m > 0) {
                e += j < m ? S[m] - x : S[m - 1];
            }
            e -= S_N;
            if(e >= 0) return true;
        }
        return false;
    });
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int n,k;
	ll ans = 0;
	scanf("%d%d",&n,&k);
	for(register int i = k;i <= n+1;i++)
	{
		ll maxx,minn;
		minn = 1ll*(0+i-1)*i/2;
		maxx = 1ll*(n + 1 + n - i)*i/2;
		ans = (ans + maxx%MOD - minn%MOD + 1 + MOD)%MOD; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3832
r,c=map(int,input().split())
sheet=[list(map(int,input().split())) for i in range(r)]
for i in range(r):
    sheet[i].append(sum(sheet[i]))
Column_sum=[0]*(c+1)
for j in range(c+1):
    for i in range(r):
        Column_sum[j]+=sheet[i][j]

for i in range(r):
    print(*sheet[i])
print(*Column_sum)


Measured memory_bytes: 6228
#include<stdio.h>
#include<stdlib.h>
int s(int *a,int *b){return *a-*b;}
int N,M,R,P[1005]={0},X[1000005],i,j,p,t;
int bs(int r,int l,int k)
{
	int m;
	while(l-r>1)
	{
		m=(r+l)/2;
		if(X[m]==k)
			return m;
		if(X[m]<=k)
			r=m+1;
		else
			l=m-1;
	}
	return l;
}

int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		for(i=0;i<N;i++)
			scanf("%d",&P[i+1]);
		for(i=p=0;i<=N;i++)
			for(j=i;j<=N;j++)
				X[p++]=P[i]+P[j];
		qsort(X,p,4,s);
		for(i=R=0;i<p;i++)
		{
			if(X[i]<=M)
			{
				t=X[i]+X[bs(0,p-1,M-X[i])];
				if(t<=M&&t>R)R=t;
			}
		}
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 4564
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] countArr = new int[11];
            for (int i = 0; i < 3; i++) {
                countArr[in.nextInt()]++;
            }

            if (countArr[5] == 2 && countArr[7] == 1) {
                out.println("YES");
            } else {
                out.println("NO");
            }

        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 28500
def main():
    N, W = list(map(int, input().split()))
    DP = [[0 for i in range(W+1)] for j in range(N+1)]
    for i in range(N):
        w, v = list(map(int, input().split()))
        for sum_w in range(W+1):
            if sum_w - w >= 0:
               DP[i+1][sum_w] = max(DP[i][sum_w],DP[i][sum_w-w]+v)
            DP[i+1][sum_w] = max(DP[i+1][sum_w],DP[i][sum_w])
    print(max(DP[-1]))

if __name__ == "__main__":
    main()
    pass

Measured memory_bytes: 171528
use std::io::prelude::*;
use std::io;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_to_string(&mut buf).unwrap();

    let mut lines = buf.lines();

    let (n, m) = {
        let mut line = lines.next().unwrap().split_whitespace();
        let n: i32 = line.next().unwrap().parse().unwrap();
        let m: usize = line.next().unwrap().parse().unwrap();
        (n, m)
    };
    let mut foods: Vec<bool> = vec![true; m];
    
    for _ in 0..n {
        let mut line = lines.next().unwrap().split_whitespace();
        let k: i32 = line.next().unwrap().parse().unwrap();
        let mut food: Vec<bool> = vec![false; m];
        for __ in 0..k {
            let a: i32 = line.next().unwrap().parse().unwrap();
            food[a as usize - 1] = true;
        }
        
        foods = foods.iter().zip(food.iter()).map(|(a, b)| *a && *b).collect();
    }
    
    let mut ans = 0;
    for item in foods.iter() {
        ans += *item as i32;
    }
    
    println!("{}", ans);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >> n;
    int ans = 0;
    auto check = [&](int x){
        int res = 0;
        for(int i = 1;i*i <= x;i++){
            if(x%i == 0){
                res++;
                if(x/i != i)res++;
            }

        }
        return res == 8;

    };
    for(int i = 1; i <= n;i+=2){
        if(check(i))ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using ld = long double;
const ld inf = 1e20;
const ld eps = 1e-10;
const ld pi = acos(-1.0);

using point = complex<ld>;

ld dot(point a, point b) {
	return real(conj(a) * b);
}

ld cross(point a, point b) {
	return imag(conj(a) * b);
}

int ccw(point a, point b, point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;	// a,b,c counter-clockwise
	if (cross(b, c) < -eps) return -1;	// a,b,c clockwise
	if (dot(b, c) < 0) return 2;		// c,a,b on a line
	if (norm(b) < norm(c)) return -2;	// a,b,c on a line
	return 0;							// a,c,b on a line
}

struct line {
	point a, b;
	line() {}
	line(const point& a_, const point &b_)
		: a(a_), b(b_) {}
};

bool isis_ll(line l, line m) {
	return std::abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(line l, line s) {
	return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(line l, point p) {
	return std::abs(cross(l.b - p, l.a - p)) < eps;
}

bool isis_sp(line s, point p) {
	return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

point proj(line l, point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

point is_ll(line s, line t) {
	point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool isis_ss(line s, line t) {
	if (isis_ll(s, t)) return isis_ls(s, t) && isis_ls(t, s);
	return isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a);
}

ld dist_lp(line l, point p) {
	return abs(p - proj(l, p));
}

ld dist_ll(line l, line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

ld dist_ls(line l, line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

ld dist_sp(line s, point p) {
	point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(line s, line t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}

istream& operator >> (istream& is, point& p) {
	ld x, y; cin >> x >> y;
	p = point(x, y);
	return is;
}

istream& operator >> (istream& is, line& l) {
	point a, b; cin >> a >> b;
	l = line(a, b);
	return is;
}

vector<point> convex_cut(const vector<point>& p, line l) {
	const int n = p.size();
	vector<point> res;
	for (int i = 0; i < n; ++i) {
		auto a = p[i], b = p[(i + 1) % n];
		if (ccw(l.a, l.b, a) != -1) {
			res.push_back(a);
		}
		if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0) {
			if (cross(a - b, l.a - l.b) == 0) continue;
			res.push_back(is_ll(line(a, b), l));
		}
	}
	return res;
}

ld area(const vector<point>& ps) {
	const int n = ps.size();
	ld a = 0;
	for (int i = 0; i < n; i++) {
		a += cross(ps[i], ps[(i + 1) % n]);
	}
	return abs(a / 2);
}

int main()
{
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vector<point> ps(n);
	for (int i = 0; i < n; i++) {
		cin >> ps[i];
	}
	int q;
	cin >> q;
	while (q--) {
		line l;
		cin >> l;
		cout << area(convex_cut(ps, l)) << endl;
	}
	return 0;
}



Measured memory_bytes: 3332
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]    
    T = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for h in range(H):
        cnt = 1
        for w in range(W):
            if S[h][w] == '#':
                cnt = 1
            else:
                L[h][w] = cnt
                cnt += 1

    for h in range(H):
        cnt = 1
        for w in range(W-1,-1,-1):
            if S[h][w] == '#':
                cnt = 1
            else:
                R[h][w] = cnt
                cnt += 1

    for w in range(W):
        cnt = 1
        for h in range(H):
            if S[h][w] == '#':
                cnt = 1
            else:
                T[h][w] = cnt
                cnt += 1

    for w in range(W):
        cnt = 1
        for h in range(H-1,-1,-1):
            if S[h][w] == '#':
                cnt = 1
            else:
                D[h][w] = cnt
                cnt += 1

    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = T[h][w] + D[h][w] + L[h][w] + R[h][w] - 3
            ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 179716
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    REP(i,n){
        REP(j,d){
            cin>>x.at(i).at(j);
        }
    }
    int cnt=0;
    REP(i,n-1){
        for(int j=i+1;j<n;j++){
            int sum=0;
            REP(l,d){
                sum+=(x.at(i).at(l)-x.at(j).at(l))*(x.at(i).at(l)-x.at(j).at(l));
            }
            //OUT(sum);
            for(int l=1;l*l<=sum;l++){
                if(l*l==sum) {
                    cnt++;
                    break;
                }
            }
        }
    }
    OUT(cnt);
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]


def bfs():
    q = [(0, 0, 1)]
    m = []
    while len(q) > 0:
        x, y, c = q.pop(0)
        for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
            if (H, W) == (yy + 1, xx + 1):
                return c + 1
            if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                    (xx, yy) not in m:
                m.append((xx, yy))
                q.append((xx, yy, c + 1))
    return -1


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    c = bfs()
    if c == -1:
        print(-1)
    else:
        print(ans - c)


main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

vector<pair<ll, int>> v;
set<int> s;
set<int, greater<int>> t;

int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		ll a; scanf("%lld", &a);
		v.EB(a, i);
	}
	sort(ALL(v), greater<pii>());
	s.insert(n);
	t.insert(-1);
	ll ans = 0;
	for(auto &p : v){
		int &c = p.second;
		ll &q = p.first;
		auto d = s.upper_bound(c),
				 e = s.upper_bound(*d);
		auto b = t.upper_bound(c),
				 a = t.upper_bound(*b);
		if(e != s.end()){
			ans += q * (c - *b) * (*e - *d);
		}
		if(a != t.end()){
			ans += q * (*d - c) * (*b - *a);
		}
		s.insert(c);
		t.insert(c);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 11120