akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

bool kieru(std::vector<int> const& a, size_t i) {
  size_t res = 1;
  for (size_t j = i+1; j < a.size(); ++j) {
    if (a[j] != a[i]) break;
    ++res;
  }
  for (size_t j = i-1; j < a.size(); --j) {
    if (a[j] != a[i]) break;
    ++res;
  }
  return res >= 4;
}

size_t neko(std::vector<int> const& a) {
  std::vector<int> dq;
  size_t n = a.size();
  int last = -1;
  size_t ren = 0;
  for (size_t i = 0; i < n; ++i) {
    if (last == a[i]) {
      ++ren;
      dq.push_back(a[i]);
    } else {
      last = a[i];
      dq.push_back(a[i]);
      ren = 0;
      for (size_t j = 1; j <= dq.size(); ++j) {
        if (dq[dq.size()-j] != last) break;
        ++ren;
      }
    }
    if (ren >= 4) {
      while (!dq.empty() && dq.back() == last) {
        dq.pop_back();
      }
    }
    // for (size_t j = 0; j < dq.size(); ++j)
    //   fprintf(stderr, "%d%c", dq[j], j+1<dq.size()? ' ':'\n');
  }
  return dq.size();
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  size_t res = n;
  for (size_t i = 0; i < n; ++i) {
    int tmp = a[i];
    if (i-1 < n && a[i-1] != a[i]) {
      a[i] = a[i-1];
      if (kieru(a, i)) {
        // fprintf(stderr, "[%zu] <- %d\n", i, a[i-1]);
        res = std::min(res, neko(a));
      }
    }
    if (i+1 < n && a[i+1] != a[i]) {
      a[i] = a[i+1];
      if (kieru(a, i)) {
        // fprintf(stderr, "[%zu] <- %d\n", i, a[i+1]);
        res = std::min(res, neko(a));
      }
    }
    a[i] = tmp;
  }

  printf("%zu\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

using ll = long long;
using namespace std;

const int MAX=405;
const ll inf = 1e18L +5;
ll dp[MAX][MAX];


int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a[0];
    for(int i=1; i<n; ++i)
    {
        cin >> a[i];
        a[i]+=a[i-1];
    }

    for (int L=n-1; L>=0; --L)
    {
        for(int R=L; R<n; ++R)
        if (R!=L)
        {
            dp[L][R]=inf;
            ll sum = a[R];
            if (L-1>=0) sum-=a[L-1];
            for(int i=L; i<R; ++i)
            {
                dp[L][R]=min(dp[L][R],dp[L][i] + dp[i+1][R] + sum);
            }
        } else dp[L][R] =0;
    }
    cout << dp[0][n-1];
    return 0;
}



Measured memory_bytes: 1536
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local cnt = 0
local cur = 1
while cnt < n do
  cnt = cnt + 1
  cur = a[cur]
  if cur == 2 then break end
end
print(cnt < n and cnt or -1)


Measured memory_bytes: 2424
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {


			//テンプレート
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());
			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			////出力
			//Console.WriteLine(a + b + c + " " + s);

			int a = int.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' ');
			int[] d = new int[a];

			for (int i = 0;i < a;i++)
			{
				d[i] = int.Parse(input[i]);
			}

			Array.Sort(d);

			int min_point = 0;
			int max_point = 0;

			//for(int i= 0;i < a; i++)
			//{
			//	if (i >= d.Length /2 )
			//	{
			//		if(min_point != 0)
			//			min_point = i;

			//		if ((d.Length / 2 + 1) >= i)
			//		{
			//			max_point = i;
			//			break;
			//		}



			//	}
			//}

			Console.WriteLine(d[a/2] - d[a/2 - 1]);
			Console.ReadLine();

        }
    }
}

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

