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

int main()
{
	char b;
	cin >> b;
	switch(b){
		case 'A': cout << 'T' << endl; break;
		case 'T': cout << 'A' << endl; break;
		case 'G': cout << 'C' << endl; break;
		case 'C': cout << 'G' << endl; break;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
score = {"taro": 0, "hanako": 0}
for _ in range(n):
    t, h = input().split()
    if t > h:
        score["taro"] += 3
    elif t < h:
        score["hanako"] += 3
    else:
        for player in score.keys():
            score[player] += 1
print(score["taro"], score["hanako"])



Measured memory_bytes: 5604
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> paint(H+2, vector<char> (W+2, '.'));
  for(int i = 1; i <= H; i++){
     for(int j = 1; j <= W; j++){
      char s;
      cin >> s;
      paint[i][j] = s;
    }
  }
  
  bool x = true;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(paint[i][j] == '#'){
        if(paint[i-1][j]=='.' && paint[i+1][j]=='.' && paint[i][j-1]=='.' && paint[i][j+1]=='.'){
          x = false;
        }
      }
    }
  }
  
  if(x) cout << "Yes" << endl;
  else cout << "No" << endl;
}
     
      

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)

sum_a = 0
sum_b = 0
cnt_a = 0
cnt_b = 0
n.times do |i|
  if a[i] < b[i] then
    cnt_a += ((b[i] - a[i]) / 2.0).ceil
  else
    cnt_b += (a[i] - b[i])
  end
  sum_a += a[i]
  sum_b += b[i]
end
d = sum_b - sum_a
if d < 0 then
  puts "No"
elsif cnt_a > d || cnt_b > d then
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 3068
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;


struct UnionFind {
    UnionFind(int n) :parent(n), rank(n, 0), nums(n, 1), groupnum(n) {
        iota(parent.begin(), parent.end(), 0);
    }
    int find(int a) {
        return parent[a] == a ? a : (parent[a] = find(parent[a]));
    }
    bool same(int a, int b) {
        return find(a) == find(b);
    }
    void unite(int a, int b) {
        a = find(a), b = find(b);
        if (a == b)
            return;
        groupnum--;
        if (rank[a] < rank[b]) {
            parent[a] = b;
            nums[b] += nums[a];
        }
        else {
            parent[b] = a;
            nums[a] += nums[b];
            if (rank[a] == rank[b])
                rank[a]++;
        }
    }
    int group_count() {
        return groupnum;
    }
    int get_group_size(int i) {
        return nums[find(i)];
    }
    vector<int> parent;
    vector<int> rank;
    vector<int> nums;
    int groupnum;
};

