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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){


  ll n, x;
  cin >> n >> x;

  while(n != 0){
    ll ans = 0;
    REP(i, 1, n-1) REP(j, i+1, n) REP(k, j+1, n+1){
      if (i==j || j==k || i==k) continue;
      if (i+j+k == x) ans++;
    }

    cout << ans << endl;

    // 次の入力
    cin >> n >> x;
  }


}


Measured memory_bytes: 3136
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,m; R(n,m);
    VPII AA;
    REP(i,n){
        int x,y; R(x,y);
        AA.PB({x,y});
    }
    sort(ALL(AA));
    LL an=0;
    REP(i,n){
        LL v=min(m,AA[i].S);
        m-=v;
        an+=v*AA[i].F;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 1400
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        while (true) {
            StringBuilder sb = new StringBuilder(sc.next());
            if (sb.toString().equals("-"))  break;
            int m = Integer.parseInt(sc.next());
            for (int i=0; i<m; i++) {
                int n = Integer.parseInt(sc.next());
                sb = sb.append(sb.substring(0, n));
                sb.delete(0, n);
            }
            out.println(sb);
        }
        
        out.flush();
    }
}


Measured memory_bytes: 26388
#include<iostream>
using namespace std;
#define INF (int)1e9 + 7
int main() {
    int n;
    cin >> n;
    int Min = INF, Max = 1;
    while (n--) {
        int a;
        cin >> a;
        Min = Min > a ? a : Min;
        Max = Max < a ? a : Max;
    }
    cout << Max - Min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int N, K, S[200200], E[200200], Z[200200], B[200200];
vector<int> V[200200], I[200200];

void go(int x, int l)
{
	S[x] = ++K;
	for (auto &y : V[x]) if (y != l){
		go(y, x);
	}
	E[x] = K;
	Z[x] = E[x] - S[x] + 1;
}

void push(int x, int p)
{
	while (x <= N){
		B[x] += p;
		x += x & (-x);
	}
}

int pop(int x)
{
	int r = 0;
	while (x){
		r += B[x];
		x -= x & (-x);
	}
	return r;
}

int range(int x)
{
	return pop(E[x]) - pop(S[x] - 1);
}

int main()
{
	scanf ("%d", &N);
	for (int i = 1, c; i <= N; i++){
		scanf ("%d", &c);
		I[c].push_back(i);
	}
	for (int i = 1; i < N; i++){
		int x, y; scanf ("%d %d", &x, &y);
		V[x].push_back(y);
		V[y].push_back(x);
	}
	go(1, 0);

	for (int c = 1; c <= N; c++){
		long long ans = 1ll * N * (N + 1) / 2;

		sort(I[c].begin(), I[c].end(), [&](int x, int y){return S[x] > S[y]; });
		vector<pair<int, int> > q;
		for (int x : I[c]){
			int e = 1;
			for (int y : V[x]) if (S[x] < S[y]){
				int z = Z[y] - range(y);
				ans -= 1ll * z * (z + 1) / 2;
				e += z;
			}
			push(S[x], e);
			q.push_back({ S[x], e });
		}

		int z = N - range(1);
		ans -= 1ll * z * (z + 1) / 2;
		for (auto &p : q) push(p.first, -p.second);
		printf ("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 38344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    vector<char>vec(26);
    vec={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    vector<int>vec2(26,0);
   
 
    for(int i=0;i<S.size();i++){
        for(int j=0;j<26;j++){
        if(S.at(i)==vec.at(j)){
            vec2.at(j)++;
          }
        }
    }
    for(int i=0;i<26;i++){
     if(vec2.at(i)==0){
         cout << vec.at(i)<<endl;
         return 0;
      }
    }
    cout <<"None"<<endl;

}

Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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

using pint = pair<int,int>;
int n;
vector<int> v;

int main() {
    while (cin >> n) {
        v.resize(n);
        for (int i = 0; i < n; ++i) cin >> v[i];
        
        map<int,int> odd, even;
        for (int i = 0; i < n; ++i) {
            if (i & 1) odd[v[i]]++;
            else even[v[i]]++;
        }
        vector<pair<int,int> > vodd, veven;
        for (auto it = odd.begin(); it != odd.end(); ++it) {
            vodd.push_back(pint(it->second, it->first));
        }
        for (auto it = even.begin(); it != even.end(); ++it) {
            veven.push_back(pint(it->second, it->first));
        }
        sort(vodd.begin(), vodd.end()); reverse(vodd.begin(), vodd.end());
        sort(veven.begin(), veven.end()); reverse(veven.begin(), veven.end());
        
        int res = max(vodd[0].first, veven[0].first);
        if ((vodd.size() == 1 || vodd[0].first > vodd[1].first) &&
            (veven.size() == 1 || veven[0].first > veven[1].first) &&
            (vodd[0].second == veven[0].second))
        {
            // odd max
            if (even.size() > 1) chmax(res, vodd[0].first + veven[1].first);
            
            // even max
            if (odd.size() > 1) chmax(res, vodd[1].first + veven[0].first);
        }
        else {
            chmax(res, vodd[0].first + veven[0].first);
        }
        
        cout << n - res << endl;
    }
}





























Measured memory_bytes: 6520
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem171c(n))
}

fun problem171c(n: Long): String {
    val alphabets = arrayOf(
        "z",
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"
    )
    var n = n
    var ans = ""
    while (true) {
        ans = alphabets[(n % 26).toInt()] + ans
        if (n % 26 == 0L) n--
        if (n / 26 == 0L) break
        n /= 26L
    }
    return ans
}

Measured memory_bytes: 36168
N=int(input())
S=[]
for i in range(N):
    S.append(input())

print('AC x {}'.format(S.count('AC')))
print('WA x {}'.format(S.count('WA')))
print('TLE x {}'.format(S.count('TLE')))
print('RE x {}'.format(S.count('RE')))

Measured memory_bytes: 16232
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_char0(const void *a, const void *b) {
  return *(char *)a - *(char *)b;
}
int compare_char1(const void *a, const void *b) {
  return *(char *)b - *(char *)a;
}

int main()
{
    char s[101],t[101],mini = 26,maxi = 0;
    int len[2],i,j;

    scanf("%s %s",s,t);

    len[0] = strlen(s);
    qsort(s,len[0],sizeof(char),compare_char0);
    len[1] = strlen(t);
    qsort(t,len[1],sizeof(char),compare_char1);

    if(strcmp(s,t) < 0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    printf("\n");
}

Measured memory_bytes: 128
#include<stdio.h>

int F(int);
int Fib[45];
int main()
{
  int n,i;
  for(i=0;i<45;i++)Fib[i]=0;
  scanf("%d",&n);
  printf("%d\n",F(n));
  return 0;
}

int F(int n)
{
  if(n==0||n==1)return Fib[n]=1;
  if(Fib[n]!=0)return Fib[n];
  return Fib[n]=F(n-1)+F(n-2);
}
  



Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define PI acos(-1)
int main(){
int n;
cin>>n;
vector<int>in(n);
long long int sum=0;
rep(i,n){cin>>in[i];sum+=in[i];}
sort(in.begin(),in.end());
cout<<in[0]<<" "<<in[n-1]<<" "<<sum<<endl;
}

Measured memory_bytes: 1256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int retSolve;

int dfs(vector<vector<int>> field, int turn, int sx, int sy) {
    if (turn > 10) return 0;

    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    for (int i = 0; i < 4; i++) {
        vector<vector<int>> tmpField = field;
        int nx = dx[i] + sx;
        int ny = dy[i] + sy;
        if (tmpField[ny][nx] == 1 || tmpField[ny][nx] == 4) continue;
        int nnx = dx[i] + nx;
        int nny = dy[i] + ny;
        for (;;) {
            if (tmpField[ny][nx] == 4) break;
            if (tmpField[ny][nx] == 3) {
                retSolve = min(retSolve, turn);
                break;
            }
            if (tmpField[nny][nnx] == 1) {
                tmpField[sy][sx] = 0;
                tmpField[ny][nx] = 2;
                tmpField[nny][nnx] = 0;
                dfs(tmpField, turn+1, nx, ny);
                break;
            }
            nx = nnx;
            ny = nny;
            nnx += dx[i];
            nny += dy[i];
        }
    }
    return 0;
}

int solve(int W, int H) {
    int const INF = 15;
    retSolve = INF;
    vector<vector<int>> field(H+2, vector<int>(W+2, 4));
    int sx, sy;
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            cin >> field[h][w];
            if (field[h][w] == 2) {
                sx = w;
                sy = h;
            }
        }
    }
    dfs(field, 1, sx, sy);
    if (retSolve == INF) return -1;
    else return retSolve;
}

int main(void) {
    int W, H;
    vector<int> ans;
    while (1) {
        cin >> W >> H;
        if (!W && !H) break;
        ans.push_back(solve(W, H));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl a(n);
  map<ll,ll> m;
  set<pll> s;
  REP(i,n) {
    ll ai;
    cin >> ai;
    a[i] = -ai;
    m.insert(make_pair(-ai,0));
  }
  REP(i,n){
    auto it = s.upper_bound(make_pair(a[i],m[a[i]]));
    if(it!=s.end()){
      s.erase(it);
    }
    s.insert(make_pair(a[i],m[a[i]]++));
  }

  cout << s.size() << endl;
  return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public void Calc()
        {
            var s = Console.ReadLine();

            Console.WriteLine(s == "ARC" ? "ABC" : "ARC");

            //var p = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            //var A = p[0];
            //var B = p[1];
            //var N = p[2];
            //long ans = 0;
            //if (B > N)
            //{
            //    ans = (long)Math.Floor((double)A * N / B) - A * (long)Math.Floor((double)N / B);
            //}
            //else
            //{
            //    ans = (long)Math.Floor((double)A * (B - 1) / B) - A * (long)Math.Floor((double)(B - 1) / B);
            //}

            ////var max = 0;
            ////for (var x = 1; x <= N; x++)
            ////{
            ////    var ans = Math.Floor((double)A * x / B) - A * Math.Floor((double)x / B);
            ////    max = Math.Max((int)ans, max);
            ////}

            //Console.WriteLine(ans);

        }


    }
    public static class Combination
    {
        public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition = false)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return new T[] { item };
                yield break;
            }
            foreach (var item in items)
            {
                var leftside = new T[] { item };

                // item よりも前のものを除く （順列と組み合わせの違い)
                // 重複を許さないので、unusedから item そのものも取り除く
                var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).ToList();

                foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
                {
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}


Measured memory_bytes: 25896
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 10){
    x = r * x - d;
    cout << x << endl;
  }
  
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a+b, min(b+c, c+a)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;

	int n;
	cin>>n;
	vector<LL> x(n),y(n);
	FOR(i,0,n)cin>>x[i]>>y[i];
	vector<pll> xy(n);
	FOR(i,0,n){
		xy[i]=MP(x[i],y[i]);
	}
	sort(xy.begin(),xy.end());
	LL ans=0;
	FOR(i,0,n){
		FOR(j,i+1,n){
			LL p=xy[j].ST-xy[i].ST,q=xy[j].ND-xy[i].ND;
			LL cnt=0;
			vector<int> used(n,0);
			FOR(k,0,n){
				LL nx=xy[k].ST,ny=xy[k].ND;
				if(used[k])continue;
				used[k]=1;
				FOR(kk,k+1,n){
					LL tx=xy[kk].ST,ty=xy[kk].ND;
					if(tx-nx==p&&ty-ny==q){
						used[kk]=1;
						cnt++;
						nx=tx,ny=ty;
					}
				}
			}
			//cerr<<p<<" "<<q<<" "<<cnt<<endl;
			ans=max(ans,cnt);
		}
	}
	cout<<n-ans<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 <<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(s.front() != 'B' || s.back() != 'B'){
    cout << 0 << endl;
    return 0;
  }
  vector<bool> b(2*n);
  b.at(0) = false;
  int fc = 1, tc = 0;
  rep2(i, 1, s.size()){
    if(s.at(i) == s.at(i-1))b.at(i) = !b.at(i-1);
    else b.at(i) = b.at(i-1);
    if(b.at(i) == false) fc++;
    else tc++;
  }
  if(fc != tc){
    cout << 0 << endl;
    return 0;
  }

  // rep(i, n*2){
  //   cerr << b.at(i) << " ";
  // }
  // cerr << endl;
  int c = 0;
  mint ans = 1;
  rep(i, n*2){
    if(b.at(i) == false) c++;
    else{
      ans *= c;
      c--;
    }
  }

  mint fac = 1;
  rep(i, n){
    fac *= (i+1);
  }
  ans *= fac;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace  std;

