akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vec<int> a(n);rep(i,n)cin >> a[i];
    //まずsetとして互いに素か否かの判定
    int g=a[0];
    rep2(i,1,n)g=__gcd(a[i],g);
    if(g!=1){
        cout << "not coprime" << endl;
        return 0;
    }

    vec<bool> pri(1001,true);
    pri[0]=false;
    pri[1]=false;
    rep2(i,2,1001){
        if(pri[i]){
            for(int j=2*i;j<=1000;j+=i)pri[j]=false;
        }
    }
    vec<int> primes;
    rep(i,1001){
        if(!pri[i])continue;
        primes.emplace_back(i);
    }
    map<int,int> ans;
    rep(i,n){
        rep(j,primes.size()){
            if(primes[j]*primes[j]>a[i])break;
            if(a[i]%primes[j]==0){
                ans[primes[j]]++;
                if(ans[primes[j]]>=2){
                    cout << "setwise coprime" << endl;return 0;
                }
                while(!(a[i]%primes[j]))a[i]/=primes[j];
            }
        }
        if(a[i]!=1){
            ans[a[i]]++;
            if(ans[a[i]]>=2){
                cout << "setwise coprime" << endl;return 0;
            }
        }
    }
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 7304
#include<bits/stdc++.h>
using namespace std;
int main()
{
	printf("33854\n");
	printf("+ 0 1 10000\n");
	printf("< 2 10000 10000\n");
	for(int i=1;i<=30;i++) printf("+ %d %d %d\n",9999+i,9999+i,10000+i);
	for(int i=30;i>=0;i--)
	{
		printf("+ 3 6 4\n");
		for(int j=0;j<i;j++) printf("+ 4 %d 4\n",10000+j);
		printf("< 4 0 %d\n",20000+i);
		printf("< 4 0 5\n");
		for(int j=1;j<=i;j++) printf("+ 5 5 5\n");
		printf("+ 3 5 3\n");
	}
	printf("+ 6 6 3\n");
	for(int i=30;i>=0;i--)
	{
		printf("+ 3 6 4\n");
		for(int j=0;j<i;j++) printf("+ 4 %d 4\n",10000+j);
		printf("< 4 1 %d\n",30000+i);
		printf("< 4 1 5\n");
		for(int j=1;j<=i;j++) printf("+ 5 5 5\n");
		printf("+ 3 5 3\n");
	}
	for(int i=0;i<=30;i++)
	{
		for(int j=0;j<=30;j++)
		{
			printf("+ %d %d 3\n",20000+i,30000+j);
			printf("< 10000 3 3\n");
			for(int k=1;k<=i+j;k++) printf("+ 3 3 3\n");
			printf("+ 2 3 2\n");
		}
	}
    return 0;
}

Measured memory_bytes: 3720
import glob


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\158\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        S = self.input_data().split()[0]
        Q = int(self.input_data())
        query = []

        zengo = True
        add_first = ""
        add_last = ""

        for i in range(Q):
            tmp = [j for j in self.input_data().split()]
            if tmp[0] == "1":
                query.append([1])
            else:
                query.append([2, int(tmp[1]), tmp[2]])

        for q in query:
            if q[0] == 1:
                zengo = not zengo
            else:
                if zengo:
                    if q[1] == 1:
                        add_first = q[2] + add_first
                    else:
                        add_last = add_last + q[2]
                else:
                    if q[1] == 2:
                        add_first = q[2] + add_first
                    else:
                        add_last = add_last + q[2]

        result = add_first + S + add_last
        if zengo:
            print(result)
        else:
            print(result[::-1])




solver = Solver(REL_PATH)
solver.exec_resolve()


