akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, multiset<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const long long INF = 1LL<<40;

int main() {
    int N, K; cin >> N >> K;
    vector<long long> maxd(N, -INF), vals;
    multiset<long long> se;
    for (int i = 0; i < N; ++i) {
        int s; long long v;
        cin >> s >> v;
        --s;
        chmax(maxd[s], v);
        vals.push_back(v);
    }
    sort(vals.begin(), vals.end(), greater<long long>());
    sort(maxd.begin(), maxd.end(), greater<long long>());
    long long sum = 0;
    for (int i = 0; i < K; ++i) sum += vals[i], se.insert(vals[i]);
        
    long long res = 0;
    long long tmp = sum;
    for (long long x = 1; x <= K; ++x) {
        long long add = maxd[x-1];
        long long back = *se.begin();
        tmp += add;
        if (back > add) {
            se.erase(se.begin());
            tmp -= back;
        }
        else {
            se.erase(se.find(add));
            tmp -= add;
        }
        chmax(res, tmp + x * x);

        /*
        cout << "--------------" << endl;
        COUT(x);
        COUT(se);
        COUT(tmp);
        COUT(tmp + x*x);
        */
    }
    cout << res << endl;
}














Measured memory_bytes: 6260
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}
int main(){
  int a[5];
  while( scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
    qsort(a,5,sizeof(int),compare_int);
    if((a[0]==a[1]&& a[1]==a[2] && a[2]==a[3]) || (a[1]==a[2] && a[2]==a[3] && a[3]==a[4]))printf("four card\n");
    else if(a[0]==a[1] && a[1]==a[2]){
      if(a[3]==a[4])printf("full house\n");
      else printf("three card\n");
    }
    else if(a[1]==a[2] && a[2]==a[3])printf("three card\n");
    else if(a[2]==a[3] && a[3]==a[4]){
      if(a[0]==a[1])printf("full house\n");
      else printf("three card\n");
    }
    else if(a[0]==a[1]){
      if(a[2]==a[3] || a[3]==a[4])printf("two pair\n");
      else printf("one pair\n");
    }
    else if(a[1]==a[2]){
      if(a[3]==a[4])printf("two pair\n");
      else printf("one pair\n");
    }
    else if(a[2]==a[3] ||a[3]==a[4])printf("one pair\n");
    else {
      if(a[0]==1 && a[1]==10 && a[2]==11 && a[3]==12 && a[4]==13)printf("straight\n");
      else if(a[0]+1==a[1] && a[1]+1==a[2] && a[2]+1==a[3] && a[3]+1==a[4])printf("straight\n");
      else  printf("null\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    map<string,int> a;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        a[s]+=1;
    }
    int z=0;
    for(auto moji:a){
        z=max(z,moji.second);
    }
    for(auto moji:a){
        if(z==moji.second) cout<<moji.first<<endl;
    }
}


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

#define rep(i, k) for (int i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int h, n, s = 0;
    cin >> h >> n;
    int a;
    rep(i, n) {
        cin >> a;
        s += a;
    }
    // 倒せないか判定
    if (h > s) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

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


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

#define MAX 10000
using namespace std;
#define inf    0x3f3f3f3f
#define ll long long
#define all(a) (a).begin(),(a).end()
#define INF (int)1e15
#define MOD 1000000007
#define access(i) a[i/3][i%3]

 int main(){

 ll n; cin>>n;

 for(int i=0;i<n;i++){
    cout<<"ACL";
 }


 cout<<endl;

  return 0;
 }


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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() { 

	string S;
	cin >> S;
	long a[3]={},isa=0;

	for(long i = 0; i < S.size(); i++) {
		if(S[i] == 'a') {
			a[0]++;
		}else if(S[i] == 'b') {
			a[1]++;
		}else {
			a[2]++;
		}
	}

	sort(a,a+3);
	reverse(a,a+3);
	isa += a[0] - a[1];
	isa += a[0] - a[2];
	if(isa > 2) {
		cout << "NO" << endl;
	}else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int main()
{
     
    int x;
    cin >> x ;
    cout << 1000LL * (x/500) + 5LL * ((x % 500 )/5 ) <<"\n";
}


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

int main(){
  int r, D;
  vector<int> x(11);
  
  cin >> r >> D >> x.at(0);
  
  for (int i = 0; i < 10; i++) {
    x.at(i + 1) = r * x.at(i) - D;
    cout << x.at(i + 1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    int n,m,k;
    int[][] c;
    int[] shop;
    int[] d;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        c = new int[n][n];
        for(int i=0; i<n; i++) Arrays.fill(c[i],-1);
        for(int i=0; i<m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            int l = sc.nextInt();
            c[a][b] = l;
            c[b][a] = l;
        }

        shop = new int[k];
        for(int i=0; i<k; i++) shop[i] = sc.nextInt()-1;

        d = new int[n];
        Arrays.fill(d,-1);
        dijkstra();

        int max = 0;
        for(int i=0; i<n; i++){
            if(d[i]==-1) continue;
            for(int j=i+1; j<n; j++){
                if(c[i][j]==-1 || d[j]==-1) continue;
                int d1 = d[i], d2 = d[j];
                int cc = c[i][j];

                if(d1<d2){
                    cc -= (d2-d1);
                    d1 = d2;
                }else{
                    cc -= (d1-d2);
                    d2 = d1;
                }

                if(cc>0){
                    if(cc%2==0) d1 += cc/2;
                    else d1 += cc/2+1;
                }
                max = Math.max(max,d1);
            }
        }

        System.out.println(max);
    }

    void dijkstra(){
        //pos, cost
        PriorityQueue<int[]> 
            q = new PriorityQueue<int[]>(n, new Comparator<int[]>(){
                    public int compare(int[] a, int [] b){
                        return a[1] - b[1];
                    }
                });
        for(int i=0; i<k ;i++) q.add(new int[]{shop[i],0});

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], cost = qq[1];

            if(d[pos]!=-1) continue;
            d[pos] = cost;

            for(int i=0; i<n; i++){
                if(c[pos][i]==-1) continue;
                q.add(new int[]{i,cost+c[pos][i]});
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 140272
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;


int main(){
	int N; cin >> N;
	int H,ans=1,ma=0;
	cin >> H;
	ma=H;
	for(int i=1; i<N; i++){
		cin >> H;
		if(ma<=H){
			ma=H;
			ans+=1;
		}
	}
	cout << ans << endl;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

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; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> e(8, vector<int>(8, 0));
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a][b] = 1;
    e[b][a] = 1;
  }

  vector<int> v;
  for (int i = 1; i < n; i++) {
    v.push_back(i);
  }

  ll ans = 0;
  do {
    int prev = 0;
    bool flag = true;
    for (int i = 0; i < n-1; i++) {
      if (e[prev][v[i]] == 0) {
        flag = false;
        break;
      }
      prev = v[i];
    }
    if (flag) ans++;
  } while (next_permutation(v.begin(), v.end()));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
a = list(set(A))
cc = Counter(A)
dup = set([x for x in a if cc[x] > 1])
c_l = [(cc[i]-1)*(cc[i])/2 for i in a]
al = sum(c_l)

for k in A:
    if k in dup:
        print(int(al-cc[k]+1))
    else :
        print(int(al))

Measured memory_bytes: 94796
#include <bits/stdc++.h>
using namespace std;
int c[10][10];
int maps[210][210];
int ans[210][210];
int h, w;

void floyd() {
    //memcpy(ans, maps, sizeof(maps));
    for(int k = 0; k < 10; ++k) {
        for(int i = 0; i < 10; ++i) {
            for(int j = 0; j < 10; ++j) {
                if(i == j || i == k || j == k) continue;
                if(c[i][k] + c[k][j] < c[i][j]) {
                    c[i][j] = c[i][k] + c[k][j];
                }
            }
        }
    }
}

int main(void) {
    while(cin >> h >> w) {
        for(int i = 0; i < 10; ++i) {
            for(int j = 0; j < 10; ++j) {
                cin >> c[i][j];
            }
        }
        floyd();
        int ans = 0;
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                cin >> maps[i][j];
                if(maps[i][j] == -1 || maps[i][j] == 1) continue;
                ans += c[maps[i][j]][1];
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
ll x[1010],y[1010],z[1010];
ll tx[1010],ty[1010],tz[1010];
ll sum[1010];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>z[i];
	}
	ll ans=0;
	for(ll i=-1;i<=1;i+=2){
		for(ll j=-1;j<=1;j+=2){
			for(ll k=-1;k<=1;k+=2){
				ll tans=0;
				for(ll q=0;q<n;q++){
					sum[q]=i*x[q]+j*y[q]+k*z[q];
				}
				sort(sum,sum+n,greater<ll>());
				for(ll q=0;q<m;q++)
					tans+=sum[q];
				ans=max(ans,tans);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n,a;
  cin >> n;
  int s=1000000;
  int l=-1000000;
  long long int g=0;
  for(int i=1; i<=n; i++){
    cin >> a;
    
    if(s>a)
      s=a;
    
    if(l<a)
      l=a;
    
    g+=a;
    
  }
  cout << s << ' ' <<  l << ' ' << g << endl;
    
    
  }


Measured memory_bytes: 3092
//by OIerC
//Forca Barcelona!
#include<cstdio>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e3 + 5;

int a[N][N], b[N][N], left[N][N], right[N][N], up[N][N];
char s[N];

int main()
{
	int n = read();
	int m = read();
	int ans = max(n, m);
	
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j)
			if (s[j] == '#') a[i][j] = 1;		
	}
	
	for (int i = 1; i < n; ++i)
		for (int j = 1; j < m; ++j)
			if ((a[i][j] + a[i][j + 1] 
			+ a[i + 1][j] + a[i + 1][j + 1]) % 2 == 0)
			{
				b[i][j] = 1;
				left[i][j] = j;
				right[i][j] = j;
				up[i][j] = 1;
			}
	--n;
	--m;
	
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 2; j <= m; ++j)
			if (b[i][j] == b[i][j - 1] && b[i][j])
				left[i][j] = left[i][j - 1];
		
		for (int j = m - 1; j >= 1; --j)
			if (b[i][j] == b[i][j + 1] && b[i][j])
				right[i][j] = right[i][j + 1];
	}
	
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (i > 1 && b[i][j] == b[i - 1][j] && b[i][j])
			{
				left[i][j] = max(left[i][j], left[i - 1][j]);
				right[i][j] = min(right[i][j], right[i - 1][j]);
				up[i][j] = up[i - 1][j] + 1;
			}
			
			int x = right[i][j] - left[i][j] + 1;
			int y = up[i][j];
			
			ans = max(ans, (x + 1) * (y + 1));
		}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = a+b+c;
    if(ans > 21){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    
}

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

int main(){

    int n, a, b, temp1;
    string str;

    cin >> n >> a >> b;
    cin >> str;
    temp1 = a+b;
    for(int i = 0 ;i < n; ++i){
        if(str[i] == 'c')cout << "No" <<endl;
        else if(str[i] == 'a'){
            if(temp1 > 0){
                temp1--;
                cout << "Yes" <<endl;
            }
            else cout << "No" <<endl;
        }
        else{
            if(temp1 > 0 && b > 0){
                temp1--;
                b--;
                cout << "Yes"<<endl;
            }
            else cout << "No" <<endl;
        }
    }


return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = nextInt(sc);
        int M = nextInt(sc);

        int LMax = 1;
        int RMin = N;

        for (int i = 0; i < M; i++) {
            int Li = nextInt(sc);
            int Ri = nextInt(sc);

            if (Li > LMax) LMax = Li;
            if (Ri < RMin) RMin = Ri;
         }

        int num = RMin - LMax + 1;

        show((num < 0) ? 0 : num);
    }
    private static int nextInt(Scanner sc) {
        return Integer.parseInt(sc.next());
    }
    private static void show(Object answer) {
        System.out.println(answer);
    }
}


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

using namespace std;

const int N = 200005;
int n, q;
vector<int> adjList[N];
bool vis[N];
int val[N];

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

    cin >> n >> q;
    for(int i = 1; i <= n - 1; i++){
        int a, b;
        cin >> a >> b;
        adjList[a].push_back(b);
        adjList[b].push_back(a);
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        val[a] += b;
    }

    vis[1] = 1;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int fr = q.front();
        q.pop();
        int siz = adjList[fr].size();
        for(int t = 0; t < siz; t++){
            int x = adjList[fr][t];
            if(!vis[x]){
                vis[x] = 1;
                val[x] += val[fr];
                q.push(x);
            }
        }
    }

    for(int i = 1; i <= n; i++){
        cout << val[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 15732
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
 int ans=0;
    for(int i=1;i<100;i++){
    if(i*1000<n){
    continue;
      }
      else{
      ans=i*1000-n;
      break;
      }
    }
cout<<ans;


return 0;
}


Measured memory_bytes: 3636
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String w = sc.next();
        int res = 0;
        while (sc.hasNext()) {
            String s = sc.next();
            if (s.equals("END_OF_TEXT")) break;
            if (isContain(s, w)) res++;
        }
        System.out.println(res);
    }
    
    static boolean isContain(String s, String w) {
        s = s.toUpperCase();
        w = w.toUpperCase();
        return s.equals(w);
    }
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

//ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// counting divsrs: vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++;

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

int calc_cost(vector<int> arr, int choice) {
    int ans = 0;
    for (int num : arr) {
        ans += (num - choice) * (num - choice);
    }
    return ans;
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
     int N;
    scanf("%d", &N);
    vector<int> arr(N);
    int total = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
        total += arr[i];
    }
    
    int avg = total / N;
  
    int ans = min({calc_cost(arr, avg-1), calc_cost(arr, avg), calc_cost(arr, avg+1)});
    
    printf("%d\n", ans);
	
	return 0;
}	





Measured memory_bytes: 3816
void main()
{
    string s = readln.chomp;

    s.count('1').writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int n, a[101], s, ss, c = INT_MAX;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) 
    {
        cin >> a[i];
        s += a[i];
        ss += a[i]*a[i];
    }
    for (int y = -100; y <= 100; y++)
        c = min(c, ss + n*y*y - 2*y*s);
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vl A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    sort(all(A),greater<ll>()), sort(all(B),greater<ll>());
    rep(i,N-1)
        if(A[i]==A[i+1]){
            cout << 0 << endl;
            return 0;
        }
    rep(i,M-1)
        if(B[i]==B[i+1]){
            cout << 0 << endl;
            return 0;
        }

    ll ai = 0, bi = 0, now = N * M;
    ll ans = 1, ncnt = 0, mcnt = 0;
    while(now){
        ll isa = false, isb = false;
        if (ai < N && now == A[ai]) isa = true, ai++;
        if (bi < M && now == B[bi]) isb = true, bi++;

        if(isa&&isb){
            ncnt++, mcnt++;
        }else if(isa){
            ans *= mcnt;
            ans %= MOD;
            ncnt++;
        }else if(isb){
            ans *= ncnt;
            ans %= MOD;
            mcnt++;
        }else{
            ans *= ncnt * mcnt - (N * M - now);
            ans %= MOD;
        }

        now--;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, a, b;
    cin >> n;
    cin >> a;
    cin >> b;

    int sum = 0;
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        int dsum = 0;
        while (tmp) {
            dsum += tmp % 10;
            tmp /= 10;
        }

        if (dsum >= a && dsum <= b) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
s = [[0 for i in range(n)]for j in range(m)]
for i in range(n+1):
    for j in range(m+1):
        if (i*m + j*n - 2*i*j) == k:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 17908
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		String S=sc.next();//65 //67 //71//84
		int ctn=0;
		int ans=0;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)==65||S.charAt(i)==67||S.charAt(i)==71||S.charAt(i)==84) {
				ctn++;
			}else {
				ctn=0;
			}
			ans=Math.max(ans, ctn);
		}
		p(ans);
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	a, b, c := readN(), readN(), readN()
	if a*c < b {
		fmt.Println(c)
		return
	}
	fmt.Println(b / a)
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

