akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

int main() {
    /*int a,b,h,s;
    cin >> a >> b >> h;
    
    s=(a+b)*h/2;
    
    cout << s << endl;*/
    
    /*int N,A,B;
    cin >> N >> A;
    B=N*N-A;
    
    cout << B << endl;*/
    
   /* int A,B,C,D,s1,s2;
    cin >> A >> B >> C >> D;
    
    s1=A*B;
    s2=C*D;
    
    if(s1>s2){
        cout << s1 << endl;
    }
    else if(s1<s2){
        cout << s2 << endl;
    }
    else{
        cout << s1 << endl;
    }*/
    
   /* int a,b,c,s;
    cin >> a >> b >> c;
    
    s=0;
    if(a!=b){
        s=s+1;
    }
    if(a!=c){
        s=s+1;
    }
    if(b!=c){
        s=s+1;
    }
    if(a==b&&a==c&&b==c){
        s++;
    }
    cout << s << endl;*/
    
    /*int N,K,X,Y,s;
    cin >> N >> K >> X >> Y;
    
    if(N>K){
        s=K*X+Y*(N-K);
    }
    
    
    
    else if(N<=K){
        s=N*X;
    }
    
    cout << s << endl;*/
    
   /* long long N,A[200000],B[200000],s;
    cin >> N;
    
    int i = 0;
    while(i<N){
        cin >> A[i] >> B[i];
        i++;
    }
    
    i=0;
    while(i
    <N){
        s=A[i]*B[i];
        i++;
        cout << s << endl;
    }*/
    
    /* N,A,B,ans;
    cin >> N;
    
    for(int i=0;i<N;i++){
        
    }*/

    /*int N,L,maxL,sumL;
    cin >> N;
    
    maxL=0;
    sumL=0;
    for(int i=0;i<N; i++){
        cin >> L;
        maxL=max(L,maxL);
        sumL+=L;
    }
    if(maxL<sumL-maxL){
        cout << "Yes" << endl;
    }
    else if(maxL>=sumL-maxL){
        cout << "No" << endl;
    }*/
    
    /*int N,H;
    cin >> N;
    
    int u=0;
    int maxh=0;
    for(int i=0; i<N;i++){
        cin >> H;
        if(H>=maxh){
            u++;
        }
    
        maxh=max(maxh,H);
        
    }
        
    cout << u << endl;*/
    
    int N;
    cin >> N;
    
    int V[20];
    int i=0;
    while(i<N){
        cin >> V[i];
        i++;
        
    }
    int C[20];
    i=0;
    while(i<N){
        cin >> C[i];
        i++;
    }
    
    int answer = 0;
    i=0;
    while(i<N){
        if(V[i]>C[i]){
            answer=answer+V[i]-C[i];
            
        }
        i++;
    }
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.insert(n,0)
a.insert(0,0)
sum = 0
for i in range(n+1):
    sum += abs(a[i+1] -a[i])
for i in range(n):
    print(sum - abs(a[i+1] - a[i]) - abs(a[i+2] - a[i+1]) + abs(a[i+2] - a[i]))

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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='1'){
      count++;
    }
  }
  cout<<2*min(count,N-count)<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
 
