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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int length = S.size();
    
    vector<int> standCount;    //1110110111 なら 0, 1, 1, 0のように端に存在しなくとも0をセット(端が0ならその値)
    vector<int> reverseCount; //1110110111なら3, 2, 3
    bool isStand = true;
    int count = 0;
    for (int i = 0; i < length; i++)
    {
        if(isStand){
            if(S.at(i) == '0'){
                count++;
            } else {
                standCount.push_back(count);
                count = 1;
                isStand = false;
            }
        }else{
            if(S.at(i) == '1'){
                count++;
            } else {
                reverseCount.push_back(count);
                count = 1;
                isStand = true;
            }
        }
    }
    if(isStand){
        standCount.push_back(count);
    }else{
        reverseCount.push_back(count);
        standCount.push_back(0);
    }
    int standSize = standCount.size();
    vector<int> ruisekiReverse(standSize);//3, 2, 3 なら0, 3, 5, 8(半開区間)
    vector<int> ruisekiStand(standSize + 1);//1, 2, 3, 3なら 0, 1, 3, 6, 9(半開区間)
    for(int i = 1; i < standSize; i++){
        ruisekiReverse.at(i) = ruisekiReverse.at(i - 1) + reverseCount.at(i - 1);
    }
    for(int i = 1; i < standSize + 1; i++){
        ruisekiStand.at(i) = ruisekiStand.at(i - 1) + standCount.at(i - 1);
    }
    int answer = 0;
    if(K >= standSize){
        answer = S.size();
    }else{
        for(int i = 1; i <= standSize - K + 1; i++){
            //i 番目からk個(i + k - 1番目)まで直立をさかだちにして結合
            int count = ruisekiStand.at(i + K - 1) - ruisekiStand.at(i - 1);
            //上の間の元から逆立ちしていた分を加算
            int revHi = min(i + K - 1, standSize - 1); 
            int revLo = max(i - 2, 0);
            count += ruisekiReverse.at(revHi) - ruisekiReverse.at(revLo);
            answer = max(answer, count);
        }
    }
    cout << answer << endl;
    return 0;
}


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

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

    auto values = vector<int>(N);
    for (auto& x : values) cin >> x;

    auto optimal = 0LL;
    for (const auto x : values)
        if (x > 0) optimal += x;

    auto positives = 0LL;
    auto negatives = 0LL;
    for (auto i = 0; i < K-1; i++)
        if (values[i] > 0) positives += values[i];
        else negatives += values[i];

    auto result = 0LL;
    for (auto left = 0, right = K-1; right < N; left++, right++)
    {
        if (values[right] > 0) positives += values[right];
        else negatives += values[right];

        result = max({result, optimal - positives, optimal + negatives});

        if (values[left] > 0) positives -= values[left];
        else negatives -= values[left];
    }

    cout << result << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for (ll i = 0; i < N; i++) cin >> A.at(i);
    for (ll i = 0; i < M; i++) cin >> B.at(i);

    ll ans = 0, i = 0, j = 0, T = K;
    while (true) {
        if (i >= M) {
            i--;
            break;
        }
        if (T - B.at(i) >= 0) {
            T -= B.at(i);
            i++;
            ans++;
        } else {
            i--;
            break;
        }
    }
    ll tmp = ans;
    while (j < N) {
        //cout << tmp << ": i = " << i << ", j = " << j << ", T = " << T << endl;
        if (T - A.at(j) >= 0) {
            T -= A.at(j);
            j++;
            tmp++;
        } else {
            if (i >= 0) {
                T += B.at(i);
                i--;
                tmp--;
            } else break;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


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

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

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	long long N,X;
	scanf("%lld %lld",&N,&X);
	printf("%lld\n",(N-GCD(N,X))*3);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % mod;  a = (a * a) % mod;  b /= 2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#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...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,i,id;
long double a,x,t,r,mi = MAX;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>t>>a;
    rep(i,1,n + 1){
        cin>>x;
        r = t - x * 0.006;
        if(fabs(a - r) < mi){
            mi = fabs(a - r);
            id = i;
        }
    }
    cout<<id;
    return 0;
}

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

int main() {
    map<char, int> l{ {'A',10}, {'B',11}, {'C',12}, {'D',13}, {'E',14}, {'F',15} };
    char x, y;
    cin >> x >> y;
    if (l[x] < l[y]){
        cout << "<" << endl;
    } else if (l[x] == l[y]){
        cout << "=" << endl;
    } else {
        cout << ">" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    ll x; cin >> x;
    ll happiness = 0;
    happiness += 1000*(x/500);
    x -= 500*(x/500);
    
    happiness += 5*(x/5);
    
    cout << happiness << endl;
    

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int  N,X,i,count;
  int L[111];
  count = 0;
  cin >> N >> X;
  for(i=0;i<=N-1;i++)
    cin >> L[i];
  int D[111];
  D[0] = 0;
  for(i=0;i<=N-1;i++)
    D[i+1] = D[i] + L[i];
  for(i=0;i<=N;i++)
    if(D[i] <= X)  count++;
  cout << count << endl;
}

Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    xy=[list(map(int,input().split())) for i in range(n)]
    x,y=[[xy[i][0],i] for i in range(n)],[[xy[i][1],i] for i in range(n)]
    x.sort()
    y.sort()
    ans=10**18*4
    for i1 in range(n):
        i1_sub=n-i1
        x_sub1=x[i1][0]
        for l1 in range(i1_sub,1,-1):
            x_sub2=x[i1+l1-1][0]
            for i2 in range(n):
                i2_sub=n-i2
                y_sub1=y[i2][0]
                x_subsub=x_sub2-x_sub1
                for l2 in range(i2_sub,1,-1):
                    y_sub2=y[i2+l2-1][0]
                    z=0
                    for i in range(n):
                        if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                            z+=1
                        if z>=k:
                            ans=min(x_subsub*(y_sub2-y_sub1),ans)
                            break
                    else:
                        break
    print(ans)
main()

Measured memory_bytes: 43868
#include <stdio.h>

void Sort(void);
int k = 0,n,A[2000001],B[2000001];

main(){

  int i;

  scanf("%d",&n);

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

  Sort();

  return 0;
}
void Sort(void){

   int C[k + 1];
   int i;
   k = k + 1;

   for(i = 0 ; i < k ; i++){
     C[i] = 0;
   }

   for(i = 1 ; i <= n ; i++ ){
     C[A[i]]++;
   }

   for(i = 1 ; i < k ;i++ ){
     C[i] = C[i] + C[i - 1];
   }

   for(i = n ; i >= 1 ;i-- ){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
   }

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

   printf("\n");


}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	vector<int> a(3);
	for (auto &i : a) cin >> i;
	if (accumulate(a.begin(), a.end(), 0) >= 22)
		cout << "bust\n";
	else
		cout << "win\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n;
	return 0;
}

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

using namespace std;
int main() {
	string str;
	bool che = false;

	cin >> str;

	for (int i = 0; i < str.length()/2; i++) {
		if (str.at(i) == str.at(str.length() - i-1)) {
			
		}
		else {
			che = true;
		}
	}
	for (int i = 0; i < (str.length() + 1 ) / 4; i++) {
		if (str.at(i) == str.at(str.length()/2-1-i)) {
		}
		else {
			che = true;
		}
	}

	if (che == true) {
		cout<<"No";
	}
	else
	{
		cout << "Yes";
	}

	return 0;
}


Measured memory_bytes: 256
import math
N, D = map(int, input().split())
a = []
for i in range(N):
  b = map(int, input().split())
  a += b
res = 0
for i in range(N-1):
  j = i + 1
  while(j < N):
    x = []
    y = []
    for k in range(D):
      x.append(a[i * D + k])
      y.append(a[j * D + k])
    tmp = 0
    for k in range(D):
      tmp += (x[k] - y[k]) ** 2
    if tmp == int(tmp ** 0.5) * int(tmp ** 0.5):
      res += 1
    j += 1
print(res)

Measured memory_bytes: 3064
#include <stdio.h>

char S[200200];

int main()
{
	long long l = 0, c[26] = { 0, };
	scanf("%s", S);
	while (S[l]) {
		c[S[l] - 'a']++;
		l++;
	}

	long long ans = 1 + l * (l + 1) / 2;
	for (int i = 0; i < 26; i++) ans -= c[i] * (c[i] + 1) / 2;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 384
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=200009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int dp[M+3];

 main()

{
    fast
    int n;
    cin>>n;
    int a[n+3];
    f(i,1,n)
    {
        cin>>a[i];
    }
    memset(dp,-1,sizeof dp);
    rf(i,n,1)
    {
        int x=a[i];
        dp[x]=1;
        if(dp[x+1]!=(-1))dp[x]+=dp[x+1];
    }
    int mx=0;
    f(i,1,n)
    {
        mx=max(mx,dp[i]);
    }
    cout<<n-mx<<endl;
    return 0;

}





































Measured memory_bytes: 3328
from collections import defaultdict
from collections import deque
from itertools import accumulate
def main():
    t = 10**18
    n = int(input())
    A=[int(i) for i in input().split()]
    A.sort()
    tmp = 1
    for i in A:
        tmp*=i
        if tmp>t:
            print(-1)
            exit()

    print(tmp)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22436
import java.util.*;
public class Main {
	public static void main(String[] args){
		String S=new java.util.Scanner(System.in).nextLine();
		if(S.equals("ABC")){
        	System.out.println("ARC");
        }
      	if(S.equals("ARC")){
      		System.out.println("ABC");
      	}
		
	}
}

Measured memory_bytes: 35792
x=input().split()
h=int(x[0])
w=int(x[1])
c=[[]*10 for i in range(10)]
for i in range(10):
    y=input().split()
    x=0
    while x<10:
        y[x]=int(y[x])
        x=x+1
    c[i].extend(y)
    
a=[[]*w for i in range(h)]

for i in range(h):
    y=input().split()
    x=0
    while x<w:
        y[x]=int(y[x])
        x=x+1
    a[i].extend(y)
    
for k in range (10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j], c[i][k]+c[k][j])
cost=0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            cost=cost+c[a[i][j]][1]
print(cost)



Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    vector<int> ans;
    if (n%2){
        for (int i = n-1;i >= 0;i--) if (i%2 == 0) ans.push_back(a[i]);
        rep(i,n) if (i%2) ans.push_back(a[i]);
    }
    else{
        for (int i = n-1;i >= 0;i--) if (i%2) ans.push_back(a[i]);
        rep(i,n) if (i%2 == 0) ans.push_back(a[i]);
    }
    array_output(all(ans));
}


