akhauriyash/Code-Regression huggingface dataset:
a, b, k = map(int, input().split())

if k - a > 0:
  k -= a
  a = 0
  if k - b > 0:
    b = 0
    print(str(a) + " " + str(b))
  else:
    b -= k
    print(str(a) + " " + str(b))
else:
  a -= k
  print(str(a) + " " + str(b))

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

using namespace std;

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

int main(){
    vector<int> data(3);
    REP(i,3){
        cin>>data[i];
    }
    sort(ALL(data));
    cout<<data[0]+data[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

double t,e,p;
ll K;

double dfs(ll d,double l,double r){
    if(t-e<=l && r<=t+e){return 1;}
    if(r<t-e || t+e<l){return 0;}
    if(d==K){
        return (abs((l+r)/2-t)<=e?1:0);
    }
    if((l+r)/2>=t){
        return dfs(d+1,l,(l+r)/2.0)*(1.0-p)+dfs(d+1,(l+r)/2.0,r)*p;
    }
    return dfs(d+1,l,(l+r)/2.0)*p+dfs(d+1,(l+r)/2.0,r)*(1.0-p);
}



int main(){
    double l,r;
    cin>>K>>l>>r>>p>>e>>t;
    cout<<fixed<<setprecision(12)<<dfs(0,l,r)<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3284
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    k = 1
    ans = 0
    for i in range(n):
        if a[i] != k:
            ans += 1
        else:
            k += 1
    if k == 1:
        print(-1)
        return
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 71500
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    while (cin >> n && n){
        int ans = 0;
        FOR(i,1,n){
            int x = i;
            while (x > 0 && x % 5 == 0){
                ans++;
                x /= 5;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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 V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, M;
    cin >> N >> M;
    vector<vector<int>> job(100010);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        job[a].push_back(b);
    }
    priority_queue<int> que;
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 0; j < job[i].size(); j++) {
            que.push(job[i][j]);
        }
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;cin>>s;
    ll ans = 700;
    for(auto &ele:s)if(ele=='o')ans+=100;
    cout<<ans;
}


Measured memory_bytes: 256
# [input]
# n = int(input())
# (string) s = input()
# a, b, c = map(int, input().split())
# h = list(map(int, input().split()))

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    if v[i] - c[i] > 0 :
        ans += v[i] - c[i]
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;

map<string,char> n;
map<char,string> m;

void init1(){
  m[' '] = "101";
  m['\''] = "000000";
  m[','] = "000011";
  m['-'] = "10010001";
  m['.'] = "010001";
  m['?'] = "000001";
  m['A'] = "100101";
  m['B'] = "10011010";
  m['C'] = "0101";
  m['D'] = "0001";
  m['E'] = "110";
  m['F'] = "01001";
  m['G'] = "10011011";
  m['H'] = "010000";
  m['I'] = "0111";
  m['J'] = "10011000";
  m['K'] = "0110";
  m['L'] = "00100";
  m['M'] = "10011001";
  m['N'] = "10011110";
  m['O'] = "00101";
  m['P'] = "111";
  m['Q'] = "10011111";
  m['R'] = "1000";
  m['S'] = "00110";
  m['T'] = "00111";
  m['U'] = "10011100";
  m['V'] = "10011101";
  m['W'] = "000010";
  m['X'] = "10010010";
  m['Y'] = "10010011";
  m['Z'] = "10010000";
}

void init2(){
  n["00000"] = 'A';
  n["00001"] = 'B';
  n["00010"] = 'C';
  n["00011"] = 'D';
  n["00100"] = 'E';
  n["00101"] = 'F';
  n["00110"] = 'G';
  n["00111"] = 'H';
  n["01000"] = 'I';
  n["01001"] = 'J';
  n["01010"] = 'K';
  n["01011"] = 'L';
  n["01100"] = 'M';
  n["01101"] = 'N';
  n["01110"] = 'O';
  n["01111"] = 'P';
  n["10000"] = 'Q';
  n["10001"] = 'R';
  n["10010"] = 'S';
  n["10011"] = 'T';
  n["10100"] = 'U';
  n["10101"] = 'V';
  n["10110"] = 'W';
  n["10111"] = 'X';
  n["11000"] = 'Y';
  n["11001"] = 'Z';
  n["11010"] = ' ';
  n["11011"] = '.';
  n["11100"] = ',';
  n["11101"] = '-';
  n["11110"] = '\'';
  n["11111"] = '?';
}

int main(){
  string str;

  init1();
  init2();

  while(getline(cin,str)){
    string s = "";
    for(int i = 0 ; i < (int)str.size() ; i++){
      s += m[str[i]];
    }
    
    if((int)s.size() % 5){
      for(int i = 0 ; i < (int)s.size() % 5 ; i++){
	s += '0';
      }
    }
    
    string ans = "";
    for(int i = 0 ; i < (int)s.size() ; i+=5){
      ans += n[s.substr(i,5)];
    }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1220
import static java.lang.Math.*;

import java.util.*;

public class Main {
    int dx[] = { 0, 1, 0, -1 };
    int dy[] = { 1, 0, -1, 0 };
    char dr[] = "DLUR".toCharArray();

    private class Point {
        long x, y, len;
        boolean isOdd;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
            this.len = abs(x) + abs(y);
            this.isOdd = (x + y) % 2 == 0;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        Point p[] = new Point[n];
        BitSet bs = new BitSet();
        long max = 0;

        for (int i = 0; i < n; i++) {
            p[i] = new Point(sc.nextInt(), sc.nextInt());
            if (p[i].isOdd) {
                bs.set(i);
            }
            max = max(max, p[i].len);
        }
        sc.close();

        if (bs.cardinality() > 0 && bs.cardinality() < n) {
            System.out.println(-1);
            return;
        }

        boolean isOdd = bs.cardinality() == n;
        if (isOdd) {
            for (int i = 0; i < n; i++) {
                p[i].x--;
            }
        }

        int m = 0;
        for (; max > 0; m++) {
            max /= 2;
        }
        long l[] = new long[m];
        for (int i = 0; i < m; i++) {
            l[i] = 1L << i;
        }
        System.out.println(m + (isOdd ? 1 : 0));
        System.out.println((isOdd ? "1 " : "") + Arrays.toString(l).replaceAll("[^0-9 ]+", ""));

        for (int i = 0; i < n; i++) {
            char move[] = new char[m];
            long nx = p[i].x;
            long ny = p[i].y;

            for (int j = m - 1; j >= 0; j--) {
                for (int k = 0; k < 4; k++) {
                    if (check(nx + l[j] * dx[k], ny + l[j] * dy[k], l[j])) {
                        nx += l[j] * dx[k];
                        ny += l[j] * dy[k];
                        move[j] = dr[k];
                        break;
                    }
                }
            }

            if (isOdd) {
                System.out.print("R");
            }
            System.out.println(new String(move));
        }
    }

    private boolean check(long x, long y, long range) {
        return abs(x) + abs(y) <= (range - 1);
    }

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


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A <= C && B <= D){
    cout << max(B-C,0) << endl;
  }else if(A <= C && D <= B){
    cout << D-C << endl;
  }else if(C <= A && B <= D){
    cout << B-A << endl;
  }else if(C <= A && D <= B){
    cout << max(D-A,0) << endl;
  }
}

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

typedef struct{
		int i,pre,ans;
		long year;
} prefecture;

int cmp_year( const void *p, const void *q ) {
    return ((prefecture*)p)->year - ((prefecture*)q)->year;
}

int cmp_i( const void *p, const void *q ) {
    return ((prefecture*)p)->i - ((prefecture*)q)->i;
}



int main(){
	int n,m,i,j,ban[100000]={0};
	int ans[100000][2];
	scanf("%d%d",&n,&m);
	prefecture p[m];
	for(i=0;i<m;i++){
		scanf("%d%ld",&p[i].pre,&p[i].year);
		p[i].i=i;
		ans[i][0]=p[i].pre;
	}
	qsort(p,m,sizeof(prefecture),cmp_year);	
	for(i=0;i<m;i++){
//		printf("%ld\n",y[i]);
/*		for(j=0;j<m;j++){
			if(ycpy[j]==y[i]){
				ban[p[j]-1]++;
				ans[j][1]=ban[p[j]-1];
			}
		}*/
		ban[p[i].pre-1]++;
		p[i].ans=ban[p[i].pre-1];
	}qsort(p,m,sizeof(prefecture),cmp_i);	
	for(i=0;i<m;i++)printf("%06d%06d\n",ans[i][0],p[i].ans);
	return 0;
}


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

int main() {
	int h,w,i,j;
	cin >> h >> w;
	char c;
	vector<vector<int>> s(h+2,vector<int>(w+2,0));
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			cin >> c;
			if(c=='#'){
				s[i+1][j+1]=1;
			}
		}
	}
	for(i=1; i<=h; i++){
		for(j=1; j<=w; j++){
			if(s[i][j]==1){
				cout << '#';
			}else{
				cout << s[i-1][j-1]+s[i-1][j]+s[i-1][j+1]+s[i][j-1]+s[i][j+1]+s[i+1][j-1]+s[i+1][j]+s[i+1][j+1];
			}
			
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split());mod=998244353;base=[]
for i in range(N):
    A=input().split();s=sum(int(A[j])*2**j for j in range(M))
    for b in base:s=min(s,s^b)
    if s!=0:base.append(s)
res=N-len(base);print((pow(2,N+M-1,mod)-pow(2,M-1+res,mod))%mod)

Measured memory_bytes: 3064
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

K = ni()

e, o = 0, 0
ans = 0
for i in range(1, K + 1):
    if i % 2 == 0:
        e += 1
        ans += o
    elif i % 2 == 1:
        o += 1
        ans += e

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    bool good = false;
    for(int i = 0; i < s.size() - 1; ++i) {
        good |= (s[i] == s[i + 1]);
    }
    cout << (good ? "Bad" : "Good") << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

ans = sum(b)

for i in range(n-1):
    if a[i+1] == a[i] + 1:
        ans += c[a[i]-1]

print(ans)


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

const int MAXN = 100005;
int n, a[MAXN], K;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> K;
	int pos;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] == 1) pos = i;
	}
	int ans = n;
	auto div_up = [](int a, int b) {
		return a/b+(a%b!=0);
	};
	for (int i = 1; i <= pos && i+K-1 <= n; i++)
		if (i+K-1 >= pos)
			ans = min(ans, div_up(i-1, K-1)+div_up(n-(i+K-1), K-1)+1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
'use strict'

function main() {
  let input = require('fs').readFileSync('/dev/stdin', 'utf8');
  input = input.trim().split(/\s+/).map(x => x - 0);
  
  const N = input.shift();
  let list = input;
  list.sort((a, b) => b - a);
  
  let result = 0;
  for(let i = 0; i < list.length; i++) {
    if(i % 2 == 0) {
      result += list[i];
    } else {
      result -= list[i];
    }
  }
  
  console.log(result);
}

main();



Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		int side1, side2, angle;
		double area, around, height, rad;
		
		side1 = scan.nextInt();
		side2 = scan.nextInt();
		angle = scan.nextInt();
		rad = Math.toRadians(angle);
		
		
		area = (side1 * side2 * Math.sin(rad)) / 2;
		around = side1 + side2 +
				Math.sqrt(Math.pow(side1, 2) + Math.pow(side2, 2) - 
						(2 * side1 * side2 * Math.cos(rad)));
		height = side2 * Math.sin(rad);
		
		System.out.println(area);
		System.out.println(around);
		System.out.println(height);
		
		scan.close();
	}
}



