akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;

signed main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    cin >> A;
    cout << (H <= accumulate(A.begin(), A.end(), 0L) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 1024
#coding:utf-8
 
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
cnt = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      p = i * 500 + j * 100 + k * 50
      if p > x:
        break
      if p == x:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
l, a, b, MOD = [int(item) for item in input().split()]
vec = [0, a%MOD, 1]

def mat_mat_mul3(m1, m2):
    m3 = [[0] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                m3[i][j] += m1[i][k] * m2[k][j]
                m3[i][j] %= MOD
    return m3

def mat_vec_mul3(m1, v1):
    v2 = [0] * 3
    for i in range(3):
        for k in range(3):
            v2[i] += v1[k] * m1[i][k]
            v2[i] %= MOD
    return v2

A_d_pow = [[None] * 66 for _ in range(20)]
for d in range(20):
    for i in range(66):
        if i == 0:
            A = [[1, 0, 0], 
                 [0, 1, 0], 
                 [0, 0, 1]]
            A_d_pow[d][i] = A
            continue
        if i == 1:
            A = [[10**d % MOD, 1, 0], 
                 [0, 1, b % MOD], 
                 [0, 0, 1]]
            A_d_pow[d][i] = A
            continue
        A_d_pow[d][i] = mat_mat_mul3(A_d_pow[d][i-1], A_d_pow[d][i-1])

multimes = [0] * 20
for i in range(1,20):
    if 10**i > a:
        cnt = (10**i - 1 - a) // b + 1
        if cnt >= l:
            multimes[i] = l
            break
        else:
            multimes[i] = cnt
            l -= cnt
            a += cnt * b

for i, num in enumerate(multimes):
    if num == 0:
        continue
    for j in range(66):
        if num & 1 << j:
            vec = mat_vec_mul3(A_d_pow[i][j+1], vec)

print(vec[0])

Measured memory_bytes: 3700
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	REP(i, 9){
		REP(j, 9) {
			printf("%dx%d=%d\n", i+1, j+1,(i+1)*(j+1));
		}
	}
	return 0;
}

Measured memory_bytes: 3220
#include<stdio.h>

int main(void)
{
    int t[3];
    scanf("%d%d%d",&t[0],&t[1],&t[2]);
    int min=500;

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i!=j && min>t[i]+t[j]){
                min=t[i]+t[j];
            }
        }
    }

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

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    vector<int> a(N);

    rep(i, N) {
        read(a[i]);
    }

    vector<int> ans;

    rep(i, N) {
        bool f = false;
        repr(i, a.size(), 1) {
            if (a[i-1] == i) {
                ans.push_back(i);
                a.erase(a.begin() + i-1);
                f = true;
                break;
            }
        }
        if (!f) {
            print(-1);
            return 0;
        }
    }

    if (ans.size() != N) {
        print(-1);
        return 0;
    }

    reverse(all(ans));
    for (int e : ans) print(e);
    return 0;
}


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