Measured memory_bytes: 6644
N=int(input())

S=[None]*N
for i in range(N):
  S[i]=input()


M=int(input())
T=[None]*M
for i in range(M):
  T[i]=input()
  
score=0

for i in range(N):
  count=0
  for j in range(N):
    if S[i]==S[j]:
      count+=1
  for k in range(M):
    if S[i]==T[k]:
      count-=1
  if count>score:
    score=count
    
print(score)
  


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    pair<int, int> p1, p2, v, f; 
    cin >> p1.first >> p1.second; 
    cin >> p2.first >> p2.second; 
    v = make_pair(p2.first - p1.first, p2.second - p1.second); 
    f = make_pair(-v.second, v.first); 
    cout << p2.first + f.first << " " << p2.second + f.second << " ";
    cout << p1.first + f.first << " " << p1.second + f.second << endl;
    return 0; 
}

Measured memory_bytes: 256
// 木の直径
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100000

const int WHITE = 0;// 未訪問
const int GRAY = 1; // 訪問中
const int BLACK = 2;// 訪問完了

const int INV = -1;

typedef struct
{
    int end;    // 辺の終了側の頂点
    int weight; // 辺の重み
}DATA;

// 木の情報を保持する動的配列
vector<DATA> G[MAX_N];

// 各頂点の訪問状態を保持する配列
int color[MAX_N + 1];