Measured memory_bytes: 26404
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul  unsigned long long int
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod
//ll divide(ll a, ll b)  //euler's theorem(a/b)%mod
//{
//   return a*power(b,mod-2)%mod;  //only when mod is prime
//}

ll power(ll x, ll y)
{
    ll res = 1;
   while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
int main()
{
    speed;
    int n;
    cin>>n;
    ll a[4][n+1];
    for(int i=1;i<=n;i++) cin>>a[1][i]>>a[2][i]>>a[3][i];
	ll dp[4][n+1];
	dp[1][1]=a[1][1];
	dp[2][1]=a[2][1];
	dp[3][1]=a[3][1];
	for(int i=2;i<=n;i++)
	{
		dp[1][i]=a[1][i]+max(dp[2][i-1],dp[3][i-1]);
		dp[2][i]=a[2][i]+max(dp[1][i-1],dp[3][i-1]);
		dp[3][i]=a[3][i]+max(dp[2][i-1],dp[1][i-1]);
	}
	cout<<max(dp[1][n],max(dp[2][n],dp[3][n]))<<'\n';
	return 0;
}


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

int main(){
	int n,m;
	cin>>n>>m;
	int a[100][100]={0};
	int b[100]={0};
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		cin>>b[i];	
	}
	for(int i=0;i<n;i++){
		int last=0;
		for(int j=0;j<m;j++){
			last+=a[i][j]*b[j];
		}
		cout<<last<<endl;
	}
}


Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

