akhauriyash/Code-Regression huggingface dataset:
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    string s,t; cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<vi> dp(n+1,vi(m+1,0));
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if(s[i] == t[j])
            {
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
            }
            else dp[i+1][j+1] = max(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
        }
    }
    int i = n, j = m;
    string ans="";
    while(i>0 and j>0)
    {
        if(dp[i][j] == dp[i-1][j]) i--;
        else if(dp[i][j] == dp[i][j-1]) j--;
        else {
            ans+=s[i-1];
            i--;
            j--;
        }
    }
    reverse(all(ans));
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

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


int main(){
    string s;cin>>s;
    ll bc = 0;
    ll ans = 0;
    int n = s.size();
    rep(i,n){
        if(s[i]=='B') bc++;
        else ans+=bc;


    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3752
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
	//input = input[0].split(" ");
	var r = input[0];
 
    var r= parseInt(r, 10);
   var R = r*r*3;
  
  
  console.log(R);
     }
     
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));    
 

Measured memory_bytes: 11468
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;



int main(){
	int n;
	cin >> n;
	map<int,int> dic;

	rep(i, 0, n) {
		int x;
		cin >> x;
		dic[x]++;
	}

	
	int cnt = 0;
	for (auto i : dic) {
		if (i.second % 2 == 1) {
			continue;
		}
		else {
			cnt++;
		}
	}

	if (cnt % 2 == 0){
		cout << dic.size() << endl;
	}
	else {
		cout << dic.size() - 1 << endl;
	}



	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define REP(i,m,n) for(i=(m);i<((int)(n));i++)
#define rep(i,n) REP(i,0,n)
#define INFTY (1<<21)
#define LLINFTY (1LL<<53)
typedef long long ll;
typedef unsigned long long ull;
int n,a[20],res;
inline int ab(int n){return n<0?-n:n;}
inline int min(int a,int b)
{
  return a<b?a:b;
}
void solve(int p,int x,int y)
{
  if(p==n){
    res=min(res,ab(x-y));
    return;
  }
  solve(p+1,x+a[p],y);
  solve(p+1,x,y+a[p]);
}
int main(void)
{
  int i;
  for(;;){
    scanf("%d",&n); if(!n)break;
    rep(i,n) scanf("%d",a+i);
    res=INFTY;
    solve(0,0,0);
    printf("%d\n",res);
  }
  return 0;
}

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

ll func(ll x, ll y, ll z) {
	ll maxV = max({ x,y,z });
	ll minV = min({ x,y,z });
	return maxV - minV;
}

int main() {

	ll h, w; cin >> h >> w;

	ll ans = 2147483647;
	for (ll y = 1; y <= h - 1; y++) {
		ll sa, sb, sc;
		sa = y * w;
		sb = w / 2 * (h - y);
		sc = (w - w / 2) * (h - y);
		ans = min(ans, func(sa, sb, sc));

		if (y == h - 1) continue;
		sa = y * w;
		sb = (h - y) / 2 * w;
		sc = (h - (y + (h - y) / 2)) * w;
		ans = min(ans, func(sa, sb, sc));
	}

	swap(h, w);
	for (ll y = 1; y <= h - 1; y++) {
		ll sa, sb, sc;
		sa = y * w;
		sb = w / 2 * (h - y);
		sc = (w - w / 2) * (h - y);
		ans = min(ans, func(sa, sb, sc));

		if (y == h - 1) continue;
		sa = y * w;
		sb = (h - y) / 2 * w;
		sc = (h - (y + (h - y) / 2)) * w;
		ans = min(ans, func(sa, sb, sc));
	}

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

Measured memory_bytes: 3636
#include<iostream>
#include<vector>

using namespace std;

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

vector<int> a[111];
vector<int> l;

int main() {
  int n;
  for (;;){
    cin >> n;
    if (n == 0) break;
    rep (i, n) {
      int m;
      a[i].clear();
      cin >> m;
      rep (j, m) {
	int p;
	cin >> p;
	a[i].push_back(p);
      }
    }
    int k;
    cin >> k;
    l.clear();
    rep (i, k) {
      int ll;
      cin >> ll;
      l.push_back(ll);
    }
    int res = -1;
    rep (i, n) {
      rep (j, k) {
	bool ok = false;
	rep (ii, a[i].size()) if (a[i][ii] == l[j]) ok = true;
	if (!ok)goto aaa;
      }
      if (res == -1) res = i;
      else {res = -1;break;}
    aaa:;
    }
    if (res >= 0) ++res;
    cout << res << endl;
  }
}

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

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)
const ll INF = 1LL << 60;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;


int main()
{
    ll N,W;

    cin>>N>>W;
    vl w(N+1);
    w[0]=0;
    vl v(N+1);
    v[0]=0;
    ll V=0;
    for(ll i=1;i<=N;i++) {

        cin >> w[i]>>v[i];
        V+=v[i];
    }
    
    vector<vector<ll>> dp(N+1,vl(V+1,INF));


    dp[0][0]=0;
    for(ll i=1;i<=N;i++) {
        for(ll j=0;j<=V;j++) {
            if(j - v[i] >=0) {
                dp[i][j] = min( dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    ll res =0;
    rep(i,0,N+1) {
        rep(j,0,V+1) {

            if(dp[i][j]<=W)
                res = j;
        }
    }

    cout<<res<<endl;

    return 0; 
}



Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,m,ans=0; cin >> n >> m;
  ans= n*(n-1)/2+m*(m-1)/2;
  cout << ans << endl;
}






Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def meguru_bisect(ok, ng):
        """
        is_okを定義して下さい
        :param ok: 取りうる最小の値-1
        :param ng: 取りうる最大の値+1
        :return: is_okを満たす最小(もしくは最大)の値
        """
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def is_ok(x):
        cnt = 0
        for h in H:
            h -= b * x
            if h > 0:
                cnt += (h + ab - 1) // ab
        return cnt <= x

    n, a, b = map(int, input().split())
    ab = a - b
    H = list(int(input()) for _ in range(n))

    res = meguru_bisect(10 ** 9 + 1, 0)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12980
using System;
namespace ABC
{
    public class A
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            while(N >= 1000)
            {
                N = N - 1000;
            }

            if (N <= 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1000 - N);
            }
            
        }
    }
}


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

int main()
{
	int n,x, k, i;
	cin>>n>>k;
	for(i=0; i<n; i++)cin>>x;
	int ans=0;
	int r=1;
	while(r<n)
	{
		r+=(k-1);
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, bool> mp;
    rep(i, n)
    {
        int t;
        cin >> t;
        if (mp[t] == true)
        {
            cout << "NO" << endl;
            return 0;
        }
        mp[t] = true;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i){
        cin >> H[i];
    }

    bool isYes = true;
    if(N != 1){
        for(int i = N-2; i >= 0; --i){
            int tmp = H[i]-H[i+1];
            if(tmp <= 0){
                continue;
            }else if(tmp == 1){
                H[i]--;
            }else{
                isYes = false;
                break;
            }
        }
    }
    if(isYes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    char c; cin >> c;
    cout << char(c+1)<< endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m, f, b;
	cin>> m >> f >> b;
	if (m + f >= b){
		if (m > b){
			cout << "0" << endl;
		}
		else 
			cout << (b - m) << endl;
	}
	 
	
	if (m + f < b){
		cout << "NA" << endl;
	}
	
       
		


	return 0;
}


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

namespace AOJ2
{
    class Program
    {

        static List<int> CorrectCountList = new List<int>();

        static Dictionary<int, int> RankDict = new Dictionary<int, int>();

        static void Main(string[] args)
        {
            
            Dictionary<int, int> teamDict = new Dictionary<int, int>();
            
            while (true)
            {
                string[] inputArray = Console.ReadLine().Split(',');
                if (inputArray[0] == "0" && inputArray[1] == "0")
                {
                    break;
                }
                
                teamDict.Add(int.Parse(inputArray[0]), int.Parse(inputArray[1]));
                CorrectCountList.Add(int.Parse(inputArray[1]));
            }

            CorrectCountList =  CorrectCountList.Distinct().ToList();
            CorrectCountList.Sort();
            CorrectCountList.Reverse();

            SetDictionary();

            List<int> outList = new List<int>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                int num = int.Parse(input);
                outList.Add(RankDict[teamDict[num]]);

            }

            foreach (int a in outList)
            {
                Console.WriteLine(a);
            }



        }

        static void SetDictionary()
        {
            for (int i = 0; i < CorrectCountList.Count; i++)
            {
                RankDict.Add(CorrectCountList[i], i + 1);
            }


        }
        
    }
}

Measured memory_bytes: 6500
//
//AtCoder Beginner Contest 135
//C - City Savers
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;
    cin >> n;

    vector<int> a(n+1);
    vector<int> b(n);
    REP(i, n+1) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll ans = 0;

    REPD(i,n){
        REPD(j,2){
            ll sa = a[i+j] - b[i];
            if (sa>=0) {
                ans+=b[i];
                a[i+j]-=b[i];
                b[i] = 0;
            }else{
                ans+=a[i+j];
                b[i]-=a[i+j];
                a[i+j]=0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for i in range(H)]
ans=float("inf")

for i in range(1<<(H-1)):
    cnt=0
    
    lst=[0]*H
    qqq=0
    for j in range(H-1):
        if i&(1<<j)==0:
            lst[j+1]=qqq
            continue
        else:
            qqq+=1
            lst[j+1]=qqq
            cnt+=1
    data=[0]*H
    for j in range(W):
        for k in range(H):
            data[lst[k]]+=S[k][j]
            if data[lst[k]]>K:
                cnt+=1
                break
        else:
            continue
        data=[0]*H
        for k in range(H):
            data[lst[k]]+=S[k][j]
            if data[lst[k]]>K:
                break
        else:
            continue
        break
    else:
        ans=min(ans,cnt)
print(ans)

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

int N, D[200000], M, T[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> D[i];
    cin >> M;
    for(int i=0;i<M;i++)    cin >> T[i];

    map<int, int> m;
    for(int i=0;i<N;i++)    m[ D[i] ]++;

    string ans = "YES";
    for(int i=0;i<M;i++){
        if( m[ T[i] ] == 0 ){
            ans = "NO";
            break;
        }
        m[ T[i] ]--;
    }

    cout << ans << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edge(N+1, vector<int>());
    int a, b;
    for (int i = 0; i < M; i++) {
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<vector<int>> dp(N+1, vector<int>(11, 0));
    int Q;
    cin >> Q;
    vector<int> c(Q+1, 0);
    int v, d;
    for (int i = 1; i <= Q; i++) {
        scanf("%d %d %d", &v, &d, &c[i]);
        dp[v][d] = i;
    }
    for (int i = 9; i >= 0; i--) {
        for (int v = 1; v <= N; v++) {
            dp[v][i] = max(dp[v][i], dp[v][i+1]);
            for (int u : edge[v]) {
                dp[v][i] = max(dp[v][i], dp[u][i+1]);
            }
        }
    }
    for (int v = 1; v <= N; v++) printf("%d\n", c[dp[v][0]]);
    return 0;
}


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

using namespace std;

inline int read()
{
    int x=0;char ch=getchar();
    while(ch<'0'|| ch>'9')ch=getchar();
    while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
    return x;
}

typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;

int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];

inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}

inline void work(vec &ls,vec &rs,vec &f)
{
    if(ls.size()>rs.size())swap(ls,rs);
    int el=ls.size(),er=rs.size();

    sort(ls.begin(),ls.end(),cmpy);
    sort(rs.begin(),rs.end(),cmpx);

    mv[0]=rs[0].y;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].y);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].y+rs[j].x>mid)j--;
        if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
    }

    sort(ls.begin(),ls.end(),cmpx);
    sort(rs.begin(),rs.end(),cmpy);
    mv[0]=rs[0].x;
    for(int i=1;i<er;i++)
        mv[i]=min(mv[i-1],rs[i].x);

    for(int i=0,j=er-1;i<el;i++)
    {
        while(j>=0 && ls[i].x+rs[j].y>mid)j--;
        if(j>=0)f.push_back(pr(mv[j],ls[i].y));
    }
}

