akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace abc170_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = CIn.ReadInt();
      var N = CIn.ReadInt();
      var p = new HashSet<int>(CIn.ReadIntArray(N));

      for (int i = 0; i < 200; i++)
      {
        if (!p.Contains(X - i))
        {
          Console.WriteLine(X - i);
          return;
        }
        if (!p.Contains(X + i))
        {
          Console.WriteLine(X + i);
          return;
        }
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/
bool isPrime(int n){
	for(int i=2;i*i<=n;i++){
		if(!(n%i))return false;
	}
	return true;
}
int main(){
	FIO
	
	// using legendre formula
	int n;cin>>n;
	vi primes;
	rep(i,2,1001){
		if(isPrime(i))primes.pb(i);
	}
	// find largest prime power
	ll ans=1;
	rep(i,0,SZ(primes)){
		int p=primes[i];
		int x=0,tn=n;
		while(tn){
			tn/=p;
			x+=tn;
		}
		ans=(ans%mod*(x+1)%mod)%mod;
	}
	cout<<ans;
	return 0;
}


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

int main(){
  string S,T;
  cin >> S >> T;
  int flag=0;
  if(T.size()-S.size() != 1) flag=1;
  for(int i=0; i<S.size(); i++){
    if(S[i] != T[i]) flag=1;
  }
  if(flag) cout << "No";
  else cout << "Yes";
  return 0;
}

Measured memory_bytes: 3596
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string base("CODEFESTIVAL2016");
	string S;
	cin >> S;
	int ans = 0;
	for (int n = 0; n < S.size(); n++) {
		if (base[n] != S[n])ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3164
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))
#pragma comment(linker, "/STACK:102400000,102400000")

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
#define Endl endl
#define int long long

//#define Local

using namespace std;


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

	//freopen("input1.txt","r",stdin);
	//freopen("output1.txt","w",stdout);

	int n;
	cin>>n;
	vector<int> all;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin>>tmp;
		all.push_back(tmp);
	}
	sort(all.begin(),all.end());
	int ma=all[all.size()-1];
	int res=0;
	for(int i=0;i<n;i++)
	{
		if(abs((ma+1)/2-all[i])<abs((ma+1)/2-res))
			res=all[i];

	}
	cout<<ma<<" "<<res<<endl;


	#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    ll ans_min = INFINITY;
    for (ll i = 1; i <= sqrt(n); ++i) {
        ll ans;
        ll j = n / i;
        if(i * j == n){
            ans = i + j - 2;
            ans_min = min(ans,ans_min);
        }
    }
    print(ans_min);
}


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

const ll INF = 1e18;
const int MX = 2005;
ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n+1)rep(j,n+1) dp[i][j] = -INF;
  dp[0][0] = 0;
  vector<P> p;
  rep(i,n) p.emplace_back(a[i],i);
  sort(p.rbegin(), p.rend());
  rep(i,n) {
    int pi = p[i].second;
    rep(l,i+1) {
      int r = i-l;
      chmax(dp[i+1][l+1], dp[i][l]+ll(pi-l)*a[pi]);
      chmax(dp[i+1][l], dp[i][l]+ll((n-r-1)-pi)*a[pi]);
    }
  }
  ll ans = 0;
  rep(i,n+1) chmax(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var k = int.Parse(ReadLine());
		var a = ReadLine().Split().Select(int.Parse).ToArray();
		var sum = 0;
		for(int i = 0; i < n; i++)
		{
			sum += Min(a[i], k - a[i]);
		}
		WriteLine(sum * 2);
	}
}


Measured memory_bytes: 19124
import java.util.Scanner;

class MyInteger {
    int value;

    MyInteger(int value){ //?????????????????????
        this.value = new Integer(value);
    }

    Integer getValue(){
        return value;
    }
}