inline ll cal(ll x) {
    ll res = 0;
    while (x % 2 == 0) {
        res++;
        x /= 2;
    }
    return res;
}

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    ll s = 1;
    ll cnt = 0;
    rep(i, 0, n) {
        cin >> a[i];
        b[i] = a[i] / 2LL;
    }
    cnt = cal(b[0]);
    rep(i, 0, n) {
        if (cnt != cal(b[i])) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i, 0, n) s = s * b[i] / __gcd(s, b[i]);

    cout << max(0LL, (m + s) / (s * 2)) << endl;

    return 0;
}


Measured memory_bytes: 1792
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, m, pen[MAXN];
bool f[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int u;
        string v;
        cin >> u >> v;
        if (v == "WA") {
            if (!f[u]) pen[u]++;
        }
        else {
            if (!f[u]) f[u] = true;
        }
    }
    int res = 0, num = 0;
    FOR(i,1,n)
        if (f[i]) {
            res += pen[i];
            num++;
        }
    cout << num << ' ' << res;
    return 0;
}


Measured memory_bytes: 768
import itertools

N = int(input())
C = [1 if x == 'W' else 0 for x in input()]

rcount = C.count(0)
ans = rcount
W_acc = itertools.accumulate(C)
R_count = C.count(0)
for i, c in enumerate(W_acc, 1):
    ans = min(ans, abs(rcount - i) + c)