int main(void) {
	char str[102][102], temp[102];
	int N, L, i;
	scanf("%d %d", &N, &L);
	gets(temp);
	for (L = 0;L < N;L++)
		gets(str[L]);
	for (L = 0;L < N-1;L++) {
		for (i = 0;i < N - 1;i++) {
			if (strcmp(str[i], str[i + 1]) > 0) {
				strcpy(temp, str[i]);
				strcpy(str[i], str[i + 1]);
				strcpy(str[i + 1], temp);
			}
		}
 
	}
	for (i = 0;i < N;i++)
		printf("%s", str[i]);
	return 0;
 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100007
#define MOD 1000000007
#define MODL 1000000007LL
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

// Trace dinâmico
template<typename T>
void trace(T a) { cout << a << "\n"; }
template<typename T, typename... Args>
void trace(T a, Args... args) { cout << a << " "; trace(args...); }

// Debugador de recursão
int recNum = 0;
void prTabs() { for (int ii = 0; ii < recNum; ++ii) cout << "    "; }
template<typename... Args>
void recInit(Args... args) { prTabs(); trace("rec(", args..., ")"); recNum++; }
template<typename T>
void recEnd(T a) { prTabs(); trace("->", a); recNum--;}

int MD(int x) {
	if(x < 0) return x+MOD;
	if(x >= MOD) return x-MOD;
	return x;
}

ll MDL(ll x) {
	return (x%MODL+MODL)%MODL;
}

ll modpow(ll a, ll b, ll m) {
	if (!b) return 1LL;
	if (b&1LL) return a*modpow(a, b-1, m)%m;
	ll r = modpow(a, b>>1, m);
	return r*r%m;
}

//m prime
ll invmod(ll a , ll m) {
	return modpow(a, m-2, m);
}



int n, t, a, b, c;
int main(){
	sc("%d", &n);
	if (n >= 30) pr("Yes\n");
	else pr("No\n");
 	return 0;
}


Measured memory_bytes: 3760
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    X = list(map(int,input().split()))

    dp = [0] * 101

    for i in range(101):
        for j in range(N):
            dp[i] += (X[j] - i) ** 2

    res = min(dp)

    print(res)



main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		v.push_back(t);
	}	

	vector<vector<vector<int> > > vvv (k + 1, vector<vector<int> > (n + 1, vector<int> (n + 1, -0x3f3f3f3f)));
	

	int res = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < n; j++) {
			for (int l = j + 1; l <= n; l++) {
				if (i == 0 && (j > 0 || l < n))
					continue;
				if (i == 0) {
					vvv[i][j][l] = 0;
				}
				if (v[j] >= 0) {
					vvv[i+1][j+1][l] = max(vvv[i+1][j+1][l], vvv[i][j][l] + v[j]);
				}
				else {
					vvv[i+1][j+1][l] = max(vvv[i+1][j+1][l], vvv[i][j][l] + v[j]);
					if (i + 2 <= k) 
						vvv[i+2][j+1][l] = max(vvv[i+2][j+1][l], vvv[i][j][l]);		

				}
				res = max(res, vvv[i+1][j+1][l]);
				if (v[l - 1] >= 0) {
					vvv[i+1][j][l-1] = max(vvv[i+1][j][l-1], vvv[i][j][l] + v[l - 1]);
				}
				else {
					vvv[i+1][j][l-1] = max(vvv[i+1][j][l-1], vvv[i][j][l] + v[l - 1]);
					if (i + 2 <= k)
						vvv[i+2][j][l-1] = max(vvv[i+2][j][l-1], vvv[i][j][l]);
				}
				res = max(res, vvv[i+1][j][l-1]);
			}
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 1536
n=int(input())
d=[]
for i in range(n):
    a,b,c=map(int,input().split())
    d.append((a,b,c))
    if c!=0:
        x,y,h=a,b,c

for i in range(101):
    for j in range(101):
        p=abs(i-x)+abs(j-y)+h
        for a,b,c in d:
            if (c==0 and p-abs(i-a)-abs(j-b)<1) or (c==(p-abs(i-a)-abs(j-b))):
                pass
            else:
                p=-1
                break
        if p!=-1:
            print(i,j,p)
            exit()

Measured memory_bytes: 41584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

struct Edge {
	int u, v;
	int cap, flow;

	Edge(int u_, int v_, int flow_, int cap_) {
		u = u_;
		v = v_;
		cap = cap_;
		flow = flow_;
	}
};

const int INF = 1e9 + 239;	

namespace Flow {
	const int MAX_LOG = 40;

	int n;
	int start;
	int end;

	vector<int> d;
	vector<int> pnt;

	vector<Edge> ed;
	vector<vector<int>> g;

	int dfs(int u, int flow) {
		if (flow == 0) {
			return 0;
		}
		if (u == end) {
			return flow;
		}
		for (; pnt[u] < (int)g[u].size(); pnt[u]++) {
			int ind = g[u][pnt[u]];
			int to = ed[ind].v;
			if (d[to] < d[u] + 1) {
				continue;
			}
			int pushed = dfs(to, min(flow, ed[ind].cap - ed[ind].flow));
			if (pushed > 0) {
				ed[ind].flow += pushed;
				ed[ind ^ 1].flow -= pushed;
				return pushed;
			}
		}
		return 0;
	}

	bool bfs(int lim) {
		for (int i = 0; i < n; i++) {
			d[i] = INF;
		}
		d[start] = 0;
		queue<int> q;
		q.push(start);
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (auto ind : g[u]) {
				int to = ed[ind].v;
				if (d[to] > d[u] + 1 && ed[ind].flow + lim <= ed[ind].cap) {
					d[to] = d[u] + 1;
					q.push(to);
				}
			}
		}
		return d[end] != INF;
	}

	void init() {
		pnt.resize(n, false);
		d.resize(n);
		g.resize(n);
	}

	int solve() {
		int ans = 0;
		int cur = (1LL << MAX_LOG);
		for (int i = 0; i < MAX_LOG; i++) {
			cur /= 2;
			while (bfs(cur)) {
				fill(pnt.begin(), pnt.end(), 0);
				while (true) {
					int nw = dfs(start, INF);
					ans += nw;
					if (nw == 0) {
						break;
					}
				}
			}
		}
		return ans;
	}

	void add_edge(int u, int v, int c) {
		int pnt = (int)ed.size();
		ed.push_back(Edge(u, v, 0, c));
		ed.push_back(Edge(v, u, 0, c));
		g[u].push_back(pnt);
		g[v].push_back(pnt + 1);
	}
} // namespace Flow

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

	int n, m;
	cin >> n >> m;
	Flow::n = n + m + 2;
	Flow::start = n + m;
	Flow::end = n + m + 1;
	Flow::init();
	int is = -1;
	int js = -1;
	int it = -1;
	int jt = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			if (c == '.') {

			} else if (c == 'o') {
				Flow::add_edge(i, j + n, 1);
			} else if (c == 'S') {
				is = i;
				js = j;
			} else if (c == 'T') {
				it = i;
				jt = j;
			}
		}
	}
	if (is == it || js == jt) {
		cout << -1 << endl;
		return 0;
	}
	Flow::add_edge(Flow::start, is, INF);
	Flow::add_edge(Flow::start, js + n, INF);
	Flow::add_edge(Flow::end, it, INF);
	Flow::add_edge(Flow::end, jt + n, INF);
	int ans = Flow::solve(); 
	cout << ans << endl;
}