int main() {
    while (true) {
        char serve[101] = {};
        cin >> serve;
        if (serve[0] == '0') {
            break;
        }
        int score[2] = {};
        for (int i = 1; serve[i] != '\0'; i++) {
            if (serve[i] == 'A') {
                score[0]++;
            } else {
                score[1]++;
            }
        }
        if (score[0] > score[1]) {
            score[0]++;
        } else {
            score[1]++;
        }
        cout << score[0] << " " << score[1] << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  ll L,R; cin>>L>>R;

  ll dp[63][6]={};// i桁目, 0初手1, 1初手2, 2xlim, 3ylim, 4free, 5xylim

  dp[62][0]=1;

  repr(i,61,0){
    bool r=R>>i &1;
    bool l=L>>i &1;

    //0
    if(r and l) dp[i][5]+=dp[i+1][0];
    if(r and !l) {
      dp[i][3]+=dp[i+1][0];
      dp[i][1]+=dp[i+1][0];
    }
    if(!r and !l) dp[i][0]+=dp[i+1][0];

    //1
    if(r and l) dp[i][2]+=dp[i+1][1];
    if(r and !l) {
      dp[i][4]+=dp[i+1][1];
      dp[i][1]+=dp[i+1][1];
    }
    if(!r and !l){
      dp[i][4]+=dp[i+1][1];
      dp[i][1]+=dp[i+1][1];
    }
    if(!r and l) dp[i][2]+=dp[i+1][1];

    //2
    if(l) dp[i][2]+=dp[i+1][2];
    if(!l){
      dp[i][4]+=dp[i+1][2];
      dp[i][2]+=dp[i+1][2]*2;
    }

    //3
    if(!r) dp[i][3]+=dp[i+1][3];
    if(r){
      dp[i][4]+=dp[i+1][3];
      dp[i][3]+=dp[i+1][3]*2;
    }

    //4
    dp[i][4]+=dp[i+1][4]*3;

    //5
    if(r and l) dp[i][5]+=dp[i+1][5];
    if(r and !l) {
      dp[i][2]+=dp[i+1][5];
      dp[i][3]+=dp[i+1][5];
      dp[i][5]+=dp[i+1][5];
    }
    if(!r and !l) dp[i][5]+=dp[i+1][5];

    rep(j,6){
      dp[i][j]%=MOD;
    }

    /*
    db(i);
    rep(j,6){
      cout<< dp[i][j]<<" ";
    }
    cout<<"\n";
    */
  }

  ll ans=0;

  rep(j,6){
    ans+=dp[0][j];
  }

  cout<< ans%MOD <<"\n";


}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,a[100100],m;
map<int,int> mp;

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();m=read();
	rep(i,1,n) a[i]=read();
	int profit=0,cnt=0,mx=a[n];
	per(i,n-1,1)
	{
		int tmp=mx-a[i];
		if (tmp>profit) {profit=tmp;cnt=1;}
		else if (tmp==profit) cnt++;
		mx=max(mx,a[i]);
	}
	mp[a[n]]=1;int ans=0;
	per(i,n-1,1)
	{
		if (mp.count(a[i]+profit)) ans++;
		mp[a[i]]=1;
	}
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 5376
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int ans = 0;

            while (a >= b) {
                b *= 2;
                ++ans;
            }
            while (b >= c) {
                c *= 2;
                ++ans;
            }
            boolean ok = false;
            if (ans <= k) ok = true;
            out.println(ok ? "Yes" : "No");

        }

    }
}



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

struct Problem {
    UL N;
    UL V[200000];
    vector<UL> E[200000];
    UL P[200000];
    UL LIS[200001];
    UL ans[200000];

    void DFS(UL p) {
        UL l, r; l = 0; r = N + 1;
        while (l + 1 < r) {
            UL m = (l + r) >> 1;
            if (LIS[m - 1] < V[p]) l = m;
            else r = m;
        }
        UL buf = LIS[l];
        LIS[l] = V[p];
        UL infl, infr; infl = 0; infr = N + 1;
        while (infl + 1 < infr) {
            UL m = (infl + infr) >> 1;
            if (LIS[m - 1] != ~0u) infl = m;
            else infr = m;
        }
        ans[p] = infl;

        for (UL e : E[p]) {
            if (P[p] == e) continue;
            P[e] = p;
            DFS(e);
        }
        LIS[l] = buf;
    }