// 頂点:0から一番離れた頂点のNo.
int Zero_Leave_V = -1;
// 頂点間の最大距離
int Max_Distance = -1;

int N;

void depthFirstSearch(int now_v, int distance);

int main(void)
{
    int start;
    DATA ele;

    cin >> N;

    // 配列の初期化
    for(int i = 0; i < N + 1; i++)
    {
        color[i] = WHITE;
    }

    for(int i = 0; i < N - 1; i++)
    {
        cin >> start >> ele.end >> ele.weight;

        G[start].push_back(ele);
        // 双方向に設定する
        swap(start, ele.end);
        G[start].push_back(ele);
    }

    // 頂点:0 から最も離れた点を求める
    depthFirstSearch(0, 0);

    // 訪問情報の初期化
    for(int i = 0; i < N + 1; i++)
    {
        color[i] = WHITE;
    }

    Max_Distance = -1;

    // Zero_Leave_V から, 最も離れた点との距離を求める
    depthFirstSearch(Zero_Leave_V, 0);

    cout << Max_Distance << endl;

    return 0;
}

// 深さ優先探索を実施する関数
// now_vertex : 現在の頂点のNo.
// distance : 現在までの距離
void depthFirstSearch(int now_v, int distance)
{

    int end, mid_distance;

    // 訪問中を設定
    color[now_v] = GRAY;

    for(unsigned int i = 0; i < G[now_v].size(); i++)
    {
        end = G[now_v][i].end;

        if( color[end] == WHITE )
        {
            // 距離の計算
        	mid_distance = distance;
        	mid_distance += G[now_v][i].weight;

            // 未訪問の頂点が存在する時は再帰的に関数コールする
            depthFirstSearch(end, mid_distance);
        }
    }

    // 訪問完了
    color[now_v] = BLACK;

    if( Max_Distance < distance )
    {
        //距離が最大となる頂点と距離の値を保存する
        Zero_Leave_V = now_v;
        Max_Distance = distance;
    }

    return;
}