Measured memory_bytes: 25832
#include<stdio.h>
int main (){

    long long int berapaKali;
    scanf("%lld", &berapaKali);
    long long int a1[berapaKali];
    long long int a2 = 1;
    long long int max = 1000000000000000000;
    long long int hasil;

    for(int j=0;j<berapaKali;j++){
        scanf("%lld", &a1[j]);
    }

    for(int h=0;h<berapaKali;h++){

        if(a1[h]==0){
            printf("0\n");
            return 0;
        }
    }
    for(int i=0;i<berapaKali;i++){
        if(a1[i] <= max/a2){
        	a2 *= a1[i]; 
		}else{
    		printf("-1\n");
			return 0;	
		}
    }
    hasil = a2;
    printf("%lld\n", hasil);
    
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    vector<long long> A(N),B(N);
    vector<pair<long long,long long>> C;
    for(int i = 0; i < N;i++){
        cin >> A[i] >> B[i];
        C.push_back(make_pair(A[i]+B[i],i));
    }
    
    sort(C.begin(),C.end());
    reverse(C.begin(),C.end());
    
    long long tSum = 0,aSum = 0;
    for(int i = 0; i < N;i++){
       int index = C[i].second;
       if(i % 2 == 0){
           tSum += A[index];
       }else{
           aSum += B[index];
       }
    }
    cout << tSum - aSum << endl;
    
    
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n,k;
    cin>>k>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int mx=0;
    rep(i,n-1){
        int x=a[i+1]-a[i];
        if(mx<x)mx=x;
    }
    int x=(k-a[n-1])+a[0];
    if(x>mx)mx=x;

    cout<<k-mx<<endl;

    
    return 0;
}

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

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = double.Parse(Console.ReadLine());

            Console.WriteLine(2.0 * r * Math.PI);
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}


Measured memory_bytes: 27624
H, W = map(int, input().split())
s = [[True]*(W+2)]
for i in range(H):
    st = input()
    l = [False]
    for t in st:
        l.append(t == "#")
    l.append(False)
    s.append(l)
s.append([True]*(W+2))

flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] and not s[i][j-1] and not s[i][j+1] and not s[i+1][j] and not s[i-1][j]:
            flag = False
            break

print("Yes" if flag else "No")


Measured memory_bytes: 3064
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
      
      ll n;cin>>n;
      map< string , ll > m;
      f(i,0,n)
      {
        string s;cin>>s;
        m[s]++;
      }
      cout<<"AC x "<<m["AC"]<<endl<<"WA x "<<m["WA"]<<endl<<"TLE x "<<m["TLE"]<<endl<<"RE x "<<m["RE"]<<endl;
      
    }    
} 

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

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < 3; i++){
    if (S.at(i) == T.at(i))
      count++;
  }
  cout << count << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll       long long int
#define fast     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define MOD      1000000007
#define pb       push_back
#define PI 3.1415926
#define ordered_set tree<ll, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update> 
int32_t main() 
{ fast
	ll n,m;
	cin>>n>>m;
	ll a[m],sum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		sum=sum+a[i];
	}
	if(sum>n)
		cout<<-1<<endl;
	else
		cout<<n-sum<<endl;
 

  }

