akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

const int MAX_N = 1e6;
ll fac[MAX_N+1], ifac[MAX_N+1], inv[MAX_N+1];

ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n & 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n >>= 1;
    }
    return res;
}

void init(){
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
}

ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

int main(){
    init();
    int N;
    cin >> N;
    //num[i]:=スコアがi以下になるような並べ方の数
    ll ans = 0, num[N];
    //i個のマシンで全てを黒にする場合
    rep(i, N){
        if(2*i < N) {num[i] = 0; continue;}
        num[i] = fac[i]*fac[N-1-i]%MOD;
        num[i] *= comb(i-1, N-i-1), num[i] %= MOD;
        ans = ans+(MOD+num[i]-num[i-1])*i, ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 31488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  int l = 0, r = n - 1;
  int ans = 0;

  while (l < r) {
    if(s[l] == s[r]) {
      l++;
      r--;

    } else if (s[l] == 'x') {
      ans++;
      l++;
    } else if (s[r] == 'x') {
      ans++;
      r--;
    } else {
      puts("-1");
      return 0;
    }
  }

  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto i = 0; i < n; i++)
    {
        int vi;
        cin >> vi;
        v[i] = vi;
    }

    sort(v.begin(), v.end());

    double ans = v[0];

    for (auto i = 1; i < n; i++)
    {
        ans = (ans + v[i]) / 2.0;
    }

    cout << setprecision(16) << ans << endl;
}

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

int n;
ll num[10][10];

int main()
{
    cin >> n;
    for(int i = 0; i <= n; i++)
    {
        string s = to_string(i);
        num[s[0] - '0'][s[s.size() - 1] - '0']++;
    }
    ll res = 0;
    for(int i = 1; i <= 9; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            res += num[i][j] * num[j][i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		System.out.print((char) (a.charAt(0) - 0x20));
		System.out.print((char) (b.charAt(0) - 0x20));
		System.out.print((char) (c.charAt(0) - 0x20));
	}
}

Measured memory_bytes: 23124
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var prexy = 0; var pret = 0;
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var t = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            var y = int.Parse(line[2]);
            var xy = x + y;
            var xymax = prexy + (t - pret);
            var xymin = prexy - (t - pret);
            if (t % 2 == 0 && xy % 2 == 1) { Console.WriteLine("No"); goto end; }
            if (t % 2 == 1 && xy % 2 == 0) { Console.WriteLine("No"); goto end; }
            if (xy > xymax) { Console.WriteLine("No"); goto end; }
            if (xy < xymin) { Console.WriteLine("No"); goto end; }
            prexy = xy;
            pret = t;
        }
        Console.WriteLine("Yes");
        end:;
    }
}

Measured memory_bytes: 17232
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool isC = false,isF = false;
	REP(i,s.size()){
		if(s[i] == 'C')
			isC = true;
		if(s[i] == 'F' && isC)
			isF = true;
	}
	if(isC && isF)cout << "Yes" << endl;
	else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int k=3;
  if(a==b && b==c){
   cout << "1" << endl;
  }
  else{
   if(a!=b && b!=c && c!=a){
    cout << "3" << endl; 
   }
    else{
     cout << "2" << endl; 
    }
  }
  return 0;}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
 public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
   int n=sc.nextInt();
   int a[]=new int[n];
   for(int i=0;i<n;i++)
     a[i]=sc.nextInt();
   int dp[]=new int[n];
   dp[0]=0;
   
   dp[1]=Math.abs(a[1]-a[0]);
   for(int i=2;i<n;i++){
    dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]),dp[i-2]+Math.abs(a[i]-a[i-2]));
   }
    System.out.println(dp[n-1]);
 }
}

Measured memory_bytes: 50940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
ll f[N],g[N],x[N],E,T;
int n;

int main(){
	read(n),read(E),read(T);
	rep(i,1,n)read(x[i]);
	memset(f,0x3f,sizeof f);
	memset(g,0x3f,sizeof g);
	f[0]=0;
	rep(i,1,n){
		int t=lower_bound(x+1,x+n+1,x[i]+(T+1)/2)-x;
//		printf("%d  ->  %d\n",i-1,t);
		g[t]=min(g[t],f[i-1]+x[i]-x[i-1]+3ll*(x[t]-x[i]));
		f[t-1]=min(f[t-1],f[i-1]+x[i]-x[i-1]+T+(x[t-1]-x[i]));
		g[i]=min(g[i],g[i-1]+3ll*(x[i]-x[i-1]));
		f[i]=min(f[i],g[i]);
//		printf("%d   %lld  %lld\n",i,f[i],g[i]);
	}
	printf("%lld\n",f[n]+E-x[n]);
	return 0;
}

