akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  map<int,int> mp;
  rep(i,N){
    mp[A[i]-1]++; mp[A[i]]++; mp[A[i]+1]++;
  }
  int ans = 0;
  for (auto itr : mp){
//    cout << itr.first << "-" << itr.second << endl;
      ans = max(ans, itr.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a<=b+w&&b<=a+w)
        cout<<0<<endl;
    else if(a+w<b)
        cout<<b-(a+w)<<endl;
    else if(a>b+w)
        cout<<a-b-w<<endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)


template<typename T>
struct LinearSystemIncidence {
  struct Edge {
    int id, to;
    bool fwd;
    Edge(int i, int t, bool f) : id(i), to(t), fwd(f) {}
  };

  int n, m;
  vector<T> x;
  vector<bool> seen;
  vector<vector<Edge>> G;
  
  LinearSystemIncidence(int n, vector<P> &E) : n(n), m(E.size()), G(n) {
    rep(i, m) {
      G[E[i].first].emplace_back(i, E[i].second, true);
      G[E[i].second].emplace_back(i, E[i].first, false);
    }
  }

  T dfs(vector<T> &b, int u) {
    seen[u] = true;
    T res = b[u];
    for (Edge e : G[u]) {
      if (seen[e.to]) continue;
      T tmp = dfs(b, e.to);
      x[e.id] = tmp * (e.fwd ? 1 : -1);
      res += tmp;

      // mod2
      x[e.id] %= 2;
      if (x[e.id] < 0) x[e.id] += 2;
      ////
    }
    res %= 2; // mod 2
    return res;
  }

  pair<bool, vector<T>> solve(vector<T> &b) {
    x.assign(m, 0);
    seen.assign(n, false);
    for (int s = 0; s < n; ++s) {
      if (seen[s]) continue;
      if (dfs(b, s)) return {false, vector<T>()};
    }
    return {true, move(x)};
  }
};


int main() {
  ll n, m; cin >> n >> m;
  vector<P> E;
  Vll c(n+1);
  rep(i, m) {
    int u, v; cin >> u >> v;
    E.emplace_back(u, v);
    ++c[u];
  }

  LinearSystemIncidence<ll> LSI(n+1, E);
  auto sol = LSI.solve(c);

  if (sol.first) {
    rep(i, m) {
      if (sol.second[i]) swap(E[i].first, E[i].second);
      cout << E[i].first << " " << E[i].second << "\n";
    }
  }
  else cout << -1 << "\n";
  return 0;
}

Measured memory_bytes: 12660
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <atcoder/segtree>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







long long op(long long a, long long b){return a+b;}
long long e(){return 0;}

int main(){
    int N, Q; std::cin >> N >> Q;
    atcoder::segtree<long long, op, e> BIT(N);
    {
        int a;
        for(int i(0); i < N; ++i){
            std::cin >> a;
            BIT.set(i, a);
        }
    }
    {
        int op, l, r;
        for(int i(0); i < Q; ++i){
            std::cin >> op >> l >> r;
            if(op) std::cout << BIT.prod(l, r) << "\n";
            else BIT.set(l, BIT.get(l) + r);
        }
    }
    return 0;
}


Measured memory_bytes: 15384
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;cin >> a >> b >> c >> d;
  ll x = (a+d-1)/d;
  ll y = (c+b-1)/b;
  if(x>=y)cout <<"Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