Measured memory_bytes: 3728
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private int[][] dist;
    private List<Integer> r = new ArrayList<>();

    private int ans = Integer.MAX_VALUE / 2;

    private void solve(Scanner sc) {
        /*
         * ワーシャルフロイド法
         */
        int N = sc.nextInt();
        dist = new int[N][N];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (i != j) {
                    dist[i][j] = Integer.MAX_VALUE / 2;
                }
            }
        }
        int M = sc.nextInt();
        int R = sc.nextInt();
        for (int i = 0; i < R; ++i) {
            r.add(sc.nextInt() - 1);
        }

        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int c = sc.nextInt();
            if (dist[a][b] > c) {
                dist[a][b] = dist[b][a] = c;
            }
        }

        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    if (dist[i][j] > dist[i][k] + dist[k][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }

        dfs(new HashSet<>(), -1, 0);

        _out.println(ans);
    }
    private void dfs(Set<Integer> set, int p, int d) {
        if (set.size() >= r.size()) {
            if (d < ans) {
                ans = d;
            }
            return;
        }

        for (int t : r) {
            if (set.contains(t)) {
                continue;
            }
            set.add(t);
            if (p < 0) {
                dfs(set, t, d);
            } else {
                dfs(set, t, d + dist[p][t]);
            }
            set.remove(t);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 47636
#include <iostream>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 256
import itertools
import numpy as np
import math
N = int(input())

p = [list(map(int,input().split())) for n in range(N)]

s = list(itertools.permutations(range(N)))

def dis(s):
  ans = 0
  for i in range(len(s)-1):
    ans += np.sqrt((p[s[i]][0] - p[s[i+1]][0])**2 + (p[s[i]][1] - p[s[i+1]][1])**2)
  return ans

ans = sum([dis(x) for x in s])/math.factorial(N)
print(ans)

Measured memory_bytes: 18340
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int D;
vector<int> c(26);
vector<int> last(26, 0);
vector<vector<int>> s(365, vector<int>(26));
void input();
ll score;
int next_num;
void dfs(int nest, int d) {
	ll M = 0, temp = score;
	int prev, n;
	rep(j, 0, 26) {
		score = temp;
		score += s[d - 1][j];
		prev = last[j];
		last[j] = d;
		rep(k, 0, 26)score -= c[k] * (d - last[k]);
		if (nest && d < D)dfs(nest - 1, d + 1);
		if (M < score)M = score, n = j;
		last[j] = prev;
		//printf("%lld %d\n", *score, *next);
	}
	score = M;
	next_num = n;
}
int main()
{
	input();
	rep(i, 1, D + 1) {
		//score = 0;
		dfs(2, i);
		printf("%d\n", next_num + 1);
		//printf("%d\n", score);
	}
	return 0;
}
void input() {
	cin >> D;
	rep(i, 0, 26)cin >> c[i];
	rep(i, 0, D) {
		rep(i2, 0, 26)cin >> s[i][i2];
	}
}


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

int main(){
  int n;
  cin >> n;
  map<string, int> MA;
  int mx = 0;
  string s;
  rep(i , n){
    cin >> s;
    mx = max(mx, ++MA[s]);
  }
  for (auto ma : MA){
    if(ma.second == mx) cout << ma.first << endl;
  }
}

Measured memory_bytes: 25216
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		String s = sc.next();
		s = new StringBuilder(s).reverse().toString();
		String[] words = {
			"maerd",
			"remaerd",
			"esare",
			"resare",
		};
		int pos = 0;
		for (;;) {
			boolean change = false;
			for (String word : words) {
				if (pos + word.length() <= s.length() && s.substring(pos, pos + word.length()).equals(word)) {
					pos += word.length();
					change = true;
				}
			}
			if (!change) break;
		}
		if (pos == s.length()) 
			System.out.println("YES");
		else
			System.out.println("NO");
		
		
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

int main()
{
	int n,p=0;
	cin>>n;
	while(n>0){
		if(n%10==7)
		{
			p++;
			cout<<"Yes\n";
			break;
		}
		n /= 10;
	}	
	if(p==0){
		cout<<"No\n";
	}
}

Measured memory_bytes: 3632
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()


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

const int mod = 1000000007;

int vis[100010];
int dp[100010];

int main(){
	int n, m; scanf("%d%d", &n, &m);
	while (m--){
		int x; scanf("%d", &x);
		vis[x] = 1;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++){
		if (vis[i]) continue;
		dp[i] = (dp[i] + dp[i - 1]) % mod;
		if (i != 1) dp[i] = (dp[i] + dp[i - 2]) % mod;
	}
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


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

ll inf = 10000000;
ll mod = 1000000007;

int main() {
    int N, M;
    map<int, int> a;
    cin >> N >> M;
    REP(i, M) {
        int tmp;
        cin >> tmp;
        a[tmp] = 0;
    }
    ll dp[100100] = {0};
    dp[0] = 1;
    REP(i, N) {
        if (!a.count(i + 2)) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= mod;
        }
        if (!a.count(i + 1)) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= mod;
        }
    }
    cout << dp[N] << endl;

}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-15
*Algorithm:Teacher's Dijkstra
*Stats:Unknown*/

bool debug=false;

int n,m;
map<int,vector<int>> nei[100005]; //at station [] the train <1> can get <2>
map<int,int> d[100005]; //at station [] the train <1>'s dis is <2>
vector<int> lines[100005]; //lines at []

template<typename T> struct pq_small{
	priority_queue<T,vector<T>,greater<T> > pq;
	void push(T x){
		pq.push(x);
	}

	void pop(){
		pq.pop();
	}

	int size(){
		return pq.size();
	}

	bool empty(){
		return pq.empty();
	}

	T top(){
		return pq.top();
	}
};

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		nei[a][c].push_back(b);
		nei[b][c].push_back(a);
		lines[a].push_back(c);
		lines[b].push_back(c);
	}
	
	pq_small<pair<int,pii>> pq; //first -> cost second -> station third -> line
	d[0][0]=0;
	pq.push(make_pair(0,make_pair(0,0)));
	while(!pq.empty()){
		pair<int,pii> last=pq.top();
		int c=last.first,p=last.second.first,q=last.second.second;
		
		if(debug)cout<<c<<" "<<p<<" "<<q<<endl;
		
		pq.pop();
		
		if(d[p][q]!=c){
			continue;
		}
		
		//Situation 1
		if(d[p].count(0)==0 || d[p][0]>c){
			d[p][0]=c;
			pq.push(make_pair(c,make_pair(p,0)));
		}
		
		//Situation 2
		if(q==0){
			for(int i=0;i<lines[p].size();i++){
				if(d[p].count(lines[p][i])==0 || d[p][lines[p][i]]>c+1){
					d[p][lines[p][i]]=c+1;
					pq.push(make_pair(c+1,make_pair(p,lines[p][i])));
				}
			}
		}
		
		//Situtation 3
		for(int i=0;i<nei[p][q].size();i++){
			if(d[nei[p][q][i]].count(q)==0 || d[nei[p][q][i]][q]>c){
				d[nei[p][q][i]][q]=c;
				pq.push(make_pair(c,make_pair(nei[p][q][i],q)));
				
				//cout<<"3 -> "<<c<<" "<<nei[p][q][i]<<" "<<q<<endl;
			}
		}
	}
	
	int mn=d[n-1][0];
	
	if(mn==0){
		cout<<-1;
	}else{
		cout<<mn;
	}
	return 0;
}