class Main {
    static void swap(MyInteger a, MyInteger b){
        int tmp = a.value;

        a.value = b.value;
        b.value = tmp;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        MyInteger a = new MyInteger(Integer.parseInt(scan.next()));
        MyInteger b = new MyInteger(Integer.parseInt(scan.next()));
        MyInteger c = new MyInteger(Integer.parseInt(scan.next()));

        if (a.value > b.value)
            swap(a, b);
        if (b.value > c.value)
            swap(b, c);
        if (a.value > b.value)
            swap(a, b);
        
        System.out.println(a.value+ " " +b.value + " "+ c.value);
    }
}

Measured memory_bytes: 26148
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
	a = input()
	if   a[0] == '0':
		if a[2] == '0': Q.appendleft(a[4:])
		else          : Q.append(a[4:])
	elif a[0] == '1': print(Q[int(a[2:])])
	else:
		if a[2] == '0': Q.popleft()
		else:           Q.pop()


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

#素因数分解
def factorize_dict(n):
    b = 2
    fct = dict()
    while b * b <= n:
        while n % b == 0:
            n //= b
            #fct.append(b)
            if b not in fct:
                fct[b] = 1
            else:
                fct[b] += 1
        b = b + 1
    if n > 1:
        #fct.append(n)
        if n not in fct:
            fct[n] = 1
        else:
            fct[n] += 1
            
    return fct

factorized_N = factorize_dict(N)
#print(factorized_N)

z_list = []

for f_dict in factorized_N.items():
    prime_number = f_dict[0]
    how_many = f_dict[1]
    z_list += [prime_number**i for i in range(1,how_many+1)]
    
z_list.sort(reverse=False)
#print(z_list)

ans = 0
for z in z_list:
    if N%z == 0:
        ans += 1
        N /= z
        if N == 1:
            break
        
print(ans)    