    void Solve() {
        scanf("%d", &N);
        rep(i, N) scanf("%d", V + i);
        rep(i, N - 1) {
            UL u, v; scanf("%d%d", &u, &v); u--; v--;
            E[u].push_back(v);
            E[v].push_back(u);
        }
        rep(i, N) P[i] = ~0u;
        rep(i, N + 1) LIS[i] = ~0u;
        DFS(0);
        rep(i, N) printf("%d\n", ans[i]);
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 31704
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    int64_t A,B;

    scanf("%"PRId64"%"PRId64, &A, &B);

    printf("%"PRId64, MAX(A+B,MAX(A-B,A*B)));

    return 0;
}


Measured memory_bytes: 128
a,b=[int(i) for i in input().split()]
height=[1]
for i in range(1000):
    height.append(height[i]+i+2)
for i in range(1000):
    if height[i]>a and height[i+1]>b:
        if height[i]-a==height[i+1]-b:
            print(height[i]-a)
            break

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

const int MAX = 1000005;

int main() {

	int N;
	cin >> N;

	vector<int> cnt(MAX);
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		int x = 0;
		if (cnt[A[i]] != 0) {
			cnt[A[i]]++;
			continue;
		}
		while (x + A[i] < MAX) {
			x += A[i];
			cnt[x]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (cnt[A[i]] == 1) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {
  
  long long m, k; cin >> m >> k;
  long long l = 2 << m;
  if (m == 0) {
    if (k == 0) cout << "0 0" << endl;
    else cout << -1 << endl;
    return 0;
  }
  if (k == 0) {
    for(int i=0; i<l; i++) {
      cout << i/2 << " ";
    }
    cout << endl;
    return 0;
  }
  // cerr << l/2 << " " << k << endl;
  if(l/2 <= k || m == 1) {
    cout << -1 << endl;
    return 0;
  }

  for(int i=0; i<l/2; i++) {
    if(i==k) continue;
    cout << i << " ";
  }
  cout << k << " ";
  for(int i=l/2; i<l; i++) {
  if(l-i-1==k) continue;
    cout << l-i-1 << " ";
  }
  cout << k << endl;

  return 0;
}



// EOF


Measured memory_bytes: 1920
{
  const main = (input: string) => {
    const r = reader(input)
    const n = r.n()
    const s = r.s()

    let sum = 1

    for (let i = 0; i < n - 1; i++) {
      if (s[i] !== s[i + 1]) {
        sum +=1
      }
    }

    console.log(sum)
  }

  const reader = (str: string) => {
    const lines = str.trim().split("\n")
    const s = () => lines.shift() || ""
    const n = () => Number(s())

    const ss = () => s().split(" ")
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require("fs").readFileSync("/dev/stdin", "utf8")

  main(getInput())
}


Measured memory_bytes: 7500
using System;

namespace ITP1_9_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string cards = Console.ReadLine();
                if (cards == "-")
                    break;
                int n = int.Parse(Console.ReadLine());
                for(int i = 0; i < n; i++)
                {
                    int m = int.Parse(Console.ReadLine());
                    string s = cards.Substring(0, m);
                    string t = cards.Substring(m);
                    cards = t + s;
                }
                Console.WriteLine(cards);
            }
        }
    }
}

Measured memory_bytes: 8860
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

const ll INF = (ll)4e16;
double W[] = {1, 1.7, 2.8, 4.2, 6.8, 12, 18, 31};
typedef long long ll;
ll a[10];
int m;
ll b[10000];
string s[10000];
string p = " FESTIVAL";

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

	a[0] = 1;
	while(m < 1000)
	{
		s[m] = "";
		for (int i = 1; i < 8; i++)
		{
			int cnt = 0;
			double nval = a[i] * W[i];
			while(a[i] == 0 || a[i] < nval)
			{
				a[i] += a[i - 1];
				s[m] += p[i];
				cnt++;
			}
//			printf("%d ", cnt);
		}
//		printf("\n");
		reverse(s[m].begin(), s[m].end());
		b[m] = a[7];
//		cerr << b[m] << endl;
		if (b[m] >= INF) break;
		m++;
	}
	
//	cout << m << endl;

	string ans = "";
	
	ll x;
	cin >> x;
	for (int i = m; i >= 0; i--)
	{
		while(x >= b[i])
		{
			x -= b[i];
			ans += p[8];
		}
		ans += s[i];
	}
	reverse(ans.begin(), ans.end());
	if (ans.size() > 5000) throw;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.*;


public class Main {