print(ans)


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> v(n);
	int sum=0;
	
	for(int i=0; i<n; i++)
	{
		cin>>v[i];
		sum+=v[i];
	}
	
	int t=round(double(sum)/double(n));
	int r=0;
	for(int i=0; i<n; i++)
	{
		int w=v[i]-t;
		r+=w*w;
	}
	
	cout<<r<< endl; 
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int H,W,a;
    a = 1;
    while(a == 1){
        cin >>H >>W;
        if(H == 0 & W == 0) break;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                cout <<"#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,w; cin>>h>>w;
  ll n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  
  ll now=1;
  vvll ans(h, vll(w));
  rep(i,h){
    
    rep(j,w){
      
      if(i%2==0){
        ans[i][j]=now;
      }else{
        ans[i][w-1-j]=now;
      }
      
      a[now-1]--;
      if(a[now-1]==0) now++;
    }
  }
  
  rep(i,h){
    rep(j,w){
      cout<<ans[i][j]<<' ';
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 3716
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS

main :: IO ()
main = do
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- VU.map pred . unsafeTextToVectorInt <$> T.getLine :: IO (VU.Vector Int)
  let
    (start, period) = go 0 0 IMS.empty :: (Int, Int)
      where
        go :: Int -> Int -> IntMap Int -> (Int, Int)
        go l i m | Just s <- IMS.lookup i m = (s, l - s)
                 | otherwise               = go (succ l) (as VU.! i) (IMS.insert i l m)
    pos :: Int -> Int
    pos = go 0
      where
        go :: Int -> Int -> Int
        go i 0 = i
        go i l = go (as VU.! i) (pred l)
  print . succ . pos $ if k < start then k else start + (k - start) `mod` period

unsafeTextToVectorInt :: T.Text -> VU.Vector Int
unsafeTextToVectorInt = VU.unfoldr next
  where
    next :: T.Text -> Maybe (Int, T.Text)
    next s | T.null s  = Nothing
           | otherwise = Just . either undefined (T.stripStart <$>) . T.signed T.decimal $ s
{-# INLINE unsafeTextToVectorInt #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 45164
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
	fast;ll t1;t1=1;
	while(t1--)
	{
		ll ans,a,i;
		string s;
		cin>>s;
		ans=0;
		a=0;
		for(i=0;i<3;i++){
			if(s[i]=='R'){a++;}
			else{ans=max(ans,a);a=0;}
		}
		ans=max(ans,a);
		cout<<ans;
	}
}

Measured memory_bytes: 3648
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	v := -a + b
	if k%2 == 0 {
		v = a - b
	}
	if v < -1000000000000000000 || 1000000000000000000 < v {
		fmt.Println("Unfair")
		return
	}
	fmt.Println(v)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <queue>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

using TUP = tuple<int, int, int>;

const vector<int> dr = {1, 0, -1, 0};
const vector<int> dc = {0, 1, 0, -1};

int h, w;
vector<string> maze;

void show(VVI &vv) {
	for (auto v: vv) {
		for (auto x: v) {
			printf("%2d ", x);
		}
		printf("\n");
	}
}

bool can_go(int row, int col) {
	bool inside = (0 <= row && row < h && 0 <= col && col < w);
	if (!inside) {
		return false;
	}

	return maze[row][col] == '.';
}

int main() {
	int ch, cw, dh, dw;
	cin >> h >> w;
	cin >> ch >> cw >> dh >> dw;
	ch--;
	cw--;
	dh--;
	dw--;

	maze.assign(h, "");
	for (int i = 0; i < h; i++) {
		cin >> maze[i];
	}

	priority_queue<TUP, vector<TUP>, greater<TUP>> que;
	que.emplace(0, ch, cw);

	VVI n_magic(h, vector<int>(w, -1));

	int ans = -1;
	int cnt, row, col;
	while (!que.empty()) {
		tie(cnt, row, col) = que.top();
		que.pop();

		if (n_magic[row][col] != -1) {
			continue;
		}

// printf("%d %d %d: %d\n", cnt, row, col, n_magic[row][col]);

		n_magic[row][col] = cnt;
		if (row == dh && col == dw) {
			ans = cnt;
			break;
		}

		int nr, nc;
		for (int i = 0; i <= 4; i++) {
			nr = row + dr[i];
			nc = col + dc[i];
			if (can_go(nr, nc) && n_magic[nr][nc] == -1) {
				que.emplace(cnt, nr, nc);
			}
		}

		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				nr = row + i;
				nc = col + j;

				if (can_go(nr, nc) && n_magic[nr][nc] == -1) {
					que.emplace(cnt+1, nr, nc);
				}
			}
		}
	}

	cout << ans << endl;
	// show(n_magic);
	return 0;
}


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

#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,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int t = 0;
	REP(j, INF) {
		if (t % 60 == 0 && j != 0) {
			cout << -1 << endl;
			return 0;
		}
		REP(i, a) {

			if (t % 60 == c) {
				cout << t << endl;
				return 0;
			}
			t++;
		}
		if (t % 60 == c) {
			cout << t << endl;
			return 0;
		}
		t += b;

	}
	return 0;
}