Measured memory_bytes: 13676
s=int(input())
a=[]
a.append(s)
for i in range(1,1000000):
    n=a[i-1]
    f=0
    if n%2==0:
        f=n//2
    else:
        f=3*n+1
    if f in a:
        print(i+1)
        exit()
    a.append(f)


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

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int x = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();


			//System.Diagnostics.Debug.WriteLine(s);
			//System.Diagnostics.Debug.WriteLine(s.Substring(0, s.Length / 2));
			//System.Diagnostics.Debug.WriteLine(s.Substring(s.Length / 2 + 1, s.Length / 2));
			if (!Check(s)) {
				Console.WriteLine("No");
				return;
			}
			if (!Check(s.Substring(0, s.Length / 2))) {
				Console.WriteLine("No");
				return;
			}
			if (!Check(s.Substring(s.Length / 2 + 1, s.Length / 2))) {
				Console.WriteLine("No");
				return;
			}
			Console.WriteLine("Yes");


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(sw.Elapsed);
		}

		static bool Check(string s)
		{
			int l = s.Length;
			for (int i = 0; i < l / 2; i++) {
				if (s[i] != s[l - 1 - i]) {
					return false;
				}
			}
			return true;
		}

	}
}

Measured memory_bytes: 11092
N,X,Y=map(int,input().split())
dp=[0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    dp[min(min(abs(X-i)+1,abs(Y-i))+abs(Y-j),abs(i-j))-1]+=1
for i in range(N-1):
  print(dp[i])

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

int32_t main() {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	int a, b, h, m;
	cin >> a >> b >> h >> m;

	double hrs = h * 5;
	double min, d;
	if (m != 0) {
		hrs += double(m) / 12;
		min = m;
	}

	if (m == 0) {
		min = 60.0;
	}

	d = (hrs - min) * 6;
	double agl = (pi * d) / 180.0;
	double ans = sqrt(((a * a) + (b * b)) - (2 * a * b * cos(agl))) ;

	cout << fixed << setprecision(20) << ans;


}

Measured memory_bytes: 4140
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
  return 0;
}


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

void Solve(){
  char c; cin >> c;
  if(c == 'A') cout << "T" << endl;
  if(c == 'T') cout << "A" << endl;
  if(c == 'G') cout << "C" << endl;
  if(c == 'C') cout << "G" << endl;
}
int main(){
  Solve(); return 0;
}

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

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

	string s;
	//int n,a,b;

	//cin >> n >> a >> b;
	cin >> s;
	
	string ans="Good";
	

	
	rep(i,3){
		if(s[i]==s[i+1]) ans="Bad";
	}

	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m;
vector <pair<long long, long long>> vertice;
vector <vector<long long>> graph;
vector <long long> dp;
long long dfs(long long root){
    if(graph[root].size()==0){
        dp[root] = 0;
    }else{
        long long tmp = 0;
        for(long long i = 0; i < graph[root].size(); i++){
            if(dp[graph[root][i]]==-1){
                tmp = max(tmp,dfs(graph[root][i]));
            }else{
                tmp = max(tmp,dp[graph[root][i]]);
            }
        }
        dp[root] = tmp + 1;
    }
    return dp[root];
}
int main(){
    cin >> n >> m;
    vertice = vector <pair<long long, long long>>(m,{0,0});
    graph = vector <vector<long long>>(n,vector<long long>());
    dp = vector<long long>(n,-1);
    for(long long i = 0; i < m; i++){
        cin >> vertice[i].first;//root
        cin >> vertice[i].second;//leaf
        vertice[i].first--;
        vertice[i].second--;
    }
    for(long long i = 0; i < m; i++){
        graph[vertice[i].first].push_back(vertice[i].second);
    }
    vector <long long> ans(n);
    for(long long i = 0; i < n; i++){
        ans[i] = dfs(i);
    }
    sort(ans.begin(),ans.end());
    cout << ans.back() << endl;
        
    return 0;
}

