akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

int main() {
    using namespace std;
    long long n,a[200000]={},s,w;
    bool flag=0;
    cin>>n;
    for (long i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a,a+n);
    s=a[n-1];
    w=n-2;
    for (long j = n-2; j >0; --j) {
        s+=a[w];
        if (flag)
            w--;
        flag=!flag;
    }
    cout<<s;
    return 0;
    }

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

typedef struct p{
    double x;
    double y;
}vertex;

vertex MakeTriangleBase1(vertex p1,vertex p2){
    vertex base;

    if(p1.x < p2.x) base.x=(p2.x-p1.x)/3.0 + p1.x;
    else base.x = (p1.x-p2.x)/3.0*2 + p2.x;

    if(p1.y < p2.y) base.y=(p2.y-p1.y)/3.0 + p1.y;
    else base.y = (p1.y-p2.y)/3.0*2 + p2.y;

    return base; 
}

vertex MakeTriangleBase2(vertex p1, vertex p2){
    vertex base;

    if(p1.x < p2.x) base.x=(p2.x-p1.x)/3.0*2 + p1.x;
    else base.x = (p1.x-p2.x)/3.0 + p2.x;

    if(p1.y < p2.y) base.y=(p2.y-p1.y)/3.0*2 + p1.y;
    else base.y = (p1.y-p2.y)/3.0 + p2.y;

    return base;
}

vertex MakeTriangleTop(vertex p1, vertex p2){
    vertex top;
    if(p1.x > p2.x){
        if(p1.y < p2.y){
            top.x = p2.x - (p1.x - p2.x);
            top.y = p1.y;
        }else if(p1.y > p2.y){
            top.x = p1.x + (p1.x - p2.x);
            top.y = p2.y;
        }else{
            top.x = (p1.x + p2.x)/2.0;
            top.y = p2.y - ((top.x - p2.x) * sqrt(3.0));
        }
    }else{
        if(p1.y < p2.y){
            top.x = p1.x - (p2.x - p1.x);
            top.y = p2.y;
        }else if(p1.y > p2.y){
            top.x = p2.x + (p2.x - p1.x);
            top.y = p1.y;
        }else{
            top.x = (p1.x + p2.x)/2.0;
            top.y = p1.y + ((p2.x - top.x) * sqrt(3.0));
        }
    }
    return top;
}

void KochCurve(int n, vertex start, vertex end){
    vertex triangle[3];

    if(n == 0){
        printf("%.8f %.8f\n",end.x,end.y);
    }else{
        triangle[0] = MakeTriangleBase1(start,end);
        triangle[1] = MakeTriangleBase2(start,end);
        triangle[2] = MakeTriangleTop(triangle[0],triangle[1]);

        KochCurve(n-1,start,triangle[0]);
        KochCurve(n-1,triangle[0],triangle[2]);
        KochCurve(n-1,triangle[2],triangle[1]);
        KochCurve(n-1,triangle[1],end);
    }
    return;
}