inline void dfs(int u)
{
    if(!f[u].empty())f[u].clear();
    if(g[u].empty())
    {
        f[u].push_back(pr(0,0));
        return;
    }

    for(int i=0,e=g[u].size();i<e;i++)
        dfs(g[u][i].x);

    vec &ls=f[g[u][0].x];
    for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
        ls[i].x+=c,ls[i].y+=c;
    vec &rs=f[g[u][1].x];
    for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
        rs[i].x+=c,rs[i].y+=c;

    work(ls,rs,f[u]);
    ls.clear();
    rs.clear();
}

int main()
{
    n=read();
    for(int i=2,a;i<=n;i++)
    {
        fa[i]=read();
        g[fa[i]].push_back(pr(i,read()));
    }

    ll l=0,r=1e10,ans=1e10;
    while(l<=r)
    {
        mid=l+r>>1;
        dfs(1);
        if(f[1].empty())
            l=mid+1;
        else
            r=mid-1,ans=mid;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 32372
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 256 * 1024;

int s[MAX_N];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &s[i]);
	int is_odd = 0;
	for (int i = 0; i < n; i++)
		if (s[i] % 2 == 1) is_odd = 1;
	if (is_odd) cout << "first";
	else cout << "second";
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int list[n];
	for(int i=0; i<n; ++i) {
		cin >> list[i];
	}
	int res = INT_MAX;
	for(int to=-100; to<=100; ++to) {
		int cost = 0;
		for(int i=0; i<n; ++i) {
			cost += pow(to-list[i], 2);
		}
		res = min(res, cost);
	}
	cout << res << endl;
}


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