llint h, w;
char c[2005][2005];
llint l[2005][2005], r[2005][2005];
llint d[2005][2005], u[2005][2005];

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

  cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	for(int y = 1; y <= h; y++){
		llint cnt = 0;
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			l[x][y] = cnt;
		}
		cnt = 0;
		for(int x = w; x >= 1; x--){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			r[x][y] = cnt;
		}
	}
	for(int x = 1; x <= w; x++){
		llint cnt = 0;
		for(int y = 1; y <= h; y++){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			d[x][y] = cnt;
		}
		cnt = 0;
		for(int y = h; y >= 1; y--){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			u[x][y] = cnt;
		}
	}

	llint ans = 0;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '.') ans = max(ans, l[x][y]+r[x][y]+d[x][y]+u[x][y]-3);
		}
	}
	cout << ans << endl;

  return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x;
        int y;
        String op;
        ArrayList<Integer> answer = new ArrayList<Integer>();

        while(true){
            x = sc.nextInt();
            op = sc.next();
            y = sc.nextInt();
            if(op.equals("?")) break;

            if(op.equals("+")) answer.add(x + y);
            else if(op.equals("-")) answer.add(x - y);
            else if(op.equals("*")) answer.add(x * y);
            else if(op.equals("/")) answer.add(x / y);
        }

        for(int i = 0; i < answer.size(); i++){
            System.out.println(answer.get(i));
        }

        sc.close();
    }
}


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

