akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,p; cin >> n >> p;
  int even = 0, odd = 0;
  rep(i,n){
    int a; cin >> a;
    even += 1-a%2;
    odd += a%2;
  }

  vector<vector<ll>> nCr(n+1,vector<ll>(n+1));
  nCr[0][0] = 1;
  rep(i,n) rep(j,i+1){
    nCr[i+1][j+1] += nCr[i][j];
    nCr[i+1][j] += nCr[i][j];
  }
  ll ans = 0;
  rep(i,even+1){
    for(int j = p; j < odd+1; j+=2){
      ans += nCr[odd][j]*nCr[even][i];
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>

int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  if(y%2!=0){
    printf("No\n");
    return 0;
  }
  int a=2*x-y/2;
  if(0<=a&&a<=x){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

int main(){

	# ifdef FILEs
		freopen( "input.txt", "r", stdin );
		freopen( "output.txt", "w", stdout );
	# endif
	ios_base::sync_with_stdio( false );
	int n, m;
	cin >> n >> m;
	if( n > m ){
		cout << "No";
	}else{
		cout << "Yes";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
char s[110][110] ;
int main(){
    int A , B ;
    cin >> A >> B ;
    cout << "99 99" << endl ;
    for( int i = 1 ; i <= 99 ; i++ )
        for( int j = 1 ; j <= 99 ; j++ )
            s[i][j] = '.' ;
    if ( A == 1 ) B++ ;
    for( int i = 1 ; i <= 33 ; i++ )
        for( int j = 1 ; j <= 33 ; j++ ){
            if ( A > 1 ){
                for( int k = 3 * i - 2 ; k <= 3 * i ; k++ )
                    for( int l = 3 * j - 2 ; l <= 3 * j ; l++ ){
                        if ( k == 3 * i - 1 && l == 3 * j - 1 ) continue ;
                        s[k][l] = '#' ;
                }
                A-- ;
            }
            else{
                if ( B > 1 ){
                    s[3 * i - 1][3 * j - 1] = '#' ;
                    B-- ;
                }
            }
    }
    for( int i = 1 ; i <= 99 ; i++ ){
        for( int j = 1 ; j <= 99 ; j++ )
            printf( "%c" , s[i][j] ) ;
        printf( "\n" ) ;
    }
    return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

void maxHeapify(int,int[],int);
void buildMaxHeap(int,int[]);

int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    int array[size];
    for(int i = 0; i < size; i++)
        scanf("%d",&array[i]);
    
    buildMaxHeap(size,array);
    
    for(int i = 0; i < size; i++)
        printf(" %d",array[i]);
    printf("\n");
    return (EXIT_SUCCESS);
}

void maxHeapify(int size, int array[size], int loc){
    int largest;
    int left = 2*loc+1;
    int right = 2*loc+2;
    int temp;
    if(left < size && array[left] > array[loc])
        largest = left;
    else largest = loc; 
    if(right < size && array[right] > array[largest])
        largest = right;
    if(largest != loc){
        temp = array[loc];
        array[loc] = array[largest];
        array[largest] = temp;
        maxHeapify(size,array,largest);
    }
}

void buildMaxHeap(int size, int array[size]){
    for(int i = size/2; i >= 0; i--)
        maxHeapify(size,array,i);
}




Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

int main() {
	int n; cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	map<int, int> cnt;
	for (int i = 0; i < n; i++) cnt[x[i]]++;
	if (cnt.size() > 3) {
		cout << "No" << endl;
		return 0;
	}

	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());

	int cur = x[0], prev = x.back();
	for (int i = 1; i < n; i++) {
		if (cnt[cur] <= 0) {
			cout << "No" << endl;
			return 0;
		}
		cnt[cur]--;
		int buf = cur;
		cur = cur^prev;
		prev = buf;
	}
	if (cnt[cur] <= 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 4224
import numpy as np

n=int(input())
x=list(map(int, input().split()))

av=sum(x)/n

a=int(av)

v1=sum([(int)(i-a)*(i-a) for i in x])
v2=sum([(int)(i-a-1)*(i-a-1) for i in x])

print(min(v1,v2))

Measured memory_bytes: 12452
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int K;
  cin >> K;

  ll ans = 0;
  rep(i, 1, K + 1) {
    rep(j, 1, K + 1) {
      rep(k, 1, K + 1) {
        int t = gcd(i, j);
        ans += gcd(t, k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	string s; cin >> s;
	int i = s.length()-1;
	while(i > 0) {
      if(s[i] == 'Z') break;
      i--;
	} 

	int j = 0;
	while(j <i) {
		if(s[j] == 'A') break;
		j++;
	}
	cout << (i - j) + 1 << endl;
return 0;
}


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

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    char str[25][25];
    for(int i=0;i<n;i++)
    {
        scanf("%s",str[i]);
    }

    for(int i=0;i<n-1;i++)
    {
        for(int j=0;j<m-1;j++)
        {
            if(str[i][j]=='#'&&str[i+1][j]=='#'&&str[i][j+1]=='#')
            {
                printf("Impossible\n");
                return 0;
            }
        }
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(str[i][j]=='#'&&str[i-1][j]=='#'&&str[i][j-1]=='#')
            {
                printf("Impossible\n");
                return 0;
            }
        }
    }
    printf("Possible\n");
}

Measured memory_bytes: 256
while True:
    d,w = map(int,input().split())

    if d == 0:
        break

    e = list(list(map(int,input().split()))for i in range(d))
    ans = 0
    for sx in range(w-2):
        for sy in range(d-2):
            for tx in range(sx+2,w):
                for ty in range(sy+2,d):
                    #外周の最大値
                    max_out = float('inf')
                    for i in range(sx,tx+1):
                        max_out = min(e[sy][i],e[ty][i],max_out)
                    for i in range(sy,ty+1):
                        max_out = min(e[i][sx],e[i][tx],max_out)
                    v = 0
                    for j in range(sx+1,tx):
                        for i in range(sy+1,ty):
                            v += max_out-e[i][j]
                            if max_out - e[i][j] <= 0:
                                v = -float('inf')
                    ans = max(v,ans)
    print(ans)


Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

struct Node {
	Node *l, *r;
	char op;
	int val;
};

char s[500];

int num(char* &p){
	int ret = 0;
	while (true) {
		if ('0' <= *p && *p <= '9') {
			ret = ret * 10 + *p - '0';
			p++;
		} else break;
	}
	return ret;
}

set<int> expr(char* &p){
	vector<set<int>> val;
	vector<char> op;
	while (*p) {
		if (*p == ')') break;
		if (*p == '(') {
			p++;
			val.push_back(expr(p));
			p++;
		} else {
			int a = num(p);
			set<int> s;
			s.insert(a);
			val.push_back(s);
		}
		if (*p && *p != ')') op.push_back(*(p++));
	}
	set<int> dp[20][20];
	FOR(i, sz(val)) dp[i][i + 1] = val[i];
	for (int l = 2; l <= sz(val); l++) {
		for (int left = 0; left + l <= sz(val); left++) {
			int right = left + l;
			FOR(o, l - 1){
				int a = o + left + 1;
				char uop = op[a - 1];
				for (auto x : dp[left][a]) for (auto y : dp[a][right]) {
					if (uop == '*') dp[left][right].insert(x*y);
					if (uop == '/' && y != 0) dp[left][right].insert(x / y);
					if (uop == '+') dp[left][right].insert(x + y);
					if (uop == '-') dp[left][right].insert(x - y);
				}
			}
		}
	}
	return dp[0][sz(val)];
}

int solve(){
	char* p = s;
	auto a = expr(p);
	return sz(a);
}

int main(){
	while (cin >> s, strcmp(s,"#")!= 0) {
		cout << solve() << endl;
	}
}

Measured memory_bytes: 1456
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 505;
struct edg{int pos; long long cap; int rev;};
vector<edg> gph[MAXN];
void clear(){for(int i=0; i<MAXN; i++) gph[i].clear();}
void add_edge(int s, int e, long long x){
	gph[s].push_back({e, x, (int)gph[e].size()});
	gph[e].push_back({s, 0, (int)gph[s].size()-1});
}
int dis[MAXN], pnt[MAXN];
bool bfs(int src, int sink){
	memset(dis, 0, sizeof(dis));
	memset(pnt, 0, sizeof(pnt));
	queue<int> que;
	que.push(src);
	dis[src] = 1;
	while(!que.empty()){
		int x = que.front();
		que.pop();
		for(auto &e : gph[x]){
			if(e.cap > 0 && !dis[e.pos]){
				dis[e.pos] = dis[x] + 1;
				que.push(e.pos);
			}
		}
	}
	return dis[sink] > 0;
}
long long dfs(int x, int sink, long long f){
	if(x == sink) return f;
	for(; pnt[x] < gph[x].size(); pnt[x]++){
		edg e = gph[x][pnt[x]];
		if(e.cap > 0 && dis[e.pos] == dis[x] + 1){
			long long w = dfs(e.pos, sink, min(f, e.cap));
			if(w){
				gph[x][pnt[x]].cap -= w;
				gph[e.pos][e.rev].cap += w;
				return w;
			}
		}
	}
	return 0;
}
long long match(int src, int sink){
	long long ret = 0;
	while(bfs(src, sink)){
		long long r;
		while((r = dfs(src, sink, (long long)2e9))) ret += r;
	}
	return ret;
}

int a[MAXN];
int main()
{
    int N; scanf("%d", &N);
    long long ans = 0;
    for(int i=1; i<=N; ++i)
    {
        scanf("%d", a+i);
        if(a[i]>0) ans += a[i];
    }
    int S = N+1;
    int T = N+2;
    for(int i=1; i<=N; ++i)
    {
        if(a[i] <= 0) add_edge(S, i, -a[i]);
        else add_edge(i, T, a[i]);
    }
    for(int i=1; i<=N; ++i)
        for(int j=2*i; j<=N; j += i)
            add_edge(i, j, (long long)(1e18));
    printf("%lld\n", ans - match(S, T));
    return 0;
}






















Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s: String = sc.next()
    var a: Int = 0
    var z: Int = 0
    for (i in 0 until s.length) {
        if (s[i] == 'A') {
            a = i
            break
        }
    }
    for (i in s.length - 1 downTo 0) {
        if (s[i] == 'Z') {
            z = i
            break
        }
    }
    print(z - a + 1)
}

Measured memory_bytes: 32304
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))
sumA = sum(A)
 
ans, sumA2 = abs(sumA - 0), 0
for i in range(N):
    sumA2 += A[i]
    ans = min(ans, abs(sumA - sumA2 * 2))
 
print(ans)

Measured memory_bytes: 26220
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;

int main() {
  int t;
  cin >> t;
  ll a, b, c, d;

  while (t--) {
    cin >> a >> b >> c >> d;
    // 無条件No: 初めから在庫ない、補充量がb未満、補充する前に終了

    // 次にb未満になるのに補充されない　これはどんな時？
    // cよりデカく、bより小さい数が現れるか？
    // (a + d * x) mod bを考えればよさそう
    if (a < b || d < b || c < a - a / b * b)
      cout << "No";
    else {
      if (b <= c + 1)
        cout << "Yes";
      else {
        // y = (a % b + (d % b) * x) % bがc < y < bとなるか
        // c以下ギリギリまで近づけて、超えた後にb未満ならNo
        if (d % b == 0)
          cout << "Yes";
        else {
          ll g = __gcd(b, d);
          ll x = (c - a % b) / g;
          ll y = a % b + g * x;
          cout << (y + g < b ? "No" : "Yes");
        }
      }
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3612
N, X, Y = map(int,input().split())
rc = [0] * (N - 1)
for i in range(1, N):
  for j in range(i + 1, N + 1):
    l = j - i
    s = abs(X - i) + abs(Y - j) + 1
    rc[min(l,s) - 1] += 1
    #if min(l,s) == 2:
      #print(i,j)
for i in rc:
  print(i)

Measured memory_bytes: 3444
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
s = int(input())
h = s//3600
m = (s-(h*3600))//60
ss = s-(h*3600)-m*60
print(h, end='')
print(':', end='')
print(m, end='')
print(':', end='')
print(ss)



Measured memory_bytes: 7020
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvi g;
	public:
	vi match,used;
	bool BM_dfs(int v){
		used[v]=1;
		for(int i=0;i<g[v].size();i++){
			int u=g[v][i],w=match[u];
			if(w<0||!used[w]&&BM_dfs(w)){
				match[v]=u;
				match[u]=v;
				return 1;
			}
		}
		return 0;
	}
	int BM(){
		int res=0;
		match=vi(V,-1);
		for(int i=0;i<V;i++) if(match[i]<0){
			used=vi(V);
			if(BM_dfs(i)) res++;
		}
		return res;
	}
	Graph(int v){
		V=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
};

int n,m,l;

int main(){
	while(1){
		cin>>n>>m>>l;
		if(!n) break;
		Graph g(2*l);
		vvi G(n,vi(n,inf));
		vp a(l);
		for(int i=0;i<m;i++){
			int v,u,c;
			cin>>v>>u>>c;
			G[v][u]=G[u][v]=c;
		}
		for(int i=0;i<l;i++){
			int p,t;
			cin>>p>>t;
			a[i]={t,p};
		}
		for(int i=0;i<n;i++) G[i][i]=0;
		for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
		for(int i=0;i<l;i++) for(int j=0;j<l;j++){
			if(i!=j&&G[a[i].second][a[j].second]<=a[j].first-a[i].first) g.add_edge(i,l+j);
		}
		cout<<l-g.BM()<<endl;
	}
}

Measured memory_bytes: 8420
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll N,T;
    cin >> N >> T;
    vector<ll> t(N);
    rep(i,N)    cin >> t.at(i);

    ll ans=T*N;
    rep(i,N-1) {
        if(t[i+1]-t[i]-T<0) ans+=t[i+1]-t[i]-T;
    }

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

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

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

		int N = sc.nextInt();
		long ans = 1;
		long[] A = new long[N];

		for(int i=0; i<N; i++) {
			A[i] = sc.nextLong();
			if(A[i] == 0) {
				System.out.println(0);
				return ;
			}
		}

		for(int i=0; i<N; i++) {
			long a = A[i];
			if(Math.log10(ans) + Math.log10(a) > 18) {
				System.out.println(-1);
				return;
			}
			ans *= a;

		}


		if(ans <= 1000000000000000000l) {
			System.out.println(ans);
		}else {
			System.out.println(-1);
		}

	}
}



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

int main() {
    int N, K;  cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    long long ans = 1LL << 60;
    for (int i = 0; i < (1 << N); ++i) {
        int color = 0;
        for (int j = 0; j < N; ++j) if ((i >> j) & 1) ++color;
        if (color >= K) {
            long long cost = 0;
            int highest = 0;
            for (int j = 0; j < N; ++j) {
                if (((i >> j) & 1) && a[j] <= highest) {
                    cost += highest - a[j] + 1;
                    ++highest;
                }
                else {
                    highest = max(highest, a[j]);
                }
            }
            ans = min(ans, cost);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var X int
	fmt.Scanf("%d", &X)

	if X >= 400 && X < 600 {
		fmt.Println("8")
	} else if X >= 600 && X < 800 {
		fmt.Println("7")
	} else if X >= 800 && X < 1000 {
		fmt.Println("6")
	} else if X >= 1000 && X < 1200 {
		fmt.Println("5")
	} else if X >= 1200 && X < 1400 {
		fmt.Println("4")
	} else if X >= 1400 && X < 1600 {
		fmt.Println("3")
	} else if X >= 1600 && X < 1800 {
		fmt.Println("2")
	} else if X >= 1800 && X < 2000 {
		fmt.Println("1")
	}
}


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

int main() {
    int N, R;
    cin >> N >> R;
    if(N >= 10) {
        cout << R << endl ;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }

    return 0;
}



Measured memory_bytes: 256
f :: String -> Bool
f [] = True
f [x] =  if x `elem` ['R','U','D'] then True else False
f [x,y] = if x `elem` ['R','U','D'] && y `elem` ['L','U','D'] then True else False
f (x:y:xs) = if x `elem` ['R','U','D'] && y `elem` ['L','U','D'] then True && f xs else False && f xs
main = do
 s <- getLine
 if (f s) == True then putStrLn "Yes" else putStrLn "No"

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    char c;
    cin >> c;
    if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') PRINT("vowel");
    else PRINT("consonant");
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left
from itertools import combinations 

input = sys.stdin.readline
 
N = int(input())
l= list(map(int, input().split()))
 
l.sort()
cnt = 0
 
for n,i in enumerate(l[:N-2]):
    for m,j in enumerate(l[n+1:N-1],n+1):
        cnt += max(0,bisect_left(l,i+j)-(m+1)) 
        
print(cnt)

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=2e5+1e2;
const int modd=1e9+7;
const int inf=0x3f3f3f3f;
struct node {
	int x,y;
	bool operator < (const node &aa) const {
		return ((x<aa.x) || (x==aa.x && y<aa.y));
	}
	bool operator == (const node &aa) const {
		return (x==aa.x && y==aa.y);
	}
}s[maxn];
int n,m;
int cnt,N;
int a[maxn],b[maxn],c[maxn],dp[maxn];

inline void file() {
	freopen("ARC101F.in","r",stdin);
	freopen("ARC101F.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline void Add(int &a,int b) {
	a+=b;
	a=(a>=modd?a-modd:a);
	a=(a<0?a+modd:a);
}

struct Bit {
	int bit[maxn];

	inline void init() { Set(bit,0); }

	inline int lowbit(int x) { return x&-x; };

	inline void update(int x,int y) {
		for (;x<=maxn;x+=lowbit(x)) Add(bit[x],y);
	}

	inline int query(int x) {
		int sum=0;
		for (;x;x-=lowbit(x)) Add(sum,bit[x]);
		return sum;
	}
}T;

int main() {
//	file();
	n=read(); m=read();
	For (i,1,n) a[i]=read();
	For (i,1,m) b[i]=read();
	For (i,1,n) {
		int p=lower_bound(b+1,b+m+1,a[i])-b;
		if (p==1 || p==m+1) continue;
		s[++N].x=a[i]-b[p-1]; s[N].y=b[p]-a[i];
		c[++cnt]=a[i]-b[p-1]; c[++cnt]=b[p]-a[i];
	}
//	For (i,1,N) cout << s[i].x << " " << s[i].y << endl;
	c[++cnt]=0; c[++cnt]=inf;
	sort(c+1,c+cnt+1); cnt=unique(c+1,c+cnt+1)-(c+1);
//	For (i,1,cnt) cout << c[i] << " " ; cout << endl;
	For (i,1,N) {
		s[i].x=lower_bound(c+1,c+cnt+1,s[i].x)-c;
		s[i].y=lower_bound(c+1,c+cnt+1,s[i].y)-c;
	}
	sort(s+1,s+N+1); N=unique(s+1,s+N+1)-(s+1);
//	For (i,1,N) cout << s[i].x << " " << s[i].y << endl;
	T.init(); T.update(1,1);
	for (int i=1,j;i<=N;i=j+1) {
		j=i;
		while (j<N && s[j+1].x==s[i].x) ++j;
//		cout << i << "*" << j << endl;
		For (k,i,j) dp[k]=T.query(s[k].y-1);
//		cout << dp[i] << endl;
		For (k,i,j) T.update(s[k].y,dp[k]);
	}
	printf("%d",T.query(cnt));
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int N = S.size();
    for(int i=0; i<N/2; i++) if(S[i] != S[N-1-i]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
integer(16) :: s,k,x,y,z,ans=0

read*,k,s

do x = 0,k
do y = 0,k
  z = s - x - y
  if( 0<=z .and. z<=k )then
    ans = ans + 1
  end if
end do
end do

print*,ans
end program


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MAX = 1100000;
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;
}

int main() {
  COMinit();
  int x,y;
  cin >> x >> y;
  if (x*2 < y || y*2 < x || (x+y)%3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int n = (x+y)/3;
  int k = y-n;
  cout << com(n,k) << endl;
  return 0;
}


Measured memory_bytes: 29420
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) D(N);
    READVEC(D);
    sort(ALL(D));
    cout << D[N / 2] - D[N / 2 - 1] << endl;
    return 0;
};


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define LEN 100005

/*プロセスを表す構造体*/
typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

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

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

int min(int a, int b){return a < b ? a : b;}/*最小値を返す*/

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    /*全てのプロセスをキューに順番に追加する*/

    for( i= 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }

    head = 1; tail = n + 1;

    /*シミュレーション*/
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);/*qまたは必要な時間u.tだけ処理を行う*/
        u.t -= c;/*残りの必要時間を計算*/
        elaps += c;/*経過時間を計算*/
        if(u.t > 0)enqueue(u);/*処理が完了していればキューに追加*/
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}


Measured memory_bytes: 11844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		boolean exist = false;
		for (int C = 1; C <= 3; ++C) {
			if (A * B * C % 2 != 0) {
				exist = true;
				break;
			}
		}
		if (exist) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		in.close();

	}

}

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

int main(){
  int n;
  cin >> n;
  long long int ans=0;
  for(int i=1; i<=n; i++){
    if(i%3==0||i%5==0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[20],b[20];
inline bool check()
{
	int n=strlen(a);
	for(int i=0;i<n;++i)
	if(a[i]!=b[i])return 0;
	return 1;
}
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	if(strlen(a)+1==strlen(b) && check())puts("Yes");
	else puts("No");
}

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

using namespace std;

int n,k,ans=1;

int main()
{
     cin>>n>>k;
     ans=1;
     for(int i=0;i<n;i++)
    {
        if(ans>k)
        {
            ans+=k;
        }
        else 
        ans*=2;

    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int h, w, k; cin >> h >> w >> k; --k;
	vector<int> v;
	rep(i, pow(2, w - 1))
	{
		bool ok = true;
		rep(j, w - 2)if (i&(1 << j) && i&(1 << j + 1))ok = false;
		if (ok)v.push_back(i);
	}
	vector<vector<int>> dp(h + 1, vector<int>(w));
	dp[0][0] = 1;
	int MOD = 1e9 + 7;
	rep(i, h)rep(j, w)
	{
		for (int x : v)
		{
			if (j > 0 && x&(1 << (j - 1)))
			{
				dp[i + 1][j - 1] += dp[i][j];
				dp[i + 1][j - 1] %= MOD;
			}
			else if (j < w - 1 && x&(1 << j))
			{
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= MOD;
			}
			else
			{
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
			}
		}
	}
	cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
N = int(input())

cntab = 0
cns = 0
cne = 0
cnse = 0
for _ in range(N):
    S = input()
    if S[0] == 'B' and S[-1] == 'A':
        cnse += 1
    elif S[0] == 'B':
        cns += 1
    elif S[-1] == 'A':
        cne += 1
    for s1, s2 in zip(S, S[1:]):
        if (s1 == 'A') and (s2 == 'B'):
            cntab += 1


if N == cnse:
    print(cntab + N - 1)
elif cnse == 0:
    print(cntab + min(cns, cne))
else:
    if (cns == 0) and (cne == 0):
        print(cntab + cnse - 1)
    elif (cns == 0) or (cne == 0):
        print(cntab + cnse)
    else:
        print(cntab + cnse + 1 + min(cns-1, cne-1))


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

int main(){
    int M, T, P, R;
    cin >> M >> T >> P >> R;
    while(M > 0){
        vector<pair<pair<int, int>, int>> ans(T);
        for(int i=0; i<T; i++){
            ans[i].first = make_pair(P, 0);
            ans[i].second = -i;
        }
        vector<vector<int>> pen(T, vector<int>(P, 0));
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            t--; p--;
            if(j == 0){
                ans[t].first.first--;
                ans[t].first.second += m + pen[t][p];
            }else{
                pen[t][p] += 20;
            }
        }
        sort(ans.begin(), ans.end());
        for(int i=0; i<T; i++){
            cout << -ans[i].second+1;
            if(i<T-1) cout << (ans[i].first == ans[i+1].first ? "=":",");
        }
        cout << endl;

        cin >> M >> T >> P >> R;
    }
}



Measured memory_bytes: 3092
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val k, x = sc.nextInt

  def OneClue(k: Int, x: Int): List[Int] = {
    val min = x - (k - 1)
    val max = x + (k - 1)
    (min to max).toList
  }

  println(OneClue(k, x).mkString(" "))
}

Measured memory_bytes: 27328
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		String s = " ";
       
        for(int i=0;i<a;i++){s+="ACL";
                            }
        
		System.out.println(s);
	}
}


Measured memory_bytes: 38668
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        long a = in.nextLong();
        long b = in.nextLong();
        out.println(a / gcd(a, b) * b);
    }

    static long gcd(long a, long b) {
        return 0 < b ? gcd(b, a % b) : a;
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            out.flush();
        } catch (Throwable t) {
            out.flush();
            t.printStackTrace();
        }
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


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


void solve(){
    string n;
    cin>>n;
    int sum=0;
    int cnt=n.size();
    for(int i=0;i<n.size();i++){
        sum+=n[i]-'0';
        if(sum>=10){
            sum=sum-9;
            cnt++;
        }
    }
    if(cnt%2){
        cout<<"Audrey wins."<<endl;
    }
    else{
        cout<<"Fabre wins."<<endl;
    }

}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename TEachPrime, typename TEachUniquePrime = function<void(T)>>
constexpr void factorize(T n, TEachPrime&& each_prime, TEachUniquePrime&& each_unique_prime = [](T) {}) {
    static_assert(is_convertible<decltype(each_prime), function<void(T)>>::value, "each_prime must be void(T)");
    static_assert(is_convertible<decltype(each_unique_prime), function<void(T)>>::value, "each_unique_prime must be void(T)");
    for(T i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            each_unique_prime(i);
            while(n % i == 0) {
                each_prime(i);
                n /= i;
            }
        }
    }
    if(n > 1) {
        each_prime(n);
        each_unique_prime(n);
    }
}
const int N = 100;
ll C[N+1][N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> counter(N + 1);
    for(int i = 1; i <= n; i++) {
        factorize(i, [&](int p) {
            counter[p]++;
        });
    }
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            if(i == 0) {
                C[i][j] = j == 1;
            } else {
                for(int k = 1; k <= counter[i] + 1; k++) {
                    if(j % k == 0) {
                        C[i][j] += C[i-1][j / k];
                    }
                }
            }
        }
    }
    cout << C[N][75] << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {// Main
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		HashSet<Integer> map =new HashSet<Integer>();
		for(int i =  1 ; i<=k; i++) {
			int d = sc.nextInt();
			for(int  j = 1 ; j<=d ;j++) {
				int x = sc.nextInt();
				map.add(x);
			}
		}
		System.out.println(n - map.size());
    }
}


