akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin >> s;
    int ans = 0;
    int tmp = 0;
    for(int i = 0;i < s.size(); i++)
    {
        if(s[i] == 'A' || s[i] =='T' || s[i] =='C' || s[i] == 'G')
        {
            tmp++;
        }
        else
        {
            tmp = 0;
        }

        if(tmp > ans)
        {
            ans = tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N;cin>>N;
	vector<int> a(N);
	int num_min=0;
	for(int i=0;i<N;i++){
		cin>>a[i];
		if(a[i]<0)num_min++;
	}
	int sum=0;
	if(num_min%2==0){
		for(int i=0;i<N;i++)sum+=llabs(a[i]);
	}
	else{
		for(int i=0;i<N;i++)a[i]=llabs(a[i]);
		sort(a.begin(),a.end());
		sum-=a[0];
		for(int i=1;i<N;i++)sum+=a[i];
	}

	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

int main(){
  int N;
  cin >> N;
  set<string> S;
  string s;
  REP(i,N){
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << endl;

  return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int count=0;
  string S,T;
  cin >> S;
  cin >> T;
  
  for(int i = 0 ; i < S.length() ; i++ ) {
    if (S[i] != T[i]) {
      count += 1;
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3916
s = input()
t = input()


def lcs(s, t)->list:
    sn = len(s)
    tn = len(t)
    dp = [[0 for _ in range(tn+1)] for _ in range(sn+1)]
    for i in range(sn):
        for j in range(tn):
            if s[i] == t[j]: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            else: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j], dp[i][j+1])
    #print(dp)
    return dp


def restore_str(lcs_dp)->str:
    restore = str()
    i = len(s)
    j = len(t)

    while i > 0 and j > 0:
        #print(i, j)
        if lcs_dp[i][j] == lcs_dp[i-1][j]: i -= 1
        elif lcs_dp[i][j] == lcs_dp[i][j-1]: j -= 1
        else: 
            restore = s[i-1] + restore
            i -= 1
            j -= 1

    return restore


def main():
    lcs_dp = lcs(s, t)
    ans = restore_str(lcs_dp)
    return print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 120412
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll mod = 1000000007;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> hen(n, vector<bool>(n));

    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--; b--;
        hen[a][b] = 1;
        hen[b][a] = 1;
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(!hen[i][j])continue;
            hen[i][j] = 0;


            vector<vector<int>> dist(n, vector<int>(n, 10000000));
            for(int k = 0; k < n; k++){
                for(int l = 0;l < n; l++){
                    if(hen[k][l])dist[k][l] = 1;
                }
            }
            for(int k = 0; k < n; k++)dist[k][k] = 0;


            for(int K = 0; K < n; K++){
                for(int I = 0; I < n; I++){
                    for(int J = 0; J < n; J++){
                        dist[I][J] = min(dist[I][J], dist[I][K] + dist[K][J]);
                    }
                }
            }
            bool res = false;
            for(int k = 0; k < n; k++){
                int nax = *max_element(dist[k].begin(), dist[k].end());
                if(nax > 100000)res = true;
            }
            cnt += res;
            hen[i][j] = 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

ll N;
ll C[212345];
vector<vector<int>> x;
ll memo[212345];

ll f(int i) {
	if (i == 0) return 1;
	if (memo[i] != -1) return memo[i];
	auto itr = lower_bound(x[C[i - 1]].begin(), x[C[i - 1]].end(), i - 1);
	if (itr == x[C[i - 1]].begin() || *(itr - 1) + 1 == *itr) return memo[i] = f(i - 1) % 1000000007;
	else return memo[i] = (f(i - 1) + f(*(itr - 1) + 1)) % 1000000007;
}

int main() {

	x.resize(212345);
	rep(i, 212345) memo[i] = -1;

	scanf("%lld", &N);
	rep(i, N) {
		scanf("%lld", &C[i]);
		x[C[i]].push_back(i);
	}

	printf("%lld\n", f(N));

	return 0;
}


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

int main()
{
    int a, b, c, d;
    int h, w;
    cin >> a >> b >> c >> d;
    w = a - c;
    h = b - d;
    int a1,b1,c1,d1;
    a1=c+h;
    b1=d-w;
    c1=a1+w;
    d1=b1+h;
    cout<<a1<<" "<<b1<<" "<<c1<<" "<<d1;
}


Measured memory_bytes: 256
using System;

namespace V0055{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            decimal input;
            while((input = sr.Next<decimal>()) != decimal.MinValue) Console.WriteLine(input * 7.814814814814M);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T) typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T) Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }
    }
}