Measured memory_bytes: 92652
a,b,k=map(int,input().split())

if b-a+1<=2*k:
    for i in range(a,b+1):
        print(i)
    exit()

else:
    for i in range(a,a+k):
        print(i)
    for j in range(b-k+1,b+1):
        print(j)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<climits>
#include<set>
#include<bitset>
#include<random>
using namespace std;

typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define maxs(a,b) a = max(a,b)
#define mins(a,b) a = min(a,b)
#define rep(i,n) for(int i = 0;i < n;i++)

int main(void){
   int n;scanf("%d",&n);
   int k = 0;
   bool possible = false;
   for(k = 0;k*(k+1) <= 2 * n;k++){
      if(k * (k + 1) == 2* n){possible = true;break;}
   }
   if(!possible){
      cout << "No" << endl;return 0;
   }else{
      cout << "Yes" << endl;
      cout << k + 1 << endl;
   }
   
   vector<int> a[1000];
  int start = 0;
  int block_num = 1;
  for(int i = 0;i < k;i++){
     for(int j = 0;j < block_num;j++){
        a[j].push_back(start + j + 1);
     }
     for(int j = 0;j < block_num;j++){
        a[i + 1].push_back(start + j + 1);
     }
     start += block_num++;
  }
  for(int i = k;i >= 0;i--){
     cout << k << " ";
     for(auto j : a[i]) cout << j << " ";
     cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

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

	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(d <= t * s) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
N, Q = map(int, input().split())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
graph = [[] for _ in range(N)]
for a, b in ab:
  graph[a] += [b]
  graph[b] += [a]
dist = [0 for _ in range(N)]
for p, x in px:
  dist[p-1] += x

def dfs(u, pre):
  for v in graph[u]:
    if v != pre:
      dist[v] += dist[u]
      dfs(v, u)
  return


dfs(0, -1)
dist = list(map(str, dist))
print(" ".join(dist))

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

int reverseNumber(int n) {
  int N = 0;
  while (n > 0) {
    N = N * 10 + n % 10;
    n /= 10;
  }
  return N;
}

int main() {
  int A, B;
  int counter = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    int n = i;
    int N = reverseNumber(n);
    if (n == N) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll n;
    cin>>n;
    map<ll,ll> m;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        m[a]++;
    }
    ll ans=0;
    for(auto x:m){
        if(x.second<x.first) ans+=x.second;
        else ans+=x.second-x.first;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9488
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int H, W, D; cin >> H >> W >> D;
	vector<vector<int>> grid(H, vector<int>(W));
	map<int,pair<int, int>> mp;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> grid[i][j];
			mp[grid[i][j]] = make_pair(i, j);
		}
	}


	vector<vector<int>> cost(H * W + 1);
	for (int i = 0; i <= D - 1; i++) {
		int cnt = 1;
		cost[i].push_back(0);
		while (i + cnt * D <= H * W) {
			//cout << "cnt=" << cnt << endl;
			int now = i + cnt * D, len = cost[i].size();
			cost[i].push_back( cost[i][len-1] 
				+ abs(mp[now - D].first - mp[now].first) + abs(mp[now - D].second - mp[now].second));
			cnt++;
		}
	}

	int Q; cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R; cin >> L >> R;
		int se = L % D;
		L /= D, R /= D;
		cout << cost[se][R] - cost[se][L] << endl;
	}

}


Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,m,t,cnt;
  int a[110];
  
  cin >> n >> m >> t;
  
  cnt = t;
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    
    if(i > 0){
      cnt -= min(m*2,(a[i]-a[i-1]));
    }
    
  }
  
  cnt -= min(a[0],m);
  cnt -= min(t-a[n-1],m);
  
  cout << cnt << endl;

  return(0);
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std; typedef long long int ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/*******************************************************************************/
const double pi = 3.14159265358979323846L;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    freopen("output.txt", "w", stdout);
#endif

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = abs((30.0 * h + m * 0.5) - (6.0 * m));
    if (angle > 180.0)
        angle = 360.0 - angle;
    double long cs = (a * a) + (b * b) - 2 * a * b * cos(angle * pi / 180.0);
    cs = sqrt(cs);
    cout << fixed << setprecision(20) << cs << '\n';
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()