struct Edge {
    int from;
    int to;
    int cost;
};
bool pred(const Edge &lhs, const Edge &rhs) {
    return lhs.cost > rhs.cost;
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> x(n), y(n);
    rep(i, 0, n) {
        cin >> x[i].first >> y[i].first;
        x[i].second = y[i].second = i;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    priority_queue<Edge, vector<Edge>, decltype(&pred)> edges(pred);

    rep(i, 0, n-1) {
        edges.push({ x[i + 1].second, x[i].second, x[i + 1].first - x[i].first });
        edges.push({ y[i + 1].second, y[i].second, y[i + 1].first - y[i].first });
    }
    UnionFind uf(n);
    long long now = 0;
    int cnt = 0;
    while(cnt < n-1) {
        auto t = edges.top();
        edges.pop();
        if (uf.same(t.from, t.to))
            continue;

        uf.unite(t.from, t.to);
        now += t.cost;
        cnt++;
    }

    cout << now << endl;


    return 0;
}

Measured memory_bytes: 6388
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	s := sc.Text()
	e := strings.Split(s, " ")
	a, _ := strconv.Atoi(e[0])
	b, _ := strconv.Atoi(e[1])
	c, _ := strconv.Atoi(e[2])

	for i := a; i <= a*b; i += a {
		if i%b == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


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

int main(){
	string s[3];
	cin >> s[0];
	cin >> s[1];
	cin >> s[2];
	cout << s[0][0] << s[1][1] << s[2][2] << endl;
}

Measured memory_bytes: 256
// Problem : B - Trick or Treat
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

    
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
using namespace std;
int main()
{
	fast;
		ll n,k;
	
		cin>>n>>k;
		ll dp[n+5]={0};
		while(k--)
		{
			ll d;
			cin>>d;
			ll a[d];
			for(int i=0;i<d;i++)
			{
				cin>>a[d];
				//cout<<a[d]<<endl;
				dp[a[d]]++;
			}
			
		}
			ll count=0;
			for(int i=1;i<=n;i++)
			{
				if(dp[i]==0)
				count++;
			}
			cout<<count<<endl;
		
}






Measured memory_bytes: 3648
// Problem : D - Decrease (Contestant ver.)
// Contest : AtCoder Regular Contest 079
// URL : https://atcoder.jp/contests/arc079/tasks/arc079_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n = 50;
ll k, kn, a[N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> k;
	kn = k / n;
	for (int i = 1; i <= n; i++) {
		a[i] = i + kn - 1;
	}
	kn = k % n;
	for (int i = n; i >= n - kn + 1; i--) {
		a[i]++;
	}
	cout << n << '\n';
	for (int i = 1; i <= n; i++) {
		cout << a[i] << ' ';
	}
}


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

#define max(a, b) (a > b ? a : b)
#define max_3(a, b, c) max(a, max(b, c))

int main() {
	
	int A, B;
	cin >> A >> B;
	cout << max_3(A + B, A - B, A*B);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    string ans = "";
    rep(i, dy) ans += 'U';
    rep(i, dx) ans += 'R';
    rep(i, dy) ans += 'D';
    rep(i, dx) ans += 'L';
    ans += 'L';
    rep(i, dy+1) ans += 'U';
    rep(i, dx+1) ans += 'R';
    ans += 'D';
    ans += 'R';
    rep(i, dy+1) ans += 'D';
    rep(i, dx+1) ans += 'L';
    ans += 'U';
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	pair<int, int> s;
	bool flag = true;
	REP(i, n){
		cin >> s.first >> s.second;
		if (s.first <= a && a < s.second) flag = false;
		else if (s.first < b && b <= s.second) flag = false;
		else if (a <= s.first && s.second <= b) flag = false;
	}

	if (flag) cout << 0 << endl;
	else cout << 1 << endl;

}



Measured memory_bytes: 3104
H, W, K = map(int, input().split())
cw = [input() for i in range(H)]

# bit全探索
count = 0
for cols in range(2**H):  # 全ての行の塗りつぶし方を2進数で列挙
    for rows in range(2**W):  # 全ての列の塗りつぶし方を2進数で列挙
        black = 0
        for i in range(H):
            for j in range(W):
                if (cols >> i) & 1 == 0 and (rows >> j) & 1 == 0:
                    black += cw[i][j] == '#'
        if black == K:
            count += 1
print(count)


Measured memory_bytes: 9136
A=[]
_max = 0
_max2 = 0
N=int(input())
for i in range(N):
    A.append(int(input()))
    _,_max2,_max=sorted([A[-1],_max2,_max])

for i in range(N):
    print(_max if _max!=A[i] else _max2)

Measured memory_bytes: 16744
//
// Created by munaiyi on 2020/3/17.
//

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6 + 5;
char shit[maxn];
int dp[2][maxn];

int main() {
    scanf("%s", shit);
    int l = strlen(shit);
    while (l && shit[l - 1] == '0') l--;
    dp[0][l] = 0;
    dp[1][l] = maxn;
    for (int i = l - 1; i >= 0; i--) {
        dp[0][i] = min(dp[0][i + 1], dp[1][i + 1]) + shit[i] - '0';
        dp[1][i] = min(dp[0][i + 1] + 1  + 10 - shit[i] + '0', dp[1][i + 1] + 9 - shit[i] + '0');
//        dp[1][i] = min(dp[1][i], dp[1][i + 1] + shit[i] - '0');
//        printf("%d %d %d\n", i, dp[0][i], dp[1][i]);
    }
    printf("%d\n", min(dp[0][0], dp[1][0]));
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

int A[301];
ld DP[301][301][301];
int done[301][301][301];
ll cnt[4];
int n;

ld solve(int a, int b, int c)
{
    if(a==0 && b==0 && c==0)return 0;
    if(done[a][b][c])return DP[a][b][c];

    DP[a][b][c] = 1;
    if(a)DP[a][b][c]+= solve(a-1,b,c) * 1.0*a/n;
    if(b)DP[a][b][c]+= solve(a+1,b-1,c) * 1.0*b/n;
    if(c)DP[a][b][c]+= solve(a,b+1,c-1) * 1.0*c/n;
    DP[a][b][c]/=(1-(n-a-b-c)*1.0/n);
    done[a][b][c]=1;

    return DP[a][b][c];
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>A[i],cnt[A[i]]++;

    cout<<fixed<<setprecision(13)<<solve(cnt[1],cnt[2],cnt[3]);
}


Measured memory_bytes: 532864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
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; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans =0;
    if(a>=k){
        cout<<k<<endl;
    }
    else if(a+b>=k){
        cout<<a<<endl;
    }
    else{
        k-=a+b;
        cout<<a-k<<endl;
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) //多次元初期化
{
    std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;

    if (s[0] == 'A')
        ++a;
    rep(i, 2, s.size() - 1)
    {
        if (s[i] == 'C')
            ++c;
    }
    rep(i, 0, s.size()) if ('A' <= s[i] && s[i] <= 'Z')++ b;

    if (a == 1 && b == 2 && c == 1)
        cout << "AC\n";
    else
        cout << "WA\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define EPS 1e-8
#define INF 1e9+10
#define INFL 1e18
typedef long long ll;
using namespace std; //576
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a==c-1){
      cout << 1 << endl;
  }
  else{
      cout << 0 << endl;
  }

}

Measured memory_bytes: 256
{-# LANGUAGE PatternSynonyms #-}

import Data.Bool   (bool)
import Data.Maybe  (fromMaybe)
import Data.Monoid (First (First, getFirst))

main :: IO ()
main = do
    _ <- getLine
    s <- getLine
    answer $ solve s

type Answer = Maybe String
answer :: Answer -> IO ()
answer = putStrLn . fromMaybe "-1"

pattern Sheep = True
pattern Wolf  = False

solve :: String -> Answer
solve s = fmap showLogic . getFirst $ foldMap (First . validate s) assumptions
  where
    showLogic = map (bool 'W' 'S')
    assumptions = reverse [[x, y] | x <- [Wolf, Sheep], y <- [Wolf, Sheep]]
    inner (x : xs) as@(aa : al : _) = bool (inner xs) id (null xs) $ ((==) (x == 'o') al == aa) : as
    validate (x : xs) as@[a2, aa] = bool Nothing (Just $ reverse ps) $ (==) (x == 'o') (a2 == am) == aa && aa == an
      where
        an : ps@(am : _) = inner xs as



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

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

    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0]==5 && a[1]==5 && a[2]==7){
        cout << "YES";
    }
    else{
        cout << "NO";
    }


    return 0;
}