using namespace std;

typedef long long ll;

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= mod) return a - mod;
  if (a < 0) return a + mod;
  return a;
}

int mul(int a, int b) {
  return a * (ll) b % mod;
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return mul(a, pw(b, mod - 2));
}

int f(int a, int b) {
  int r = 1;
  for (int i = a; i <= b; i++)
    r = mul(r, i);
  return r;
}

int co(int n, int a) {
  int up = f(n - a + 1, n), down = f(1, a);
  return dv(up, down);
}

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

  int n, a, b;
  cin >> n >> a >> b;
  int sol = pw(2, n);
  sol = add(sol, -1);
  sol = add(sol, -co(n, a));
  sol = add(sol, -co(n, b));
  cout << sol << "\n";
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

count = 0
ans = 0
for i in a:
	if x >= i:
		x = x - i
		ans += 1
	else:
		break
else:
	if x:
		ans -= 1

print(ans)


Measured memory_bytes: 3060
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()

M = 998244353
B = pow(10, 18, M)
N = int(input())

def geometric_mod(a, r, m, n):
  x = a
  for i in range(n):
    yield x
    x = (x*r)%m

BB = list(geometric_mod(1, B, M, N+2))

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
      sum_g[g[i]] = (sum_g[g[i]] + BB[i]) % M
      sum_g[0]  = (sum_g[0] - BB[i]) % M

  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = (ret + sx*sy*sz) % M
  return ret