    private static final long INF = 1_000_000_000_000_000_000L;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] x = new long[N];
        long[] y = new long[N];
        long[] z = new long[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
        }

        long max = -INF;
        int bit = 1 << 3;
        for (int d = 0; d < bit; d++ ) {
            int a = (d & (1<<2)) != 0 ? 1 : -1;
            int b = (d & (1<<1)) != 0 ? 1 : -1;
            int c = (d & 1) != 0 ? 1 : -1;
            long[] v = new long[N];
            for (int i = 0; i < N; i++) {
                v[i] = a*x[i]+b*y[i]+c*z[i];
            }
            Arrays.sort(v);
            long tmp = 0;
            for (int i = 0; i < M; i++) {
                tmp += v[N-1-i];
            }
            max = Math.max(max, tmp);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 26892
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define FO(n) for (ll i = 0; i < n; i++)
#define endl "\n"
const long long int M = 10e9 + 7;
void solve()
{
    int n;
    cin>>n;
 vector<pair<int,int>>v;
 for(int i=0;i<n;i++){
     pair<int,int>p;
     cin>>p.first>>p.second;
     v.push_back(p);
 }
 for(int i=0;i<n;i++){
     if(i+2>=n)break;
     if(v[i].first==v[i].second&&v[i+1].first==v[i+1].second&&v[i+2].first==v[i+2].second){
         cout<<"Yes"<<endl;
         return;
     }
}
 cout<<"No"<<endl;
}

int main()
{
    faster;
    //int t;
    //cin >> t;
    //while (t--)
        solve();
    return 0;
}




Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    _ = int(input())
    A = [int(x) for x in input().strip().split()]
    MOD = 10 ** 9 + 7
    ans = 0

    for i in range(60+1):
        zero = 0
        one = 0
        m = 1 << i
        for a in A:
            if a & m:
                one += 1
            else:
                zero += 1
        ans += (one * zero) * m
        ans = ans % MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()

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

int main(void){
    int n, k;
    priority_queue<int, vector<int>, greater<int>> qu;
    vector<int> v;
    cin >> n >> k;
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i = 0;i<=n-k;i++){
        qu.push(v.at(i+k-1) - v.at(i));
    }
    cout << qu.top() << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    set<string>st;
    while(n--)
    {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size();
    return 0;
}


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

inline int left(int i, int H){ return (2 * i <= H ? 2 * i : -1); }
inline int right(int i, int H){ return (2 * i + 1 <= H ? 2 * i + 1 : -1); }

void max_heapify(int* A, int i, int H)
{
    int l = left(i, H), r = right(i, H);
    if(l < 0 && r < 0) return;
    int maxid = i, x;
    if(l > 0) maxid = (A[l] > A[maxid] ? l : maxid);
    if(r > 0) maxid = (A[r] > A[maxid] ? r : maxid);
    if(maxid == i) return;
    x = A[maxid]; A[maxid] = A[i]; A[i] = x;
    max_heapify(A, maxid, H);
}

void BuildMaxHeap(int* A, int H)
{
    for(int i = H / 2; i > 0; i--) max_heapify(A, i, H);
    return;
}

int main()
{
    int *A;
    int i, H;
    scanf("%d", &H);
    A = new int[H + 1];
    for(i = 1; i <= H; i++) scanf("%d", &A[i]);
    BuildMaxHeap(A, H);
    for(i = 1; i <= H; i++) printf(" %d", A[i]);
    printf("\n");
    delete [] A;
    return 0;
}

Measured memory_bytes: 3112
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long n, vector<long long> a){
	LL s=0;
	for(auto i:a) {
		s+=i;
	}	
	int p=0;
	for(int i=1; i<n; ++i) {
		if (abs(a[i]*n-s)<abs(a[p]*n-s)){
			p=i;
		}
	}
	cout<<p<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> a((N-1)-0+1);
	for(int i = 0 ; i <= (N-1)-0 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    auto solve = [&]() {
        int odd = 0;
        REP(i, N) {
            if (A[i] % 2 == 1)odd++;
        }
        if (odd % 2 == 1)return false;
        return true;
    };

    YESNO(solve(), "YES", "NO");
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  unsigned int i,j,k;
  unsigned int r = 0,g = 0,b = 0;
  unsigned int len;
  unsigned long cnt = 0;

  scanf("%d",&len);
  char str[len];
  scanf("%s",str);

  for(i = 0;i < len;i++){
    if(str[i] == 'R'){
      r++;
    }
    else if(str[i] == 'G'){
      g++;
    }
    else if(str[i] == 'B'){
      b++;
    }
  }
  cnt = r * g * b;

  for(i = 0;i < len;i++){
    for(j = i+1;j < len;j++){
      if((j+j-i) < len){
        if((str[i] != str[j]) && (str[j] != str[j+j-i]) && (str[j+j-i] != str[i])){
          cnt--;
        }
      }
    }
  }
  printf("%ld",cnt);
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second

ll N;
ll a[10005];
ll cnt;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

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

rep(i,N){
	ll nn=a[i];
	while(1){
		if(nn%2==0){
			nn/=2;
			cnt++;
		}else{
			break;
		}
	}
}

cout<<cnt<<endl;

}
	


Measured memory_bytes: 384
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
    long long a,b;
  	cin >> a >> b;
  if(a==1||b==1){cout << 1 << endl; return 0;}
  	if(a%2!=0 && b%2!=0)cout << (a*b/2)+1 << endl;
    else cout << a*b/2 << endl;
	return 0; 
}

