akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h1,m1,s1,h2,m2,s2;
  rep(i,3){
    cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
    if(s2 - s1 < 0){
      s1 = 60 -(s1 - s2);
      --m2;
    }
    else{
      s1 = s2 - s1;
    }
    if(m2 - m1 < 0){
      m1 = 60 - (m1 - m2);
      --h2;
    }
    else{
      m1 = m2 - m1;
    }
    cout << h2 - h1 << " " << m1 << " " << s1 << endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
    long long N, A, B;
    cin >> N >> A >> B;

    long long syou = N / (A + B);
    long long amari = N % (A + B);

    if (amari >= A)
    {
        amari = A;
    }

    long long ans = syou * A + amari;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, M, X;
    cin >> N >> M >> X;
    vector<lint> C(N);
    vector<vector<lint>> A(N, vector<lint>(M));
    REP(i, N) {
        cin >> C[i];
        REP(j, M) {
            cin >> A[i][j];
        }
    }
    lint min = 1e9;
    REP(k, pow(2, N)) {
        vector<lint> AA(M);
        lint CC = 0;
        REP(i, N) {
            if(((k >> i) & 1) == 1) {
                CC += C[i];
                REP(j, M) {
                    AA[j] += A[i][j];
                }
            }
        }
        bool flg = true;
        REP(i, M) {
            if(AA[i] < X) {
                flg = false;
                break;
            }
        }
        if(flg && CC < min) min = CC;
    }
    if(min == 1e9) {
        cout << -1 << endl;
    } else {
        cout << min << endl;
    }
}

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

#define LL long long
#define int long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<LL, LL>
#define pdd pair<double, double>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define length(p1, p2) ((p1.fi-p2.fi)*(p1.fi-p2.fi)+(p1.se-p2.se)*(p1.se-p2.se))
#define ith(state, i) (state & (1 << i))
#define PI acos(-1.0)

using namespace std;

constexpr int N = 2e5+9;
constexpr int M = 1e4+9;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int n, m;
vector<int> g[N];
int dis[N], from[N];

void bfs(int s) {
    memset(dis, 0x3f, sizeof(dis));
    dis[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v: g[u]) {
            if (dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                from[v] = u;
                q.push(v);
            }
        }
    }
}

signed main() {
    fastio;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v), g[v].push_back(u);
    }
    bfs(1);
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) {
        cout << from[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 16936
#include <bits/stdc++.h>
using namespace std;
int N; string s, a, b, A, B;
void change(int i){
  int j=(N+i-1)%N, k=(i+1)%N;
  A[i]=(A[i]=='S')?'W':'S'; a[i]=(a[i]=='o')?'x':'o';
  a[j]=(a[j]=='o')?'x':'o'; a[k]=(a[k]=='o')?'x':'o';
  B[i]=(B[i]=='S')?'W':'S'; b[i]=(b[i]=='o')?'x':'o';
  b[j]=(b[j]=='o')?'x':'o'; b[k]=(b[k]=='o')?'x':'o';
}
void flipA(int c){ for(int i=c+2; i<c+N; i+=3){change(i%N);} }
void flipB(int c){ for(int i=c+1; i<c+N; i+=3){change(i%N);} }
int main(){
cin >> N >> s;
a=string(N,'o'); b=string(N,'x');
A=string(N,'S'); B=string(N,'W');
for(int i=0; i<N-2; i++){ if(a[i]!=s[i]){change(i+1);} }  
if(a[N-2]==s[N-2]&&a[N-1]==s[N-1]){ cout << A << "\n"; }
else if(N%3==0){ cout << -1 << "\n"; }
else if(N%3==1){
  if(a[N-2]==s[N-2]){ flipA(N-1); cout << B << "\n"; }
  else if(a[N-1]==s[N-1]){ flipA(N-2); cout << B << "\n"; }
  else{ flipA(N-2); flipA(N-1); cout << A << "\n"; }
}
else{
  if(a[N-2]==s[N-2]){ flipB(N-1); cout << B << "\n"; }
  else if(a[N-1]==s[N-1]){ flipB(N-2); cout << B << "\n"; }
  else{ flipB(N-2); flipB(N-1); cout << A << "\n"; }
}
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

typedef long long ll;

ll dp[105][100005];
ll mod = 1e9 + 7;

int main(int argc, char *argv[])
{
	int N, K, a[100005];

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= N; i++) {
		dp[i][0] = 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= K; j++) {
			if (j - a[i - 1] - 1 >= 0) {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1] + mod) % mod;
			} else {
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
		}
	}

	cout << dp[N][K] << endl;

	return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

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

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


int main() {

	int n;
	cin >> n;

	ull sum = 0;
	ull a, b;
	rep(i, 0, n) {

		cin >> a >> b;

		sum += b - a + 1;

	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
h, w = [int(el) for el in input().split(' ')]

S = []
for i in range(0, h):
	temp = [x == '#' for x in input()]
	temp.insert(0, False)
	temp.append(False)
	S.append(temp)


S.insert(0, [False]*(w+2))
S.append([False]*(w+2))


# evaluate
def sol():
	for i in range(1, h+1):
		for j in range(1, w+1):
			if S[i][j]:
				if S[i-1][j] or S[i+1][j] or S[i][j-1] or S[i][j+1]:
					pass
				else:
					return('No')
	else:
		return('Yes')

print(sol())


Measured memory_bytes: 3064
//
// Created by Masaya Hirose on 2020年6月月21日.
//

#include <iostream>
using namespace std;

int main(){
   int x, y;
   cin >> x >> y;

   for(int a=0; a<=x; a++){
       if((2*a+4*(x-a)==y)){
           cout << "Yes";
           return 0;
       }
   }
   cout << "No";

    return 0;
}

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

int main() {
    ll n,i; string s; cin>>n>>s;
    for(i=0;i<s.length()-1;i++)
    {
        if (s[i]==s[i+1]) {n--;}
    } cout<<n;
	return 0;
}

Measured memory_bytes: 3672
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split(" ");
    long a = Long.parseLong(input[0]);
    BigDecimal b = new BigDecimal(input[1]);
    BigDecimal answer = new BigDecimal(a).multiply(b);
    String wkAnswer = answer.toString();
    int idx = wkAnswer.indexOf('.');
    if(idx < 0){
      System.out.print(wkAnswer);
    } else {
      System.out.print(wkAnswer.substring(0, idx));
    }
  }
}

Measured memory_bytes: 36160
#include <bits/stdc++.h>
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
// const int MOD = 998244353;

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<long> va(a);
    vector<long> vb(b);
    for (size_t i = 0; i < a; i++) {
        cin >> va[i];
    }
    for (size_t i = 0; i < b; i++) {
        cin >> vb[i];
    }
    sort(va.rbegin(), va.rend());
    sort(vb.rbegin(), vb.rend());
    priority_queue<long> pq;
    for (size_t i = 0; i < x; i++)
    {
        pq.push(va[i]);
    }
    for (size_t i = 0; i < y; i++)
    {
        pq.push(vb[i]);
    }
    for (size_t i = 0; i < c; i++)
    {
        int t;
        cin >> t;
        pq.push(t);
    }
    
    long ans = 0;
    for (size_t i = 0; i < x + y; i++) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int sz=s.size();
  rep(i,sz){cout<<'x';}
  cout << endl;
  return 0;
}


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

