akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}

ll dp[3000009][30],a[30][30],n,req=1;
ll get(int x,int y){
    if(dp[x][y]!=-1)
        return dp[x][y];
    if(y==0){
        dp[x][y] = 1;
        return dp[x][y];
    }
    dp[x][y] =0;
    for(int i=0;i<n;i++){
        if(1<<i & x){
            if(a[i+1][y]==1)
                dp[x][y] = (dp[x][y] + get( x- (1<<i) ,y-1))% mod;
        }
    }
    return dp[x][y];
}
int main(){
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<n;i++)
        req*=2;
    req -=1;
    cout<<get(req, n);
    // cout<<endl;
    // for(int i=0;i<=req;i++){
    //     for(int j=0;j<=n; j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
}

Measured memory_bytes: 703360
#include<bits/stdc++.h>
using namespace std;
char ch[4][4];
int main()
{
	int n=3;
	for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j)
	{
		cin>>ch[i][j];
	}
	cout<<ch[1][1]<<ch[2][2]<<ch[3][3]<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,x[105],i,pas,ans;
int main(){
	cin>>n;
	for(k=1;k<=n;k++){
		cin>>x[k];
	} pas=1e10;
	for(k=1;k<=100;k++){ ans=0;
		for(i=1;i<=n;i++){
			ans+=(k-x[i])*(k-x[i]);
		}
		pas=min(pas,ans);
	} cout<<pas;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int a,b,c; cin >> a >> b >> c;
	if(b*c >= a) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3616
// atcoder/abc178/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int x;
  while (cin >> x) {
    cout << (x ^ 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

void main() 
{
	int scanCheck = 0;
	int data[5];

	for (int i = 0; i < 5; i++) {
		scanCheck = scanf("%d", &data[i]);
	}
	for (int i = 0; i < 5; i++) {
		if (data[i] == 0) {
			printf("%d", i + 1);
		}
	}
}

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

long long dp[100001][13];

int main() {
    string s;
    cin >> s;
    int n = 0;
    n = s.size();
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int check = 0;
        if (s[i] == '?') check = -1;
        else check = s[i] - '0';

        for (int j = 0; j < 10; j++) {
            if (check != -1 && check != j) continue;
            for (int k = 0; k < 13; k++) {
                dp[i + 1][(10 * k + j) % 13] += dp[i][k];
            }
        }
        for (int j = 0; j < 13; j++) dp[i + 1][j] %= 1000000007;
    }
    cout << dp[n][5] << endl;

    return 0;
}


Measured memory_bytes: 10624
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX c
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
//階乗


long long modinv(long long a, long long m) {//modの逆元
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
ll Factrial(ll num){
  if(num==1||num==0){
    return 1;
  }else if(num<0){
    printf("ERROR_minus\n");
    return 0;
  }else{
    return (num*Factrial(num-1))%d9_7;
  }
}

ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める
  ll ans=1;
  for(ll i=n;i>=n-k+1;i--){
    ans*=i;
    ans%=mod;
  }
  ll k1=Factrial(k);
  k1%=mod;
  ans*=modinv(k1,mod);
  ans%=mod;
  return ans;
}
int main(void){
	ll n,m;
  cin>>n>>m;
  ll now=2;
  vi b(200000000,0);
  set<ll> nums;
  if(m==1){
    cout<<1<<endl;
    return 0;
  }
  while(m!=1){
    if(m%now==0){
      m/=now;
      b[now]++;
      nums.insert(now);
    }else{
      now+=1;
    }
  }
  ll ans=1;
  for(auto i:nums){
    //cout<<i<<" "<<b[i]<<endl;
    ans*=linercomb(n+(ll)b[i]-1,(ll)b[i],d9_7);
    ans%=d9_7;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 781568
n = int(input())
nums = [int(i) for i in input().split()]


def solve(nums):
    for num in nums:
        if num % 2 == 0:
            if num % 3 == 0 or num % 5 == 0:
                continue
            else:
                return 'DENIED'
    return 'APPROVED'


print(solve(nums))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n+m; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (B / A > C) {
        cout << C << endl;
    } else {
        cout << B / A << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;

int n, k;

void read(int &para)
{
	char ch = getchar();
	while (ch<'0' || ch>'9')
		ch = getchar();
	int x = 0;
	while (ch >= '0'&&ch <= '9')
		x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	para = x;
}

int main(int argc, char ** argv)
{
	read(n);
	for (int i = 0; i * 4 <= 2 * n; i++)
	{
		for (int j = 0; j * 7 + i * 4 <= 2 * n; j++)
			if (i * 4 + j * 7 == n)
			{
				cout << "Yes" << endl;
				return 0;
			}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	string tmp=s;
	for(int i=0;i<=s.size()/2-1;i++)
	{
		swap(s[i],s[s.size()-1-i]);
	}
	for(int i=0;i<=s.size()-1;i++)
	{
		if(s[i]=='b')
		{
			s[i]='d';continue;
		}
		if(s[i]=='d')
		{
			s[i]='b';continue;
		}
		if(s[i]=='q')
		{
			s[i]='p';continue;
		}
		if(s[i]=='p')
		{
			s[i]='q';continue;
		}
	}
	if(s==tmp)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int modi = 1e9+7;

void solve(){
	int h,w,k;
	cin >> h >> w >> k;
	vvl dp(h+1,vl(w+1,0));
	dp[0][0] =1;
	for(int i =0;i<h;i++){
		for(int j =0;j<w;j++){
			for(int k = 0;k<(1<<(w-1));k++){
				int pos = 1;
				for(int l=0;l<w-2;l++){
					if((k>>l)&1 && (k>>(l+1))&1)
						pos = 0;
				}

				if(pos){
					//for going left cases 
					if(j>=1 && (k>>(j-1))&1){
						dp[i+1][j-1]+=dp[i][j];
						dp[i+1][j-1]%=modi;
					}
					// for going right
					else if(j<=w-2 && (k>>(j))&1){
						dp[i+1][j+1]+=dp[i][j];
						dp[i+1][j+1]%=modi;
					}
					//just going done
					else {
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= modi;
					}
				}
			}
		}
	}
	dbg(dp);
	cout << dp[h][k-1] << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

int main(){
	int n, m; cin >> n >> m;
	vector<long long> a(n), b(m), c(m);
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	b.resize(m);
	c.resize(m);
	for(int i = 0; i < m; ++i) cin >> b[i] >> c[i];

	vector<int> index(m);
	iota(index.begin(), index.end(), 0);
	sort(index.begin(), index.end(), [&](int i, int j) { return c[i] > c[j]; });

	long long sum = 0;
	long long K = 0;
	for( auto i : index ){
		for(int j = 0; j < b[i]; ++j){
			if(K >= n) break;
			sum += max(a[K++], c[i]);
		}
	}
	for(int i = K; i < n; ++i) sum += a[i];
	cout << sum << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

map<P, ll> mp;

ll d(ll n) { return pow(2, n + 2) - 3; }

ll p(ll n, ll x) {
  if(mp.count({n, x})) return mp[{n, x}];
  if(n == 0) return 1;
  if(x <= 1) return 0;
  ll d1 = d(n - 1);
  ll res = 0;
  x--;
  if(x > d1) {
    res += pow(2, n) - 1;
    x -= d1;
  } else {
    mp[{n, x}] = p(n - 1, x);
    return mp[{n, x}];
  }
  res++;
  x--;
  if(x) {
    if(x >= d1)
      res += pow(2, n) - 1;
    else
      res += p(n - 1, x);
  }
  mp[{n, x}] = res;
  return res;
}

int main() {
  ll n, x;
  cin >> n >> x;
  cout << p(n, x) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String str = sc.next();
		char[] list = str.toCharArray();

        int[] intArray = convertIntArray(list);
        int sum = 0;

		for(int i = 0; i < intArray.length; i++)
		{
			sum += intArray[i];
		}

		if(sum % 9 != 0)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}
	}

	private static int[] convertIntArray(char[] array)
	{
		int[] intArray = new int[array.length];
		int index = 0;

		for(int i = 0; i < array.length; i++)
		{
			intArray[i] = Character.getNumericValue(array[i]);
		}

		return intArray;
	}
}


Measured memory_bytes: 32328
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

constexpr int mod = 998244353;

ll mpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else {
        ll y = (n % 2) ? x : 1;
        return mpow(x * x % mod, n / 2) * y % mod;
    }
}

int main() {
    int n; cin >> n;
    vector<int> d(n), a(n, 0);

    int m = 0;
    REP(i, n) {
        cin >> d[i];
        a[d[i]]++;
        m = max(m, d[i]);
    }

    bool f = true;
    REP(i, n) {
        if (i == 0 && d[i] != 0) {
            f = false;
        } else if (i != 0 && d[i] == 0) {
            f = false;
        }
    }

    if (!f) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    REP(i, m ) {
        ans *= mpow(a[i], a[i + 1]);
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;
// (]  >=
int main() {
    string s;
    cin >> s;
    bool first_win;
    if (s[0] != s.back()) {
        first_win = s.size() % 2;
    } else {
        first_win = 1 - (s.size() % 2);
    }
    if (first_win) {
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n; cin >> n;
    vvl g(n);
    map<pair<int,int>,int> id;
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--;b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        if(a > b)swap(a,b);
        id[{a,b}] = i;
    }
    int m; cin >> m;
    vl path(m,0);
    rep(i,m){
        int u,v; cin >> u >> v;
        u--;v--;
        queue<pair<int,int> > que;
        vl prev(n,-2);
        vl dists(n,-1);
        que.push({u, 0});
        dists[u] = 0;
        while(!que.empty()){
            int node = que.front().first;
            int dist = que.front().second;
            que.pop();
            for(auto nv:g[node]){
                if(dists[nv] != -1)continue;
                dists[nv] = dist + 1;
                prev[nv] = node;
                que.push({nv, dist+1});
            }
        }
        while(1){
                int a = v; //初めの位置
                int b = prev[v]; //次の位置
                if(b == -2)break;
                int tmp1 = min(a,b);
                int tmp2 = max(a,b);
                path[i] |= (1LL << id[{tmp1,tmp2}]);
                v = prev[v];
        }
        //out(path[i]);
    }
    ll res = 0;
    //制約を全探索する
    for(ll i=0;i < (1LL<<m);i++){
        ll now = 0;
        rep(j,m)if(i & (1LL<<j))now |= path[j];
        ll tmp = __builtin_popcountl(now); //黒が一個以上

        int white = __builtin_popcountll(now);  // 白くなるべき辺の数
        ll num = 1LL << (n - 1 - white);
        if(__builtin_popcountl(i) % 2 == 0)res += num;
        else res -= num;
        //out(res);
    }
    out(res);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int a[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0, f = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            if (f == 1) {
                f = 0;
                ++ans;
            } else {
                f = -1;
            }
        } else if (a[i] > a[i - 1]) {
            if (f == -1) {
                f = 0;
                ++ans;
            } else {
                f = 1;
            }
        }
    }
    cout << ans + 1;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N,M; cin >> N >> M;
  int A=0;
  rep(i,M){
    int a; cin >> a;
    A+=a;
  }
  if(N-A>=0) cout << N-A << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint n, h, w;
bool used[10005];

int main(void)
{
  cin >> n >> h >> w;
  llint x;
  for(int i = 0; i < n; i++){
    cin >> x;
    if(i % 2 == 0) x = i*w+x;
    else x = i*w-x;
    for(int j = 0; j < w; j++){
      used[x+j] = true;
    }
  }
  llint ans = 0;
  for(int i = 0; i < n*w; i++){
    if(used[i]) ans += h;
  }
  cout << h*n*w - ans << endl;
  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    string s;
    cin>>s;
    if(s.size()==26){
        if(s == "zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 << endl;
        }else {
            int  p = s.size()-1;
            char x = 'x';
            while(s[p-1]>s[p]&&p>=1){
             //  cout<<s[p]<<s[p-1]<<endl;
             p--;
            }
           // cout<<p<<endl;

           // cout<<p<<endl;
            char a1 = s[p-1];

           // cout<<p<<endl;
            char k = 'z';
            for(int i=p;i<26;i++){if(s[i]<k&&s[i]>a1)k=s[i];}


//           cout<<s[p]<<endl;


            p--;
           // cout<<p<<endl;
         //  cout<<k<<endl;


            string s2 = "";
            if(p>=2)s2 +=s.substr(0,p);

           s2+=k;

            cout<<s2<<endl;
        }
    }else{
        vector<int> v(27,0);
        rep(i,s.size()){
            int a = s[i] - 'a';
            v[a]++;
        }
        int b=0;
        while(v[b]!=0){b++;}
        cout<<s<<char('a'+b)<<endl;


    }



    return 0;
}


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
MOD = 10**9 + 7
N, M = inpl()
S = inpl()
T = inpl()

total = [0]*(N+1)*(M+1)
for i in range(N):
	for j in range(M):
		if S[i] == T[j]:
			n = total[(M+1)*i+j] + 1
		else:
			n = 0
		total[(M+1)*(i+1)+(j+1)] = (n + total[(M+1)*i+(j+1)] + total[(M+1)*(i+1)+j] - total[(M+1)*i+j]) % MOD
print((total[-1]+1) % MOD)

Measured memory_bytes: 72940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

map<string,int> atom;
bool unk;

ll A(string s)
{
    // printf(" A:::"); dbg(s);
    int S = s.size();
    int idx = 0;
    while(idx<S && (s[idx]<'0'||'9'<s[idx])) ++idx;

    ll mul = 1;
    string name = s.substr(0,idx);
    ll ret;
    if(!atom.count(name))
    {
        unk = true;
        ret = 0;
    }
    else ret=atom[name];

    if(idx!=S) mul = atoll(s.substr(idx).c_str());
    return ret*mul;
}

ll M(string s)
{
    // dbg(s);
    int S = s.size();
    if(S==0) return 0;

    int idx = 0;

    ll ret = 0;
    if(s[0]=='(')
    {
        int b = 1;
        ++idx;
        while(b>0)
        {
            if(s[idx]=='(') ++b;
            else if(s[idx]==')') --b;
            ++idx;
        }

        ll val = M(s.substr(1,idx-2));

        int mul = 1;
        if(idx<S && '0'<=s[idx] && s[idx]<='9')
        {
            int st = idx;
            while('0'<=s[idx] && s[idx]<='9') ++idx;
            mul = atoi(s.substr(st,idx-st).c_str());
        }

        ret += val*mul;
        ret += M(s.substr(idx));
    }
    else
    {
        int st = idx;
        ++idx;
        while(idx<S && (s[idx]<'A'||'Z'<s[idx]) && s[idx]!='(') ++idx;
        ret += A(s.substr(st,idx-st));
        ret += M(s.substr(idx));
    }
    return ret;
}

int main()
{
    string s;
    while(cin >>s)
    {
        if(s=="END_OF_FIRST_PART") break;
        int v;
        cin >>v;
        atom[s] = v;
    }
    while(cin >>s)
    {
        if(s=="0") break;

        unk = false;
        ll ans = M(s);

        if(unk) cout << "UNKNOWN" << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static long[] list = new long[10001];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			int y = stdIn.nextInt();
			int m = stdIn.nextInt();
			int d = stdIn.nextInt();
			
			int day = y*365 + (m-1) * 30 + d;
			
			if(day < (1868*365 + 8 * 30 + 8)) {
				System.out.println("pre-meiji");
			}
			else if(day <= (1912*365 + 6 * 30 + 29)) {
				System.out.println("meiji " + (y-1867) + " " + m + " " + d);
			}
			else if(day <= (1926*365 + 11 * 30 + 24)) {
				System.out.println("taisho "+ (y-1911) + " " + m + " " + d);
			}
			else if(day <= (1989*365 + 7)) {
				System.out.println("showa "+ (y-1925) + " " + m + " " + d);
			}
			else {
				System.out.println("heisei "+ (y-1988) + " " + m + " " + d);
			}
		}
	}
}

Measured memory_bytes: 17276
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

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

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

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

int main(void) {

	int n, a, b;
	cin >> n >> a >> b;

	int arr[3] = {};

	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		if (p <= a)
			arr[0]++;
		else if (a + 1 <= p && p <= b)
			arr[1]++;
		else
			arr[2]++;
	}

	COUT(min({arr[0],arr[1],arr[2]}));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>

using namespace std;

long long int lcm(long long int a, long long int b) {
	long long int x = a * b;
	long long int tmp;
	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a   = b;
		b   = tmp;
	}

	/* ユークリッドの互除法 */
	long long int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return x / b;
}

int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;

	long long int tempC_A  = (A - 1) / C;
	long long int tempD_A  = (A - 1) / D;
	long long int tempCD_A = (A - 1) / lcm(C, D);

	long long int tempC_B  = B / C;
	long long int tempD_B  = B / D;
	long long int tempCD_B = B / lcm(C, D);
	cout << (B - (tempC_B + tempD_B - tempCD_B)) -
	            (A - 1 - (tempC_A + tempD_A - tempCD_A))
	     << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pf pop_front
#define mp make_pair
using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s,t;
	int n,m;
	cin>>s>>t;
	n=s.size();
	m=t.size();
	int dp[n+1][m+1];
	for(int i=0;i<=m;i++)
		dp[0][i]=0;
	for(int j=0;j<=n;j++)
		dp[j][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-1]+(s[i-1]==t[j-1])));
		}
	}
	string ans="";
	int i=n,j=m;
	while(ans.size()<dp[n][m])
	{
		if(max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-1]+(s[i-1]==t[j-1])))==dp[i-1][j])
			i--;
		else if(max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-1]+(s[i-1]==t[j-1])))==dp[i][j-1])
			j--;
		else
		{
			ans=s[i-1]+ans;
			i--;
			j--;
		}
	}
	
	//cout<<dp[n][m]<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 35456