Measured memory_bytes: 256
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define MAX 100009
#define SQMAX 4048
#define SZ (MAX / SQMAX + 1)
#define MOD 163577857
#define INF 200000009
#define EPS 1e-8
#define ll long long
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define pb push_back
#define io ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;
char s[3][3];

int main() {
    scanf("%s%s%s", s[0], s[1], s[2]);
    string res = "";
    res += s[0][0];
    res += s[1][1];
    res += s[2][2];
    printf("%s", res.c_str());
}


Measured memory_bytes: 764
package main

import "fmt"

type dice struct {
	o, tw, th, fo, fi, s int
}

func (Dice dice) rot(D string) dice {
	for _, d := range D {
		switch d {
		case 'N':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.tw, Dice.s, Dice.o, Dice.fi
		case 'E':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.fo, Dice.o, Dice.s, Dice.th
		case 'W':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.th, Dice.s, Dice.o, Dice.fo
		case 'S':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.fi, Dice.o, Dice.s, Dice.tw
		case 'R':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.th, Dice.fi, Dice.tw, Dice.fo
		case 'L':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.fo, Dice.tw, Dice.fi, Dice.th
		}
	}
	return Dice
}

func (Dice dice) isEqual(D dice) bool {
	var cnt int
	rotdice := map[int]dice{
		1: D,
		2: D.rot("N"),
		3: D.rot("W"),
		4: D.rot("E"),
		5: D.rot("S"),
		6: D.rot("N").rot("N"),
	}
	for i := 1; i <= 6; i++ {
		D = rotdice[i]
		for {
			if Dice == D {
				return true
			}
			if cnt == 3 {
				cnt = 0
				break
			}
			D = D.rot("R")
			cnt++
		}
	}
	return false
}