ll dp[3005][3005];

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

    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; ++i){
        dp[0][i] = 1;
    }

    for(int i = 0; i < n - 1; ++i){
        if(s[i] == '<'){
            for(int j = 0; j < n - i; ++j){
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % mod;
            }
            for(int j = 0; j < n - i - 1; ++j){
                dp[i+1][j] = dp[i][j];
            }
        }
        else{   // s[i] == '>'
            for(int j = n - i - 1; j >= 0; --j){
                dp[i][j] = (dp[i][j] + dp[i][j+1]) % mod;
            }
            for(int j = 0; j < n - i - 1; ++j){
                dp[i+1][j] = dp[i][j+1];
            }
        }
    }
    cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 70016
#include <stdio.h>
#include <stdlib.h>

int kaijo(int nb)
{
	int sum;

	sum = 1;
	while (nb > 0)
	{
		sum *= nb;
		nb--;
	}
	return (sum);
}

int dict_order(int *P, int N)
{
	int i;
	int j;
	int p;
	int index;

	index = 1;
	i = 0;
	while (i < N)
	{
		j = 0;
		p = 0;
		/* 0からi(現在地)まで、P[i]より小さい既出の値の個数(前の桁)をカウント */
		while (j < i)
		{
			if (P[j] < P[i])
				p++;
			j++;
		}
		/* (n! * (現在地の値 - 1))では前のケタと重複する数字も含む場合があるので 上述のpを使う */
		index += kaijo(N - (i + 1)) * (P[i] - 1 - p);
		i++;
	}
	return (index);
}