Measured memory_bytes: 256
def main():
    
    N = int(input())

    POW6 = []
    POW9 = []
    for i in range(7):
        POW6.append(6**i)
        
    for i in range(6):
        POW9.append(9**i)
        
    dp = [N]*(N+1)
    dp[0] = 0    
    
    for i in range(N+1):
        cnt = 0
        while i+POW6[cnt] <= N:
            dp[i+POW6[cnt]] = min(dp[i+POW6[cnt]], dp[i]+1)
            cnt += 1
            if cnt == len(POW6):
                break
        
        cnt = 0
        while i+POW9[cnt] <= N:
            dp[i+POW9[cnt]] = min(dp[i+POW9[cnt]], dp[i]+1)
            cnt += 1
            if cnt == len(POW9):
                break            
            
    print(dp[N])
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3828
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if(x>=1&&x<=100){
            System.out.println(x*x*x);
        }
    }
}



Measured memory_bytes: 26168
#include <stdio.h>

typedef struct node{
  int id;
  int key;
}NODE;

int main(){

  NODE heap[250];
  int i, n;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&heap[i].key);
    heap[i].id = i;
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",heap[i].id,heap[i].key);
 
    if(i!=1) printf("parent key = %d, ",heap[i/2].key);
  
    if(2*i<=n) printf("left key = %d, ",heap[2*i].key);
    if(2*i+1<=n) printf("right key = %d, ",heap[2*i+1].key);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 604
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Point = Tuple!(int, "x", int, "t");