Measured memory_bytes: 9384
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int now = i;
		int tmp = 0;
		while (now != 0) {
			tmp += now % 10;
			now /= 10;
		}
		if (a <= tmp && tmp <= b)ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(int arg_start,int arg_end){
		start = arg_start;
		end = arg_end;
	}
	int start,end;
};

ll dp[5001][5001],work[16000];


int main(){

	int N,M,K,Q;

	scanf("%d %d %d %d",&N,&M,&K,&Q);

	int LIMIT = 0;
	while(LIMIT < N)LIMIT += 2*K;

	vector<Info> V;

	for(int day = 0; day <= M; day++){
		for(int num = 0; num <= N-1; num++)dp[day][num] = 0;
	}

	dp[0][0] = 1;

	for(int day = 0; day <= M-1; day++){

		for(int i = 0; i < 2*N; i++)work[i] = 0;

		for(int num = 0; num <= N-1; num++){

			if(dp[day][num] == 0)continue;

			work[num] += dp[day][num];
			work[num+K] -= dp[day][num];
			work[num+LIMIT] -= dp[day][num];
			work[num+LIMIT+K] += dp[day][num];
		}

		for(int i = 1; i < 2*N; i++){
			work[i] += work[i-1];
		}

		for(int i = 0; i < 2*N; i++){
			if(i+2*K < 2*N){
				work[i+2*K] += work[i];
			}else{
				break;
			}
		}

		for(int i = 0; i < 2*N; i++){
			dp[day+1][i%N] += work[i]%MOD;
		}
	}

	int a,b,c;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d",&a,&b,&c);

		c = (c-a+N)%N;

		printf("%lld\n",dp[b][c]%MOD);
	}

	return 0;
}



Measured memory_bytes: 198692
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int d = Y - (2 * X);
    
    if(d >= 0 && d % 2 == 0 && (d / 2) <= X)
    {
      System.out.println("Yes");
    }
      else
      {
      System.out.println("No");
      }
  }
}


Measured memory_bytes: 35528
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