Measured memory_bytes: 3212
n = int(input())
card_list = list(map(int,input().split()))
alice_score = 0
bob_score = 0
card_list.sort(reverse = True)
for i in range(0,n):
    if i % 2 == 0:
        alice_score += card_list[i]
    else:
        bob_score += card_list[i]
        
print(alice_score - bob_score)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  char c[2][3];
  cin >> c[0][0] >> c[0][1] >> c[0][2] >> c[1][0] >> c[1][1] >> c[1][2] ;
  if((c[0][0]==c[1][2])&&(c[1][0]==c[0][2])&&(c[0][1]==c[1][1])){
    cout << "YES";
  }else {
    cout <<"NO";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
ll power(ll a,ll n)
{
    ll p;
    if(n==0)
    {
        return 1;
    }
    p=power(a,n/2);
    p=((p%mod)*(p%mod))%mod;
    if(n%2==1)
    {
        p=(p%mod)*(a%mod);
    }
    return p;
}
int main()
{
    fastIO;
    ll a,b,c;
    cin>>a>>b;
    c=a*b;
    if(a==1 || b==1)
    {
        cout<<1;
    }
    else
    {
        cout<<(c+1)/2<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

struct edge{ll to; ll cost;};
vector<edge> tree[200000];
ll depth[200000];

void dfs(ll v,ll p,ll d){
  depth[v] = d;
  for( edge &e: tree[v]){
    if( e.to==p){ continue;}
    else{ dfs(e.to, v, d+e.cost); }
  }
}

int main(){
  ll N; cin>>N;
  REP(i,N-1){
    ll a,b,c; cin>>a>>b>>c;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }
  ll Q,K; cin>>Q>>K;
  dfs(K,-1,0);
  
  REP(i,Q){
    ll x,y; cin>>x>>y;
    cout << depth[x] + depth[y] <<"\n";
  }
}


Measured memory_bytes: 16640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, H, W;
  while (cin >> N >> H >> W) {
    int res = (N - H + 1) * (N - W + 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    int a, b;

    cin >> n >> m;

    vector<int> ans(n);

    for (int i = 0; i < m; i++) {
        cin >> a >> b;

        ans.at(a - 1)++;
        ans.at(b - 1)++;
    }

    for (int i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
    
}

Measured memory_bytes: 3600
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <numeric>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define rng mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count())

#define ri(...) i64 __VA_ARGS__; rx(__VA_ARGS__)
#define rc(...) char __VA_ARGS__; rx(__VA_ARGS__)
#define rs(...) string __VA_ARGS__; rx(__VA_ARGS__)
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << '[' << #__VA_ARGS__ << "]: "; dbg_log(__VA_ARGS__)
#else
#define dbg(...) ;;
#endif

#define fa(i, v) for (auto &i : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(i) ri(_i); fi(i, _i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#ifdef __SIZEOF_INT128__
typedef __uint128_t u128;
typedef __int128_t i128;
#endif
typedef vector<i64> vi;
typedef vector<vi> vvi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) out << x << ' ';
    return out;
}

template<typename T>
inline void rx(T &x) {
    cin >> x;
}

template<typename T, typename... R>
inline void rx(T &x, R &... l) {
    cin >> x;
    rx(l...);
}

template<typename T>
inline void dbg_log(const T &x) {
    cerr << x << '\n';
}

template<typename T, typename... R>
inline void dbg_log(const T &x, const R &... l) {
    cerr << x << ", ";
    dbg_log(l...);
}

template<typename T>
inline void wl(const T &x) {
    cout << x << '\n';
}

template<typename T, typename... R>
inline void wl(const T &x, const R &... l) {
    cout << x << ' ';
    wl<R...>(l...);
}

int main() {
    fio;

    ri(n, m, k);
    vvi a(n, vi(m));
    fi(t, k) {
        ri(i, j, x);
        a[--i][--j] = x;
    }

    typedef i64 Q;
    vector<vector<vector<Q>>> dp(n, vector<vector<Q>>(m, vector<Q>(4)));
    fi(i, n) {
        fi(j, m) {
            fi(u, 4) {
                dp[i][j][u] = max(
                        max(
                                (i > 0 ? dp[i - 1][j][3] : 0) + (u > 0 ? a[i][j] : 0),
                                j > 0 && u > 0 ? dp[i][j - 1][u - 1] + a[i][j] : 0
                        ), max(
                                j > 0 ? dp[i][j - 1][u] : 0,
                                u > 0 ? dp[i][j][u - 1] : 0
                        )
                );
            }
        }
    }
    wl(dp[n - 1][m - 1][3]);

    return 0;
}


Measured memory_bytes: 706680
n,x,y=map(int,input().split())

x-=1
y-=1

dist=[0 for i in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    dist[min(j-i,abs(x-i)+1+abs(j-y))]+=1

for i in dist[1:]:
  print(i)

Measured memory_bytes: 3444
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, 100005) dp[i] = 1e9;
	dp[0] = 0;
	vi pos = {1};
	int num = 6;
	while(num < 100000) pos.pb(num), num *= 6;
	num = 9;
	while(num < 100000) pos.pb(num), num *= 9;
	rep(i, pos.size()){
		for(int j = pos[i]; j <= n; j++) dp[j] = min(dp[j], dp[j - pos[i]] + 1);
	}
	cout << dp[n] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 998244353;

fn main() {
    input! {
        n: usize,
        s: usize,
        a: [usize; n],
    }
    let mut dp = vec![0usize; s + 1];
    dp[0] = 1;
    for i in 0..n {
        let ai = a[i];
        for j in (0..=s).rev() {
            if j >= ai {
                dp[j] = (dp[j - ai] + 2 * dp[j]) % M;
            } else {
                dp[j] = (2 * dp[j]) % M;
            }
        }
    }
    // for i in 1..=n {
    //     eprintln!("{:?}", dp[i]);
    // }
    println!("{}", dp[s]);
}


Measured memory_bytes: 2244
#include <iostream>
#include <string>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
  return 0;
}

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

int main(){

  int a=0,b=0,c=0,t=0;
  cin>>a >>b >>c;

  if(a>b){
    t=a;
    a=b;
    b=t;
    t=0;
  }
  if(a>c){
    t=a;
    a=c;
    c=t;
    t=0;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  if(a>c){
    t=a;
    a=c;
    c=t;
    t=0;
  }
  if(a>b){
    t=a;
    a=b;
    b=t;
    t=0;
  }
  if(b>c){
    t=b;
    b=c;
    c=t;
  }
  cout<<a <<" " <<b <<" " <<c <<endl;
  return 0;
}

Measured memory_bytes: 1168
n=int(input())
s=input()

r=s.count('R')
g=s.count('G')
b=s.count('B')

ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k<n:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans-=1

print(ans)


Measured memory_bytes: 73540
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    ll dp[n][n+1];
    memset(dp,0,sizeof(dp));
    rep(i,0,n-1)dp[0][i]=1;
    rep(i,0,n-2){
        rep(j,0,n-1){
            if(s[i]=='>'){
                dp[i+1][0]+=dp[i][j];
                dp[i+1][j]-=dp[i][j];
            }else{
                dp[i+1][j]+=dp[i][j];
                dp[i+1][n-i-1]-=dp[i][j];
            }
        }
        rep(j,1,n)Add(dp[i+1][j],dp[i+1][j-1]);
    }
    /*
    rep(i,0,n-1){
        rep(j,0,n-1)cout<<dp[i][j]<<" ";cout<<endl;
    }*/
    cout<<mod(dp[n-1][0])<<endl;
    
    return 0;
}


Measured memory_bytes: 70656
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long int lli;
typedef pair<int,int> mp;
typedef pair<int,mp> mmp;
#define fir first
#define sec second



int prim(int n,vector<mp>* vs,int s=0){
	vector<int> gone(n,0);
	priority_queue<mp,vector<mp>,greater<mp> > que;
	gone[s]=1;
	rep(i,vs[s].size()){
		int to=vs[s][i].fir,
			co=vs[s][i].sec;
		que.push(mp(co,to));
	}
	
	int res=0;
	while(!que.empty()){
		mp pa=que.top();
		que.pop();
		int no=pa.sec,
			co=pa.fir;
		if(gone[no]==0){
			gone[no]=1;
			res+=co;
			rep(i,vs[no].size()){
				int to=vs[no][i].fir,
					tc=vs[no][i].sec;
				if(gone[to]==1)continue;
				que.push(mp(tc,to));
			}
		}
	}
	return res;
}


	


	
int n,m;

vector<mp> vs[10005];


//vector<mmp> es;


int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		vs[a].push_back(mp(b,c));
		vs[b].push_back(mp(a,c));
		//es.push_back(mmp(c,mp(a,b)));
	}
	printf("%d\n",prim(n,vs));
	return 0;
}