int main(){
    int n;
    vertex start = {0,0};
    vertex end = {100,0};

    scanf("%d",&n);
    printf("%.8f %.8f\n",start.x,start.y);
    KochCurve(n,start,end);

    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

ll n,x;

inline ll gcd(ll a,ll b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> x;
  cout << 3 * (n - gcd(n,x));
}

Measured memory_bytes: 256
char m[98],v[98],c;C(i){return m[i]==c&!v[i]?v[i]=1,1+C(i+1)+C(i-1)+C(i+7)+C(i-7):0;}E(i){m[i]==79?m[i]=0:m[i]==c?m[i]=0,E(i+1),E(i-1),E(i+7),E(i-7):0;}main(i,e,n){for(read(0,m+7,3);read(0,m+7,84);printf("%d\n",n))for(e=n=-1;e;n++){for(i=11*84;i--;m[7+e]<47?m[7+e]=m[e],m[e]=0:0)e=i%84;memset(v,e=0,98);for(i=6;++i<7*13;c&&strchr("RGBYP",c)&&C(i)>3&&E(e=i))c=m[i];}}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

const ll MOD = 1e9 + 7;
const int INF = 55;
ll dp [INF] [INF * INF];

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    int w, h, n;
    cin >> w >> h >> n;

    int x, y, a;

    int x_left = 0, x_right = w, y_down = 0, y_up = h;

    while (n--)
    {
        cin >> x >> y >> a;


        if (a == 1)
        {
            x_left = max(x_left, x);
            
        }

        else if (a == 2)
        {
            x_right = min(x_right,x);
        }

        else if (a == 3)
        {
            y_down = max(y_down, y);
            
        }

        else if (a == 4)
        {
            y_up = min(y_up, y);
            
        }

    }

    ll ans = max(0, x_right-x_left) * max(0, y_up-y_down);

    cout << ans << endl;


}


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


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  constexpr char endl = '\n';

  int n, k;
  const int INF=1e9+5;
  cin >> n >> k;
  vector<int> arr;
  vector<ll> dp(n,INF);
  for (int i=0; i<n; ++i) {
    int a;
    cin >> a;
    arr.push_back(a);
  }

  dp[0]=0;
  for (int i=0; i<n-1; ++i) {
    for (int j=i+1; j<=i+k; ++j) {
      if (j<n) {
        dp[j]=min(dp[j], dp[i]+abs(arr[i]-arr[j]));
      }
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
from collections import defaultdict

n, m = map(int, input().strip().split())
data = [input().strip().split() for _ in range(m)]

ac = defaultdict(int)
wa = defaultdict(int)

for p, s in data:
    if s == 'AC':
        ac[p] += 1
    else:
        if ac[p] == 0:
            wa[p] += 1

correct = 0
penalty = 0
for i in range(n + 1):
    p = str(i)
    if ac[p] > 0:
        correct += 1
        penalty += wa[p]

print(correct, penalty)


Measured memory_bytes: 55800
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

X = getN()

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
else:
    print(1)

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

void f(vector<ll> &v) {
  vector<ll> n;
  n.push_back(0);
  for(ll i = 0; i < v.size(); i++) {
    n.push_back(n.back() + v[v.size() - 1 - i]);
  }
  v.clear();
  for(ll i = 0; i < n.size(); i++) {
    v.push_back(n[i]);
  }

  return;
}

int main() {
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for(ll i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }

  ll ans = 0;

  vector<ll> v0, v1, v2, v3;
  for(ll i = 0; i < N; i++) {
    ll tmp = w[i] - w[0];
    if(tmp == 0) {
      v0.push_back(v[i]);
    }else if(tmp == 1) {
      v1.push_back(v[i]);
    }else if(tmp == 2) {
      v2.push_back(v[i]);
    }else {
      v3.push_back(v[i]);
    }
  }

  sort(v0.begin(), v0.end());
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());

  f(v0);
  f(v1);
  f(v2);
  f(v3);

  for(ll i0 = 0; i0 < v0.size(); i0++) {
    for(ll i1 = 0; i1 < v1.size(); i1++) {
      for(ll i2 = 0; i2 < v2.size(); i2++) {
        for(ll i3 = 0; i3 < v3.size(); i3++) {
          if(w[0] * i0 + (w[0] + 1) * i1 + (w[0] + 2) * i2 + (w[0] + 3) * i3 <= W) {
            ans = max(ans, v0[i0] + v1[i1] + v2[i2] + v3[i3]);
          }
        }
      }
    }
  }

  cout << ans << endl;

  

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();

		int c = 1;
		int D = 0;
		for (int i = 0; i < N; i++) {
			int L = sc.nextInt();
			D += L;
			if (D > X)
				break;
			c++;
		}

		System.out.println(c);
	}
}

Measured memory_bytes: 23380
from collections import defaultdict, Counter


def main():
    n, a = map(int, input().split())
    y = [0] + [int(i) - a for i in input().split()]
    x = max(max(y) + a, a)
    dp = [[0] * (2 * n * x + 1) for _ in range(n + 1)]
    for i in range(n + 1):
        for j in range(2 * n * x + 1):
            if i == 0 and j == n * x:
                dp[i][j] = 1
            elif i >= 1 and (j - y[i] < 0 or j - y[i] > 2 * n * x):
                dp[i][j] = dp[i - 1][j]
            elif i >= 1 and 0 <= j - y[i] and j - y[i] <= 2 * n * x:
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - y[i]]
            else:
                dp[i][j] = 0

    print(dp[n][n * x] - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5988
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=21105;
const int NN=20005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set<str> a;
    for (int i=1;i<=n;i++){
        str s;
        cin >> s;
        a.insert(s);
    }
    cout << a.sz();
    r0;
}
/*


1
5
2 3 4 5 1


1
4
4 2 3 1








*/


