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

long long solve(int n, int m, vector<int> &w, vector<int> &v) {
	vector<vector<long long>> dp(n+1, vector<long long>(m+1,0));
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= m; ++j)
		{
			if (i==0 || j==0) dp[i][j] = 0;
			else if (j >= w[i-1]) {
				dp[i][j] = max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	return dp[n][m];
}

int main(int argc, char const *argv[])
{
	int n,m;
	cin >> n >> m;
	vector<int> w(n), v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> v[i];
	}
	cout << solve(n,m,w,v) << "\n";
	return 0;
}

Measured memory_bytes: 83260
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n; ll c;
    cin >> n >> c;
    vector<ll> pos(n, 0);
    vector<ll> value(n, 0);
    vector<ll> L1(n+1, 0);
    vector<ll> L2(n+1, 0);
    vector<ll> R1(n+1, 0);
    vector<ll> R2(n+1, 0);
    ll acc = 0;
    for(int i = 0; i < n; i++) {
        cin >> pos[i] >> value[i];
        acc += value[i];
        L1[i+1] = acc - pos[i];
        L2[i+1] = acc - pos[i]*2;
    }
    acc = 0;
    for(int i = n-1; i >= 0; i--) {
        acc += value[i];
        R1[n-i] = acc - (c-pos[i]);
        R2[n-i] = acc - (c-pos[i])*2;
    }
    for(int i = 0; i < n; i++) {
        L1[i+1] = max(L1[i+1], L1[i]);
        L2[i+1] = max(L2[i+1], L2[i]);
        R1[i+1] = max(R1[i+1], R1[i]);
        R2[i+1] = max(R2[i+1], R2[i]);
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
        ans = max(ans, L1[i] + R2[n-i]);
        ans = max(ans, L2[i] + R1[n-i]);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4992
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

double N, X[8], Y[8];

double Dist(int i, int j){
  double ans = (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
  return sqrt(ans);
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  double sum = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      sum += Dist(i, j);
    }
  }
  printf("%.6lf\n", sum / (N / 2));
  return 0;
}


Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-24 11:13:57
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

bool dp[22][4040];

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

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

  dp[0][0] = true;

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 4040; ++j) {
      dp[i + 1][j] |= dp[i][j];
      if (j - a[i] < 0) continue;
      dp[i + 1][j] |= dp[i][j - a[i]];
    }
  }

  int q; cin >> q;

  while (q--) {
    int m; cin >> m;
    cout << (dp[n][m] ? "yes" : "no") << '\n';
  }

  return 0;
}


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