Measured memory_bytes: 18304
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    S = lines.pop(0)
    res = 1
    for c in [chr(i) for i in range(97,97+26)]:
        n = S.count(c)
        if n > 0:
            res *= n + 1
    print((res - 1) % 1000000007)


lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3316
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main() {
    ll n;
    ll a[100010];
    ll sum = 0;
    ll count =0;
    ll min_minus =-1000000010;
    ll min_plus = 1000000010;
    bool has_0 = false;
    
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum += (ll)abs(a[i]);
        
        if(a[i]<0){
            count++;
            min_minus = max(min_minus,a[i]);
        }else if(a[i]>0){
            min_plus = min(min_plus,a[i]);
        }else{
            has_0 = true;
        }
    }
    
    if(has_0){
        std::cout << sum << std::endl;
        return 0;
    }
    
    if(count%2==0){
        std::cout << sum << std::endl;
        return 0;
    }else{
        std::cout << sum - (ll)abs(min_plus) - (ll)abs(min_minus) + (ll)abs(min_minus+min_plus) << std::endl;
        
    }
    
}

Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <bitset>
#include <fstream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int res = 0;
    for (int i = 1; i < (int) s.size(); ++i) {
        if (s[i] != s[i - 1]) ++res;
    }
    cout << res << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0, tmp;
	vector<int> v;

	cin>> n;
	v.resize(n+1);

	for(int i=1;i<100;i++){
		for(int j=1;j<100;j++){
			for(int k=1;k<100;k++){
				tmp=i*i+j*j+k*k+i*j+j*k+k*i;
				if(tmp<=n) v[tmp]++;
			}
		}
	}

	for(int i=1;i<=n;i++) cout<< v[i] <<endl;
 
	return 0;
}

Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;
typedef pair<plint, lint> query;

template< typename T >
struct BinaryIndexedTree {
	vector< T > data;

	BinaryIndexedTree(int sz) {
		data.assign(++sz, 0);
	}

	T sum(int k) {
		T ret = 0;
		for (++k; k > 0; k -= k & -k) ret += data[k];
		return (ret);
	}

	void add(int k, T x) {
		for (++k; k < data.size(); k += k & -k) data[k] += x;
	}
};