using namespace std;

const int MAXN = 1e4+10;
const int MAXG = 110;

int n,m;
int x[MAXN],op[MAXN],y[MAXN];
int f[MAXG][MAXG],g[MAXG][MAXG];
bool vis[MAXG] ;

void dfs(int u){
    int i, k;
    vis[u] = 1;
    for(i=1;i<=n;i++)
    if(g[u][i]){
        if(!vis[i]) dfs(i);
        for(k=1;k<=n;k++)
        if(f[i][k])
        f[u][k] = f[k][u] = 1;
    }
}

bool check(int mid) {
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            f[i][j] = 0 ;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) g[i][j]=0;
        g[i][i]=1;
    }
    for (int Q=1; Q<=mid; Q++) {
        int i = x[Q] , j = y[Q] , ope = op[Q];
        if (ope==1) g[i][j] = 1 ;
        else if (ope==2) g[i][j] = g[j][i] = 1 ;
        else if (ope==4) f[i][j] = f[j][i] = 1 ;
    }
    for (int k = 1 ; k <= n ; k++)
        for (int i = 1 ; i <= n ; i++)
            for (int j = 1 ; j <= n ; j++)
                if (g[i][k] && g[k][j]) g[i][j] = 1 ;

    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++)
    if(!vis[i]) dfs(i);

    for (int Q = 1 ; Q <= mid ; Q++) {
        int i = x[Q] , j = y[Q] , ope = op[Q];
        if (ope==3) {
            if (f[i][i] && f[j][j]) return false ;
            if (g[i][j] && g[j][i]) return false ;
        } else if (ope==5) {
            if (f[i][j] || f[j][i] || f[i][i] || f[j][j]) return false ;
        }
    }
    return true ;
}

