akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  vector<int> A(N);
  rep(i, N) {
    A[i] = S[i] - '0';
  }

  if (P == 2 || P == 5) {
    int ans = 0;
    rep(i, N) {
      if (A[i] % P == 0)
        ans += (i + 1);
    }
    cout << ans << endl;
    return 0;
  }

  vector<int> sum(N + 1);

  reverse(all(A));

  int ten = 1;
  rep(i, N) {
    sum[i + 1] = sum[i] + A[i] * ten;
    sum[i + 1] %= P;
    ten *= 10;
    ten %= P;
  }

  vector<int> cnt(10001);
  rep(i, N + 1) {
    cnt[sum[i]]++;
  }

  int ans = 0;
  rep(i, 10001) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3732
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int mod = 1000000007;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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()
int n;
ll a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    if (n == 1)
    {
        if (a[0] == 1)
        {
            cout << 0 << "\n";
            return 0;
        }
        else
        {
            cout << 1 << "\n";
            return 0;
        }
    }
    int ans = 0;
    int countd = 1;
    int temp = a[0];
    for (int i = 1; i < n; i++)
    {

        if (temp == a[i])
        {
            countd++;
        }
        else
        {
            if (countd == temp)
            {
            }
            else if (countd > temp)
            {
                ans += countd - temp;
            }
            else
            {
                ans += countd;
            }
            temp = a[i];
            countd = 1;
        }
        if (i == n - 1)
        {
            if (countd == temp)
            {
            }
            else if (countd > temp)
            {
                ans += countd - temp;
            }
            else
            {
                ans += countd;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;
const double EPS = 1e-10;
const double PI = acos(-1.0);



const int n = 151;
vector<vector<int>> a(n, vector<int>(n));

void init(){
	for(int i=1;i<n;++i) for(int j=i+1;j<n;++j){
		a[i][j] = i * i + j * j;
	}
}

bool solve(){
	int h, w;
	cin>> h>> w;
	if(!h && !w) return false;

	int x = h * h + w * w;
	pii ans(n, n);
	for(int i=1;i<n;++i){
		for(int j=i+1;j<n;++j){
			int y = i * i + j * j;
			if((i <= h && y == x) || y < x) continue;
			if(y < ans.first * ans.first + ans.second * ans.second){
				ans = pii(i, j);
			}
		}
	}
	cout<< ans.first<< " "<< ans.second<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	init();
	while(solve());
	return 0;
}

Measured memory_bytes: 1308
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a < b:
        a, b = b, a
    ans = a
    a -= 1
    ans += max(a, b)
    print(ans)
    return

#B
def B():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    ans = 0
    for i in range(n):
        dp[i] = max(dp[i - 1], h[i])
        if dp[i - 1] <= h[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    s = S()
    ans = 0
    for num, i in enumerate(s):
        if num % 2:
            if i == "0":
                ans += 1
        else:
            if i == "1":
                ans += 1
    ansb = 0
    for num, i in enumerate(s):
        if not num % 2:
            if i == "0":
                ansb += 1
        else:
            if i == "1":
                ansb += 1
    print(min(ans, ansb))
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 49776
import std.stdio, std.string, std.conv;

struct Point {
    double x, y;
}

void koch(int n, Point a, Point b) {
    import std.math;
    if (n == 0) return;
    double th = PI * 60.0 / 180.0;
    Point s = Point((2.0 * a.x + 1.0 * b.x) / 3.0, (2.0 * a.y + 1.0 * b.y) / 3.0);
    Point t = Point((1.0 * a.x + 2.0 * b.x) / 3.0, (1.0 * a.y + 2.0 * b.y) / 3.0);
    Point u = Point((t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x, (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y);
    koch(n-1, a, s);
    writefln("%.8f %.8f", s.x, s.y);
    koch(n-1, s, u);
    writefln("%.8f %.8f", u.x, u.y);
    koch(n-1, u, t);
    writefln("%.8f %.8f", t.x, t.y);
    koch(n-1, t, b);
}

void main() {
    int n = readln.chomp.to!int;
    Point a = Point(0.0, 0.0);
    Point b = Point(100.0, 0);
    writefln("%.8f %.8f", a.x, a.y);
    koch(n, a, b);
    writefln("%.8f %.8f", b.x, b.y);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    cout << (d <= t * s ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int64_t> vec(4);
	for (int i = 0; i < 4; i++) {
  cin >> vec.at(i);
	}
  
  int64_t ans;
  ans = vec.at(0)*vec.at(2);
  
  for (int i =0;i<2;i++){
  
    if(vec.at(i) * vec.at(2) > ans)ans=vec.at(i)*vec.at(2);
        if(vec.at(i) * vec.at(3) > ans)ans=vec.at(i)*vec.at(3);
    
  }
  cout << ans << endl;
}

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

int meguru_binary_search (int n, int ok, int ng);

int main () {

    int N;
    scanf("%d", &N);

    int a[N];

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

    int ans = 0;

    for (int i = 0; i < N; i++) {
        ans += meguru_binary_search(a[i], 0, 40);
    }

    cout << ans << endl;

    return 0;
}

int meguru_binary_search (int n, int ok, int ng) {

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng)/2;

        if (n % (int)pow(2, mid) == 0) ok = mid;
        else ng = mid;
    }

    return ok;
}

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

int main(){

  int a,b;
  cin >> a >> b;
  int ans=0;
  if(a<=b){
    ans+=b;
    b--;
  }
  else{
    ans+=a;
    a--;
  }

  if(a<=b){
    ans+=b;
    b--;
  }
  else{
    ans+=a;
    a--;
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 256
//Written by:Poushi
//Dept_CSE of IUT
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define fixedprecision(n) cout<<fixed<<setprecision(n)
#define frf(i,a,n) for(i=a;i<n;i++)
#define frb(i,b,n) for(i=b;i>n;i--)

int main()
{
    int n,t,i,j;
    set<int> st;
    set<int>::iterator it;
    cin>>t;
    while(t--)
    {
       cin>>n;
       it=st.find(n);
       if(it==st.end())
       {
           st.insert(n);
       }
       else
        st.erase(it);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 8212
#include <stdio.h>

int a, b, c, d, e, f;

int main()
{
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &f);
    
    printf("%d\n", a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000 ? 1 : 0);
    
    return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int x;
    cin >> x;

    vi dp(100100, 0);
    dp[0] = 1;
    for (int i = 1; i <= x; i++) {
        for (int j = 100; j <= 105; j++) {
            if (i - j >= 0 and dp[i - j] > 0) dp[i] = 1;
        }
    }

    cout << dp[x] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

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 MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<pll>vec(n);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    vec[i]=pii(-a,b);
  }
  sort(vec.begin(),vec.end());
  
  ll ans = -vec[0].fi+vec[0].se;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
using namespace std;
# define M_PI  3.14159265358979323846
float area(int radius) {
   return 2* M_PI *radius;
}

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    
    int t=1;
    while(t--)
    {
      
      int r;
      cin>>r;
      cout<<area(r)<<endl;


      fflush(stdout);
    }

return 0;

}

Measured memory_bytes: 3796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            var sb = new StringBuilder();
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                    sb.Append(s[i]);
            }
            WriteLine(sb.ToString());
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>

int main(void) {
    int N, i;
    double xa, ya, ra, xb, yb, rb, d;

    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%lf%lf%lf%lf%lf%lf",
              &xa, &ya, &ra, &xb, &yb, &rb);
        d = hypot(xb - xa, yb - ya);
        if (d > ra + rb) {
            puts("0");
        }
        else if (d + rb < ra) {
            puts("2");
        }
        else if (d + ra < rb) {
            puts("-2");
        }
        else {
            puts("1");
        }
    }
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
 

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c <= 0) {
      cout <<"Yes";
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout <<"No";
      return 0;
    }

  }
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 2 * (1e5 + 1);
const int INF = 1e9 + 5;
const long long MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int n;
    string s;
    cin >> n >> s;
    int x = 0, b = 0;
    for (int i = 0; i < n; i++) {
        s[i] == 'I' ? x++ : x--;
        b = max(b, x);
    }
    cout << b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
 //     freopen("q.gir","r",stdin);
 //     freopen("q.cik","w",stdout);
      int n;
      int w;
      cin>>n>>w;
      vector<vector<int> >dp(n+1,vector<int>(w+1,0));
      vector<ii>arr(n+1);
      for(int i=1;i<=n;i++)cin>>arr[i].first>>arr[i].second;
      for(int i=1;i<=n;i++){
            for(int j=0;j<arr[i].first;j++)dp[i][j]=dp[i-1][j];
            for(int j=arr[i].first;j<=w;j++){
                  dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i].first]+arr[i].second);
            }
      }
      int ans=0;
      for(int i=0;i<=w;i++)ans=max(ans,dp[n][i]);
      cout<<ans;
}