constexpr int N = 2020;

char board[N][N];

int row[N][N];
int col[N][N];

int main() {
  int h,w;
  cin >> h >> w;

  memset(row,0,sizeof(row));
  memset(col,0,sizeof(col));

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> board[i][j];
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if(board[i][j] == '#') row[i][j] = 0;
      else row[i][j] = row[i][j - 1] + 1;
    }
  }

  for (int j = 1; j <= w; j++) {
    for (int i = 1; i <= h; i++) {
      if(board[i][j] == '#') col[i][j] = 0;
      else col[i][j] = col[i - 1][j] + 1;
    }
  }

  // backward

  for (int i = h; i >= 1; i--) {
    int maxv = 0;
    for (int j = w; j >= 1; j--) {
      if(board[i][j] == '#') maxv = 0;

      row[i][j] = max(maxv, row[i][j]);
      maxv = max(maxv, row[i][j]);
    }
  }

  for (int j = w; j >= 1; j--) {
    int maxv = 0;
    for (int i = h; i >= 1; i--) {
      if(board[i][j] == '#') maxv = 0;

      col[i][j] = max(maxv, col[i][j]);
      maxv = max(maxv, col[i][j]);
    }
  }

  // calc ans
  int ans = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      ans = max(ans, row[i][j] + col[i][j] - 1);
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 36096
#include <iostream>

int main(){
	using namespace std;
	long long a,b,k;
	cin >> a >> b >> k;
	if (a < k) {
		k -= a;
		a = 0;
		b -= k;
	}
	else {
		a -= k;
	}
	if (b < 0) {
		b = 0;
	}
	cout << a << " " <<b <<endl;
	return 0;
}

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

Measured memory_bytes: 9128
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
if all([a == b for a,b in ab]):
  print(0)
  exit()
ans = 0
diff = 10 ** 9
for a,b in ab:
  ans += b
  if a > b:
    diff = min(diff, b)
print(ans-diff)

Measured memory_bytes: 8052
#include<stdio.h>

int main(){
	int r_val=0, c_val=0, sum1[100], sum2[100],tmp=0;
	int table[101][101];
	for(int i=0; i<100; i++){
		for(int f=0; f<100; f++){
			table[i][f]=0;
			sum1[i]=0;
			sum2[i]=0;
		}
	}
	scanf(" %d %d",&r_val ,&c_val);
	for(int i=0; i<r_val; i++){
		for(int f=0; f<c_val; f++){
			scanf(" %d", &table[i][f]);
			sum1[i]+=table[i][f];
		}
	}
	for(int i=0; i<r_val; i++){
		for(int f=0; f<c_val; f++){
			printf("%d ",table[i][f]);
		}
		printf("%d\n",sum1[i]);
	}
	for(int i=0; i<c_val; i++){
		for(int f=0; f<r_val; f++){
			sum2[i]+=table[f][i];
			if(i==0) tmp+=sum1[f];
		}
		printf("%d ",sum2[i]);
	}
	printf("%d\n",tmp);
	return 0;
}