Measured memory_bytes: 19200
package main

import "fmt"

const N = 100005
const INF = 1e9+7
var h [N]int
var cost [N]int

func abs(n int) int {
  if n < 0 {
    return -n
  } else {
    return n
  }
}

func min(a, b int) int {
  if a < b {
    return a
  } else {
    return b
  }
}

func main() {
  var n int
  fmt.Scanf("%d", &n)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &h[i])
    cost[i] = INF
  }
  cost[0] = 0
  cost[1] = cost[0] + abs(h[1] - h[0])
  for i := 2; i < n; i++ {
    cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]))
  }
  
  fmt.Println(cost[n-1])
}

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

int main() {
	int A, B, C, D;
	std::string S;

	std::cin >> S;
	A = (int) (S[0] - '0');
	B = (int) (S[1] - '0');
	C = (int) (S[2] - '0');
	D = (int) (S[3] - '0');

	for(int i = 0; i < (1 << 3); ++i) {
		int sum = A;
		char op[3];
		if((i >> 0 & 1) == 0) {
			sum += B;
			op[0] = '+';
		} else {
			sum -= B;
			op[0] = '-';
		}
		if((i >> 1 & 1) == 0){
			sum += C;
			op[1] = '+';
		} else {
			sum -= C;
			op[1] = '-';
		}
		if((i >> 2 & 1) == 0) {
			sum += D;
			op[2] = '+';
		} else {
			sum -= D;
			op[2] = '-';
		}

		if(sum == 7) {
			std::cout << A << op[0] << B << op[1] << C << op[2] << D << "=7" << std::endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int rev(int n)
{
    int rem,rev=0;
     while(n)
       {
           rem=n%10;
           rev=rev*10+rem;
           n=n/10;
       }
       return rev;
}
int main()
{
    int a,b,pali=0,i,num,revnum;
    cin>>a>>b;
    for(i=a; i<=b; i++)
    {
        num=i;
        revnum=rev(num);
        if(num==revnum)
        {
            pali++;
        }
    }
    cout<<pali<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  REP(i, H) cin >> s[i];

  int dx[] = {0, 0, -1, 1};
  int dy[] = {1, -1, 0, 0};
  bool ok = true;
  REP(i, H) REP(j, W){
    if(s[i][j] == '.') continue;
    bool f = false;
    REP(k, 4){
      int id = i+dx[k];
      int jd = j+dy[k];
      if(id < 0 || id >= H || jd < 0 || jd >= W) continue;
      if(s[id][jd] == '#') f = true;
    }
    if(!f) ok = false; 
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int k;
    cin >> k;
    deque<ll> q;
    REP1(i, 9) q.emplace_back(i);
    ll x;
    while (--k) {
        x = q.front(); q.pop_front();
        if (x % 10 != 0) q.emplace_back(x * 10 + (x % 10 - 1));
        q.emplace_back(x * 10 + (x % 10));
        if (x % 10 != 9) q.emplace_back(x * 10 + (x % 10 + 1));
    }
    cout << q.front() << endl;
}


Measured memory_bytes: 1792
MOD = 10 ** 9 + 7
INF = 10 ** 12
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  itertools import permutations
from math import gcd

def main():
    k = int(input())
    ans = 0
    for i in range(1,k + 1):
        for j in range(1,k + 1):
            for l in range(1,k + 1):
                ans += gcd(gcd(i,j),l)
    print(ans)
if __name__ =='__main__':
    main()  

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

int main() {
  int N, L;
  cin >> N >> L;
  string S[N], s;
  for(int i = 0; i < N; i++) {
    cin >> S[i];
  }

  sort(S, S + N);
  
  for(int i = 0; i < N; i++) {
    s += S[i];
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s >> n;
    int ans = 0;
    rep(i, 0, n) {
        string t;
        cin >> t;
        t += t;
        rep(j, 0, t.size()-s.size()) {
            if (s == t.substr(j, s.size())) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
#define ull unsigned long long
#define mod 1000000007

using namespace std;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def dfs(x,y):
    global st
    global visited
    global ans

    if MAP[y][x] == '#':
        ans |= 0
        return
    elif MAP[y][x] == 'B':
        ans |= 1
        return
    elif MAP[y][x] == 'W':
        ans |= 2
        return
    else:
        visited[y][x] = True
        st.add((x,y))
        if not visited[y][x+1]:
            dfs(x+1,y)
        if not visited[y][x-1]:
            dfs(x-1,y)
        if not visited[y+1][x]:
            dfs(x,y+1)
        if not visited[y-1][x]:
            dfs(x,y-1)
        return

while True:
    W,H = inpl()
    if W == 0:
        break
    else:
        MAP = []
        MAP.append(['#']*(W+2))
        for _ in range(H):
            MAP.append(['#']+list(input())+['#'])
        MAP.append(['#']*(W+2))

        visited = [[False]*(W+2) for _ in range(H+2)]
        dp = [[-1]*(W+2) for _ in range(H+2)]
        ansb = answ = 0
        for y0 in range(1,H+1):
            for x0 in range(1,W+1):
                if not visited[y0][x0]:
                    st = set([])
                    ans = 0
                    dfs(x0,y0)
                    for x,y in st:
                        dp[y][x] = ans

        #for d in dp:
        #    print(' '.join([str(k).rjust(2) for k in d]))

        answ = ansb = 0
        for d in dp:
            answ += d.count(2)
            ansb += d.count(1)

        print(ansb,answ)



Measured memory_bytes: 9864
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int ans = 0;
	int BA = 0, frontB = 0, endA = 0;
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		
		int m = s.size();
		for(int j = 0; j < m - 1; ++j) {
			if( s[j] == 'A' && s[j + 1] == 'B' ) ans++;
		}	
		
		if( s[0] == 'B' && s[m - 1] == 'A' ) BA++;
		else if( s[0] == 'B' && s[m - 1] != 'A' ) frontB++;
		else if( s[0] != 'B' && s[m - 1] == 'A' ) endA++;		
	}
	
	if( frontB == 0 && endA == 0 ) {
		ans += max(0, BA - 1);
	} else {
		ans += min(frontB + BA, endA + BA);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
a = list(map(int, input().split()))
kakuritu = 0
for N in range(a[0]):
    N = N+1
    count = 0
    if N >= a[1]:
        kakuritu = kakuritu + 1/a[0]
    else:
        while True:
            N=N*2
            count = count + 1
            if N >= a[1]:
                kakuritu = kakuritu + (1/2)**count/a[0]
                break

print(kakuritu)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int n;
  cin>>n;
  int ans=0;
  vector<int> v;
  for(int i=1;i*i<=n;i++){
    if(n%i)continue;
    v.pb(i);
    if(i*i==n)break;
    v.pb(n/i);
  }
  for(int i=0;i<v.size();i++){
    //    cout<<v[i]<<endl;
    if(n/v[i]<v[i]-1)ans+=v[i]-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long int ll;

ll N,K;
ll DP[110005][102];
ll W[102],V[102];
ll INF=1e18;

int main(){

	cin>>N>>K;
	for(int i=0;i<N;i++)
		cin>>W[i+1]>>V[i+1];

	for(int i=1;i<1003*N;i++)
		DP[i][0]=INF;

	for(int i=0;i<N*1003;i++)
		for(int j=1;j<N+1;j++)
			DP[i][j]=min(DP[i][j-1],((i-V[j]>=0)?(DP[i-V[j]][j-1]+W[j]):INF));


	for(int i=N*1003-1;i>=0;i--)
		if(DP[i][N]<=K){
			cout<<i;
			return 0;
		}

}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;

VVLL DP;
VI w, c;

ll f(int cur_w, int elem) {
    if (cur_w <= 0 || elem <= 0) return 0;
    ll& res = DP[cur_w][elem];
    if (res != -1) return res;
    if (cur_w < w[elem]) return res = f(cur_w, elem-1);
    return res = max(f(cur_w - w[elem], elem-1) + c[elem], f(cur_w, elem-1));
 }


int main() {
    int N, W;
    cin >> N >> W;
    DP = VVLL(W+1, VLL(N+1, -1));
    w = VI(N+1);
    c = VI(N+1, 0);
    for (int i = 1; i <= N; ++i) cin >> w[i] >> c[i];
    cout << f(W, N) << endl;
}

Measured memory_bytes: 82304
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i < a + k; i++) {
    if (i > b) {
      return 0;
    }
    P(i);
  }

  for (int i = b - k + 1; i <= b; i++) {
    if (i < a + k) continue;
    P(i);
  }



  return 0;
}



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

int main() {
  int input[3];  

  cin >> input[0] >> input[1] >> input[2];

  int tmp;
  if(input[0] > input[1]) {
    tmp = input[1];
    input[1] = input[0];
    input[0] = tmp;
  }
  if(input[2] < input[0]) {
    tmp = input[0];
    input[0] = input[2];
    input[2] = tmp;
  }    
  if(input[1] > input[2]) {
    tmp = input[2];
    input[2] = input[1];
    input[1] = tmp;
  }
  
  cout << input[0] << " " << input[1]<< " " << input[2] << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>

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

	int *a;
	a = (int *)malloc(sizeof(int)*(n));
	int i = 0;
	while (i < n)
	{
		scanf("%d",&(a[i]));
		i++;
	}
	int cnt = 0;
	i = 0;
	while (i < n)
	{
		if (i%2 == 0 && a[i]%2 != 0)
			cnt++;
		i++;
	}
	printf("%d\n", cnt);
	return (0);
}


Measured memory_bytes: 1724
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

long long ans;
long long b;
int n;
int a[21];


int main()
{
    int i,j,k;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ans=1;
    b=1;
    for(i=1;i<=n;i++)
    {
        ans*=3;
        if(a[i]%2==0)
        {
           b*=2;
        }
        else
        {
           b*=1;
        }
    }
    
    cout<<ans-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vi h(n);
    rep(i,n)cin >> h[i];
    vvi g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    rep(i,n){
        bool c = true;
        rep(j,g[i].size()){
            if(h[i] <= h[g[i][j]])c = false;
        }
        if(c)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

// 入力
int H,W;
vector<string> A;


// DP テーブル
long long dp[1010][1010] = {}; 

int main() {
  
  cin >> H >> W;
  A.resize(H);
  FOR(i,0,H) cin >> A[i];
  
  //初期条件
  dp[0][0] = 1;

  // ループ
  FOR(i,0,H) {
    FOR(j,0,W) {
      if (i+1 < H && A[i+1][j] == '.') { //先にi+1<Hを書かないとエラーになる
        (dp[i+1][j] += dp[i][j]) %= 1000000007;
      }
      if (j+1 < W && A[i][j+1] == '.') { 
        (dp[i][j+1] += dp[i][j]) %= 1000000007;
      }
    }
  }
  
  cout << dp[H-1][W-1] << endl;
 
}

Measured memory_bytes: 13408
import java.io.BufferedReader;

import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// 入力を読むのに必要
            String line = br.readLine();
            
            System.out.println((long)getCubeOf(line));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static double getCubeOf(String line) {
    	long x = Long.parseLong(line);
    	
    	return (long)Math.pow(x, 3);
    }
}



Measured memory_bytes: 24256
'use strict';
const main = arg => {
  const input = arg.trim().split('\n');
  const numPeople = parseInt(input[0], 10);
  const jyoushiIDs = input[1].split(' ').map(n => parseInt(n, 10));
 
  let sum = new Array(numPeople).fill(0);

  jyoushiIDs.forEach(id => {
    sum[id-1] += 1;
  });

  sum.forEach(n => console.log(n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int AT, AK, BT,BK;
  cin>>AT>>AK>>BT>>BK;
  int Ae=AT/BK;
  if(AT%BK !=0)Ae++;
  int Be=BT/AK;
  if(BT%AK !=0)Be++;
  if(Ae>=Be){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

int pos[100005];

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

    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        pos[x] = i;
    }

    for (int i = 1; i <= n; i++) {
        if (i == 1) printf("%d", pos[i]);
        else printf(" %d", pos[i]);
    }

    printf("\n");
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n, d;

	cin >> n >> d;

	int r = 2 * d + 1;
	cout << (n % r == 0 ? n / r : n / r + 1) << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b;
    MSG(a * b - a - b + 1)
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans +=1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<vector<int> > A(N);

    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        A[a].push_back(b);
    }

    priority_queue<int, vector<int>, greater<int> > q;

    int ans = 0;

    for(int i = 0; i < N; i++) {
        if(!q.empty()) {
            int x = q.top();
            if(i == x) {
                ans++;
                while(!q.empty()) {
                    q.pop();
                }
            }
        }
        for(int j = 0; j < A[i].size(); j++) {
            q.push(A[i][j]);
        }
    }

    cout << ans << endl;
}   

Measured memory_bytes: 6144
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let q: isize = sc.input();

    let max_n: isize = 1e5 as isize;
    let is_prime = get_primes(max_n);
    let mut cnt = vec![0; max_n as usize + 1];

    let mut i = 3;
    while i <= max_n as usize {
        if is_prime[i] && is_prime[(i + 1) / 2] { cnt[i] += 1; }
        i +=2;
    }
    for i in 0..max_n as usize {
        cnt[i + 1] += cnt[i];
    }
    for _ in 0..q {
        let (l, r): (usize, usize) = (sc.input(), sc.input());
        println!("{}", cnt[r] - cnt[l - 1]);
    }
}

fn get_primes(n: isize) -> Vec<bool> {
    let mut is_prime = vec![true; n as usize + 1];

    let mut i = 2;
    while i * i <= n {
        if is_prime[i as usize] {
            let mut j = i * i;
            while j <= n {
                is_prime[j as usize] = false;
                j += i;
            }
        }
        i += 1;
    }
    is_prime
}


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

#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)

using ll = long long;

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

  int X;
  cin >> X;

  cout << 1 - X << '\n';

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 1e5+7;
const int MOD = 1e9+7;

int main(){

  int n,m; cin >> n >> m;
  ll sum = 1;
  if(abs(n - m) >= 2){
    cout << "0" << endl;
    return 0;
  }
  else if(n == m){
    for(int i = 1; i <= m; i++){
      sum = sum * (n--) % MOD;
    }
    cout << 2 * sum * sum % MOD << endl;
  }
  else {
    int k = max(n,m);
    int l = min(n,m);
    for(int i = 1; i < k; i++){
      sum = sum * (l--) % MOD;
    }
    k = sum * k % MOD;
    cout << sum * k % MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

ll gcd(ll a,ll b)
{
	if (b == 0) 
		return a; 
	return gcd(b, a % b);  
}

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

ll fun (ll x, ll y, ll z) {
	ll ans = (x * x) + (y * y) + (z * z);
	ans =ans + (x * y) + (y * z) + (z * x);
	return ans;
}

void solve(){
	ll n;
	cin>>n;
	ll ans[n+1];
	init(ans,0);
	for(ll i=1;i<=100;i++)
	{
		for(ll j=1;j<=100;j++)
		{
			for(ll k=1;k<=100;k++)
			{

				if(fun(i,j,k)<=n)
				{
					ans[fun(i,j,k)]++;
				}
			}
		}
	}
	REP(i,n)
	{
		cout<<ans[i+1]<<ln;
	}

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int sum = 0;

int main() {
    int n; cin >> n;
    int a = n%100;
    int c = n/100;
    int b = a%10;
    int e = a/10;
    if(b==7){    
         cout <<"Yes"<<endl;
    }else if(c == 7){
        cout << "Yes" <<  endl;
    }else if(e == 7){
        cout << "Yes" <<  endl;
    }else{
        cout << "No" <<  endl;
    }
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    vector<int> vec(3);
    for(int i=0; i<3; i++) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    if((2*vec[2] - vec[1] - vec[0]) % 2 == 0) {
        cout << (2*vec[2] - vec[1] - vec[0]) / 2 << endl;
    } else {
        cout << (2*vec[2] - vec[1] - vec[0] + 3) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
function main()
  n = parse(Int, readline())
  a = map(x -> parse(Int, x), split(readline(), " "))
  
  lgcd = zeros(Int, n)
  rgcd = zeros(Int, n)

  for i in 1:n
    if i == 1
      lgcd[i] = a[i]
    else
      lgcd[i] = gcd(a[i], lgcd[i-1])
    end
  end

  for i in 1:n
    if i == 1
      rgcd[end-i+1] = a[end]
    else
      rgcd[end-i+1] = gcd(a[end-i+1], rgcd[end-i+2])
    end
  end

  ans = 0
  for i in 1:n
    if i == 1
      temp = rgcd[i+1]
    elseif i == n
      temp = lgcd[i-1]
    else
      temp = gcd(lgcd[i-1], rgcd[i+1])
    end
    ans = temp > ans ? temp : ans
  end
  println(ans)
end

main()

Measured memory_bytes: 172452
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 
	int n, x[110];
	cin >> n;
	for (int i = 0;i < n;i++) cin >> x[i];
 
	int tairyoku=0,ans=0;
	for(int i=0;i<n;i++)	ans += (x[i]-1) * (x[i] - 1);
 
	for (int i = 1;i <= 100;i++) {
		for (int j = 0; j < n;j++)	tairyoku += (x[j] - i) * (x[j] - i);
		ans = min(tairyoku, ans);
		tairyoku = 0;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	long long inf = 1e18; 
	long long A[200010] = {}; 
	for(int i = 1; i <= N; i++) cin >> A[i]; 
	long long dp[200010][2] = {}; // 最後に選んだのがi番目で最適個数からのロスがj個
	dp[1][0] = A[1]; dp[1][1] = -inf; 
	dp[2][0] = A[2]; dp[2][1] = -inf; 
	if(N >= 3){
		dp[3][0] = A[1] + A[3]; dp[3][1] = A[3]; 
	}
	if(N >= 4){
		dp[4][0] = max(A[1], A[2]) + A[4]; 
		dp[4][1] = A[4]; 
	}
	for(int i = 5; i <= N; i++){
		if(i % 2){
			dp[i][0] = dp[i-2][0] + A[i]; 
			dp[i][1] = max({dp[i-2][1], dp[i-3][0], dp[i-4][0]}) + A[i]; 
		}
		else{
			dp[i][0] = max(dp[i-2][0], dp[i-3][0]) + A[i]; 
			dp[i][1] = max({dp[i-2][1], dp[i-3][1], dp[i-4][0], dp[i-5][0]}) + A[i]; 
		}		
	}
	if(N % 2 == 0) cout << max(dp[N-1][0], dp[N][0]) << endl; 
	else cout << max({dp[N][1], dp[N-1][0], dp[N-2][0]}) << endl; 
}

Measured memory_bytes: 8320
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  cout << (n / 2) * (n / 2 + n % 2) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,m;
    cin >> n >> m;
    if (n > m) swap(n,m);
    if (n==1) {
        if (m==1) {
            cout << 1 << endl;
        } else {
            cout << m-2 << endl;
        }
        return 0;
    }

    cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 3096
import math

def dist(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

c1x, c1y, c1r = map(int, input().split())
c2x, c2y, c2r = map(int, input().split())

d = dist(c1x, c1y, c2x, c2y)
if d>c1r+c2r:
    print(4)
elif d==c1r+c2r:
    print(3)
elif d+c1r==c2r or d+c2r==c1r:
    print(1)
elif d+c1r<c2r or d+c2r<c1r:
    print(0)
else:
    print(2)


Measured memory_bytes: 5668
parseMap(a::Array{SubString{String}, 1}) = map(x -> parse(Int, x), a)
ipad(x,y) = lpad(x,6,0)*lpad(y,6,0)

function main()
	n,m = readline() |> split |> parseMap
	py = Array{Int}(3,m)
	for i in 1:m
		py[1:2,i] = readline() |> split |> parseMap
		py[3,i] = i
	end
	py = sortcols(py, by = x->(x[1],x[2]))
	py[2,1] = 1
	for i in 2:m
		if py[1,i] != py[1,i-1]
			py[2,i] = 1
		else
			py[2,i] = py[2,i-1]+1
		end
	end
	py = sortcols(py, by = x->(x[3]))
	for i in 1:m
		println(ipad(py[1,i],py[2,i]))
	end
end
main()

Measured memory_bytes: 171228
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  int ans = n*800 - n/15*200;
  cout << ans << endl;
} 






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
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)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  int ans = 0;
  vi cent = {1,5,10,25};
  RREP(i,4){
    ans += n/cent[i];
    n %= cent[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s,t;
  cin >> s >> t;
  int n=s.size(),m=t.size();
  for(int i=n-m;i>=0;i--){
    bool flag=true;
    for(int j=0;j<m;j++){
      if(s[i+j]!=t[j] && s[i+j]!='?'){
        flag=false;
      }
    }
    if(flag){
      for(int j=0;j<i;j++){
        if(s[j]!='?')cout << s[j];
        else cout << 'a';
      }
      cout << t;
      for(int j=i+m;j<n;j++){
        if(s[j]!='?')cout << s[j];
        else cout << 'a';
      }
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
return 0;}

Measured memory_bytes: 256