void main() {
    int n;
    scan(n);

    auto p = new Point[](2*n);

    foreach (i ; 0 .. n) {
        int ai, bi;
        scan(ai, bi);
        p[2*i] = Point(ai, 0);
        p[2*i + 1] = Point(bi, 1);
    }

    p.sort();

    int ans;
    int tmp;

    foreach (i ; 0 .. 2*n) {
        if (p[i].t == 0) {
            tmp++;
            ans = max(ans, tmp);
        }
        else {
            tmp--;
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

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

    set<int> values;
    for (int i=0; i<N; i++) values.insert(d[i]);

    cout << values.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int A;
	cin>>A;
	if(A==3||A==5||A==7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
dict = {}
b = set(a)
for d in b:
    dict.update({d:0})
for c in a:
    dict[c]+=1
ans = 0
for d in b:
    if dict[d]%2 == 1:
        ans += 1
print(ans)    


Measured memory_bytes: 23312
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

vector<int> enum_divisor(int m) {
  vector<int> divisors;
  for (ll i = 1; i*i <= m; ++i) {
    if (m % i != 0) continue;
    divisors.push_back(int(i));
    if (i * i != m) divisors.push_back(int(m / i));
  }
  return divisors;
}

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n, 0);
  vector<int> ans;

  vector<int> s(n, 0);

  for (int i = n-1; i >= 0; i--) {
    if (b[i] == a[i]) continue;
    b[i] ^= 1;
    ans.push_back(i+1);
    for (auto& v : enum_divisor(i+1)) {
      if (v == i+1) continue;
      b[v-1] ^= 1;
    }
  }

  cout << ans.size() << endl;
  for (auto v : ans) {
    cout << v << endl;
  }

  return 0;
}


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

ans = 0
mod = 10 ** 9 + 7

for k in range(K, N + 2):
    min_sum = k * (k - 1) // 2
    max_sum = k * (N + (N - k + 1)) // 2
    ans = (ans + (max_sum - min_sum + 1)) % mod

print(ans)


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

bool judge(string x,char y){
    for(int i=0;i<x.length();i++){
        if(x[i]!=y) return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    int ans=1000;
    
    for(int i=0;i<26;i++){
        string ss=s;
        int now=0;
        char a='a'+i;
        while(judge(ss,a)){
            for(int j=1;j<ss.length();j++){
                if(ss[j]==a) ss[j-1]=a;
            }
            ss=ss.substr(0,ss.length()-1);
            now++;
        }
        ans=min(ans,now);
    }
    
    cout << ans << endl;
    
    return 0;
}




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

const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
int x[N], y[N];
char op[N][2];
int n;

vector<pair<int, char> > v1[N * 2];
vector<pair<int, char> > v2[N * 2];

int cacl_1() {
    for(int i = 0; i < N * 2; i++) v1[i].clear();
    int res = inf;
    for(int i = 1; i <= n; i++) {
        if(!(op[i][0] == 'R' || op[i][0] == 'U')) continue;
        v1[x[i] + y[i]].push_back({x[i], op[i][0]});
    }
    for(int i = 0; i < N * 2; i++) {
        sort(v1[i].begin(), v1[i].end());
        for(int j = 0; j < (int)v1[i].size() - 1; j++) {
            if(v1[i][j].second == 'R' && v1[i][j + 1].second == 'U') {
                res = min(res, v1[i][j + 1].first - v1[i][j].first);
            }
        }
    }
    return res * 10;
}

int cacl_2() {
    for(int i = 0; i < N * 2; i++) v2[i].clear();
    int res = inf;
    for(int i = 1; i <= n; i++) {
        if(!(op[i][0] == 'R' || op[i][0] == 'L')) continue;
        v2[y[i]].push_back({x[i], op[i][0]});
    }
    for(int i = 0; i < N * 2; i++) {
        sort(v2[i].begin(), v2[i].end());
        for(int j = 0; j < (int)v2[i].size() - 1; j++) {
            if(v2[i][j].second == 'R' && v2[i][j + 1].second == 'L') {
                res = min(res, v2[i][j + 1].first - v2[i][j].first);
            }
        }
    }
    return res * 5;
}

void Rotate() {
	for(int i = 1; i <= n; i++) {
		int xx = y[i], yy = 200000 - x[i];
		char ch = op[i][0];
		if(ch == 'U') ch = 'R';
		else if(ch == 'R') ch = 'D';
		else if(ch == 'D') ch = 'L';
		else ch = 'U';
		x[i] = xx, y[i] = yy, op[i][0] = ch;
	}
}

void solve() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d%d%s", &x[i], &y[i], op[i]);
    }
    int res = 1e9;
    for(int i = 1; i <= 4; i++) {
        res = min(res, cacl_1());
        res = min(res, cacl_2());
        Rotate();
    }
    if(res == 1e9) puts("SAFE");
    else printf("%d\n", res);
}

int main() {
//    freopen("in.txt", "r", stdin);
//    int t; cin >> t; while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 37148
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	printf("%s\n", s == "ABC" ? "ARC" : "ABC");

	Please AC;
}


Measured memory_bytes: 3788
#include <iostream>
#include<math.h>
using namespace std;



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

	int p[60];
	int c = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];

		if(p[i] != i + 1)c++;

	}

	if (c > 2)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  cin >> h >> n;
  int sum=0;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    sum+=x;
  }
  if(sum>=h) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<tuple<int, int, char,  long long   int, string> > v; 
    tuple<int, int, char,  long long  int, string> t; 
    for(int i = 0; i < n; i++){
        int a, b;
        char c;
        long long  int d;
        string s;
        cin >> a >> b >> c >> d >> s;
        t = make_tuple(a, b, c , d, s);
        v.push_back(t);
    }
    sort(v.begin(), v.end());

    for(int i = 0; i < n; i++){
        cout << std::get<0>(v[i]) << " " <<
                std::get<1>(v[i]) << " " << 
                std::get<2>(v[i]) << " " << 
                std::get<3>(v[i]) << " " << 
                std::get<4>(v[i]) << endl;
    }
    cout << flush; 
    

}


Measured memory_bytes: 12264
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  int64_t sum=0;
  for(int i=0;i<N-1;i++){
    sum+=i+1;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i <= m;i++){
        for (int j = 0; j <= n;j++){
            if((i*n)+(j*m)-2*i*j==k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Point2D.Double P1 = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
			Point2D.Double P2 = new Point2D.Double(sc.nextDouble(),sc.nextDouble());
			System.out.println(P1.distance(P2));
		}
	}
}



