akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	N := readInt()
	L := make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = readInt()
	}

	sort.Ints(L)
	result := 0
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			x := L[i] + L[j]
			for k := j + 1; k < N; k++ {
				if L[k] >= x {
					break
				}
				result++
			}
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	string S;
	cin >> S;

	int n[3] = { 0,0,0 };
	REP(i, S.length())
	{
		n[(int)(S[i] - 'a')]++;
	}

	int max = std::max(n[0], std::max(n[1], n[2]));
	int min = std::min(n[0], std::min(n[1], n[2]));

	if (max - min < 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool a = 0;
  for(int i = 0;i < 50000;i++) {
    if(i + (8 * i)/100 == N) {
      a++;
      cout << i << endl;
      break;
    }
  }
  if(a) {
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = INF;
    exrep(i, -100, 100) {
        ll now = 0;
        rep(j, n) {
            now += abs(a[j] - i)*abs(a[j] - i);
        }
        chmin(ans, now);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
    int a, b;
    std::string result;
    std::cin >> a;
    std::cin >> b;
    if((a - b) > 0){
      result = "a > b";
    }
    if((a - b) < 0){
      result = "a < b";
    }
    if((a - b) == 0){
      result = "a == b";
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long

int main() {
    int n;
    cin>>n;string s;
    map<string,int>m;
    while(n--)
    {
        cin>>s;
        m[s]+=1;
    }int mmm=0;
 for (auto& x: m) {
     if(x.second>mmm)mmm=x.second;
 }
       
       vector<string>A; 
for (auto& it :m) { 
    if(it.second==mmm)
        A.push_back(it.first); 
    } 
     sort(A.begin(), A.end());
     
    
      REP(i,A.size())
      {
          cout<<A[i]<<endl;
      }}
          
          
          
    

Measured memory_bytes: 27152
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int t,n,s,f,ans;
	while(cin>>t,t){
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			ans+=(f-s);
		}
		if(ans>=t)cout<<"OK"<<endl;
		else cout<<t-ans<<endl;
		ans=0;
	}
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 10000;
  for(int i = 0; i <= s.size() - t.size(); i++) {
    int cnt = 0;
    for(int j = 0; j < t.size(); j++) {
      if(s[j + i] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans;
}

Measured memory_bytes: 3600
n = int(raw_input())
A = map(int,raw_input().split())
Q = int(raw_input())
m = map(int,raw_input().split())

def s(i, m):
  if m == 0:
    return True
  if i >= n or m > sum(A):
    return False
  r = s(i + 1, m) or s(i + 1, m - A[i])
  return r

for j in range(Q):
  if s(0, m[j]):
    print "yes"
  else:
    print "no"
  
  

Measured memory_bytes: 6452
#include <iostream>
#include<cmath>
#include<string>
#include<iomanip>
#include<algorithm>
#include<map>
#define LL long long int
using namespace std;
int main()
{
    int a,b,c; cin>>a>>b>>c; int ans=1;
    if(a%2==1||b%2==1||c%2==1){cout<<0 ; return 0;}
    for(int i=0;i<=2e7;i++)
    {
        int tempa=a/2,tempb=b/2,tempc=c/2;
        a=tempb+tempc;b=tempa+tempc;c=tempb+tempa;
       if(a%2==1||b%2==1||c%2==1){cout<<ans; return 0;}
        ans++;
    }
    cout<<-1;
}


Measured memory_bytes: 256
from collections import deque
q = deque()

for _ in range(int(input())):
	b=input()
	if b[0] == 'i':
		q.appendleft(b[7:])
	elif b[6] == ' ':
		try:
			q.remove(b[7:])
		except:
			pass
	elif len(b) > 10:
		q.popleft()
	elif len(b) > 6:
		q.pop()
print(*q)


Measured memory_bytes: 69740
#include <bits/stdc++.h>
using namespace std;
int values;
int number (int n, int base) {
	if (n == 0) return 0;

	int x = n % base;
	n /= base;

	if (x < 0) {
		n += 1;
	}
    values++;
	number(n, base);
	return 0;
	
}


int main() {
	int n,  base;
	cin >> n >> base;
    number(n, base); 
    cout << values << "\n";
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli n;
vll a;

void no(){
  cout << "No" << endl;
  exit(0);
}

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

bool solve(lli k){
  if(*min_element(a.begin(),a.end()) < k-1 || *max_element(a.begin(),a.end()) > k) return false;
  if(count(a.begin(),a.end(),k)){
    return k-count(a.begin(),a.end(),k-1) >= 1 && k-count(a.begin(),a.end(),k-1) <= (count(a.begin(),a.end(),k))/2;
  }else{
    return k-count(a.begin(),a.end(),k-1) >= 0 && k-count(a.begin(),a.end(),k-1) <= (count(a.begin(),a.end(),k))/2;
  }
}

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  lli k = *max_element(a.begin(),a.end());
  if(solve(k-1) || solve(k) || solve(k+1)) yes();
  else no();
  return 0;
}


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

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

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

vector<bool> to_bit(int n, int size) {
    vector<bool> ans(size);
    rep(i, size) {
        ans[i] = (n % 2 == 1);
        n /= 2;
    }
    return ans;
}

int main() {
    // Input
    int H, W, K;
    vector<string> c;

    cin >> H >> W >> K;
    c = vector<string>(H);
    rep(i, H) cin >> c[i];

    // Process
    vector<vector<int>> C(H, vector<int>(W, 0));
    rep(i, H) rep(j, W) if (c[i][j] == '#') C[i][j] = 1;

    int ans = 0;
    int h_size = (int)pow(2, H);
    int w_size = (int)pow(2, W);
    rep(i, h_size * w_size) {
        vector<bool> w = to_bit(i % w_size, W);
        vector<bool> h = to_bit(i / w_size, H);

        int cnt = 0;
        rep(j, H) {
            rep(k, W) {
                if (h[j] || w[k]) continue;
                if (C[j][k] == 1) cnt++;
            }
        }
        if (cnt == K) ans++;
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4104
n=input()
a=[map(int,raw_input().split()) for _ in xrange(n)]
t=1<<n
q=[-(1<<64)]*t
for m in xrange(t):
    s=0
    for i in xrange(n):
        if (m>>i)&1:
            for j in xrange(i):
                if (m>>j)&1:
                    s+=a[i][j]
    q[m]=max(q[m],s)
z=[-(1<<64)]*t
for m in xrange(t):
    z[m]=q[m]
    s=m
    while s:
        z[m]=max(z[m],z[s]+q[(s^m)&m])
        s=(s-1)&m
print z[-1]

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

using P = pair<int, int>;

constexpr int MAX_H = 50;
constexpr int MAX_W = 50;

int H, W;
int sh{-1}, sw{-1}, gh{-1}, gw{-1};
char grid[MAX_H][MAX_W + 1];
int count[MAX_H][MAX_W];

//#define OCTAS
#ifdef OCTAS
constexpr int dh[]{-1, -1, -1, 0, 0, +1, +1, +1};
constexpr int dw[]{-1, 0, +1, -1, +1, -1, 0, +1};
#else
constexpr int dh[]{-1, 0, 0, +1};
constexpr int dw[]{0, -1, +1, 0};
#endif

// CAUTION!!!
// Call init_count() first!!!
//
void init_count() {
  // この方法で初期化できるのは-1だから
  memset(::count, -1, sizeof(::count));
}

int bfs(int y, int x) {
  queue<P> que;
  ::count[y][x] = 0;
  que.push(P(y, x));

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    int cnt = ::count[p.first][p.second];
    if (p.first == gh && p.second == gw) {
      return cnt;
    }
    ++cnt;
    for (int i{}; i < sizeof(dh) / sizeof(int); ++i) {
      int nh = p.first + dh[i];
      int nw = p.second + dw[i];
      if (nh < 0 || nh >= H ||
          nw < 0 || nw >= W ||
          ::count[nh][nw] >= 0 ||
          grid[nh][nw] == '#')
        continue;
      ::count[nh][nw] = cnt;
      que.push(P(nh, nw));
    }
  }

  return -1;
}

int main() {
  init_count();

  scanf("%d%d", &H, &W);
  int white_num{};
  for (int h{}; h < H; ++h) {
    scanf("%s", &grid[h][0]);
    for (int w{}; w < W; ++w) {
      if (grid[h][w] == '.')
        ++white_num;
    }
  }
  sh = sw = 0;
  gh = H - 1;
  gw = W - 1;
  int ret = bfs(sh, sw);

  printf("%d\n", ret < 0 ? ret : white_num - ret - 1);
  return 0;
}


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

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

  for (int i = 1; i < 10; i++){
    for( int j = 1; j < 10; j++){
      if (n == i * j){
        cout << "Yes" << endl;
        return 0;
      } 
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		for(int i = 0;i <= 25;i++){
			for(int j = 0;j <= 15;j++){
				if(4*i+7*j == n){
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");

		
	
	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 25044
n, x = map(int, (input().split()))
a, p = [1], [1]
for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1]+1 + f(n-1, x-2-a[n-1])
print(f(n, x))

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

#define FOR(i, l, r) for (i = (l); i < (r); i++)
#define INF (0x7FFFFFFF)
using namespace std;
typedef long long ll;

#define MAX_N (500010)
int A[MAX_N];
int L[(MAX_N>>1)];
int R[(MAX_N>>1)];
int n;
int calc = 0;

void merge(int A[], int left, int mid, int right ) {
    // returns when the number of element is 1 or less.
    if ( right - left <= 1 ) return;
    int i;
    int n1 = mid - left;
    int n2 = right - mid;
    int n = right - left;

    FOR( i, 0, n1 ) {
	L[i] = A[left + i];
    }

    FOR( i, 0, n2 ) {
	R[i] = A[mid + i];
    }

    L[n1] = R[n2] = INF;

    int i_l = 0;
    int i_r = 0;

    FOR( i, left, right ) {
	if ( L[i_l] <= R[i_r] ) {
	    A[i] = L[i_l];
	    i_l++;
	}
	else {
	    A[i] = R[i_r];
	    i_r++;
	}
	calc++;
    }

    return;
}

void mergeSort( int A[], int left, int right ) {
    // proceeds when the number of element is greater than 1.
    if ( right - left > 1 ) {
	int mid = (right + left) >> 1;
	mergeSort( A, left, mid );
	mergeSort( A, mid, right );
	merge( A, left, mid, right );
    }
}

int main()
{
    int i;
    scanf("%d", &n);
    FOR(i, 0, n) scanf("%d", &A[i]);
    
    mergeSort( A, 0, n );

    FOR(i, 0, n) {
	printf("%d%c", A[i], (i == n-1) ? '\n' : ' ');
    }

    printf("%d\n", calc);

    return 0;
}

Measured memory_bytes: 7048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;
	return 0;
}

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

long long combination[100001];
long long numbers[100001];
#define MOD 1000000007

long long gcdExtended(long long,long long,long long*,long long*);

// Function to find modulo inverse of a 
long long modInverse(int a, int m) 
{ 
    long long x, y; 
    long long g = gcdExtended(a, m, &x, &y); \
    // m is added to handle negative x 
    long long res = (x%m + m) % m; 
    return res;
} 
  
// C function for extended Euclidean Algorithm 
long long gcdExtended(long long a, long long b, long long *x, long long *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    long long x1, y1; // To store results of recursive call 
    long long gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

int main()
{
    int N,K;
    scanf("%d %d",&N,&K);
    for(int i = 0; i < N; i++)
    {
        scanf("%lld",numbers + i);
    }
    sort(numbers,numbers + N);

    for(int i = 0; i < N; i ++)
    {
        if(i < K - 1)
        {
            combination[i] = 0;
        }
        else if(i == K - 1)
        {
            combination[i] = 1;
        }
        else
        {
            combination[i] =((combination[i-1] * i) % MOD * modInverse(i - K + 1, MOD) % MOD);
        }
    }

    long long ans = 0;
    for(int i = 0; i < N; i ++)
    {
        ans += numbers[i] * combination[i];
        ans -= numbers[i] * combination[N-1-i];
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    printf("%lld",ans % MOD);
}

Measured memory_bytes: 3240
def solve():
    from math import sqrt
    N = n = int(input())
    primes = [] if n%2 else [2]
    while n%2 == 0:
        n //= 2
    for i in range(3, int(sqrt(n)), 2):
        if n % i == 0:
            primes.append(i)
            while n % i == 0:
                n //= i
    if n != 1:
        primes.append(n)

    numer, denom = N, 1
    for prime in primes:
        numer *= prime-1
        denom *= prime

    print(numer//denom)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 7856
# -*- coding: utf-8 -*-
from collections import Counter
h,w = map(int, input().split())
al = []
for _ in range(h):
    al += list(input())

c = Counter(al)

if h%2==1 and w%2==1:
    for k in c.keys():
        if c[k]%2==1:
            c[k] -= 1
            break

g4 = (h//2)*(w//2)*4
for k in c.keys():
    while c[k]>=4 and g4>0:
        c[k] -= 4
        g4 -= 4
if g4>0:
    print("No")
    exit()

g2 = (h%2)*(w//2)*2 + (w%2)*(h//2)*2
for k in c.keys():
    while c[k]>=2 and g2>0:
        c[k] -= 2
        g2 -= 2
if g2>0:
    print("No")
    exit()

for k in c.keys():
    if c[k]>0:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	for(;;){
		int n;
		cin >>n;
		if(!n){break;}
		double pin[100][2] = {0},min_x =  10000;
		int rubber[2] = {0};
		bool done[100] = {false};
		for(int i=0; i<n; i++){
			scanf("%lf,%lf",&pin[i][0],&pin[i][1]);
			if(min_x>pin[i][0]){min_x = pin[i][0];rubber[0] = i;}
		}
		rubber[1] = rubber[0];
		for(;;){
			int now,j;
			for(int i=0; i<n; i++){
				if(!done[i] && i!=rubber[1]){
					double ax = pin[i][0]-pin[rubber[1]][0];
					double ay = pin[i][1]-pin[rubber[1]][1];
					for(j=0; j<n; j++){
						if(!done[j]){
							double bx = pin[j][0]-pin[rubber[1]][0];
							double by = pin[j][1]-pin[rubber[1]][1];
							if(ax*by-ay*bx<0){break;}
						}
					}
					if(j == n){now = i;break;}
				}
			}
			done[now] = true;
			rubber[1] = now;
			if(rubber[1] == rubber[0]){break;}
		}
		int sum = 0;
		for(int i=0; i<n; i++){if(!done[i]){sum++;}}
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

#define MAX 1000000
int left(int);
int right(int);
void maxHeapify(int*,int,int);

int main(){
  int A[MAX],n,i;
  scanf("%d",&n);

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

  for(i=n/2;i>0;i--){
    maxHeapify(A,i,n);
  }

  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}

void maxHeapify(int *A,int i,int n){
  int l,r,largest,tmp;
  l=i*2;
  r=i*2+1;
 
  if(l<=n && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=n && A[r]>A[largest]) largest=r;

  if(largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest,n);
  }
}

Measured memory_bytes: 4076
n = int(input())
s = input()
t = input()
if s == t:
    print(n)
    exit()
t = t[::-1]
s = s[::-1]
res = n
j = 0
for i in range(n):
    if s[j]==t[i]:
        j += 1
    else:
        res += 1
print(res)

Measured memory_bytes: 9184
using Yorukatsu017.Questions;
using Yorukatsu017.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu017.Questions
{
    /// <summary>
    /// ARC059 A
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadIntArray();

            yield return Enumerable.Range(-100, 201).Min(i => a.Sum(ai => (ai - i) * (ai - i)));
        }
    }
}


namespace Yorukatsu017
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu017.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu017.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main() {
    string S;
    bool flag = true;

    cin >> S;

    bool a[26];
    for (int i = 0; i < 26; i++){
        a[i] = false;
    }

    for (int i = 0; S[i] != '\0'; i++){
        a[S[i] - 'a'] = true;
    }

    for (int i = 0; i < 26; i++){
        if (a[i] != true){
            cout << char(i + 'a') << endl;;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#define _CRT_SECURE_NO_WARNINGS 1
#define LIMIT 200001
int main()
{
	char s[LIMIT], t[LIMIT], c1, c2;
	scanf("%s", s, LIMIT);
	scanf("%s", t, LIMIT);

	int numberLetter = strlen(s);

	for (int i = 0; i < numberLetter; i++) {
		if (s[i] != t[i]) {
			c1 = s[i];
			c2 = t[i];
			for (int j = 0; j < numberLetter; j++) {
				if (s[j] == c1 || s[j] == c2) {
					if (j < i) {
						printf("No\n");
						return 0;
					}
					if (s[j] == c1) {
						s[j] = c2;
					}
					else {
						s[j] = c1;
					}
				}
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
n,m = map(int, input().split())
a = [0]*n ; b = [0]*n ; c =[0]*m ; d = [0]*m

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

for i in range(m):
    c[i],d[i] = map(int, input().split())

for i in range(n):
    md = []
    for j in range(m):
        md.append(abs(a[i]-c[j])+abs(b[i]-d[j]))
    print(md.index(min(md))+1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}


int main(void){
    llint n,i,num1=0,num2=0;
    scanf("%lld",&n);
    llint a[n];
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,n,sizeof(llint),compare);
    for(i=0;i<n-1;i++){
        if(a[n-1-i] == a[n-2-i]){
            if(num1!=0){
                num2=a[n-1-i];
                break;
            }else{
                num1=a[n-1-i];
            }
            i++;
        }
    }

    printf("%lld\n",num1*num2);
    return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<math.h>
using namespace std;
#define dint __int128
#define gc getchar()
#define fup(i,a,b) for(int i=a;i<b;++i)
#define upf(i,a,b) for(int i=a;i<=b;++i)
#define dnf(i,a,b) for(int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define hh putchar(10)
#define ll long long
inline ll read(){ll x,f=1;char a;while((a=getchar())<48||a>57)if(a==45)f=-1;
for(x=a^48;(a=getchar())>47&&a<58;x=(x<<3)+(x<<1)+(a^48));return f*x;}

struct node
{
    string x;
    int y;
}n[103],m[103];
void Main()
{
    int ln,lm;
    cin>>ln;
    fup(i,0,ln)
    {
        cin>>n[i].x;
        n[i].y=1;
        fup(j,0,i)
        if(n[i].x==n[j].x)
        {--i;--ln;++n[j].y;}
    }
    cin>>lm;
    fup(i,0,lm)
    {
        cin>>m[i].x;
        m[i].y=-1;
        fup(j,0,i)
        if(m[i].x==m[j].x)
        {--i;--lm;--m[j].y;}
    }
    int ans=0,f;
    fup(i,0,ln)
    {
        f=1;
        fup(j,0,lm)
        {
            if(n[i].x==m[j].x)
            {
                f=0;
                ans=max(ans,n[i].y+m[j].y);
                break;
            }
        }
        if(f)ans=max(ans,n[i].y);
    }
    cout<<ans;
//    gc;gc;
}
int main()
{
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stdio.h>

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
        cout<<"Yes";
    else
        cout<<"No";
}




Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    int N;
    cin >> N;

    vll A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;

    reple(i, 0, 60)
    {
        int count = 0;
        rep(j, N)
        {
            count += A[j] % 2;
            A[j] /= 2;
        }

        ll tmp = 0;
        tmp += (1LL << i);
        tmp %= MOD;
        tmp *= count;
        tmp %= MOD;
        tmp *= (N - count);
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 54;

long long x[N], y[N];
set<pair<long long, long long>> s;

void solve() {
  int n; scanf("%d", &n);
  if (n == 1) {
    printf("1");
    return;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", x+i, y+i);
    s.emplace(x[i], y[i]);
  }
  int ans = 1e9;
  for (int i = 0; i < n-1; ++i) {
    for (int j = i+1; j < n; ++j) {
      long long a = x[j]-x[i], b = y[j]-y[i];
      int cur = n;
      for (const auto &e: s) {
	if (s.count({e.first+a, e.second+b}))
	  --cur;
      }
      ans = min(ans, cur);
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

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

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 A, B;
  cin >> A >> B;
  cout << A / __gcd(A, B) * B << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static bool[] b;
	static int[] h;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int n=s[0],m=s[1];
		b=new bool[n];
		h=new int[n];
		long inf=long.MaxValue>>1;
		var dp=new long[n][];
		for(int i=0;i<n;i++){
			dp[i]=new long[n];
			for(int j=0;j<n;j++){
				if(i!=j){dp[i][j]=inf;}
			}
		}
		for(int i=0;i<m;i++){
			int[] e=sc.Ia;
			dp[e[0]][e[1]]=e[2];
			//dp[e[1]][e[0]]=e[2];
		}
		bool bo=false;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				for(int k=0;k<n;k++){
					if(dp[j][i]!=inf&&dp[i][k]!=inf){dp[j][k]=Min(dp[j][k],dp[j][i]+dp[i][k]);}
				}
				if(dp[j][j]<0){bo=true;}
			}
		}
		StringBuilder sb=new StringBuilder();
		if(bo){sb.Append("NEGATIVE CYCLE\n");}
		else{
			for(int i = 0;i<n;i++) {
				sb.Append(dp[i][0]==inf?"INF":dp[i][0].ToString());
				for(int j = 1;j<n;j++) {sb.Append(" "+(dp[i][j]==inf?"INF":dp[i][j].ToString()));}
				sb.Append("\n");
			}
		}
		Console.Write(sb);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main(int argc, const char * argv[]){
    int K, A, B;
    cin >> K >> A >> B;
    int ans = K;

    while(ans <= B){
        if(A <= ans && ans <= B){
            cout << "OK" << endl;
            return 0;
        }
         ans += K;
    }

    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int R,AN,BN,XA[100000],YA[100000];
vector<int> yp[10000]; 

int main() {
  while(true) {
    scanf("%d %d %d", &AN, &BN, &R);
    if (AN == 0 && BN == 0) break;
    for (int i = 0; i < 10000; ++i) {
      yp[i].clear();
    }
    for (int i = 0; i < AN; ++i) {
      scanf("%d %d", XA+i, YA+i);
    }
    for (int i = 0; i < BN; ++i) {
      int x,y;
      scanf("%d %d", &x, &y);
      yp[x].push_back(y);
    }
    for (int i = 0; i < 10000; ++i) {
      sort(yp[i].begin(), yp[i].end());
    }
    int ans = 0;
    vector<int> yd(4*R+1);
    for (size_t i = 0; i < yd.size(); ++i) {
      yd[i] = (int)sqrt(4*R*4*R - i*i);
    }
    for (int i = 0; i < AN; ++i) {
      int minx = max(0, XA[i] - 4*R);
      int maxx = min(9999, XA[i] + 4*R);
      for (int j = minx; j <= maxx; ++j) {
	int miny = YA[i] - yd[abs(XA[i] - j)];
	int maxy = YA[i] + yd[abs(XA[i] - j)];
	for (size_t k = 0; k < yp[j].size() && yp[j][k] <= maxy; ++k) {
	  if (miny <= yp[j][k]) ++ans;
	}
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

M = 0
for i in range(-1, N-1):
  dis = abs(A[i] - A[i + 1])
  if 2*dis > K:
    dis = K - dis
  #print(dis)
  if dis > M:
    M = dis
    
print(K-M)
    

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

int main(void)
{
    int K, A, B;
    cin >> K >> A >> B;

    if (A % K == 0) {
        cout << "OK" << endl;
    }
    else {
        int tmp = A / K;
        if (K * (tmp+1) <= B) {
            cout << "OK" << endl;
        }
        else {
            cout << "NG" << endl;
        }
    }
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {
  int x;
  cin >> x;
  for (int k = -118; k < 120; k++) {
    for (int i = -118; i < 120; i++) {
      int j = i - k;
      int tmpx = (i * i * i * i * i) - (j * j * j * j * j);
      if (tmpx == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3508
import math

def make_divisors(n):
    lo_d , up_d = [] , []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lo_d.append(i)
            if i != n // i:
                up_d.append( n // i )
        i += 1
    return lo_d + up_d[::-1]

N = int(input())
List = make_divisors(N)
len_a = len(List)
ans = List[ len_a // 2 ]
print( math.floor(math.log(ans , 10)) + 1 )

Measured memory_bytes: 9140
#include<stdio.h>

struct CNT{
	int num;
	int flag;
};

char sq[102][102];
struct CNT cnt[102][102] = {0};

int main(){
	int H, W;
	int i, j;
	int min, flag=0;

	scanf("%d %d", &H, &W);

	for(i=0; i<H; i++){
		scanf("%s", sq[i]);
	}


	if(sq[0][0] == '.'){
		cnt[0][0].num = 0;
		cnt[0][0].flag = 0;
	}else{
		cnt[0][0].num = 1;
		cnt[0][0].flag = 1;
	}
	for(i=1; i<W; i++){
		if(sq[0][i] == '.'){
			cnt[0][i].num = cnt[0][i-1].num;
			cnt[0][i].flag = 0;
		}else{
			cnt[0][i].num = (cnt[0][i-1].flag == 1) ? cnt[0][i-1].num : cnt[0][i-1].num+1;
			cnt[0][i].flag = 1;
		}
	}
	for(i=1; i<H; i++){
		if(sq[i][0] == '.'){
			cnt[i][0].num = cnt[i-1][0].num;
			cnt[i][0].flag = 0;
		}else{
			cnt[i][0].num = (cnt[i-1][0].flag == 1) ? cnt[i-1][0].num : cnt[i-1][0].num+1;
			cnt[i][0].flag = 1;
		}
	}
	for(i=1; i<H; i++){
		for(j=1; j<W; j++){
			if(cnt[i-1][j].num == cnt[i][j-1].num){
				min = cnt[i-1][j].num;
				flag = (cnt[i-1][j].flag == 1 || cnt[i][j-1].flag == 1) ? 1 : 0;
			}else if(cnt[i-1][j].num < cnt[i][j-1].num){
				min = cnt[i-1][j].num;
				flag = cnt[i-1][j].flag;
			}else{
				min = cnt[i][j-1].num;
				flag = cnt[i][j-1].flag;
			}

			if(sq[i][j] == '.'){
				cnt[i][j].num = min;
				cnt[i][j].flag = 0;
			}else{
				cnt[i][j].num = (flag == 1) ? min : min+1;
				cnt[i][j].flag = 1;
			}
		}
	}

	printf("%d", cnt[H-1][W-1].num);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>


int main(){
	int n, h, input;
	bool ok = true;
	std::cin >> n;
	std::cin >> h;
	h = std::max(h - 1, 0);
	for(int i = 0; i < n - 1; i++){
		std::cin >> input;
		if(h > input){
			ok = false;
			break;
		}
		h = std::max(h, input - 1);
	}
	if(ok){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(long[]), n = rd[0], ts = rd[1];
  auto t = readln.split.to!(long[]);

  auto ans = 0L;
  foreach (i; 0..n-1)
    ans += t[i+1]-t[i] > ts ? ts : t[i+1]-t[i];
  ans += ts;

  writeln(ans);
}


Measured memory_bytes: 10584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
char s[200002];
scanf("%s",s);
int a=999999;
int b=0;
int ren=strlen(s);
for(int count=0;s[count]!='\0';count++){
if(s[count]=='A'&&a>count){a=count;}
if(s[count]=='Z'&&b<count){b=count;}

}
printf("%d\n",b-a+1);

}

Measured memory_bytes: 384
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  int N;
  cin >> N;
  vector<int> a(N);

  rep(i, N) cin >> a[i];

  ll ans = (1LL<<28);
  for(int i = -100; i <= 100; i++){
    ll tmp_ans = 0;
    rep(j, N){
      tmp_ans += (i-a[j]) * (i-a[j]);
    }
    chmin(ans, tmp_ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
# from collections import Counter, deque
# from collections import defaultdict
# from itertools import combinations, permutations, accumulate, groupby, product
# from bisect import bisect_left,bisect_right
# from heapq import heapify, heappop, heappush
# from math import floor, ceil,pi,factorial
# from operator import itemgetter
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9 + 7

n = int(input())

ans = 0
for i in range(1,n+1):
    if 1 <= i and i <= 9: ans += 1
    if 100 <= i and i <= 999: ans += 1
    if 10000 <= i and i <= 99999: ans += 1

print(ans)


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

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

    if(s=="Sunny")
       cout << "Cloudy" << endl;
    else if(s=="Cloudy")
      cout << "Rainy" << endl;
    else
    {
         cout << "Sunny" << endl;
    }
    
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])throws IOException
   {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tk;
    int n=Integer.parseInt(br.readLine());
    tk=new StringTokenizer(br.readLine());
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    {
      a[i]=Integer.parseInt(tk.nextToken());
     }
    if(n<=2)
    {
      System.out.println(Math.abs(a[1]-a[0]));
      System.exit(0);
    }
     int prev1=0;
     int prev2=Math.abs(a[1]-a[0]);
    int minCost=Integer.MAX_VALUE;
    for(int i=2;i<n;i++)
    {
      minCost= Math.min(prev1+Math.abs(a[i-2] -a[i]) , prev2+ Math.abs(a[i-1]-a[i]));
      prev1=prev2;
      prev2=minCost;
    }
    System.out.println(minCost);
    
    
    
    
  }
  
}
 

Measured memory_bytes: 31244
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<vector<int>> bingo (3, vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> bingo.at(i).at(j) ;
    }
  } //bingoの初期化
  
  int N ;
  cin >> N ;
  int b ;
  
  for(int i=0;i<N;i++){
    cin >> b ; //読み上げられた番号
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b == bingo.at(i).at(j)){
          bingo.at(i).at(j) = 0 ; //穴の開いたところは0とする
        }
      }
    }
  } //穴あけ完了
  
  for(int i=0;i<3;i++){
      if(bingo.at(i).at(0) == 0 && bingo.at(i).at(1) == 0 && bingo.at(i).at(2) == 0){
        cout << "Yes" ;
        return 0 ;
      }
    } //横列のビンゴ
  
  for(int i=0;i<3;i++){
      if(bingo.at(0).at(i) == 0 && bingo.at(1).at(i) == 0 && bingo.at(2).at(i) == 0){
        cout << "Yes" ;
        return 0 ;
      }
    } //縦列のビンゴ
  
  if(bingo.at(0).at(0) == 0 && bingo.at(1).at(1) == 0 && bingo.at(2).at(2) == 0){
    cout << "Yes" ;
    return 0 ;
  }
  
  if(bingo.at(0).at(2) == 0 && bingo.at(1).at(1) == 0 && bingo.at(2).at(0) == 0){
    cout << "Yes" ;
    return 0 ;
  }
  
  cout << "No" ;
  return 0 ;
}

Measured memory_bytes: 256
x,k,d = map(int, input().split())
mx = x + d*k
mn = x - d*k
 
if (x <= 0 and mx > 0) or (x >= 0 and mn < 0):
  if k%2 == 0:
    if x < 0:
      b = min(abs(abs(x)%(2*d)),abs(abs(x)%(2*d)-2*d))
    else:
      b = min(abs(x%(2*d)),abs(x%(2*d)-2*d))
    b = min(abs(b),abs(mx),abs(mn))
  else:
    if x > 0:
      b = min(abs(abs(x-d)%(2*d)),abs(abs(x-d)%(2*d)-2*d))
    else:
      b = min(abs(abs(x+d)%(2*d)),abs(abs(x+d)%(2*d)-2*d))
  ans = min(abs(b),abs(mx),abs(mn))
else:
  ans = min(abs(mx),abs(mn))
print (ans)

Measured memory_bytes: 61824
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int cntr,cntl;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='('){
			cntr++;
		}
		else{
			cntr--;
		}
		if(cntr<0){
			cntl++;
			cntr=0;
		}
	}
	for(int i=1;i<=cntl;i++)
		cout<<"(";
	cout<<s;
	for(int i=1;i<=cntr;i++)
		cout<<")";
	return 0;
}


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

using namespace std;

const int Nmax = 105;
typedef long long ll;

struct
{
    int weight;
    ll cost;
} a[Nmax];

int N,W;

const inline ll Max(ll a, ll b)
{
    return (a > b) ? a : b;
}

int main()
{
    cin >> N >> W;
    for(int i = 1; i <= N; ++i)
        cin >> a[i].weight >> a[i].cost;

    vector<ll> dp(W + 1,0),dp0(W + 1,0);

    for(int i = 1; i <= N; ++i)
    {
        for(int j = 1; j <= W; ++j)
            if(a[i].weight <= j)
                dp[j] = Max(dp0[j],dp0[j - a[i].weight] + a[i].cost);
            else
                dp[j] = dp0[j];
        dp0 = dp;
    }
    cout << dp0[W];
    return 0;
}


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

int main(){
  long long n,x,y = 0,z;
  cin >> n;
  long long A[n-1],X[n] = {};
  for(int i = 0;i < n-1;i++){
    cin >> A[i];
  }
  for(int i = 0;i < n;i++){
    if(i == 0)X[i] = A[i]; 
    if(A[i] == A[i+1])X[i+1] = A[i];
    if(A[i] < A[i+1]){
      X[i+1] = A[i];
    }
    if(A[i] > A[i+1]){
      X[i+1] = A[i+1];
    }
    //cout << X[i] << endl;
  }
  for(int i = 0;i < n;i++){
    y += X[i];
  }
  cout << y << endl;
}

Measured memory_bytes: 256
import sys

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

if 0 in As:
    print(0)
    sys.exit(0)

ans = 1
for i in range(N):
    ans *= As[i]
    if ans > 10**18:
        print(-1)
        sys.exit(0)

print(ans)


Measured memory_bytes: 21584
char s[4005],t[4005];
u[4005],m,i,j,c;
main(n){
	for(;~scanf(" %s %s",s,t+1);i=m=!printf("%d\n",m)){
		for(n=strlen(s);!i|t[i];i++)
			for(j=n;j--;m<c?m=c:0)
				u[j+1]=c=s[j]-t[i]?0:u[j]+1;
	}
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  stack<int> ss;
  for (int i = 0, n = s.size(); i < n; i++) {
    if (!ss.empty() && s[i] ^ ss.top() == '0' ^ '1') {
      ss.pop();
      ans++;
    } else {
      ss.push(s[i]);
    }
  }
  cout << ans * 2 << endl;
}


Measured memory_bytes: 768
#include <stdio.h>
#define N 10000
#define T 500

main()
{

  int i,j;
  int A[N],B[T];
  int n,t,f=0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);;
  }

  scanf("%d",&t);
  
  for(j = 0; j < t; j++){
    scanf("%d",&B[j]);;
  }
  
  
  for(i = 0; i < t; i++){
    for(j = 0; j < n; j++){
      if(A[j] == B[i]){
	f++;
	break;
      }
    }
  }
  
  printf("%d\n",f);

  return 0;
  
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b,c) for(int i=a;i<b;i+=c)
#define REPN(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    int n;
    int arr[120];
    int mini = -100, maxi = 100;
    sc(n);
    FOR(i,n){
        sc(arr[i]);
    }

    int mincost = INF;

    REPN(i,mini,maxi,1){
        int tot = 0;
        FOR(j,n){
            int diff = abs(arr[j] - i);
            diff*=diff;
            tot += diff;
        }
        mincost = min(mincost, tot);
    }

    cout << mincost << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
const int N = 2e5;
using namespace std;
int n,a[N+5],mi,ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
    mi = N + 5;
    for (int i = 1;i <= n;i++)
    {
        if (a[i] <= mi)
            ans++;
        mi = min(mi,a[i]);            
    }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024