struct LazySegmentTree {
private:
	int n;
	vector< long long > node, lazy;
	vector< bool > lazyFlag;

public:
	LazySegmentTree(vector< long long > v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INF);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = min(node[k],lazy[k]);
			if (r - l > 1) {
                lazy[k*2+1]=min(lazy[k],lazy[k*2+1]);
                lazy[k*2+2]=min(lazy[k],lazy[k*2+2]);
				//lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = min(lazy[k],(ll)x);
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	long long find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INF;
		if (a <= l && r <= b) return node[k];
		long long vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		long long vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int n,q;
ll s[200010],t[200010],x[200010];
ll d[200010];
ll ns[200010],nt[200010],nd[200010];
vector<ll>v;


void input(){
	cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i]>>x[i];
        v.eb(s[i]-x[i]);
        v.eb(t[i]-x[i]);
    }
    for(int i=0;i<q;i++){
        cin>>d[i];
        v.eb(d[i]);
    }
	return;
}

void solve(){
	sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    for(int i=0;i<n;i++){
        ns[i]=lower_bound(ALL(v),s[i]-x[i])-v.begin();
        nt[i]=lower_bound(ALL(v),t[i]-x[i])-v.begin();
    }
    for(int i=0;i<q;i++){
        nd[i]=lower_bound(ALL(v),d[i])-v.begin();
    }
    vector<ll>vv;
    vv.resize(600001);
    for(int i=0;i<600000;i++){
        vv[i]=INF;
    }
    LazySegmentTree seg(vv);
    for(int i=0;i<n;i++){
        seg.update(ns[i],nt[i],x[i]);
    }
    for(int i=0;i<q;i++){
        if(seg.find(nd[i],nd[i]+1)==INF)cout<<-1<<endl;
        else cout<<seg.find(nd[i],nd[i]+1)<<endl;
    }
	return;
}

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

Measured memory_bytes: 59624
H,W=map(int,input().split())
prev=0
for i in range(H):
  s=input()
  id = s.index("#")
  if id >= prev:
    flag=False
    prev = W-1 - s[::-1].index("#")
    for j in range(id,W):
      if flag and s[j]=="#":
        print("Impossible")
        exit(0)
      if s[j]==".":
        flag=True
  else:
    print("Impossible")
    exit(0)
print("Possible")
  

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct S {
  lli x, y, c;
  S(lli x, lli y, lli c) : x(x), y(y), c(c) {}
};

lli h, w, k;
vector<string> a;

lli u,d,l,r,sx,sy;

void bfs(lli x, lli y) {
  queue<S> q;
  q.emplace(x, y, 0);

  while (!q.empty()) {
    S s = q.front(); q.pop();
    l=min(l,s.x); r=max(r,s.x); u=min(u,s.y); d=max(d,s.y);
    lli vx=1, vy=0;
    if (s.c<k) {
      for (lli i=0; i<4; ++i) {
        lli tx=s.x+vx, ty=s.y+vy;
        if (0<=tx && tx<w && 0<=ty && ty<h && a[ty][tx] == '.') {
          a[ty][tx] = '*';
          q.emplace(tx, ty, s.c+1);
        }
        lli t=vx; vx=-vy; vy=t;
      }
    }
  }
}

int main() {
  cin >> h >> w >> k;
  read_n(a, h);
  d=r=0; l=w-1; u=h-1;
  for (lli y=0; y<h; ++y) {
    for (lli x=0; x<w; ++x) {
      if (a[y][x] == 'S') { sx=x; sy=y; goto out; }
    }
  }
out:

  bfs(sx, sy);
  lli m = min({u, h-1-d, l, w-1-r});
  cout << 1+(m+k-1)/k << endl;
  return 0;
}