Measured memory_bytes: 9288
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int m1 = Integer.parseInt(sc.next());
        int d1 = Integer.parseInt(sc.next());
        int m2 = Integer.parseInt(sc.next());
        int d2 = Integer.parseInt(sc.next());
        
        if(m1 == m2){
            System.out.println("0");
        }else{
            System.out.println("1");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n;
    string s;
    cin >> n >> s;
    map<char,int> mp;
    for(int i = 0; i < n; i++) mp[s[i]]++;

    ll ans = 1;

    for(auto p:mp){
        ans *= p.second+1;
        ans %= mod;
    }

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

Measured memory_bytes: 3760
#include<stdio.h>
int main(void){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
x=int(input())
s=list(map(int,input().split()))

res=0
sm=0

cur=s[0]

for n in range(1,x):
    if s[n]<=cur:
        cur=s[n]
        sm+=1
    else:
        cur=s[n]
        res=max(res,sm)
        sm=0
res=max(res,sm)
print(res)

Measured memory_bytes: 20296
#include <cstdio>
#ifdef _MSC_VER
#include <conio.h>
#else
#define getch()
#endif

int main(){
	int A=0;
	int B=0;
	scanf(" %d %d",&A,&B);
	printf("%d\n",A+B<24?A+B:A+B-24);
	getch();
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int partition(pair<int,char> *A, int p, int r){
    int x=A[r].first;
    int i=p-1;
    for(int j=p;j<r;j++){
        if(A[j].first<=x){
            i++;
            auto tmp=A[i];
            A[i]=A[j];
            A[j]=tmp;
        }
    }
    auto tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;

    return i+1;
}

void quick_sort(pair<int,char> *A, int p, int r){
    if(p<r){
        int q = partition(A, p , r);
        quick_sort(A, p, q-1);
        quick_sort(A, q+1, r);
    }
}

int main(){
    unordered_map<int, queue<char>> suit;
    int n;
    pair<int,char> A[100000];
    cin >> n;
    for(int i=0;i<n;i++){
        char s;
        int  num;
        cin >> s >> num;
        A[i]=make_pair(num, s);
        suit[num].push(s);
    }

    quick_sort(A, 0, n-1);
    for(int i=0;i<n;i++){
        if(A[i].second!=suit[A[i].first].front()){
            cout << "Not stable" << endl;
            break;
        }
        suit[A[i].first].pop();
        if(i==n-1) cout << "Stable" << endl;
    }
    for(int i=0;i<n;i++) cout << A[i].second << ' ' << A[i].first << endl;
    
    return 0;
}


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

bool ball(vector<int> &a,int b,int c,int n){
    //cout<<n<<" "<<b<<" "<<c<<endl;
    if(n==10){
        return true;
    }
    if(a[n]>b&&n<=9){
        b=a[n];
        return ball(a,b,c,n+1);
    }
    if(a[n]>c&&n<=9){
        c=a[n];
        return ball(a,b,c,n+1);
    }
    return false;
}


int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        vector<int> a;
        int b=0;
        int c=0;
        for(int j=0;j<10;j++){
            cin>>tmp;
            a.push_back(tmp);
        }
        if(ball(a,b,c,0)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
}

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

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"yes":"no");
}
int main() {
  ll a;
  double b;
  cin>>a>>b;
  b*=100.0;
  ll c=llround(b);
  ll ans=a*c/100;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  long long int N, M;
  cin >> N >> M;
  vector<pair<long long int, long long int>> X(N);
  for (long long int i = 0; i < N; i++) {
    long long int A, B;
    cin >> A >> B;
    X.at(i) = make_pair(A, B);
  }
  
  sort(X.begin(), X.end());
  
  long long int ans = 0;
  long long int i = 0;
  while (M > X.at(i).second) {
    ans += X.at(i).first * X.at(i).second;
    M -= X.at(i).second;
    i++;
  }
  ans += X.at(i).first * M;
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    if(a!=b&&b!=c&&c!=a){
        printf("3\n");
    }
    else if((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&c!=a)){
        printf("2\n");
    } else{
        printf("1\n");
    }
    return  0;
}


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

int main(){

	 int n, sum;

	while(1){

		int count = 0;
		cin >> n >> sum;
		if(n == 0 && sum == 0) break;

		for(int i=1; i<=n-2; i++){
			for(int j=i+1; j<=n-1; j++){
				for(int k=j+1; k<=n; k++){
					if(i+j+k == sum) count++;
				}
			}
		}
		cout << count << endl;
	} 

	return 0;		
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using pchar = pair<char,char>;

int simulate(const string &s, const vector<pchar> &td, int pos) {
    for (auto c : td) {
        if (s[pos] != c.first) continue;
        if (c.second == 'L') --pos;
        else ++pos;
        if (pos < 0) return -1;
        if (pos >= (int)s.size()) return 1;
    }
    return 0;
}

int solve(int N, const string &s, const vector<pchar> &td) {
    // 左側の境目
    int low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == -1) low = mid;
        else high = mid;
    }
    int left_fall = high;

    // 右側の境目
    low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == 1) high = mid;
        else low = mid;
    }
    int right_fall = N-1-low;

    return N - (left_fall + right_fall);
}

int main() {
    int N, Q; string s; cin >> N >> Q >> s;
    vector<pchar> td(Q);
    for (int i = 0; i < Q; ++i) cin >> td[i].first >> td[i].second;
    cout << solve(N, s, td) << endl;
}


Measured memory_bytes: 900
#include <iostream>

#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
		int N;
		cin >> N;

		vector<int> v(N, 0);
		rep(i,0, N) 
		{
			int a;
			cin >> a;
			v[a]++;
		}

		if (N % 2 != 0 && v[0] != 1)
		{
			cout << 0 << endl;
			return 0;
		}

		ll ans = 1;
		for (int i = 1; i < N; i++) 
		{
			if (v[i] == 0)
				continue;
			if (v[i] != 2)
			{
				ans = 0;
				break;
			}
			ans = 2 * ans % mod;
		}

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

Measured memory_bytes: 640
n,m = list(map(int,input().split()))
d = {}
ac = 0
wa = [0] * (n+1)
wa_sum = 0