int main() {
    while (~scanf("%d%d",&n,&m) && (n+m)) {
        for (int i=1; i<=m; i++) scanf("%d%d%d",&op[i],&x[i],&y[i]);
        int l=1,r=m,ans=0;
        while (l<=r) {
            int mid=l+r>>1;
            if (check(mid)) {
                ans=mid;
                l=mid+1;
            } else r=mid-1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>

int main(int argc, char const *argv[]) {

        int N;
        std::cin >> N;

        int sum_sitting_human_num;
        for (size_t gtoupNum = 0; gtoupNum < N; gtoupNum++) {
            int begin_edge_position;
            int end_edge_position;
            std::cin >> begin_edge_position >> end_edge_position;
            sum_sitting_human_num += (end_edge_position - begin_edge_position) + 1;
        }
        std::cout << sum_sitting_human_num << '\n';

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long int x[2000];
long long int y[2000];
long long int z[2000];
int xa,ya,za;

bool comp(int a, int b) {
    return x[a]*xa+y[a]*ya+z[a]*za>x[b]*xa+y[b]*ya+z[b]*za;
}



int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++){
        scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
    }
    long long int ans=0;
    for(int i=-1;i<2;i+=2)for(int j=-1;j<2;j+=2)for(int k=-1;k<2;k+=2){
        xa=i;
        ya=j;
        za=k;
        vector<int> po;
        for(int h=0;h<N;h++)po.push_back(h);
        sort(po.begin(),po.end(),comp);
        long long int karians=0;
        for(int l=0;l<M;l++)karians+=x[po[l]]*xa+y[po[l]]*ya+z[po[l]]*za;
        if(karians>ans)ans=karians;
    }
    printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

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

namespace NyaGadget
{

#define rep(i, begin, end) for (ll i = begin; i < end; i++)
#define size(collection) ((ll) (collection).size())
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)

	struct Imos2D
	{	// 二次元IMOS法ライブラリ
		vector<vector<ll>> grid;

		Imos2D(ll w, ll h)
		{
			grid.resize(h + 1);
			each(i, e, grid)
				e.resize(w + 1);
		}

		void Add(ll hmin, ll hmax, ll wmin, ll wmax, ll v)
		{
			grid[hmin][wmin] += v;
			grid[hmin][wmax + 1] -= v;
			grid[hmax + 1][wmin] -= v;
			grid[hmax + 1][wmax + 1] += v;
		}

		void Update(void)
		{
			rep(i, 0, size(grid))
			{
				rep(j, 1, size(grid[i]))
					grid[i][j] += grid[i][j - 1];
			}
			rep(i, 1, size(grid))
			{
				rep(j, 0, size(grid[i]))
					grid[i][j] += grid[i - 1][j];
			}
		}
	};

#undef rep
#undef size
#undef fori
#undef each

}

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;

struct Range
{
	ll l;
	ll r;
};

int main(void)
{
	ll N, M, Q; cin >> N >> M >> Q;

	vector<Range> train(M);
	each(i, e, train)
	{
		cin >> e.l >> e.r;
		e.l--; e.r--;
	}

	vector<Range> query(Q);
	each(i, e, query)
	{
		cin >> e.l >> e.r;
		e.l--; e.r--; 
	}

	Imos2D imos(N, N);
	each(i, e, train)
		imos.Add(0, e.l, e.r, N - 1, 1);

	imos.Update();
	each(i, e, query)
		cout << imos.grid[e.l][e.r] << endl;

	return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#include<algorithm>
#include<cstdint>

int64_t const MOD = 998244353;

int const MAXN = 3000;

int64_t dp1[MAXN+1][MAXN+1];
int64_t dp2[MAXN+1][MAXN+1];
int N, S;

int main() {
  std::cin >> N >> S;
  for(int i = 1; i <= N; ++i) {
    // don't choose i'th num
    std::copy_n(dp1[i-1], S+1, dp1[i]);
    dp1[i][0] = dp2[i][0] = i;
    for(int s = 1; s <= S; ++s) dp2[i][s] = (dp2[i-1][s]+dp1[i-1][s])%MOD;
    int a; std::cin >> a;
    // x_1 = i
    (dp1[i][a] += i) %= MOD;
    (dp2[i][a] += i) %= MOD;
    // x_2+ = i
    for(int s = a+1; s <= S; ++s) {
      (dp1[i][s] += dp1[i-1][s-a]) %= MOD;
      (dp2[i][s] += dp1[i-1][s-a]) %= MOD;
    }
  }
  std::cout << dp2[N][S] << std::endl;
  return 0;
}


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

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	if ((a[1] * 10 + a[2]) % 4 == 0) {
		cout << "YES" << endl;
	} else  {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
$Rectangle=trim(fgets(STDIN));
//????????§??°???????????????
$fget = explode(" ", $Rectangle);
//????????????????¨????????????????
$W=$fget[0];
$H=$fget[1];
$x=$fget[2];
$y=$fget[3];
$r=$fget[4];
//??°?????????????????£????????´???????¨???????????????????
if(-100<=$x && $x<=100 && -100<=$y && $y<=100 && 0<$W && $W<=100 && 0<$H && $H<=100 && 0<$r && $r<=100){
    if($r <= $x && $x <= $W-$r && $r <= $y && $y <= $H-$r){
        echo "Yes";
    }
    else{
        echo "No";
    }
}
?>

Measured memory_bytes: 15488
N,D=map(int,input().split())
l=[]
l1=[]
count=0
for i in range(N):
  x,y=map(int,input().split())
  l.append(x)
  l1.append(y)
for i in range(N):
  if (l[i]**2 +l1[i]**2)**0.5 <=D:
    count+=1
print(count)    
  


Measured memory_bytes: 24928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e18;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  vector<ll> a, b;
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    a.push_back(x+y);
    b.push_back(x-y);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  cout << max(a.back() - a.front(), b.back() - b.front()) << endl;

  return 0;
}


Measured memory_bytes: 6624
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<typename S, typename T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<typename S, typename T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T> bool print_(const T& a) {
    cout << a;
    return true;
}
template <typename T> bool print_(const vector<T> &vec) {
    for(auto &a : vec) {
        cout << a;
        if(&a != &vec.back()) cout << " ";
    }
    return false;
}
template <typename T> bool print_(const vector<vector<T>>& vv) {
    for(auto &v : vv) {
        for(auto &a : v) {
            cout << a;
            if(&a != &v.back()) cout << " ";
        }
        if(&v != &vv.back()) cout << "\n";
    }
    return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail> 
void print(Head &&head, Tail &&... tail) {
    bool f = print_(head);
    if(sizeof...(tail) != 0) cout << (f ? " " : "\n");
    print(forward<Tail>(tail)...);
}
#pragma endregion
void Pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    if(a[n-1]-a[0]>=2) Pr(0);
    if(a[n-1] == a[0]){
        Pr(a[0] <= n/2 || a[0] == n-1);
    }
    ll cnt = 0;
    rep(i, n){
        cnt += (a[0] == a[i]);
    }
    Pr(1 <= (a[n-1]-cnt) && (a[n-1]-cnt) <= (n-cnt)/2);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
	char x, y;
	scanf(" %c %c",&x,&y);
	if(x < y)
		printf("<\n");
	else if(x > y)
		printf(">\n");
	else
		printf("=\n");
}

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

vector<ll> memo(100);
vector<bool> checked(100,false);

void luca(int i){
    if(checked[i])return;
    if(i==0||i==1){
        return;
    }
    else{
        luca(i-1);luca(i-2);
        memo[i] = memo[i-1]+memo[i-2];
        checked[i]=true;
    }
}

int main(){
    memo[0]=2;
    memo[1]=1;
    checked[0]=true;checked[1]=true;
    int n;
    cin >> n;
    luca(n);
    cout << memo[n] <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem126b(s))
}

fun problem126b(s: String): String {
    val front = s.take(2).toInt()
    val back = s.takeLast(2).toInt()
    return if (front !in 1..12 && back !in 1..12) "NA"
    else if (front !in 1..12 && back in 1..12) "YYMM"
    else if (front in 1..12 && back !in 1..12) "MMYY"
    else "AMBIGUOUS"
}

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

int main(){
  int N;
  cin >> N;
  int cnt=0;
  for(int i=1;i<=N;i++){
    if(i>=1 &&i<=9){
      cnt++;
    }
    if(i>=100 &&i<=999){
      cnt++;
    }
    if(i>=10000 && i<=99999){
      cnt++;
    }
  }
  cout << cnt <<endl;
}


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

int main(){
  int N;
  cin>>N;
  string B[N];
  for(int i=0;i<N;i++) cin>>B[i];
  int M;
  cin>>M;
  string R[M];
  for(int i=0;i<M;i++) cin>>R[i];
  int A=0;
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=i;j<N;j++){
      if(B[i]==B[j]) sum++;
    }
    for(int k=0;k<M;k++){
      if(B[i]==R[k]) sum--;
    }
    A=max(A,sum);
  }
  cout<<A<<endl;
}

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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

