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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int n;

const int num = 'z' - 'a' + 1;
int main() {
    std::cin >> n;

    VI min = VI(num, std::numeric_limits<int>::max());
    REP(i, n) {
        std::string S;
        std::cin >> S;
        VI cnt = VI(num, 0);
        EACH(it, S) {
            cnt[*it - 'a']++;
        }
        REP(i, num) {
            min[i] = std::min(min[i], cnt[i]);
        }
    }

    REP(i, num) {
        char c = i + 'a';
        REP(j, min[i]) {
            std::cout << c;
        } 
    }
    std::cout << std::endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))

int main(){
	string S;
	cin >> S;
	auto f = S.find_first_of('A');
	auto e = S.find_last_of('Z');
	out(e - f +1);
    return 0;
}



Measured memory_bytes: 640
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	s := make([]int, M)
	c := make([]int, M)
	for i := 0; i < M; i++ {
		s[i], c[i] = ReadInt()-1, ReadInt()
	}
	low, high := 0, 9
	if N >= 2 {
		low = 1
		for j := 0; j < N-1; j++ {
			low *= 10
		}
		high = low*10 - 1
	}
	for i := low; i <= high; i++ {
		str := strconv.Itoa(i)
		ok := true
		for j := 0; j < M; j++ {
			if str[s[j]]-'0' != byte(c[j]) {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println(str)
			return
		}
	}
	fmt.Println(-1)
}

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: 1844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

vector<vector<ll>> G;
vector<ll> d, f;
vector<bool> b;
ll t;

ll dfs(ll v, ll t) {
    b[v] = true;
    d[v] = t;
    for (auto nv : G[v]) {
        if (b[nv]) continue;
        t = dfs(nv, t + 1);
    }
    f[v] = t + 1;
    return t + 1;
}

int main() {
    ll n;
    cin >> n;
    G.resize(n), d.resize(n), f.resize(n), b.resize(n);
    rep(i, n) {
        ll u, k;
        cin >> u >> k;
        u--;
        rep(j, k) {
            ll v;
            cin >> v;
            v--;
            G[u].emplace_back(v);
        }
    }
    ll now = 0;
    rep(i, n) {
        if(b[i]) continue;
        now = dfs(i, now + 1);
    }
    rep(i, n) cout << i+1 << " " << d[i] << " " << f[i] << endl;
}



Measured memory_bytes: 3144
N,Y=gets.split.map(&:to_i)
aa=bb=cc=-1
(0..N).each do |a|
  (0..(N-a)).each do |b|
    c=N-a-b
    aa,bb,cc=[a,b,c] if 10000*a+5000*b+1000*c == Y
  end
end
puts "#{aa} #{bb} #{cc}"


Measured memory_bytes: 1788
using System;
using System.Linq;
using Pair = System.Collections.Generic.KeyValuePair<long, long>;

namespace DPL1_H
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = scan;
            int N = (int)t[0];
            long W = t[1];
            var w = new long[N];
            var v = new long[N];
            for (int i = 0; i < N; i++)
            {
                t = scan;
                w[i] = t[1];
                v[i] = t[0];
            }

            int n1 = N / 2;
            var ps = new Pair[1 << n1];
            for (int i = 0; i < 1 << n1; i++)
            {
                long sw = 0, sv = 0;
                for (int j = 0; j < n1; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        sw += w[j];
                        sv += v[j];
                    }
                }
                ps[i] = new Pair(sw, sv);
            }
            Array.Sort(ps, (a,b) => { return a.Key.CompareTo(b.Key); });
            int m = 1;
            for (int i = 0; i < 1 << n1; i++)
            {
                if (ps[m - 1].Value < ps[i].Value) ps[m++] = ps[i];
            }
            ps = ps.Take(m).ToArray();

            long ans = 0;
            int n2 = N - n1;

            for (int i = 0; i < 1 << n2; i++)
            {
                long sw = 0, sv = 0;
                for (int j = 0; j < n2; j++)
                {
                    if ((i >> j & 1) == 1)
                    {
                        sw += w[n1 + j];
                        sv += v[n1 + j];
                    }
                }
                if (sw <= W)
                {
                    long tv = ps[UpperBound(ps, W - sw) - 1].Value;
                    ans = Math.Max(ans, sv + tv);
                }
            }

            Console.WriteLine(ans);
        }

        static long UpperBound(Pair[] arr, long val)
        {
            int low = 0, high = arr.Length;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr[mid].Key <= val) low = mid + 1;
                else high = mid;
            }
            return low;
        }
        static long[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } }
    }
}

Measured memory_bytes: 25976
from itertools import product

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = set(int(input()) for _ in range(N))