Measured memory_bytes: 1152
import math

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

count=0

while True:
  ch = 0
  for i in range(n):
    if a[i]%2 != 0:
      ch += 1
  if ch == 0:
    
    for j in range(n):
      a[j]= a[j]/2
    count +=1
  else:
    break


    
print(count)

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

int main(void) {
    int N, buf;
    std::vector<int> v;

    std::cin >> N;

    v.reserve(N);
    for(int i = 0; i < N; i++) {
        std::cin >> buf;
        v.push_back(buf);
    }

    std::sort(v.begin(), v.end());

    int prev = -1;
    int ans = 0;
    for(auto i : v) {
        if(i != prev) {
            ans++;
            prev = i;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int h,w;
while(1){
cin >> h >> w;
if(h==0 && w==0)break;
for(int i=1; i<=h; i++){
for(int j=1; j<=w; j++){
if(i==1 || i==h) cout << "#";
else if(j==1 || j==w) cout << "#";
else cout << ".";
}
cout <<endl;
}
cout <<endl;
}
return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
    int a, b, sum, dif, pro, res;
    scanf("%d %d", &a, &b);
    sum = a + b;
    dif = a - b;
    pro = a * b;

   if(sum >= dif){
       if(sum >= pro){
           res = sum;
       }else if(pro > sum){
           res = pro;
       }
   }

   if(dif > sum){
       if(dif >= pro){
           res = dif;
       }else if(pro > dif){
           res = pro;
       }
   }

   printf("%d\n", res);

   return 0;
}

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

const int MAX=  1E18;

const int MAXN = 200005;
int s[MAXN];

int n;

signed main(){
	cin >> n;
	for(int i=1; i<= n; ++i){
		cin >> s[i];
		s[i] += s[i-1];
	}
	int ans = MAX;
	for(int i=1; i< n; ++i){
		ans = min(ans, abs(s[n]-2*s[i]));
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+5;
ll dp[N][34];
void solve(){
	ll n,m; 
	cin>>n>>m;
	for(int i=0;i<33;i++){
		dp[0][i] = 1;
	}
	for(int i=0;i<N;i++){
		dp[i][0] = 1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=33;j++){
			for(int k=0;k<=j;k++){
				dp[i][j]+=dp[i-1][k];
				dp[i][j]%=mod;
			}
		}
	}
	ll ans  = 1; 
	for(ll i=2;i*i<=m;i++){
		if(m%i==0){
			int cnt = 0;
			while(m%i==0){
				m/=i;
				cnt++;
			}
			ll trt = dp[n-1][cnt];
			ans=(ans*trt)%mod;
		}
	}
	if(m!=1){
		ans*=dp[n-1][1];
		ans%=mod;
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}

/*
5 5
#####
#.#.#
####.
#.#.#
###.#
*/




/// 1100111011
/// 0123456789
/// 00000000001


Measured memory_bytes: 30244
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in h,w;
  cin>>h>>w;
  string s;
  forn(z,h){
    forn(i,w){
      cin>>s;
      if(s=="snuke"){
	cout<<char('A'+i)<<(z+1)<<endl;
      }
    }
  }
  return 0;
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int main(){
	string s,ans;
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i=8;i<s.size();i++){
		ans.push_back(s[i]);
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector<vector<ll>>jobs(m+1);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(a<=m){
            jobs[m-a].push_back(b);
        }
    }
    priority_queue<ll>q;
    ll res=0;
    for(int i=m-1;i>=0;i--){
        for(auto j:jobs[i]){
            q.push(j);
        }
        if(!q.empty()){
            res+=q.top();
            q.pop();
        }
    }
    cout<<res<<endl;
    return 0;
    }


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

using namespace std;

int mat[8];

void print()
{
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            if(mat[i]==j)
            {
                cout<<'Q';
            }else
            {
                cout<<'.';
            }
        }
        cout<<endl;
    }
}
bool dfs(int r)
{
    if(r==8)
    {
        print();
        return true;
    }

    if(mat[r]!=-1)
    {
        for(int i=0;i<r;i++)
        {
            if(mat[i]==mat[r]||r-i==mat[r]-mat[i]||r-i==mat[i]-mat[r])
            {
                return false;
            }
        }
        return dfs(r+1);
    }
    for(int i=0;i<8;i++)
    {
        mat[r]=i;
        bool flag=true;
        for(int j=0;j<r;j++)
        {
            if(mat[j]==i||r-j==i-mat[j]||r-j==mat[j]-i)
            {
                flag=false;
                break;
            }
        }
        if(flag&&dfs(r+1))
        {
            return true;
        }
    }
    mat[r]=-1;
    return false;
}

int main()
{
    int n;

    int r,c;

    ios::sync_with_stdio(false);

    cin>>n;
    memset(mat,-1,sizeof(mat));
    for(int i=0;i<n;i++)
    {
        cin>>r>>c;
        mat[r]=c;
    }

    dfs(0);

    return 0;
}



Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	string t1 = "", t2 = "";
	rep(i, n) {
		if (i % 2 == 0) {
			t1 += '0';
			t2 += '1';
		}
		else {
			t1 += '1';
			t2 += '0';
		}
	}
	int c1=0, c2=0;
	rep(i, n) {
		if (s[i] != t1[i]) c1++;
		if (s[i] != t2[i]) c2++;
	}
	int ans = min(c1, c2);
	cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for(int i=0; i<n; ++i) cin >> p[i];
  for(int i=0; i<n; ++i) cin >> q[i];
  vector<int> a(n);
  for(int i=0; i<n; ++i) a[i] = i+1;

  map<vector<int>,int> mp;
  do{
    mp[a] = mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  cout << abs(mp[p]-mp[q]);
  return 0;


}

Measured memory_bytes: 5248
#include<stdio.h>

int main(){

    int W, H, x ,y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y ,&r);

    if (x - r < 0) {
    	printf("No\n");
    	return 0;
    }
    if (W < x + r) {
    	printf("No\n");
    	return 0;
    }
    if (y - r < 0) {
    	printf("No\n");
    	return 0;
    }
    if (H < y + r) {
    	printf("No\n");
    	return 0;
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
using namespace std;
const int64_t BIG_PRIME = 1000000007;

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

    string head, tail;

    bool rev = false;

    for (int i = 0; i < q; i++)
    {
        int qu;
        cin >> qu;
        if (qu == 1)
        {
            rev = !rev;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                if (rev)
                {
                    tail += c;
                }
                else
                    head += c;
            }
            else
            {
                if (rev)
                {
                    head += c;
                }
                else
                    tail += c;
            }
        }
    }

    s += tail;
    reverse(ALL(head));
    s = head + s;

    if (rev)
    {
        reverse(ALL(s));
    }

    // for (int i = 0; i < q; i++)
    // {
    //     int qu;
    //     cin >> qu;
    //     if (qu == 1)
    //     {
    //         reverse(ALL(s));
    //     }
    //     else
    //     {
    //         int f;
    //         char c;
    //         cin >> f >> c;
    //         if (f == 1)
    //         {
    //             s = c + s;
    //         }
    //         else
    //         {
    //             s.push_back(c);
    //         }
    //     }
    // }

    cout << s << endl;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <list>
#include <fstream>
#include <ctime>
#include <random>
#include <array>

using namespace std;

//const int mod = int(1e9) + 7;
//const int SZ = 10100;
//const int MX = 210500;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
#define ll long long
#define sqr(x) (x)*(x)
#define FREIN(file) freopen(file, "rt", stdin)

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)

const int magic = 3;
const int INF  = 1e9;
#ifndef M_PI
#define M_PI 3.14159265358979323
#endif
void solve();
//void init();

void dump(const vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << ' ';
    }
    cerr << endl;
}

template<typename T, int N>
void dump(const array<T, N>& a) {
    for (int i = 0; i < a.size(); i++) {
        cerr << a[i] << ' ';
    }
    cerr << endl;
}

int main(int argc, char** argv)
{
#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
//        cin >> t;
//        init();
    for (int tt = 1; tt <= t; tt++) {
//        cout << "Case #" << tt << ": ";
        solve();
    }
    return 0;
}
// Solution ***********************************************************************************************

const int MX = 200500;
const int mod = int(1e9) + 9;

void solve() {
    ll a, b, c;
    ll x, y ;
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    c = min(c, a + b);
    ll z = min(x, y);
    x -= z;
    y -= z;
    a = min(a, c);
    b = min(b, c);
    cout << c * z + a * x + b * y << endl;
}

Measured memory_bytes: 256