bool compare(const pair<string, pair<int, int>> &a, const pair<string, pair<int, int>> &b)
{
    if (a.first != b.first)
    {
        return (a.first < b.first);
    }
    else
    {
        return (a.second.first > b.second.first);
    }
}

int main()
{
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> vp;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        vp.push_back({s, {p, i}});
        /* code */
    }
    sort(vp.begin(), vp.end(), compare);
    for (auto &a : vp)
    {
        cout << a.second.second + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <array>
#include <time.h>
#include <limits.h>
#pragma comment(lib, "winmm.lib")
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)


using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	stack<int> S;
	string tmp;
	int pop1, pop2;
	while (cin >> tmp){
		if (tmp == "+"){
			pop1 = S.top();
			S.pop();
			pop2 = S.top();
			S.pop();
			S.push(pop1 + pop2);
		}
		else if (tmp == "-"){
			pop1 = S.top();
			S.pop();
			pop2 = S.top();
			S.pop();
			S.push(pop2 - pop1);
		}else if (tmp == "*"){
			pop1 = S.top();
			S.pop();
			pop2 = S.top();
			S.pop();
			S.push(pop1 * pop2);
		}else if (tmp == "/"){
			pop1 = S.top();
			S.pop();
			pop2 = S.top();
			S.pop();
			S.push(pop2 / pop1);
		}
		else{
			S.push(stoi(tmp));
		}
	}

	cout << S.top() << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll N, K; cin>>N>>K;
    vector<ll> h(N, 0);
    for(int i=0; i<N; ++i) cin>>h[i];
    vector<ll> dp(N, INT_MAX);
    dp[0] = 0;
    for(int i=0; i<N; ++i){
        for(int j=i+1; j<=min(N-1, i+K); ++j){
            dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				
				sum+=(__gcd(i,(__gcd(j,k))));
			}
		}
	}
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 3652
import math

