akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int NUM=110;
const int MAX=2010;
const int INF=0x7ffffff;
int dis[NUM][NUM],p[MAX],t[MAX];
int access[MAX][MAX],vis[MAX],match[MAX];
void init(int n);
bool dfs(int now,int m);
int main()
{
    int n,m,l,u,v,x;
    while(~scanf("%d%d%d",&n,&m,&l)&&n+m+l)
    {
        init(n);
        for (int i=0; i<m; i++)
        {
            scanf("%d%d%d",&u,&v,&x);
            dis[u][v]=dis[v][u]=x;
        }
        for (int k=0; k<n; k++)
            for (int i=0; i<n; i++)
                for (int j=0; j<n; j++)
                    if (dis[i][j]>dis[i][k]+dis[k][j])
                        dis[i][j]=dis[i][k]+dis[k][j];
        for (int i=0; i<l; i++)
            scanf("%d%d",&p[i],&t[i]);
        for (int i=0; i<l; i++)
            for (int j=0; j<l; j++)
                if (i!=j&&t[i]+dis[p[i]][p[j]]<=t[j])
                    access[2*i][2*j+1]=access[2*j+1][2*i]=1;
        int num=0;
        for (int i=0; i<2*l; i++)
        {
            if (match[i]<0)
            {
                memset(vis,0,sizeof vis);
                if (dfs(i,2*l))
                    num++;
            }
        }
        printf("%d\n",l-num);
    }
    return 0;
}
void init(int n)
{
    memset(access,0,sizeof access);
    memset(vis,0,sizeof vis);
    memset(match,-1,sizeof match);
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            if (i!=j)
                dis[i][j]=INF;
}
bool dfs(int now,int m)
{
    vis[now]=1;
    for (int i=0; i<m; i++)
    {
        if (access[now][i])
        {
            if (match[i]==-1||!vis[match[i]]&&dfs(match[i],m))
            {
                match[i]=now;
                match[now]=i;
                return true;
            }
        }
    }
    return false;
}



Measured memory_bytes: 19064
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

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

  int n=s.length();

  int disr[110000]={0};
  for(int i=0;i<n;i++){
    int j=i;
    if(s[i]=='R'){
      while(s[i]=='R'){i++;}
      while(j!=i){disr[j]=i-j;j++;}
    }
  }
  int disl[110000]={0};
  for(int i=n;i>0;i--){
    int j=i;
    if(s[i]=='L'){
      while(s[i]=='L'){i--;}
      while(j!=i){disl[j]=j-i;j--;}
    }
  }
  int ans[110000]={0};
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      int k=disr[i];
      if(k%2==0)ans[i+k]++;
      else ans[i+k-1]++;
    }
    else{
      int m=disl[i];
      if(m%2==0) ans[i-m]++;
      else ans[i-m+1]++;

    }
  }

  for(int i=0;i<n;i++){
    cout<<ans[i]<<' ';
  }
}


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