for i in range(m):
  p,s = input().split()
  p = int(p)
  if p in d:
    if d[p] == 'AC':
      pass
    else:
      if s == 'AC':
        d[p] = 'AC'
        ac += 1
        wa_sum += wa[p]
      else:
        wa[p] += 1
  else:
    d[p] = s
    if s == 'AC':
      ac += 1
    else:
      wa[p] += 1

print(ac,wa_sum)

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

int main() {
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int dis=0;
  for(int i=0;i<n-1;i++){
    dis=max(dis,(a.at(i+1)-a.at(i)));
  }
  dis=max(dis,k-a.at(n-1)+a.at(0));
  cout<<k-dis<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long

int main () {
  ll n, k;
  cin >> n >> k;
  map<ll, ll> check;
  ll sub;
  for (ll i = 0; i < n; i++) {
    cin >> sub;
    check[sub]++;      
  } 
  vector<ll> ans;
  for (auto itr = check.begin(); itr != check.end(); ++itr) {
    ans.push_back(itr->second);    
  }
  sort(ans.begin(), ans.end());
  ll num = 0;
  if (ans.size() < k) {
    cout << num << endl;
    return 0;  
  }
  for (ll i = 0; i < ans.size() - k; i++) {
    num = num + ans[i];    
  }
  cout << num << endl;
}

Measured memory_bytes: 14964
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  // やるだけ
  string t = s;
  reverse(t.begin(), t.end());
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == 'b') t[i] = 'd';
    else if (t[i] == 'd') t[i] = 'b';
    else if (t[i] == 'p') t[i] = 'q';
    else t[i] = 'p';
  }

  // 解答
  cout << (s == t ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int W,H,x,y,r; 
    cin >> W >> H >> x >> y >> r;
    if(x>=r && x+r<=W && y>=r && y+r<=H){
        cout << "Yes" << endl;
        
    }
    else{
        cout << "No" << endl;
    }
    
}



Measured memory_bytes: 3108
N = int(input())
v = list(map(int, input().split()))

os=dict()
es=dict()
for i in range(N//2):
    os[v[2*i]] = os.get(v[2*i], 0) + 1
    es[v[2*i+1]] = es.get(v[2*i+1], 0) + 1

osr=sorted(os.items(), key=lambda x: (x[1], x[0]))
esr=sorted(es.items(), key=lambda x: (x[1], x[0]))

osv = osr.pop()
esv = esr.pop()

o1n = N//2 - osv[1]
e1n = N//2 - esv[1]

count = o1n + e1n
if osv[0] == esv[0]:
    if len(osr) == 0:
        o2n = N//2
    else:
        o2n = N//2 - osr.pop()[1]
    if len(esr) == 0:
        e2n = N//2
    else:
        e2n = N//2 - esr.pop()[1]

    count = min(o1n + e2n, o2n + e1n)

print(count)


Measured memory_bytes: 25448
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int height = Convert.ToInt32(Console.ReadLine());
            int width = Convert.ToInt32(Console.ReadLine());
            int n = Convert.ToInt32(Console.ReadLine());
            int total = 0;
            int count = 0;

            if (height > width)
            {
                while (n > total)
                {
                    total += height;
                    count++;
                }
            }
            else
            {
                while (n > total)
                {
                    total += width;
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

int num(vector<int> e, int m) {
  int ret = 0;
  for ( int i = 0; i < e.size(); i++ ) {
    if ( e[i] >= m ) { ret++; }
  }
  return ret;
}

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

  vector<int> e(n+1, 0);
  for ( int i = 2; i <= n; i++ ) {
    int cur = i;
    for ( int j = 2; j <= i; j++ ) {
      while ( cur%j == 0 ) {
        e[j]++;
        cur /= j;
      }
    }
  }

  int d75 = num(e, 74);
  int d25_3 = num(e, 24) * (num(e, 2)-1);
  int d15_5 = num(e, 14) * (num(e, 4)-1);
  int d5_5_3 = num(e, 4) * (num(e, 4)-1) * (num(e, 2)-2) / 2;
  cout << d75 + d25_3 + d15_5 + d5_5_3 << endl;
  return 0;
}


Measured memory_bytes: 3632
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
l = 0
r = W+1
u = 0
d = H+1
flag = True
for s,t in zip(S[::-1],T[::-1]):
    if l+1==r or u+1==d:
        flag=False
        break
    if t == 'L':
        r = min(W+1, r+1)
    if t == 'R':
        l = max(0, l-1)
    if t == 'U':
        d = min(H+1, d+1)
    if t == 'D':
        u = max(0, u-1)
    if s == 'L':
        l += 1
    if s == 'R':
        r -= 1
    if s == 'U':
        u += 1
    if s == 'D':
        d -= 1
if not(l < sc < r and u < sr < d):
    flag = False
if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A, B, K; cin >> A >> B >> K;
  if(A>=K) {
    cout << A-K << " " << B <<endl;
  } else if(A+B <= K) {
    cout << "0 0" <<endl;
  } else {
    cout << "0 " << A+B-K << endl;
  }
}


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

void maxHeapify(int *,int);
void heapIncreaseKey(int *,int,int);

int H=0;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}