a, b, x = map(int, input().split())

if x <= ((a**2) * b / 2):
    ans = a * (b**2) / (2 * x)
else:
    ans = 2 * ((a**2 * b) - x) / a**3
e = 90
s = 0
while e - s > 10**(-8):
    m = (e + s) / 2
    z = math.tan(math.radians(m))
    if z == ans:
        s = m
        break
    elif z > ans:
        e = m
    else:
        s = m
print(s)



Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	LL k,count,num;
	// nyuryoku
	cin >> k;
	// keisan
	count = 1;
	num = 1;
	if(k % 2 == 0 || k%5 == 0){
		cout << "-1" << endl;
		return 0;
	}
	k *= 9;
	while(1){
		num = num*10%k;
		if(7*(num -1)%k == 0){
			cout << count << endl;
			return 0;
		}
		count++;
	}
	// syutsuryoku
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define ll long long

using namespace std;

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;

        vector<ll> a(n);
        for (int i = 0; i < n; i++)
        {
            in >> a[i];
        }
        sort(a.begin(), a.end());

        out << *max_element(a.begin(), a.end()) - *min(a.begin(), a.end()) << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

ll n;
ll a[200001];
int yoso[200001]={};


int main(){
  scanf("%lld",&n);
  ll sum=0;
  for(ll i=1;i<=n;i++){
    scanf("%lld",&a[i]);}
  for(ll i=n;i>=1;i--){
    if(i+a[i]<=200000){
      sum+=yoso[i+a[i]];}
    if(i-a[i]>0){
      yoso[i-a[i]]++;}}
  printf("%lld\n",sum);


  //printf("%lld %lld\n",a,b);
  
  return 0;
}