for h, w in product(range(3), repeat=2):
    if A[h][w] in B:
        A[h][w] = -1

for h in range(3):
    if all(A[h][i]==-1 for i in range(3)):
        print('Yes')
        exit()

for w in range(3):
    if all(A[i][w]==-1 for i in range(3)):
        print('Yes')
        exit()

if A[0][0]==A[1][1]==A[2][2] or A[0][2]==A[1][1]==A[2][0]:
        print('Yes')
        exit()

print('No')

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int n;
vint vec(200);
int heigth=-10;
int counter=0;

int main(){
    cin>>n;
    rep(i,n)cin>>vec[i];
    rep(i,n){
        if(vec[i]>=heigth)counter++;
        heigth=max(heigth,vec[i]);
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
#define int(x) int x; scanf("%d",&x)
#define input(x) scanf("%d",&x)
#define rep(x,n) for(int x = 0; x < n; x++)
#define _br printf("\n")
#define INF 2000000000
#define NIL -1

//left child,right brother.

struct Node{
    int d;
    int p;
    int l;
    int r;
};

int n;
Node *T;

void input_data(){
    input(n);
    T = new Node[n];
    rep(i,n){
        T[i].d = NIL;
        T[i].p = NIL;
        T[i].l = NIL;
        T[i].r = NIL;
    }
    
    rep(i,n){
        int(id);int(num);
        int *ch;
        
        if (num != 0) {
            ch = new int[num];
            rep(k,num){
                input(ch[k]);
            }
            T[id].l = ch[0];
            T[ch[0]].p = id;
        }
        
        for (int k = 1; k < num; k++) {
            T[ch[k-1]].r = ch[k];
            T[ch[k]].p = id;
        }
        if (num != 0) delete [] ch;
    }
}

void deci_depth(int i, int de){
    T[i].d = de;
    if (T[i].l != NIL) deci_depth(T[i].l,de+1);
    if (T[i].r != NIL) deci_depth(T[i].r,de);
}

int ret_root(){
    int i = 0;
    while (T[i].p != NIL) {
        i = T[i].p;
    }
    return i;
}

void Node_type(int i, int root){
    if (i == root) {
        printf("root, ");
    }else if(T[i].l == NIL){
        printf("leaf, ");
    }else{
        printf("internal node, ");
    }
}

void print_child(int i){
    printf("[");
    if (T[i].l != NIL) {
        i = T[i].l;
        printf("%d",i);
        while (T[i].r != NIL) {
            i = T[i].r;
            printf(", %d",i);
        }
    }
    printf("]");
}

int main(){
    
    input_data();
    int root = ret_root();
    deci_depth(root,0);
    
    rep(i,n){
        printf("node %d: parent = %d, depth = %d, ",i,T[i].p,T[i].d);
        Node_type(i,root);
        print_child(i);
        _br;
    }
    
    return 0;
}

Measured memory_bytes: 2848
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	int N, tmp;
	long long result = 0;
	int A[200000];
	vector<long long> B;
	
	cin >> N;

	for(int i=0; i<200000; i++){
		B.push_back(0);
	}

	for(int i=0; i<N; i++){
		cin >> tmp;
		A[i] = tmp;
		B[tmp-1] = B[tmp-1] + 1;
	}

	for(int i=0; i<N; i++){
		result += (B[i] * (B[i]-1) / 2);
	}


	for(int k=0; k<N; k++){
		cout << result - (B[A[k]-1] - 1) << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

typedef long long ll;

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;

  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  rep(i, N) {
    H -= A[i];
  }

  if (H <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	unsigned short set;            	/* 使用できる最大値格納用変数 */
	unsigned long tag;            	/* 目標値格納用変数 */
	signed short mid;            	/* 計算用変数 */
	int agg[100];       	/* 計算結果格納用配列 */
	int i, j;           	/* ループ変数 */
	int input_count = 0;	/* 入力数カウンタ */
	int num_count = 0;  	/* 目標を満足する値のカウンタ */
	
	/* 配列の初期化 */
	for(i = 0;i < 100;i++){
		agg[i] = 0;
	}
	
	/* 数値の入力、演算を無限ループ */
	while(1){
		/* 使用できる最大値、目標値の入力 */
		scanf("%d %ld", &set, &tag);
		
		/* 終了処理 */
		if(set == 0 && tag == 0){
			break;
		}
		/* カウンタをリセット */
		num_count = 0;
		
		/* 目標を満足する値をカウント */
		for(i = 1;i < set;i++){
			for(j = i;j <= set;j++){
				/* i + j と目標値の差をmidに代入 */
				mid = tag - (i + j);
				/* midがiとjの間にある場合カウント*/
				if(mid > i && mid < j){
					num_count++;
				}
			}
		}
		
		/* カウントした結果を格納 */
		agg[input_count] = num_count;
		/* 入力数をカウント */
		input_count++;
	}
	
	/* 結果の出力 */
	for(i = 0;i < input_count;i++){
		printf("%d\n", agg[i]);
	}
	
	return 0;
}



Measured memory_bytes: 2100
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int n,q;

struct Tree{
  int N;
  vector<vector<int>> info;
  explicit Tree();
  explicit Tree(int n) : N(n){
    info.resize(N);
  }
  void init(){
    for(int i=0; i<N-1; i++){
      int a,b; scanf("%d %d", &a, &b);
      a--; b--;
      this->info[a].push_back(b);
      this->info[b].push_back(a);
    }
  }
};

struct Solver : public Tree{
  int Q;
  ll x;
  vector<ll> ans;
  vector<int> reached;
  explicit Solver(int n, int q) : Tree(n), Q(q){
    this->init();
    ans.resize(n); ans.assign(n,0);
    reached.resize(n); reached.assign(n,0);
  }
  void print_item(){
    for(int i=0; i<N; i++){
      if(!this->info.empty()){
        for(int j=0; j<(int)this->info[i].size(); j++){
          printf("%d %d\n", i, this->info[i][j]);
        }
      }
    }
  }
  void dfs(int i){
    reached[i] = 1;
    if(!this->info[i].empty()){
      for(int j=0; j<(int)this->info[i].size(); j++){
        int im = this->info[i][j];
        if(this->reached[im]) continue;
        ans[im] += ans[i];
        dfs(im);
      }
    }
    return;
  }
  void solve(){
    for(int i=0; i<Q; i++){
      int p;
      scanf("%d %lld", &p, &x); p--;
      ans[p] += x;
    }
    dfs(0);
    for(int i=0; i<N; i++){
      printf("%lld\n", ans[i]);
    }
  }
};

int main(){
  scanf("%d %d", &n, &q);

  Solver solver(n,q);
  solver.solve();
}

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

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

int main()
{
    ll N, W;
    ll dp[110][100100] = {0};
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N)
    {
        rep(sum, W + 1)
        {
            if (sum - w[i] >= 0)
            {
                chamax(dp[i + 1][sum], dp[i][sum - w[i]] + v[i]);
            }
            chamax(dp[i + 1][sum], dp[i][sum]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 86272
from collections import Counter

N = int(input())
lines = list(map(int, input().split()))

l = Counter(lines)

l = {k:v for k,v in l.items() if v>=2}

if len(l.keys()) <= 1:
  print(0)
else:
  anss = list(l.keys())
  ma  = max(anss)
  ma2 = sorted(anss)[-2]
  print(ma * ma2 if l[ma] < 4 else ma ** 2)


Measured memory_bytes: 18600
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n;
vector<int> idx[26];

char s[N], t[N];
int main(){
    scanf("%s%s", &s, &t);
    n = strlen(s);
    for(int i = 0 ; i < n ; ++i)
        idx[s[i] - 'a'].emplace_back(i);
    int m = strlen(t);
    int lst = -1, kam = 0;
    for(int i = 0 ; i < m ; ++i)
        t[i] -= 'a';
    for(int i = 0 ; i < m ; ++i){
        int mkan = lower_bound(idx[t[i]].begin(), idx[t[i]].end(), lst + 1) - idx[t[i]].begin();
        if(mkan == idx[t[i]].size()){
            if(idx[t[i]].empty()){
                puts("-1");
                return 0;
            }
            ++kam;
            lst = idx[t[i]][0];
            continue;
        }
        lst = idx[t[i]][mkan];
    }
    printf("%lld\n", (1LL * kam * n) + 1LL * lst + 1LL);
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m;
	cin>>n>>m;
	map<ll,ll> ma;
	for(ll i=1;i<=n;i++)
	{
		ll x;
		cin>>x;
		ma[i]=x;
	}
	vector<ll> v1[n+1];
	for(ll i=1;i<=m;i++)
	{
		ll x,y;
		cin>>x>>y;
		v1[x].push_back(y);
		v1[y].push_back(x);
	}
	ll sum=0;
	map<ll,ll>m1;
	map<pair<ll,ll>,ll> ma1;
	for(ll i=1;i<=n;i++)
	{
		if(v1[i].size()==0)
		sum++;
		else
		{
			bool flag=true;
			for(ll j=0;j<(ll)v1[i].size();j++)
			{
				ll x=v1[i][j];
				if(ma[i]>ma[x] and m1[i]==0)
				{
					continue;
				}
				else
				{flag=false;break;}
			}
			if(flag==true)
			{m1[i]++;
			sum++;
			}
			
		}
	}
	cout<<sum;
	return 0;
}
	


Measured memory_bytes: 18388
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    A.sort()
    B.sort()
    C.sort()

    def is_ok1(mid, S, K):
        if K <= S[mid]:
            return True
        else:
            return False

    def is_ok2(mid, S, K):
        if K < S[mid]:
            return True
        else:
            return False

    def binary_search_meguru(S, K, is_ok):
        left = -1
        right = N
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid, S, K):
                right = mid
            else:
                left = mid
        return right

    ans = 0
    for b in B:
        a = binary_search_meguru(A, b, is_ok1)
        c = binary_search_meguru(C, b, is_ok2)
        ans += a * (N-c)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 104804
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s1 = sc.next();
        String s2 = sc.next();
        int n1 = (int)s1.charAt(0);
        int n2 = (int)s2.charAt(0);
        if(n1 > n2){
        	System.out.println(">");
        }else if(n1 < n2){
        	System.out.println("<");
        }else{
        	System.out.println("=");
        }
    }
}

Measured memory_bytes: 35620
fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val ans = if(readLine()!!.split(" ").map { it.toInt() }.filter { it % 2 == 0 }.all { it % 3 == 0 || it % 5 == 0 }) "APPROVED" else "DENIED"
    println(ans)
}


Measured memory_bytes: 38124
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int X=s.nextInt();
    if(X<600) System.out.println(8);
    else if(X<800) System.out.println(7);
    else if(X<1000) System.out.println(6);
    else if(X<1200) System.out.println(5);
    else if(X<1400) System.out.println(4);
    else if(X<1600) System.out.println(3);
    else if(X<1800) System.out.println(2);
    else if(X<2000) System.out.println(1);

  }  
}