int main()
{
  int n,k;
  cin>>n>>k;
  ll h[n+1],dp[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;i++){
    ll cost=LLONG_MAX;
    for(int j=1;j<=k;j++){
      if(i-j<=0)continue;
      else cost=min(cost,dp[i-j]+abs(h[i-j]-h[i]));
    }
    dp[i]=cost;
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
N,K = list(map(int, input().split()))
A =list(map(int, input().split()))
A = sorted(A)
i = len(list(A))
if K == 0:
    print(sum(A))
else:
    if N > K:
        print(sum(A[0:(i-K)]))
    else:
        print(0)

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

int main(){
  int a,b; cin >> a >> b;
  if(a>b){
    if(b==1){
      cout << "Bob" << endl;
    }
    else{
      cout << "Alice" << endl;
    }
  }
  if(b>a){
    if(a==1){
      cout << "Alice" << endl;
    }
    else{
      cout << "Bob" << endl;
    }
  }
  if(a==b){
    cout << "Draw" << endl;
  }
}


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

int main() {
  long long N;
  cin >> N;
 
  vector<pair<long long,int>> A;
  for (long long i = 2; i*i < N; i++) {
    int x = 0;
    while(N%i == 0) {
      N /= i;
      x++;
    }
    A.emplace_back(i,x);
  }
  if (N != 1)
    A.emplace_back(N,1);
  
  int count = 0;
  for (auto p : A) {
    int b = 1;
    int y = p.second;
    while (y >= b) {
      y -= b;
      b++;
      count++;
    }   
  }
  cout << count << endl;
        
      
}


Measured memory_bytes: 19752
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long LL;
int n,x[maxn],T,E;
LL f[maxn],ans;   

int main()
{
    scanf("%d%d%d",&n,&E,&T);
    for (int i=1;i<=n;i++) scanf("%d",x+i);
    for (int i=1;i<=n;i++) f[i]=1e16;
/*    for (int i=1;i<=n;i++) 
        for (int j=1;j<=i;j++)
            f[i]=min(f[i],f[j-1]+max(T,(x[i]-x[j])*2));*/
    int p=1;LL t=1e16;;
    for (int i=1;i<=n;i++)
    {
        while ((x[i]-x[p])*2>T&&p<=i) 
        {
            t=min(t,f[p-1]-2*x[p]);
            p++;   
        }
        f[i]=min(f[i],min(f[p-1]+T,t+2*x[i]));
    }
    ans=E+f[n];
    printf("%lld\n",ans);
    return 0;
}

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

int main() {

  int H, W;
  cin >> H >> W;

  vector<string> S(H);
  for (int i = 0; i < H; i++){
    cin >> S[i];
  }

  vector<vector<int>> w(H,vector<int>(W));
  vector<vector<int>> countW(H);
  for (int i = 0; i < H; i++){
    int count = 0;
    int current = 0;
    for (int j = 0; j < W; j++){
      if (S[i][j] == '.') {
        w[i][j] = count;
        current++;
        if (j == W - 1) {
          countW[i].push_back(current);
        }
      } else {
        countW[i].push_back(current);
        current = 0;
        count++;
      }
    }
  }

  vector<vector<int>> h(W,vector<int>(H));
  vector<vector<int>> countH(W);
  for (int i = 0; i < W; i++){
    int count = 0;
    int current = 0;
    for (int j = 0; j < H; j++){
      if (S[j][i] == '.') {
        h[i][j] = count;
        current++;
        if (j == H - 1) {
          countH[i].push_back(current);
        }
      } else {
        countH[i].push_back(current);
        current = 0;
        count++;
      }
    }
  }

  int answer = 0;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        int ans = countW[i][w[i][j]] + countH[j][h[j][i]] - 1;
        answer = max(answer, ans);
      }
    }
  }

  cout << answer << endl;
  
  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int H, W;