Measured memory_bytes: 2760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
 
int main(void){
    ll A,B,m;
    cin>>A>>B>>m;
    vector<ll>a(A),b(B);
    for(ll i=0;i<A;i++)cin>>a[i];
    for(ll i=0;i<B;i++)cin>>b[i];
    map<P,ll>div;
    ll ans = (ll)INF;
    for(ll i=0;i<m;i++){
        ll x,y,c;
        cin>>x>>y>>c;
        if(div[P(x,y)]!=0){
            if(div[P(x,y)]<c)div[P(x,y)]=c;
        }
        else div[P(x,y)]=c;
        ans = min(ans,a[x-1]+b[y-1]-c);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    cout<<min(ans,a[0]+b[0])<<endl;
    return 0;
}



Measured memory_bytes: 8064
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b = MAP()

ans = a*(a-1) // 2 + b*(b-1) // 2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1234;
int uf[maxn];
int find(int x){
	if(x == uf[x]) return x;
	return uf[x] = find(uf[x]);
}
vector<pair<int,int> > tr[maxn];
int dep[maxn], par[maxn], cost[maxn];
void dfs(int u){
	for(auto to : tr[u]){
		int v = to.first, w = to.second;
		if(v == par[u]) continue;
		par[v] = u;
		dep[v] = dep[u] + 1;
		cost[v] = w;
		dfs(v);
	}
}
int get_cost(int u, int v){
	int cs = 0;
	while(u != v){
		if(dep[u] < dep[v]) swap(u, v);
		cs = max(cs, cost[u]);
		u = par[u];
	}
	return cs;
}
int main(){
	iota(uf, uf + maxn, 0);
	int n, m; cin >> n >> m;
	long long x; cin >> x;
	vector<tuple<int, int, int> > e;
	for(int i = 0; i < m; i++){
		int u, v, w; cin >> u >> v >> w;
		e.push_back(make_tuple(w, u, v));
	}
	sort(e.begin(), e.end());
	long long mst = 0;
	for(int i = 0; i < m; i++){
		int u, v, w; tie(w, u, v) = e[i];
		if(find(u) != find(v)){
			tr[u].push_back({v, w});
			tr[v].push_back({u, w});
			uf[find(u)] = find(v);
			mst += w;
		}
	}
	if(x < mst) {
		cout << 0 << endl;
		return 0;
	}
	dfs(1);
	int smaller = 0, equal = 0, upper = 0;
	for(int i = 0; i < m; i++){
		int u, v, w; tie(w, u, v) = e[i];
		long long nst = mst - get_cost(u, v) + w;
		if(nst < x) smaller++;
		else if(nst == x) equal++;
		else upper++;
	}
	const int mod = 1'000'000'007;
	int val = 1;
	for(int i = 0; i < equal; i++){
		val = val + val;
		if(val >= mod) val -= mod;
	}
	if(x != mst){
		val += mod - 1;
		if(val >= mod) val -= mod;
	} else {
		val += mod - 2;
		if(val >= mod) val -= mod;
	}
	for(int i = 0; i < upper; i++){
		val = val + val;
		if(val >= mod) val -= mod;
	}
	if(x != mst){
		val = val + val;
		if(val >= mod) val -= mod;
	}
	cout << val << endl;
	return 0;
}


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


int main(){
    init();

    int w,h,n;  cin >> w >> h >> n;
    int arr[4] = {0,w,0,h};
    for(int i = 0;i < n;i++){
        int x,y,a;  cin >> x >> y >> a;
        if(a == 1)
            arr[0] = max(arr[0], x);
        else if(a == 2)
            arr[1] = min(arr[1], x);
        else if(a == 3)
            arr[2] = max(arr[2], y);
        else
            arr[3] = min(arr[3], y);
    }

    if(arr[0] > arr[1] || arr[2] > arr[3])
        return cout << 0, 0;

    cout << abs(arr[0] - arr[1]) * abs(arr[2] - arr[3]);
}

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

using namespace std;


int main()
{
  double x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2	>> y2;
  printf("%lf\n", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));
  return 0;
}

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

void solve() 
{
    ll n;cin>>n;
    ll mn=(ll)1e16;REP(i,5){ll x;cin>>x;mn=min(mn,x);}
    cout<<5+(n-1)/mn<<endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX = 303030;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n) {
	ll res = 1;
	a %= MOD;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int X[200];

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

	int N;
	cin >> N;
	for (int i = 0; i < N; i++)cin >> X[i];
	int ans = 1e8;
	for (int i = -200; i <= 200; i++) {
		int temp = 0;
		for (int j = 0; j < N; j++)temp += (X[j]-i)*(X[j]-i);
		ans = min(temp, ans);
	}
	puts(ans);

	


	return 0;
}

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