edge = [read_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 65256
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [0 for _ in range(k + 1)]
	for i in range(1, k + 1):
		for num in A:
			if i - num < 0:
				continue
			if dp[i]: 
				break
			if not dp[i-num]: 
				dp[i] = 1
	print("First" if dp[-1] else "Second")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 44912
#include <iostream>

#define MAX_N 123456

using namespace std;

int main() {
	int prime[MAX_N*2+1];
	fill(&prime[0], &prime[0]+MAX_N*2+1, 1);

	for (int i = 2; i <= MAX_N*2; ++i) {
		for (int j = i*2; j <= MAX_N*2; j += i) {
			prime[j] = 0;
		}
	}

	for (int i = 0; i < MAX_N*2; ++i) {
		prime[i+1] += prime[i];
	}

	int n;
	while ( cin >> n, n ) {
		cout << prime[2*n] - prime[n] << endl;
	}
}

Measured memory_bytes: 2124
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int[] point = new int[6];
		Scanner scan = new Scanner(System.in);
		
		for(int i=0; i<6;i++){
			point[i] = scan.nextInt();
		}
		Dice dice = new Dice(point);
		char[] m = scan.next().toCharArray();
		scan.close();
		
		for(int i=0;i<m.length;i++){
			dice.Move(m[i]);
		}
		System.out.println(dice.T);
	}
}