Measured memory_bytes: 80256
/* ex 6-2
    kas056 */

#include <stdio.h>
#include <string.h>//strlenを使えるようにする

#define SIZE 1000

int main(void){
    int mid; //間の数は入力した文字の長さ－2
    char omission[SIZE];

    scanf("%s", omission);
    int length = strlen(omission);//入力の読込後、長さ測定

    mid = length - 2;//midの大きさは(長さ-2)

    if(mid < 1){//midが0以下ならエラー
        fprintf(stderr, "unexpected characters: %s", omission);
    }

    else{//ヌル文字でない最後の文字は、omission[length - 1]に入っている。
        printf("%c%d%c\n",omission[0], mid, omission[length - 1]);
        
    }

    return 0;

}

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

int main(){
    int N, M;
    cin >> N >> M;
    int a[N];
    int sum = 0;
    for(int i =0; i < N; i++){
        cin >> a[i];
        sum += a[i];
    }

    sort(a, a + N, greater<int>());
    if(a[M - 1]* 4*M >= sum) cout <<"Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N=int(input())
a_list=list(map(int,input().split()))

count = defaultdict(int)

for a in a_list:
    if a > 0:
        count[a-1] += 1
    count[a] += 1
    count[a+1] += 1

print(max(count.values()))

Measured memory_bytes: 62636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int k = scanner.nextInt();

		if((n % k) == 0) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}


		scanner.close();
	}

}


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