Measured memory_bytes: 46208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int N; cin >> N;
    int sum = 0;
    vi v(N);
    rep(i, N){
        cin >> v[i];
        sum += v[i];
    }
    int ave = 0;
    if(sum >= 0) {
        ave = (double) sum / N + 0.5;
    } else {
        ave = (double) sum / N - 0.5;
    }
    int ans = 0;
    rep(i, N) {
        ans += (v[i] - ave) * (v[i] - ave); 
    }
    COUT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Number
{
    int n;
    int diff;
};
int main()
{
    int n = 5;
    Number arr[n];
    int max1 = 0,in = 0,ans = 0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i].n;
        if(arr[i].n%10 == 0)
        {
            arr[i].diff = 0;
            continue;
        }
        int ps = ((arr[i].n)/10)*10 + 10;
        arr[i].diff = ps - arr[i].n;
        if(arr[i].diff > max1)
            max1 = arr[i].diff, in = i;
    }
    for(int i=0; i<n; i++)
    {
        ans += arr[i].n;
        if(i != in)
            ans += arr[i].diff;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, m;
	cin >> n;
	vector<int> t(n+1);
	REPS(i, n)cin >> t[i];
	cin >> m;
	vector<int> p(m+1),x(m+1);
	REPS(i, m)cin >> p[i] >> x[i];

	REPS(i, m) {
		int sum = 0;
		REPS(j, n) {
			if (j == p[i]) {
				sum += x[i];
			}
			else sum += t[j];
		}
		cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> val(30);
    ll vva = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        
        if(a > k) continue;
        for(int i = 29; i >= 0; i--) {
            if((k>>i&1) < (a>>i&1)) break;
            if((k>>i&1) > (a>>i&1)) {
                val[i] += b;
            }
        }
        if((a&k) == a) vva += b;
    }

    cout << max(vva, *max_element(all(val))) << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,a[N],b[N],cnt,r[N];
string s,f[N];
string calc(int l,int r){
	string ans="";
	if (a[l]<b[l]){
		int las=a[l]-1;
		for (int i=l;i<=r;i++)
		if (las<a[i]){ans+="ab";las=b[i];}
	}
	else{
		string t;
		for (int i=l;i<=r;i++){
			t="";
			int j=i,k=i;
			while ((j<=r)||(k<=r))
			if (a[j]<b[k]){t+='a';j++;}
			else {t+='b';k++;}
			ans=max(ans,t);
		}
	}
	return ans;
}
int main(){
	cin>>n>>s;
	for (int i=0;i<n*2;i++)
	if (s[i]=='a') a[++a[0]]=i+1;
	else b[++b[0]]=i+1;
	a[n+1]=b[n+1]=n*2+1;
	
	for (int i=1;i<=n;i++)
	if (max(a[i],b[i])==i*2) r[++cnt]=i;
	for (int i=1;i<=cnt;i++) f[i]=calc(r[i-1]+1,r[i]);
	for (int i=cnt-1;i;i--) f[i]=max(f[i+1],f[i]+f[i+1]);
	cout<<f[1]<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int K;
  string S;
  cin >> K;
  cin >> S;
  if (S.size() > K) {
    cout << S.substr(0, K) << "...";
  } else {
    cout << S << endl;
  };
  return 0;
};

Measured memory_bytes: 3628