class Dice {
	int T,F,R,L,B,D;

	public Dice(int[] point){
		this.T=point[0];
		this.F=point[1];
		this.R=point[2];
		this.L=point[3];
		this.B=point[4];
		this.D=point[5];
	}
	public void Move(char move){
		int temp;
		switch(move){
			case 'E':
				temp=this.D;
				this.D=this.R;
				this.R=this.T;
				this.T=this.L;
				this.L=temp;
				break;
			case 'S':
				temp=this.D;
				this.D=this.F;
				this.F=this.T;
				this.T=this.B;
				this.B=temp;
				break;
			case 'W':
				temp=this.D;
				this.D=this.L;
				this.L=this.T;
				this.T=this.R;
				this.R=temp;
				break;
			case 'N':
				temp=this.D;
				this.D=this.B;
				this.B=this.T;
				this.T=this.F;
				this.F=temp;
				break;
		}
	}
}


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

using namespace std;
using ll = long long int;

int main(){
    int N;
    cin>>N;
    vector<int> a(N),b(N),c(N);
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    vector<vector<ll>> sum(N);
    for(int i=0;i<N;i++) sum[i].resize(3);
    for(int i=0;i<N;i++){
        if(i==0){
            sum[i][0]=a[0];
            sum[i][1]=b[0];
            sum[i][2]=c[0];
        }
        else{
            sum[i][0]=a[i]+max(sum[i-1][1],sum[i-1][2]);
            sum[i][1]=b[i]+max(sum[i-1][0],sum[i-1][2]);
            sum[i][2]=c[i]+max(sum[i-1][1],sum[i-1][0]);
        }
    }
    
    cout<<max(sum[N-1][0],max(sum[N-1][1],sum[N-1][2]))<<endl;
    
    return 0;
}




Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
using namespace std;

bool shelf[20012][2];
int dp[10012][3];
const int INF = 1000000;

int table[3][3][4] = {
  {
    {0, 1, 3, 3},
    {1, 1, 2, 2},
    {2, 2, 2, 2},
  },
  {
    {1, 1, 3, 2},
    {0, 1, 1, 2},
    {1, 3, 1, 2},
  },
  {
    {2, 2, 2, 2},
    {1, 2, 1, 2},
    {0, 3, 1, 3},
  },
};

int main()
{
  int T; cin >> T;
  while (T--) {
    memset(shelf, false, sizeof(shelf));
    
    int N; cin >> N;
    for (int i = 0; i < 4*N; ++i) {
      char ch; cin >> ch;
      int y = (i < 2*N);
      int x = (i < 2*N) ? (i + 1) : (i - 2*N + 1);
      shelf[x][y] = (ch == 'Y');
    }

    dp[0][0] = 0;
    dp[0][1] = dp[0][2] = INF;
    
    for (int x = 1; x <= N+1; ++x) {
      int state = (shelf[2*(x-1)][0] | shelf[2*(x-1)+1][0]) * 2
                + (shelf[2*(x-1)][1] | shelf[2*(x-1)+1][1]);
      for (int out = 0; out < 3; ++out) {
        dp[x][out] = INF;
        for (int in = 0; in < 3; ++in) {
          dp[x][out] = min(dp[x][out], dp[x-1][in] + table[in][out][state]);
        }
      }
    }

    cout << dp[N+1][0] + N << endl;
  }
}