int main() {
  double a,b,h,m;
  cin >> a >> b >> h >> m;

  cout << fixed << setprecision(10);

  double pi = 3.14159265358979;

  double aa = 30*h + m / 2;
  double bb = 6* m;

  if (aa >= bb) {
    double kakudo = aa - bb;
    cout << sqrt(a*a + b*b - 2*a*b*cos(kakudo*pi/180));
  }
  else {
    double kakudo = bb - aa;
    cout << sqrt(a*a + b*b - 2*a*b*cos(kakudo*pi/180));
  }

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
using ll = long long;
using Vll = vector<ll>;
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }


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

  ll m = n/2;
  ll k = (n%2) ? 3 : 2;

  Vll dp(k);
  rep(i, m) drep(j, k) dp[j] = *max_element(dp.begin(), dp.begin()+j+1) + a[2*i+j];

  cout << *max_element(dp.begin(), dp.end()) << endl;
  return 0;
}


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

namespace AtCoder.AISing
{
    class A
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var l = input[0];
            var r = input[1];
            var d = input[2];
            Console.WriteLine(r / d - (l - 1) / d);
        }
    }
}


Measured memory_bytes: 28292
N = int(input())
a1 = list(input())
a2 = list(input())
t, i = 0, 0
x = 1

while (i < len(a1) - 1):
	if(t == 0):
		if(a1[i] == a1[i + 1]):
			x = x*6
			t = 1
			i += 2
		
		else:
			x = x*3
			t = 2
			i += 1

			if(i == len(a1) - 1):
				x = x*2

		continue

	if(t == 1):
		if(a1[i] == a1[i + 1]):
			x = x*3
			t = 1
			i += 2

		else:
			x = x*1
			t = 2
			i += 1

			if(i == len(a1) - 1):
				x = x*2


		continue

	if(t == 2):
		if(a1[i] == a1[i + 1]):
			x = x*2
			t = 1
			i += 2

		else:
			x = x*2
			t = 2
			i += 1

			if(i == len(a1) - 1):
				x = x*2

		continue


if(len(a1) == 1):
	print(3)