func main() {
	var n int
	fmt.Scan(&n)
	var Dice1 dice
	fmt.Scan(&Dice1.o, &Dice1.tw, &Dice1.th, &Dice1.fo, &Dice1.fi, &Dice1.s)
	for i := 0; i < n-1; i++ {
		var Dice dice
		fmt.Scan(&Dice.o, &Dice.tw, &Dice.th, &Dice.fo, &Dice.fi, &Dice.s)
		if Dice1.isEqual(Dice) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll mod=998244353;
  ll N,K;
  cin>>N>>K;
  vector<pair<ll,ll>> vec(K);
  for(ll i=0;i<K;i++){
    ll L,R;
    cin>>L>>R;
    vec[i]=make_pair(L,R);
  }
  sort(all(vec));
  vector<ll> dp(N,0);
  
  
  for(ll i=N-2;i>=0;i--) {
    
    dp[i]=dp[i+1];
    dp[i]%=mod;
    for(ll j=0;j<K;j++) {
     ll A,B;
      tie(A,B)=vec[j];
     if(i+A>N-1) {
break;
     }
      if(i+A==N-1) {
dp[i]++;
      }
      else {
      
      dp[i]+=dp[i+A];
        dp[i]%=mod;
      }
      
      
      if(i+B+1>N-1) {
break;
      }
      if(i+B+1==N-1) {
dp[i]--;
      }
      else {
     
      dp[i]-=dp[i+B+1];
        dp[i]%=mod;
      }
      
    }
  }
  if(dp[0]<0) {
while(dp[0]<0) {
dp[0]+=mod;
}
  }
 cout<<dp[0]<<endl;
}
    
    
    
    
    
    

Measured memory_bytes: 4756
private fun countDivisorNum(n: Int, a: Int, b: Int): Int {
    return (a..b).map{ if (n % it == 0) 1 else 0 }.sum()
}

fun main(args : Array<String>) {
    val (a, b, n) = readLine()!!.split(" ").map(String::toInt)
    println("${countDivisorNum(n, a, b)}")
}



Measured memory_bytes: 32740
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long sum=0,cnt=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    cnt+=a[i];
    if(a[i]==0){
      sum+=cnt/2;
      cnt=0;
    }
  }
  sum+=cnt/2;
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>                
#define MAN 10000
#define GOSEN 5000
#define SEN 1000
using namespace std;
int N, Y;
int x, y, z;
bool clear;//
int main(void){
	cin >> N >> Y;

	for(x = 0; x <= N; x++){
		for(y = 0; y <= N; y++){
			if(N - x - y >= 0) z = N - x - y; 
			else continue;
			if( Y == x * MAN + y * GOSEN + z * SEN){clear=true; break;}
		}if(clear)break;
	}

	if(!clear) cout << "-1 -1 -1" << endl;
	else cout << x <<' '<< y <<' '<< z << endl;
}


Measured memory_bytes: 256
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
count = 0

import numpy as np
for i in range(n-1):
    for j in range(i+1,n):
        a = np.array(x[i])
        b = np.array(x[j])
        ab = sum(np.power((a-b),2))**0.5
        if ab%1 == 0:
            count += 1
print(count)

Measured memory_bytes: 18756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 = 1LL << 60;
ll dp[1000][100010] = {0};