Measured memory_bytes: 0
N, M = map(int, input().split())
X = [-1] * (N + 1)
flag = False
for i in range(M):
    s, c = map(int, input().split())
    if X[s] == -1:
        X[s] = c
    else:
        if c != X[s]:
            flag = True

X = X[1:]
if len(X) > 1 and X[0] == 0:
    flag = True

if flag:
    print(-1)
else:
    if len(X) > 1 and X[0] == -1:
        X[0] = 1
    X = [('0' if i == -1 else str(i)) for i in X]
    print(''.join(X))


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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

int a[1000001], b[1000001];

int gcd(int a, int b) {
	if(a<b) {
		swap(a,b);
	}
	if(a%b==0) {
		return b;
	}

	return gcd(b, a%b);
}

void decrypt() {
	fl(i,0,1000001) {
		a[i]= b[i] = 0;
	}

	vector<int> vec;
	a[0] = 0;
	a[1] = 1; a[2] = 0;
	fl(i,2,1000001) {
		if(a[i]==0) {
			for(int j=i;j<1000001;j+=i) {
				a[j] = i;
			}
		}
	}
	int n, flag, tmp, tmp2;
	cin>>n;
	flag = 0;
	fl(i,0,n) {
		cin>>tmp;
		vec.pb(tmp);
		while(tmp>1) {
			tmp2 = a[tmp];
			b[tmp2]++;
			while(tmp%tmp2==0) tmp /=tmp2;
			if(b[tmp2]>1) {
				flag = 1;
				break;
			}
		}
	}
	int div = vec[0];
	fl(i,1,n) {
		div = gcd(div, vec[i]);
	}
	if(flag==0) {
		cout<<"pairwise coprime\n";
	}else if(div==1) {
		cout<<"setwise coprime\n";
	} else {
		cout<<"not coprime\n";
	}

	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 15236
n,m=map(int,input().split())
li=[]
for i in range(m):
    li.append(int(input()))

def convi(li):
    m=max(li)
    a=[1,1]
    if m>2:
        for i in range(2,m+1):
            a.append(a[i-2]+a[i-1])
            
    ans=1    
    for j in li:
        ans=ans*a[j-1]%1000000007
    return ans

def count(li,n):
    t=1
    ans=1
    li2=[]
    li.append(n+1)
    if len(li)>0:
        for i in range(len(li)):
            
            if i>0:
                li2.append(li[i]-li[i-1]-1)
                if li[i]-li[i-1]==1 and i<len(li):
                    return 0
            else:
                li2.append(li[i])
                
    #print(li2)      
    return convi(li2)
                

print(count(li,n)%1000000007)   


Measured memory_bytes: 471944
#include<algorithm>
#include<iostream>
using namespace std;
int n,m,o,ans,dp[55],a[55],b[55],c[55],d[55];
int shu() 
{
    int sum=0;
    for(int i=1;i<=o;i++) 
	{
        if(dp[b[i]]-dp[a[i]]==c[i]) 
		{
            sum+=d[i];
        }
    }
    return sum;
}
void dfs(int temp) 
{
    if(temp>n) 
	{
        ans=max(ans,shu());
        return;
    }
    for(int i=dp[temp-1];i<=m;i++) 
	{
        dp[temp]=i;
        dfs(temp+1);
    }
}

int main() 
{
    cin>>n>>m>>o;
    for(int i=1;i<=o;i++) 
	{
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dp[0]=1;
    dfs(1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
import java.io.*;
class Main
{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));			   
String[] strs=br.readLine().trim().split("\\s+");     
  int h,a;
  h=Integer.parseInt(strs[0]);
  a=Integer.parseInt(strs[1]);
  if(h%a==0)
    System.out.println(h/a);
  else
    System.out.println((h/a)+1);
}
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 there(int64 x) {
  int64 l = -1001, r = 1001, m = 0;
  while (r - l > 1) {
    m = (l + r) / 2;
    if (m * m * m * m * m <= x) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 X;
	cin >> X;
	for (int64 i = -1000; i <= 1000; i++) {
	  int64 rest = X + i*i*i*i*i;
	  int64 a = there(rest);
	  if (a*a*a*a*a == rest) {
	    cout << a << " " << i << endl;
	    return 0;
	  }
	}
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string s;
  cin >> s;
  char a = s[0];
  char b = s[3];
  bool f = false;
  if(a == s[1] && a == s[2]) f = true;
  if(b == s[1] && b == s[2]) f = true;
  yorn(f);
  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

ans = [-1, -1, -1]
for i in range(N+1):
    for j in range(N+1-i):
        if 10000*i + 5000*j + 1000*(N-(i+j)) == Y:
            ans = [i, j, N-(i+j)]
            break
    else:
        continue
    break

print(str(ans[0]) + ' ' + str(ans[1]) + ' ' + str(ans[2]))

Measured memory_bytes: 3064
n= int(input())
x= list(map(int,input().split()))
m= sum(x)/len(x)
g= int(m)
ans=0
if m-g<g+1-m:
  ans=g
else:
  ans=g+1
aaa=0
for i in x:
  aaa+= (ans-i)**2
print(aaa)

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> p(N);
    map<pair<int, int>, int> mp;
    rep(i, N) cin >> p[i].first >> p[i].second;

    rep(i, N) {
        rep(j, N) {
            if (i == j)
                continue;
            int dx = p[i].first - p[j].first;
            int dy = p[i].second - p[j].second;
            mp[{dx, dy}]++;
        }
    }

    int ans = N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (auto e : mp) {
        ans = min(ans, N - e.second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int a,s,d[1000][1000],f,g,h,i,j;
int main(void)
{
    scanf("%d %d",&a,&s);
    for(i=0;i<a;i++){
        for(j=0;j<s;j++)
            scanf("%d",&d[i][j]);
    }
    for(i=0;i<a;i++){
        for(j=0;j<s;j++)
            d[i][s]+=d[i][j];
            d[a][s]+=d[i][j];
    }
    for(i=0;i<s;i++){
        for(j=0;j<a;j++)
            d[a][i]+=d[j][i];   
    }
    for(i=0;i<=a;i++){
        for(j=0;j<=s;j++){
            printf("%d",d[i][j]);
            if(s!=j){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

struct edge
{
  ll to;
  ll cost;
  edge() {}
  edge(ll to, ll cost) : to(to), cost(cost){};
};

vector<ll> dijkstra(ll s, vector<vector<edge>> &g)
{
  //pair.first=距離,pair.second=点
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
  vector<ll> dist(g.size(), INF);
  dist[s]=0;
  q.push({0, s});

  while (!q.empty())
  {
    pair<ll, ll> p = q.top();
    q.pop();
    ll v = p.second; 
    if (dist[v] < p.first)
      continue; 
    rep(i, g[v].size())
    {
      edge e = g[v][i];
      if (dist[e.to] > dist[v] + e.cost)
      {
        dist[e.to] = dist[v] + e.cost;
        q.push({dist[e.to], e.to});
      }
    }
  }
  return dist;
}

int main()
{
ll n,m,r;
cin >> n >> m >> r ;
vector<vector<edge>> g(n);
rep(i, m)
{
    ll a,b,c;
    cin >> a>>b>>c;
    g[a].emplace_back(b, c);
}

vector<ll> ans=dijkstra(r,g);
for (int i = 0; i < ans.size(); ++i) {
    if(ans[i]<INF/2)cout << ans[i] << endl;
    else cout << "INF" << endl;
}
return 0;
}



Measured memory_bytes: 19312
#include <stdio.h>

int main(void)
{
	int a, b, c, d, max;
  
  scanf("%d%d%d%d", &a, &b, &c, &d);

  max = a*b;
  if (c*d>max) max = c*d;
  
  printf("%d\n", max);
  
  return 0;
  
}

Measured memory_bytes: 128
#include <iostream>

#define Nmax int(1e5 + 1)
using namespace std;

char s[Nmax];
int N,Q,L,R,M;
int a[Nmax],b[Nmax];

int main() {
    cin >> N >> Q;
    cin >> (s + 1);
    for(int i = 1; s[i]; ++i)
        if(s[i] == 'C' && s[i - 1] == 'A')
            a[i] = a[i - 1] + 1;
        else
            a[i] = a[i - 1];
    for(; Q; --Q) {
        cin >> L >> R;
        b[++M] = a[R] - a[L];
    }
    for(int i = 1; i <= M; ++i)
        cout << b[i] << '\n';
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
int main()
{
fast_io
li n,k;
cin>>n>>k;
if(n%k==0)
cout<<"0";
else
{
  li x=n/k;
  li mi=abs(n-x*k);
  x++;
  mi=min(mi,abs(n-x*k));
  cout<<mi;
}
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
int n;
std::vector<int> a;
std::cin >> n;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    a.push_back(temp);
}
std::vector<int> checkf(100001,0);
std::vector<int> checks(100001,0);
int sum = 0;
int fchar = a[0];
int schar = a[1];
int first = 1;
int second = 1;
int maxfirst = 0;
int maxsecond = 0;
int mfchar = a[0];
int mschar = a[1];

int premaxf = a[0];
int premaxs = a[1];
int pf = 1;
int ps = 1;
int ppremaxf = a[0];
int ppremaxs = a[1];
int ppf = 1;
int pps = 1;
for(int i = 0; i < n; i++){
    if(i % 2 == 0){
        checkf[a[i]]++;
    } else {
        checks[a[i]]++;
    }
}
for(int i = 0;i < 100001; i++){
    if(checkf[i] != 0 && maxfirst == 0){
        pf = checkf[i];
        premaxf = i;
        maxfirst = checkf[i];
        mfchar = i;
        continue;
    }
    if(checks[i] != 0 && maxsecond == 0){
        ps = checks[i];
        premaxs = i;
        maxsecond = checks[i];
        mschar = i; 
        continue;
    }
    if(maxfirst <= checkf[i]){
        pf = maxfirst;
        premaxf = mfchar;
        maxfirst = checkf[i];
        mfchar = i;
    } else if(pf <= checkf[i]){
        pf = checkf[i];
        premaxf = i;
    } 
    if(maxsecond <= checks[i]){
        ps = maxsecond;
        premaxs = mschar;
        maxsecond = checks[i];
        mschar = i; 
    } else if(ps <= checks[i]){
        ps = checks[i];
        premaxs = i;
    } 
}
if(mfchar == mschar){
    if(mfchar == premaxf && mschar == premaxs){
        std::cout << n - maxfirst << std::endl;
    } else {
    if(mfchar == premaxf){
        
        std::cout << n - (maxfirst + ps) << std::endl;
    } else if(mschar == premaxs){

        std::cout << n - (pf + maxsecond) << std::endl;
    } else if(pf + maxsecond > ps + maxfirst){

        std::cout << n - (pf + maxsecond) << std::endl;
    } else {
        std::cout << n - (maxfirst + ps) << std::endl;

    }
    }
} else {
    std::cout << n - (maxfirst + maxsecond) << std::endl;
}
return 0;
}


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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, b, ans = 0;
  //string s;
  cin >> n;
  vector<int> a(n);
  //if(1) {}
  //((a == b)? "Yes" : "No")
  rep(i, n) cin >> a.at(i);
  sort(all(a));
  for(int i = 1; i < n; i++) {
    if(a.at(i) == a.at(i - 1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    F0R(i,n) cin >> a[i];
    sort(a,a+n);
    cout << abs(a[0] - a[n-1]) << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256