Measured memory_bytes: 4032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int n, m, c; cin >> n >> m >> c;
	vector<int> b(m), a(m);
	int t = 0, ans = 0;
	rep(i, m)cin >> b[i];
	rep(hi, n) {
		rep(i, m) {
			cin >> a[i];
			t += a[i] * b[i];
		}
		if (t + c > 0)
			ans++;
		t = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const int maxn=1e6+5;
ll n,m,p;
ll ss,ee;

int head[maxn];

ll cnt=0;
/***
deep 数组初始化为-1
***/
vector<int>v[maxn];
ll dis1[maxn],dis2[maxn];
bool vis[maxn];
void bfs()
{
    for(int i=1;i<=n;i++) dis2[i]=INF,vis[i]=false;
    queue<int>q;
    q.push(ss);
    vis[ss]=1;
    dis2[ss]=0;
    while(!q.empty())
    {
        int u=q.front();q.pop();vis[u]=false;
        for(int i=0;i<v[u].size();i++)
        {
            int e=v[u][i];
            if(dis2[e]>dis2[u]+1)
            {
                dis2[e]=dis2[u]+1;
                if(!vis[e])
                {
                    q.push(e);
                    vis[e]=1;
                }
            }
        }
    }
}
void bfs1()
{
    for(int i=1;i<=n;i++) dis1[i]=INF,vis[i]=false;
    queue<int>q;
    q.push(ee);
    vis[ee]=1;
    dis1[ee]=0;
    while(!q.empty())
    {
        int u=q.front();q.pop();vis[u]=false;
        for(int i=0;i<v[u].size();i++)
        {
            int e=v[u][i];
            if(dis1[e]>dis1[u]+1)
            {
                dis1[e]=dis1[u]+1;
                if(!vis[e])
                {
                    q.push(e);
                    vis[e]=1;
                }
            }
        }
    }
}
int main()
{
    scanf("%lld%lld%lld",&n,&ss,&ee);
    for(int i=1;i<=n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    bfs();
    bfs1();
    //ee dis1 ss dis2
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        if(dis2[i]<dis1[i])
        {
            res=max(dis1[i]-1,res);
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 31104
#include <stdio.h>

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  int sum = 0;
  for (int i = 0; i < m; i++) {
    int tmp;
    scanf("%d", &tmp);
    sum += tmp;
  }

  printf("%d\n", sum <= n ? n - sum : -1);

  return 0;
}


Measured memory_bytes: 1736
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {

  long k;
  vector<long> a(5, 0);
  cin >> a;

  // long min = 0;

  sort(a.begin(), a.end(), [](long & l, long & r) {
    return (l-1) % 10 < (r-1) % 10;
  });


  for (int i = 1; i < 5; ++i) {
    a[i] = (ceil((double)a[i] / 10.0)) * 10;
  }

  long ans = 0;
  ans = a[0] + a[1] + a[2] + a[3] + a[4];




  cout << ans;





}




















Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
//#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
//typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int N = 1e3+1;
//int n,m,k,q;

const int MOD = 1e9+7;
int main(){

    int w,a,b;
    cin>>w>>a>>b;
    if(b<a) swap(a,b);
    
    if(a+w>=b) cout<<0<<endl;
    else cout<< b-(a+w)<<endl;
    


    return 0;
}


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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n+1];
    for(int i=0;i<=n;++i) cin>>a[i];
    if(n==0)
    {
        if(a[0]==1)
        {
            cout<<1;
            return 0;
        }
        else
        {
            cout<<(-1);
            return 0;
        }
    }
    int b[n+1];
    b[0]=1;
    for(int i=0;i<n;++i)
    {
        b[i+1]=min(2*(b[i]-a[i]),(int) 1e18);
    }
    int c[n+1];
    c[n]=a[n];
    if(b[n]<a[n])
    {
        cout<<(-1);
        return 0;
    }
    for(int i=(n-1);i>=0;i--)
    {
        c[i]=c[i+1]+a[i];
    }
    int res[n+1];
    int sum=0;
    for(int i=0;i<=n;++i)
    {
        res[i]=min(b[i],c[i]);
        sum+=res[i];
        if(res[i]<=0)
        {
            cout<<(-1);
            return 0;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>
#include <string>
#define LI long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(void){
    LI a[28]={};
    string s; cin>>s;
    FOR(i,0,s.size()){
        a[s[i]-'a']++;
    }
    LI ans=1;
    FOR(i,0,28){
        FOR(j,0,28){
            if(i<j) ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}


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

void solver(){
  long long a, b, k;

  cin >> a >> b >> k;

  if (a < k) {
    k -= a;
    a = 0;
    if (b < k) {
      b = 0;
    } else {
      b -= k;
    }
  } else {
    a -= k;
  }

  cout << a << " " << b << "\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    db n,k;
    cin>>n>>k;
    db ans=0;
    Fr(i,n){
        db ka=1/n;
        int kari=i;
        while(kari<k){
            kari*=2;
            ka/=2;
        }
        ans+=ka;
    }
    printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int x, y;
	while (cin >> x >> y, x * y) {//
		int skimap[15][15] = {};//x = j y = i
		int dp[15][15] = {};//x = j y = i
		int flyover = 0;//??´????£??????????????????????
		for (int i = 0; i < y; i++) {
			for (int j = 0; j < x; j++) {
				cin >> skimap[i][j];
			}
		}
		for(int i = 0; i < x; i++){
			if (skimap[0][i] == 0)dp[0][i] = 1;
		}
		for (int i = 0; i < y - 1; i++) {
			for (int j = 0; j < x; j++) {
				if (skimap[i][j] == 0) {
					if (j - 1 >= 0) {
						if (skimap[i + 1][j - 1] == 0) {
							dp[i + 1][j - 1] += dp[i][j];
						}
					}
					if (skimap[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
					if (j + 1 < x) {
						if (skimap[i + 1][j + 1] == 0) {
							dp[i + 1][j + 1] += dp[i][j];
						}
					}
				}
				else if (skimap[i][j] == 1) {
					continue;
				}else {
					if (i + 2 < y) {
						if (skimap[i + 2][j] != 1)dp[i + 2][j] = dp[i][j];
					}else {
						flyover += dp[i][j];
					}
				}
			}
		}
		int sum = flyover;
		for (int i = 0; i < x; i++) {
			sum += dp[y - 1][i];
		}
		cout << sum << endl;
	}
	return 0;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a[5], i, j, t;
  for(i = 0; i < 5; ++i) scanf("%d", &a[i]);
  for(i = 0; i < 5; ++i) for(j = i + 1; j < 5; ++j) if(a[i] < a[j]) t = a[i], a[i] = a[j], a[j] = t;
  for(i = 0; i < 4; ++i) printf("%d ", a[i]);
  printf("%d\n", a[4]);
  return 0;
}


Measured memory_bytes: 2712