int main(){
  int i;
  int *A;
  int key;
  char order[7];


  A=(int *)malloc(sizeof(int)*10000000);
  while(1){
    scanf("%s",order);
    if(order[0]=='i'){
      H++;
      scanf("%d",&key);
      heapIncreaseKey(A,H,key);
    }
    else if(order[1]=='x'){
      printf("%d\n",A[1]);
      A[1]=A[H];
      H--;
      maxHeapify(A,1);
    }
    else break;
    
  }
  
return 0;
}
void maxHeapify(int *A,int i){
  int l;
  int r;
  int largest;
  int temp;
  l=left(i);
  r=right(i);
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A,largest);
  }
  return;
}
    
void heapIncreaseKey(int *A,int i,int key){
  int temp;
  A[i]=key;
  while(i>1&&A[parent(i)]<A[i]){
    temp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=temp;
    i=parent(i);
  }
}



Measured memory_bytes: 5644
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	int n; cin >> n;
	while (n--) {
		int l = 0, r = 0;
		bool ok = true;
		rep(i, 10) {
			int b; cin >> b;
			if(l < b) l = b;
			else if (r < b) r = b;
			else ok = false;
		}
		cout << (ok ? "YES" : "NO" ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    string s;
    ll t, n;
    while (cin >> s >> t)
    {
        if (s == "-")
        {
            break;
        }
        repi(i, t, 0)
        {
            cin >> n;
            string tmp = s.substr(0, n);
            s.erase(0, n);
            s+=(tmp);
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

mint comb[2005][2005];
void com() {
    comb[0][0]=1;
    rep(i, 2002) {
        rep(j, 2002) {
            comb[i][0] = 1;
            comb[i + 1][j + 1] = comb[i][j] + comb[i][j + 1];
        } 
    }

}
int main() {
    int n, k;
    cin >> n >> k;
    int aka = n - k;
    com();
    for (int i = 1; i <= k; ++i) {
        mint ans;
        ans = comb[aka + 1][i] * comb[k - 1][i - 1];
        cout << ans;
        cout << endl;
    }
    return 0;
}

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

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    string s, t;
    scan(s);
    scan(t);
    iota(3).map!(i => s[i] == t[i]).sum().writeln;
}








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

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
def bubble(A):
    #标记是否需要继续冒泡
    flag =True;
    n=len(A)
    i=0
    while flag:
        flag=False
        for j in range(n-1,i,-1):
           if A[j][1]<A[j-1][1]:
               A[j],A[j-1]=A[j-1],A[j]
               flag=True
        i+=1
 
 
#选择排序法
def selection(A):
    n=len(A)
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][1]<A[minj][1]:
                minj=j
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]
             
   
           
n=int(input())
ss=[x for x in input().split()]     
ss2=ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=' ')
print(ss2[-1])
if ss==ss2:
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5620
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int n;
int G[20][20];