Measured memory_bytes: 28040
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

    int num_500yen = (int)X/500;
    int num_5yen = (int)(X%500)/5;

    cout<<1000*num_500yen + 5* num_5yen<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define left  (2*idx)+1
#define right (2*idx)+2
#define pb push_back
#define ll long long
#define all(x) x.begin(),x.end()
 

const ll MOD = (ll)(1e9 + 7); 
const ll N = 0;

int main()
{
	FIO;
	int n, k, x, cnt = 0;
	cin >> n >> k;
	for(int i=1; i<=n; i++) {
		cin >> x;
		if(x >= k) {
			cnt+=1;
		}
	}
	cout << cnt << "\n";
	return 0;	
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,k;
    cin >> n >> k;
    k--;
    string s;
    cin >> s;
    string t1="ABC",t2="abc";
    for (int i=0;i<3;i++) {
        if (s[k]==t1[i]) s[k]=t2[i];
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()

int main() {
    int n,m;
    cin >> n >> m;
    // Max[i] : 展望台i+1から直接いける展望台のうち最大の高さ
    vector<int> h(n),Max(n);
    rep(i,n) {
        cin >> h[i];
    }
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        Max[a] = max(Max[a], h[b]);
        Max[b] = max(Max[b], h[a]);
    }
    int ans = 0;
    rep(i,n) {
        if (h[i] > Max[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
vector<int> x = {1,-1,0,0};
vector<int> y = {0,0,-1,1};
int main(){
    string s;
    cin >> s;
    string ans = "keyence";
    int n= s.size();
    if(s==ans){
        cout<<"YES"<<endl;
        return 0;
    }
    rep(i,-1,n){
        rep(j,i+1,n+1){
            string a;
            rep(k,0,n){
                
                if(k>i&&k<j){
                    continue;
                }
                a.push_back(s[k]);
            }
            if(a==ans){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    
    

  return 0;
}

Measured memory_bytes: 3640
import bisect
from operator import itemgetter
import math
import copy
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(x):
    global f
    if visited[x] == False:
        visited[x] = True
        path.append(x)
        if x == N:
            f = 1
        else:
            for i in root[x]:
                if f == 0:
                    tami(i)
                else:
                    break
            else:
                if f == 0:
                    del path[-1]

def nas(x):
    global cnt
    if (visited[x] == False) and (data[x] == 0):
        visited[x] = True
        cnt += 1
        for i in root[x]:
            nas(i)

N = I()
ab = [IL() for i in range(N-1)]
data = np.array([0]*(N+1))
root = [[]*(N+1) for i in range(N+1)]
visited = [False]*(N+1)

path = []
f = 0
for a,b in ab:
    root[a].append(b)
    root[b].append(a)

tami(1)
middle_No = path[math.ceil(len(path)/2)-1]
data[middle_No] = 1

visited = [False]*(N+1)
cnt = 0
nas(N)

Snuke = cnt
Fennec = N - Snuke

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")

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

int main(){
  int n;
  cin >> n;
  vector<int> hoge(n);
  for (int i = 0; i < n; i++){
    cin >> hoge.at(i);
  }

  sort(hoge.begin(), hoge.end());
  // cout << "a" << endl;
  // for (int i = 0; i < hoge.size(); i++){
  //   cout << hoge[i] << endl;
  // }
  int middle1 = hoge[(n/2) - 1];
  int middle2 = hoge[(n/2)];
  // cout << "middle1 " << middle1 << endl;
  // cout << "middle2 " << middle2 << endl;
  cout << middle2 - middle1 << endl;
}

Measured memory_bytes: 768
using System;
using System.Linq;

namespace atcoder.abc172.b
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = getStringParam().ToCharArray();
            char[] T = getStringParam().ToCharArray();
            int ret = 0;

            for (int c = 0; c < T.Length; c++)
            {
                if (S[c] != T[c])
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);

        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 28248
#include <iostream>
#include <string>
using namespace std;
 
typedef long long ll;
 
int main()
{
    ll M, N;
 
    cin >> N >> M;
    ll *A = new ll[N];
 
    ll total = 0;
    for(ll i=0; i<N; i++)
    {
        cin >> A[i];
        total += A[i];
    }
 
    ll cnt = 0;
    for(ll i=0; i<N; i++)
    {
        if(A[i] >= total/4.0/M)
        {
            cnt++;
        }
    }
 
    if(cnt >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256