int main() {

	int D;
	unsigned long long int G;
	cin >> D >> G;
	vector<int> p(D);
	vector<unsigned long long int> c(D);
	for (int i = 0; i < D; i++) {
		cin >> p.at(i) >> c.at(i);
	}

	unsigned long long int num,tmp,ans=G;
	bool flag;

	for (int bit = 0; bit < (1 << D); bit++) {
		tmp = 0;
		num = 0;
		flag = true;

		for (int i = 0; i < D; i++) {

			if (bit & (1 << i)) {
				tmp += 100 * (i + 1)*p.at(i) + c.at(i);
				num += p.at(i);
			}

		}

		for (int i = D-1; i >= 0; i--) {
			if (tmp >= G)break;
			if (bit & (1 << i)) {
				continue;
			}
			if (G - tmp > (p.at(i) - 1) * 100 * (i + 1)) {
				flag = false;
				break;
			}

			int t_num = (G - tmp) / (100 * (i + 1)) + ((G - tmp) % (100 * (i + 1)) != 0);
			num += t_num;
			tmp += 100 * (i + 1)*t_num;

			/*if ((G - tmp) % (100 * (i + 1)) == 0) {
				num += (G - tmp) / (100 * (i + 1));
				tmp = G;
			}
			else {
				num += (G - tmp) / (100 * (i + 1)) + 1;
				tmp += 100 * (i + 1)*((G - tmp) / (100 * (i + 1)) + 1);
			}*/

		}

	//	cout << "bit = " << bit << ", num = " << num << ", tmp = " << tmp << ", flag = "<< flag<< endl;
		if (flag && ans > num)ans = num;

	}
	
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;

const int MOD = 1000000007;
const int INF = 1000000000;

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


int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << ((m1!=m2) ? 1 : 0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#Satoooh 
H, W = map(int, input().split())
S = [input() for _ in range(H)]
# そのマスを含めてLeft, Right, Up, Downに
#それぞれ何マス分明かりを照らせるかを配列に記録
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):#全マスを走査
		if S[i][j] == ".":
			if j == 0:#一番左側のマスについて
				L[i][j] = 1
			else:#それ以外
				L[i][j] = L[i][j - 1] + 1
                #累積和のように、１個左側の値にプラス１

for i in range(H):
	for j in range(W - 1, -1, -1):#右側からの連続をチェック
		if S[i][j] == ".":
			if j == W - 1:#一番右側のマスについて
				R[i][j] = 1
			else:
				R[i][j] = R[i][j + 1] + 1

for j in range(W):
	for i in range(H - 1, -1, -1):#下からの連続
		if S[i][j] == ".":
			if i == H - 1:#一番下のマスについて
				D[i][j] = 1
			else:
				D[i][j] = D[i + 1][j] + 1

for j in range(W):
	for i in range(H):
		if S[i][j] == ".":
			if i == 0:#一番上のマスについて
				U[i][j] = 1
			else:
				U[i][j] = U[i - 1][j] + 1


ans = 0
X = [[0] * W for _ in range(H)]#全マスを０で初期化
for i in range(H):
	for j in range(W):
		X[i][j] = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
        #自分自身のマスは上記４回足している
	ans = max(ans, max(X[i]))
    #最大値で更新。配列Xは元々２次元だが、
    #ここでは横１次元をまとめて見ている

print(ans)#最も多くのマスを照らせる場合のマスの個数

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		if(n==0) {
			System.out.println(x);

		}else {
			Arrays.sort(a);

			int j=0;
			int p=100;
			int q=100;
			for(j=0;a[j]<x;j++) {

			}
			int c=0;
			int i=0;
			boolean f=true;
			for(i=0;i<=x+100;i++) {
				if(x-i!=a[Math.max(0, j-c)]) {

					break;
				}else if(x+i!=a[Math.min(n-1, j+c)]) {
					f=false;
				    break;
				}else {

					    c++;
				}
			}

			if(f) {
				System.out.println(x-i);
			}else {
				System.out.println(x+i);
			}
		}





	}

}


Measured memory_bytes: 35936
N = int(input())
if N <= 105:
    if N == 105:
        print(1)
    else:
        print(0)
    exit()
ret = 1
for i in range(107, N+1, 2):
    div = 0
    for j in range(1, i+1, 2):
        if i%j==0:
            div += 1
    if div == 8:
        ret += 1
print(ret)


Measured memory_bytes: 9124
// ABC 149-D
// 2019.12.29 bal4u

#include <stdio.h>
#include <ctype.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
//	do c = gc();
//	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

int N;
char T[100005];
char a[100005];
int p[128];