int par[20];
bool dis[20];
vector<int> chil[20]; 

void make_tree(int v){
	for(int i = 0; i < n; i++){
		if(i != par[v] && G[i][v] >= 0){
			par[i] = v;
			chil[v].push_back(i);
			make_tree(i);
		}
	}
}
int dfs(int v){
	int res = 0;
	int maxi = 0;
	for(int i = 0; i < n; i++){
		if(i != par[v] && G[i][v] >= 0){
			if(chil[i].empty()) continue;
			int d = dfs(i);
			res += d + G[i][v] * 2;
		}
	}
	return res ;
}

int calc(){
	int res = 0;
	for(int i = 0; i < n; i++){
		int c = 0;
		int v = i;
		if(!dis[i]) continue;
		while(par[v] >= 0){
			c += G[v][par[v]];
			v = par[v];
		}
		res = max(res, c);
	}
	return res;
}

int main(){
	while(cin >> n && n){
		memset(G, -1, sizeof(G));
		for(int i = 0; i < 20; i++) chil[i].clear();
		fill(par, par + 20, -1);
		fill(dis, dis + 20, false);
		for(int i = 0; i < n-1;i++){
			int t, f, m;
			cin >> t >> f >> m;
			G[t-1][f-1] = G[f-1][t-1] = m;
		}
		make_tree(0);
		for(int i = 0; i < n; i++){
			if(chil[i].empty()) dis[par[i]] = true;
		}
		cout << dfs(0)-calc() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#define int long long
using namespace std;

int n, k, q;
int a[2000];
int b[2000];

//l以上r以下の整数だけ消す、ということが可能か？
bool check(int l, int r) {
	if (l > r) return false;
	
	int i;
	int type[2001];
	
	for (i = 0; i < n; i++) {
		if (a[i] > r) type[i] = 1;
		else if (a[i] < l) type[i] = -1;
		else type[i] = 0;
	}
	type[n] = -1;
	
	int zeroCnt = 0;
	int length = 0;
	int ret = 0;
	for (i = 0; i <= n; i++) {
		if (type[i] == -1) {
			int okCnt = min(zeroCnt, length - k + 1);
			if (okCnt >= 0) { ret += okCnt; }
			zeroCnt = 0;
			length = 0;
		}
		else {
			if (type[i] == 0) zeroCnt++;
			length++;
		}
	}
	return ret >= q;
}

signed main() {
	int i;
	
	cin >> n >> k >> q;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) b[i] = a[i];
	sort(b, b + n);
	
	int ans = 1145141919;
	for (i = 0; i < n; i++) {
		int st = 0, ed = 1145141919, mid;	//xxxooo, (st, ed]
		while (ed - st >= 2) {
			mid = (st + ed) / 2;
			if (check(b[i], mid)) { ed = mid; }
			else { st = mid; }
		}
		if (ed >= 1000000007) continue;
		ans = min(ans, ed - b[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans = 0;
    ans+=min(a,k);
    k-=a;
    if(k<=0)
    {
        cout<<ans<<endl;
        return 0;
    }
    k-=b;
    if(k<=0)
    {
        cout<<ans<<endl;
        return 0;
    }
    ans-=min(c,k);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N - i + 1):
        left = Y - 10000*i - 5000*j
        if i*10000 + j*5000 + (N-i-j)*1000 == Y:
            print(i, j, N-i-j)
            exit()

print(-1, -1, -1)




Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		boolean[][] mtx = new boolean[H][W];
		for (int i = 0; i < H; i++) {
			String s = sc.next();
			for (int j = 0; j < W; j++) {
				mtx[i][j] = (s.charAt(j) == '#');
			}
		}

		boolean[][] r = new boolean[H][W];
		boolean[][] b = new boolean[H][W];
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j == 0) {
					r[i][j] = true;
					b[i][j] = false;
				} else if (j == W - 1) {
					r[i][j] = false;
					b[i][j] = true;
				} else if (i == H - 1) {
					r[i][j] = false;
					b[i][j] = true;
				} else if (i % 2 == 0) {
					r[i][j] = true;
					b[i][j] = false;
				} else {
					r[i][j] = false;
					b[i][j] = true;
				}
				if (mtx[i][j]) {
					r[i][j] = true;
					b[i][j] = true;
				}
			}
		}

		StringBuffer buf = new StringBuffer();
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (r[i][j]) {
					buf.append('#');
				} else {
					buf.append('.');
				}
			}
			buf.append('\n');
		}
		buf.append('\n');
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (b[i][j]) {
					buf.append('#');
				} else {
					buf.append('.');
				}
			}
			buf.append('\n');
		}
		System.out.println(buf.toString());
	}
}