Measured memory_bytes: 1528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int count = 0;

		char word = 'a';
		String input = "";

		int[] countList = new int[26];

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			while (sc.hasNext()) {

			input = sc.nextLine();

				//?°????????????????
				input = input.toLowerCase();

				if (input != null) {

					//??¢?????????????????????????´¢
					char[] check = input.toCharArray();
					for (int i = 0; i < 26; i++) {

						for (int j = 0; j < check.length; j++) {
							if ((int)check[j] == (int)word) {
								count++;
							}
						}
						countList[i] += count;
						count = 0;
						word++;
					}
					word = 'a';
				}
			}
			//????????????
			word = 'a';
			for (int i = 0; i < countList.length; i++) {

				System.out.println(word + " : " + countList[i]);
				word++;
			}

		}finally {
			sc.close();
		}
	}

}

Measured memory_bytes: 26052
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <iterator>
#include <utility>

namespace n91 {

void main_() {
  const auto n = scan<usize>();
  std::vector<u32> a;
  a.reserve(n);
  std::copy_n(std::istream_iterator<u32>(std::cin), n, std::back_inserter(a));

  const auto itr0 = std::max_element(a.begin(), a.end());
  const auto max0 = *itr0;
  *itr0 = static_cast<u32>(0);
  const auto itr1 = std::max_element(a.begin(), a.end());
  *itr0 = max0;
  const auto max1 = *itr1;

  for (const auto e : a) {
    if (e != max0) {
      std::cout << max0;
    } else {
      std::cout << max1;
    }
    std::cout << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 3200
n, m = map(int, input().split())
INF = 10 ** 5 * 12
dp = [INF] * (1 << n)
dp[0] = 0
keys = []

for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a])

for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost)

ans = dp[-1] if dp[-1] != INF else -1
print(ans)


Measured memory_bytes: 45672
from sys import stdin, setrecursionlimit, stdout
#setrecursionlimit(1000000)
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline().rstrip()
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############
a=set()
for _ in range(ii()):
    a.add(si())
print(len(a))

Measured memory_bytes: 31308
from collections import Counter

N=int(input())
S=input()

c=Counter(S+'RGB')
ans = (c['R']-1)*(c['G']-1)*(c['B']-1)

max_d = (N-3)//2+1

for d in range(1,max_d+1):
  for i in range(N-2):
    j = i+d
    k = j+d
    if k > N-1:break
    if len(set([S[i],S[j],S[k]]))==3:
      ans -= 1
      
print(ans)