int main() {
  int n, w;
  cin >> n >> w;
  ll weight[n];
  ll value[n];
  rep(i,n) {
    cin >> weight[i] >> value[i];
  }

  // N個の品物の数ループ
  rep(i,n) {
    // 重さが 0->w になるまで 1+w 回ループ
    rep(limit, 1+w) {

      // 品物iの重さが上限より小さいか？
      // :eyes: 0-1 ナップザックなので、置けるか置かないかだけ見ている
      if (limit - weight[i] >= 0) {
        // 上で代入した、選ばない場合と選ぶ場合の最大を取る
        chmax(dp[i+1][limit], value[i] + dp[i][limit - weight[i]]);
      }
      // 品物iを選ばない場合
      // そのままコピー
      chmax(dp[i+1][limit], dp[i][limit]);
    }
  }  

  cout << dp[n][w] << endl;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    while (a >= b) {
        --k;
        b *= 2;
    }
    while (b >= c) {
        --k;
        c *= 2;
    }

    print(0 <= k ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 3608
A,B,C,X,Y = map(int,input().split())
sum = 0
if A+B > C*2:
    if X > Y:
        sum = Y*2*C
        X = X-Y
        Y = 0
    else :
        sum = X*2*C
        Y = Y-X
        X = 0
if C*2 < A:
    sum = sum + X*2*C
    X = 0
if C*2 < B:
    sum = sum + Y*2*C
    Y = 0
sum = sum + X*A + Y*B
print(sum)

Measured memory_bytes: 3188
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

using namespace std;

signed main(){
    int n;
    cin >> n;
    int dif = 0; // 昇順の数列との差分
    int p;
    for (int i = 1;i <= n;i++){
        cin >> p;
        if (p != i) ++dif;
    }
    if (dif <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var count = s.Count(z => z == 'o');
            var remin = 15 - s.Length;

            Console.WriteLine(count + remin >= 8 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 11220
# coding:utf-8

N, M = map(int, input().split())
NL = []
summoney = []
min = 1000000000

for i in range(N):
    *A, B = map(int, input().split())
    A.append(B)
    NL.append(A)

NL = sorted(NL)

for j in range(N):
    if M - NL[j][1] >= 0:
        summoney.append(NL[j][0]*NL[j][1])
        M =  M - NL[j][1]
    elif  M - NL[j][1] < 0:
        summoney.append(M*NL[j][0])
        break

print(sum(summoney))

Measured memory_bytes: 28656
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 20090717
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=60000+10,inf=0x3f3f3f;

struct edge{
    int to,Next,c;
}e[N<<2];
bool vis[N];
int cnt,head[N],d[N];
void add(int u,int v,int c)
{
    e[cnt].to=v;
    e[cnt].c=c;
    e[cnt].Next=head[u];
    head[u]=cnt++;
}
void spfa()
{
    memset(vis,0,sizeof vis);
    vis[1]=1;
    memset(d,inf,sizeof d);
    d[1]=0;
    queue<int>q;
    q.push(1);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        vis[x]=0;
        for(int i=head[x];~i;i=e[i].Next)
        {
            int To=e[i].to;
            if(d[x]+e[i].c<d[To])
            {
                d[To]=d[x]+e[i].c;
                if(!vis[To])
                {
                    vis[To]=1;
                    q.push(To);
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cnt=0;
    memset(head,-1,sizeof head);
    for(int i=0;i<n;i++)
    {
        add(i,(i+1)%n,1);
        add(i,i*10%n,0);
    }
    spfa();
    cout<<d[0]+1<<endl;
    return 0;
}
/********************

********************/


Measured memory_bytes: 4480
package main

import (
	"fmt"
)

func even(n int) int {
	return n / 2
}

func odd(n int) int {
	return 3*n + 1
}

func main() {
	var s int
	fmt.Scan(&s)

	ss := []int{s}

	for i := 1; ; i++ {
		if ss[i-1]%2 == 0 {
			ss = append(ss, even(ss[i-1]))
		} else {
			ss = append(ss, odd(ss[i-1]))
		}
		for i := 0; i< len(ss)-1 ; i++ {
			if ss[i] == ss[len(ss)-1] {
				fmt.Println(len(ss))
				return
			}
		}
	}
}


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

using namespace std;
typedef unsigned long long ll;

#define PI (acos(-1))
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct p{
    long x;
    long y;
};

static long p_equal(p p1, p p2){
    return p1.x == p2.x && p1.y == p2.y;
};

int main(void){
    long n; cin >> n;
    vector <p> ps;
    long x;
    long y;
    struct p _p;
    REP(i, n){
        cin >> x; cin >> y;
        _p = {x, y};
        ps.push_back(_p);
    }
    vector <p> diffs;
    REP(i, n){
        REP(j, n){
            _p = {ps[i].x - ps[j].x, ps[i].y - ps[j].y};
            if (_p.x != 0 or _p.y != 0){
                diffs.push_back(_p);
            }
        }
    }
    long max_count = 0;
    REP(i, diffs.size()){
        p __p = diffs[i];
        max_count = max(max_count, count_if(diffs.begin(), diffs.end(), [__p](p _p) { return p_equal(__p, _p);}));
    }
    cout << n-max_count << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

bool a[400000];

int main(){
	
	int N = 400000;
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(i % 7 != 1 && i % 7 != 6){
			a[i] = false;
		}else if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	while(true){
		cin >> N;
		if(N == 1){
			break;
		}
		cout << N << ":";
		for(int i = 1; i <= N; i++){
			if(a[i] && (i % 7 == 1 || i % 7 == 6) && N % i == 0){
				cout << " " << i;
			}
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 10004, MAXM = 102, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int r;
    cin >> r;
    cout << 3 * r * r << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_H = 105;
const int MAX_W = 105;
char D[MAX_H][MAX_W];

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

void dfs(char c, int y, int x, int w, int h) {
  for (int k = 0; k < 4; k++) {
    int x2 = x + dx[k];
    int y2 = y + dy[k];
    if (0 <= x2 && x2 < w && 0 <= y2 && y2 < h && c == D[y2][x2]) {
      D[y2][x2] = '.';
      dfs(c, y2, x2, w, h);
    }
  }
}

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;

    for (int i = 0; i < H; i++) {
      string s;
      cin >> s;
      for (int j = 0; j < W; j++) {
        D[i][j] = s[j];
      }
    }

    int res = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        char c = D[i][j];
        if (c != '.') {
          dfs(c, i, j, W, H);
          res++;
        }
      }
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;cin>>N;
  vector<long>prime(0);
  vector<int>pow(100000,0);
  long now=2;
  long rn=0;
  int kind=-1;
  while(true){
  	if(N==1)break;
    if(now*now>N){
      if(rn==N){
        pow[kind]++;
      }else{
      	prime.push_back(N);
      	kind++;
      	pow[kind]=1;
      }
  	  break;
    }
    if(N%now==0){
      N/=now;
      if(rn==now){
      	pow[kind]++;
        rn=now;
      }else{
      	kind++;
      	prime.push_back(now);
        pow[kind]=1;
        rn=now;
      }
      now=1;
    }
    now++;
  }
  int cnt=0;
  for(int i=0;i<prime.size();i++){
    int now=1;
    while(true){
      if(pow[i]>=now){
      	cnt++;
  		pow[i]-=now;
      }else{
      	break;
      }
      now++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3788
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

if N % 2 == 1:
    num = (N - 1) // 2
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, N):
        if A[i] == ceil(i / 2) * 2:
            continue
        else:
            print(0)
            exit()
else:
    num = N // 2
    for i in range(N - 1):
        if A[i] == (i // 2) * 2 + 1:
            continue
        else:
            print(0)
            exit()
ans = 1
for i in range(num):
    ans *= 2
    ans %= (10**9 + 7)

print(ans)


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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    n %= 10;
    if(n==3){
        cout << "bon" << endl;
    }else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int z=-1,n,i,j[255],o,maxo=-100000,s[5000]={0};
	scanf("%d",&n);
	while(n!=0){
		o=0;
		z++;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		for(i=1;i<n;i++){
			if(s[i]<s[i-1]+s[i]){
				s[i]=s[i-1]+s[i];
			}

		}
		for(i=0;i<n;i++){
			maxo=max(maxo,s[i]);
		}
		j[z]=maxo;
		maxo=-100000;
		scanf("%d",&n);
	}
	for(i=0;i<=z;i++){
		printf("%d\n",j[i]);
	}
	return 0;
}

Measured memory_bytes: 1216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long n = Long.parseLong(br.readLine());

		long ans = modpow(10, n, 1000000007) - modpow(9, n, 1000000007) - modpow(9, n, 1000000007)
				+ modpow(8, n, 1000000007);
		ans %= 1000000007;
		ans = (ans + 1000000007) % 1000000007;
		System.out.println(ans);
	}

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

Measured memory_bytes: 32796
var s:String;
begin
readln(s);
if s='SUN' then writeln(7)else if s='MON' then writeln(6)else if s='TUE' then writeln(5)else if s='WED' then writeln(4)else if s='THU' then writeln(3)else if s='FRI' then writeln(2)else writeln(1);
end.


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#define fileoutput ofstream f;f.open("output.txt");if(!f.is_open()){cout<<"faild";return 0;}cout.rdbuf(f.rdbuf());
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mod 1000000007
#define inf 2e9
#define sz 1005
using namespace std;

int main()
{
	int n, x, arr[10];
	string s1 = "", s2 = "", ss = "";
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		arr[i] = i + 1;
		cin >> x;
		string s = to_string(x);
		s1 += s;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		string s = to_string(x);
		s2 += s;
	}
	for (int i = 0; i < n; i++)
	{
		string s = to_string(arr[i]);
		ss += s;
	}
	int cnt1 = 1, cnt2 = 1, cnt = 1;
	if (ss == s1)cnt1 = cnt;
	if (ss == s2)cnt2 = cnt;
	while (next_permutation(arr, arr + n))
	{
		ss.clear();
		for (int i = 0; i < n; i++)
		{
			string s = to_string(arr[i]);
			ss += s;
		}
		cnt++;
		if (ss == s1)cnt1 = cnt;
		if (ss == s2)cnt2 = cnt;
	}
	cout << abs(cnt1 - cnt2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    ll ans = T;
    for(int i = n - 2; i >= 0; i--){
        ans += min(T, t[i + 1] - t[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


N = int(input())
primes = get_sieve_of_eratosthenes(55555)
#print(len(primes))
#print(primes)
primes = [x for x in primes if x % 5 == 1]
print(*primes[:N])

Measured memory_bytes: 5528
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

int main(){
    string a,b;
    cin >> a >> b;
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    if(a<b) puts("Yes");
    else puts("No");
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i, N) {
    cin >> A.at(i);
  }
  rep(i, N) {
    cin >> B.at(i);
  }
  rep(i, N-1) {
    cin >> C.at(i);
  }

  int ans = 0;
  rep(i, N) {
    ans += B.at(A.at(i)-1);
    if (i != 0) {
      if(A.at(i) == (A.at(i - 1) + 1)){
        ans += C.at(A.at(i-1)-1);
      }
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int a = 0;
    int b  = 0;
    cin >> a;
    if (a % 10 == 7){
        b = 1;
    }
    a = a / 10;
    if (a % 10 == 7){
        b = 1;
    }
    a = a / 10;
    if (a == 7){
        b = 1;
    }
    if (b == 1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3672
#pragma region template

#include <bits/stdc++.h>

using namespace std;

// -type-
using str = string;
using ll = int64_t;
using pii = pair<int64_t, int64_t>;
using pis = pair<int64_t, str>;
using psi = pair<str, int64_t>;
using vi = vector<int64_t>;
using vvi = vector<vector<int64_t>>;
using vs = vector<str>;
using vpii = vector<pair<int64_t, int64_t>>;


//--const
constexpr ll MOD = 1000000007;

constexpr ll INF = (ll)0x3f0000003f000000;
constexpr double EPS = 1e-9;
constexpr int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
              dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// clang-format off
//--define
#define _overload3(_1, _2, _3, name, ...) name
#define   rep(...) _overload3(__VA_ARGS__,  _rep3,  _rep2,)(__VA_ARGS__)
#define  repc(...) _overload3(__VA_ARGS__, _repc3, _repc2,)(__VA_ARGS__)
#define  repr(...) _overload3(__VA_ARGS__, _repr3, _repr2,)(__VA_ARGS__)
#define repcr(...) _overload3(__VA_ARGS__,_repcr3,_repcr2,)(__VA_ARGS__)
#define _rep(i,k,n) for(int i=(k)   , i##_len=(n); i < i##_len; ++i)
#define   _rep2(i  ,n) _rep(i,0,n) 
#define   _rep3(i,k,n) _rep(i,k,n)
#define  _repc2(i  ,n) _rep(i,1,n+1)
#define  _repc3(i,k,n) _rep(i,k,n+1) 
#define _repr(i,k,n) for(int i=(n-1), i##_len=(k); i >=i##_len; --i)
#define  _repr2(i  ,n) _repr(i,0,n)
#define  _repr3(i,k,n) _repr(i,k,n) 
#define _repcr2(i  ,n) _repr(i,1,n+1)
#define _repcr3(i,k,n) _repr(i,k,n+1)

#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(...) debug_args(__LINE__, __VA_ARGS__)
#define pow2(n) (1LL<<(n))


//--functions
inline bool in(string s, string c) {return (s.find(c) != string::npos);}
inline bool in(string s,   char c) {return (s.find(c) != string::npos);}

template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}

void print_args(ostream&) {}
template <class S, class... T>
void print_args(ostream& out,const S& a,const T&... args) {
    out << ' ' << a;
    print_args(out, args...);
}
template <class S, class... T>
void print(const S& a, const T&... args) {
    std::cout << a;
    print_args(std::cout, args...);
    std::cout << '\n';
}
template <class S, class... T>
void debug_args(const S& a, const T&... args) {
    std::cout << "(L:" << std::setw(3) << a << ")";
    print_args(std::cout, args...);
    std::cout << '\n';
}
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(0);
        std::cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

void solve(long long N, std::vector<long long> X) {
    ans = INF;
    repc(p, 100) {
        ll sum(0);
        rep(i, N) {
            sum += ll(pow(X[i] - p, 2));
        }
        ans = min(ans, sum);
    }
    print(ans);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
    }
    solve(N, std::move(X));

    return 0;
}


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

namespace aoj_ALDS1_3_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] inputArray = Console.ReadLine().Split(' ');
            Stack<int> resultStack = new Stack<int>();
            for (int i = 0; i < inputArray.Length; i++)
            {
                if (inputArray[i] == "*")
                {
					resultStack.Push(resultStack.Pop() * resultStack.Pop());
                }
                else if (inputArray[i] == "+")
                {
					resultStack.Push(resultStack.Pop() + resultStack.Pop());
                }
                else if (inputArray[i] == "-")
                {
					resultStack.Push((resultStack.Pop() - resultStack.Pop()) * -1);
                }
                else
                {
                    resultStack.Push(int.Parse(inputArray[i]));
                }
            }

			Console.WriteLine(resultStack.Pop());
        }
    }
}



Measured memory_bytes: 16392
#include <stdio.h>
#define  MAX  10
void  main( )
{
	int data[MAX];
	int  n,i,w;
    for( i=0; i<MAX; i++ )
      { scanf("%d",&data[i]); 
	  }

    for( n=MAX; n>1; n-- )
      {
        for( i=0; i<n-1; i++ )
          {
            if ( data[i]<data[i+1] )
              {
                w=data[i];
                data[i]=data[i+1];
                data[i+1]=w;
              }
          }
      }

    for( i=0; i<3; i++ )
      { printf("%d\n",data[i]); }
    fflush(stdout);
}
//?????????????????±???

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){
    string str;
    cin >> str;
    
    int ans = 0;
    ans += 10000 * stoi(str.substr(0, 4));
    ans += 100 * stoi(str.substr(5, 2));
    ans += stoi(str.substr(8, 2));

    if(ans <= 20190430) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;

int main(){
  int n;
  cin >> n;
  int a;
  map<int, int> mp;
  for ( int i = 0; i < n; i++){
    cin >> a;
    mp[a]++;
  }
  bool flag = true;
  long long ans = 1;
  if ( n % 2 == 0){
    for ( int i = 0; i < n/2; i++){
      int x = 2 * i + 1;
      if ( mp[x] != 2){
        flag = false;
      }
    }
  } else {
    for ( int i = 0; i < n/2; i++){
      int x = 2 * i;
      if ( x > 0 && mp[x] != 2){
        flag = false;
      }
      if ( x == 0 && mp[x] != 1){
        flag = false;
      }
    }
  }
    if ( !flag ){
      cout << 0 << endl;
    }else {
      for ( int i = 0; i < n/2; i++){
        ans *= 2;
        ans %= mod;
      }
      cout << ans << endl;
    }
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	ll X, K; cin >> X >> K;
	
	vll datl(K+1), datr(K+1);
	vll low(K+1), high(K+1);
	vll R(K+1);
	
	datl[0] = 0, datr[0] = X;
	low[0] = 0, high[0] = X, R[0] = 0;
	for (int i = 1; i <= K; i++) {
		cin >> R[i];
		ll diff = R[i] - R[i-1];
		tie(datl[i], datr[i], low[i], high[i]) = tie(datl[i-1], datr[i-1], low[i-1], high[i-1]);
		if (i & 1) {
			datl[i] -= diff;
			datr[i] -= diff;
		} else {
			datl[i] += diff;
			datr[i] += diff;
		}
		if (datl[i] < 0) {
			low[i] = min(low[i] - datl[i], high[i]);
			datl[i] = 0;
		}
		datr[i] = max(0ll, datr[i]);
		if (datr[i] > X) {
			high[i] = max(high[i] - (datr[i] - X), low[i]);
			datr[i] = X;
		}
		datl[i] = min(X, datl[i]);
	}
		
	int Q;
	cin >> Q;
	while (Q--) {
		ll t, a;
		ll pos;
		cin >> t >> a;
		pos = --upper_bound(begin(R), end(R), t) - begin(R);
		a = max(min(a, high[pos]), low[pos]);
		ll x = datl[pos] + (a - low[pos]);
		ll diff = t - R[pos];
		if (pos & 1) x = min(x + diff, X);
		else x = max(x - diff, 0ll);
		cout << x << endl;
	}

	return (0);
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        long long int x,k,d,p,p1;
      cin>>x>>d>>k;
      x=abs(x);
      p1=x/k;
      if(p1>=d) cout<<x-k*d;
      else{

      p=x-p1*k;
      //cout<<p1<<endl;
      if(p1%2==d%2) cout<<p;
      else{
        cout<<min(abs(p+k),abs(p-k));
      }
      }

    }
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int i,flg=0,flg1=0;
	int n,k,cnt=0;
	scanf("%d",&n);
	while(n !=0){
		for(i=0;i<n;i++){
			scanf("%d",&k);
			if(flg==1 && k>=2){
				cnt+=1;
			}
			else if(k>=2){
				cnt+=2;
				flg=1;
				flg1=1;
			}
			else if(k==1){
				cnt+=1;
			}
			else if(k<=0){
				cnt+=0;
			}
		}
		if(cnt>0 && flg1==1){
			printf("%d\n",cnt);
		}
		else if(flg1==0){
			printf("NA\n");
		}
		cnt=0;
		flg=0;
		flg1=0;
		scanf("%d",&n);
	}
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int i, j, s_len = s.size(), t_len = t.size();
    for(i=s_len-1; i>=0; i--) {
        if(s[i] == '?' || s[i] == t[0]) {
            for(j=0; j<t_len && i+j<s_len; j++) {
                if(s[i+j] != '?' && s[i+j] != t[j]) break;
                if(j == t_len-1) {
                    for(j=0; j<t_len; j++) s[i+j] = t[j];
                    for(j=0; j<s_len; j++) if(s[j] == '?') s[j] = 'a';
                    cout << s << endl;
                    return 0;
                }
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256