main(){
  char ch;
  int id, p, t;
  vector<pair<int, int> > T;
  vector<int> R, TR;
  while(1){
    cin >> id >> ch >> p;
    if ( id == 0 && p == 0 ) break;
    T.push_back(make_pair(p, id));
  }
  sort(T.begin(), T.end());
  reverse(T.begin(), T.end());
  R.resize(T.size());
  TR.resize(T.size());
  int rank = 1;
  R[0] = rank;
  for ( int i = 1; i < T.size(); i++ ) {
    if ( T[i-1].first == T[i].first ) R[i] = rank;
    else R[i] = ++rank;
  }
  for ( int i = 0; i < T.size(); i++ ) TR[T[i].second-1] = R[i];
  while( cin >> t ) cout << TR[t-1] << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;


void solve()
{
	int a, b;
	cin >> a >> b;

	cout << max(a - 2 * b, 0);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
        int i=0,j,a,b;
        char s[1000];
        scanf("%s",s);
        j=strlen(s);
        
        printf("%c%d%c",s[0],j-2,s[j-1]);
                return 0;
}

Measured memory_bytes: 128
# coding: utf-8

import sys

def dfs(rw,cm):
    global flag
    flag[rw][cm] = 1
    if 0 <= rw - 1 and mp[rw-1][cm] == '.' and flag[rw-1][cm] == 0:
        dfs(rw-1,cm)
    if cm + 1 < m and mp[rw][cm+1] == '.' and flag[rw][cm+1] == 0:
        dfs(rw,cm+1)
    if 0 <= cm - 1 and mp[rw][cm-1] == '.' and flag[rw][cm-1] == 0:
        dfs(rw,cm-1)
    if rw + 1 < n and mp[rw+1][cm] == '.' and flag[rw+1][cm] == 0:
        dfs(rw+1,cm)

if __name__ == '__main__':
    while 1:
        m,n = map(int,input().split())
        if m == 0 and n == 0:
            break
        mp = []
        for i in range(n):
            mp.append(list(input()))
            if '@' in mp[-1]:
                stj = mp[-1].index('@')
                sti = i
        flag = [[0 for i in range(m)] for j in range(n)]
        dfs(sti,stj)
        print(sum(flag[i].count(1) for i in range(n)))

Measured memory_bytes: 7840
sa = list(input())
sb = list(input())
sc = list(input())

now = sa.pop(0)
while True:
    if now == "a":
        if not sa:
            print("A")
            break
        now = sa.pop(0)
    elif now == "b":
        if not sb:
            print("B")
            break
        now = sb.pop(0)
    else:
        if not sc:
            print("C")
            break
        now = sc.pop(0)


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

int main(){
  int x, n;
  cin>>n;
  double rate = 1.08;
  x = n/rate;
  
  if((int)(x*rate) == n){
    cout<< x << endl;
  }
  else if((int)((x+1)*rate) == n){
  	cout<< x + 1 << endl;
  }
  else cout<<":(";
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  int N; cin >> N;
  int tmax = 0;
  int t[N+2]; FOR(i,0,N) cin >> t[i+1], tmax += t[i+1];
  int v[N+2]; FOR(i,0,N) cin >> v[i+1];
  v[0] = v[N+1] = 0;
  t[0] = t[N+1] = 0;
  double l[2*tmax+1], r[2*tmax+1];
  l[0] = 0;
  r[2*tmax] = 0;
  CLR(l);CLR(r);
  int i = 1;
  int T = 0;
  FOR(k,0,N+1) {
    T += t[k];
    while(i <= (T + t[k+1]) * 2) {
      l[i] = min(l[i-1] + 0.5, (double)v[k+1]);
      i++;
    }
  }
  T = 0;
  i = 1;
  for(int k = N + 1; k > 0; k--) {
    T += t[k];
    while(i <= (T + t[k-1]) * 2) {
      r[2 * tmax - i] = min(r[2 * tmax - i + 1] + 0.5, (double)v[k-1]);
      i++;
    }
  }
  // FOR(i,0,tmax+1) cout << l[i] << " " << r[i] << endl;
  double ans = 0;
  FOR(i,0,2*tmax) {
    ans += (min(l[i], r[i]) + min(l[i+1], r[i+1])) * 0.25;
  }
  printf("%.10lf\n", ans);
  return 0;
}

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

typedef vector<int> vi;
typedef long long int ll;
typedef pair<int,int> pi;
typedef unsigned long long int ull;

ll lsone(ll p){return(p & -p);}

int main(){
    std::ios::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n, m, a, b;
    cin >> n;
    cout << (n - 1) / 2;
}

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

int func(int l, int r){
    int ans, tmp;
    ans = N;
    for(int i=l; i<=r; i++){
        for(int j=i+1; j<=r; j++){
            tmp = (i*j) % N;
            ans = tmp < ans ? tmp : ans;
        }
    }
    return ans;
}

int main(void){
    int L, R;
    cin >> L >> R;
    // mod
    int l, r, ans;
    l = L % N;
    r = R % N;
    if(R-L>=N){
        cout << 0 << endl;
    }else{
        if(l < r){
            ans = func(l, r);
            cout << ans << endl;
        }else{
            cout << 0 << endl;
        }
    }
    return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>

using namespace std;
typedef long long ll;

int cal_gcd(int a, int b);
int main(){
    int k;
    ll sum = 0;
    cin >> k;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                sum += cal_gcd(i,cal_gcd(j,l));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

int cal_gcd(int a, int b){
    int buf = 0;
    if(a < b) {
        buf = b;
        b = a;
        a = buf;
    }
    if(a % b == 0) return b;
    return cal_gcd(a%b,b);
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!

def bubble_sort(A):
    for i in range(len(A)):
        flag = 1
        while flag:
            flag = 0
            for j in range(len(A)-1, i, -1):
                if A[j][1] < A[j-1][1]:
                    A[j], A[j-1] = A[j-1], A[j]
                    flag = 1
    return A

def sentaku_sort(A):
    for i in range(len(A)):
        min_n = i
        for j in range(i+1, len(A)):
            if A[j][1] < A[min_n][1]:
                min_n = j
        if min_n != i:
            A[i], A[min_n] = A[min_n], A[i]
    return A

def isStable(A, B):
    for i in range(len(A)):
        for j in range(i+1, len(A)):
            for a in range(len(A)):
                for b in range(a+1, len(A)):
                    if A[i][1] == A[j][1] and A[i] == B[b] and A[j] == B[a]:
                        return False
    return True
    

def hyoji(A):
    for i in range(len(A)):
        if i != len(A)-1:
            print(A[i], end = ' ')
        else:
            print(A[i])


n = int(input())
A = input().split()

B = bubble_sort(A[:])
hyoji(B)
if isStable(A, B):print('Stable')
else:print('Not stable')

C = sentaku_sort(A[:])
hyoji(C)
if isStable(A, C):print('Stable')
else:print('Not stable')



Measured memory_bytes: 5612
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val graph = Array(n) { mutableListOf<Int>() }
    val ea = IntArray(n-1)
    val eb = IntArray(n-1)

    repeat(n-1) {
	val (a, b) = readLine()!!.split(' ').map { it.toInt()-1 }
	ea[it] = a
	eb[it] = b
	graph[a].add(it)
	graph[b].add(it)
    }

    val ans = IntArray(n-1)
    val ord = IntArray(n)
    val parent = IntArray(n)
    val parentc = IntArray(n)
    var len = 1
    repeat(n) {
	val v = ord[it]
	var color = 1
	for (k in graph[v]) {
	    val w = ea[k] xor eb[k] xor v
	    if (w != parent[v]) {
		if (color == parentc[v]) color++
		parent[w] = v
		parentc[w] = color
		ans[k] = color
		ord[len++] = w
		color++
	    }
	}
    }

    println(ans.max())
    ans.forEach { println(it) }
}


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

int main(){
	int n;
	cin>>n;
	string taro,hanako;
	int taroscore=0,hanakoscore=0;
	for(int i=0;i<n;++i){
		int dec=0;
		cin>>taro>>hanako;
		for(int j=0;j<min(taro.length(),hanako.length());++j){
			if(taro[j]>hanako[j]){
				taroscore+=3;
				dec=1;
				break;
			}
			else if(taro[j]<hanako[j]){
				hanakoscore+=3;
				dec=1;
				break;
			}
		}
		if(dec==0){
			if(taro.length()>hanako.length())taroscore+=3;
			else if(taro.length()<hanako.length())hanakoscore+=3;
			else{
				taroscore+=1;
				hanakoscore+=1;
			}
		}
	}
	cout<<taroscore<<" "<<hanakoscore<<endl;
}


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

#define MAX 102

int h;
int w;

char buf[MAX][MAX];

short dp[MAX][MAX][MAX][MAX];
pair<int, int> E;
int im[MAX][MAX];
int gt(int a, int b){
	if (a < 0 || b < 0){
		return 0;
	}
	return im[a][b];
}
int rect(int x1, int x2, int y1, int y2){
	return gt(x2, y2) + gt(x1 - 1, y1 - 1) - gt(x2, y1 - 1) - gt(x1 - 1, y2);
}
int dfs(int a, int b, int c, int d){
	if (a > b || c > d)return 0;
	return dp[a][b][c][d];
}
int main(){
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		scanf("%s", buf[i]);
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (buf[i][j] == 'E'){
				E = make_pair(i, j);
			}
			if (buf[i][j] == 'o'){
				im[i][j]++;
			}
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 1; j < w; j++){
			im[i][j] += im[i][j - 1];
		}
	}
	for (int j = 0; j < w; j++){
		for (int i = 1; i < h; i++){
			im[i][j] += im[i - 1][j];
		}
	}
	int a;
	int b;
	int c;
	int d;
	short int can;
	short int add;
	for (int rng = 1; rng <= h; rng++){
		for (int rng2 = 1; rng2 <= w; rng2++){
			for (int i = 0; i + rng <= h; i++){
				for (int j = 0; j + rng2 <= w; j++){
					a = i;
				 b = a + rng - 1;
					c = j;
					d = j + rng2 - 1;
					{
						can = E.first + a + 1;
						if (a + 1 <= can&&can <= b){
							add = rect(can, can, max(c, E.second - (w - d) + 1), min(d, E.second + c));
							add += dfs(a + 1, b, c, d);
							dp[a][b][c][d] = add;
						}
					}

					//choose b
					{
					 can = E.first - (h - b);
						if (a <= can&&can <= b - 1){
						 add = rect(can, can, max(c, E.second - (w - d) + 1), min(d, E.second + c));
							add += dfs(a, b - 1, c, d);
							dp[a][b][c][d] = max(dp[a][b][c][d], add);
						}
					}
					//choose c
					{
						can = E.second + c + 1;
						if (c + 1 <= can&&can <= d){
							add = rect(max(a, E.first - (h - b) + 1), min(b, E.first + a), can, can);
							add += dfs(a, b, c + 1, d);
							dp[a][b][c][d] = max(dp[a][b][c][d], add);
						}
					}
					//choose d
					{
						can = E.second - (w - d);
						if (c <= can&&can <= d - 1){
							add = rect(max(a, E.first - (h - b) + 1), min(b, E.first + a), can, can);
							add += dfs(a, b, c, d - 1);
							dp[a][b][c][d] = max(dp[a][b][c][d], add);
						}
					}
				}
			}
		}
	}
	
	int ans=dfs(0, h - 1, 0, w - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 209152
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;

int main()
{
    int age;
    cin >> age;
    if (age == 3 or age == 5 or age == 7)
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }

    sws;
}

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


int main() {
    string s;
    cin >> s;
    int blacks = 0;
    ll ans = 0;
    rep(i,s.length()){
        if(s[i] == 'W'){
            ans += blacks;
        }else blacks++;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##################################
# University of Wisconsin-Madison
# Author: Yaqi Zhang
##################################

# standard library
import sys
sys.setrecursionlimit(10**9)

from functools import lru_cache

def main():
    N = int(input())
    INF = 10**18
    nums = list(map(int, input().split()))
    @lru_cache(None)
    def dp(idx, n):
        if idx >= N:
            return -INF
        if N - idx + 2 < 2 * n:
            return -INF
        if n == 0:
            return 0
        elif n == 1:
            return max(nums[idx:])
        return max(nums[idx] + dp(idx + 2, n - 1), dp(idx + 1, n))
    print(dp(0, N // 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 204696
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int N,K;
int main (){
    cin >> N >> K;
    int l[N];
    for(int i=0; i<N; i++){
        cin >> l[i];
    }
    sort(l, l+N);
    int ans = 0;
    for(int i=N-1; K>0; i--){
        ans += l[i];
        K--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll h, w, k;

ll memo[8][110];

ll dfs(ll pos, ll hei) {
	if(memo[pos][hei] != -1) return memo[pos][hei];
	if(hei == h + 1) {
		if(pos == k) return 1;
		else return 0;
	}
	ll ret = 0;
	REP(i,(1ll<<(w-1))) {
		bitset<7> bi(i);
		bool d = true;
		REP(j,w-2) if(bi[j] == 1 && bi[j + 1] == 1) d = false;
		if(!d) continue;
		bool upd = false;
		if(pos > 0 && bi[pos - 1]) {
			upd =true;
			ret += dfs(pos - 1, hei + 1);
		}
		if(pos < w - 1 && bi[pos]) {
			upd = true;
			ret += dfs(pos + 1, hei + 1);
		}
		if(!upd) ret += dfs(pos, hei + 1);
	}
	return memo[pos][hei] = ret % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w >> k;
	k--;
	if(w == 1) {
		cout << 1 << endl;
		return 0;
	}
	REP(i,8) REP(j,110) memo[i][j] = -1;
	cout << dfs(0, 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int NMAX =1e5 + 10;
ll a,b,n;
ll cal(ll x){
	return (a*x)/b-a*(x/b);
}

int main(int argc, char const *argv[])
{
	
	scanf("%lld%lld%lld",&a,&b,&n);
	ll ans=cal(n),l = 1,r = n;
    while(l<r){
        ll m1=(2*l+r)/3;
        ll m2=(2*r+l+2)/3;
        ll lv = cal(m1),rv = cal(m2);
        ans = max(ans,max(lv,rv));
        if(lv > rv)
            r=m2-1;
        else
            l=m1+1;
    }

	for(register ll i = max(1ll,l-1000);i <= min(n,l+1000);i++)
		ans = max(ans,cal(i));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void solve()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] == '1')
		{
			++ans;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

static const int MAX = 1e6+5;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int n;
vector<bool> pflg(1000010);
vector<int> a(200010);
vector<llint> aa(1000010);

bool isPrime(int p) {
    int i;

    if (p<2) return false;
    else if (p==2) return true;
    if (p%2==0) return false;
    for(i=3;i*i<=p;i+=2) {
        if(p%i==0) return false;
    }
    return true;
}

void yakusuu_zeta(int m, vector<llint>& dp){
	//g(x)=Σ[k|x]f(k)のとき、fからgを作る
    for(int im=2;im<=m;im++) {
        if(!pflg.at(im)) {
            for(int ik=1;ik<m/im+1;ik++) {
                dp.at(ik*im) += dp.at(ik);
            }
        }
    }
}

int main(void) {
    cin >> n;

    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        aa.at(a.at(in))++;
    }

    pflg.at(0) = true;
    pflg.at(1) = true;
    for(int ip=2;ip*ip<=MAX;ip++) {
        if(!pflg.at(ip)) {
            for(int jp=ip*ip;jp<=MAX;jp+=ip) {
                pflg.at(jp) = true;
            }
        }
    }
    yakusuu_zeta(1000000, aa);

    int ans = 0;
    for(int in=0;in<n;in++) {
        if(aa.at(a.at(in))==1) ans++;
    }
    cout << ans << endl;
    // for(int in=0;in<100;in++) {
    //     cout << aa.at(in) << " ";
    //     if(in%10==9) cout << endl;
    // }
    return 0;
}


Measured memory_bytes: 11772
#include <iostream>
#include <cstdlib>
#include <climits>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int len = S.size();
  int ans = INT_MAX;

  for(int i = 0; i < len-2; i++){
    int num = stoi(S.substr(i, 3));
    ans = min(ans, abs(num-753));
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
      	return y
    else:
      	while x%y!=0:
      	    z =	x%y
      	    x =	y
      	    y =	z
      	else:
      	    return z

def lcm(m, n):
    return int(m * n/gcd(m, n))

AB=list(map(int, input().split()))

print(lcm(AB[0],AB[1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
//int nm[10001][10001] = {0};
 
map<pair<int,int>,int> nm;
 
int b[10000];
 
int main() {
    int n,m;
 
    cin >> n >> m;
 
    while(1){
        int s,t,e;
        scanf(" %d %d %d",&s,&t,&e);
        if( (s+t+e) == 0) break;
        //nm[s][t] = e;
        nm[make_pair(s,t)] = e;
    }
 
    int l;
 
    cin >> l;
 
    pair<int,int> tmp;
 
    while(l--) {
 
        int c[n+1] = {0};
 
        for(int i=1;i<=m;i++){
            scanf(" %d",&b[i]);
        }
 
        int i, j;
        for (i = 1; i <= n; i++) {
            /*for (j = 0; j < m; j++) {
                c[i] = c[i] + nm[i][j+1] * b[j];
            }*/
        }
        for(map<pair<int,int>,int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) {
            tmp = itr->first;
            c[tmp.first] += b[tmp.second] * itr->second;
            //cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << tmp.second << endl;
        }
 
 
        for(int i=1;i<=n;i++){
            //cout << c[i];
            printf("%d",c[i]);
            if(i!=n) printf(" ");//cout <<  ' ';
        }
        printf("\n");
 
    }
    return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	string s; cin >>s;
	vector<int>a;
	int i=0;
	int cnt=1;
	while(i<s.size()-1){
      if(s[i]==s[i+1] ){
      	cnt++;
      	i++;
      }
      else{
      	a.push_back(cnt);
      	cnt=1;
      	i++;
      }
	}
    a.push_back(cnt);
    int bsum=0;
    int wsum=0;
    int ans =2000000;
    if(s[0]=='.'){
    	for(int i=1;i<a.size();i+=2)
    		bsum+=a[i];
    	for(int i=2;i<a.size();i+=2)
    		wsum+=a[i];
    	if(a.size()%2 ==0){
    		int cntb=bsum;
    		int cntw=wsum;
    		ans=min(ans,cntb);
    		ans=min(ans,cntw);
    		cntb=0;
    		for(int i=1;i<=a.size()/2;i++){
    			cntw-=a[i*2];
    			cntb+=a[i*2-1];

    			ans=min(ans,cntb+cntw);

    		}
    	}
    	if(a.size()%2 ==1){
    		int cntb=bsum;
    		int cntw=wsum;
    		ans=min(ans,cntb);
    		ans=min(ans,cntw);
    		cntb=0;
    		for(int i=1;i<=(a.size()-1)/2;i++){
    			cntw-=a[i*2];
    			cntb+=a[i*2-1];

    			ans=min(ans,cntb+cntw);

    		}
    	}


    }
    if(s[0]=='#'){
    	for(int i=0;i<a.size();i+=2)
    		bsum+=a[i];
    	for(int i=1;i<a.size();i+=2)
    		wsum+=a[i];
    	if(a.size()%2 ==1){
    		int cntb=bsum;
    		int cntw=wsum;
    		ans=min(ans,cntb);
    		ans=min(ans,cntw);
    		cntb=0;
    		for(int i=1;i<=(a.size()+1)/2;i++){
    			cntw-=a[i*2-1];
    			cntb+=a[i*2-2];

    			ans=min(ans,cntb+cntw);

    		}
    	}
    	if(a.size()%2 ==0){
    		int cntb=bsum;
    		int cntw=wsum;
    		ans=min(ans,cntb);
    		ans=min(ans,cntw);
    		cntb=0;
    		for(int i=1;i<=(a.size()-1)/2;i++){
    			cntw-=a[i*2-1];
    			cntb+=a[i*2-2];

    			ans=min(ans,cntb+cntw);

    		}
    	}


    }
    cout << ans << endl;
}


Measured memory_bytes: 1532
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

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

int main(){
    char a=in;
    if ((int)a-(int)'Z'<=0) cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NK = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] l = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            Array.Sort(l);
            Array.Reverse(l);
            long sum = 0;
            for(int j = 0; j < NK[1]; j++)
            {
                sum += l[j];
            }
            Console.WriteLine(sum);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);

Measured memory_bytes: 28152
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define PI 3.1415926535

int dim;
 
void Koch(double, double, double, double, int);
 
int main(){
  int i;
  double x1 = 0, y1 = 0, x2 = 100, y2 = 0;
   
  scanf("%d",&dim);
 
  printf("%1.8f %1.8f\n",x1,y1);
   
  if(0<=dim || dim<=6){
    Koch(x1,y1,x2,y2,dim);
  }
   
  printf("%1.8f %1.8f\n",x2,y2);
   
  return 0;
}
 
void Koch(double x1, double y1, double x2, double y2, int dim) {
  double x3=0, y3=0, x4=0, y4=0, x5=0, y5=0;
  double s , c;
   
  if(dim != 0){
    s = sin(PI/3);
    c = cos(PI/3);
 
    x3 = ( 2*x1 +   x2 ) / 3;
    y3 = ( 2*y1 +   y2 ) / 3;
    x5 = (   x1 + 2*x2 ) / 3;
    y5 = (   y1 + 2*y2 ) / 3;
    x4 = x3 + (x5-x3)*c + (y5-y3)*s;
    y4 = y3 - (x5-x3)*s + (y5-y3)*c;
    Koch( x1, y1, x3, y3, dim-1 );
    printf("%1.8f %1.8f\n",x3,fabs(y3));
    Koch( x3, y3, x4, y4, dim-1 );
    printf("%1.8f %1.8f\n",x4,fabs(y4));
    Koch( x4, y4, x5, y5, dim-1 );
    printf("%1.8f %1.8f\n",x5,fabs(y5));
    Koch( x5, y5, x2, y2, dim-1 );
}
  return;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args)throws IOException
	{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	int N = Integer.parseInt(br.readLine());
	int K = Integer.parseInt(br.readLine());
	int X = Integer.parseInt(br.readLine());
	int Y = Integer.parseInt(br.readLine());
	if(N<=K){
		System.out.println(X*N);
	}
	else{
	System.out.println((X*K)+(N-K)*Y);
	}
	}

}


Measured memory_bytes: 8148
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 0, 6) if(s[i] == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [d] <- readInts
  print . showAnswer $ solve d

type Input  = Int
type Output = String

solve :: Input -> Output
solve d
  | d == 25 = "Christmas"
  | d == 24 = "Christmas Eve"
  | d == 23 = "Christmas Eve Eve"
  | d == 22 = "Christmas Eve Eve Eve"

showAnswer :: Output -> Answer
showAnswer = String

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

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

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.lang.Math;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
		int div = 2;
		int count = 0;
		
		while(Math.sqrt(a) > div ){
			for(int tempdiv = div;a%tempdiv == 0;tempdiv = tempdiv * div){
				a/= tempdiv;
				count++;
			}
            while(a%div==0){
              a/=div;
            }//除爆你
			div++;
			}
      if(a !=1){count++;}
      System.out.print(count);
    }
}

Measured memory_bytes: 35908
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 105
int a[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	int ans=10000005;
	for(int i=1;i<=100;i++)
	{
		int cur=0;
		for(int j=1;j<=n;j++)
		{
			cur+=(a[j]-i)*(a[j]-i);
		}
		if(cur<ans) ans=cur;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
function Main(input){
    input = input.split("\n");
    var mem = input[1].split(" ").map(Number);
    var sum = 0;
    var num = mem[0];
    input.shift();
    input.shift();
    input.forEach(function(val){
        sum += Math.ceil(num/val);
    })
    console.log(sum+mem[1]);
  }Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,s;
    cin>>n>>s;
    vector<int> A(n);
    for(auto &a : A) cin>>a;
    vector<vector<ll>> dp(n+1,vector<ll>(s+1));
    dp[0][0] = 1;
    for(int i=0;i<n;++i){
        for(int j=0;j<=s;++j){
            dp[i+1][j] += 2*dp[i][j];
            dp[i+1][j] %= mo2;
            if(j+A[i] <= s){
                dp[i+1][j+A[i]] += dp[i][j];
                dp[i+1][j+A[i]] %= mo2;
            }
        }
    }
    cout << dp[n][s] <<  endl;
    return 0;
}


Measured memory_bytes: 73652
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

H, W = map(int, input().split())
c = [list(input()) for _ in range(H)]

cnt = 0
for row in c:
    for chara in row:
        if chara == '#':
            cnt += 1
res = H*W - cnt

def check(ny, nx):
    if 0<=ny<=H-1 and 0<=nx<=W-1 and c[ny][nx]=='.':
        return True
    else:
        return False

deq = deque()
deq.append([(0, 0)]) # insert indices
ddy = [-1, 0, 1, 0]
ddx = [0, -1, 0, 1]
step = 0
found = False
while deq[0]:
    nqueue = []
    cqueue = deq.popleft()
    for val in cqueue:
        y, x = val
        if val==(H-1, W-1):
            found = True
            break
        for dy, dx in zip(ddy, ddx):
            ny, nx = y+dy, x+dx
            if check(ny, nx):
                c[ny][nx] = '#'
                nqueue.append((ny, nx))
    if found: break
    deq.append(nqueue)
    step += 1

if not(found):
    print(-1)
    exit()
res -= (step+1)
print(res)



Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=1e18;
const int maxn=(1e6)+10;
int n,m,K;
vector<vector<char> > s;
vector<vector<ll> > dis[4];
vector<vector<bool> > vis[4];
char S[maxn];
int xs,ys,xt,yt;
ll ans,tmp;
ll up(ll x) {
	if (x%K==0) return x;
	return x+K-x%K;
}
int fx[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
struct node { int z,x,y; };
struct cmp {
	bool operator() (node A,node B) {
		return dis[A.z][A.x][A.y]>dis[B.z][B.x][B.y];
	}
};
priority_queue<node,vector<node>,cmp> q;
void insert(int x,int y,int z,int d) {
	if (1<=x&&x<=n&&1<=y&&y<=m&&s[x][y]=='.') {
		if (dis[z][x][y]>d) {
			dis[z][x][y]=d;
			q.push((node){z,x,y});
		}
	}
}
int main() {
//	freopen("1.txt","r",stdin);
	read(n); read(m); read(K);
	read(xs); read(ys); read(xt); read(yt);
	
	s.resize(n+2);
	for (int i=1;i<=n;i++) {
		s[i].resize(m+2);
		scanf("%s",S+1);
		for (int j=1;j<=m;j++) s[i][j]=S[j];
	}
	
	for (int k=0;k<=3;k++) {
		dis[k].resize(n+2); vis[k].resize(n+2);
		for (int i=1;i<=n;i++) {
			dis[k][i].resize(m+2);
			vis[k][i].resize(m+2);
			for (int j=1;j<=m;j++) dis[k][i][j]=INF;
		}
		dis[k][xs][ys]=0;
		q.push((node){k,xs,ys});
	}
	int x,y,z,a,b; node u;
	while (!q.empty()) {
		u=q.top(); q.pop();
		z=u.z,x=u.x,y=u.y;
		if (vis[z][x][y]) continue;
		//printf("%d %d %d %d\n",z,x,y,dis[z][x][y]);
		vis[z][x][y]=1;
		insert(x+fx[z][0],y+fx[z][1],z,dis[z][x][y]+1);
		insert(x,y,(z+3)%4,up(dis[z][x][y]));
		insert(x,y,(z+1)%4,up(dis[z][x][y]));
	}
	ans=INF;
	for (int i=0;i<=3;i++)
		ans=min(ans,up(dis[i][xt][yt]));
	if (ans>=INF) printf("-1\n");
	else printf("%lld\n",ans/K);
	
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 39096
N, K = map(int, input().split())

d_list = []
A_list = []
for _ in range(K):
    d_list.append(int(input()))
    tmp = list(map(int, input().split()))
    for a in tmp:
        A_list.append(a)

A_set = set(A_list)
print(N - len(A_set))

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int l[10];
int N, A, B, C;
int ans;

void solve(int n, vector<int>& num)
{
    if (n >= N)
    {
        vector<int> a, b, c;
        rep(i, N)
        {
            if (num[i] == 1) a.push_back(i);
            else if (num[i] == 2) b.push_back(i);
            else if (num[i] == 3) c.push_back(i);
        }
        if (a.size() == 0 or b.size() == 0 or c.size() == 0) return;

        int tmp = 0;
        int aa, bb, cc;
        aa = bb = cc = 0;

        // a
        tmp += 10 * (a.size()-1);
        rep(i, a.size()) aa += l[a[i]];
        tmp += abs(A - aa);

        // b
        tmp += 10 * (b.size()-1);
        rep(i, b.size()) bb += l[b[i]];
        tmp += abs(B - bb);

        // c
        tmp += 10 * (c.size()-1);
        rep(i, c.size()) cc += l[c[i]];
        tmp += abs(C - cc);

        ans = min(ans, tmp);
        return;
    }

    num[n] = 0;
    solve(n+1, num);

    num[n] = 1;
    solve(n+1, num);

    num[n] = 2;
    solve(n+1, num);

    num[n] = 3;
    solve(n+1, num);
}

int main()
{
    ans = 1e8;
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> l[i];

    vector<int> num(N, 0);
    solve(0, num);

    cout << ans << endl;
}


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

int main(void)
{
  int x=3;
  int y;
//  int z;  
//  z = pow(x, 10);
  scanf("%d", &x);
//  printf("%d\n",x);
  y = x*x*x;
  printf("%d\n",y);
//  printf("%d\n",z);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    rep(i, 0, n - 1){
        cin >> c[i] >> s[i] >> f[i];
    }   
    rep(i, 0, n){
        int ans = 0;
        rep(j, i, n - 1){
            if(ans <= s[j]) ans = s[j];
            else ans = (ans + f[j] - 1) / f[j] * f[j];
            ans += c[j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256