Measured memory_bytes: 74628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, r;
    cin >> n >> r;
    if (n < 10) r += 100 * (10 - n);
    cout << r << endl;
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int N, M;
pair<int, int> p[100005];

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

    cin >> N >> M;
    rep(i, M) cin >> p[i].second >> p[i].first;
    sort(p, p+M);

    int ans = 1, cut = p[0].first;
    FOR(i, 1, M){
        if(cut <= p[i].second){
            ans++;
            cut = p[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#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 ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 9;
int n, k;
int a[N];
int b[N];

VI d(int x)
{
	VI res;
	for(int i = 1; i * i <= x; ++i)
		if (x % i == 0)
		{
			res.PB(i);
			if (i * i < x)
				res.PB(x / i);
		}
		
	sort(ALL(res));
	reverse(ALL(res));
	return res;
}

bool can(int x)
{
	FOR(i, 0, n)
		b[i] = a[i] % x;
	
	sort(b, b + n);
	bool ok = 0;
	
	FOR(i, 0, n + 1)
	{
		LL l = 0, r = 0;
		FOR(j, 0, i)
			l += b[j];
		FOR(j, i, n)
			r += x - b[j];
			
		ok |= max(l, r) <= k;
	}
		
	return ok;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n >> k;
	int s = 0;
	FOR(i, 0, n)
	{
		cin >> a[i];
		s += a[i];
	}
	
	VI div = d(s);
	for(auto i: div)
		if (can(i))
		{
			cout << i;
			return 0;
		}
	
	assert(0);
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
struct side{
	int from,to,next;
}a[400010];
int sidecnt=0,head[100010]={},dis[100010]={},fa[100010]={};
void add(int x,int y){
	++sidecnt;
	a[sidecnt].from=x;
	a[sidecnt].to=y;
	a[sidecnt].next=head[x];
	head[x]=sidecnt;
}

bool vis[100010]={};
int n,m;
queue<int> q;

int main(){
	cin>>n>>m;
	int i,x,y;
	for(i=1;i<=m;++i){
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	q.push(1);
	vis[1]=1;
	while(!q.empty()){
		x=q.front();
		//cout<<x<<"**\n";
		q.pop();
		for(i=head[x];i!=0;i=a[i].next){
			y=a[i].to;
			if(!vis[y]){
				dis[y]=dis[x]+1;
				vis[y]=1;
				q.push(y);
				fa[y]=x;
			}
			
		}
	}
	for(i=2;i<=n;++i){
		if(dis[i]==0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(i=2;i<=n;++i)
		cout<<fa[i]<<"\n";
	return 0;
}

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

bool is_prime[115000];
vector<int> primes;

void calc_prime(int n){
	for(int i = 0; i <= n; ++i)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	
	for(int i = 2; i <= n; ++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}

int main() {
	int n, p;
	calc_prime(110000);
	while(cin >> n >> p && (n != -1 && p != -1)){
		p--;
		vector<int> data;
		auto idx = upper_bound(primes.begin(), primes.end(), n) - primes.begin();
		for(int i = idx; i < idx + 50 && i < primes.size(); ++i){
			for(int j = i; j < idx + 50 && j < primes.size(); ++j){
				data.push_back(primes[i] + primes[j]);
			}
		}
		sort(data.begin(), data.end());
		cout << data[p] << endl;
	}
	return 0;
}

Measured memory_bytes: 1436
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    scanf("%d%d",&a,&b);
    if(a>0)
    return printf("Positive")&0;
    if(a==0||(a<0&&b>0))
    return printf("Zero")&0;
    if((abs(b)-abs(a))%2!=0)
    return printf("Positive")&0;
    printf("Negative");
    return 0;
}

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

def dfs(s): #文字列sで始まる個数
  if int(s) > n:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in "753") else 0
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0'))
  



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

int main() {
  ll x;
  cin >> x;
  
  ll n = x/11;
  ll m = x%11;
  
  ll res = n * 2;
  if(m != 0){
    if(m <= 6){
      ++res;
    }else{
      res += 2;
    }
  }
  
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> P(N),C(N);
    rep(i,N){cin>>P.at(i);P.at(i)--;}
    rep(i,N)cin>>C.at(i);
    vector<vector<ll>> point(N,vector<ll>(0));
    rep(i,N){
        int now=i;
        ll sum=0;
        
        while(1){
            now=P.at(now);
            sum+=C.at(now);
            point.at(i).pb(sum);
            if(now==i)break;
        }
    }

/*rep(i,N){
    rep(j,sz(point.at(i))){
        cout<<point.at(i).at(j)<<" ";
    }
    cout<<endl;
}*/

    ll ans=-1e18;
    rep(i,N){
        if(K<=sz(point.at(i))){
            rep(j,K){
                chmax(ans,point.at(i).at(j));
            }
        }
        if(K>sz(point.at(i))){
            if(point.at(i).at(sz(point.at(i))-1)>0){
                ll x=K/sz(point.at(i)),y=K%sz(point.at(i));
                ll now=point.at(i).at(sz(point.at(i))-1)*(x-1);
                rep(j,sz(point.at(i))){
                    chmax(ans,now+point.at(i).at(j));
                }
                now+=point.at(i).at(sz(point.at(i))-1);
                rep(j,y){
                    chmax(ans,now+point.at(i).at(j));
                }
            }
            else{
                rep(j,sz(point.at(i))){
                    chmax(ans,point.at(i).at(j));
                }
            }
            /*rep(j,sz(point.at(i))){
                chmax(ans,point.at(i).at(j));
            }
            if(point.at(i).at(sz(point.at(i))-1)>0){
                ll x=K/sz(point.at(i)),y=K%sz(point.at(i));
                ll now=0;
                now+=point.at(i).at(sz(point.at(i))-1)*x;
                ll na=now;
                rep(ii,y){
                    chmax(na,now+point.at(i).at(ii));
                }
                chmax(ans,na);
                na=point.at(i).at(sz(point.at(i))-1)*(x-1);
                rep(ii,sz(point.at(i))){
                    chmax(na,now+point.at(i).at(ii));
                }
                chmax(ans,na);
            }*/
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  ll a, b;
  cin >> a >> b;

  for (ll x = 0; x <= 10000; x++) {
    if (ll(x * 0.08) == a && ll(x * 0.1) == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll arr[n] = {0};
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	ll sfx[n];
	for (int i = n - 1; i >= 0; i--)
	{
		if (i == n - 1)
			sfx[i] = arr[n - 1];
		else
		{sfx[i] = sfx[i + 1] + arr[i]; sfx[i] %= mod;}
	}
	ll ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		ll ans1 = arr[i] * sfx[i + 1];
		ans1 %= mod;
		ans += ans1;
		ans %= mod;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 6772
from operator import itemgetter
n,m = map(int, input().split())
input_list = []
for _ in range(n):
    i,j = map(int, input().split())
    d = {'price': i, 'amount': j}
    input_list.append(d)

total = 0
target = m
sorted_list = sorted(input_list, key=itemgetter('price'))
for dic in sorted_list:
    price = dic['price']
    amount = dic['amount']
    if target <= amount:
        total += target*price
        break
    else:
        total += amount*price
        target -= amount
print(total)

Measured memory_bytes: 42332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int s,w;
    cin>>s>>w;
    if(w>=s)fin("unsafe");
    else fin("safe");
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    seen.assign(n, false);  // 初期化
    int cnt = 0; 
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++; // dfsした回数をカウント
        }
    }
    cout << cnt-1 << endl;
    return 0;
}

Measured memory_bytes: 9596
n = int(input())
s = input()
cum_sum = [0 for _ in range(n)]

for i in range(n):
    if s[i] == '#':
        cum_sum[i] += 1

for i in range(n-1):
    cum_sum[i+1] += cum_sum[i]

#print(cum_sum)

ans = 10 ** 10
for i in range(n):
    tmp = 2 * cum_sum[i] + n - i - 1 - cum_sum[n-1]
    #print(ans, tmp)
    if ans > tmp:
        ans = tmp

tmp = n - cum_sum[n-1]
if ans > tmp:
    ans = tmp

if n == 1:
    print(0)
elif n == cum_sum[-1]:
    print(0)
else:
    print(ans)

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

int main(void)
{
	int n;
	cin >> n;
	long long sum = 0;
	int min = 1000000000, max = -1000000000;
	for (int i = 0; i < n; i++)
	{
		int x;
	    cin >> x;
		sum += x;
		if (min > x) min = x;
		if (max < x) max = x;
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3124
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd,numbers)

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(a,b,c)
print(sum)



Measured memory_bytes: 69892
import java.util.*;

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

	int n = sc.nextInt();

	while(n!=0){
	    double[] x = new double[4];
	    double[] y = new double[4];
	    for(int i=0; i<x.length; i++){
		x[i] = sc.nextDouble();
		y[i] = sc.nextDouble();
	    }

	    x[1] -= x[0];
	    y[1] -= y[0];
	    x[3] -= x[2];
	    y[3] -= y[2];
	    String ans = "NO";
	    if(x[1]*y[3]-x[3]*y[1]==0){ans = "YES";}

	    System.out.println(ans);
	    n--;
	}
    }
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <functional>

int main() {
  for(int tci = 0; ; ++tci) {
    int n, k; scanf("%d%d", &n, &k);
    if(n == 0) break;
    int cards[10];
    for(int i = 0; i < n; ++i) {
      scanf("%d", &cards[i]);
    }
    bool selected[10];
    std::fill_n(selected, n, false);
    int nums[10000], nums_size = 0;
    std::function<void(int, int)> search = [&](int depth, int num) {
      if(depth <= 0) {
        nums[nums_size++] = num;
      } else {
        for(int i = 0; i < n; ++i) {
          if(selected[i]) continue;
          selected[i] = true;
          search(depth - 1, num * (cards[i] < 10 ? 10 : 100) + cards[i]);
          selected[i] = false;
        }
      }
    };
    search(k, 0);
    std::sort(nums, nums + nums_size);
    nums_size = std::unique(nums, nums + nums_size) - nums;
    printf("%d\n", nums_size);
  }
  return 0;
}

Measured memory_bytes: 1060
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w; rd(h, w);
  int[char] cnt;
  for(char c='a'; c<='z'; c++) cnt[c]=0;
  foreach(_; 0..h){
    auto s=readln.chomp;
    foreach(char c; s) cnt[c]++;
  }

  auto a=new int[](0);
  foreach(v; cnt.values){
    if(v) a~=v;
  }
  sort(a);
  // writeln(a);

  auto b=new int[](0);
  auto y=(h+1)/2, x=(w+1)/2;
  foreach(i; 0..y)foreach(j; 0..x){
    if(i+1!=y && j+1!=x) b~=4;
    else if(i+1==y && j+1==x){
      if(h%2==0 && w%2==0) b~=4;
      else if(h%2 && w%2) b~=1;
      else b~=2;
    }else if(i+1==y) b~=(h%2==0 ? 4 : 2);
    else b~=(w%2==0 ? 4 : 2);
  }
  sort!("a>b")(b);
  // writeln(b);

  const inf=to!int(1e8);
  foreach(ref e; a){
    foreach(ref e2; b){
      if(e2<=e) e-=e2, e2=inf;
    }
  }

  // writeln(a);
  // writeln(b);

  int sm=reduce!("a+b")(a);
  if(sm==0){
    foreach(e; b) assert(e==inf);
    writeln("Yes");
  }else{
    writeln("No");
  }

  
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int X;
    cin >> X;
    if(X <= 99){
        cout << 0 << "\n";
        return 0;
    }
    
    int count = X/100;
    int target = X%100;
    
    for(int i = 0; i < count; i++){
        if(target <= 5){
            cout << 1 << "\n";
            return 0;
        }
        target -= 5;
    }
    
    cout << 0 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,k;
  cin >> n >> k;
  
  int lis[n]={0};
  
  int d,a;
  rep(i,k){
    cin >> d;
    rep(j,d){
      cin >> a;
      lis[a-1]++;
    }
  }
  
  int ans = 0;
  rep(i,n){
    if(lis[i]==0)ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio> 
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof
 
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

pair<double, double> solve_eq(int a, int b, int c, int d, int e, int f)
{
  double x = double(b*f - c*e)/double(b*d - a*e);
  double y = double(c - a*x)/double(b);

  if (abs(y) < 0.001)
    y = 0;

  if (abs(x) < 0.001)
    x = 0;

  return pair<double, double>(x, y);
}

int main(int argc, char **argv)
{
  int a, b, c, d, e, f;

  cout.setf(ios::fixed);
  cout.precision(3);
  while (cin >> a >> b >> c >> d >> e >> f) {
    pair<double, double> p;
    p = solve_eq(a, b, c, d, e, f);
    cout << p.first << " " << p.second << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n,k;
signed main(){
    cin>>n>>k;
    vector<int>a;
    rep(i,0,n){
        int b;cin>>b;a.push_back(b);
    }
    sort(a.begin(),a.end());
    int ans=n;
    int t=0;
    for(int i=n-1;i>=0;i--){
        if(t+a[i]<k)t+=a[i];
        else ans=min(ans,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll N,T; scanf("%lld %lld",&N,&T);
    vector<ll> t(N); rep(i,N) scanf("%lld",&t[i]);

    ll ans = T;
    for(int i=0;i<N-1;i++){
        ans += min(T,t[i+1]-t[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner

import scala.collection.mutable


object Main {

  case class ResidueRing(private val input: Long) {
    val representative: Long = ((input % ResidueRing.mod) + ResidueRing.mod) % ResidueRing.mod

    def +(that: ResidueRing): ResidueRing = ResidueRing(this.representative + that.representative)

    def -(that: ResidueRing): ResidueRing = ResidueRing(this.representative - that.representative)

    def *(that: ResidueRing): ResidueRing = ResidueRing(this.representative * that.representative)

    def unary_- : ResidueRing = ResidueRing(-this.representative)

  }

  object ResidueRing {
    val mod: Long = (1e9 + 7).toLong
    val _0: ResidueRing = ResidueRing(0)
    val _1: ResidueRing = ResidueRing(1)
  }


  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    n
  }


  def solve(n: Int): Long = {
    // 過去3文字分記憶しておけばいい
    val alphabets = "ATGC"
    val stateList: IndexedSeq[String] =
      for (c1 <- alphabets;
           c2 <- alphabets;
           c3 <- alphabets) yield IndexedSeq(c1, c2, c3).mkString


    val regex = """.AGC|.GAC|.ACG|A.GC|AG.C""".r // コンパイルされる。
    def transition(state: String, alphabet: Char): Option[String] = {
      /*
      (state(0), state(1), state(2), alphabet) match {
        case (_, 'A', 'G', 'C')
             | (_, 'G', 'A', 'C')
             | (_, 'A', 'C', 'G')
             | ('A', _, 'G', 'C')
             | ('A', 'G', _, 'C') => None
        case _ => Some(IndexedSeq(state(1), state(2), alphabet).mkString)
      }
      */
      if (regex.findFirstIn(state + alphabet).nonEmpty) None
      else Some(state.tail + alphabet)
    }

    val mapAll0: mutable.Map[String, ResidueRing] = mutable.Map.empty
    for (state <- stateList) {
      mapAll0.+=((state, ResidueRing._0))
    }
    val dp: Array[mutable.Map[String, ResidueRing]] = Array.fill(n + 1)(mapAll0.clone)

    dp(0)("TTT") += ResidueRing._1
    for (i <- 0 until n) {
      for (state <- stateList) {
        for (alphabet <- alphabets) {
          val next = transition(state, alphabet)
          next match {
            case Some(nextState) => dp(i + 1)(nextState) += dp(i)(state)
            case None =>
          }

        }
      }
    }
    val result = dp.last.values.foldLeft(ResidueRing._0)(_ + _)
    result.representative
  }


  def main(args: Array[String]): Unit = {
    val n = read()
    println(solve(n))
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int DP[100100];

int main(){
    int N, M;
    cin >> N >> M;
    set<int> A;
    REP(i,M){
        int a;
        cin >> a;
        //a--;
        A.insert(a);
    }

    ll ans = 0;

    DP[0] = 1;
    for(int i = 0; i < N; i++){
        if(A.find(i+1) == A.end()){
            DP[i+1] += DP[i];
            DP[i+1] %= MOD;
        }
        if(A.find(i+2) == A.end()){
            DP[i+2] += DP[i];
            DP[i+2] %= MOD;
        }
    }


    ans = DP[N];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int num[200000];
bool cmp(int x,int y){
    return x > y;
}
int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n;i++){
        scanf("%d", &num[i]);
    }
    long long ans = 0;
    sort(num, num + n, cmp);
    int k = 2;
    ans +=(long long) num[0];
    int i = 0;
    while(k<n){
        if(k%2==0)
            i++;
        ans += (long long)num[i];
        k++;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 4628
# https://atcoder.jp/contests/abc117/tasks/abc117_d
=begin
3 7
1 6 3

14

4 9
7 4 0 3

46

1 0
1000000000000

1000000000000
=end
N, upper_bit = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
beki_ary = (1..39).to_a.each_with_object([1]) { |_i, obj| obj << (obj[-1] * 2)}
already_min = false

ans = 0
39.step(0, -1) do |digest|
  ones = A.count { |str| str[digest] == 1 }
  if ones * 2 >= N
    already_min ||= (upper_bit[digest] == 1)
    ans += beki_ary[digest] * ones
  else
    if already_min || (upper_bit[digest] == 1)
      ans += beki_ary[digest] * (N - ones)
    else
      ans += beki_ary[digest] * ones
    end
  end
end
p ans


Measured memory_bytes: 10788
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<set>
#include<vector>
#include<bitset>
#include<map>
#define N 100005
#define ll long long
#define oo 100000000
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,a[N],p[4];
int main(){
	n=read();For(i,1,n) a[i]=read();
	For(i,1,n){
		if(a[i]%4==0) p[0]++;
		else if(a[i]%2==0) p[1]++;
		else p[2]++;
	}
	if(p[1]==0){
		if(p[0]+1>=p[2]) puts("Yes");
		else puts("No");
	}else{
		if(p[0]>=p[2]) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main() {
  int n;
  long double d,x,y;
  cin >> n >> d;
  int ans = 0;

  rep(i,n) {
    cin >> x >> y;
    ans += (d*d >= x*x + y*y);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"

using namespace std;

int main() {
	string s;
	cin >> s;
	string tmp = "";
	set<string> se;
	for(int i = s.length() - 1; i >= 0; --i){
        tmp += s[i];
        if(tmp == "maerd" || tmp == "remaerd" || tmp == "esare" || tmp == "resare"){
            reverse(tmp.begin(), tmp.end());
            se.insert(tmp);
            tmp = "";
        }
	}
	if(tmp.length() == 0 && s.size() >= 1)cout << "YES";
	else cout << "NO";
	return 0;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			String s = sc.nextLine();
			if (s.equals("#")) break;

			String[] cs = s.split("\\|");
			boolean sat = false;
			for (String c : cs)
			{
				if (isSat(c))
				{
					sat = true;
					break;
				}
			}
			System.out.println(sat ? "yes" : "no");
		}
	}

	static boolean isSat(String c)
	{
		String[] ls = c.substring(1, c.length() - 1).split("&");
		return !isContradist(ls[0], ls[1]) && !isContradist(ls[1], ls[2]) && !isContradist(ls[0], ls[2]);
	}

	static boolean isContradist(String l1, String l2)
	{
		int v1 = l1.charAt(l1.length() - 1);
		if (l1.charAt(0) == '~') v1 = -v1;
		int v2 = l2.charAt(l2.length() - 1);
		if (l2.charAt(0) == '~') v2 = -v2;
		return v1 + v2 == 0;
	}
}

Measured memory_bytes: 48612
#include <iostream>
#include <string>
#include <algorithm>

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define FOR(i, n) for(int i = 0; i < (n); i++)

int main()
{
    using namespace std;

    int k, s;

    cin >> k >> s;

    int ans = 0;

    FOR(x, k + 1)
    {
        FOR(y, k + 1)
        {
            if(x + y <= s && x + y + k >= s)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

//using namespace std;
struct Move{
  int bx;
  int by;
  int ax;
  int ay;
  Move(int x, int y, int x1, int y1){
    bx = x; by = y; ax = x1; ay = y1;
  }
};

int main(){
  int W, H, a, oddNum=0, preLastOddIndex = -1;
  int oddIndex[500];
  std::vector<Move> moves;

  std::cin >> H >> W;
  for(int i=0; i<H; i++, oddNum = 0){
    for(int j=0; j<W; j++){
      std::cin >> a;
      if(j == preLastOddIndex){
        a++;
        preLastOddIndex = -1;
      }
      if(a%2){//odd
        oddIndex[oddNum] = j;
        oddNum++;
      }
    }

    if(oddNum % 2 && i != H-1){//sum is odd
      preLastOddIndex = oddIndex[oddNum-1];
      oddNum--;
      moves.push_back( Move(preLastOddIndex, i, preLastOddIndex, i+1) );
    }
    for(int j=0; j < oddNum; j+=2){
      //      if(oddNum - j == 1)
      //        break;
      for(int k = oddIndex[j]; k < oddIndex[j+1]; k++)
        moves.push_back(Move(k,i,k+1,i));
    }
  }

  std::cout << moves.size() << std::endl;
  for(int i = 0; i < (int)moves.size(); i++)//YとX逆
    std::cout << moves[i].by+1 <<" "<< moves[i].bx+1 <<" "<< moves[i].ay+1 <<" "<< moves[i].ax+1 << std::endl;
  //printf("%d %d %d %d\n", moves[i].by+1, moves[i].bx+1, moves[i].ay+1, moves[i].ax+1);

  return 0;
}


Measured memory_bytes: 4208
#include <stdio.h>
#include <string.h>

int main(){
    int i,count=0;
    char a[5];
    
    scanf("%s",a);
    
    for(i=0;i<3;i++){
        if(a[i]=='1'){
            count++;
        }
    }
    
    printf("%d\n",count);
    
    return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

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

  int a, b, c; cin >> a >> b >> c;
  
  if (a == b) cout << c << endl;
  else if (b == c) cout << a << endl;
  else cout << b << endl;
  
  return (0);
}

Measured memory_bytes: 3652
import math
def resolve():
    A,B,H,M=map(int, input().split()) 
    Arad = (M%60)*6
    Brad = (H%12)*30+(M/60)*30
    c2 = A**2+B**2-2*A*B*math.cos(math.radians(Arad-Brad))
    c = math.sqrt(c2)
    print(c)
resolve()

Measured memory_bytes: 9440