else:
	print(x % 1000000007)

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

long long n, a[100005], l1, l2, rec=1;
vector<long long> post;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);
    int num=a[n-1], cnt=0;
    for(int i=n-1; i>=0; i--) {
        if(a[i]==num) {
            cnt++;
        } else {
            num = a[i];
            cnt = 1;
        }
        if(cnt>=2) {
            post.push_back(a[i]);
        }
    }
    sort(post.begin(), post.end());
    if(post.size()) l1 = post[post.size()-1];
    for(int i=post.size()-1; i>=0; i--) {
        if(post[i]!=l1) {
            l2 = post[i];
            break;
        } else rec++;
    }
    if(rec>=4) cout << (long long) l1*l1<<endl;
    else cout << (long long)l1*l2 << endl;

    return 0;
}


Measured memory_bytes: 2168
<?php

$n = trim(fgets(STDIN));
$x = explode(" ", trim(fgets(STDIN)));
$y = explode(" ", trim(fgets(STDIN)));

for($i=0; $i<count($x); $i++){
    $array1[$i] = abs($x[$i] - $y[$i]);
    $array2[$i] = abs($x[$i] - $y[$i])**2;
    $array3[$i] = abs($x[$i] - $y[$i])**3;
    $mugen[$i] = abs($x[$i] - $y[$i]);
}
// var_dump($array1);
echo array_sum($array1),PHP_EOL;
echo sqrt(array_sum($array2)),PHP_EOL;
echo pow(array_sum($array3), 1/3),PHP_EOL;
echo max($mugen);