lint N, Q, L, R;
lint arr[500000];
vector<query> queries;
vector<plint> sec;
lint last[500000];
lint ans[500000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> Q;
	REP(i, N) last[i] = -1;
	REP(i, N) {
		cin >> arr[i]; arr[i]--;
		if (last[arr[i]] != -1) sec.push_back({ last[arr[i]], i });
		last[arr[i]] = i;
	}
	REP(i, Q) {
		cin >> L >> R; L--; R--;
		queries.push_back({ { L, R }, i });
	}
	sort(ALL(queries), greater<query>());
	sort(ALL(sec), greater<plint>());
	BinaryIndexedTree<int> bit(N);
	lint sec_idx = 0;
	REP(i, Q) {
		while (sec_idx < SZ(sec) && queries[i].first.first <= sec[sec_idx].first) {
			bit.add(sec[sec_idx].second, 1);
			sec_idx++;
		}
		lint l = queries[i].first.first, r = queries[i].first.second;
		ans[queries[i].second] = (r - l + 1) - (bit.sum(r));
	}
	REP(i, Q) {
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 40408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		String t=scan.next();
		int count=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)!=t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int main(){
  int N;
  cin >> N;
  string s, t, u;
  cin >> s >> t >> u;
  int result = 0;
  for(int i = 0; i < N; i ++){
  	if ((s[i] != t[i]) && (t[i] != u[i]) && (s[i] != u[i])){
      result += 2;
    }
    else if ((s[i] == t[i]) && (t[i] == u[i])){
      continue;
    }
    else{
      result += 1;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N;
  cin >> N;

  out((N + 1) / 2);
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i32; n],
    }

    let mut dp = [0; 100000];
    dp[0] = 0;

    for i in 1..n {
        let mut min = i32::max_value();
        for j in 1..k+1 {
            if i >= j {
                let tmp = dp[i-j] + (h[i-j]-h[i]).abs();
                if min > tmp {
                    min = tmp;
                }
            }
            dp[i] = min;
        }
    }

    println!("{}", dp[n-1]);
}


Measured memory_bytes: 4732
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,m=MI()
    s=SI()
    dp=[inf]*(n+1)
    dp[0]=0
    pre=[-1]*(n+1)
    q=deque()
    q.append((0,0))
    for i,c in enumerate(s[1:]):
        if q[0][0]==i-m:q.popleft()
        if c=="0":
            dp[i+1]=q[0][1]+1
            pre[i+1]=q[0][0]
        while q and q[-1][1]>dp[i+1]:q.pop()
        q.append((i+1,dp[i+1]))
    if dp[-1]>=inf:print(-1)
    else:
        ans=[]
        now=n
        while n:
            ans.append(n-pre[n])
            n=pre[n]
        print(*ans[::-1])

main()

Measured memory_bytes: 14588
n = gets.to_i
tree = Struct.new(:parent, :sibling, :degree, :depth, :height, :type, :children)
node = Array.new(n) {tree.new}
n.times do
  ar = gets.split.map(&:to_i)
  node[ar[0]].children = a = ar[1..-1].reject {|x| x == -1}
  node[ar[0]].degree = a.size
  node[ar[0]].parent = -1
  node[ar[0]].sibling = -1
  node[ar[0]].type = "internal node"
end

node.each_with_index do |nd, i|
  nd.children.each {|child| node[child].parent = i}
  case nd.degree
  when 0
    nd.type = "leaf"
    nd.height = 0
  when 1
    node[nd.children[0]].sibling = -1
  when 2
    node[nd.children[0]].sibling = nd.children[1]
    node[nd.children[1]].sibling = nd.children[0]
  end
end

root_index = 0
node.each_with_index {|nd, i| root_index = i if nd.parent == -1}
node[root_index].type = "root"

search = ->(index, depth) {
  node[index].depth = depth
  children = node[index].children
  return 0 if children.empty?
  height_max = 0
  children.each do |child|
    h = search.(child, depth + 1) + 1
    height_max = h if h > height_max
  end
  node[index].height = height_max
}
search.(root_index, 0)

node.each_with_index do |nd, i|
  puts "node #{i}: parent = #{nd.parent}, sibling = #{nd.sibling}, degree = #{nd.degree}, depth = #{nd.depth}, height = #{nd.height}, #{nd.type}"
end


Measured memory_bytes: 6896
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	long long int K;
	
	cin >> K;
	
	long long int div = K / 50;
	long long int ret = K % 50;
	
	cout << "50" << endl;
	
	for(int i = 0; i < 50; i++){
		long long int output = div;
		if(i < ret){
			cout << output + 50 - (ret - 1) + 49;
		}else{
			cout << output - ret + 49;
		}
		if(i != 49){
			cout << " ";
		}
	}
	
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int n;
string s;

string dfs(string str)
{
    FOR(i,2,n) {
        int l = str.size();
        str += (str[l-1] == 'S' ^ str[l-2] == 'S' ^ s[l-1] == 'o') ? 'S' : 'W';
    }
    return str;
}

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

    string ans;
    vector<string> vs = {"SS", "SW", "WS", "WW"};
    REP(i,4) {
        ans = dfs(vs[i]);

        bool flag = (ans[0] == 'S' ^ s[0] == 'o' ^ ans[1] == ans[n-1])
                & (ans[n-1] == 'S' ^ s[n-1] == 'o' ^ (ans[0] == ans[n-2]));

        if (flag) {
            cout<<ans<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
    return 0;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  int c[10][10];
  rep(i,0,10){
    rep(j,0,10){
      cin>>c[i][j];
    }
  }
  int d[10][10];
  rep(i,0,10){
    rep(j,0,10){
      d[i][j]=c[i][j];
    }
  }
  rep(k,0,10){
    rep(i,0,10){
      rep(j,0,10){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  
  int a[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
    }
  }
  int ans=0;
  rep(i,0,h){
    rep(j,0,w){
      if(a[i][j]!=-1){
        ans+=d[a[i][j]][1];
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    public void Solve()
    {
        int[] x = LineInt();
        Console.WriteLine((x.Distinct().Count() == 2) ? "Yes" : "No" );
    }
}

public class Prog
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 28244
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
	  
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int[] m = new int[N];
    int total = N;
    int m_total = 0;
    
    for(int i = 0; i < N; i++){
    	m[i] = sc.nextInt();
    	m_total += m[i];
    }
    Arrays.sort(m);
    total += (X - m_total) / m[0];
    
    System.out.println(total);
  }
}

Measured memory_bytes: 21588
N = int(input())
A = list(map(int, input().split()))

Kosui = [0]*N

for i in range(N):
	Kosui[0] += A[i]*(-1)**i

for i in range(N-1):
	Kosui[i+1] = (A[i] - (Kosui[i]//2))*2

print(" ".join(map(str, Kosui)))

Measured memory_bytes: 19180
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2005;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

char s[N];int n,dp[N][N],c[N][N],ans;
inline void upd(int &a,int b){a+=b;if(a>=mod)a-=mod;}
int main()
{
  scanf("%s",s+1);n=strlen(s+1);
  for(int i=0;i<=n;i++)
    for(int j=c[i][0]=1;j<=i;j++)upd(c[i][j]=c[i-1][j],c[i-1][j-1]);
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=0,c=s[i]-48;j<=i;j++){
      if(j>=c-1)upd(dp[i][j],dp[i-1][j-c+1]);
      if(j>=c)upd(dp[i][j],dp[i-1][j-c]);
    }
  for(int i=0;i<=n;i++)upd(ans,1ll*dp[n][i]*c[n][i]%mod);
  printf("%d\n",ans);
  return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int fast_expo(int a , int n){
	if(n == 0)
		return 1;
	if(n == 1){
		return a;
	}
	else if(n%2 == 0){
		int temp = fast_expo(a,n/2);
		return (temp*temp)%mod;
	}
	else{
		return (a*fast_expo(a,n-1))%mod;
	}
}

int32_t main(){
	boost;
    //code
	int n;
	cin >> n;
	int a[n];
	map<int,int> mp;
	for(int i = 0 ; i < n ; ++i){
		cin >> a[i];
		mp[a[i]]++;
	}

	int mx = *max_element(a,a+n);
	int mn = *min_element(a,a+n);

	if(mn >= 0 and mx < n){
		if(n%2){
			if(mp[0] == 1){
				cout << fast_expo(2,n/2);
			}
			else{
				cout << 0;
			}
		}
		else{
			bool flag = true;
			for(int i = 0 ; i < n ; ++i){
				if(mp[a[i]] != 2){
					flag = false;
					break;
				}
			}

			if(flag)
				cout << fast_expo(2,n/2);
			else
				cout << 0;
		}
	}
	else{
		cout << 0;
	}
	return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    double n,m,d; cin >> n >> m >> d;
    double ans;
    if(d==0){
        ans=(m-1)/n;
        cout << setprecision(10) << ans << endl;
    }else{
        ans+=2*(n-d)*(m-1)*1.0/(n*n);
        cout << setprecision(20) << ans << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   string op;
   while(true){
       cin >> a >> op >>b;
       if(op == "?"){
           break;
       }
       else if(op == "+"){
           cout << a+b << endl;
       }
       else if(op == "-"){
           cout << a-b << endl;
       }
       else if(op == "*"){
           cout << a*b << endl;
       }
       else if(op == "/"){
           cout << a/b << endl;
       }
       else{
           
       }
   }
}



Measured memory_bytes: 3112
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = read();
    }
    a.sort();
    println!("{}", a[n-1] - a[0]);
}


Measured memory_bytes: 4352
n = int(input())

m = []

for i in range(n):
    a, b = input().split()
    m.append([a, int(b)])

s = input()

ret = 0
flag = False

for i in range(n):
    if flag:
        ret += m[i][1]
    if m[i][0] == s:
        flag = True

print(ret)


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace question3
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];
            
            for (int i = 0; i < n; i++) {
                a[i] = int.Parse(Console.ReadLine());
            }

            var sortedA = a.ToList().OrderByDescending(e=>e).ToArray();
            var a1 = sortedA[0];
            var a2 = sortedA[1];

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(a[i] == a1 ? a2 : a1);
            }
        }
    }
}


Measured memory_bytes: 25300
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    edge = {}
    edge_order = [0]*(N-1)
    for i in range(N-1):
        a, b = (int(i)-1 for i in input().split())
        G[a].append(b)
        G[b].append(a)
        edge[a*N + b] = -1  # 辺(a,b)の色
        edge_order[i] = a*N + b
    # 辺彩色
    # 最大次数だけ色があればよさそう？
    # BFSで塗っていく
    # ある辺を塗るときに必要なのは，親の辺の色と，同じ親の頂点を持つ
    # 辺のうち彩色済みの色（陽に持たなくてよい）
    max_deg = max(len(G[i]) for i in range(N))

    from collections import deque

    def bfs(s):
        que = deque([])
        par = [-1]*N
        par_color = [-1]*N
        c = 0
        que.append(s)
        while que:
            pos = que.popleft()
            for v in G[pos]:
                if par[pos] == v:
                    continue
                if par_color[pos] == c:
                    c += 1
                    if c == max_deg:
                        c = 0
                if pos < v:
                    edge[pos * N + v] = c
                else:
                    edge[v * N + pos] = c
                par[v] = pos
                par_color[v] = c
                que.append(v)
                c += 1
                if c == max_deg:
                    c = 0

    bfs(0)

    print(max_deg)
    for i in range(N-1):
        print(edge[edge_order[i]] + 1)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

map<string, map<string, int> > mp;

signed main() {
  int n;
  string s;

  cin >> n >> s;

  rep(i, 0, 1 << n) {
    string r = "", b = "";
    rep(j, 0, n) {
      if(i >> j & 1) r += s[j];
      else b = s[j] + b;
    }
    mp[r][b]++;
  }

  int ans = 0;

  rep(i, 0, 1 << n) {
    string r = "", b = "";
    rep(j, 0, n) {
      if(i >> j & 1) r = s[j + n] + r;
      else b += s[j + n];
    }
    ans += mp[r][b];
  }

  cout << ans << endl;
}


Measured memory_bytes: 119552
#include <iostream>                     
#include<string>                        
#include<stack>                         
using namespace std;                    
int main(void){                         
  string s;                             
  cin >> s;                             
  int n = s.size(),ans = 0;             
  int num0 = 0,num1 = 0;                
/*  stack<int> ss;                      
  for(int i =0 ; i < n;++i){            
    int top;                            
    if(!ss.empty()){                    
      top = ss.top();                   
      if(top != (int)s[i]) ans += 2;    
      else{                             
        ss.push(top);                   
        ss.push((int)s[i]);             
      }                                 
    }                                   
    else{                               
      ss.push((int)s[i]);               
    }                                   
  }*/                                   
  for(int i = 0; i < n;++i){            
    if(s[i] == '0') num0++;             
    else  num1++;                       
  }                                     
  if(num0 > num1) ans = 2*num1;         
  else ans = 2 *num0;                   
  cout << ans << endl;                  
  return 0;                             
}                                       

Measured memory_bytes: 512
import numpy as np
h,w=map(int,input().split())
s=[input() for _ in range(h)]
dp=np.zeros((h,w),np.int64)
if s[0][0]=='#':
      dp[0,0]=1
for i in range(h):
  for j in range(w):
    if (i,j)==(0,0):
      continue
    elif i==0:
      if s[i][j-1]=='.' and s[i][j]=='#':
        dp[i,j]=dp[i,j-1]+1
      else:
        dp[i,j]=dp[i,j-1]
    elif j==0:
      if s[i-1][j]=='.' and s[i][j]=='#':
        dp[i,j]=dp[i-1,j]+1
      else:
        dp[i,j]=dp[i-1,j]
    else:
      dp[i,j]=min(dp[i,j-1]+1 if s[i][j-1]=='.' and s[i][j]=='#' else dp[i,j-1],dp[i-1,j]+1 if s[i-1][j]=='.' and s[i][j]=='#' else dp[i-1,j])
print(dp[-1,-1])
#print(dp)

Measured memory_bytes: 13820
/*input
5
1 -2 3 -4 5
*/
#include <bits/stdc++.h>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define sz size
#define pb push_back
#define mp make_pair
using namespace std;

//#define LOCAL
#ifdef LOCAL
	#define DEBUG(x) do { cout << #x << ": " << x << '\n'; } while (0)
#else
	#define DEBUG(x) 
#endif

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

const int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

long long a[200005], ans;
map<long long, long> mapi, ok;

int main(){
	fastIo;

	int n;
	cin >> n;

	long long val;
	for(int i = 1; i <= n; i++){
		cin >> val;
		a[i] = a[i - 1] + val;
		mapi[a[i]]++;
	}
	for(int i = 1; i <= n; i++){
		if(ok[a[i]]) continue;
		ans += (mapi[a[i]] * (mapi[a[i]] - 1)) / 2;
		ok[a[i]] = 1;
	}
	cout << ans + mapi[0] << '\n';

	return 0;
}

Measured memory_bytes: 26880
#include <iostream>
#include <vector>
using namespace std;
const long long mod=1e9+7;
vector<long long> fac(2001);
vector<long long> ifac(2001);

long long mpow(long long x, long long n){
	long long r=1;
	while(n!=0){
		if(n&1){
			r= r*x%mod;
		}
		x=x*x%mod;
		n=n>>1;
	}
	return r;
}

long long comb(long long a, long long b){
	if(a==0 && b==0){
		return 1;
	}
	if(a<b || a<0){
		return 0;
	}
	long long tmp = ifac[a-b] * ifac[b] % mod;
	return tmp * fac[a] % mod;
}

int main(){
	long long n,k,i,j;
	cin >> n >> k;
	fac[0]=1;
	ifac[0]=1;
	for(i=0;i<2000;i++){
		fac[i+1] = fac[i]*(i+1) % mod;
		ifac[i+1] = ifac[i]*mpow(i+1,mod-2) % mod;
	}

	for(i=1; i<=k; i++){
		long long ans;
		long long ab,cd;
		ab=comb(k-1,i-1)%mod;
		cd=comb(n-k+1,i)%mod;
		ans=ab*cd;
		ans%=mod;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, M := ReadInt(), ReadInt()
	if N-1 <= M {
		fmt.Println(0)
		return
	}
	a := ReadInts(N)
	adjL := make([][]int, N)
	for i := 0; i < M; i++ {
		x, y := ReadInt(), ReadInt()
		adjL[x] = append(adjL[x], y)
		adjL[y] = append(adjL[y], x)
	}
	groups := make([][]int, 0)
	seen := make([]bool, N)
	for v := 0; v < N; v++ {
		if !seen[v] {
			group := dfs(adjL, v, seen)
			groups = append(groups, group)
		}
	}

	groupOf := make([]int, N)
	for g, group := range groups {
		for _, v := range group {
			groupOf[v] = g
		}
	}

	nodes := make([]int, N)
	for i := 0; i < N; i++ {
		nodes[i] = i
	}
	sort.Slice(nodes, func(i, j int) bool {
		return a[nodes[i]] < a[nodes[j]]
	})

	selectedGroup := make([]bool, len(groups))
	rest := (N-1-M)*2 - len(groups)
	costs := make([]int, 0)
	for i := 0; i < N; i++ {
		v := nodes[i]
		if !selectedGroup[groupOf[v]] {
			selectedGroup[groupOf[v]] = true
			costs = append(costs, a[v])
			continue
		}
		if rest > 0 {
			costs = append(costs, a[v])
			rest--
			continue
		}
	}
	if rest > 0 {
		fmt.Println("Impossible")
	} else {
		ans := 0
		for _, cost := range costs {
			ans += cost
		}
		fmt.Println(ans)
	}
}

func dfs(adjL [][]int, v int, seen []bool) []int {
	if seen[v] {
		return nil
	}
	seen[v] = true
	ans := []int{v}
	for _, u := range adjL[v] {
		ans = append(ans, dfs(adjL, u, seen)...)
	}
	return ans
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
  
  int pre, last, num = 0;

  cin >> pre >> last;
  
  for (int i = pre; i <= last; i++) {
    string str;
    
    str = to_string(i);
    
    if (str[0] == str[4] && str[1] == str[3]) {
      num++;
    }
  }
  
  cout << num << endl;
  

}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(){
    int X;
    scanf("%d", &X);
    int max = 1;
    for (int i = 2; i*i <= X; ++i){
        for (int j = 2; pow(i, j) <= X; ++j){
            max = pow(i, j)>max ? pow(i, j):max;
        }
    }

    printf("%d", max);

    return 0;
}

Measured memory_bytes: 384
n=int(input())
w=[int(x) for x in input().split()]
s1=0
s2=0
all=[]
for i in range(1,n+1):
	s1=sum(w[:i-1])
	s2=sum(w[i-1:])
	all.append(abs(s1-s2))
	
print(min(all))

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm> 
using namespace std;
int c,ans;
int w[200001];
int k[200001];
int cmp(int a,int b){
	return a>b;
}
int main(){
	int i,j,l1,l2,m,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	scanf("%d",&w[i]);
	k[i]=w[i];
	
	
}
sort(w+1,w+1+n,cmp);
for(i=1;i<=n;i++){
if(k[i]<w[n/2])printf("%d\n",w[n/2]);
else printf("%d\n",w[n/2+1]);
}
		return 0;
	}



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

int main(){
  int a;
  int b;
  cin >> a >> b;
  if(-1<(a-b) && 1>(a-b)){
    cout << a+b;
  }
  else if(-1>=(a-b) || 1<=(a-b)){
    if(a>b){
      cout << a+a-1;
    }
    else if(b>=a){
      cout << b+b-1;
    }
  }
}

    


Measured memory_bytes: 256
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
using namespace std;
const int MAX=1e6+5,mod=1e9+7;
int n;
int f[MAX];
int main()
{
	scanf("%d",&n),f[n]=n,f[n-1]=1ll*n*n%mod;
	for(int i=n-2,sum=0;i>=1;--i)
	  (sum+=f[i+3])%=mod,(f[i]+=((1ll*(n-1)*(n-1)%mod+f[i+1])%mod+i+1+sum)%mod)%=mod;
	return printf("%d",f[1]),0;
}

Measured memory_bytes: 4096
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#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__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  forn(i,n) cin >> a[i];
  int ans = 1e9;
  rep(i,1,101){
    int cur = 0;
    forn(j,n){
      cur += (a[j] - i) * (a[j] - i);
    }
    setmin(ans, cur);
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int n,ans=0;
	long long d,p,q;
	scanf("%d%lld",&n,&d);
	d=d*d;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&p,&q);
		if(q*q+p*p<=d){
			ans++;
		} 
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void) {
	int a, b, c;
	while (cin >> a >> b >> c && (a != -1 || b != -1 || c != -1)) {
		if (a == -1 || b == -1) {
			cout << "F";
		}
		else if (a + b < 30) {
			cout << "F";
		}
		else if (a + b < 50) {
			if (c >= 50) {
				cout << "C";
			}
			else {
				cout << "D";
			}
		}
		else if (a + b < 65) {
			cout << "C";
		}
		else if (a + b < 80) {
			cout << "B";
		}
		else {
			cout << "A";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int n,m;
    cin>>n>>m;
    Graph G(3*n);
    rep(i,m){
        int u,v;
        cin>>u>>v;
        u--;v--;
        G[3*u].push_back(3*v+1);
        G[3*u+1].push_back(3*v+2);
        G[3*u+2].push_back(3*v);
    }
    int s,t;
    cin>>s>>t;
    s--;t--;
    V<int> dist(3*n,-1);
    queue<int> que;
    dist[3*s]=0;
    que.push(3*s);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(int nv:G[v]){
            if(dist[nv]!=-1) continue;
            dist[nv]=dist[v]+1;
            que.push(nv);
        }
    }
    int d=dist[3*t];
    if(d==-1||d%3!=0) cout<<-1<<endl;
    else cout<<d/3<<endl;
}


Measured memory_bytes: 17792
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int ca=0,cb=0,co=0,cab=0;
        while(sc.hasNext()){
            String str[]=sc.next().split(",");
            if(str[1].equals("A")){
                ca++;
            }
            if(str[1].equals("B")){
                cb++;
            }
            if(str[1].equals("O")){
                co++;
            }
            if(str[1].equals("AB")){
                cab++;
            }
        }
        System.out.printf("%d\n%d\n%d\n%d\n",ca,cb,cab,co);
    }
 
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

// 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;
//const int mod = 998244353;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void) {
  int n; cin >> n;
  mint ten = 10;
  mint nine = 9;
  mint eight = 8;
  mint ans = ten.pow(n);
  ans -= nine.pow(n);
  ans -= nine.pow(n);
  ans += eight.pow(n);
  pl(ans)
  return 0;
}


Measured memory_bytes: 3560