int main()
{
	int i, R, S, P, K, ans;
	
	N = in(), K = in(), R = in(), S = in(), P = in();
	p['r'] = P, p['s'] = R, p['p'] = S;
	ins(T), ans = 0;
	for (i = 0; i < K; ++i) ans += p[T[i]], a[i] = T[i];
	for ( ; i < N; ++i) {
		if (a[i-K] != T[i]) ans += p[T[i]], a[i] = T[i];
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
/*
    Author: aksayushx
*/
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;

/*
void compute()
{
	fac[0]=1;
	for(ll i=1;i<=10000;i++)
	fac[i]=(i*fac[i-1])%mod;
}
ll power(ll x, ll y)  
{  
    ll res = 1; 
    x = x % mod;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % mod;  
        y = y>>1; 
        x = (x*x) % mod;  
    }  
    return res;  
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
}
ll nCr(ll n,ll r) 
{ 
    if (r == 0) 
        return 1; 
    return (fac[n] * modInverse(fac[r]) % mod * modInverse(fac[n - r]) % mod) % mod; 
}*/ 

int n,k;
vector<int> a;
vector<int> dp;
int optimal(int stones)
{
    if(dp[stones]!=-1)
    return dp[stones];
    int i=0;
    while(a[i]<=stones && i<n)
    {
        int moves=1+optimal(stones-a[i]);
        if(moves%2==1)
        {
            dp[stones]=moves;
            return dp[stones];
        }
        i++;
    }
    dp[stones]=0;
    return dp[stones];
}
void aksayushx()
{
    cin>>n>>k;
    a.resize(n);
    dp.resize(k+1,-1);
    for(int i=0;i<n;i++)
    cin>>a[i];
    int win=optimal(k);
    if(win%2==1)
    cout<<"First";
    else
    cout<<"Second";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
        aksayushx();
    return 0;
}


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


const int MAX = 2000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll k;
string s;

ll modpow( ll a, ll b ){
	if ( b == 0 ) return 1;
	if ( b == 1 ) return a;
	
	ll tmp = modpow( a, b/2 );
	tmp = tmp*tmp%MOD;
	if ( b % 2 == 1 ) return ((tmp%MOD)*a)%MOD;
	return tmp;
}


ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}


int main(){
	cin >> k;
	cin >> s;
	ll len = s.size();
	COMinit();

	// 全てのパターンの文字列を、「条件に一致するか？」を判定するフィルタに通して、いくつ最終地点に到達するか
	/*
	  入力が26^nパターンの文字列
	  フィルタのr文字目に到達 するパターンの数は
	  f(n,r) = nCr * (26-1)^(n-r)
	  
	  len <= r <= n となる全てのrについて f(n,r) を足したものが答え
	  
	  n = len+k
	*/
	
	
	ll sum = 0;
	ll n = len+k;
	ll n25 = modpow(25,n-len);
	for ( int r = len; r <= n; r++ ){
		//cout << n << " " << r << " " << COM(n,r) << " " << n25 << endl;
		sum = (sum + (COM(n,r) * n25)%MOD)%MOD;
		n25 = (n25 * inv[25])%MOD;
	}
	
	cout << sum%MOD << endl;
	
	return 0;
}




Measured memory_bytes: 51192
process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    let n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .filter(x => x !== "");


    [target, ...str] = n;
    const a = str.map(x => x.split(" "));
    const b = Array.prototype.concat.apply([], a);
    let c = 0;
    let low = [];
    const lowcase = target.toLowerCase();
    b.forEach(x =>{
        low.push(x.toLowerCase());
    })
    for (let i = 0; i < b.length; i++) {
        if (lowcase == low[i]) {
            c += 1;
        }
    }
    console.log(c);


});


Measured memory_bytes: 15740
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	vs st;
	st.pb("a");
	st.pb("b");
	st.pb("c");
	st.pb("d");
	st.pb("e");
	st.pb("f");
	st.pb("g");
	st.pb("h");
	st.pb("i");
	st.pb("j");
	st.pb("k");
	st.pb("l");
	st.pb("m");
	st.pb("n");
	st.pb("o");
	st.pb("p");
	st.pb("q");
	st.pb("r");
	st.pb("s");
	st.pb("t");
	st.pb("u");
	st.pb("v");
	st.pb("w");
	st.pb("x");
	st.pb("y");
	st.pb("z");
	st.pb("ld");
	st.pb("mb");
	st.pb("mp");
	st.pb("nc");
	st.pb("nd");
	st.pb("ng");
	st.pb("nt");
	st.pb("nw");
	st.pb("ps");
	st.pb("qu");
	st.pb("cw");
	st.pb("ts");
	int n;
	cin>>n;
	string in;
	getline(cin,in);
	vs fil;
	while(getline(cin,in)){
		rep(i,in.size()){
			if(in[i]==' ')fil.pb("");
			else if(i+1==in.size()||in[i+1]==' '){
				fil.pb(in.substr(i,1));
			}else{
				string s=in.substr(i,2);
				bool h=false;
				rep(j,st.size())if(st[j]==s){
					h=true;
					i++;
					fil.pb(s);
				}
				if(!h){
					fil.pb(in.substr(i,1));
				}
			}
		}
		fil.pb("");
	}
	map<string,map<string,int> >ma;
	rep(i,fil.size()-1)if(fil[i]!=""&&fil[i+1]!="")ma[fil[i]][fil[i+1]]++;
	rep(i,st.size()){
		int m=0;
		string out;
		for(map<string,int>::iterator it=ma[st[i]].begin();it!=ma[st[i]].end();it++){
			if(m<it->second){
				m=it->second;
				out=it->first;
			}
		}
		if(!m)out="a";
		cout<<st[i]<<" "<<out<<" "<<m<<endl;
	}
}

Measured memory_bytes: 4676
#include<stdio.h>
int main()
{
  int A,B;
  scanf("%d %d",&A,&B);
  if((A-B)>(A+B))
  {
    	if((A-B)>(A*B))
          printf("%d",A-B);
    	else
          printf("%d",A*B);
  }
  else
  {
    	if((A+B)>(A*B))
          printf("%d",A+B);
    	else
          printf("%d",A*B);
  }
  return 0;
}