Measured memory_bytes: 9376
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int N, M;
	while (cin >> N >> M, N || M)
	{
		vector<P> data(N);
		for (int i = 0; i < N; ++i)
		{
			cin >> data[i].second >> data[i].first;
		}
		sort(data.begin(), data.end(), greater<P>());
		for (int i = 0; i < N; ++i)
		{
			if (M >= data[i].second)
			{
				M -= data[i].second;
				data[i].second = 0;
			}
			else
			{
				data[i].second -= M;
				M = 0;
				break;
			}
		}
		int sum = 0;
		for (int i = 0; i < N; ++i)
		{
			sum += data[i].first * data[i].second;
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iterator>

int main()
{
  int N, M;
  std::cin >> N >> M;

  std::vector<std::pair<int, long long>> PY(M);
  std::vector<std::vector<long long>> C(N);

  for (int i = 0; i < M; i++) {
    std::cin >> PY[i].first;
    std::cin >> PY[i].second;
    C[PY[i].first - 1].push_back(PY[i].second);
  }

  for (int i = 0; i < N; i++) {
    std::sort(std::begin(C[i]), std::end(C[i]));
  }

  for (int i = 0; i < M; i++)
  {
    auto & v = C[PY[i].first - 1]; // PY[i].firstが県番号
    auto c = std::lower_bound(std::begin(v), std::end(v), PY[i].second);
    printf("%06d%06d\n", PY[i].first, std::distance(std::begin(v), c)+1);
  }

  return 0;
}

Measured memory_bytes: 8576
n = int(input())

mark = ["S", "H", "C", "D"]
number = [1,2,3,4,5,6,7,8,9,10,11,12,13]
pair = []

for i in mark:
    for j in number:
        pair.append(i+str(j))

for i in range(n):
    a,b = input().split()
    pair.remove(a+b)
    
for ans in pair:
    print(ans[0] + " " + ans[1:])


Measured memory_bytes: 5596
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1



int main(void) {
	int n, m; cin >> n >> m;
	vint p(n);
	int ans=0, pe=0;
	rep(i, m) {
		int x; cin >> x; x--;
		string y; cin >> y;
		if (y == "WA") {
			if (p[x] == -1) {
				continue;
			}
			p[x]++;
		}
		else {
			if (p[x] == -1) {
				continue;
			}
			pe += p[x];
			ans++;
			p[x] = -1;
		}

	}
	cout << ans << ' ' << pe << endl;
	return 0;
}

Measured memory_bytes: 640
def main():
    x, k, d = map(int, input().split())
    if x >=0 and abs(x) >= k *d:
        print(x - k*d)
    elif x < 0 and abs(x) >= k *d:
        print(abs(x) - k*d)
    else:
        x = abs(x)
        t = x // d
        k -= t
        x -= t*d
        print(abs(x - (k%2)*d))

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
using System;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var sp = Console.ReadLine().Split(' ');
            var x = int.Parse(sp[0]);
            var y = int.Parse(sp[1]);

            if (y % 2 != 0 || y / 2 < x || (y+3) / 4 > x)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27532
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return 0;
}



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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	string s;cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int cmp(char a,char b){
	return a>b;
}
int main(){
	string a,b;
//	while(1){
		cin >> a >> b;
		sort(a.begin(),a.end());
		sort(b.begin(),b.end(),cmp);
//		cout << a << ',' << b;
		if(a<b){
			cout << "Yes";
		}else{
			cout << "No";
		}
//	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    string S;
    cin>>S;
    S[3]='8';
    cout<<S<<endl;
    return 0;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  int n, d, x;
  scanf("%d%d%d", &n, &d, &x);
  int res = x;
  REP(i, n) {
    int a;
    scanf("%d", &a);
    for(int j = 1; j <= d; j += a) {
      ++res;
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    string s;
    cin >> a >> s;
    cout << (a < 3200?"red":s) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=2020202021;
  ll sm=0;
  ll sm2=0;
  cin >> n ;
  vi a(n);
  REP(i,n){
    cin>>a[i];
    sm+=a[i];
  }
  
  REP(i,n){
    sm2+=a[i];
    ans=min(abs(sm-sm2*2),ans);
  }

  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
import collections
import numpy as np
import sys
import copy
N=int(input())
#W,H,X,Y=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A)
s=B[N//2-1]
b=B[N//2]
for i in range(N):
    if A[i]<=s:
        print(b)
    else:
        print(s)


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

int main()
{
    ll l;
    cin >> l;
    double a = 0.0;
    double b = 0.0;
    double c = 0.0;

    if (l % 3 == 0)
    {
        a = l / 3;
        b = a;
        c = a;
        printf("%.12f\n", a * b * c);
        return 0;
    }
    if (l % 3 == 1)
    {
        l--;
        a = l / 3;
        a += 0.3333333333;
        b = a;
        c = l / 3;
        c += 0.3333333334;

        printf("%.12f\n", a * b * c);
        return 0;
    }
    if (l % 3 == 2)
    {
        l--;
        l--;
        a = l / 3;
        a += 0.6666666667;
        b = a;
        c = l / 3;
        c += 0.6666666666;

        printf("%.12f\n", a * b * c);
        return 0;
    }

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<int> X, Y;
  for (int i = 0; i < 30 + 1; i++) {
    for (int j = 0; j < 30 + 1; j++) {
      if (i == 0 && j == 0) continue;
      X.emplace_back(100 * A * i + 100 * B * j);
    }
  }
  for (int i = 0; i < 100 + 1; i++) {
    for (int j = 0; j < 100 + 1; j++) {
      Y.emplace_back(C * i + D * j);
    }
  }
  int a = -1, b = 0;
  for (int x : X) {
    for (int y : Y) {
      if (x + y <= F && y <= x * E / 100) {
        if ((double)y / (x + y) > (double)a / b) {
          a = y, b = x + y;
        }
      }
    }
  }
  cout << b << ' ' << a << '\n';
  return 0;
}


Measured memory_bytes: 508
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s, t;
    cin >> s >> t;
    int n = SZ(s);

    vector<int> pos(26, -1);
    for(int i = n - 1; i >= 0; i--){
        pos[s[i]-'a'] = i;
    }

    auto nxt = initVec2<int>(n, 26, -1);
    for(int i = n - 1; i >= 0; i--){
        rep(j, 26){
            nxt[i][j] = pos[j];
        }
        pos[s[i]-'a'] = i;
    }

    vector<int> ans;
    ans.push_back(pos[t[0]-'a']);
    int i = 1;
    while(i < SZ(t) && ans.back() != -1){
        ans.push_back(nxt[ans.back()][t[i++]-'a']);
    }

    if(ans.back() == -1){
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    rep(i, SZ(ans) - 1){
        if(ans[i] >= ans[i+1]){
            cnt++;
        }
    }
    cout << n * cnt + ans.back() + 1 << endl;

    return 0;
}


Measured memory_bytes: 25848
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        char[] ary = scn.nextLine().toCharArray();
        StringBuilder sb = new StringBuilder();
        for(char elm : ary) {
            if(Character.isLowerCase(elm)) {
                 sb.append(Character.toUpperCase(elm));
            } else {
                 sb.append(Character.toLowerCase(elm));
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 26108
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
 
    ll n, k;
    cin >> n >> k;

    ll num;

    ll test = n / k;

    if(test > 0) n -= test * k;

    while(1){
        num = min(abs(n - k), n);
        if(num == n) break;
        else n = num;
    }

    cout << n;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <math.h>
#include <unordered_set>
using namespace std;

#define endl "\n"
#define pb push_back
#define INF INT_MAX/10
typedef long long ll;
typedef pair<ll,ll> PII;
typedef long long ll;



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;
    cin >> n >> m;

    // Represent m in n no.s

    int q = m/n;
    int r = m%n;

    for ( int i = q ; i >= 1 ; i-- )
    			if ( m%i == 0 ){
    				cout << i << endl;
    				return 0;
    			}
    /*

    if ( q % 2 == 0 ){

    	if ( r % 2 == 0 ){

    		for ( int i = q ; i >= 1 ; i-- )
    			if ( m%i == 0 ){
    				cout << i << endl;
    				return 0;
    			}

    	}
    	else cout << 1 << endl;
    }
    else {

    	if ( r%2 == 0 ){

    		if ( n%2 == 0 ){
    			for ( int i = q ; i >= 1 ; i-- )
    				if ( m%i == 0 ){
    				cout << i << endl;
    				return 0;
    			}
    		}
    		else cout << 1 << endl;
    	}
    	else{
    		if ( n%2 == 0 ){
    			for ( int i = q ; i >= 1 ; i-- )
    				if ( m%i == 0 ){
    				cout << i << endl;
    				return 0;
    			}
    		}
    		else{
    			for ( int i = q ; i >= 1 ; i-- )
    				if ( m%i == 0 ){
    				cout << i << endl;
    				return 0;
    			}
    		}
    	}

    }*/



    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 200005;
vector<int> a(n);
vector<vector<int>> tree(n,vector<int>());

struct SegmentTree{
        int n;
        vector<ll> node;
        
        SegmentTree(vector<ll> v){
                int sz = v.size();
                n = 1;
                while(n < sz) n *= 2;
                node.resize(2*n-1,0);
                for(int i=0;i<sz;i++) node[i+n-1] = v[i];
                for(int i=n-2;i>=0;i--) node[i] = max(node[2*i+1],node[2*i+2]);
        }
        
        void update(int x,ll val){
                x += n-1;
                node[x] = val;
                while(x > 0){
                        x = (x-1)/2;
                        node[x] = max(node[2*x+1],node[2*x+2]);
                }
        }
        
        ll getmax(int a,int b,int k=0,int l=0,int r=-1){
                if(r < 0) r = n;
                if(r <= a || b <= l) return 0;
                if(a <= l && r <= b) return node[k];
                ll vl = getmax(a,b,2*k+1,l,(l+r)/2);
                ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
                return max(vl,vr);
        }

        ll& operator [](int i){ return node[i+n-1];}
};

vector<ll> ans(n);
vector<ll> t(n,0);
SegmentTree dp(t);

void dfs(int i,int p=-1){
    ll before = dp[a[i]];
    dp.update(a[i], dp.getmax(0,a[i]) + 1);
    ans[i] = dp.getmax(0,dp.n+1);
    for(int c:tree[i]){
        if(c==p) continue;
        dfs(c,i);
    }
    dp.update(a[i],before);
    return;
}

int main(){
    cin >> n;
    vector<pll> temp(n);
    rep(i,n){
        cin >> temp[i].first;
        temp[i].second = i;
    }
    sort(temp.begin(),temp.end());
    int j = 1;
    rep(i,n){
        a[temp[i].second] = j;
        if(i<n-1){
            if(temp[i].first == temp[i+1].first);
            else ++j;
        }
    }
    
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        --u;--v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    dfs(0);
    
    rep(i,n){
        cout << ans[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 50996
/****************
 *		*
 * ALDS_1_6_C	*
 * QuickSort	*
 *		*
 * 2019/08/26	*
 *		*
 ****************/

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

#define	MAX_ARRAY	100000
#define MAX_LIMIT 	1000000001


typedef struct{
  char type;
  int value;
}Card;

Card A[MAX_ARRAY];
Card B[MAX_ARRAY];

void merge(int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  Card Left[MAX_ARRAY/2+1];
  Card Right[MAX_ARRAY/2+1];
  
  for(i=0;i<n1;i++) Left[i] = B[left + i];
  Left[n1].value = MAX_LIMIT;
  for(j=0;j<n2;j++) Right[j] = B[mid + j];
  Right[n2].value = MAX_LIMIT;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(Left[i].value <= Right[j].value){
      B[k] = Left[i];
      i++;
    }
    else {
      B[k] = Right[j];
      j++;
    }
  }
}

void mergeSort(int left,int right){
  if((left + 1) < right){
    int mid = (left + right)/2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }

  return;
  
}


void swap(int i,int j){
  Card temp = A[i];
  A[i] = A[j];
  A[j] = temp;

  return;
}

int partition(int p,int r){
  Card x = A[r];
  int i = p-1;

  for(int j=p;j<r;j++){
    if(A[j].value <= x.value){
      i++;
      swap(i,j);
    }
  }
  swap(i+1,r);

  return i+1;
  
}

void quickSort(int p,int r){
  if(p < r){
    int q = partition(p,r);
    quickSort(p,q-1);
    quickSort(q+1,r);
  }
}

int main(void){
  int n=0;
  char input_sentence[10];
  int input_value = 0;
  bool stable=true;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s %d",input_sentence,&input_value);
    A[i].type = input_sentence[0];
    B[i].type = input_sentence[0];
    A[i].value = input_value;
    B[i].value = input_value;
  }
  
  quickSort(0,n-1);
  mergeSort(0,n);

  for(int i=0;i<n && stable == true;i++){
    if(A[i].type != B[i].type) stable = false;
  }


  if(stable)
    printf("Stable\n");
  else
    printf("Not stable\n");
  
  for(int i=0;i<n;i++){
    printf("%c %d\n",
	   A[i].type,A[i].value);
  }
  
  return 0;
}



Measured memory_bytes: 5468
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int a[200005],sum[200005]={0};
bool cmp(int x,int y){
	return x>y;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum[a[i]]++;
	}
	sort(sum,sum+200005,cmp);
	int ans=0;
	for(int i=k;sum[i]!=0;i++){
        ans+=sum[i];
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            int count = 0;
            int prev = cin.ReadInt;
            for (int i = 1; i < n; i++)
            {
                var x = cin.ReadInt;
                if (prev > x)
                {
                    count += prev - x;
                }
                prev = x;
            }

            count += prev;
            Console.WriteLine(count);

            return;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 13268
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,t;
	int d[20][20];
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		rep(i,n){
			t=0;
			rep(j,n){
				scanf("%d",d[i]+j);
				t+=d[i][j];
			}
			d[i][n]=t;
		}
		rep(i,n+1){
			t=0;
			rep(j,n)t+=d[j][i];
			d[n][i]=t;
		}
		rep(i,n+1){rep(j,n+1)printf("%5d",d[i][j]);puts("");}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(k,nu)    for(int i=k; i<nu;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);

int main(){
    double r; cin >> r;
    printf("%10f",2*r*PI);
    return 0;
}
/*

*/


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    double a,b,c,s,l,h,pi = 3.141592653589793;
    cin>>a>>b>>c;
    s=0.5*a*b*sin(pi*(c/180));
    l=sqrt(a*a+b*b-2*a*b*cos(pi*(c/180)))+a+b;
    h=s*2/a;
    cout<<setprecision(30)<<s<<endl<<l<<endl<<h<<endl;
    return 0;
}



Measured memory_bytes: 3592