int main() {
    int x,a,b,A,B;
    cin >> x >> a >> b;
    if(a-x < 0)A = x-a;
    else A = a-x;
    if(b-x < 0)B = x-b;
    else B = b-x;
    
    if(A > B)cout << 'B' << endl;
    if(A < B)cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static IO io = new IO();
    public static void main(String[] args) {

        int n = io.nextInt();
        System.out.println(n*n*n);

    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 24288
class Queue:
    def __init__(self, size):
        self.data = [None for i in range(size)]
        self.front = 0
        self.tail = 0 
    
    def initialize(self):
        self.front = self.tail = 0
    
    def isempty(self):
        return self.front == self.tail
    
    def isfull(self):
        return (self.tail + 1)%len(self.data) == self.front
    
    def enqueue(self, x):
        if self.isfull():
            raise Exception('overflow')
        else:
            self.data[self.tail] = x
            self.tail = (self.tail + 1)%len(self.data)
    
    def dequeue(self):
        if self.isempty():
            raise Exception('underflow')
        else:
            x = self.data[self.front]
            self.front = (self.front + 1) %len(self.data)
            return x

T = 0
size, time = list(map(int, input().split()))
# print(isinstance(time, int))
queue = Queue(size+2)
for i in range(size):
    ele = tuple(input().split())
    queue.enqueue(ele)

while not queue.isempty():
    task, t = queue.dequeue()
    t = int(t)
    if t <= time:
        T += t
        print(task, T)
    else:
        t -= time
        T += time
        queue.enqueue((task,t))


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,c;
    cin >> n >> c;
    vector<vector<pair<ll,ll>>> subrokuga(c);
    for(i = 0;i < n;++i){
        ll s,t,ch;
        cin >> s >> t >> ch;
        --ch;
        subrokuga.at(ch).emplace_back(s,t);
    }
    for(i = 0;i < c;++i){
        sort(all(subrokuga.at(i)));
    }
    vector<vector<pair<ll,ll>>> rokuga(c);
    for(i = 0;i < c;++i){
        if(subrokuga.at(i).size() == 0) continue;
        pair<ll,ll> tmp;
        rep(j, subrokuga.at(i).size()){
            if(j == 0){
                tmp = subrokuga.at(i).at(j);
            }else{
               if(subrokuga.at(i).at(j).first == tmp.second){
                    tmp.second = subrokuga.at(i).at(j).second;
                }else{
                    rokuga.at(i).emplace_back(tmp);
                    tmp = subrokuga.at(i).at(j);
                }
            }  
        }
        rokuga.at(i).emplace_back(tmp);
    }
    vector<ll> sche(2e5,0);
    for(i = 0;i < c;++i){
        rep(j, rokuga.at(i).size()){
            ll s = rokuga.at(i).at(j).first;
            ll t = rokuga.at(i).at(j).second;
            ++sche.at(s-1);
            --sche.at(t);
        }
    }
    for(i = 1;i < sche.size();++i){
        sche.at(i) += sche.at(i-1);
    }
    ll ans = 0;
    for(i = 0;i < sche.size();++i){
        ans = max(ans, sche.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll n;
ll happy[110000][3];
ll dp[110000][3];
// 0: imi
// 1: yama
// 2: HW

int main() {
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>happy[i][0]>>happy[i][1]>>happy[i][2];
    }

    for(int i=1;i<=n;i++){
        for(int place=0;place<3;place++){
            for(int placeY=0;placeY<3;placeY++){
                if(place==placeY) continue;
                dp[i][place]=max(dp[i][place],dp[i-1][placeY]+happy[i][place]);
            }
        }
    }
    ll ans=0;
    for(int place=0;place<3;place++){
        ans=max(ans,dp[n][place]);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 5120
program main
  implicit none
  integer :: n, i, k, hap
  character(100000) :: s
  read (*, *) n, k
  read (*, *) s
  hap = 0
  do i = 1, n
    if (i == 1) then
      if (s(1:1) == "R" .and. s(2:2) == "R") hap = hap + 1
    else if (i == n) then
      if (s(n:n) == "L" .and. s(n - 1:n - 1) == "L") hap = hap + 1
    else
      if (s(i:i) == "L") then
        if (s(i - 1:i - 1) == "L") hap = hap + 1
      else
        if (s(i + 1:i + 1) == "R") hap = hap + 1
      end if
    end if
  end do
  write (*, "(i0)") min(n - 1, hap + 2 * k)
end program main


Measured memory_bytes: 700
W, H, N = map(int, input().split())

XYA = [tuple(map(int, input().split())) for _ in range(N)]

x = (0, W)
y = (0, H)
for xya in XYA:
    a = xya[2]
    if a == 1:
        if x[0] < xya[0]:
            x = (xya[0], x[1])
    elif a == 2:
        if xya[0] < x[1]:
            x = (x[0], xya[0])
    elif a == 3:
        if y[0] < xya[1]:
            y = (xya[1], y[1])
    else:
        if xya[1] < y[1]:
            y = (y[0], xya[1])

res = (x[1] - x[0]) * (y[1] - y[0])
if x[1] - x[0] < 0 or y[1] - y[0] < 0:
    res = 0

print(res)

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

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

    vector<long long> a(n+1);
    vector<long long> b(n+1);
    vector<long long> c(n+1);
    for(long long i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<long long> > dp(n+1, vector<long long>(3, 0));

    for(long long i = 1; i <= n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
    return 0;
}

Measured memory_bytes: 11108
#include <cstdio>
#include <cstring>

long long g(long long a, long long b){
	return b?g(b,a % b):a;
}

#define l(a,b) a*b/g(a,b)

int main(){
	int a[3], m[3], p[3] = {1,1,1}, c[3];
	while(scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),*a){
		memset(c,0,sizeof(c));
		for(int i=0;i<3;i++){
			do{
			p[i] = a[i] * p[i] % m[i];c[i]++;
			}while(p[i] != 1);
		}
		printf("%lld\n",l(l(c[0],c[1]),c[2]));
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

bool ng(int a, int b, int c) {
    return (a == 1 && b == 2 && c == 3);
}

ll dp[101][4][4][4];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    dp[0][0][0][0] = 1;
    FOR(i, 0, n)FOR(a, 0, 4)FOR(b, 0, 4)FOR(c, 0, 4)FOR(d, 0, 4) {
        if (ng(b, c, d))continue;
        if (ng(c, b, d))continue;
        if (ng(b, d, c))continue;
        if (ng(a, c, d))continue;
        if (ng(a, b, d))continue;
        dp[i + 1][b][c][d] += dp[i][a][b][c];
        dp[i + 1][b][c][d] %= mod;
    }

    ll ans = 0;
    FOR(i, 0, 4)FOR(j, 0, 4)FOR(k, 0, 4) {
        ans += dp[n][i][j][k];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;
int cnt[100000];
int main(){
 	int h,w,d; cin >>h>>w>>d;
 	int a;
 	map<int,int> mpx,mpy;
 	for(int i=1;i<=h;i++){
 		for(int j=1;j<=w;j++){
 			cin >>a;
 			mpx[a]=j;
 			mpy[a]=i;
 		}
 	}
 	for(int i=1;i<=h*w;i++){
 		if(i-d>=1){
 			cnt[i]+=abs(mpx[i]-mpx[i-d]);
 			cnt[i]+=abs(mpy[i]-mpy[i-d]);
 			cnt[i]+=cnt[i-d];
 		}
 	}
 	int q; cin >>q;
 	for(int i=0;i<q;i++){
 		int l,r;
 		cin >>l >> r;
 		if(l==r){
 			cout << 0 << endl;
 		}
 		else{
 			int ans=cnt[r]-cnt[l];
 			cout << ans  << endl;
 		}
 	}
 	return 0;
 }

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

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}

int main()
{
int x;
  scanf("%d",&x);

  if (x==0){
    printf("1");
	return 0;  
  }
  
  printf("0");
  
  return 0;
  
}


Measured memory_bytes: 2092
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))

char s[10];

int main(void) {
	scanf("%s", &s);
	string a = (string)s;
	if (a.back() == '2' || a.back() == '4' || a.back() == '5' || a.back() == '7' || a.back() == '9') {
		printf("hon\n");
		return 0;
	}

	if (a.back() == '0' || a.back() == '1' || a.back() == '6' || a.back() == '8') {
		printf("pon\n");
		return 0;
	}

	if (a.back() == '3') {
		printf("bon\n");
	}


	return 0;
}

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

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

int main() {
    ll x, y;
    cin >> x >> y;
    cout << x + y - gcd(x, y) + 1 << "\n";
    return 0;
}


Measured memory_bytes: 3116
$x=0
$y=0
$bord = []
$cnt = 0


def calc()

	max = 0
	for i in 0..$x-1
		for j in 0..$y-1
			if $bord[j][i] != -1 then
				if j > 0 then
					up = $bord[j-1][i]
				else
					up = -1
				end
			
				if i > 0 then
					left = $bord[j][i-1]
				else
					left = -1
				end

			
				if up > left and up != -1 then
					$bord[j][i] += up * 10
					
				elsif left != -1 then
					$bord[j][i] += left * 10
				end
				if $bord[j][i] > max then
					max = $bord[j][i]
				end
			end
		end
	end
	return max
end
	
loop{
	line = gets
	if line==nil then
		break
	end
	sp = line.split(nil)
	
	if sp.count() != 2 then
		break
	else
		$x = sp[0].to_i()
		$y = sp[1].to_i()
		if $x == 0 and $y == 0 then
			break
		end
		
		sx = 0
		sy = 0
		$cnt = 1 
		$bord = Array.new($y).map{Array.new($x,0)}
		for i in 0..$y-1
			line = gets
			for j in 0..$x-1
				tmp = -1
				if line[j] =~ /\d/ then
					tmp = line[j].to_i() 
				end
				$bord[i][j] = tmp
			end
		end
		print calc()
		print("\n")
	end
}

Measured memory_bytes: 6152
#coding-utf8
#Complete Binary Tree

def parent(i):
    return i//2

def left(i):
    return i*2

def right(i):
    return i*2+1

def main():
    H=int(input())
    a = [0] + list(map(int, input().split()))

    for i in range(H):
        i+=1
        print("node "+str(i)+": key = "+str(a[i])+", ",end="")
        if(parent(i)):
            print("parent key = "+str(a[parent(i)])+", ",end="")
        if(left(i)<=H):
            print("left key = "+str(a[left(i)])+", ",end="")
        if(right(i)<=H):
            print("right key = "+str(a[right(i)])+", ",end="")
        print()

    return 0

if __name__ == "__main__":
    main()



Measured memory_bytes: 5684
n,k = map(int,input().split())
if n%k == 0:
    print(0)

else:
    
    x = (n+k-1)//k
    y = (n-k-1)//k
    if y < 0:
        y += 1
    if x < 0:
        x+= 1
    a =abs(x*k-n)
    b = abs(y*k-n)
    if a < b:
        print(a)
        
    else:
        print(b)

Measured memory_bytes: 3064
#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(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> a(n+1);
  rep(i,m){
    int x;
    cin >> x;
    a[x]++;
  }
  int ans1=0,ans2=0;
  rep(i,x-1) ans1+=a[i+1];
  rep(i,n-x-1) ans2+=a[x+i+1];
    
  cout << min(ans1,ans2);
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <numeric>

using namespace std;

int main(){
    double x,y,s;
    while(cin >> x >> y >> s, x&&y&&s){
        double maxs = 0;
        for(double i=1; i<=s-1; i+=1){
            for(double j=1; j<=s-1; j+=1){
                double befi = floor(i*(100+x)/100), befj = floor(j*(100+x)/100);
                if((befi + befj) == s){
                    double afi = i*(100+y)/100, afj = j*(100+y)/100;
                    double hoge = floor(afi)+floor(afj);
                    maxs = max(maxs, hoge);
                }
            }
        }
        printf("%.0f\n", maxs);
    }
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
typedef pair<string,int> sp;
int dd[] = {1,-1,4,-4};


string swap(string s,int a,int b){
	char tmp = s[a];
	s[a] = s[b];
	s[b] = tmp;
	return s;
}
int main(){
string s="01234567";
map<string,int> cost;
queue<sp> q;
q.push(sp(s,0) );
cost[s] = 1;
while(!q.empty()){
	sp now = q.front();
	q.pop();
	int ss=now.second;
	//if(!cost[now.first])continue;
	for(int i=0;i<4;i++){
		if(ss+dd[i]<0||ss+dd[i]>7)continue;
		if(ss==3&&i==0)continue;
		if(ss==4&&i==1)continue;
		string next = swap(now.first,ss,ss+dd[i]);
		if(!cost[next]){
			cost[next] = cost[now.first]+1;
			q.push(sp(next,ss+dd[i]));
		}
	}

}
string st;
st.resize(8);
while(cin>>st[0]>>st[1]>>st[2]>>st[3]>>st[4]>>st[5]>>st[6]>>st[7]){
	cout<<cost[st]-1<<endl;
}


	return 0;
}



Measured memory_bytes: 5336
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  if (s=="BBB" || s=="AAA") {cout << "No";}
  else{cout << "Yes";}
}

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

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}

int n;

int main() {
	cin >> n;
	for (int i = 31; i <= 55555; i += 5) {
		if (isprime(i) == true) {
			if (i != 31) cout << " ";
			cout << i; n--;
		}
		if (n == 0) break;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
#define N 1000010


int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int jibai=0,jihei=0,oubai=0,ouhei=0;
    for(int i=0;i<n;i++)
    {
        if((i+1)%2)
        {
            if(s[i]=='0')jihei++;
            else
                jibai++;
        }
        else
        {
            if(s[i]=='0')
                ouhei++;
            else
                oubai++;
        }
    }
    printf("%d\n",min(jihei+oubai,jibai+ouhei));
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <complex>
#include <string>
#include <sstream>
#include <iomanip>
#include <climits>
#include <functional>
#include <bitset>
#include <tuple>

using namespace std;

typedef long long  ll;

int main()
{
    int x, y, s;

    while (cin >> x >> y >> s) {
        if (x == 0 && y == 0 && s == 0)
            break;

        int res = 0;
        for (int i = 1; i <= 1000; ++i) {
            for (int j = i; j <= 1000; ++j) {
                if ((i * (100 + x) / 100) + (j * (100 + x) / 100) == s) {
                    res = max(res, (i * (100 + y) / 100) + (j * (100 + y) / 100));
                }
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
N = int(input())
a = []
for _ in range(0, N):
    a1, a2 = map(int, input().split())
    a.append(a1)
    a.append(a2)
ans = ''
for i in range(0, (2 * N) - 1, 2):
    if a[i] == a[i + 1]:
        ans += 'Y'
    else:
        ans += 'N'

if 'YYY' in ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
n, k = map(int, input().split())
aaa = list(map(int, input().split()))
dp = [False] * (k + 1)
for i in range(1, k + 1):
    win = None
    for a in aaa:
        j = i - a
        if j < 0:
            break
        if dp[j] == False:
            win = True
            break
    if win is None:
        win = False
    dp[i] = win
print('First' if dp[k] else 'Second')


Measured memory_bytes: 42988
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    
    for(int i = 1; i <= 100; i++){
        if(i * d >= l && i * d <= r ) cnt++;
    }

    cout << cnt << endl;
}   

Measured memory_bytes: 3648
import numpy as np

n=int(input())
a_list=list(map(int,input().split()))
a_list_2=sorted(a_list,reverse=True)
a=np.array(a_list_2,dtype='uint8')

alice=0
bob=0
for i in range(n):
	if i%2==0:
		alice+=a[i]
	else:
		bob+=a[i]

print(alice-bob)


Measured memory_bytes: 12504
import sys
from math import sqrt
readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
PS = [list(map(int, readline().split())) for i in range(N)]
PS.sort()

def dist(P, Q):
    return sqrt((P[0] - Q[0])**2 + (P[1] - Q[1])**2)


INF = 10**18
S = [INF]*N; T = [INF]*N
S[0] = T[0] = dist(PS[0], PS[1])
for k in range(2, N):
    s = t = INF
    for i in range(k-1):
        d = dist(PS[i], PS[k])
        s = min(s, T[i] + d)
        t = min(t, S[i] + d)
    S[k-1] = s; T[k-1] = t
    d = dist(PS[k-1], PS[k])
    for i in range(k-1):
        S[i] += d; T[i] += d
print(min(min(s, t) + dist(PS[i], PS[N-1]) for i, (s, t) in enumerate(zip(S, T))))



Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
const int MOD = 1e9 + 7;
#define rep(i, ne) for (int i = 0; i < ne; ++i)

int N;
vector<ull> a, b;

void input() {
  cin >> N;
  a.resize(N);
  b.resize(N + 1);
  rep(i, N) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
  }
}

void solve() {
  ull ans = 0;
  ull tmp;
  rep(i, N) {
    tmp = (b[N] - b[i + 1]) % MOD;
    tmp = (a[i] * tmp) % MOD;
    ans = (ans + tmp) % MOD;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  input();
  solve();
  getchar();
  return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
 
using namespace std;
 
#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll; 
typedef pair<int,int> P;

int main(){
	int n;
    cin >> n;
    vector<int> l(n);
    vector<ll> co(2001,0);
    rip(i,n,0){
        cin >> l[i];
        co[l[i]]++;
    }
    sort(all(l));
    vector<ll> da(2001,0);
    ll ans=0;
    rip(i,n,0){
        rip(j,2001,0){
            if(j>l[i]){
                ans+=da[j];
            }
        }
        rip(j,i,0){
            da[l[i]+l[j]]++;
        }
    }
    cout << ans << endl;
}

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

int main(void){
  int len_hour_hand,len_minute_hand,hour,minute;
  double diff_rad,distance;
  scanf("%d %d %d %d",&len_hour_hand,&len_minute_hand,&hour,&minute);
  diff_rad = 11*M_PI*(60*hour+minute)/360;
  distance = sqrt(pow(len_hour_hand,2)+pow(len_minute_hand,2)
                  -2*len_hour_hand*len_minute_hand*cos(diff_rad));
  printf("%.10f\n",distance);
  return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 17;

int a[MAX];
LL s[MAX];

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m, v, p;
	cin >> n >> m >> v >> p;
	FOR(i, 0, n)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	FOR(i, 0, n)
		s[i] = a[i] + (i ? s[i - 1] : 0);
	int ans = p;
	FOR(i, p, n)
	{
		ans += (i - p + 1LL) * (a[i] + m) - (s[i - 1] - s[p - 2]) >= (LL)max(0, v - n + (i - p + 1)) * m
			&& a[i] + m >= a[p - 1];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007
#define next nxt

int n,x[N],y[N],z[N],next[N],p[N],h[N],q[N],f[N],g[N],s[N],cnt,cmt,cir;
long long fac[N],inv[N],ans;
vector<int> v[N];

long long C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

void travel(int x,int pre){
	h[x]=true;q[++cnt]=x;
	for (int t=p[x];t;cmt++,t=next[t])
		if (!h[y[t]]) travel(y[t],t);
		else if (t/2!=pre/2) cir=t;
}

void build(int x){
	h[x]=true;
	for (int t=p[x];t;t=next[t])
		if (y[t]!=g[x]){
			if (y[t]<g[x]) v[x].push_back(y[t]),f[y[t]]=true;
			if (!h[y[t]]) g[y[t]]=x,build(y[t]);
		}
}

long long solve(int x){
	s[x]=0;long long ans=1;
	for (int i=0;i<(int)v[x].size();i++){
		ans=ans*solve(v[x][i])%mod;
		s[x]+=s[v[x][i]];
		ans=ans*C(s[x],s[v[x][i]])%mod;
	}
	s[x]++;return ans;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=2*n;i++){
		x[2*i]=y[2*i+1]=read();
		y[2*i]=x[2*i+1]=n+read();
		z[2*i]=z[2*i+1]=x[2*i]+y[2*i];
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
		next[2*i+1]=p[x[2*i+1]];p[x[2*i+1]]=2*i+1;
	}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod;
	ans=fac[2*n];
	for (int i=1;i<=2*n;i++)
		if (!h[i]){
			cnt=cmt=0;travel(i,0);
			if (cmt!=cnt*2) {printf("0\n");return 0;}
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),g[q[i]]=0,
				h[q[i]]=false,f[q[i]]=false;
			g[x[cir]]=y[cir];build(x[cir]);
			for (int i=1;i<=cnt;i++)
				if (!f[q[i]]) v[0].push_back(q[i]);
			long long tmp=solve(0);
			
			v[0].clear();
			for (int i=1;i<=cnt;i++)
				v[q[i]].clear(),g[q[i]]=0,
				h[q[i]]=false,f[q[i]]=false;
			g[y[cir]]=x[cir];build(y[cir]);
			for (int i=1;i<=cnt;i++)
				if (!f[q[i]]) v[0].push_back(q[i]);
			tmp+=solve(0);
			
			ans=ans*tmp%mod*inv[cnt]%mod;
		}
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 78072
#include<iostream>

using namespace std;
using ll = long long;

ll n;
ll a[100005], b[100005];

ll solver(){
  ll cnt = 0;
  for(int i = 0; i < n; ++i){
    ll tmp = b[i];
    if(tmp >= a[i]){
      cnt += a[i];
      tmp -= a[i];
      if(tmp >= a[i + 1]){
        cnt += a[i + 1];
        a[i + 1] = 0;
      }else{
        a[i + 1] -= tmp;
        cnt += tmp;
      }
    }else{
      cnt += tmp;
    }
  }
  return cnt;
}

int main(){
  cin >> n;
  for(int i = 0; i < n + 1; ++i){
    cin >> a[i];
  }
  for(int i = 0; i < n; ++i){
    cin >> b[i];
  }
  cout << solver() << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
VI p(A), q(B), r(C); invec(p), invec(q), invec(r);

sort(ALL(p), greater<i64>());
sort(ALL(q), greater<i64>());

move(RANGE(p, 0, X), back_inserter(r));
move(RANGE(q, 0, Y), back_inserter(r));
sort(ALL(r), greater<i64>());

cout << accumulate(RANGE(r, 0, X+Y), (i64)0) << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 6384
N = gets.to_i
X = gets.split.map(&:to_i)
sorted_x = X.sort
med = sorted_x[X.size / 2]

X.each do |x|
  if x < med
    puts sorted_x[(X.size + 1) / 2]
  else
    puts sorted_x[(X.size - 1) / 2]
  end
end


Measured memory_bytes: 24536
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Map<Integer, Integer> stores = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int price = in.nextInt();
            int quant = in.nextInt();
            stores.put(price, stores.getOrDefault(price, 0) + quant);
        }
        long yen = 0;
        for (int price : stores.keySet()) {
            while (stores.get(price) > 0) {
                m--;
                stores.put(price, stores.get(price) - 1);
                yen += price;
                if (m == 0) {
                    System.out.println(yen);
                    return;
                }
            }
        }
        System.out.println("?");
    }
}


Measured memory_bytes: 98196
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << s1[0] << s2[1] << s3[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll W, H;
    cin >> W >> H;
    vector<ll> p(W), q(H);
    Rep (i, W) {
        cin >> p[i];
    }
    p.push_back(1e9);
    Rep (i, H) {
        cin >> q[i];
    }
    q.push_back(1e9);
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());

    ll ans = 0, edge = 0;
    ll xnow = 0, ynow = 0;

    Rep (i, W+H) {
        if (p[xnow] < q[ynow]) {
            ans += p[xnow] * (H+1-ynow);
            xnow++;
        } else {
            ans += q[ynow] * (W+1-xnow);
            ynow++;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 2672
def gcd(p, q):
  while q != 0:
    r = p % q
    p = q
    q = r
  return p

K = int(input())
sum = 0
for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      sum += gcd(gcd(a, b), c)
print(sum)

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

struct color
{
  double L, a, b;
};

inline double sqr(double x) { return x*x; }
inline double operator-(const color& lhs, const color& rhs)
{
  return sqr(lhs.L - rhs.L) + sqr(lhs.a - rhs.a) + sqr(lhs.b - rhs.b);
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<color> cs;
  for (int i = 0; i < N; i++) {
    color c;
    cin >> c.L >> c.a >> c.b;
    cs.push_back(c);
  }

  double ans = 0.0;
  for (int s = 0; s < (1<<N); s++) {
    vector<color> v;
    for (int i = 0; i < N; i++) {
      if (s & (1<<i)) {
        v.push_back(cs[i]);
      }
    }
    if (v.size() != M) {
      continue;
    }

    double x = 0.0;
    for (vector<color>::const_iterator it = v.begin(); it != v.end(); ++it) {
      for (vector<color>::const_iterator jt = it+1; jt != v.end(); ++jt) {
        x += *it - *jt;
      }
    }
    ans = max(ans, x);
  }
  printf("%.6f\n", ans);
  return 0;
}

Measured memory_bytes: 0
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}
fn dfs(ss: &mut String, c: char, depth: usize, limit: usize) {
    // let mut sss = ss.clone();

    if ss.len() == limit {
        println!("{}", ss);
    }
    if ss.len() == limit {
        return;
    }
    for i in 0..(depth + 1) {
        let mut cc = 'a' as i64;
        cc += i as i64;
        let cc = cc as u8 as char;
        ss.push(cc);
        dfs(ss, cc, max(depth, (i) + 1), limit);
        ss.pop();
    }
}
fn solve() {
    let mut n: usize = read();
    let mut s: String = String::new();
    dfs(&mut s, 'a', 0, n);

    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 2104
n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))
a = set(a)
dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
    if i<n-1 and i+2 not in a:
        dp[i+2] += dp[i]
print(dp[-1]%(10**9+7))

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


int main(){
    int N;
    cin >> N;
    vector<int> A(N),a;
    rep(i,N) cin >> A[i];
    a = A;
    sort(a.begin(),a.end());
    int first = a[N-1], second = a[N-2];
    for (int i = 0; i < N; i++)
    {
        if(A[i] == first) cout << second << endl;
        else cout << first << endl;
    }

    
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define fe first
#define se second
#define ll long long
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
//#define vl vector<ll>
//#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define all(x) (x).begin(), x.end()
using namespace std;

saken a, b;
int n;

int main(){

cin >> n;
cin >> a;
cin >> b;

if(a == b) {cout << a.sz(); return 0;}

int ans = 0;

for(int len = 1; len <= n; ++len) {

    for(int i = 1; i <= n; ++i) {

        saken to1 = a.substr(i - 1, len);
        saken to2 = b.substr(0, len);

        if(to1 == to2) {ans = max(ans, len);}

    }

}

cout << n * 2 - ans;

return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD = 1000000007;
ll cnt =0,ans=0;
const int MAX = 510000;

int main(){
   double a,b,h,m;
   cout << fixed << setprecision(15) ;
   cin >> a >> b >> h >> m;
   double A,B;
   A = 30*h + 0.5*m;
   B = 6.0*m;
   double pi = acos(-1);
   
   double the =  abs(B-A);

   double sita = the*pi/180;

   double answer;
   answer = a*a + b*b - 2*a*b*cos(sita);

   cout << pow(answer,0.5) << endl;

}
       


Measured memory_bytes: 4316
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    string LR;
    cin >> LR;
    vector<ll> ans;
    ans.resize(LR.size(), 0);
    ll even = 0;
    ll odd = 0;
    int phase = 0;
    while (true) {
        for (int i = 0; i < LR.size(); i++) {
            if (i == LR.size() - 1) {
                continue;
            }
            if (LR[i] == 'R') {
                if (i % 2 == 0) {
                    even++;
                } else {
                    odd++;
                }
                if (LR[i+1] == 'L') {
                    ll here, next;
                    if (i % 2 == 0) {
                        here = even;
                        next = odd;
                    } else {
                        here = odd;
                        next = even;
                    }
                    ans[i] += here;
                    ans[i+1] += next;
                    even = 0;
                    odd = 0;
                }
            }
        }
        for (int i = 0; i < LR.size(); i++) {
            if (LR[i] == 'R') {
                LR[i] = 'L';
            } else {
                LR[i] = 'R';
            }
        }
        reverse(LR.begin(), LR.end());
        reverse(ans.begin(), ans.end());
        phase++;
        if (phase == 2) {
            break;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i < ans.size() - 1) {
            cout << ' ';
        }
    }
    cout << endl;
}


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

using namespace std;

typedef long long LL;

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

    int ones = 0, twos = 0, fours = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0) fours++;
        else if (tmp % 2 == 0) twos++;
        else ones++;
    }

    if (twos == 0 && ones - fours == 1 || ones == fours || ones == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}
int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)){
    sum++;
    }
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2096
#define N 100
#include <stdio.h>
int main(){
  int i,j,k,a[N],n,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=1;i<n+1;i++){
    for(k=0;k<n-1;k++){
      printf("%d ",a[k]);
    }
    printf("%d",a[n-1]);
    printf("\n");
    
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      
      a[j+1] = a[j];
      j--;      
    }
    a[j+1] = v;
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int c[m], d[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < n; i++) {
    int cp = 1, mv = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    for (int j = 1; j < m; j++) {
      int v = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if (v < mv) {
        cp = j + 1;
        mv = v;
      }
    }
    cout << cp << endl;
  }
}

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

int main()
{
	int N, K, x,ans = 0,a,b;

	cin >> N >> K;

	for (int c = 0; c < N; c++) {
		cin >> x;
		a = x;
		b = K - x;
		if (a < b)  ans += a * 2;
		else ans += b*2;
	}

	cout << ans << endl;

	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=2e5+5;

int st[6*N],qt[6*N],a[N],h[N];

void update_tree(int cur,int s,int e,int pos,int val)
{
     if(pos<s || pos>=e)
          return;
     if(s==e-1)
     {
          st[cur]=val;
          return;
     }
     int c1=(cur<<1),c2=c1+1,m=(s+e)>>1;
     update_tree(c1,s,m,pos,val);
     update_tree(c2,m,e,pos,val);
     st[cur]=max(st[c1],st[c2]);
}

void query_tree(int cur,int s,int e,int l,int r)
{
     if(l>=e || r<=s)
     {
          qt[cur]=0;
          return;
     }
     if(s>=l && r>=e)
     {
          qt[cur]=st[cur];
          return;
     }
     int c1=2*cur,c2=c1+1,m=(s+e)>>1;
     query_tree(c1,s,m,l,r);
     query_tree(c2,m,e,l,r);
     qt[cur]=max(qt[c1],qt[c2]);
}

int32_t main()
{
     IOS;
     
     int n;
     cin>>n;
     for(int i=1;i<=n;i++)
          cin>>h[i];
     for(int i=1;i<=n;i++)
          cin>>a[i];
     int ans=0;     
     for(int i=1;i<=n;i++)
     {
          query_tree(1,1,n+1,1,h[i]);
          int temp=qt[1];
          temp+=a[i];
          ans=max(ans,temp);
          update_tree(1,1,n+1,h[i],temp);
     }
     cout<<ans;
     return 0;
}


Measured memory_bytes: 14592