Measured memory_bytes: 35608
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
    }

    int num = (n - 1) % (k - 1) == 0 ? (n - 1) / (k - 1) : (n - 1) / (k - 1) + 1;
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int D,N;
  cin>>D>>N;
  int ans=1;
  if(D==0) {
    if(N==100){
      cout<<101<<endl;
    }
    else {
      cout<<N<<endl;
         }
  }
  else {
    for(int i=0;i<D;i++){
    ans *=100;
  }
    if(N==100){
      cout<<101*ans<<endl;
    }
    else{
  cout<<N*ans<<endl;
  }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

 
void solve(void)
{
  int N;
  cin>>N;
  vector<int> X(N);
  for (int i = 0; i < N; i++)
  {
    cin>>X[i];
  }
  int ANS = INF;
  for (int p = 0; p <= 100; p++)
  {
    int VAL = 0;
    for (int i = 0; i < N; i++)
    {
      VAL += (X[i] - p)*(X[i] - p);
    }
    chmin(ANS,VAL);
    
  }
  cout<<ANS<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  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(void){
   int X,Y;
   cin>>X>>Y;
   int ans=X+Y/2;
   cout<<ans<<endl;
   
   
}

Measured memory_bytes: 3596
//33
#include<iostream>
#include<vector>

using namespace std;

int main(){
  bool cmp[100000]={true,true};
  vector<int> prm;
  for(int i=2;i<100000;i++){
    if(!cmp[i]){
      prm.push_back(i);
      for(int j=2;j*i<100000;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n;cin>>n,n;){
    int ans=0;
    for(int i=0;prm[i]<=n;i++){
      int s=prm[i];
      for(int j=1;s<n;j++){
	s+=prm[i+j];
      }
      ans+=s==n;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

constexpr int64_t NUM = 26;
vector<int64_t> c(NUM);
vector<vector<int64_t>> s;

int64_t score(const vector<int64_t>& v) {
    vector<int64_t> last(NUM, -1);
    int64_t result = 0;
    for (int64_t i = 0; i < v.size(); i++) {
        //開催による満足度増加
        result += s[i][v[i]];

        //最終開催日更新
        last[v[i]] = i;

        //開催されないことによる満足度減少
        for (int64_t j = 0; j < NUM; j++) {
            result -= c[j] * (i - last[j]);
        }

        //この日までのスコア
        cout << result << endl;
    }

    return result;
}

int main() {
    int64_t D;
    cin >> D;
    for (int64_t& C : c) {
        cin >> C;
    }

    s.resize(D, vector<int64_t>(NUM));
    for (int64_t i = 0; i < D; i++) {
        for (int64_t j = 0; j < NUM; j++) {
            cin >> s[i][j];
        }
    }

    vector<int64_t> t(D);
    for (int64_t i = 0; i < D; i++) {
        cin >> t[i];
        t[i]--;
    }

    score(t);
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> vec(S.length());
  for(int i = 0; i < S.length(); i++){
    vec.at(i) = S[i];
  }
  for(int i = 0; i < S.length(); i++){
    if((vec.at(i)+N)>90) cout << char((vec.at(i)+N)%90+64);
    else cout << char(vec.at(i)+N);
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
pair<vector<T>, vector<T>> dijkstra(int s,vector<vector<edge<T>> > &G){
    size_t n=G.size();
    using P = pair<T, int>;
    vector<T> d(n, INF<T>);
    vector<T> ans(n, 0);
    vector<int> b(n,-1);
    priority_queue<P,vector<P>,greater<> > Q;
    d[s]=0;
    ans[s] = 1;
    Q.emplace(d[s],s);
    while(!Q.empty()){
        T cost;
        int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] == cost2) (ans[e.to] += ans[i]) %= MOD;
            if(d[e.to] <= cost2) continue;
            ans[e.to] = ans[i];
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return make_pair(d, ans);
}


int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    vector<vector<edge<ll>>> G(n);
    for (int i = 0; i < m; ++i) {
        int u, v; ll d;
        scanf("%d %d %li", &u, &v, &d);
        G[u-1].emplace_back(v-1, d);
        G[v-1].emplace_back(u-1, d);
    }
    vector<ll> d1, ans1, d2, ans2;
    tie(d1, ans1) = dijkstra(s, G);
    tie(d2, ans2) = dijkstra(t, G);
    ll ans = (ans1[t]*ans2[s]) % MOD;
    for (int i = 0; i < n; ++i) {
        if(d1[i] == d2[i] && d1[i] + d2[i] == d1[t]){
            ll x = (ans1[i]*ans2[i]) % MOD;
            (x *= x) %= MOD;
            (ans += MOD-x) %= MOD;
        }
    }
    for (int from = 0; from < n; ++from) {
        for (auto &&i : G[from]) {
            if(d1[from]+i.cost + d2[i.to] == d1[t] &&
               2*d1[from] < d1[t] && d1[t] < 2*d1[i.to]){
                ll x = (ans1[from]*ans2[i.to])%MOD;
                (x *= x) %= MOD;
                (ans += MOD- x) %= MOD;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


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

int linearSearch(int A[],int n,int key)
{
	int i = 0;
	A[n] = key;
	while(A[i] != key)
	{
		i++;
	}
	return i != n;
	/*if (i != n)
	{
		
		cout << "a";
		return true;
	}
	else
	{
		cout << "b";
		return false;
	}*/
}
int main()
{
	int n,S[10001],q,key,sum = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&S[i]);
	}

	scanf("%d",&q);
	for (int i = 0; i < q; ++i)
	{
		scanf("%d",&key);
		if (linearSearch(S,n,key))
		{
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3228
from math import gcd
def prime_table(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

N = int(input())
A = list(map(int,input().split()))
g = A[0]
for i in range(1,N):
    g = gcd(g,A[i])
    if g == 1:
        break
if g != 1:
    print('not coprime')
else:
    PT = prime_table(10**6+1)
    l = len(PT)
    flag = set()
    for j in range(N):
        n = A[j]
        for i in range(l):
            p = PT[i]
            if n % p == 0:
                while n % p == 0:
                    n //= p
                if p in flag:
                    print('setwise coprime')
                    exit()
                else:
                    flag.add(p)
            if p*p > n:
                if n in flag and n != 1:
                    print('setwise coprime')
                    exit()
                else:
                    if n != 1:
                        flag.add(n)
                break
    print('pairwise coprime')

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

int main() {
    string ss[]{"dream","dreamer","erase","eraser"};
    for (auto& s:ss)
        reverse(s.begin(),s.end());
    string s;cin>>s;
    reverse(s.begin(),s.end());
    for (int i=0;i<s.size();) {
        int f=1;
        for (auto t:ss)
            if (s.substr(i,t.size())==t) {
                i+=t.size();
                f=0;
                break;
            }
        if (f) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,ls[30],mx1,mx2,x[370][30],c[30],ans[370][30],a,la,val,mi[30];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=26;i++)scanf("%d",&c[i]),ls[i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=26;j++)
        {
            scanf("%d",&x[i][j]);
        }
    }
    for(int st=1;st<=26;st++)
    {
        for(int i=1;i<=26;i++)ls[i]=0;
        ls[st]=1;
        ans[1][st]=st;
        mi[st]=c[st]+x[1][st];
        for(int i=2;i<=n;i++)
        {
            mx1=0,mx2=1;
            for(int j=1;j<=26;j++)
            {
                int k=((i-ls[j])*c[j])+x[i][j];
                if(mx1<k)mx1=k,mx2=j;
                else if(mx1==k)if(ls[j]<ls[mx2])mx2=j;
            }
            //printf("[%d]",mx1);
            ls[mx2]=i;
            ans[i][st]=mx2;
            mi[st]+=mx1;
        }
    }
    int p1=INT_MIN,p2=1;
    for(int i=1;i<=n;i++)if(p1<mi[i])p1=mi[i],p2=i;
    for(int i=1;i<=n;i++)printf("%d\n",ans[i][p2]);
}


Measured memory_bytes: 3908
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, m, x[100005];
signed main() {
	cin >> n >> m;
	rep(i, m)cin >> x[i];
	if (n >= m) {
		cout << 0 << endl;
		endre;
	}
	sort(x, x + m);
	vector<int>vec;
	rep(i, m - 1) {
		vec.push_back(x[i + 1] - x[i]);
	}
	sort(all(vec));
	reverse(all(vec));
	int sum = 0;
	rep(i, n - 1) {
		sum += vec[i];
	}
	cout << x[m - 1] - x[0] - sum << endl;
	endre;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)


//for range sum query
struct fenwick_tree{
  //0-indexed
  //1-indexed用のコードを0-indexedに落とし込む処理をしているため、可読性がちょっと低い

  // nは元の配列且つBITのサイズ。
  // BITでは、元の配列と同じサイズの配列で管理できる。
  ll n;
  // bitを格納する配列
  vector<ll> bit;
  fenwick_tree(int sz){
    n = sz;
    // bitをサイズn, 値を0で初期化。
    bit.assign(sz,0);
  }
  //add a-th factor w;
  void add(ll a,ll w){
    //0-indexedで入ってきたaをa+1にして、1-indexedに
    //そして各値にアクセスするときだけindexを1減らす
    for(ll i=a+1;i<=n;i+=i&-i) bit[i-1] += w;
  }
  //return sum [0,a)
  ll sum(ll a){
    ll res = 0;
    //0-indexedで入ってきたaをa+1にするが、半開区間なのでa+1-1=aになる
    for(ll i=a;i>0;i-=i&-i) res += bit[i-1];
    return res;
  }
  //return sum [a,b)
  ll sum(ll a,ll b){
    return sum(b)-sum(a);
  }
};

// int main(){
//   // rsqの単位元は0なので、値を全て0にして初期化する。
//   fenwick_tree rsq(10);
//   rsq.add(5,2); // 5番目の値に2を加える。
//   rsq.add(3,1); // 3番目の値に1を加える。
//   cout << rsq.sum(6) << endl; // [0,6)の区間和を出力。結果として3を出力する。
//   cout << rsq.sum(3,5) << endl; // [3,5)の区間和を出力。結果として1を出力する。
// }
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* sample code for AOJ DSL_2_B "Range Sum Query"*/
  int n,q;
  cin >> n >> q;
  fenwick_tree rsq(n);
  REP(i,q){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){//add
      x--;
      rsq.add(x,y);
    }else{
      x--;
      cout << rsq.sum(x,y) << endl;
    }
  }
}



Measured memory_bytes: 3496
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint readE();

string s, t;
vector<char> vec;

llint pos;
bool err;

llint readN()
{
	if(t[pos] == '0'){
		pos++;
		return 0;
	}
	if(t[pos] != '1'){
		err = true;
		return 0;
	}
	llint ret = 0;
	while(t[pos] == '0' || t[pos] == '1'){
		ret *= 2;
		ret += t[pos] - '0';
		pos++;
	}
	return ret;
}

llint readF()
{
	if(t[pos] == '-'){
		pos++;
		return -readF();
	}
	else if(t[pos] == '('){
		pos++;
		int ret = readE();
		if(t[pos] == ')'){
			pos++;
			return ret;
		}
		err = true;
		return 0;
	}
	else if(t[pos] == '0' || t[pos] == '1') return readN();
	
	err = true;
	return 0;
}

llint readT()
{
	llint ret = 1;
	while(1){
		ret *= readF();
		if(t[pos] == '*') pos++;
		else return ret;
	}
}

llint readE()
{
	llint ret = 0, sgn = 1;
	while(1){
		ret += sgn * readT();
		if(t[pos] == '+'){
			pos++;
			sgn = 1;
		}
		else if(t[pos] == '-'){
			pos++;
			sgn = -1;
		}
		else return ret;
	}
}

bool readQ()
{
	llint l = readE();
	if(t[pos] != '='){
		err = true;
		return false;
	}
	pos++;
	llint r = readE();
	if(t[pos] != '#'){
		err = true;
		return false;
	}
	return l == r;
}

int main(void)
{
	cin >> s;
	s += "#";
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'A' && s[i] <= 'Z' || s[i] >= 'a' && s[i] <= 'z') vec.push_back(s[i]);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	int C = vec.size();
	if(C > 8){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'A' && s[i] <= 'Z' || s[i] >= 'a' && s[i] <= 'z'){
			s[i] = (int)(lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin()) + 'a';
		}
	}
	
	llint ans = 0;
	llint perm[8];
	for(int i = 0; i < 8; i++) perm[i] = i;
	const char c[] = {'0', '1', '+', '-', '*', '=', '(', ')'};
	
	t = s;
	do{
		for(int i = 0; i < s.size(); i++){
			if(s[i] >= 'a' && s[i] <= 'z') t[i] = c[perm[s[i]-'a']];
			else t[i] = s[i];
		}
		pos = 0;
		err = false;
		if(readQ() && !err) ans++;
	}while(next_permutation(perm, perm+8));
	
	llint div = 1;
	for(int i = 1; i <= 8-C; i++) div *= i;
	cout << ans / div << endl;
	
	return 0;
}


Measured memory_bytes: 3232
using System;

class HOUSE
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] b = new int[n];
        int[] f = new int[n];
        int[] r = new int[n];
        int[] v = new int[n];

        int[,,] house = new int[4, 3, 10];

        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split();

            b[i] = int.Parse(s[0]);
            f[i] = int.Parse(s[1]);
            r[i] = int.Parse(s[2]);
            v[i] = int.Parse(s[3]);
        }

        for(int i=0;i< n; i++)
        {
            if(house[b[i] - 1, f[i] - 1, r[i] - 1] + v[i] < 0)
            { 
                house[b[i] - 1, f[i] - 1, r[i] - 1] = 0;
            }else if (house[b[i] - 1, f[i] - 1, r[i] - 1] + v[i]>9)
            {
                house[b[i] - 1, f[i] - 1, r[i] - 1] = 9;
            }
            else
            {
                house[b[i] - 1, f[i] - 1, r[i] - 1] = house[b[i] - 1, f[i] - 1, r[i] - 1] + v[i];
            }
        }

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 10; k++)
                {
                    if (k != 9)
                    {
                        Console.Write(" {0}", house[i, j, k]);
                    }else if(k == 9)
                    {
                        Console.WriteLine(" {0}", house[i, j, k]);
                    }
                    
                }

            }
            if(i != 3)
            {
                Console.WriteLine("####################");
            }

        }
    }
}


Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

const int mod = 1000000007;
//==============================


//==============================



int main() {

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  long int a,b,c,d,f[4];
   cin>>a>>b>>c>>d;
   f[0]=a*c;
   f[1]=a*d;
   f[2]=b*c;
   f[3]=b*d;
   
   long int  largest = f[0];
   for(int i = 1;i < 4; i++) {
      /* We are comparing largest variable with every element
       * of array. If there is an element which is greater than
       * largest variable value then we are copying that variable
       * to largest, this way we have the largest element copied
       * to the variable named "largest" at the end of the loop 
       *
       */
      if(largest < f[i])
         largest = f[i];
   } 
   cout<<largest<<endl;
    return 0;
}





Measured memory_bytes: 3616
import os, sys, re, math

N = int(input())
X = [int(n) for n in input().split()]

d = [i ** 2 for i in range(101)]

min_v = 100 ** 2 * 100
for i in range(1, 101):
    min_v = min(min_v, sum(d[abs(x - i)] for x in X))

print(min_v)


Measured memory_bytes: 9828
import java.util.*;

public class Main {
  public static void main(String[] args){    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    if(n<k){
      System.out.println(n*x);
      return;
    }
    System.out.println(k*x+(n-k)*y);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
  char a[12];
  int i,c=0,e=0;
  scanf("%s",a);
  if(a[0]!='A') e=1;
  if(a[1]<'a') e=1;
  for(i=2;a[i+1]!='\0';i++){
    if(a[i]=='C') c++;
    else if(a[i]<'a') e=1;
  }
  if(c!=1) e=1;
  if(a[i]<'a') e=1;
  printf(e==0?"AC":"WA");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int k = scan.nextInt();

        int sum = 0;

        if(a>=k){
            System.out.println(k);
        }
        else{
            sum = a;
            k = k-a;
            if(b>=k) {
                System.out.println(sum);
            }
            else{
                k = k-b;
                if(c>=k){
                    System.out.println(sum-k);}
            }
        }

    }
}

Measured memory_bytes: 35704
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int n, x[10], y[10], f;
double ans;
string s;
vector<int> p;


void A() {
	cin>>n;
	cout<<n*n<<endl;
}

unsigned long long int fact(int x) {
	if (x==0) return 1;
	return (x*fact(x-1))%((int)1e9+7);
}

void B() {
	cin>>n>>s; 
	if (n%2) {cout<<"No"<<endl; return;}
	else for (int i=0; i<n/2; i++) {
		if (s[i]!=s[i+n/2]) {
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
}

unsigned long long int nck(int n, int k) {
	cout<<n<<" "<<k<<endl;
	if (n==0) return 1;
	return (nck(n-1,k-1) + nck(n-1,k)) % 1000000007;
}

void C() {
	cin>>n;
	for (int i=0; i<n; i++) {cin>>x[i]>>y[i]; p.push_back(i);}
	for (int i=0; i<n; i++) {
		for (int j=0; j<i; j++) {
			ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))/n;
			//cout<<i<<" "<<j<<" "<<dist[i][j]<<endl;
		}
	}
	printf("%.10f\n", ans*2);
}

void D() {
	int x, y;
	cin>>x>>y;
	if ((2*y-x)%3) {cout<<0<<endl; return;}
	int n = (2*y-x)/3, m = (2*x-y)/3;
	cout<<n<<" "<<m<<endl;
	cout<<nck(n+m,n)<<endl;
	
}


int main() {
	B();
}

Measured memory_bytes: 256
//B - Sum of Three Integers
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  ll k,s,ans=0;
  scanf("%lld %lld", &k,&s);
  for(ll i = 0; i <= min(s,k); i++) {  //x
    if(0<=s-i && s-i<=k){     //y+z=s-x=s-i, y,s no kumiawase ha...
      ans+=s-i+1;
    }
    else if(k<s-i && s-i<=2*k){
      ans+=2*k-(s-i)+1;
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1728
package main

import (
	"fmt"
)

func Reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var s string
	ss := []string{"maerd", "remaerd", "esare", "resare"}
	fmt.Scan(&s)
	s = Reverse(s)
	for i := 0; i < len(s); {
		b := false
		for j := 0; j < 4; j++ {
			if i+len(ss[j]) > len(s) {
				continue
			}
			if s[i:i+len(ss[j])] == ss[j] {
				b = true
				i += len(ss[j])
			}
		}
		if b == false {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


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

ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

vector<pair<ll,int>> bunkai(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; i++)
    {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while(n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1)
        res.emplace_back(n, 1);
    return res;
}

int main(){
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    auto bun = bunkai(g);
    int ans = bun.size() + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
	//WRWWRWRR     wwwrrrrwwwwrrr
	///112 112
	///1223 12
	int mod = (int) 1e9+7;
	//5 6 11
	//4 4 3 5
	//
	long[] iv;
	long[] res;
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		String s = in.next();
		int n = s.length();
		char[] cs = s.toCharArray();
		int sum = 0;
		int mut = 1;
		Map<Integer,Integer> mp = new HashMap<>();
		mp.put(0,1);
		int res =0;
		for(int i=n-1;i>=0;i--){
			int pos = cs[i]-'0';
			pos*=mut;
			sum+=pos;
			sum%=2019;
			if(mp.containsKey(sum)){
				res+=mp.get(sum);
			}
			mp.put(sum,mp.getOrDefault(sum,0)+1);
			mut*=10;
			mut%=2019;
		}
		out.println(res);
	}
	long inv(long v){
		return power(v,mod-2);
	}
	long div(long a, int b){
		return (a*iv[b])%mod;
	}
	//Map<Long,Long> mp = new HashMap<>();
	long power(long a, long b){
		if(b==0) return 1;
		//if(mp.containsKey(b)) return b;
		long ans = power(a,b/2);
		ans = (ans*ans)%mod;
		if(b%2==1) ans *= a;
		ans%=mod;
//		mp.put(b,ans);
		return ans;
	}

//	public static void main(String[] args){
//		Scanner scanner = new Scanner(new InputStreamReader(System.in));
//		long n = Long.parseLong(scanner.nextLine());
//	}
	public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

	}
}


Measured memory_bytes: 52240
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

bool isPrime(ll n) {
    if (n <= 1) {
        return false;
    }

    for (ll i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

signed main()
{
    int x;
    cin >> x;
    for (int i = x; ; i++) {
        if (isPrime(i)) {
            put(i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3680
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

# 南北のうち南だけ、とか東西のうち東だけ、みたいのがあるとNG
if ('N' in S) ^ ('S' in S) or ('E' in S) ^ ('W' in S):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 5400