int main(void)
{
	int N;
	scanf("%d", &N);
	int P[N];
	int Q[N];
	int i;
	int ans1;
	int ans2;

	i = 0;
	while (i < N)
		scanf("%d", &P[i++]);
	i = 0;
	while (i < N)
		scanf("%d", &Q[i++]);
	ans1 = dict_order(P, N);
	ans2 = dict_order(Q, N);
	// printf("%d %d\n", ans1 , ans2);
	printf("%d\n", abs(ans1 - ans2));
	return (0);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	string s;
	cin >> s;
	string b = "ACGT";
	int ans = 0;
	int cnt = 0;
	int n = (int)s.size();
	for (int i = 0; i < n; ++i) {
		bool d = 0;
		for (int j = 0; j < 4; ++j) {
			if (s[i] == b[j]) {
				d = 1;
			}
		}
		if (d) {
			cnt++;
		}else{
			ans = max(ans,cnt);
			cnt = 0;
		}
	}
	cout << max(ans,cnt);
}



















Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b)printf("a < b\n");
	else if (a>b)printf("a > b\n");
	else printf("a == b\n");
	return 0;
}


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

int main()
{
  ll n;
  cin >> n;
  vector<ll> v(n);
  
  for(int i = 0; i < n; i++)
    cin >> v[i];
  
  int f = 0;
  for(auto i: v)
  {
    if(!( i % 2 == 0 && (i%3 == 0 || i%5 == 0)))
    {
      if(i % 2 == 0)
      {
        //cout << i << "\n";
        f = 1;
      }
    }
  }
  if(!f)
    cout << "APPROVED\n";
   else
     cout << "DENIED\n";
      
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main
{
    Integer N;
    ArrayList<Long> A = new ArrayList<>();
    ArrayList<Long> S = new ArrayList<>();
    Long mod = (long)1000000007;
    void run()
    {
        this.input();
        this.ruisekiwa();
        this.output();
    }

    void input()
    {
        Scanner in = new Scanner(System.in);
        this.N = in.nextInt();
        in.nextLine();
        for(Integer i = 0; i < this.N; i++)
        {
            this.A.add(in.nextLong());
        }

        in.close();
    }

    void ruisekiwa()
    {
        this.S.add((long)0);
        for(Integer i = 0; i < this.N; i++)
        {
            this.S.add(this.S.get(i) + this.A.get(i));
        }
    }

    void output()
    {
        Long ans = (long)0;
        for(Integer i = 0; i < N - 1; i++)
        {
            ans += A.get(i) * ((S.get(N) - S.get(i + 1)) % mod);
            ans %= mod;
        }
        System.out.println(ans);
    }


    public static void main(String[] args)
    {
        Main app = new Main();
        app.run();
    }
}


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



int main() {
  vector<int> A(9);
  rep(i,9){cin>>A.at(i);}
  int N;
  cin>>N;
  vector<int> B(N);
  rep(i,N){
      cin>>B.at(i);
      rep(j,9){
          if(A.at(j)==B.at(i)){A.at(j)=-1;}
      }
  }
  bool j=false;
  if(A.at(0)==-1 && A.at(1)==-1 && A.at(2)==-1){j=true;}
  if(A.at(3)==-1 && A.at(4)==-1 && A.at(5)==-1){j=true;}
  if(A.at(6)==-1 && A.at(7)==-1 && A.at(8)==-1){j=true;}
  if(A.at(0)==-1 && A.at(3)==-1 && A.at(6)==-1){j=true;}
  if(A.at(1)==-1 && A.at(4)==-1 && A.at(7)==-1){j=true;}
  if(A.at(2)==-1 && A.at(5)==-1 && A.at(8)==-1){j=true;}
  if(A.at(0)==-1 && A.at(4)==-1 && A.at(8)==-1){j=true;}
  if(A.at(2)==-1 && A.at(4)==-1 && A.at(6)==-1){j=true;}
  if(j){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  deque<char> s;
  string S;
  int Q;
  cin >> S >> Q;
  for(int j=0;j<S.length();++j) s.push_back(S[j]);
  int T[Q] = {};
  int F[Q] = {};
  int count=1;
  char C[Q];
  for(int i=0;i<Q;++i) {
    cin >> T[i];
    if(T[i]==1) ++count;
    if(T[i]==2) {
      cin >> F[i] >> C[i];
      if(F[i]==1&&count%2==1) {
        s.push_front(C[i]);
      }
      if(F[i]==1&&count%2==0) {
        s.push_back(C[i]);
      }
      if(F[i]==2&&count%2==1) {
        s.push_back(C[i]);
      }
      if(F[i]==2&&count%2==0) {
        s.push_front(C[i]);
      }
    }
  }
  if(count % 2 == 0) reverse(s.begin(), s.end());
  for(int l=0;l<s.size();++l) cout << s[l];
  return 0;
}


Measured memory_bytes: 2688
/*input
11 5 9

*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;

int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}

int32_t main() {
    IOS;
	string s,t;cin>>s>>t;
	int flag=0;
	if(s.size()+1!=t.size()){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			flag=1;
			break;
		}
	}
	if(flag==1){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}






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


int main(){

    int N, K, Q, p;
    cin >> N >> K >> Q;
    vector<int> L(N, K-Q);
    vector<int> P(N);
    for(int i = 0; i < Q; i++){
        cin >> p;
        P.at(p-1) += 1;
    }
    for(int i = 0; i < N; i++){
        P.at(i) += L.at(i);
        if(P.at(i) >= 1){
            cout << "Yes" << endl;
        } else{
            cout << "No" <<endl;
        }
    }
return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
using namespace std;
 
const int maxn=1e5+5;
 
int n,rk,L,T;
int pos[maxn];
 
int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}
 
int main() {
	n=read(),L=read(),T=read();
	for(int i=1;i<=n;i++) {
		int x=read(),w=read();
		if(w==2)pos[i]=x-T;
		else pos[i]=x+T;
		rk+=pos[i]/L;
		if(pos[i]%L<0)rk--;
		pos[i]=(pos[i]%L+L)%L;
	}
	sort(pos+1,pos+n+1);
	rk=(rk%n+n)%n;
	for(int i=rk+1;i<=n;i++)
		printf("%d\n",pos[i]);
	for(int i=1;i<=rk;i++)
		printf("%d\n",pos[i]);
	return 0;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  long long n,ans=0;
  std::cin >> n;
  std::vector<long long> a(n);
  rep(i,n){
    std::cin >> a[i];
  }
  long long tmp=0;
  rep(i,n){
      if(a[i]==0){
        ans+=tmp/2;
        tmp=0;
      }else{
        tmp+=a[i];
      }
  }
  ans+=tmp/2;
  // rep(i,n-1){
  //   if(a[i]%2==1&&a[i+1]%2==1){
  //     ans++;
  //     a[i]--;a[i+1]--;
  //   }
  // }
  // rep(i,n-1){
  //   if(a[i]%2==1&&a[i+1]>1){
  //     a[i]--;a[i+1]--;
  //     ans++;
  //   }
  // }
  // // rep(i,n-2){
  // //   if(a[i]%2==1&&a[i+2]%2==1&&a[i+1]>1){
  // //     a[i]--;a[i+1]-=2;a[i+2]--;
  // //     ans+=2;
  // //   }
  // // }
  // rep(i,n){
  //   if(a[i]>1) {
  //     ans+=a[i]/2;
  //     a[i]=a[i]%2;
  //   }
  // }
  std::cout << ans << std::endl;
}


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

int main() {
    int K, S;
    int X, Y, Z;
    int res = 0;
    cin >> K >> S;
    
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            Z = S - i - j;
            if (Z >= 0 && Z <= K) res++;
        }
    }
    cout << res << endl;
    return 0;
}


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


int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a >= k)
  {
    cout << k << endl;
    return 0;
  }
  k -= a;
  if (b >= k)
  {
    cout << a << endl;
    return 0;
  }
  k -= b;
  cout << a - k << endl;;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
               Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if((a * b) % 2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	
	int n, t;
	cin >> n >> t;
	int q = 0;
	int y = 9999999;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		t -= x;
		y = min(y, x);
		q++;
	}
	q += t / y;
	cout << q << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int  W=scan.nextInt();
		int  H=scan.nextInt();
		int  x=scan.nextInt();
		int  y=scan.nextInt();
		int  r=scan.nextInt();

        if(W <x+r || 0 >x-r) {
        	System.out.println("No"); 	
        }
        else if(H <y+r || 0 >y-r) {
        	System.out.println("No");
        }        
        else {
        	System.out.println("Yes");
        }
	}
}



Measured memory_bytes: 26380
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1))/2+(m*(m-1))/2;
    
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MAX 100005
#define NIL -1
struct Node{int p,l,r;};
Node T[MAX];
int n,D[MAX];

void print(int u){
	int i,c;
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].p<<", ";
	cout<<"depth = "<<D[u]<<", ";
	if(T[u].p==NIL)cout<<"root, ";
	else if(T[u].l==NIL)cout<<"leaf, ";
	else cout<<"internal node, ";

	cout<<"[";
	//2??????????????????????????¢????????¨?????????????????????????????????????????????
	for (i = 0, c=T[u].l; c!= NIL;i++,c=T[c].r) {
		if(i)cout<<", ";
		cout<<c;
	}
cout<<"]"<<endl;
}

int rec(int u,int p){
	D[u]=p;
	if(T[u].r !=NIL){rec(T[u].r,p);}
	if(T[u].l !=NIL){rec(T[u].l,p+1);}
}

int main(){
	int i,j,d,v,c,l,r;
	cin>>n;
	for ( i = 0; i < n; ++i) {T[i].p=T[i].l=T[i].r=NIL;}
	for ( i = 0; i < n; ++i) {
		cin>>v>>d;
		for ( j = 0; j < d; ++j) {
			cin>>c;
			if(j==0)T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	for ( i = 0; i < n; ++i) {
		if(T[i].p==NIL)r=i;
	}
	rec(r,0);
	for ( i = 0; i < n; ++i) {
		print(i);
	}
	return 0;
}

Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int N;
V<ll> a(4000,0);
V<V<ll>> dp(4000,V<ll>(4000,-1));

ll rec(int l,int r, int k){
    if(dp[l][r] != -1) return dp[l][r];
    if(l==r) return (!k?a[l]:0);
    if(k){
        if(a[l]<a[r]) chmax(dp[l][r],rec(l,r-1,!k));
        else chmax(dp[l][r],rec(l+1,r,!k));
    }
    else{
        chmax(dp[l][r],max(rec(l,r-1,!k)+a[r],rec(l+1,r,!k)+a[l]) );
    }
    return dp[l][r];
}

int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        a[N+i] = a[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; ++i) chmax( ans, rec(i,N-1+i,0) );
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 128252
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 10;
const int mod = 1e9 + 7;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n;
vector<int> a;
char u[maxn], d[maxn];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%d", &n);
    scanf("%s", u);
    scanf("%s", d);

    for(int i = 0; i < n; ) {
        if(u[i] == d[i]) {
            ++ i;
            a.pb(0);
        }else {
            i += 2;
            a.pb(1);
        }
    }

    LL res = 1;
    for(int i = 0; i < int(a.size()); ++i) {
        if(i == 0) {
            if(a[i]) res = res * 6 % mod;
            else res = res * 3 % mod;
        }else {
            if(a[i]) {
                if(a[i-1]) res = res * 3 % mod;
                else res = res * 2 % mod;
            }else {
                if(a[i-1]) {}
                else res = res * 2 % mod;
            }
        }
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N),ans(N);
    for(int i=0;i<N;i++) cin >> A.at(i);
    for(int i=0;i<N;i++){
        int num = A.at(i) - 1;
        ans.at(num) = i+1;
    }
    for(int i=0;i<N;i++){
        if(i==N-1) cout << ans.at(i) << endl;
        else cout << ans.at(i) << " ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}

	return 0;
}

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

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

     int cnt = 0;
     for (int i = 0; i < 4; i++) {
         cnt += N % 10 == 2 ? 1 : 0;
         N /= 10;
     }

     cout << cnt << endl;
}

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

ab = sorted(ab,key = lambda x:x[0])

drink_num=0
cost =0

for abi in ab:
  if drink_num + abi[1] >= m :
    cost += (m - drink_num)*abi[0]
    break
  else:
    drink_num += abi[1]    
    cost += abi[0]*abi[1]

print(cost)    

Measured memory_bytes: 29796
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int d,t,s;
    scanf("%d%d%d",&d,&t,&s);
    if(t*s>=d){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


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

kosuu = []
for i in range(N):
    if D % A[i] == 0:
        kosuu.append(D // A[i])
    else:
        kosuu.append(D // A[i] + 1)
    
print(sum(kosuu) + X)

Measured memory_bytes: 3060