Measured memory_bytes: 20320
#include <stdlib.h>
#include <stdio.h>

int main(){
	int n;
	int data[4][3][10];
	int i, j, k;
	int num;
	int b, f, r, v;

	scanf("%d", &num);

	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k< 10; k++){
				data[i][j][k] = 0;
			}
		}
	}

	for(i=0; i<num; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		data[b-1][f-1][r-1] += v;
	}

	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k< 10; k++){
				printf(" %d", data[i][j][k]);
			}
			printf("\n");
		}
		if(i<3){
			for(k=0; k<20; k++){
				printf("#");
			}
			printf("\n");
		}
	}

	return 0;

}


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

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

  int w, r ;
  w = 0 ;
  for (int i = 0; i < n; i++) {
    if ( s.at(i) == 'W') {
      w++ ;
    }
  }
  r = n - w ;

  int a = 0 ;
  for (int i = r ; i < n ; i++) {
    if ( s.at(i) == 'R' ) {
      a++ ;
    }
  }

  cout << a << endl ;

  return 0 ;
}


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

using namespace std;


void solve() {
    map<string,int> cnt;
    string s,t;
    cin >> s >> t;
    int x,y;
    cin >> x >> y;
    cnt[s] = x;
    cnt[t] = y;
    string u; cin >> u;
    cnt[u] -= 1;
    cout << cnt[s] << ' ' << cnt[t];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    char f[H][W];

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> f[i][j];
            //cout << f[i][j];
        }
        //cout << endl;
    }

    bool bH[H], bW[W];
    for(int i = 0; i < H; i++) {
        bool b = true;
        for(int j = 0; j < W; j++) {
            b &= (f[i][j] == '.');
        }
        bH[i] = !b;
    }
    for(int j = 0; j < W; j++) {
        bool b = true;
        for(int i = 0; i < H; i++) {
            b &= (f[i][j] == '.');
        }
        bW[j] = !b;
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(bH[i] && bW[j]) {
                cout << f[i][j];
            }
        }
        if(bH[i]) {
            cout << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

ll dist(ll x, ll y) {
    return x*x+y*y;
}

int32_t main() { 
	
	setIO();

    ll N,D; cin >> N >> D; D*=D;

    int res = 0;
    F0R(i,N) {
        ll x,y; cin >> x >> y;

        res += dist(x,y) <= D;
    }

    cout << res << "\n";

}	

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

int main() {
    string s; cin >> s;
    string s1 = s.substr(0,2);
    string s2 = s.substr(2,2);
    int num1 = stoi(s1);
    int num2 = stoi(s2);
    if(num1 >= 1 && num1 <= 12 && num2 >= 1 && num2 <= 12) cout << "AMBIGUOUS" << endl;
    else if(num1 >= 1 && num1 <= 12 && num2 >= 0) cout << "MMYY" << endl;
    else if(num1 >= 0 && num2 >= 1 && num2 <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

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

int main(){
  
  int n,t,a;
  cin>>n>>t>>a;
  
  vector<int> height(n);
  for (int i=0;i<n;i++){
    cin>>height.at(i);
  }
  
  vector<double> tmp(n);
  for (int i=0;i<n;i++){
    tmp.at(i)=fabs(a-t+0.006*height.at(i));
  }
  
  
  int answer=0;
  for (int i=0;i<n;i++){
    if (tmp.at(i)<tmp.at(answer)){
      answer=i;
    }
  }
  
  cout<<answer+1<<endl;
  
  



  
}
  













Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll=long long;
ll K,a[26];
string s;
int main(){
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin>>s>>K;
    for(auto& x:s)
        if(x!='a'&&x-'a'+K>=26){
            K-=26-x+'a';
            x='a';
            if(K<1)break;
        }
    s.back()=(s.back()-'a'+K)%26+'a';
    cout<<s<<endl;
}


Measured memory_bytes: 592
#include <stdio.h>

int head(int a){
  while(a > 9) a /= 10;
  return a;
}

int main(void)
{
  int N;
  scanf("%d", &N);
  int c[10][10];
  for(int i = 0; i < 10; i++)
    for(int j = 0; j < 10; j++)
      c[i][j] = 0;
  for(int i = 1; i <= N; i++) c[head(i)][i%10]++;

  int ans = 0;
  for(int i = 1; i < 10; i++)
    for(int j = 1; j < 10; j++)
      ans += c[i][j]*c[j][i];

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        if(H % A == 0)
            System.out.println(H/A);
        else
            System.out.println(H/A+1);
    }
}


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

void change(long* x, long* y){
    long z = *x;
    *x = *y;
    *y = z;
}

void gcd(long* x, long* y){
    long z;

    if (*x < *y){
        change(x, y);
    }

    while(*x % *y){
        z = *x % *y;
        *x = *y;
        *y = z;
    }
}

int main(){
    long a,b;
    int t = 1;

    scanf("%ld%ld", &a, &b);  //a > b

    gcd(&a, &b);
   
    for(long i = 2; i <= sqrt(b); i ++){
        if(b % i == 0){
            while(b % i == 0){
                b /= i;
            }

            t++;
        }
    }
    if(b != 1){
        t++;
    }
    printf("%d",t);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include<algorithm>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001

int arr[200001];
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int choose2(int n){
	
	return n*(n-1)/2;
}

int32_t main() {
	
   string s;
   
   cin >> s;
   
   int q;
   
   cin >> q;
   int cnt = 0;
   for(int i=0;i<q;i++){
   	
   		int t;
   		
   		cin >> t;
   		
   		if(t==1){
   			cnt++;
		}
   		else if(t==2){
   			
   			int f;
   			cin >> f;
   			
   			if(f==1){
   				string c;
   				cin >> c;
   				if(cnt%2 ==0){
   					s.insert(0,c);
				}
				else{
   					s.insert(s.length(),c);
   				}
			}
   			else{
   				string p;
   				cin >> p;
   				if(cnt%2 ==1){
   					s.insert(0,p);
   				}
   				else{
   						s.insert(s.length(),p);
				   }
			}
   			
		}
   }
   if(cnt%2==1){
		reverse(s.begin(), s.end());
   }
 	cout << s << endl;
}

Measured memory_bytes: 3372
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
	int tot=0;
	char c;
	bool flag=0;
	while((c=getchar())!=10)
	{
		if(c=='C')
		{
			tot++;
			flag=1;
			break;
		}
	}
	if(!flag)
	{
		goto sc;
	}
	while((c=getchar())!=10)
	{
		if(c=='F')
		{
			tot++;
			break;
		}
	}
	sc:
		printf((!(2-tot))?("Yes"):("No"));
	putchar(10);
	return 0;
}

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

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

    vector<long> A(N);
    rep(i, N) cin >> A.at(i);

    long ans = 0;

    long ai;
    long mod = pow(10, 9) + 7;

    long as = 0;
    for (int i = N - 2; i >= 0; i--)
    {
        ai = A.at(i);
        as += A.at(i + 1);
        as %= mod;
        ans += (ai * as) % mod;
    }

    cout << ans % mod << endl;

    return 0;
}

Measured memory_bytes: 4840