s=input()
l=[]
sm=0
arr=["0","1","2","3","4","5","6","7","8","9"]
for i in range(0,10):
  l.append(s.count(arr[i]))
for i in range(0,10):
    a=int(l[i])
    sm=sm+(a*i)
if sm%9==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9284
#include <iostream>

using namespace std;
char cell[51][51];

int main()
{
    int n, m, cnt;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
        cin >> cell[i][j];

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j){
        if (cell[i][j] == '.') {
            cnt = 0;
            for (int ln = i - 1; ln <= i + 1; ++ln)
                for (int col = j - 1; col <= j + 1; ++col)
                if ((ln != i || col != j) && cell[ln][col] == '#')
                    cnt++;
            cell[i][j] = 48 + cnt;
        }
        cout << cell[i][j];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
 
ll exp(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    ll R = exp(a, b / 2);
    if (b & 1)
    {
        ll p = ((R % mod) * (R % mod)) % mod;
        p = ((a % mod) * p) % mod;
        return p;
    }
 
    else
        return ((R % mod) * (R % mod)) % mod;
}
 
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    if(n==1||n==0) {cout<< 0; return 0;}
    ans += exp(10, n) % mod;
    ans -= exp(9, n) % mod;
    ans -= exp(9, n) % mod;
    ans += exp(8, n) % mod;
  	ans%=mod;
    cout << (ans+mod)%mod;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
#include<sstream>
#include<utility>
#include<string>
#include<cstdlib>
#include<valarray>
#include<algorithm>
#include<vector>
#include<iterator>
#include<list>
#include<set>
#include<numeric>
#include<bits/stdc++.h>
#define ll long long
ll prime[1000002];
using namespace std;
int Prime(int a)
{
    for(int i=2;i<=a/2;++i)
    {
        if(a%i==0)
        {
            return 0;
        }
    }
    return 1;
}
void sieve()
{   for(int i=0;i<=1000001;i++)
    prime[i]=0;
    int maxn=1000001;
    for(int i=2;i<=maxn;i++)
    {
        if(prime[i]==0)
        {
            for(int j=i;j<=maxn;j+=i)
            {
                prime[j]++;
            }
        }
    }
}
void fibo(ll a[],ll n)
{
    ll x=0;
    ll y=1;
    a[0]=0;
    a[1]=1;
    for(ll i=2;i<n;++i)
    {
        a[i]=(x+y)%10;
        x=y;
        y=a[i];
    }
}
ll f(ll w[],ll a[][2],ll i,ll y)
{
    for(ll j=0;j<y;++j)
    {
        if(a[i][2]<=w[j])
        {
            cout<<a[i][2];
            return w[j];
        }
    }
    return w[y-1];
}
ll s(ll v[],ll a[][2],ll i,ll x)
{
    for(ll j=0;j<x;++j)
    {
        if(a[i][1]>=v[j])
        {
            cout<<" "<<a[i][1]<<" ";
            return v[j];
        }
    }
    return v[0];
}
bool binarySearch(vector <ll> arr, int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return 1; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return 0; 
}
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t,n,i;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<double> coin(N);
    rep(i,N)cin >> coin[i];
    vector<vector<double>> dp(N+1, vector<double>(3010, 0));
    dp[0][0] = 1;
    rep(i,N){
        rep(j,3010){
            dp[i+1][j+1] += dp[i][j] * coin[i];
            dp[i+1][j] += dp[i][j] * (1-coin[i]);
        }
    }
    double ans = 0;
    rep(i,3010)if(N-i > i)ans += dp[N][N-i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 74016
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define REP(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
typedef long double ld;
using namespace std;

int x,y;
void solver() {
    while(cin>>x>>y){
        if(x!=0||y!=0) {
            if (x < y)
                cout << x << " " << y << endl;
            else
                cout << y << " " << x << endl;
        }else break;
    }
}

int main() {
    solver();
    return 0;
}

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

int main(){
    int n, b, f, r, v, i, j, k, a[4][3][10] = {};
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++){
                cout << " " << a[i][j][k];
            }
            cout << endl;
        }
        if (i ==3) break;
        cout << "####################" << endl;    
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<vector>
#include<cassert>
#include<map>


#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

int par[100010];

int find(int x) {
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  rep(i,N) par[i] = i;
  map<int,int> mp;
  bool fin = false;
  rep(i,K) {
    int a,b,c;
    cin >> a >> b >> c;
    if( fin ) continue;
    if( a == 1 ) {
      if( mp.count(find(b)) && mp.count(find(c)) ) {
	if( mp[find(b)] != mp[find(c)] ) { cout << i + 1 << endl; fin = true; continue; }
      } else if( mp.count(find(b)) || mp.count(find(c)) ) {
	if( mp.count(find(b)) ) mp[find(c)] = mp[find(b)];
	else                    mp[find(b)] = mp[find(c)];
      }
      unite(b,c);
    } else if( a == 2 ) {
      int id = find(b);
      if( mp.count(id) ) {
	if( mp[id] != c ) { cout << i + 1 << endl; fin = true; continue; }
      } else {
	mp[id] = c;
      }
    } else assert(false);
  }
  if( !fin ) puts("0");
  return 0;
}

Measured memory_bytes: 8136
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		Set<Integer> s = new HashSet<Integer>();
		s.add(ni());
		s.add(ni());
		s.add(ni());
		
		if(s.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	int n;
	ll d, x, y;
	cin >> n >> d;
	d *= d;

	int ctr = 0;
	while (n--)
	{
		cin >> x >> y;
		if (x*x + y*y <= d)
			ctr++;
	}
	cout << ctr << '\n';

	return 0;
}


Measured memory_bytes: 3652
n = int(raw_input())
a = map(int, raw_input().split())
dp = [1, 1]
p = a[0]
for x in a:
    t = min(dp)
    ndp = [t + 1, t + 1]
    if p <= x and ndp[0] > dp[0]:
        ndp[0] = dp[0]
    if p >= x and ndp[1] > dp[1]:
        ndp[1] = dp[1]
    dp = ndp
    p = x
print min(dp)


Measured memory_bytes: 11380
#include <iostream>
using namespace std;
typedef long long ll;
ll L,A[200010];
ll dp[200010][5] = {};

int main(){
	cin >> L;
	for(int i=1;i<=L;i++){
		cin >> A[i];
	}
	for(int i=0;i<=L;i++){
		for(int j=0;j<5;j++){
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	dp[0][1] = 0;
	for(int i=1;i<=L;i++){
		int c = 0;
		if(A[i]%2==1) c = 1;
		else if(A[i]==0) c = 2;
		dp[i][0] = dp[i-1][0]+A[i];
		dp[i][1] = min(dp[i-1][0],dp[i-1][1])+c;
		dp[i][2] = min(min(dp[i-1][1],dp[i-1][2]),dp[i-1][0])+(A[i]%2==0);
		dp[i][3] = min(min(dp[i-1][2],dp[i-1][3]),dp[i-1][0])+c;
		dp[i][4] = min(min(dp[i-1][3],dp[i-1][4]),dp[i-1][2])+A[i];
	}
	ll ans = 1e18;
	for(int j=0;j<5;j++) ans = min(ans,dp[L][j]);
	cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> nums(n);
  for(int i = 0; i < n; i++){
  	cin >> nums.at(i);
  }
  
  sort(nums.rbegin(), nums.rend());
  
  int ans = 0;
  for(int i = 0; i < n; i=i+2){
  	ans += nums.at(i);
  }
  for(int i = 1; i < n; i=i+2){
  	ans -= nums.at(i);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Rectangle Cutting
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll w, h, x, y;
  scanf("%lld%lld%lld%lld", &w, &h, &x, &y);

  printf("%.1lf %d\n", (double)w * h / 2, (x * 2 == w && y * 2 == h) ? 1 : 0);
  return 0;
}


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

int main() {
    int N;
    cin>>N;
    int d[N];
    for(int i=0;i<N;++i){
        cin>>d[i];
    }
    int ans = 0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            ans += d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
    	n: usize,
    	m: usize,
    }
    println!("{}", c2(n)+c2(m));
}

fn c2(n: usize) -> usize {
	if n < 2 { 0 } else if n == 2 { 1 } else { n * (n-1) / 2 }
}

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

bool find7(string s){
    for(int i=0; s[i]; i++){
        if(s[i] == '7')
            return true;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    string s = to_string(n);
    if(find7(s))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}



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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
int a, b;

int main() {
	cin >> a >> b;
	if(a + b >= 10) cout << "error";
	else cout << a + b;	
	
	return 0;
}

Measured memory_bytes: 256
#16D8101014F 久留米 竜之介 Python3
#a=[]
while(True):
	i=0
	tmp=0
	a=input().split('"') 
	aL=len(a)
	if a[0] ==".":
		break
	b=input().split('"')
	bL=len(b)
		
	if aL != bL:
		print("DIFFERENT")
	else:
		while(True):
			if a[i] != b[i]:
				print("DIFFERENT")
				break
			elif i > aL-2:
				if tmp==1:
					print("CLOSE")
					break
				else:
					print("IDENTICAL")
					break
			elif a[i+1] != b[i+1]:
				if tmp==1:
					print("DIFFERENT")
					break
				else: tmp=1
			i +=2
	


Measured memory_bytes: 5580
import sys
p = [[int(t) for t in r.split()] for r in sys.stdin.read().split('\n') if r != '']
N = p[0][0]
a = p[1]
b = [0]*N
c = 0
for i in range(N, 0, -1):
    f = a[i-1] ^ (sum(b[i-1:N:i]) % 2)
    b[i-1] = f
    c += f
print(c)
print(' '.join([str(i + 1) for i, n in enumerate(b) if n]))

Measured memory_bytes: 14756
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define loop(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define len(a) (int)a.size()
#define allv(a) (a).begin(),(a).end()
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double err = 1e-9;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;



int main()
{
	ios::sync_with_stdio(0);cin.tie(NULL);
	
	ll r, g, b, n;
	cin>>r>>g>>b>>n;
	
	ll ans = 0;

	for(int i = 0; i * r <= n; i++)
		for(int j = 0; j * g <= n - i * r; j++)
		{
			if((n - j * g - i * r) % b == 0)
				ans++;
		}
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;
P Q[LEN];
int head,tail;

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

int min(int a,int b){
return a<b?a:b;}


int main()
{
    int n,q,i,c,elaps=0;
    P u;
    scanf("%d%d",&n,&q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;

    while(head!=tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}



Measured memory_bytes: 11896
/*
      Ashraful Islam Paran
      13-September-2020
      17:37:41
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int x;
    cin>>x;
    if(x)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
    
    
    cerr<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

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

int dist[100001];
vector<int> adj[100001];

int tin[100001], tout[100001];
int t;
int ancestor[20][100001];

void dfs(int x, int p, int d){
    tin[x] = t++;

    ancestor[0][x] = p;
    for (int i = 1; i < 20; i++)
        ancestor[i][x] = ancestor[i - 1][ancestor[i - 1][x]];

    dist[x] = d;
    for (int i = 0; i < adj[x].size(); i++)
        if (adj[x][i] != p)
            dfs(adj[x][i], x, d + 1);

    tout[x] = t;
}

bool is_ancestor(int x, int y){
    if (x == 0 || y == 0)
        return true;
    return tin[x] <= tin[y] && tout[x] >= tout[y];
}

int lca(int x, int y){
    if (is_ancestor(x, y))
        return x;
    if (is_ancestor(y, x))
        return y;
    for (int i = 19; i >= 0; i--)
        if (!is_ancestor(ancestor[i][x], y))
            x = ancestor[i][x];
    return ancestor[0][x];
}

int main(){
    int n, u, v;
    cin >> n >> u >> v;
    int a, b;
    t = 0;
    for (int i = 0; i < n - 1; i++){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    if (u == v){
        cout << "0\n";
        return 0;
    }

    dfs(1, 0, 0);
    // for (int i = 1; i <= n; i++)
    // cout << dist[i] << "!\n";

    int ans = 0;
    for (int i = 1; i <= n; i++){
        //choose a point
        int distu = dist[u] + dist[i] - 2 * dist[lca(u, i)];
        int distv = dist[v] + dist[i] - 2 * dist[lca(v, i)];
        
        if (distv > distu)
            ans = max(ans, distv - 1);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 21376