int main(){
    int N,X=1;
  	cin>>N;
    	for(int i=1;i<10;i++){
          if((N%i==0)&&(0<N/i)&&(N/i<10)){
            X*=0;
          }
        }
  if(X==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
drink = []
for i in range (n):
    a, b = map(int, input().split())
    drink.append([a, b])
drink.sort(key=lambda x:x[0])
money = 0
store = 0
for i in range(m):
    money += drink[store][0]
    drink[store][1] -= 1
    if drink[store][1] == 0:
        store += 1
print(money)

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

using namespace std;

int lunlun_buffer[10];
int lunlun_count = 0;
int lunlun_order;

bool focus(int focus_index);

int main(void)
{
    cin >> lunlun_order;

    for(int i = 0; i < 10; i++){
        lunlun_buffer[i] = 0;
    }

    for(int i = 0; i < 10; i++){
        if(focus(i)){
          break;
        }
    }

    int index = 9;
    while(lunlun_buffer[index] == 0){
        index -= 1;
    }
    for(int i = index; i >= 0; i--){
        cout << lunlun_buffer[i];
    }

    cout << endl;

    return 0;
}

bool focus(int focus_index)
{
  	
    for(int i = 1; i <= 9; i++){
        lunlun_buffer[focus_index] = i;

        for(int j = focus_index - 1; j >= 0; j--){
            lunlun_buffer[j] = max(lunlun_buffer[j + 1] - 1, 0);
        }
        lunlun_count += 1;
        if(lunlun_order <= lunlun_count){
            return true;
        }

        int increase_index = 0;
        while(increase_index < focus_index){
            if(lunlun_buffer[increase_index] <= lunlun_buffer[increase_index + 1] && lunlun_buffer[increase_index] < 9){
                lunlun_buffer[increase_index] += 1;
                for(int i = increase_index - 1; i >= 0; i--){
                    lunlun_buffer[i] = max(0, lunlun_buffer[i + 1] - 1);
                }

                increase_index = 0;
                lunlun_count += 1;
                if(lunlun_order <= lunlun_count){
                    return true;
                }
            }else{
                increase_index += 1;
            }
        }
    }
  
    return false;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int int_sort(const void* a,const void* b)
{
	if(*(int *)a < *(int *)b)
	{
		return -1;
	}
	else if(*(int *)a == *(int *)b)
	{
		return 0;
	}
	return 1;
}

int* search(int point,int* list,int len,int max)
{
	double i = len/2.0;
	double size = len/2.0;
	int maxp = 0;
	int* data = mem(int,2);
	while(1)
	{
		const int pt = point+list[(int)i];
		if(pt > max)
		{
			if(size < 0.5)
			{
				break;
			}
			else
			{
				size/=2.0;
				i-=size;
			}
		}
		else
		{
			if(maxp < pt)
				maxp = pt;
			if(size < 0.5)
			{
				break;
			}
			else
			{
				size/=2.0;
				i+=size;
			}
		}
	}
	data[0] = maxp;
	data[1] = (int)i;
	return data;
}

int main()
{
	int n,m;
	int* data;
	int* list;
	int i,j,k;
	while(scanf("%d %d",&n,&m),n,m)
	{
		int list_len = (n+1)*(n+1);
		data = mem(int,n+1);
		list = mem(int,list_len);
		data[0] = 0;
		for(i = 1;i <= n;i++)
		{
			scanf("%d",&data[i]);
		}
		for(k = i = 0;i <= n;i++)
		{
			for(j = 0;j <= i;j++,k++)
			{
				list[k] = data[i]+data[j];
			}
		}
		list_len = k+1;
		qsort(list,list_len,sizeof(int),int_sort);
		int max = 0;
		for(i = 0;i<list_len;i++)
		{
			int* val = search(list[i],list,list_len,m);
			if(val[0] > max)
			{
				max = val[0];
			}
			list_len = val[1]+1;
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;
string s = "";

void go(int pos, int curLet = 0) {
  if (pos == n) {
    cout << s << endl;
    return;
  }
  for (int i = 0; i < curLet; i++) {
    s[pos] = (char) ('a' + i);
    go(pos + 1, curLet);
  }

  s[pos] = (char) ('a' + curLet);
  go(pos + 1, curLet + 1);
}

int main() { 

  cin >> n;
  for (int i = 0; i < n; i++) {
    s += ".";
  }

  go(0);

  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF INT_MAX 
int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    for(int i=0;i<N;i++)cin >> A[i];
    for(int i=0;i<N;i++)cin >> B[i];
    for(int i=0;i<N;i++)cin >> C[i];

    sort(A.begin(),A.end());
    sort(C.begin(),C.end());

    ll countA,countC,ans = 0;
    for(int i=0;i<N;i++){
        auto iterA = lower_bound(A.begin(),A.end(),B[i]); 
        auto iterC = upper_bound(C.begin(),C.end(),B[i]);
        countA = iterA - A.begin();
        countC = C.end() - iterC;
        ans = ans + (countA*countC);
        //cout << countA << " " << countC << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

long long int pow(long long int m, long long int n){
	if(n == 1){
		return m;
	}
	return m * pow(m, n - 1);
}


long long int a[1000000];

int main(){
	
	long long int n, m, k;
	
	while(true){
		
		cin >> n >> m >> k;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < m * (n + 1); i++){
			a[i] = 0;
		}
		
		a[0] = 1;
		
		for(int loop = 0; loop < n; loop++){
			for(int i = m * n - 1; i >= 0; i--){
				for(int j = 1; j <= m; j++){
					a[i + j] += a[i];
				}
				a[i] = 0;
			}
		}
		
		long long int num = 0;
		
		for(long long int i = 1; i < m * (n + 1); i++){
			num += a[i] * max(1LL, i - k);
		}
		
		long long int den = pow(m, n);
		
		double ans = (double)num / (double)den;
		
		printf("%.8f\n", ans);
		
	}
	
	return 0;
}

Measured memory_bytes: 3280
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            if (T.Substring(0, S.Length) == S)
            {
                WriteLine("Yes");
            }
            else WriteLine("No");
        }

        #region Functions
        public static decimal floor(float d) => Math.Floor((decimal)d);

        public static double nqrt(int n, int value) 
        {
            if (n >= 0)
            {
                // 通常のn乗根
                return Math.Pow(n, 1.0 / (double)n);
            }
            else
            {
                if ((n % 2) != 0)
                {
                    // 奇数乗根の場合
                    return -Math.Pow(-n, 1.0 / (double)n);
                }
                else
                {
                    // 偶数乗根の場合
                    return double.NaN;
                }
            }
        }
        #endregion
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}

Measured memory_bytes: 17340
PROGRAM IronBarCutting
      implicit none
      integer(16) :: n,ans
      integer(16),allocatable :: a(:)
      integer(16) :: len,cutP,i,left,right,llen,rlen
      
      read*,n
      allocate( a(n) )
      read*,a(:)
      
      len = sum( a(:) )
      
      
      left = 1; right = n;
      llen = a(1); rlen = a(n);
      do i = 1,n-2
        if( llen>rlen )then
          right = right - 1
          rlen = rlen + a(right)
        else
          left = left + 1
          llen = llen + a(left)
        end if
      end do
      
      ans = abs( llen - rlen )
      
      
      print*,ans
      
      END PROGRAM

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    //レートが3200未満で400区切りごとに分けたときのそれぞれの人数が1人以上いる色の数をAとすると
    //最小数はA,最大数はA+(3200以上の人の数)となるので
    //配列にカウントしていけばよい

    //追記
    //Aが0の場合を考慮していなかったので修正

    int n;
    cin >> n;

    vector<int> rates(9,0);

    rep(i,n){
        int tmp;
        cin >> tmp;
        tmp = min(tmp,3200);
        rates[tmp / 400]++;
    }

    int less3200 = 0;

    rep(i,8){
        if(rates[i] > 0) less3200++;
    }

    if (less3200 == 0){
        cout << 1 << " " << rates[8] << endl;
    }else{
        cout << less3200 << " " << less3200 + rates[8] << 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 FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N*A, B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
 * Union-Find tree
 * header requirement: vector
 */
class UnionFind {
private:
  std::vector<int> disj;
  std::vector<int> rank;
public:
  UnionFind(int n) : disj(n), rank(n) {
    for (int i = 0; i < n; ++i) {
      disj[i] = i;
      rank[i] = 0;
    }
  }
  int root(int x) {
    if (disj[x] == x) {
      return x;
    }
    return disj[x] = root(disj[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (rank[x] < rank[y]) {
      disj[x] = y;
    } else {
      disj[y] = x;
      if (rank[x] == rank[y]) {
	++rank[x];
      }
    }
  }
  bool is_same_set(int x, int y) {
    return root(x) == root(y);
  }
};


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int w, h;
  while ((cin >> w >> h) && (w || h)) {
    vector<VI> mp(h, VI(w, 0));
    REP(i, 0, h) {
      REP(j, 0, w) {
	cin >> mp[i][j];
      }
    }
    UnionFind uf(w * h);
    REP(i, 0, h) {
      REP(j, 0, w) {
	if (mp[i][j] == 0) { continue; }
	REP(dx, -1, 2) {
	  REP(dy, -1, 2) {
	    if (dx == 0 && dy == 0) { continue; }
	    int nx = i + dx;
	    int ny = j + dy;
	    if (0 <= nx && nx < h && 0 <= ny && ny < w && mp[nx][ny]) {
	      // unite
	      uf.unite(i * w + j, nx * w + ny);
	    }
	  }
	}
      }
    }
    set<int> roots;
    REP(i, 0, h * w) {
      int x = i / w;
      int y = i % w;
      if (mp[x][y]) {
	roots.insert(uf.root(i));
      }
    }
    cout << roots.size() << endl;
  }
}

Measured memory_bytes: 3136
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , k ;
    cin >> n >> k ; 
    vector<int> v(n) ;
    int ans = 0 ; 
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
        ans = max(ans, v[i]) ;
    }
    double L = 1, R = 1e9 ; 
    for(int rep = 0; rep < 300; rep++){
        double mid = (L + R) / 2.0;
        int cnt = 0 ;
        for(int i = 0; i < n; i++){
            double c = ceil(v[i] / mid) ;
            cnt += c - 1 ;
        }
        if ( cnt <= k ) {
            ans = min(ans, (int)ceil(mid)) ;
            R = mid ;
        }
        else L = mid ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 4772
n = int(input())
h = list(map(int,input().split()))

#水やり回数を判別する関数
def WaterTime(list):
    times=0
    if list[0]!=0:
        times+=1
    for i in range(1,len(list)):
        if list[i]!=0 and list[i-1]==0:
            times+=1
    return times
ans=0
tmp=0
j=0
while max(h) != 0:
    tmp = max(h)
    for i in h:
        if i!=0 and i<tmp:
            tmp=i
    ans += tmp*WaterTime(h)
    for j in range(n):
        if h[j]!=0:
            h[j] = h[j]-tmp
print(ans)

Measured memory_bytes: 3064
def div(A, l, r):
    if l+1 < r:
        mid = (l+r) // 2
        div(A, l, mid)
        div(A, mid, r)
        solve(A, l, mid, r)

def solve(A, l, m, r):
    global cnt
    l_i = 0
    r_i = 0
    L = A[l:m]
    R = A[m:r]
    L.append(1e9)
    R.append(1e9)
    for i in range(l, r):
        if L[l_i] > R[r_i]:
            A[i] = R[r_i]
            r_i += 1
        else:
            A[i] = L[l_i]
            l_i += 1
            cnt += r_i
n = int(input())
A = list(map(int, input().split()))
cnt = 0
div(A, 0, n)
print(cnt)


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

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

  vector<int> operations;
  for (int i = 0; i < N; i++) {
    int o;
    cin >> o;
    operations.push_back(o - 1);
  }

  int position = 0;
  int count = 0;
  while (true) {
    int o = operations[position];
    if (position == 1) {
      cout << count << endl;
      break;
    }
    if (count >= N) {
      cout << -1 << endl;
      break;
    }

    count++;
    position = o;
  }
}


Measured memory_bytes: 3936
// ALDS1_4_C Dictionary

#include <iostream>
#include <string>
#include <vector>
#define N_MAX	1046527	// 理屈はわからないが…

long dic[N_MAX] = {0};

int char2value(char c){
	switch(c){
		case 'A': return 1;
		case 'C': return 2;
		case 'G': return 3;
		case 'T': return 4;
		default:  return 0;
	}
}

long data2value(std::string data){
	long total = 0;

	for(int i=0 ; i<data.size() ; i++){
		total = 5 * total + data[i];
	}

	return total;
}

long getHash1(long key){
	return key % N_MAX;
}

long getHash2(long key){
	return (key % (N_MAX-1)) + 1;
}

void insertData(long data){
	for(int i=0 ; ; i++){
		long hash = (getHash1(data) + i*getHash2(data)) % N_MAX;
		// No data
		if(dic[hash] == 0){
			dic[hash] = data;
			return;
		}
		// Same data
		else if(dic[hash] == data){
			return;
		}
	}
}

bool findData(long data){
	for(int i=0 ; ; i++){
		long hash = (getHash1(data) + i*getHash2(data)) % N_MAX;
		// No data
		if(dic[hash] == 0){
			return false;
		}
		// Match data
		else if(dic[hash] == data){
			return true;
		}
	}
}

int main(int argc, char *argv[]){
	std::string command;
	std::string data;
	std::vector<bool> result;
	int n;

	std::cin >> n;

	for(int i=0 ; i<n ; i++){
		std::cin >> command >> data;
		long key = data2value(data);
		if(command == "insert"){
			insertData(key);
		}
		else if(command == "find"){
			result.push_back(findData(key));
		}
	}

	for(auto itr=result.begin() ; itr!=result.end() ; itr++){
		if(*itr){
			std::cout << "yes" << std::endl;
		}
		else{
			std::cout << "no" << std::endl;
		}
	}

	return 0;
}



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

using T = double;
const T EPS = 1e-10;

/* Point */
using P = complex<T>;
#define x real()
#define y imag()
template <typename T> inline bool eq(T p, T q) { return abs(p - q) < EPS; }
inline int sgn(T x) { return (T(0) < x) - (x < T(0)); }
inline T dot(P v, P w) { return (conj(v) * w).x; }
inline T cross(P v, P w) { return (conj(v) * w).y; }
inline bool isOrth(P v, P w) { return dot(v, w) == 0; }
inline bool isPara(P v, P w) { return cross(v, w) == 0; }
inline P translate(P p, P v) { return p + v; }
inline P scale(P p, P c, T k) { return c + (p - c) * k; }
inline P rot(P p, T a) { return p * polar(1.0, a); }
inline P rot90(P p) { return {-p.y, p.x}; }
inline T orient(P a, P b, P c) { return cross(b - a, c - a); }
istream& operator>>(istream& is, P& p) {
    T xx, yy;
    is >> xx >> yy;
    p = P(xx, yy);
    return is;
}

/* Circle */
struct C : P {
    T r;
    C(P p = P(0.0, 0.0), T r = 0.0) : P(p), r(r) {}
    friend ostream& operator << (ostream& os, const C& c) { return os << '(' << c.x << ", " << c.y << ", " << c.r << ')'; }
};

P circumCenter(P a, P b, P c) {
    b -= a, c -= a;
    assert(cross(b, c) != 0);
    return a + rot90(b * norm(c) - c * norm(b)) / cross(b, c) / T(2);
}

int main() {
    cout << fixed << setprecision(3);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        P p[3];
        for (int j = 0; j < 3; ++j) {
            cin >> p[j];
        }
        P o = circumCenter(p[0], p[1], p[2]);
        cout << o.x << " " << o.y << " " << abs(p[0] - o) << endl;
    }
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main() {
	long long A, B;
	cin >> A >> B;

	cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("B.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a-c)/(c+b) << endl;
    return 0;
}

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

using namespace std;

int ans, n, v[(int)1e5];
int odd[(int)1e5+1], even[(int)1e5+1];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> v[i];
		if(i % 2 == 0) odd[v[i]]++;
		else even[v[i]]++;
	}
	
	int odd_first = 0, odd_first_itr = 0, odd_second = 0, odd_second_itr = 0;
	int even_first = 0, even_first_itr = 0, even_second = 0, even_second_itr = 0;

	for(int i = 0; i <= (int)1e5; ++i){
		if(odd[i] > odd_first){
			odd_first = odd[i];
			odd_first_itr = i;
		}
	}
	for(int i = 0; i <= (int)1e5; ++i){
		if(i == odd_first_itr) continue;
		if(odd[i] > odd_second){
			odd_second = odd[i];
			odd_second_itr = i;
		}
	}
	for(int i = 0; i <= (int)1e5; ++i){
		if(even[i] > even_first){
			even_first = even[i];
			even_first_itr = i;
		}
	}
	for(int i = 0; i <= (int)1e5; ++i){
		if(i == even_first_itr) continue;
		if(even[i] > even_second){
			even_second = even[i];
			even_second_itr = i;
		}
	}
	
	if(odd_first_itr == even_first_itr){
		ans = min(n - odd_first - even_second, n - odd_second - even_first);
	}else{
		ans = n - odd_first - even_first;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1536
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var flowers = readIntSplit(by: " ")
var ans = 0
while flowers.max()! > 0 {
    var flag = false
    for i in 0..<N {
        if flowers[i] > 0 {
            flowers[i] -= 1
            if !flag {
                ans += 1
                flag = true
            }
        } else {
            flag = false
        }
    }
}
print(ans)


Measured memory_bytes: 6768
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int ans = 1000000000;
    for(int i=-100; i<=100; i++){
        int sum=0;
        for(int j=0; j<n; j++){
            sum += (a[j]-i)*(a[j]-i);
        }
        if(sum<ans){
            ans = sum;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力の取得
N, M, Q = list(map(int, input().split()))
a, b, c, d = [], [], [], []
for q in range(Q):
    a_q, b_q, c_q, d_q = list(map(int, input().split()))
    a.append(a_q)
    b.append(b_q)
    c.append(c_q)
    d.append(d_q)


def get_score(A: tuple) -> int:
    """得点を計算するメソッド

    Arguments:
        A {tuple} -- 数列

    Returns:
        int -- 得点
    """
    score = 0
    for a_i, b_i, c_i, d_i in zip(a, b, c, d):
        score += (A[b_i-1] - A[a_i-1] == c_i) * d_i
    return score


def main() -> None:
    """Entry point
    """
    # 求解処理
    # 条件を満たす数列を全探索
    l = list(range(1, M+1))
    result = 0
    for A in itertools.combinations_with_replacement(l, N):
        result = max(result, get_score(A))

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9092
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[300010];int a[300010],m;ll ans;
void wrk()
{
	int t=0;
	for (int i=1;i<=m;i++)
	{
		if (a[i]==1) ans+=i-1-t,t++;
	}
}
int main()
{
	int n,i;cin>>s+1;n=strlen(s+1);
	for (i=1;i<=n+2;i++)
	{
		if (s[i]=='A') a[++m]=0;
		else if (s[i]=='B' && s[i+1]=='C') a[++m]=1,i++;
		else {wrk();m=0;}
	}
	cout<<ans;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    ll int a,b,n;
    cin>>a>>b>>n;
    ll int x=min((b-1),n);
    ll int ans=((a*x)/b)-a*(x/b);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
from itertools import accumulate as acc
N, K, *A = map(int, open(0).read().split())
B = [0]+list(acc(A))
M = list(acc(a if a>0 else 0 for a in A))
ans = -10**30
s = sum(A)
for i in range(N-K+1):
  mi = B[i+K]-B[i]
  c = M[N-1] - M[i+K-1]
  if i>0:
    c += M[i-1]
  ans = max(ans,mi+c,c)
print(ans)

Measured memory_bytes: 16780
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll 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;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));
}


Measured memory_bytes: 31488
#include<iostream>

int main()
{
	int a;
	int s;
	int m;
	int h;

	std::cin >> a;

	h = a / 3600;
	m = a % 3600 / 60;
	s = a % 3600 % 60;
	

	std::cout << h << ':' << m << ':' << s<<'\n';

	return 0;


}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
 
int main() {
    int N;
    string S;
    cin >> N >> S;
 
    int ans = 0;
 
    int prev_black_sum = 0;
    int now_white_sum = 0;
    int tmp_white_sum = 0;
    bool now_white;
    if(S.at(0) == '.') {
        now_white = true;
    } else {
        now_white = false;
    }
 
    for(int i=0; i < S.size(); i++) {
 
        // 白から黒に切り替わったタイミングで計算して変数なども初期化
        if (S.at(i) == '#' && now_white) {
            // 白を黒に変える場合は
            if (prev_black_sum - tmp_white_sum > now_white_sum) {
                ans += now_white_sum;
                tmp_white_sum += now_white_sum;
                now_white_sum = 0;
                // 黒のsumは更新しない
            } else {
                // 黒を白に変える
                ans = ans - tmp_white_sum  + prev_black_sum ;
                prev_black_sum = 0;
                now_white_sum = 0;
                tmp_white_sum = 0;
            }
        }
        // 黒が続いたら、黒の合計値を加算する
        if (S.at(i) == '#') {
            prev_black_sum++;
            now_white = false;
        }
 
        // 白が続いたら、白の合計値を加算する
        if (S.at(i) == '.') {
            now_white_sum++;
            now_white = true;
        }
    }
 
    // 最後が白で終わった場合
    if (S.at(N-1) == '.') {
        // 白を黒に変える場合は
        if (prev_black_sum - tmp_white_sum > now_white_sum) {
            ans += now_white_sum;
            tmp_white_sum += now_white_sum;
            now_white_sum = 0;
            // 黒のsumは更新しない
        } else {
            // 黒を白に変える
            ans = ans - tmp_white_sum - tmp_white_sum + prev_black_sum ;
            prev_black_sum = 0;
            now_white_sum = 0;
            tmp_white_sum = 0;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	string a;
	char b, c, d, e;
	cin >> a;
	b = 'Y';
	c = 'A';
	d = 'K';
	e = 'I';
	if(a[0] == b && a[1] == c && a[2] == d && a[3] == e)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n; cin >> n;

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

 int b=s.size();
cout << b << endl;

}

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

int main()
{
  i64 N;
  cin >> N;
  vector<i64> a(N);
  for (i64 i = 0; i < N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  if (a[N - 1] == 0)
    cout << "Yes" << endl;
  else if (N % 3 == 0)
  {
    if (a[0] == 0 && a[N / 3 - 1] == 0 && a[N / 3] == a[N - 1])
      cout << "Yes" << endl;
    else if (a[0] == a[N / 3 - 1] && a[N / 3] == a[2 * N / 3 - 1] && a[2 * N / 3] == a[N - 1] && (a[0] ^ a[N / 3] ^ a[2 * N / 3]) == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1024
N,W=map(int,input().split())
A=[]
W1,W2,W3,W4=[],[],[],[]
for i in range(N):
  w,v=map(int,input().split())
  if i==0:
    a=w
  A.append((v,w))
  if w-a==0:
    W1.append(v)
  elif w-a==1:
    W2.append(v)
  elif w-a==2:
    W3.append(v)
  else:
    W4.append(v)
  

W1,W2,W3,W4=sorted(W1)[::-1],sorted(W2)[::-1],sorted(W3)[::-1],sorted(W4)[::-1]

l1,l2,l3,l4=len(W1),len(W2),len(W3),len(W4)
ans=0
for i in range(l1+1):
  for j in range(l2+1):
    for k in range(l3+1):
      for l in range(l4+1):
        value=sum(W1[:i])+sum(W2[:j])+sum(W3[:k])+sum(W4[:l])
        if a*i+(a+1)*j+(a+2)*k+(a+3)*l<=W:
          ans=max(ans,value)
print(ans)

Measured memory_bytes: 9280
# -*- coding: utf-8 -*-
# B - Template Matching
# モジュールのインポート
import itertools

# 標準入力の取得
N,M = list(map(int, input().split()))
A_LIST = [list(input()) for n in range(N)]
B_LIST = [list(input()) for m in range(M)]

# 左上を基準に全探索を行う
result = False
for n1,n2 in itertools.product(range(N-M+1), range(N-M+1)):
    is_included = True
    for m1,m2 in itertools.product(range(M), range(M)):
        char_A = A_LIST[n1+m1][n2+m2]
        char_B = B_LIST[m1][m2]
        if char_A != char_B:
            is_included = False

    if is_included:
        result = True
        break

# 結果出力
if result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
vector<int> A;

int main() {
    int K,T;
    cin >> K >> T;
    A.resize(T);
    for(int i=0; i<T; i++) cin >> A[i];

    int res = 0;

    int pre = 0;
    int maximum = A[0];
    for(int i=1; i<T; i++) {
        if(A[i] > maximum) {
            maximum = A[i];
            pre = i;
        }
    }
    A[pre]--;

    for(int i=1; i<K; i++) {
        int eat = pre;
        int temp = 0;
        for(int j=0; j<T; j++) {
            if(j == pre) continue;
            if(A[j] > temp) {
                temp = A[j];
                eat = j;
            }
        }
        if(eat == pre) {
            A[pre]--;
            res++;
        } else {
            A[eat]--;
            pre = eat;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ALDS1_2_B

def selectionSort(A):
    count = 0
    swap = False
    for i in range(len(A)):
        minj = i
        for j in range(i+1, len(A)):
            if A[j] < A[minj]:
                minj = j
                swap = True
        if swap:
            A[i], A[minj] = A[minj], A[i]
            count += 1
            swap = False
    
    print(" ".join(list(map(str, A))))
    print(count)

n = int(input())
A = list(map(int, input().split()))

selectionSort(A)


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for(int i=0; i<N; ++i) cin >> p[i];
	int ans=0;
	for(int i=1; i+1<N; ++i){
	    if((p[i]>p[i-1]) ^ (p[i]>p[i+1])) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
INF = 10**9 + 7

def main():
    n = int(input())
    N = list(map(int,input().split()))
    ans = 0
    """
    for i in range(n - 1):
        #print(N[i] , sum(N[i + 1:]))
        ans += (N[i] * sum(N[i + 1:])) % INF
        ans %= INF
    """
    # ans = sum(N)  /2
    N2 = [pow(i, 2, INF) for i in N]
    N3 = pow(sum(N), 2, INF)
    #print(N2, N3)
    N4 = (N3 - sum(N2))
    if N4 % 2 == 1:
        N4 += INF
    ans = (N4 / 2) % INF
    print(int(ans))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 49768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    int n=0;
    scanf("%d",&n);
    int a[n-1],b[n];

    for(int i=0;i<n-1;i++)
    {
        scanf("%d",&a[i]);
        b[i]=0;
    }
    b[n-1]=0;

    for(int i=0;i<n-1;i++)
    {
        b[a[i]-1]=b[a[i]-1]+1;
    }

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

    return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,sum,ans1,ans2;
  cin >> a >> b >> c >> d;
  sum = a + b + c + d;
  ans1 = sum/60;
  ans2 = sum%60;
  cout << ans1 << endl;
  cout << ans2 << endl;
  return 0;
}


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

void dfs(const vector<vector<int>> &adj, int curr, vector<int> &dp, vector<int> &visited) {
	if (!visited[curr]) {
		visited[curr] = 1;
		int max_till_now = 0;
		if (!adj[curr].empty())
		for(int vertex : adj[curr]) {
			if (!visited[vertex]) {
				dfs(adj, vertex, dp, visited);
			}
			max_till_now = max(max_till_now, dp[vertex]);
		}
		dp[curr] = max_till_now + 1;
	}
}

int solve(int n, int m, vector<int> &x, vector<int> &y) {
	vector<vector<int>> adj(n);
	for (int i = 0; i < m; ++i)
	{
		adj[x[i]].push_back(y[i]);
	}
	vector<int> dp(n,0), visited(n,0);
	for (int i = 0; i < n; ++i)
	{
		if (!visited[i]) {
			dfs(adj, i, dp, visited);
		}
	}
	int result = 0;
	for (int len : dp)
	{
		result = max(result, len);
	}
	return result-1;
}

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

Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;

void input() {
  int x, y, z;
  ;
  cin >> N >> M;
}
void solve() {
  set<int> A = {1, 3, 5, 7, 8, 10, 12};
  set<int> B = {4, 6, 9, 11};
  set<int> C = {2};

  if ((A.find(N) != A.end() && A.find(M) != A.end()) ||
      (B.find(N) != B.end() && B.find(M) != B.end()) ||
      (C.find(N) != C.end() && C.find(M) != C.end())) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n], sum = 0;
    for(int i = 0; i < n; i++)  cin >> a[i], sum += a[i];
    double d = sum/4.0/m;
    int ch = 0;
    for(int i = 0; i < n; i++)  ch += a[i] >= d;
    cout << (ch >= m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3568
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll a = inp1;
    ll b = inp1;
    ll c = inp1;
    cout << Yes(a==b&&a!=c||b==c&&b!=a||c==a&&c!=b) << endl;
    
}

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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[2001][2001];
ll check(vector<pair<ll,ll> >v,ll l,ll r,ll i)
{ 
   //cout<<l<<" "<<r<<endl;
   if(l>r)
    return 0; 
   if(dp[l][r]!=-1)
    return dp[l][r]; 
   ll ans=0;
   ll p1=v[i].first;
   ll p2=v[i].second;
   ans=max(p1*(p2-l)+check(v,l+1,r,i+1),p1*(r-p2)+check(v,l,r-1,i+1));
   return dp[l][r]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
      ll n,a,b;
      cin>>n>>a>>b;
      ll p=n/(a+b);
      ll ans=a*p;
      ans+=min(n%(a+b),a);
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 3632
#include <stdlib.h>
#include <stdio.h>
int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int main(void){
    
    int num,i;
    int a[1000000];
    int hantei = 0;
    
    scanf("%d",&num);
    
    for(i=0; i<num; i++){
        scanf("%d",&a[i]);
    }
    
    qsort(a,num,sizeof(int),cmp);
    for(i=0; i<num; i++){
         if(a[i]==a[i+1]){
            hantei = 1;
        }
    }


    if(hantei == 1){
        printf("NO");
    }else if(hantei == 0){
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
int main()
{
ll n,a,b,c,d;
cin>>n>>c>>d;
a=min(c,d);
b=max(c,d);
//cout<<a<<b;
if((b-a)%2==0)
    cout<<(b-a)/2;
else
{
    ll x=min(a-1,n-b);
    x++;
    x+=(b-a)/2;
    cout<<x;
}
return 0;
}


Measured memory_bytes: 256