Measured memory_bytes: 128
object Main extends App {
  val a = io.StdIn.readInt // don
  val b = io.StdIn.readInt // curry
  val c = io.StdIn.readInt // pasta
  val d = io.StdIn.readInt // ramen
  val e = io.StdIn.readInt // hamba-gu

  // 数を10の倍数になるまで繰り上げる
  def multiple(n: Int): Int = n match {
    case int if int%10 == 0 => int
    case int => multiple(n+1)
  }

  val array = Array(a,b,c,d,e)
  val multiples = array.map(multiple(_))
  val diffs = (array zip multiples).map(t => t._2 - t._1)
  val diff_max = diffs.max
  val last_dish = array.filter(dish => multiple(dish) - dish == diff_max).head
  val result = multiples.sum - multiple(last_dish) + last_dish
  println(result)
}

Measured memory_bytes: 54908
// コンパイル方法 cl /EHsc bubbleSort.cpp

#include <iostream>
using namespace std;

int bubbleSort(int A[],int N) {
	int sw = 0; // 交換回数 0で初期化
	bool flag = 1;
	for(int i=0; flag; i++) {
		flag = 0;
		for(int j=N-1;j>=i+1;j--) {
			if(A[j]<A[j-1]) {
				swap(A[j],A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for(int i=0;i<N; i++) cin >> A[i];
	
	sw = bubbleSort(A,N);
	
	for(int i=0;i<N;i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

Measured memory_bytes: 3032
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

/*
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/


int main(void) {
  string S;
  cin >> S;
  int b=0,n=0,ans=0;
  for (int i = 0; i < S.size(); i++) {
    if(S[i]=='W'){
      n = 1;
    }else{
      n = -1;
    }

    if(b*n < 0){
      ans++;
    }
    b = n;
  }

  printf("%d\n",ans);

}


Measured memory_bytes: 512
n = input()

"""
from itertools import *

ans = 0

for a in product(range(1,n+1), repeat=n):
    a = a + (a[-1],)*n
    ok = True
    for i in range(n):
        if len(set(a[i+1:i+a[i]+1]))!=1:
            ok = False
    if ok:
        print a
        ans += 1
print ans
"""

M = 10**9+7
T = [0]*n
X = n-1
for i in range(n)[::-1]:
    if i==n-1:
        T[i] = n
    elif i==n-2:
        T[i] = n*n
    else:
        #for a in range(2,n+1):
        #    t = i+1+a
        #    T[i] += T[t] if t<n else 1
        X -= 1
        X += T[i+3] if i+3<n else 1
        X %= M
        T[i] += T[i+1] + (n-1)*(n-1) + X
    T[i] %= M
print T[0]


Measured memory_bytes: 66176
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  set<int> S[26];
  /*
  rep(i, 26){
    rep(j, n){
      if(s[j]-'a'==i){
        S[i].insert(j);
      }
    }
  }*/
  rep(i, n){
    S[s[i]-'a'].insert(i);
  }
  int q;
  cin >> q;
  rep(i, q){
    int t;
    cin >> t;
    if(t==1){
      int iq;
      char cq;
      cin >> iq >> cq;
      iq--;
      S[s[iq]-'a'].erase(iq);
      s[iq]=cq;
      S[cq-'a'].insert(iq);
    } else {
      int lq, rq;
      cin >> lq >> rq;
      int ans=0;
      lq--; rq--;
      rep(j, 26){
        //auto it=lower_bound(S[j].begin(), S[j].end(), lq);
        auto it=S[j].lower_bound(lq);
        if(it != S[j].end() && *it<=rq){
          ans++;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}


Measured memory_bytes: 27232
#include <iostream>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A*B>C*D) { cout << A*B << endl;
	}
	if (C*D>A*B) { cout << C*D << endl;
	}
	if (A*B==C*D) { cout << A*B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100001;
bool isBipartite = true;
bool visit[N];
vector<vector<int> > edge;
int color[N];map<int, int> dist;
queue<int> q; void bfs(int s){q.push(s);                                  
 dist[s] = 0;   
 color[s]=0;      
while (!q.empty()) {
    int u = q.front(); q.pop();                        // queue: layer by layer!
    for (int j = 0; j < (int)edge[u].size(); j++) {
      int v = edge[u][j];                           // for each neighbors of u
      if (!dist.count(v)) {    // dist.find(v.first) == dist.end() also ok
        dist[v] = dist[u] + 1;
		color[v]=1-color[u]  ;                // v unvisited + reachable
        q.push(v);                              // enqueue v for next step
      }
      else if ((dist[v] % 2) == (dist[u] % 2))              // same parity
        isBipartite = false;
  } }
}
signed main(){
	int n,m;
	cin>>n>>m;
	edge.assign(n+1,vector<int>());
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	bfs(1);
	if(isBipartite==0){
		cout<<n*(n-1)/2-m;
	}
	else{
		int cnt1=0,cnt2=0;
		for(int i=1;i<=n;i++){
			if(color[i]){
				cnt1++;
			}
			else{
				cnt2++;
			}
		}
		cout<<cnt1*cnt2-m;
	}
}

Measured memory_bytes: 13312
N = int(input())
arr = list(map(int, input().split()))
 
count =0
while True:
    if sum(arr) == 0:
        break
    count +=1
    start = False
 
    for i in range(N):
        if arr[i] != 0:
            arr[i] -= 1
            start = True
            continue
        if arr[i] == 0 and start == True:
            break
print(count)

Measured memory_bytes: 76676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef vector<D> vd;
typedef vector<vd> mat;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
struct C{P p;D r;};
D eps=1e-9;
bool eq(D a, D b) { return abs(a-b)<eps;}
inline int large(D a,D b){return eq(a,b)?0:(a>b?1:-1);}
D dot(P a,P b){return real(conj(a)*b);}
inline P perp(L l, P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
inline D dLP(L l, P p) { return abs(perp(l,p)-p);}
inline Pol intCL(C c,L l){
	int x=large(dLP(l,c.p),c.r);
	Pol ret;
	if(x==1) return ret;
	if(x==0){
		ret.pb(perp(l,c.p));
		return ret;
	}
	D d=dLP(l,c.p);
	if(d<eps){
		ret.pb(c.p+(l.fs-l.sc)/abs(l.fs-l.sc)*c.r);
		ret.pb(c.p-(l.fs-l.sc)/abs(l.fs-l.sc)*c.r);
		return ret;
	}
	D theta=acos(d/c.r);
	P p=perp(l,c.p);
	ret.pb(c.p+(p-c.p)/d*polar(c.r,theta));
	ret.pb(c.p+(p-c.p)/d*polar(c.r,-theta));
	return ret;
}
vd pro(mat m,vd v){
	vd a(3,0);
	rep(i,3) rep(j,3) a[i]+=m[i][j]*v[j];
	return a;
}
int main(){
	D x,y,z,a,b,c,d,e,f,p,q,r,A,B,C_,D_,E,F;
	cin>>x>>y>>z>>a>>b>>c>>d>>e>>f;
	cin>>p>>q>>r>>A>>B>>C_>>D_>>E>>F;
	p-=x,q-=y,r-=z,x=0,y=0,z=0;
	D g=b*f-c*e,h=c*d-a*f,i=a*e-b*d;
	mat M={
		{e*i-f*h,g*f-d*i,d*h-g*e},
		{h*c-b*i,a*i-g*c,g*b-a*h},
		{b*f-e*c,d*c-a*f,a*e-b*d}
	};
	vd v=pro(M,vd{A,B,C_}),u=pro(M,vd{D_,E,F}),o=pro(M,vd{p,q,r});
	if(eq(u[2],0)) swap(v,u);
	if(eq(u[2],0)){
		puts("NO");
		return 0;
	}
	P p1=P(0,-o[2]/u[2]),p2=P(1,-(o[2]+v[2])/u[2]);
	L l=L(p1,p2);
	Pol pol=intCL(C{P(0,0),1},l);
	if(pol.size()<=1){
		puts("NO");
		return 0;
	}
	int cnt=0;
	for(P p:pol){
		D s=p.real(),t=p.imag();
		D xx=o[0]+s*v[0]+t*u[0],yy=o[1]+s*v[1]+t*u[1];
		if(xx*xx+yy*yy<1) cnt++;
	}
	if(cnt==1) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 1256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

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

int main()
{
    int n; cin >> n;
    vector<int> xi(n), yi(n);
    rep(i, n){
        cin >> xi[i] >> yi[i];
    }

    long double sum = 0;
    int cases = 0;
    vector<int> order(n);
    rep(i, n) order[i] = i;
    do{
        cases++;
        rep(i, n-1){
            sum += sqrtl(pow(xi[order[i+1]]-xi[order[i]], 2) + pow(yi[order[i+1]]-yi[order[i]], 2));
        }
    }while(next_permutation(order.begin(), order.end()));
    
    sum /= cases;
    cout << fixed << setprecision(10) << sum << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int sz = 2e5+5;
ll int arr[sz]={0},arr1[sz]={0};
//ll int arr[100][100]= {0};
int prime[10005]= {0};
//vector <ll int> vec,vec1,vec2;
set <pair <int,int>> st;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);


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

    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

const int maxn = 110;
int n;
string c[maxn];
typedef pair<string, int> P;

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

void stable_bubble(P arr[maxn], int n) {
	int cnt = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (arr[j].first[1] < arr[j - 1].first[1]) {
				swap(arr[j], arr[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
}

void stable_selection(P arr[maxn], int n) {
	int cnt = 0;
	REP(i,0,n-1)
	{
		int minj = i;
		REP(j,i,n-1)
		{
			if (arr[j].first[1] < arr[minj].first[1]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(arr[i], arr[minj]);
			cnt++;
		}
	}
}

void selectionSort(int arr[maxn], int n) {
	int cnt = 0;
	REP(i,0,n-1)
	{
		int minj = i;
		REP(j,i,n-1)
		{
			if (arr[j] < arr[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(arr[i], arr[minj]);
			cnt++;
		}
	}
	print(arr, n);
	cout << cnt << endl;
}

void bubbleSort(int arr[maxn], int n) {
	int cnt = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
	print(arr, n);
	cout << cnt << endl;
}

void insertionSort(int arr[maxn], int n) {
	print(arr, n);
	REP(i,1,n-1)
	{
		int v = arr[i];
		int j = i - 1;
		while (j >= 0 && arr[j] > v) {
			arr[j + 1] = arr[j];
			j--;
		}
		arr[j + 1] = v;
		print(arr, n);
	}
}
P c_bubble[maxn], c_selection[maxn];
void solve() {
	cin >> n;
	rep(i,0,n)
	{
		cin >> c[i];
	}
	rep(i,0,n)
	{
		c_bubble[i] = P(c[i], i);
		c_selection[i] = P(c[i], i);
	}
//	cout << "---bubble---" << endl;
	stable_bubble(c_bubble, n);
//	rep(i,0,n)
//	{
//		cout << c_bubble[i].first << " " << c_bubble[i].second << endl;
//	}
//	cout << "---selection---" << endl;
	stable_selection(c_selection, n);
//	rep(i,0,n)
//	{
//		cout << c_selection[i].first << " " << c_selection[i].second << endl;
//	}
	//bubble
	rep(i,0,n-1)
	{
		cout << c_bubble[i].first << " ";
	}
	cout << c_bubble[n - 1].first << endl;
	cout << "Stable" << endl;
	//selection
	rep(i,0,n-1)
	{
		cout << c_selection[i].first << " ";
	}
	cout << c_selection[n - 1].first << endl;
	rep(i,0,n)
	{
		if (c_selection[i].second != c_bubble[i].second) {
			cout << "Not stable" << endl;
			return;
		}
	}
	cout << "Stable" << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 3180
// B - String Palindrome
#include <bits/stdc++.h>
using namespace std;

string S;

bool ok(int l, int r){//[l,r)
	string s = S.substr(l,r);
	string t(s.rbegin(), s.rend());
	return s==t;
}

int main(){
	cin>>S;
	int n = S.size();
	if(ok(0,n) && ok(0, (n-1)/2) && ok((n+1)/2,n)) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if(a+b==c||a+c==b||b+c==a){
  cout << "Yes" << endl;
 }else{
  cout << "No" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin >> n;
	if(n==1)
		cout << 0 << endl;
	else
		cout << (1ll+n-1)*(n-1ll)/2ll << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

const double eps=1e-10;
double add(double a,double b){
    if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
    return a+b;
}

typedef pair<double,double> P;
P operator+(const P& x,const P& y){
    return {add(x.first,y.first),add(x.second,y.second)};
}

P operator-(const P& x,const P& y){
    return {add(x.first,-y.first),add(x.second,-y.second)};

}

P operator*(const P& x,const double& y){
    return {x.first*y,x.second*y};
}
double dot(P x,P y){
    return add(x.first*y.first,x.second*y.second);


}

double det(P x,P y){
    return add(x.first*y.second,-x.second*y.first);
}

bool onseg(P p1,P p2,P q){
    return det(p1-q,p2-q)==0 &&dot(p1-q,p2-q)<=0; 
}

P intersection(P p1,P p2,P q1,P q2){
    return p1+(p2-p1)*(det(q2-q1,q1-p1)/det(q2-q1,p2-p1));
}

bool cross(P p1,P p2,P q1,P q2){
    if(det(p1-p2,q1-q2)==0)return onseg(p1,p2,q1)||onseg(p1,p2,q2)||onseg(q1,q2,p1)||onseg(q1,q2,p2);
    P ret=intersection(p1,p2,q1,q2);
    return onseg(p1,p2,ret)&&onseg(q1,q2,ret);
}

double dist(P p1,P p2,P q){
    if(dot(q-p1,p2-p1)<=0)return sqrt(dot(q-p1,q-p1));
    if(dot(q-p2,p1-p2)<=0)return sqrt(dot(q-p2,q-p2));
    P d=p1-p2;
    P ret=q+P{d.second,-d.first};
    P h=intersection(p1, p2, q, ret);
    return sqrt(dot(q-h,q-h));
}

const double pi=acos(-1);
int main(){
    int n,s,t;
    vector<double> ans;
    while(cin>>n>>s>>t){
        if(n==0)break;
        P x[n][5];
        rep(i,n){
            P c;
            cin>>c.first>>c.second;
            double a,b;
            cin>>a>>b;
            a*=pi/180;
            rep(j,5){
                P y;
                y={-sin(a+2.0/5.0*j*pi),cos(a+2.0/5.0*j*pi)};
                x[i][j]=c+y*b;
            }
        }
        double d[n][n];
        rep(i,n)rep(j,n)d[i][j]=inf;
        rep(i,n)d[i][i]=0;
        rep(i,n)rep(j,n){
            if(i==j)continue;
            rep(k,5)rep(l,5){
                d[i][j]=min(d[i][j],dist(x[i][k],x[i][(k+2)%5],x[j][l]));
                if(cross(x[i][k],x[i][(k+2)%5],x[j][l],x[j][(l+2)%5]))d[i][j]=0;
            }
        }
        rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[j][i]);
        rep(i,n)rep(j,n)rep(k,n)d[j][k]=min(d[j][k],d[i][j]+d[i][k]);
        cout<<fixed<<setprecision(12)<<d[s-1][t-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3668