vector<string> A;
vector<vector<int>> dist;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int main(){
  cin >> H >> W;
  A.resize(H);
  REP(i, H){
    cin >> A[i];
  }
  dist.resize(H, vector<int>(W, INF));
  queue<pair<int, int>> que;
  REP(i, H){
    REP(j, W){
      if(A[i][j] == '#'){
        que.push({i, j});
        dist[i][j] = 0;
      }
    }
  }
  while(!que.empty()){
    int x, y; tie(y, x) = que.front();
    que.pop();
    REP(i, 4){
      int nx = x + dx[i], ny = y+dy[i];
      if(nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
      if(dist[y][x] + 1 < dist[ny][nx]){
        dist[ny][nx] = dist[y][x] +1;
        que.push({ny, nx});
      }
    }
  }
 
  int ans = 0;
  REP(i, H){
    REP(j, W){
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13456
a,b,k = map(int,input().split())
for i in range(k):
    if i%2==0:
        if a%2==1:
            a-=1
        c =a//2
        b+=c
        a-=c
    else:
        if b%2==1:
            b-=1
        c =b//2
        a+=c
        b-=c
print(a,b)

Measured memory_bytes: 61844
import math

a, b, m, h = map(int, input().split())
aAngle = (m + (h/60)) * 30
bAngle = h * 6
angle = abs(aAngle - bAngle)
c = math.sqrt(a**2 + b**2 - (2*a*b*math.cos(math.radians(angle))))
print(c)

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

using namespace std;

int main() {
int n;
cin >> n;
vector<int> a(n); 
rep(i, n) {	
	cin >> a[i];
}
int pre = -999; // 最初の比較用の負のでかい数
rep(i, n) {
	if (pre <= a[i] - 1) { //直前の数-1以上ならpreを1減らして更新
		pre = a[i] - 1;
	} else if (pre <= a[i]) {//直前の数以上ならpreを更新
		pre = a[i];	
	} else {//直前の数より小さかったら問答無用でNo
		puts("No");
		return 0;
	}
}
puts("Yes");	
return 0;	
}


Measured memory_bytes: 768
from collections import deque

H, W = map(int, input().split())
a = [[0] * W for _ in range(H)]
q = deque([])
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            a[i][j] = 1
            q.appendleft((i, j, 0))

while True:
    try:
        i, j, val = q.pop()
        if i > 0 and a[i - 1][j] == 0:
            q.appendleft((i - 1, j, val + 1))
            a[i - 1][j] = 1
        if i < H - 1 and a[i + 1][j] == 0:
            q.appendleft((i + 1, j, val + 1))
            a[i + 1][j] = 1
        if j > 0 and a[i][j - 1] == 0:
            q.appendleft((i, j - 1, val + 1))
            a[i][j - 1] = 1
        if j < W - 1 and a[i][j + 1] == 0:
            q.appendleft((i, j + 1, val + 1))
            a[i][j + 1] = 1
    except:
        print(val)
        break

Measured memory_bytes: 161240
#include<iostream>
#include<set>
#include<string>

using namespace std;

int main(void){

  int n;
  string u;
  cin >> n;
  set<string>U;
  for(int i=0;i<n;i++){
    cin >> u;
    U.insert(u);
  }

  int m;
  string t;
  cin >> m;
  bool fg = false;
  while(m--){
    cin >> t;
    if(!fg && U.find(t) != U.end())cout << "Opened by " << t << endl, fg^=true;
    else if(fg && U.find(t) != U.end())cout << "Closed by " << t << endl, fg^=true;    
    else cout << "Unknown " << t << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
// In the name of Allah


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ldo;
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
const int mod = 1e9+7, MAX = 2e5+5;
ll n, t[MAX], T, res;

int main() {
	//freopen ("in.txt", "r", stdin);
	cin >> n >> T;
	for (int i = 0; i < n; i++) cin >> t[i];
	for (int i = 0; i < n-1; i++) 
	{
		if (t[i+1] - t[i] >= T)
			res += T;
		else
			res += (t[i+1]-t[i]);
	}
	res += T;
	cout << res << endl;
	return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> p(n+1, 0);
	vector<int> v(n+1, 0);
	for(int i = 2; i <= n; i++){
		cin >> p[i];
		v[p[i]]++;
	}		
	for(int i = 1; i <= n; i++){
		cout << v[i] << endl;
	}
	return 0;
} 

Measured memory_bytes: 4784
#include<iostream>
#include<vector>
#include<ctype.h>
#include<string>
using namespace std;

string W,T;

int main(){
    int counter=0;
    cin>>W;
    for(int i=0;i<W.size();++i){
        W[i]=tolower(W[i]);
    }
    
    while(1){
        cin>>T;
        if(T=="END_OF_TEXT")break;
        for(int i=0;i<T.size();++i){
            T[i]=tolower(T[i]);
        }
        if(T==W)counter++;
    }
    cout<<counter<<endl;
    return 0;
}



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

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

    int N;
    cin >> N;

    vector<int> p(N);
    for (int n = 0; n < N; n++) {
        cin >> p[n];
    }

    int count = 0;
    for (int n = 0; n < N; n++) {
        if (p[n] != n + 1) {
            count++;
        }
    }

    if (count <= 2) {
        cout << "YES"
             << "\n";
    } else {
        cout << "NO"
             << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#
# abc178 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 1 1"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 5 -4 -2"""
        output = """-6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """-1000000000 0 -1000000000 0"""
        output = """1000000000000000000"""
        self.assertIO(input, output)


def resolve():
    a, b, c, d = map(int, input().split())

    print(max(max(a*c, a*d), max(b*c, b*d)))


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    int k = Integer.parseInt(str[3]);
    int max = 0;
    
    if(b>=k-a)
      max = Math.min(k,a);
    else
      max = a*1 + (k-a-b)*-1;
    System.out.println(max);
  }
}

Measured memory_bytes: 32460
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int d, n;
	cin >> d >> n;
	int count = 0;
	if(d == 0){
		for(int i = 0; ; i++){
			int temp = i;
			if(temp % 100 != 0)count++;
			if(count == n){
				cout << i << endl;
				return 0;
			}
		}
	}else if(d == 1){
		for(int i = 100; ; i += 100){
			if(i % 10000 != 0)count++;
			if(count == n){
				cout << i << endl;
				return 0;
			}
		}
	}else{
		for(int i = 10000; ; i += 10000){
			if(i % 1000000 != 0)count++;
			if(count == n){
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> isAC(n);//defalt false
    vector<int> pena(n);//defalt 0
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (s == "AC") isAC[p] = true;
        else if (s == "WA" and !isAC[p]) pena[p]++;
    }
    int ac = 0;
    int wa = 0;
    for (int i = 0; i < n; ++i) {
        if (isAC[i]) {
            ac++;
            wa += pena[i];
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();


        int numCount = (int)inpt[0];
        long ans = 0;
        for (long i = 1; i * i <= inpt[1]; i++) {
            if(inpt[1] % i == 0) {
                long i2 = inpt[1] / i;
                if(i2 >= numCount) {
                    ans = Math.Max(i, ans);
                }
                if(i >= numCount) {
                    ans = Math.Max(i2, ans);
                }
            }
        }
        Console.WriteLine(ans);
    }






    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


1 1


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
N = int(input())
B = list(map(int, input().split())) 
A = 0
preI = 0
for i in range(0 , N):
  if i == 0:
    b = B[i]
  elif i == N - 1:
    b = B[i - 1]
  else:
    b = min(B[i], B[i - 1])
  A += b
print(A)



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

int main() {

  long long int n;
  cin >> n;

  long long int m = 0;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;
    if ( ( in % 2 ) != 0 ) m++;

  }

  if ( n == 1 ) {
    cout << "YES" << endl;
  }else if ( ( m % 2 ) == 0 ) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var cnt, total int
	fmt.Scan(&cnt, &total)

	for s := 0; s <= cnt; s++ {
		for g := 0; g <= cnt-s; g++ {
			i := cnt - (g + s)
			sum := s*1000 + g*5000 + i*10000

			if sum == total {
				fmt.Printf("%v %v %v\n", i, g, s)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
def JudgeCoffee(string):
    if(string[2] == string[3] and string[4] == string[5]):
        return True
    else:
        return False


def Main():
    S = input()
    #S = "sippuu"
    judge = JudgeCoffee(S)
    if(judge):
        print("Yes")
    else:
        print("No")
    

Main()

Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string s;
	cin>>s;
	int ans=s.size();
	int a=s.size();
	for (int i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1])ans=min(ans,max(i+1,a-1-(i+1)+1));
	}
	cout<<ans<<endl;
  //ドーナツ食べたいのに家になかった（半ギレ
}

Measured memory_bytes: 512
n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]
ans = [0 for _ in range(n)]
for i in range(q):
    ans[a[i]-1] += 1
for i in range(n):
    if q-ans[i] < k:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8592
n=gets.to_i
cnt=0
n.times do
  flag=0
  prime=gets.to_i
  if prime < 4
    cnt+=1
    next
  end
  (2..prime**(1/2.0)).each do |i|
    if prime%i==0
      flag=1
      break
    end
  end
  cnt+=1 if flag==0
end
puts cnt

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

int main(){
    string a,b;
    cin >> a >> b;
    
    int n = a.size() + b.size();
    
    vector<char> ans;
    
    for(int i = 0; i < n; i++){
        ans.push_back(a[i]);
        ans.push_back(b[i]);
    }
    
    rep(i,n) cout << ans[i];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	if(s[0]!='A'){
		
		cout<<"WA"<<endl;
		return 0;
	}
	int ans=0;
	for(int i=2;i<(int)s.size()-1;i++){
		if(s[i]=='C')ans++;
	}
	if(ans!=1){
		cout<<"WA"<<endl;
		return 0;
	}
	int ant=0;
	for(int i=0;i<(int)s.size();i++){
		if(isupper(s[i]))ant++;
	}
	if(ant!=2){
		cout<<"WA"<<endl;
		return 0;
	}
	cout<<"AC"<<endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A[110];
  for(int i = 0; i <N; i++){
    cin >> A[i];
  }
  
  bool flag = 1;
  int cnt = 0;
  while (flag){
    flag = 0;
    for(int j =1; j < N ;j++){
      if(A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        cnt++;
        flag = 1;
      }
    }
  }
  for(int i =0; i <N; i++){
    if(i == N-1){
      cout << A[i];
      break;
    }
    cout << A[i] << " ";
  }
  cout << endl;
  cout << cnt << endl;
}



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

string s;
int ans;

int main() {
	cin >> s;
	char t;
	if (s.size() % 2 == 1) {
		t = s[s.size() / 2];
		int ans = (s.size() + 1) / 2;
		for (int i = 1; i <= s.size() / 2; i++, ans++) {
			if (s[s.size() / 2 + i] != t)
				break;
			if (s[s.size() / 2 - i] != t)
				break;
		}
		cout << ans;
		return 0;
	}
	else {
		t = s[s.size() / 2];
		int ans = s.size() / 2;
		for (int i = 1; i <= s.size() / 2; i++, ans++) {
			if (s[s.size() / 2 + i - 1] != t)
				break;
			if (s[s.size() / 2 - i] != t)
				break;
		}
		cout << ans;
		return 0;
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int max_n = 1e5+3;

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

	int n;
	cin >> n;

	int a[max_n] = {};
	int b[max_n] = {};
	int t;
	rep(i, n/2) {
		cin >> t;
		a[t]++;
		cin >> t;
		b[t]++;
	}

	vector<pii> c;
	vector<pii> d;

	rep(i, max_n){
		if(a[i] > 0) c.push_back((pii){a[i], i});
		if(b[i] > 0) d.push_back((pii){b[i], i});
	}

	sort(c.begin(), c.end());
	sort(d.begin(), d.end());

	pii w = c[c.size()-1];
	pii x = d[d.size()-1];
	if(w.second != x.second){
		cout << n - w.first - x.first << endl;
	}else{
		if(c.size() == 1 && d.size() == 1){
			cout << n / 2 << endl;
		}else if(c.size() == 1){
			pii y = d[d.size()-2];
			cout << n/2 - y.first << endl;
		}else if(d.size() == 1){
			pii z = c[c.size()-2];
			cout << n/2 - z.first << endl;
		}else{
			pii y = d[d.size()-2];
			pii z = c[c.size()-2];
			if(y.first >= z.first){
				cout << n - w.first - y.first << endl;
			}else{
				cout << n - x.first - z.first << endl;
			}
		}
	}
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//
int k[(int)pow(10,6) + 1] = {};
int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    int c = 0;
    for(int i = 0; i < n; ++i){
        if(v[i] == i + 1){
            swap(v[i],v[i+1]);
            c++;
        }
        if(v[i] == i + 1){
            swap(v[i],v[i-1]);
            c++;
        }
    }

    cout << c << endl;

    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int H, N;

signed main(){
    cin >> H >> N;
    int a = 0, sum = 0;
    REP(i, N){
        cin >> a;
        sum += a;
    }
    if(sum < H) PRINT("No");
    else PRINT("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
struct node
{
    int a[26];
};
node d[52];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,i,j,n,m,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m=s.size();
        for(char c:s)
        {
            l=c-97;
            d[i].a[l]++;
        }
    }
    s.clear();
    for(i=0;i<26;i++)
    {
        l=INT_MAX;
        for(j=0;j<n;j++)
        {
            l=min(l,d[j].a[i]);
        }
        for(j=0;j<l;j++)
        {
            s+=(char)(i+97);
        }
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,n,Min,f[1001][1001],fx[10],fy[10];
char s[1001][1001];
const int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int bfs(int sx,int sy,int gx,int gy)
{
	memset(f,0,sizeof(f));
	queue<int>x,y;
	x.push(sx);y.push(sy);f[sx][sy]=1;
	while(!x.empty()){
		int hx=x.front(),hy=y.front();
		x.pop();y.pop();
		if(hx==gx&&hy==gy)break;
		for(int i=0;i<4;i++){
			int nx=hx+dx[i],ny=hy+dy[i];
			if(nx>=1&&nx<=h&&ny>=1&&ny<=w&&s[nx][ny]!='X'&&!f[nx][ny]){
				f[nx][ny]=f[hx][hy]+1;
				x.push(nx);y.push(ny);
			}
		}
	}
	return f[gx][gy]-1;
}
int main()
{
#ifdef debug
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	cin>>h>>w>>n;
	for(int i=1;i<=h;i++)
	 for(int j=1;j<=w;j++){
	 	cin>>s[i][j];
	 	if(s[i][j]=='S'){
	 		fx[0]=i;
	 		fy[0]=j;
		 }
		 else if(s[i][j]>='1'&&s[i][j]<='9'){
		 	fx[s[i][j]-'0']=i;
		 	fy[s[i][j]-'0']=j;
		 }
	 }
	for(int i=1;i<=n;i++)
		Min+=bfs(fx[i-1],fy[i-1],fx[i],fy[i]);
	cout<<Min<<endl;
	return 0;
}

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

ll N,A,B,C,D;
int P,Q,R;
ll c=0,a=0,bc=0,ans=0;
vector<char> S;
vector<int> vec;
vector<ll> lvec;
string s;

int main(){
  cin>>P>>Q>>R;

  cout<<min(P+Q,min(P+R,Q+R))<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    unsigned long long a, ans = 1;
    cin >> n;
    bool is_over = false;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a == 0){
            cout << 0;
            return 0;
        }
        if(is_over == true) continue;
        int log10_a = 0, log10_ans = 0;
        unsigned long long a_n = a / 10, a0 = a, ans0 = ans;
        while(a_n != 0){
            log10_a++;
            a0 = a_n;
            a_n /= 10;
        }
        a_n = ans / 10;
        while(a_n != 0){
            log10_ans++;
            ans0 = a_n;
            a_n /= 10;
        }
        if(log10_a + log10_ans > 18){
            // 0を待つ
            is_over = true;
            continue;
        }
        else if(log10_a + log10_ans == 18 && a0 * ans0 > 1){
            // 0を待つ
            is_over = true;
            continue;
        }
        else if(a * ans > 1000000000000000000){
            is_over = true;
            continue;
        }
        ans *= a;
    }
    if(is_over == true) cout << -1;
    else cout << ans;
    return 0;
}

Measured memory_bytes: 3644
X,Y,Z,K = map(int, input().split())
A = sorted(list(map(int, input().split())),reverse=True)
B = sorted(list(map(int, input().split())),reverse=True)
C = sorted(list(map(int, input().split())),reverse=True)

D = {(0,0,0)}
used = set()
ans = []
for k in range(K):
  #print(k,D)
  mxdsum = 0
  for d in D:
    dsum = A[d[0]]+B[d[1]]+C[d[2]]
    if dsum >= mxdsum:
      mxdsum = dsum
      mxd = d
  ans.append(mxdsum)
  if mxd[0]+1 < X and (mxd[0]+1,mxd[1],mxd[2]) not in used:
    D.add((mxd[0]+1,mxd[1],mxd[2]))
  if mxd[1]+1 < Y and (mxd[0],mxd[1]+1,mxd[2]) not in used:
    D.add((mxd[0],mxd[1]+1,mxd[2]))
  if mxd[2]+1 < Z and (mxd[0],mxd[1],mxd[2]+1) not in used:
    D.add((mxd[0],mxd[1],mxd[2]+1))
  used.add(mxd)
  D.remove(mxd)
#print(D)
for a in ans:
  print(a)


Measured memory_bytes: 46684
#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;

ll fifth_power(ll n) {
	return n * n * n * n * n;
}

int main(void) {
	ll x;
	cin >> x;
	
	for(ll b = -119; b <= 118; ++b) {
		ll m = x + fifth_power(b);
		
		for(ll a = -118; a <= 119; ++a) {
			ll n = fifth_power(a);
			
			if( a > b && n == m ) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3636
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    long long N;
    cin >> N;
    if(N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0;
    long long n = 10;
    while(n <= N) {
        ans += N / n;
        n *= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 888
#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 = 1e5+23;

int h[N];

void solve() {
  int n; scanf("%d", &n);
  long long s = 0;
  for (int x, i = 0; i < n; ++i) {
    scanf("%d", &x);
    ++h[x];
    s += x;
  }
  int q; scanf("%d", &q);
  while (q--) {
    int b, c; scanf("%d%d", &b, &c);
    s -= 1LL*h[b]*b;
    s += 1LL*h[b]*c;
    h[c] += h[b];
    h[b] = 0;
    printf("%lld\n", s);
  }
}

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


Measured memory_bytes: 4072
n=int(input())
k=int(input())
l=[int(i) for i in "0"+str(n)]
# [0]=n [1]<n
dp=[[[0]*5,[0]*5] for i in "ww"]
dp[0][0][0]=1
for i,j in enumerate(str(n)):
    i+=1
    for p in range(k+1):
        if dp[i%2-1][0][p]:
            dp[i%2][0][p+[0,1][l[i]>0]]=1
            for q in range(l[i]):
                dp[i%2][1][p+[0,1][q>0]]+=1
        if dp[i%2-1][1][p]:
            dp[i%2][1][p]+=dp[i%2-1][1][p]
            dp[i%2][1][p+1]+=dp[i%2-1][1][p]*9
    for p in range(10): dp[i%2-1][p//5][p%5]=0
print(dp[0][0][k]+dp[1][0][k]+dp[0][1][k]+dp[1][1][k])


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

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

    for(int i=0; i<s.size(); i++) {
        if(s[i]+n<=90) {
            s[i] += n;
        }
        else {
            s[i] = s[i]+n-26;
        }
    }

    cout<<s<<endl;
    return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;

int main(void)
{
    int N;
    long long K;
    int a;
    cin >> N >> K;

    Graph G(N);
    for(int i = 0;i < N;i++) {
        cin >> a;
        G[i].push_back(a);
    }
    vector<int> seen;
    vector<int> ord(N+1, -1);

    int now = 1;
    int l = 0;
    int c = 1;
    while(1) {
        if(ord[now] != -1) {
            break;
        } 
        ord[now] = seen.size();
        seen.push_back(now);
        now = G[now-1][0];
    }
    
    c = seen.size() - ord[now];
    l = ord[now];
    if (K < l){
        cout << seen[K] << endl;
    }
    else {
        cout << seen[l + ((K - l) % c)] << endl;
    }
    return 0;

}

Measured memory_bytes: 15936
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int solve(int s){
  char str1[10];
  char str2[10];
  sprintf(str1,"%d",s);
  strcpy(str2,str1);
  int flg=0;
  for(int i=strlen(str2)-1,j=0;i>=0;i--,j++){
    if(str1[j]!=str2[i]){
      flg=1;
      break;
    }
  }
  return flg==0 ? 1 : 0;
}
int main(){
  int n,a;
  cin >> n;
  for(int i=n;i>0;i--){
    if(solve(i)==1){
      a=i;
      break;
    }
  }
  for(int i=n;i<(n+n-a);i++){
    if(solve(i)==1){
      a=i;
      break;
    }
  }
  printf("%d\n",a);
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
    int n;
    cin>>n;
    vector<int>b(n-1);
    rep(i,n-1)cin>>b[i];
    vector<int>a(n);
    ll sum=0;
    rep(i,n){
        if(i!=0 && i!=n-1){
         sum+=min(b[i],b[i-1]);
          //cout<<min(b[i],b[i-1])<<endl;
        }else if(i==0){
            sum+=b[i];
        }else if(i==n-1){
            sum+=b[i-1];
        }
    }
    cout<<sum<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
typedef  long long ll;
using namespace std;

int main(void) {
	int n, m, l;
	cin >> n >> m >>l;

	int a[100][100],b[100][100];
	ll c[100][100] = {{}};

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

	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			for (int k = 0; k < m; k++)
			{
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cout << c[i][j];
			if ( j == l -1) cout << endl;
			else cout << " ";
		}
	}

	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll tmp = 0;
    int cnt = 0;
    rep(i, n) {
        if (a[i] < 0) cnt++;
        tmp += abs(a[i]);
    }
    if (cnt % 2 == 0) {
        cout << tmp << endl;
        return 0;
    }
    int mi = INF;
    rep(i, n) {
        mi = min(mi, abs(a[i]));
    }
    cout << tmp - 2*mi << endl;

}

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

int main(void) {
	int n;
	vector<int> a;
	int sum;
	double average;
	double dev_min, dev;
	int ans;

	cin >> n;
	a.resize(n);

	sum = 0;

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

	average = (double)sum / n;
	dev_min = 1000.0;
	ans = 0;
	for (int i = 0; i < n; i++) {
		if ((dev = abs(a[i] - average)) < dev_min) {
			dev_min = dev;
			ans = i;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

ans = 0

for i in range(N):
    for j in range(N)[i+1::]:
        result = 0
        for k in range(D):
            result += (X[i][k] - X[j][k])**2
        result = result**0.5
        if result == int(result):
            ans += 1

print(ans)



Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int temp;
	if(a<b){
		temp=b;
		b=a;
		a=temp;
	}
	while(1){
		temp=a%b;
		if(temp==0){
			printf("%d\n",b);
			return 0;
		}
		a=b;
		b=temp;
	}
	return 0;
}



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

int main(){
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    map<char, string> m;
    m['A'] = sa;
    m['B'] = sb;
    m['C'] = sc;
    char turn = 'A';
    while(true){
        if (m[turn].size() == 0) {
            break;
        }
        
        string& cards = m[turn];
        turn = toupper(cards[0]);
        cards.erase(cards.begin());
    }
    cout << turn << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Hash=__int128;
using ll=long long;
const ll MOD=1e9+7;
int n,x,y,z;

Hash hasher(deque<int> &deq){
    Hash res=0;
    for(auto &e:deq){
        res*=11;
        res+=e;
    }
    return res;
}

deque<int> decode(Hash val){
    deque<int> res;
    while(val){
        res.push_front(val%11);
        val/=11;
    }
    return res;
}

map<Hash,bool> isok;
bool check(Hash val){
    if(isok.count(val)) return isok[val];
    deque<int> deq=decode(val);
    vector<int> seq(deq.begin(),deq.end());
    for(int i=0;i<seq.size();i++){
        int sum=0;
        int good=0;
        for(int j=i;j<seq.size();j++){
            sum+=seq[j];
            if(sum==x) good++;
            if(sum==x+y) good++;
            if(sum==x+y+z) good++;         
        }        
        if(good==3) return isok[val]=true;
    }    
    return isok[val]=false;
}

map<Hash,Hash> pressed;
void compress(Hash &val){
    if(pressed.count(val)){
        val=pressed[val];
    }else{
        auto deq=decode(val);
        int sum=accumulate(deq.begin(),deq.end(),0);
        while(!deq.empty() && sum>=17){
            sum-=deq.front();
            deq.pop_front();
        }
        while(!deq.empty()){
            int sum=0;
            for(auto &e:deq){
                sum+=e;
                if(sum==x){
                    break;
                }
            }
            if(sum>x) deq.pop_front();
            else break;
        }
        pressed[val]=hasher(deq);
        val=pressed[val];
    }
}
int main(){    
    cin>>n>>x>>y>>z;
    ll res=0;
    vector<map<Hash,ll>> dp(n+1);
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        res*=10;
        res%=MOD;
        for(const auto &e:dp[i]){
            for(int j=1;j<=7;j++){
                Hash val=e.first*11+j;
                if(check(val)){
                    res+=e.second;
                    res%=MOD;
                }else{
                    compress(val);
                    dp[i+1][val]+=e.second;
                    dp[i+1][val]%=MOD;
                }
            }
            dp[i+1][0]+=e.second*3;
            dp[i+1][0]%=MOD;
        }
    }
    cout<<res<<endl;

}

Measured memory_bytes: 115968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] L = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            //Lの最大値
            long lMax = L.Max();
            Array.Clear(L,Array.IndexOf(L,lMax),1);
            if (lMax <L.Sum() )
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

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

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

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


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> ps(N);
    for (auto & p : ps) cin >> p;
    ps.push_back(-1);
    int c = 0;
    int len = 0;
    for (int i = 0; i != ps.size(); ++i){
        if (ps[i] == i + 1){
            ++len;
        }else{
            c += (len + 1)/2;
            len = 0;
        }
    }
    cout << c << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#ifdef sarthak
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#else
#define trace(...)
#endif

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

void solve()
{
    ll n;
    cin >> n;

    ll ans = n/2;
    if(n%2==0)
        ans--;

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    H = int(input())
    W = int(input())

    res = (n - H + 1) * (n - W + 1)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
ll a,b,res;
int main(){
	scanf("%lld%lld",&a,&b);
	if(a==b)return puts("1"),0;
	R int r,k;
	for(r=59;(a>>r&1)==(b>>r&1);--r);
	a&=(1ll<<(r+1))-1,b&=(1ll<<(r+1))-1;
	res=(1ll<<(r+1))-a;
	for(k=r-1;(~k)&&(b>>k&1^1);--k);
	if(a>(1ll<<(k+1)))res-=a-(1ll<<(k+1));
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256