Measured memory_bytes: 14560
loop do
  n, m = gets.split.map(&:to_i)
  break if n.zero? && m.zero?

  orchard = []
  n.times do
    orchard << gets.chomp.chars
  end
  angle = [1,0, 0,1, -1,0, 0,-1]
  count = 0

  0.upto(n-1) do |x|
    0.upto(m-1) do |y|
      next if orchard[x][y].nil?
      temp = [x, y]
      f = orchard[x][y]
      orchard[x][y] = nil

      loop do
        i = temp.shift
        j = temp.shift
        angle.each_slice(2) do |a, b|
          ii = a + i
          jj = b + j
          if (0..n-1).include?(ii) && (0..m-1).include?(jj) && f == orchard[ii][jj]
            temp << ii << jj
            orchard[ii][jj] = nil
          end
        end
        if temp.empty?
          count += 1
          break
        end
      end

    end
  end

  puts count
end

Measured memory_bytes: 7756
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
int H[MAX_N];
int dp[MAX_N];

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

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

  dp[0] = 0;
  dp[1] = abs(H[0]-H[1]);
  for (int i = 2; i < N; ++i) {
    dp[i] = min(abs(H[i]-H[i-2]) + dp[i-2], abs(H[i]-H[i-1]) + dp[i-1]);
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,nt,nx,ny;cin>>n;
  bool b=true,travel;
  vector<int> t(n+1),x(n+1),y(n+1);
  t[0]=0,x[0]=0,y[0]=0;
  for(int i=0;i<n;i++){
    cin>>t[i+1]>>x[i+1]>>y[i+1];
    nt=t[i+1]-t[i],nx=x[i+1]-x[i],ny=y[i+1]-y[i];
    if(nt<abs(nx)+abs(ny)||(nt+abs(nx)+abs(ny))%2==1){b=false;break;}
  }
  cout<<(b?"Yes":"No");
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j]){
                int temp=a[j];
                a[j]=a[i];
                a[i]=temp;
            }
        }
    }
    float sum=a[0];
    for(int i=1;i<n;i++){
        sum=(sum+a[i])/2;
    }
    printf("%f",sum);
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long M, std::vector<long long> s, std::vector<long long> c){

    for(lli i=0;i<=1000;i++){
        string t = to_string(i);
        if(t.size() != N)continue;

        bool ok = true;
        REP(j,0,M){
            if(t[s[j]-1]-'0'  != c[j])ok = false;
        }
        if(ok){
            cout<<t<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    func(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
x = list(map(int, input().split()))


max_x = max(x)
min_x = min(x)
sum_a = [0]*(max_x+1)


for i in range(0,max_x+1):
    for j in range(0,N):
        sum_a[i] += (x[j]-i)**2

#print(sum_a)
min_dis = min(sum_a)

check = min(sum_a)
ans = sum_a.index(check)
a = 0
for i in range(0,N):
    a += (x[i] - ans)**2

print(a)


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

int N, M;
map< string, int > node;

struct UnionFind {
  map< string, string > data;
  string Find(string k) {
    if(data.find(k) == data.end()) return(k);
    else return(data[k] = Find(data[k]));
 }
  void Unite(string a, string b) {
    a = Find(a), b = Find(b);
    if(a == b) return;
    data[b] = a;
  }
};
 

int main()
{
  cin >> N;
  UnionFind uf;
  for(int i = 0; i < N; i++) {
    string S;
    int V;
    cin >> S >> V;
    node.insert(make_pair(S, V));
  }
  cin >> M;
  for(int i = 0; i < M; i++) {
    string U, V;
    cin >> U >> V;
    uf.Unite(U, V);
  }
  int ret = 0;
  for(map< string, int >::iterator it = node.begin(); it != node.end(); ++it) {
    node[uf.Find(it -> first)] = min(node[uf.Find(it -> first)], it -> second);
  }
  for(map< string, int >::iterator it = node.begin(); it != node.end(); ++it) {
    ret += node[uf.Find(it -> first)];
  }
  cout << ret << endl;
  return(0);
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){    
    int N;
    cin>>N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(ALL(S));
    int ans=0;
    for(int i=0;i<N;i++){
        if(i==0){
            ans++;
        }else{
            if(S[i]!=S[i-1]){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  int64_t ten = 1;
  for (int i = 0; i < n; i++){
    ten *= 10;
    ten %= 1000000007;
  }
  int64_t nine = 1;
  for (int i = 0; i < n; i++){
    nine *= 9;
    nine %= 1000000007;
  }
  int64_t eight = 1;
  for (int i = 0; i < n; i++){
    eight *= 8;
    eight %= 1000000007;
  }
  int64_t ans = ten + eight - 2 * nine;
  while (ans < 0){
    ans += 1000000007;
  }
  ans %= 1000000007;
  cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
#define itn int
signed main(void){
    int a, b, c; cin>>a>>b>>c;
    itn ireru = a-b;
    if(ireru >= c) cout<<0<<endl;
    else cout<<c - ireru<<endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    dp = [[0, 0] for _ in range(N)]
    dp[1][0] = A[0]+A[1]
    dp[1][1] = -(A[0]+A[1])
    for i in range(2, N):
        dp[i][0] = max(dp[i-1][0] + A[i], dp[i-1][1] + A[i])
        dp[i][1] = max(dp[i-1][0]-2*A[i-1]-A[i], dp[i-1][1]+2*A[i-1]-A[i])
    # print(A)
    # print(dp)
    return max(dp[N-1])


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 24792
// Ryo Kamoi

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

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

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int INF = 1000000000;

string s;
int main(){
  cin >> s;
  
  int n = 0;
  REP(i, s.size()) {
    if (s[i] == 'o') {
      n++;
    }
  }

  n += 15 - s.size();
  if (n >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    A: u64,
    B: u64,
    N: u64
  }
  let problem = |x: u64| -> u64 {
    (A as f64 * x as f64 / B as f64).floor() as u64
  };
  println!("{}", problem(N.min(B - 1)));
}


Measured memory_bytes: 2668
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
	string s[200005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	ll count = 1;
	for (int i = 0; i < n-1; i++) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 9856
N, K = map(int,input().split())
dict = {}
for _ in range(N):
    a, b = map(int,input().split())
    if a in dict:
        dict[a] += b
    else:
        dict[a] = b

for k, v in sorted(dict.items()):
    if K <= v:
        print(k)
        exit()
    else:
        K -= v


Measured memory_bytes: 14556
#include <stdio.h>
#include <string.h>

int main(void) {
	int n,i,j;
	int data[31];
	
	while(1){
		scanf("%d",&n);
		if(!n) break;
		memset(data,0,sizeof(data));
		data[0] = 1;
		for(i = 0;i < n;i++){
			for(j = 1;j <= 3;j++){
				data[i+j] += data[i];
			}
		}
		printf("%d\n",(data[n]+3649)/3650);
	}
	
	return 0;
}

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

int dt[100001][3], n;
int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        dt[i][0] = max(dt[i-1][1], dt[i-1][2]) + a;
        dt[i][1] = max(dt[i-1][0], dt[i-1][2]) + b;
        dt[i][2] = max(dt[i-1][0], dt[i-1][1]) + c;
    }
    printf("%d", max(max(dt[n][0], dt[n][1]),dt[n][2]));
    return 0;
}


Measured memory_bytes: 1408
N,K=map(int,input().split())
a=list(map(int,input().split()))

ans=10**20
for i in range(2**(N-1)):
    I=i
    T=a[0]
    C=1
    cost=0
    S=[]
    for s in range(N-1):
        if I//(2**(N-2-s))==1:
            S.append("1")
        else:
            S.append("0")
        I%=(2**(N-2-s))
    #print(S)
    for j in range(len(S)):
        if S[j]=="1":
            if a[j+1]>T:
                T=a[j+1]
                C+=1
            else:
                cost+=T+1-a[j+1]
                T+=1
                C+=1
        else:
            if a[j+1]>T:
                T=a[j+1]
                C+=1
    if C>=K and ans>cost:
        ans=cost
    #print(C,cost,S)
print(ans)

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

int main(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        cout<<s<<"es"<<endl;
    }
    else{
        cout<<s<<"s"<<endl;
    }
    return 0;
}

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

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

	int tmp = 0;
	bool flag = false;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N-i; j++) {
			tmp = 10000 * i + 5000 * j + 1000 * (N-i-j);
			if (tmp == Y) {
				cout << i << " " << j << " " << N-i-j << endl;
				flag = true;
				break;
			}
		}
		if (flag)break;
		if (i == N)cout << "-1 -1 -1" << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int *array;
int n;
int dp[21][2000];

int _dfs(int idx, int sum) {
    if(dp[idx][sum] != -1) {
        return dp[idx][sum];
    } else if(sum == 0) {
        return dp[idx][sum] = 1;
    } else if(sum < 0) {
        return dp[idx][sum] = 0;
    } else if(idx >= n) {
        return dp[idx][sum] = 0;
    } else if(_dfs(idx + 1, sum - array[idx])) {
        return dp[idx][sum] = 1;
    } else if(_dfs(idx + 1, sum)) {
        return dp[idx][sum] = 1;
    }

    return 0;
}

bool dfs(int x) {
    memset(dp, -1, sizeof(dp));

    return _dfs(0, x);
}

int main(void) {

    scanf("%d", &n);
    array = malloc(n * sizeof(int));
    for(int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    int q;
    scanf("%d", &q);
    int *m = malloc(q * sizeof(int));

    for(int i = 0; i < q; i++) {
        scanf("%d", &m[i]);
    }
    
    for(int i = 0; i < q; i++) {
        puts(dfs(m[i]) ? "yes" : "no");
    }

    free(array);
    free(m);
    return 0;
}


Measured memory_bytes: 2084
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
/* -- template -- */

struct UnionFind {
    vector<int> par;
    vector<ll> siz;
    UnionFind(int N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; ++i) {
            par[i] = i;
        }
    }
    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        siz[ry] += siz[rx];
        par[rx] = ry;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    ll size(int x) {
        return siz[root(x)];
    }
};
ll ans[100001];
int main() {
    int N, K, L; cin >> N >> K >> L;
    UnionFind train(N);
    UnionFind road(N);
    rep(i, K) {
        int p, q;
         cin >> p >> q;
         --p, --q;
         road.unite(p, q);
    }
    rep(i, L) {
        int r, s;
        cin >> r >> s;
        --r, --s;
        train.unite(r, s);
    }
    ll ans[N];
    ll sortAns[N];
    rep(i, N) {
        ans[i] = road.root(i) + train.root(i) * 2 * 1e5;
        sortAns[i] = road.root(i) + train.root(i) * 2 * 1e5;
    }
    sort(sortAns, sortAns + N);
    rep(i, N) {
        int r = upper_bound(sortAns, sortAns + N, ans[i]) - sortAns;
        int l = lower_bound(sortAns, sortAns + N, ans[i]) - sortAns;
        cout << r - l << ' ';
    }
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int arr[502];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k, s = 0, best = 1; cin >> n >> k;

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

    for(int d = 22500; d > 0; --d){
        if(s % d != 0) continue;

        for(int div : {s / d, d}){

            int moves = 0, tot = 0;
            vector<int> moddies = {};

            for(int i = 0; i < n; ++i){
                tot += div - arr[i] % div;
                moddies.push_back(arr[i] % div);
            }

            sort(moddies.begin(), moddies.end());

            for(int i : moddies){
                moves += i;
                tot -= div - i;
                if(moves == tot && moves <= k)
                    best = max(best, div);
            }
        }
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)
 
using ll = long long;
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n, ans = 0; cin >> n;
    int a[n]; REPI(i, n) cin >> a[i];
 
    sort(a, a + n);
 
    for(ll i = 0; i < n - 2; i++)
        for(ll j = i + 1; j < n - 1; j++)
            for(ll k = j + 1; k < n; k++)
                if(a[j] < a[k] + a[i] && a[k] < a[i] + a[j])
                    ans++;
 
    cout << ans;
}

Measured memory_bytes: 256
import numpy as np
_N, _K, _Q = input().split()
N, K, Q = int(_N), int(_K), int(_Q)
A = []
for i in range(Q):
  A.append(int(input()))

if K > Q:
  for i in range(N):
    print("Yes")
else:
  score = K * np.ones(N) - Q
  for i in A:
    score[i-1] += 1
  for i in score:
    if i > 0:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 17868
#include<bits/stdc++.h>
using namespace std;
int getValue(int x) {
	if (x == 4)
		return 5;
	return (x < 4) ? x : x + 2;
}
void convert(int n) {
	if (n == 0)
		return;
	convert(n / 8);
	cout << getValue(n % 8);
}
main() {
	int n;
	while( cin >> n && n ) {convert(n); cout << endl;}
}

Measured memory_bytes: 3000
N = gets.to_i
vs = gets.split.map(&:to_i)
hashes = Array.new(2){Hash.new(0)}
hashes[0][0] = 0
hashes[1][0] = 0
 
N.times do |i|
    hashes[i%2][vs[i]] += 1
end
 
a1 = hashes[0].to_a.sort_by{|a| -a[1]}
a2 = hashes[1].to_a.sort_by{|a| -a[1]}
if a1[0][0] != a2[0][0]
    num = a1[0][1] + a2[0][1]
else
    num = [a1[0][1] + a2[1][1], a1[1][1] + a2[0][1]].max
end
puts N - num


Measured memory_bytes: 21360
#include<iostream>
#include<vector>
using namespace std;
/*int main() {
	int N;
	int S;
	cin>> N;
	S = 800 * N - 200 * (N / 15);
	cout << S;
	return 0;
}*/

int main() {

	int kai=0;
	int N;
	int A;
	int B;
	int a=0, b=0;
	cin >> N;
	cin >> A;
	cin >> B;
	for (int i = 1; i <=N; i++) {
		
			a = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + i / 10000;
			if (a >= A && a <=B ) {

				kai +=i  ;
	}
		}
	cout << kai;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  cout << x2 - (y2 - y1) << ' ';
  cout << y2 - (x1 - x2) << ' ';
  cout << x1 - (y2 - y1) << ' ';
  cout << y1 - (x1 - x2) << endl;
}

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

int main() {
    int N;
    int res = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);

    map<int, int> mp;
    for (int i = 0; i < N; i++) mp[A.at(i)]++;
    for (auto x : mp) {
        if (x.second % 2 == 1) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
const int nmax=40,abmax=10,inf = 1000000;

 int a[nmax],b[nmax],c[nmax];
 int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
int main(){
	int n;
	int x,y;
	cin>>n;
	y=n/15;
	cout<<800*n-200*y<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  rep(i,n)cin >> h[i];
  int ans = 0;
  rep(i,n)if(h[i]>=k)ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	while( true ) {
		int count = 0;
		int n,x;
		cin >> n >> x;
		if( n == 0 && x == 0 ) { break; }
		for( int i=1; i<=n; i++ ) {
			for( int j=i+1; j<=n; j++ ) {
				for( int k=j+1; k<=n; k++ ) {
					if( i+j+k == x ) { ++count; }
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef unsigned long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int q;
    cin >> q;

    int n = 1e5 + 10;
    VI cnt(n, 1);
    cnt[0] = cnt[1] = 0;
    FOR(x,2,n-1){
        int c = 0;
        for (int y = 2; y * y <= x; y++){
            if (x % y == 0) c++;
        }
        if (c < 2) cnt[x] = 0;
    }
    REP(i,n-1) cnt[i + 1] += cnt[i];

    while(q--){
        int x = in();
        printf("%d\n", cnt[x]);
    }

    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  int sum = 0, max = 0, max_num;
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
    if (max < L.at(i)) {
      max = L.at(i);
      max_num = i;
    }                  
  }
  for (int i = 0; i < N; i++) {
    if (i == max_num) continue;
    sum += L.at(i);
  }
  if (max >= sum) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

bool isPalin(string s, int i, int j)
{
  for(int x=i, y=j; x < y; x++, y--)
  {
    if(s[x] != s[y]) return false;
  }
  return true;
}

int main()
{
  FastIO
    string s;
  cin >> s;
  int n = s.size();
  if(isPalin(s,0,n-1))
  {
    if(isPalin(s,0,(n-1)/2 - 1))
    {
      if(isPalin(s,(n+3)/2 - 1, n-1))
      {
        cout << "Yes\n";
      }
      else cout << "No\n";
    }
    else cout << "No\n";
  }
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256