// 復習予定

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

	int n;
	cin >> n;

	vector<vector<int>> a(n, vector<int>(n - 1));

	// input
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(begin(a[i]), end(a[i]));
	}

	vector<pair<int, int>> q;

	// i選手と試合希望の選手をqに追加
	auto check = [&](int  i) {
		if (a[i].empty()) {
			return;
		}

		int j = a[i].back();
		if (a[j].empty()) {
			return ;
		}

		if (a[j].back() == i) {
			pair<int, int> p(i, j);
			if (p.second < p.first) {
				swap(p.first, p.second);
			}

			q.push_back(make_pair(p.first, p.second));
		}
	};

	for (int i = 0; i < n; i++) {
		// i選手と試合希望の選手をqに追加
		check(i); 
	}

	int day = 0;
	while (!q.empty()) {
		day++;
		sort(begin(q), end(q));
		q.erase(unique(begin(q), end(q)), end(q));

		vector<pair<int, int>> prevQ;
		swap(prevQ, q);

		// 試合消化
		for (auto p : prevQ) {
			int i = p.first;
			int j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		// 試合追加
		for (auto p : prevQ) {
			int i = p.first;
			int j = p.second;
			check(i);
			check(j);
		}
	}

	// 全試合消化出来たか?
	for (int i = 0; i < n; i++) {
		if (!a[i].empty()) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << day << endl;
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
	int n, m, left;
	long long ans;
	cin >> n >> m;
	vector<pair<int, int>> vec(n);

	for(int i=0; i<n; i++){
		cin >> vec[i].first >> vec[i].second;
	}
	sort(vec.begin(), vec.end());

	left = m;
	ans = 0;
	for(int i=0; i<n; i++){
		if(vec[i].second <= left){
			ans += (long long)vec[i].first * vec[i].second;	
			left -= vec[i].second;
		}else{
			ans += (long long)vec[i].first * left;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

/*
10 30 90
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    long long n;
    char s[1009];
    scanf("%s",s);
    n = strlen(s);
    if(s[n-1]=='s')
    {
        s[n]='e';
        //printf("%s",s);
        s[n+1]='s';
       // printf("%s",s);
        s[n+2]='\0';
        //printf("%s",s);
    }
    else
    {
        s[n]='s';
        //printf("%s",s);
        s[n+1]='\0';
        //printf("%s",s);
    }
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
//   cin >> t;
  while(t--){
    ll a , b , c , k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    sum += min(a, k);
    k -= min(a , k);
    if(k > 0){
        k -= min(b , k);
        if(k > 0){
            sum -= min(c , k);
            cout << sum;
        }
        else{
            cout << sum;
        }
    }
    else{
        cout << sum ;
    }
   
  }
  
 
  return 0;
}


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

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

  // dataの中で隣り合う等しい要素が存在するなら"YES"を出力し、そうでなければ"NO"を出力する
  // ここにプログラムを追記
  int count = 0;
  for (int i = 0; i < N-2; i++) {
    if (data.at(i) == 'A' && data.at(i+1) == 'B' && data.at(i+2) == 'C') {
      count++;
    }
  }
    
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if(A%3 == 0 || B%3 == 0 || (A+B)%3 == 0) {
    cout << "Possible";
  }
  else {
    cout << "Impossible";
  }
}



Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String [] args) {
        final Scanner scanner = new Scanner(System.in);
        int L = scanner.nextInt();
        final Set<Double>[][] lengths = new HashSet[20][20];
        final int [] pow = new int[20];
        int i = 0;
        int largest = 0;
        while (L > 0) {
            pow[i] = L % 2;
            if (pow[i] == 1) {
                largest = i;
            }
            L /= 2;
            ++i;
        }
        for (i = 0; i <= largest; ++i) {
            for (int j = 0; j <= largest; ++j) {
                lengths[i][j] = new HashSet<>();
            }
        }
        int edgeNum = 0;
        for (i = 0; i < largest; ++i) {
            edgeNum += 2;
            lengths[i][i + 1].add((double)0);
            lengths[i][i + 1].add(Math.pow(2, i));
        }
        double maxLength = Math.pow(2, largest) - 1;

        for (i = largest - 1; i >= 0; --i) {
            if (pow[i] == 1) {
                lengths[i][largest].add(maxLength + 1);
                maxLength = Math.max(maxLength, maxLength + Math.pow(2, i));
                ++edgeNum;
            }
        }
        System.out.println(largest + 1 + " " + edgeNum);
        for (i = 0; i <= largest; ++i) {
            for (int j = i; j <= largest; ++j) {
                for (final double length : lengths[i][j]) {
                    System.out.println((i + 1) + " " + (j + 1) + " " + (int)length);
                }
            }
        }
    }
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <stdbool.h>

#define N_MAX 100
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k;

ull t[N_MAX];
bool d[N_MAX][N_MAX];

void solve(){
	return;
}

int main (void) {
	ull a, b, c;
	scanf("%llu%llu%llu", &a, &b, &c);
	if ((a & 1) & (b & 1) & (c & 1)) {
		if (b < c) SMAP(b, c);
		if (a < b) SMAP(a, b);
		printf("%llu\n", b * c);
	} else {
		puts("0");
	}
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int> > ki(n);
    map<P,int> mm;
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        if(mm[P(a,b)]) continue;
        ki[a].push_back(b);
        ki[b].push_back(a);
        mm[P(a,b)]++;
    }

    queue<int> q;
    vector<int> v(n,0);
    int ans=0;
    rep(i,n){
        if(v[i]) continue;
        q.push(i);
        int tmp=0;
        while(!q.empty()){
            int now=q.front();
            q.pop();
            tmp++;
            v[now]++;
            rep(i,ki[now].size()){
                if(!v[ki[now][i]]){
                    q.push(ki[now][i]);
                    v[ki[now][i]]++;
                }
            }
        }
        ans=max(ans,tmp);
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 27632
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static long[] fac, finv, inv;

    static void init(long mod)
    {
        fac = new long[5001];
        finv = new long[5001];
        inv = new long[5001];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < 5001; i++)
        {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = modinv(i, mod);
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }

    static long modpow(long a, long n, long mod)
    {
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    static long modinv(long a, long mod)
    {
        return modpow(a, mod - 2, mod);
    }

    static long modcomb(int a, int b, long mod)
    {
        if (a < b) return 0;
        if (a < 0 || b < 0) return 0;
        return fac[a] * (finv[b] * finv[a - b] % mod) % mod;
    }

    public static void Main(string[] args)
    {
        long mod = 1000000007;
        string[] S = Console.ReadLine().Split(' ');
        int N = int.Parse(S[0]);
        int K = int.Parse(S[1]);
        init(mod);
        for (int i = 1; i <= K; i++)
        {
            long a1 = modcomb(K - 1, i - 1, mod);
            long a2 = modcomb(N - K + 1, i, mod);
            long res = (a1 * a2) % mod;
            Console.WriteLine(res);
        }
    }
}

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




int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (auto& i : a)
		cin >> i;
	sort(a.begin(), a.end());
	for (auto i : a)
		cout << i;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define F(a,b,c) for(int a=b;a<=c;++a)
#define ms(a) memset(a,0,sizeof(a))
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define pb push_back
#define DF(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int read()
{
	int ans=0,w=1;
	char s=getchar();
	while(!isdigit(s))
	{
		if(s=='-')w=-1;
		s=getchar();
	}
	while(isdigit(s))
	{
		ans=ans*10+s-'0';
		s=getchar();
	}
	return ans*w;
}
ll jc[200050],inv[200050];
ll Pow(ll a,ll x)
{
	ll ans=1;
	while(x)
	{
		if(x&1)ans=(ans*a)%MOD;
		a=(a*a)%MOD;
		x>>=1;
	}
	return ans;
}
ll C(ll n,ll m)
{
	if(n>m)return 0;
	return jc[m]*inv[n]%MOD*inv[m-n]%MOD;
}
void Solve(int x)
{
	jc[1]=1;F(i,2,x)jc[i]=(jc[i-1]*i)%MOD;
	inv[x]=Pow(jc[x],MOD-2);
	DF(i,x,2)inv[i-1]=(inv[i]*i)%MOD;
}
int n,x,y;
struct node
{
	int c,w;
}P[200050];
struct bcj
{
	int b[200050],Size[200050];
	void init()
	{
		F(i,1,n)b[i]=i,Size[i]=1;
	}
	int fin(int o)
	{
		return b[o]==o?o:b[o]=fin(b[o]);
	}
	void Add(int x,int y)
	{
		int cx=fin(x),cy=fin(y);
		if(cx<cy)b[cy]=cx,Size[cx]+=Size[cy];
		else b[cx]=cy,Size[cy]+=Size[cx];
	}
	bool cmp(int x,int y)
	{
		return fin(x)==fin(y);
	}
}b;
int cx=1,cy=0;
bool cmp(node a,node b)
{
	return a.w<b.w;
}
int cm[200050];
bool vis[200050];
map<int,int> v[200050];
int main()
{
	n=read();x=read();y=read();
	F(i,1,n)P[i].c=read(),P[i].w=read();
	b.init();
	sort(P+1,P+n+1,cmp);
	F(i,2,n)
	{
		if(P[i].c!=P[cx].c){cy=i;break;}
	}
	F(i,1,n)if(cm[P[i].c]==0)cm[P[i].c]=i;
	F(i,1,n)
	{
		if(cm[P[i].c]!=i&&P[i].w+P[cm[P[i].c]].w<=x)b.Add(cm[P[i].c],i);
		if(P[i].c==P[cx].c)
		{
			if(P[i].w+P[cy].w<=y)b.Add(i,cy);
		}
		else if(P[i].w+P[cx].w<=y)b.Add(i,cx);
	}
	Solve(n);
	ll ans=1;
	F(s,1,n)v[b.fin(s)][P[s].c]++;
	F(s,1,n)
	{
		int c=b.fin(s);
		if(!vis[c])
		{
			vis[c]=1;
			ll ss=0,rs=1;
			for(map<int,int>::iterator it=v[c].begin();it!=v[c].end();++it)
			{
				ss+=it->second;
				rs=(rs*inv[it->second])%MOD;
			}
			ans=ans*(jc[ss]*rs%MOD)%MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26240
word = str(input())
# print(word)

counter = 0
while True:
    list_s = [str(_) for _ in input().split(" ")]
    # print(list_s)
    if "END_OF_TEXT" in list_s:
        break
    
    for s in list_s:
        # print(s)
        if s.lower() == word:
            counter += 1
            # print(f"  -> OK! ({counter})")
            
    
print(counter)


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

const int color[] = {1, 2, 3};

int main(void){
  ll N, K;
  cin >> N >> K;
  for(int i=0; i < K; i++){
    ll x, y; cin >> x >> y;
    ll c[] = {y, N-y+1, x, N-x+1};
    ll  m;

    m = *min_element(c, c+4);
    m--;
    cout << color[m%3] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
x = 10**10
for i in range(1,int(n**0.5)+1):
    if n % i == 0:
        x = min(x,int(n/i))

for i in range(10):
    if x <10**(i+1) and x >= 10**i:
        print(i+1)
        break

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

int n, k;
int b[2000][2000];
int w[2000][2000];
int ans = 0;

int main(){
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; ++i){
		int x, y;
		char z;
		scanf("%d %d %c", &x, &y, &z);
		x %= 2 * k;
		y %= 2 * k;
		if(z == 'B') ++b[x][y];
		else ++w[x][y];
	}
	for(int i=0; i<2*k; ++i)
		for(int j=1; j<2*k; ++j){
			b[i][j] += b[i][j-1];
			w[i][j] += w[i][j-1];
		}
	for(int i=0; i<2*k; ++i)
		for(int j=1; j<2*k; ++j){
			b[j][i] += b[j-1][i];
			w[j][i] += w[j-1][i];
		}
/*	for(int i=0; i<2*k; ++i){
		for(int j=0; j<2*k; ++j)
			printf("%d ", b[i][j]);
		printf("\n");
	}
	printf("\n");
	for(int i=0; i<2*k; ++i){
		for(int j=0; j<2*k; ++j)
			printf("%d ", w[i][j]);
		printf("\n");
	}
*/
	for(int i=0; i<k; ++i){
		for(int j=0; j<k; ++j){
//			printf("%d %d\n", i, j);
			int sum[2][9] = {{}, {}};
			if(i != 0){
				//0 3 6
				if(j != 0){
					sum[0][0] = b[i-1][j-1];
					sum[1][0] = w[i-1][j-1];
				}else{
					sum[0][0] = sum[1][0] = 0;
				}
				sum[0][3] = b[i-1][j+k-1] - sum[0][0];
				sum[1][3] = w[i-1][j+k-1] - sum[1][0];
				sum[0][6] = b[i-1][2*k-1] - sum[0][3] - sum[0][0];
				sum[1][6] = w[i-1][2*k-1] - sum[1][3] - sum[1][0];
			}
			if(j != 0){
				//0 1 2
				if(i != 0){
					sum[0][0] = b[i-1][j-1];
					sum[1][0] = w[i-1][j-1];
				}else{
					sum[0][0] = sum[1][0] = 0;
				}
				sum[0][1] = b[i+k-1][j-1] - sum[0][0];
				sum[1][1] = w[i+k-1][j-1] - sum[1][0];
				sum[0][2] = b[2*k-1][j-1] - sum[0][1] - sum[0][0];
				sum[1][2] = w[2*k-1][j-1] - sum[1][1] - sum[1][0];
			}
			//4 5 7 8
			sum[0][4] = b[i+k-1][j+k-1]-sum[0][1]-sum[0][3]-sum[0][0];
			sum[1][4] = w[i+k-1][j+k-1]-sum[1][1]-sum[1][3]-sum[1][0];
			sum[0][5] = b[2*k-1][j+k-1]-sum[0][2]-sum[0][4]-sum[0][1]-sum[0][0]-sum[0][3];
			sum[1][5] = w[2*k-1][j+k-1]-sum[1][2]-sum[1][4]-sum[1][1]-sum[1][0]-sum[1][3];
			sum[0][7] = b[i+k-1][2*k-1]-sum[0][4]-sum[0][6]-sum[0][3]-sum[0][0]-sum[0][1];
			sum[1][7] = w[i+k-1][2*k-1]-sum[1][4]-sum[1][6]-sum[1][3]-sum[1][0]-sum[1][1];
			sum[0][8] = b[2*k-1][2*k-1]-sum[0][5]-sum[0][7]-sum[0][4]-sum[0][6]-sum[0][3]-sum[0][0]-sum[0][1]-sum[0][2];
			sum[1][8] = w[2*k-1][2*k-1]-sum[1][5]-sum[1][7]-sum[1][4]-sum[1][6]-sum[1][3]-sum[1][0]-sum[1][1]-sum[1][2];
//			for(int p=0; p<9; ++p) printf("%d %d\n", sum[0][p], sum[1][p]);
			int tmp = 0;
			for(int l=0; l<9; ++l) tmp += sum[l%2][l];
			ans = std::max(ans, tmp);
			tmp = 0;
			for(int l=0; l<9; ++l) tmp += sum[1-l%2][l];
			ans = std::max(ans, tmp);
//			printf("%d\n\n", ans);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 2e18

int dp[1 << 15][1005];

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

    rep(i, 1<<15){
        rep(j, 1005){
            if(i!=0) dp[i][j] = INF;
        }
    }

    rep(i, m){
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b){
            int c;
            cin >> c;
            s += 1 << (c-1);
        }

        rep(j,1<<n) dp[j][i+1]=dp[j][i];
        rep(j, 1<<n){
            dp[j|s][i+1] = min(dp[j|s][i+1], dp[j][i] + a);
            // printf("%d %d %d\n", j, i, (j|s));
            // printf("%d %d %d %d %d\n", j, i, dp[j|s][i+1], dp[j][i]+a, dp[j|s][i]);
        }

        // rep(j, 1<<n){
        //     rep(k, m){
        //         cout << dp[j][k] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
    }

    // rep(i, 1<<n){
    //     rep(j, m+1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }


    
    if(dp[(1<<n) -1][m] == INF){
        cout << -1 << endl;
    }else{
        cout << dp[(1<<n) -1][m] << endl;
    }
    // printf("%d\n", N);
    return 0;
}


Measured memory_bytes: 129024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


int main()
{
    long N;
    std::vector<long> a;
    long B[200000]={};
    std::cin >> N;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        a.push_back(temp);
    }
    long count=0;
    long top=N/2;
    for(long i=top;i<N;i++){
        B[i]=a[i];
        count+=a[i];
    }
    for(long i=top-1; i>=0; i--){
        long loop=(N-i-1)/(i+1);
        long temp2=0;
        for(long j=1; j<=loop; j++){
            temp2+=B[i+(i+1)*j];
        }
        if((temp2%2==0 && a[i]==0) || (temp2%2==1 && a[i]==1)){
            B[i]=0;
        }else{
            B[i]=1;
            count+=1;
        }
    }
    std::cout << count << std::endl;
    for(int i=0; i<N; i++){
        if(B[i]==1){
            std::cout << i+1 << " ";
        }
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 4208
n = 0
s = []

def format_input(filename = None):
	global n
	global s
	if filename == None:
		n = int(input())
		s = [str(input()) for i in range(n)]

	elif filename == '__random__':
		from random import randint as rng
		from random import choices
		n = rng(1, 2 * 10**5)
		s = [''.join(choices('abcdefghijklmnopqrstuvwxyz', k = rng(1, 10))) for i in range(n)]
		print(n)
		[print(s_i) for s_i in s]

def get_answer():
	answer = len(set(s))
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 35724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,cnt=0,a[100010]={};

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	ll cnt=1,tmp=26,i;
	while(n>tmp){
		n-=tmp;
		++cnt;
		tmp*=26;
	}
	tmp/=26;
	for(i=cnt;i>=1;--i){
		a[i]=(n-1)/tmp+1;
		n-=(n-1)/tmp*tmp;
		tmp/=26;
	}
	for(i=cnt;i>=1;--i)
		cout<<char('a'+a[i]-1);
	return 0;
}
//702 zz

Measured memory_bytes: 3668
/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long int ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, ans;
    cin >> n >> m;
    ans = (1900 * m + 100 * (n - m)) * (int)pow(2, m);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int n, m, k;
    cin >> n >> m >> k;

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

    vector<int> b(m);
    rep(i, m){
        cin >> b[i];
    }

    vi ca(n);
    rep(i, n){
        if(i){
            ca[i] = ca[i-1] + a[i];
        }
        else{
            ca[i] = a[i];
        }
    }

    vi cb(m);
    rep(i, m){
        if(i){
            cb[i] = cb[i-1] + b[i];
        }
        else{
            cb[i] = b[i];
        }
    }

    int ans = 0;    
    rep(i, n){
        int time = ca[i];
        int x = i + 1;
        if(time > k){
            break;
        }
        // cout << "time: " << time << endl;
        auto it = upper_bound(all(cb), k - time);
        // cout << "y ; " << (int) (it-cb.begin()) << endl;
        ans = max(ans, x + (int) (it-cb.begin()));
    }

    rep(i, m){
        int time = cb[i];
        int x = i + 1;
        if(time > k){
            break;
        }
        // cout << "time: " << time << endl;
        auto it = upper_bound(all(ca), k - time);
        // cout << "y ; " << (int) (it-cb.begin()) << endl;
        ans = max(ans, x + (int) (it-ca.begin()));
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> v1(h,vector<char>(w,0));
  vector<vector<int>> v2(h+2,vector<int>(w+2,0));
  r(i,h){
    r(j,w){
      cin >> v1.at(i).at(j);
      if(v1.at(i).at(j)=='#'){
        r(k,3){
          r(l,3){
            v2.at(i+k).at(j+l)++;
          }
        }
      }
    }
  }
  r(i,h){
    r(j,w){
      if(v1.at(i).at(j)=='#')cout << "#";
      else cout << v2.at(i+1).at(j+1);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

x,y,z,k = map(int,input().split())

A = sorted(map(int,input().split()),reverse=True)
B = sorted(map(int,input().split()),reverse=True)
C = sorted(map(int,input().split()),reverse=True)



AB = sorted([a+b for a in A for b in B],reverse=True)

ans = sorted([ab + c for ab in AB[:k] for c in C],reverse=True)

for i in ans[:k]:
    print(i)


Measured memory_bytes: 235968
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, counter=0, tmp=1;
  cin >> N;
  
  vector<int> vec(N+1);
  vec.at(0)=0;
  for(int i=1; i<=N; i++) cin >> vec.at(i);

  while(1){
    if(vec.at(tmp)==2){
      counter++;
      break;
    }
    else if (counter > N){
      counter=-1;
      break;
    }
    else if(vec.at(tmp)==tmp){
      counter=-1;
      break;
    }
    else if (vec.at(tmp)==1){
      counter=-1;
      break;
    }
    else{
      tmp=vec.at(tmp);
      counter++;
    }
  }
  
  cout << counter << endl;
}

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

int main() {
    int N;
    cin >> N;
    set<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.insert(a);
    }
    if (A.size() == N) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	int a[n]; bool ok = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i]%2==0){
			if(a[i]%3==0||a[i]%5==0){
				
			}else ok = 0;
		}
	}
	if(ok)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int n;

void maxHeapify(vector<int>& h, int i) {
  int l = 2*i, r = 2*i+1, m = i;
  if (l <= n && h[l] > h[m]) m = l;
  if (r <= n && h[r] > h[m]) m = r;

  if (m != i) {
    swap(h[i], h[m]);
    maxHeapify(h, m);
  }
}

int main() {
  cin >> n;
  vector<int> h(n+1);
  FOR(i, 1, n+1) {
    cin >> h[i];
  }

  FORR(i, n/2, 1) {
    maxHeapify(h, i);
  }

  FOR(i, 1, n+1) {
    cout << " " << h[i];
  }
  cout << endl;

  
  return 0;
}


Measured memory_bytes: 4536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int x = 0, y = 0;
        int t = 0;
        for (int i = 0; i < n; i++) {
            String[] strings = sc.nextLine().split(" ");
            int nt = Integer.parseInt(strings[0]);
            int nx = Integer.parseInt(strings[1]);
            int ny = Integer.parseInt(strings[2]);
            if (!helper(t, x, y, nt, nx, ny)) {
                System.out.println("No");
                return;
            }
            t = nt;
            x = nx;
            y = ny;
        }
        System.out.println("Yes");
    }

    private static boolean helper(int t, int x, int y, int nt, int nx, int ny) {
        int dt = nt - t;
        int dx = Math.abs(nx - x);
        int dy = Math.abs(ny - y);
        if (dx + dy > dt) {
            return false;
        }
        return (dt & 1) == ((dx + dy) & 1);
    }
}

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

const int mod = 1e9+7;

vector<vector<ll> > mult(vector<vector<ll> > a, vector<vector<ll> > b) {
    if(a.size() == 0) return {};
    if(a[0].size() == 0) return {};
    if(b.size() == 0) return {};
    if(b[0].size() == 0) return {};
    if(a[0].size() != b.size()) return {};
    int resultRow = a.size(), resultCol = b[0].size(), n = a[0].size();
    vector<vector<ll> > product(resultRow, vector<ll>(resultCol));
    for(int i = 0; i < resultRow; ++i) {
        for(int j = 0; j < resultCol; ++j) {
            product[i][j] = 0;
            for(int k = 0; k < n; ++k) {
                product[i][j] += a[i][k] * b[k][j];
                product[i][j] %= mod;
            }
        }
    }
    return product;
}

vector<vector<ll> > power(vector<vector<ll> > matrix, ll b) {
    if (b <= 1) return matrix;
    vector<vector<ll> > temp = power(matrix, b/2);
    if (b % 2 == 0) return mult(temp, temp);
    return mult(mult(temp, temp), matrix);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    vector<vector<int>> arr(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> arr[i][j];
        }
    }
    vector<vector<int>> vect(n, vector<int>(1,1));
    vect = mult(power(arr, k), vect);
    int res = 0;
    for(int i = 0; i < n; ++i) {
        res += vect[i][0];
        res %= mod;
    }
    cout << res << '\n';
    return 0;
}


























Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    int n=nxt();
    string s1,s2;
    cin>>s1>>s2;
    ll test=1;
    vector <int> temp;
    int i=0;
    while(i<n)
    {
        if(s1[i]==s2[i])
        {
            temp.push_back(1);
            i++;
        }
        else
        {
            temp.push_back(2);
            i+=2;
        }
    }
    n=temp.size();
    i=1;
    bool f=1;
    if(temp[0]==1)
        test=3;
    else
        test=6;
    while(i<n)
    {
        if(temp[i]==1&&temp[i-1]==1)
        {
            (test*=2)%=mod;
        }
        else if(temp[i]==2&&temp[i-1]==2)
        {
            (test*=3)%=mod;
        }
        else if(temp[i]==2&&temp[i-1]==1)
        {
            (test*=2)%=mod;
        }
        i++;
    }
    cout<<test<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,j,n) for(int i=j;i<n;i++)