Measured memory_bytes: 4868
#include <iostream>
#include <map>
using namespace std;
int main(){
    int n;
    cin>>n;
    int counter=0;
    string x;
    //string y[];
    map <string,int> y;
    for(int i=0;i<n;i++){
        cin>>x;
        y[x];
        
    }
    //counter=y.size();
    cout<<y.size()<<endl;
    
    
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
		return 0;
	}
	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
ll h,n;
cin>>h>>n;
ll arr[n],brr[n];
rep(i,0,n)
cin>>arr[i]>>brr[i];
ll dp[h+1];
rep(i,0,h+1)
dp[i]=1e9;
dp[0]=0;
ll x,y;
y=1e7;
rep(i,0,n)
{
	if(brr[i]<y)
	{
		y=brr[i];
		x=arr[i];
	}
}//cout<<x<<" "<<y<<endl;
for(ll i=1;i<=min(h,x);i++)
dp[i]=y;
//cout<<x<<" "<<y<<endl;
for(ll i=x+1;i<=h;i++)
{
	for(ll j=0;j<n;j++)
	{
		ll z=max(0ll,i-arr[j]);
		if(dp[z]+brr[j]<dp[i])
		dp[i]=dp[z]+brr[j];
	}
}
cout<<dp[h];

}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  cout << C <<" " << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int N;cin >> N;
    vector<int> A,B;
    for(int a= 0;a < N+1;a++){
        int b;cin >> b;
        A.push_back(b);
    }
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        B.push_back(b);
    }
    LL ans = 0;
    for(int a = 0;a < N;a++){
        if(B.at(a) >= A.at(a)){
            ans += A.at(a);
            B.at(a) -= A.at(a);
            A.at(a) = 0;
        }else{
            ans += B.at(a);
            A.at(a) -= B.at(a);
            B.at(a) = 0;
        }
        if(B.at(a) >= A.at(a+1)){
            ans += A.at(a+1);
            B.at(a) -= A.at(a+1);
            A.at(a+1) = 0;
        }else{
            ans += B.at(a);
            A.at(a+1) -= B.at(a);
            B.at(a) = 0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
n=int(input())
if n<2:print(1)
else:
  l=[2]
  L=[1]
  for i in range(3,n+1):
    c=0
    for j in range(len(l)):
      if i%l[j]==0:
        c+=1
        while i%l[j]==0:
          i=int(i/l[j])
          L[j]+=1
    if c==0:
      l.append(i)
      L.append(1)
  ans=1
  for k in range(len(L)):
    ans*=(L[k]+1)
    ans=ans%(10**9+7)
  print(ans)

Measured memory_bytes: 3064
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [h1,m1,h2,m2,k] = nexts(5);
  m1 += h1 * 60;
  m2 += h2 * 60;
  return m2-m1-k;
}

Measured memory_bytes: 29648