int main()
{
	string s;
	cin>>s;
	int ans=1;
	bool b=false;
	forn(i,1,s.size())
	{
		if(b)//前面字符串为两个字符 
		{
			ans++;
			b = false;
		}
		else//前面为一个字符 
		{
			if(s[i]==s[i-1])
			{
				if(i==s.size()-1)
				{
					//ans++;
				}
				else
				{
					ans++;
					i++;
				}
				b=true;
			}
			else
			{
				ans++;//仍为一个字符，不变 
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush();
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0;
#define br break;
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
    ios;
    ll  n , a , b , c , d , e ;
    cin >> n >> a >> b >> c >> d >> e;
    vl v ;
    v.pb(a) ; v.pb(b) ; v.pb(c) ; v.pb(d) ; v.pb(e) ;
    sort(all(v));
    ll minn = v[0] ;
    ll res  ;
    ll foo = n % minn ;
    ll timee ;
    if(n%minn){
        timee = (n  / minn ) + 1 ;
    }
    else{
        timee = n / minn ;
    }
    ll sum = timee + 4 ;
    cout << sum << el ;
}























Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, x, y, z, a, b, c;

    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%d %d %d", &x, &y, &z);
        a = x*x;
        b = y*y;
        c = z*z;
        if((a==b+c) || (b==a+c) || (c==a+b))
            printf("YES\n");
        else
            printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 1964
#include <cstdio>
#include <vector>
#define min(a, b) (a < b ? a : b)

using namespace std;

int square(int n)
{
    return n*n;
}

int main()
{
    int no_of_elements;
    scanf("%d", &no_of_elements);

    vector <int> A(no_of_elements + 1);
    for(int i = 1; i <= no_of_elements; i++)
        scanf("%d", &A[i]);

    const int oo = 1e9;
    int min_a = -100, max_a = 100;
    int best_cost = oo;

    for(int final_value = min_a; final_value <= max_a; final_value++)
    {
        int cost = 0;

        for(int i = 1; i <= no_of_elements; i++)
            cost += square(final_value - A[i]);

        best_cost = min(best_cost, cost);
    }

    printf("%d\n", best_cost);
    return 0;
}


Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    if(v[1]>0)
    {
        cout<<-1<<'\n';
        return;
    }
    for(int i=2;i<=n;i++)
    {
        if((v[i]-v[i-1])>1)
        {
            cout<<-1<<'\n';
            return;
        }
    }
    ll x[n+1]={0};
    ll ans=0;
    for(int i=n;i>=1;i--)
    {
        if(x[i]==v[i])
        {
            x[i-1]=max((ll)0,x[i]-1);
        }
        else
        {
            ans+=v[i];
            x[i]=v[i];
            x[i-1]=max((ll)0,x[i]-1);
        }
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;


int main(){
    int X,Y,Z;cin >> X>> Y >> Z;
    long long K;cin >> K;
    vector<long long> A,B,C;
    vector<pair<long long,int>> vec;
    for(int a = 0;a < X;a++){
        long long b;cin >> b;
        A.push_back(b);
    }
    for(int a = 0;a < Y;a++){
        long long b;cin >> b;
        B.push_back(b);
    }
    for(int a = 0;a < Z;a++){
        long long b;cin >> b;
        C.push_back(b);
    }
    vector<long long> hoge;
    for(int a = 0;a < Y;a++){
        for(int b = 0;b < Z;b++){
            hoge.push_back(B.at(a)+C.at(b));
        }
    }
    sort(hoge.begin(),hoge.end());
    priority_queue<long long, vector<long long>, greater<long long>> que;
    sort(A.begin(),A.end());
    reverse(hoge.begin(),hoge.end());
    reverse(A.begin(),A.end());
    for(int a = 0;a < X;a++){
        for(int b = 0;b < hoge.size();b++){
            if(que.size() < K){
                que.push(hoge.at(b)+A.at(a));
            }else{
                if(que.top() < hoge.at(b)+A.at(a)){
                    que.push(hoge.at(b)+A.at(a));
                    que.pop();
                }else{
                    break;
                }
            }
        }
    }
    vector<long long> q;
    for(int a = 0;a < K;a++){
        q.push_back(que.top());que.pop();
    }
    reverse(q.begin(),q.end());
    for(int a = 0;a < K;a++)cout<<q.at(a)<<endl;
}


Measured memory_bytes: 10616
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    /* Euclid???????????? */
    public static long gcd(long a, long b) {
        if(b == 0) return a;
        return gcd(b, a % b);
    }
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       while (in.hasNextInt()) {
           long a = in.nextInt();
           long b = in.nextInt();

           long gcd = gcd(a, b);
           long lcm = Math.abs(a*b) / gcd;
           System.out.println(""+gcd+" "+lcm);
       }
    }
}

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

int main(){
    int x;
    cin>>x;
    for(int a=1;a<1000;++a){
        ll a5=1;
        for(int i=0;i<5;++i)a5*=a;
        for(int b=-1000;b<1000;++b){
            ll b5=1;
            for(int j=0;j<5;++j)b5*=b;
            if(a5-b5==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;
typedef vector<PII> VPII;

// TEMPLATE DEFINITIONS END

string s;

void read_input(){
    cin >> s;
}

void solve(){

    if(s[0] == s[1] && s[1] == s[2]){
        cout << "No\n";
        return;
    }

    cout << "Yes\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


Measured memory_bytes: 256