akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

bool possum(VL a, ll x) {
  int n = a.size();
  REP(i, 0, n) {
    a[i] += x;
  }
  ll tt = 0;
  REP(i, 0, n) {
    tt += a[i] / (n + 1);
  }
  return tt >= x;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  ll lo = 0;
  ll hi = 51e16;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (possum(a, mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  // Actual value is around lo
  ll cur = -1;
  for (ll x = max(lo - 2500, 0LL); x <= lo; x++) {
    if (possum(a, x)) {
      cur = x;
    } else {
      break;
    }
  }
  cout << cur << "\n";
}


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

int main(){
    string S;
    cin >> S;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    reverse(S.begin(), S.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for(int i=0;i<S.size();){
        bool innercan = false;
        for(int index=0;index<4;index++){
            if(S.substr(i,divide[index].size()) == divide[index]){
                i += divide[index].size();
                innercan = true;
                break;
            }
        }
        if(!innercan){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

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

int main(void){
    char c;
    int ans = 0;
    
    while((cin >> c)){
        if(c == '+'){
            ans++;
        }else if(c == '-'){
            ans--;
        }else{
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main() {
    
    int N;
    cin >> N;
    set<string> se;
    rep(i, N){
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 19160
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

ll ans =0;

int main(){
  ll N,M;cin >> N >> M;
  if(2*N<=M){
    ans += N;
    M-=2*N;
    N=0;
  }else{
    ans += M/2;
    N -= M/2;
    M =0;
  }

  cout << ans+M/4 << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

import static java.lang.Integer.*;

public class Main {
    public static List<String> permutation(List<String> list, String target, String ans){
        if(target.length() <= 1) {
            list.add(ans + target);
        } else {
            for (int i = 0; i < target.length(); i++) {
                String tar = target.substring(0, i) + target.substring(i + 1);
                String an = ans + target.charAt(i);

                permutation(
                        list,
                        target.substring(0, i) + target.substring(i + 1),
                        ans + target.charAt(i)
                );
            }
        }
        return list;
    }
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = parseInt(scanner.next());
        ArrayList<ArrayList<Integer>> arrays = new ArrayList<ArrayList<Integer>>();

        for(int i = 0; i < n; i++)  {
            ArrayList<Integer> array = new ArrayList<>();
            for(int j = 0; j < 2 ; j++) {
                array.add(Integer.parseInt(scanner.next()));
            }
            arrays.add(array);
        }


        String number = "";
        for(int i = 1; i <= n; i++) {
            number += i;
        }

        List<String> listA = new ArrayList<>();
        permutation(listA, number, "");

        double result = 0.0;
        double re = 0.0;
        for(int i = 0; i < listA.size(); i++) {
            String[] arr = listA.get(i).split("");
            //System.out.println(Arrays.toString(arr));
            int[] iar = Stream.of(arr).mapToInt(Integer::parseInt).toArray();
            for(int j =0; j < arr.length - 1; j++) {
                double route1 = Math.abs(Math.pow(arrays.get(iar[j] -1).get(0) - arrays.get(iar[j+1] -1).get(0),2));
                double route2 = Math.abs(Math.pow(arrays.get(iar[j] -1).get(1) - arrays.get(iar[j+1] -1).get(1),2));
                result += Math.sqrt(route1 + route2);

            }
        }
        System.out.println(result/ listA.size());

    }
}

Measured memory_bytes: 86692
n,x=list(map(int,input().split()))
if x==1 or x==2*n-1:
  print("No")
elif x==2*n-2:
  print("Yes")
  for i in range(n-1):
    print(i+1)
  print(x)
  print(2*n-1)
  for i in range(n-1,x-1):
    print(i+1)
else:
  print("Yes")
  l=[i for i in range(1,x-1)]+[i for i in range(x,2*n-3)]
  for i in range(n-2):
    print(l[i]+1)
  print(2*n-1)
  print(x)
  print(1)
  print(2*n-2)
  for i in range(n-2,2*n-5):
    print(l[i]+1)

Measured memory_bytes: 18588
# -*- coding: utf-8 -*-
"""
Created on Sun Jan  5 09:57:37 2020

@author: masat
"""

A = input()
B = input()

false_list = [A, B]
answer_list = ["1", "2", "3"]

answer = None
for i in answer_list:
    if i  not in false_list:
        answer = i
    else:
        pass

print(answer)



Measured memory_bytes: 3060
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>

using namespace std;

template <class T>
class Dijkstra {
 public:
  Dijkstra(int node_size) : node_size_(node_size) { Initialize(); }
  void Add_Edge(int from, int to, T cost) {
    graph_[from].push_back({to, cost});
  }
  void Solve(int source) {
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>,
                        std::greater<std::pair<T, int>>> pq;
    distance_[source] = 0;
    pq.push({0, source});

    while (!pq.empty()) {
      std::pair<T, int> top = pq.top();
      pq.pop();
      int v = top.second;
      if (distance_[v] < top.first) continue;
      for (const auto& e : graph_[v]) {
        if (distance_[e.to] > distance_[v] + e.cost) {
          distance_[e.to] = distance_[v] + e.cost;
          pq.push({distance_[e.to], e.to});
        }
      }
    }
  }
  T operator[](int to) const { return distance_[to]; }

 private:
  struct edge {
    int to;
    T cost;
  };
  int node_size_;
  std::vector<T> distance_;
  std::vector<std::vector<edge>> graph_;
  void Initialize() {
    distance_.assign(node_size_, std::numeric_limits<T>::max() / 2);
    graph_.resize(node_size_);
  }
};

template <class T>
class BFS {
 public:
  BFS(int node_size) : node_size_(node_size) { Initialize(); }
  void AddEdge(int from, int to) {
    graph_[from].emplace_back(to);
  }
  void Solve(int source) {
    std::queue<int> que;
    que.emplace(source);
    distance_[source] = 0;
    visited_[source] = 1;

    while (!que.empty()) {
      int top = que.front(); que.pop();
      for (int next : graph_[top]) {
        if (visited_[next]) continue;
        visited_[next] = 1;
        distance_[next] = distance_[top] + 1;
        que.emplace(next);
      }
    }
  }
  T operator[](int to) const { return distance_[to]; }

 private:
  int node_size_;
  std::vector<T> distance_;
  std::vector<int> visited_;
  std::vector<vector<int>> graph_;
  void Initialize() {
    distance_.assign(node_size_, std::numeric_limits<T>::max() / 2);
    visited_.assign(node_size_, 0);
    graph_.resize(node_size_);
  }
};

template<class T> inline void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

int main() {
  int n, u, v; fastin(n); fastin(u); fastin(v);
  --u; --v;

  BFS<int> bfs_t(n);
  BFS<int> bfs_a(n);

  for (int i = 0; i < n - 1; ++i) {
    int a, b; fastin(a); fastin(b);
    --a; --b;
    bfs_a.AddEdge(a, b);
    bfs_a.AddEdge(b, a);
    bfs_t.AddEdge(a, b);
    bfs_t.AddEdge(b, a);
  }

  bfs_t.Solve(u);
  bfs_a.Solve(v);

  int mx = -1;
  int ans = 0;

  for (int i = 0; i < n; ++i) {
    if (bfs_t[i] < bfs_a[i] && bfs_a[i] > mx) {
      mx = bfs_a[i];
      ans = bfs_a[i] - 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 13056
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int cns = 1;
    int ans = 0;
    while (true) {
        if (B <= cns) {
            break;
        }
        cns += A - 1;
        ans++;
    }
    cout << ans << endl;
}

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


int main() {

    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int cnt = 0, tmp = i;
        for (int j = 0; j < 5; ++j) {
            cnt += tmp % 10;
            tmp /= 10;
        }
        if (a <= cnt && cnt <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int r,d;
	ll x;
	cin>>r>>d>>x;
	for(int i=1;i<11;i++){
		x=r*x-d;
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>
#include <cmath>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<int> l;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s(500000,' ');
	cin >> s;
	/*
	REP(i, 500000) {
		s[i] = '>';
	}*/
	int len = s.length();
	vector<int> a(len + 1, 0);
	int x = 0;
	int now;
	
	REP(i, len) {
		//cout << "i:" << i << endl;
		if (s[i] == '<') {
			a[i] = x++;
			if (i == len - 1)a[i + 1] = x;
			continue;
		}
		now = i;
		while (s[now] == '>') {
			if (++now == len)break;
		}
		//cout << "now:" << now <<"i:"<<i<< endl;
		RFOR(j, i, now+1) {
			a[j] = now - j;
			//cout << "j:" << j << endl;
		}
		if (i!=0&&a[i - 1] >= a[i])a[i] = a[i - 1] + 1;
		i = now-1;
		x = 0;
	}
	ll ans = 0;
	REP(i, len + 1) {
		ans += a[i];
		//cout << a[i] << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    string s; cin >> s;
    int ans = 1000;

    rep(i,s.size()-2){
        chmin(ans,abs(stoi(s.substr(i,3))-753));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		if (n == 25) {
			out.println("Christmas");
		} else if (n == 24) {
			out.println("Christmas Eve");
		} else if (n == 23) {
			out.println("Christmas Eve Eve");
		} else {
			out.println("Christmas Eve Eve Eve");
		}
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

Measured memory_bytes: 21332
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int n, y;
  cin >> n >> y;
  y /= 1000;
  rep(i, n + 1) {
    rep(j, n + 1 - i) {
      if (y == 10 * i + 5 * j + (n - i - j)) {
        cout << i << " " << j << " " << (n - i - j) << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i <= (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	set<int> s;
	rep(i,n) {
		int a; cin >> a;
		if(s.count(a)) s.erase(a);
		else s.insert(a);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 4864
# https://atcoder.jp/contests/abc123/tasks/abc123_c
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    a = input_int()
    b = input_int()
    c = input_int()
    d = input_int()
    e = input_int()
    _min = min(a, b, c, d, e)
    ans = (n // _min) - 1 + 5
    if n % _min > 0:
        ans += 1
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61636
#include <cstdio>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
/*
int R,C;
int search(int i, vector< vector<int> > moti){
  if(i==R){
    int ret = 0;
    REP(j,C){
      int c=0;
      REP(k,R){
        if(moti[k][j]==1) c++;
      }
      ret+=max(c,R-c);
    }
    return ret;
  }else{
    vector< vector<int> > moti2;
    moti2=moti;
    REP(j,C){
      if(moti2[i][j]==1)moti2[i][j]=0;
      else moti2[i][j]=1;
    }
    return max(search(i+1,moti),search(i+1,moti2));
  }
}

int main(void){
  while(cin>>R>>C){
    if(R==0) break;
    vector< vector<int> > moti;    
    REP(i,R){
      vector<int> tmp;
      REP(j,C){
        int tmp2;
        cin>>tmp2;
        tmp.push_back(tmp2);
      }
      moti.push_back(tmp);
    }
    cout<<search(0,moti)<<endl;
  }
  return 0;
}
*/
int R,C;
bool moti[11][10001];
int main(){
  while(cin>>R>>C){
    if(R==0) break;
    REP(i,R)REP(j,C) cin>>moti[i][j];
    bitset<10> test;
    int ans = 0;
    for(int i=0; i<pow(2,(double)R-1)-1; i++){
      int ka = 0;
      test = i;
      REP(i,C){
        int c=0;
        REP(j,R){
          if(moti[j][i]==test[j]) c++;
        }
        ka += max(c,R-c);
      }
      ans = max(ans, ka);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 984
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if(n>=k+(k-1))
        cout << "YES" << endl;
        else
            cout << "NO" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a = 1, b = 1;
  int tmp;

  while (a != 0 || b != 0)
  {
    std::cin >> a >> b;

    if (a != 0 || b != 0)
    {
      if (a > b)
      {
        std::cout << b << " " << a << std::endl;
      }
      else
      {
        std::cout << a << " " << b << std::endl;
      }
    }
  }
}



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


string Comp(int x[26], int y[26]){
    string flag = "Yes";
    for(int i = 0; i < 26; ++i){
        for(int j = 0; j < 26; ++j){
            if(x[i] == y[j]){
                y[j] = -1;
                break;
            }
        }
    }
    for(int i = 0; i < 26; ++i){
        if(y[i] != -1){
            flag = "No";
        }
    }
    return flag;
}

int main() {
    string S, T;
    cin >> S >> T;
    
    const int sizeS = S.length();
    const int sizeT = T.length();
    
    int listS[26];
    int listT[26];
    
//    cout << sizeS << sizeT << endl;
    
    int i = 0;
    for(char alph = 'a'; alph <='z'; ++alph){
        int count = 0;
        for(int j = 0; j < sizeS; ++j){
            if(alph == (char)S[j]){
                ++count;
            }
        }
        listS[i] = count;
//        cout << count << " ";
        ++i;
    }
//    cout << endl;
    
    i = 0;
    for(char alph = 'a'; alph <='z'; ++alph){
        int count = 0;
        for(int j = 0; j < sizeT; ++j){
            if(alph == T[j]){
                ++count;
            }
        }
        listT[i] = count;
//        cout << count << " ";
        ++i;
    }
    
    cout << Comp(listS, listT) << endl;
    
    return 0;
}


Measured memory_bytes: 776
import java.util.*;

public class Main {


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

        int x = sc.nextInt();
        int y = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        List<Long> listA = new ArrayList<Long>();
        List<Long> listB = new ArrayList<Long>();
        List<Long> listAll = new ArrayList<Long>();

        for (int i = 0; i < a; i++) {
            listA.add(sc.nextLong());
        }

        for (int i = 0; i < b; i++) {
            listB.add(sc.nextLong());
        }

        Collections.sort(listA, Comparator.reverseOrder());
        Collections.sort(listB, Comparator.reverseOrder());

        for (int i = 0; i < x; i++) {
            listAll.add(listA.get(i));
        }

        for (int i = 0; i < y; i++) {
            listAll.add(listB.get(i));
        }

        for (int i = 0; i < c; i++) {
            listAll.add(sc.nextLong());
        }

        Collections.sort(listAll, Comparator.reverseOrder());

        long ans = 0;

        for (int i = 0; i < x + y; i++) {
            ans += listAll.get(i);
        }

         System.out.println(ans);

        sc.close();
    }

}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll mp[11][11];

int main(){

	ll n;cin >> n;
	string str;
	cin >> str;

	REP(i,str.size() - 1){
		int a = str[i] - '1';
		int b = str[i+1] - '1';
		mp[a][b]++;
	}
	ll ans = LLINF;
	vector<int> out;
	vector<int> now;
	REP(i,9)now.PB(i);

	do {
		ll tmp = 0;
		REP(i, 3){
			REP(j, 3){
				REP(ii, 3){
					REP(jj, 3){
						int a = now[3 * i + j];
						int b = now[3 * ii + jj];
						tmp += mp[a][b] * (abs(i - ii) + abs(j - jj));
					}
				}
			}
		}


		if(ans > tmp){
			ans = tmp;
			out = now;
		}
	}while(next_permutation(ALL(now)));

	REP(i,3){
		REP(j, 3){
			cout << out[3*i + j] + 1;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3348
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  string S;
  ll ANS;
  cin>>S;
  if(S=="SUN") ANS=7;
  if(S=="MON") ANS=6;
  if(S=="TUE") ANS=5;
  if(S=="WED") ANS=4;
  if(S=="THU") ANS=3;
  if(S=="FRI") ANS=2;
  if(S=="SAT") ANS=1;
  cout<<ANS<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int day;
  if(S=="SUN")day = 7;
  else if(S=="MON")day = 6;
  else if(S=="TUE")day = 5;
  else if(S=="WED")day = 4;
  else if(S=="THU")day = 3;
  else if(S=="FRI")day = 2;
  else day = 1;
  cout << day << endl;
  return 0;
}

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

int main(){
  long long N;
  long long K;
  long long count[100010]={0};
  cin>>N>>K;
  for(long long i=0;i<N;i++){
    long long a,b;
    cin>>a>>b;
    count[a]+=b;
  }
  long long pos=0;
  for(long long i=1;i<100010;i++){
      pos+=count[i];
      if(pos>=K){
        cout<<i<<endl;
        break;
      }
  }

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,m,X,Y;
//vector<int> a(3);
int main() {
    cin >> n >> m >> X >> Y;
    vector<int> x(n);
    vector<int> y(m);
    REP(i,n){
        cin >> x[i];
    }
    REP(i,m){
        cin >> y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    string res;
    if(x[n-1]<y[0]&&X<Y&&x[n-1]<Y&&X<y[0]){
        res = "No War";
    }else{
        res = "War";
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    medi = N // 2
    ans = B[medi] - A[medi] + 1
else:
    medi1 = N // 2 - 1
    medi2 = medi1 + 1
    A_medi = (A[medi1] + A[medi2]) / 2
    B_medi = (B[medi1] + B[medi2]) / 2
    ans = (B_medi - A_medi) * 2 + 1
print(int(ans))


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


int main(){
    int x, maxi = 0, a;
    cin >> x;
    
    if(x < 3){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 2; i < x; i++){
        a = i*i;
        while(1){
            if(a > x) break;
            maxi = max(maxi, a);
            a *= i;
        }
    }

    cout << maxi << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    int H,W;
    cin >> H >> W;
    ve<string> a(H);
    in(H,a);
    
    vvl dp(H+1,vl(W+1,0));
    dp[0][1] = 1;
    
    rep(i,H){
        rep(j,W){
            
            if(a[i][j] == '#') continue;
            
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%mod;
            
            
        }
    }
    
    cout << dp[H][W] << endl;
    
    //outmat(dp);
    
    
    

    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int a,b; cin>>a>>b;
    int m;
    m=max(a+b,a-b);
    m=max(m,a*b);
    co(m);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var s = sc.nextInt();
		sc.close();

		var calc = new Main().new ModCalc(MOD);
		var a = new int[s + 1];
		a[0] = 1;
		for (var i = 0; i < s + 1; i++) {
			for (var j = 3; j <= i; j++) {
				a[i] = calc.add(a[i], a[i - j]);
			}
		}
		System.out.println(a[s]);
	}

	public class ModCalc {
		int mod;

		public ModCalc(int mod) {
			this.mod = mod;
		}

		public int add(int a, int b) {
			return (int) (((long) a + b) % mod);
		}

		public int subtract(int a, int b) {
			return (int) (((long) a - b + mod) % mod);
		}

		public int multiply(int a, int b) {
			return (int) (((long) a * b) % mod);
		}

		public int divide(int a, int b) {
			return multiply(a, pow(b, mod - 2));
		}

		public int pow(int n, int k) {
			if (k == 0) {
				return 1;
			} else if (k % 2 == 0) {
				int p = pow(n, k / 2);
				return multiply(p, p);
			} else {
				int p = pow(n, (k - 1) / 2);
				return multiply(multiply(p, p), n);
			}
		}

		public int combine(int n, int k) {
			int sum1 = 1;
			int sum2 = 1;
			for (int i = 0; i < k; i++) {
				sum1 = multiply(sum1, n - i);
				sum2 = multiply(sum2, i + 1);
			}
			return divide(sum1, sum2);
		}
	}
}


Measured memory_bytes: 35668
#include<iostream>

using namespace std;

int n, m;
char nm[51][51];//????????????

void fill() {
	int ans = 999999;

	//2??????n-1???????????§?????????????????\?????????
	for (int i = 1; i <= n - 2; i++) {//i???W????????°?????¨???'W'???????????????????????????????????????1??????n-2?????§
		for (int j = 1; j + i <= n - 1; j++) {//j???B????????°?????¨??????i??¨j???????¨?????????§??§???n-1????????§

			int zantei = 0, row = 1;

			for (int k = 1; k <= i; k++) {//W???1??????i?????§
				for (int c = 1; c <= m; c++) {
					if (nm[row][c] != 'W') {
						zantei ++;
					}
				}
				row++;
			}
			for (int k = i+1; k <= i+j; k++) {//B???i+1??????i+j?????§
				for (int c = 1; c <= m; c++) {
					if (nm[row][c] != 'B') {
						zantei ++;
					}
				}
				row++;
			}
			for (int k = i+j+1; k <= n; k++) {//R???i+j+1??????n?????§
				for (int c = 1; c <= m; c++) {
					if (nm[row][c] != 'R') {
						zantei ++;
					}
				}
				row++;
			}

			if (zantei < ans) ans = zantei;

		}
	}

	cout << ans << endl;
}

int main() {
	cin >> n >> m;//n????¨????m??????

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> nm[i][j];
		}
	}

	fill();

	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    const int INF =114514810;
    int N,M;
    int a[52],b[52];
    bool judge=0;
    cin >> N >> M;
    int ans=0;
    REP(i,M){cin >> a[i] >> b[i];}
    int d[52][52];
    REP(l,M){
        REP(i,N){REP(j,N){d[i][j]=INF;}}
        REP(i,M){d[a[i]-1][b[i]-1]=1;d[b[i]-1][a[i]-1]=1;}
        d[a[l]-1][b[l]-1]=INF;d[b[l]-1][a[l]-1]=INF;
        REP(i,N){d[i][i]=0;}
        
        
        
        REP(k,N){
            REP(i,N){
                REP(j,N){
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        //デバッグ
        /*
        REP(i,N){
            REP(j,N){
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
            cout << endl;
            cout << endl;
        */
        
        REP(i,M){if(d[a[i]-1][b[i]-1]>114514){judge=1;break;}}
        if(judge==1){ans++;}
        judge=0;
        
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //ABC 100_b
using namespace std;
int main(){
	int D,N,ans;
	cin>>D>>N;
	if(N==100)
		N++;
	if(D==0)
		cout<<N;
	else if(D==1)
		cout<<N*100;		
	else
		cout<<N*10000;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC164A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = RInt;
            var F = RInt;

            if (S <= F) Console.WriteLine("unsafe");
            else Console.WriteLine("safe");

        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 27816
#include <iostream>

using namespace std;

int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main() {
	int k;
	cin >> k;
	cout << arr[k - 1] << endl;
	//cin >> k;
	return 0;
}

Measured memory_bytes: 256
#define CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<iomanip>
#include<math.h>
#include<vector>
#include<utility>
#include<functional>
#include<iostream>
#define sqr(x) x*x
#define REP(i,n) for(int i=0;i<n;i++)
const int INF = 100000000;
bool flg=false;
using namespace std;
typedef pair<int, int>P;


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	x = 48 - x;
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector <vector<char>> c(h,vector<char>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		String input = bf.readLine();
 		for(int i = 0;i<input.length();i++){
 			if (input.charAt(i) == '?')
 				out.print("D");
 			else
 				out.print(input.charAt(i));
 		}
 		out.close();
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




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

int main(){
    long n;
    cin >> n;
    
    vector<ll> f(n+1);
    for(long i=1;i<=n;i++){
        for(long j=1;j<=n;j++){
            if(j*i>n)break;
            f[j*i] += 1;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans += i*f[i];
    cout << ans << endl;
}

Measured memory_bytes: 81336
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

max_a = max(A)
gcd_num = A[0]
for i in A:
	gcd_num = gcd(gcd_num, i)

if K in A or (K <= max_a and K % gcd_num == 0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")


Measured memory_bytes: 16308
n,x=map(int,input().split())
m=[int(input()) for _ in range(n)]


#全部一個ずつ作った残り
d=x-sum(m)

#残りdでmが一番少ないドーナツを何個作れるか
k=int(d/min(m))

print(n+k)

Measured memory_bytes: 2940
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, N, *A = map(int, read().split())

    C = [[0] * W for _ in range(H)]
    vec = [i for i, a in enumerate(A, 1) for _ in range(a)]

    for i in range(H):
        for j in range(W):
            color = vec[i * W + j]
            if i % 2 == 0:
                C[i][j] = color
            else:
                C[i][W - j - 1] = color

    for row in C:
        print(*row)

    return


if __name__ == '__main__':
    main()


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

int main() {
  long long h,W,ans;
  cin>>h>>W;
  ans=(h*W)/2;
  if(h==1||W==1){
    cout<<1<<endl;
    return 0;
  }
  if(h%2==1&&W%2==1){
    ans++;
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

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


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, A, B;
    cin >> N >> A >> B;

    int res = A*(N/(A+B));
    N = N%(A+B);
    res += min(A, N);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


void solve(){
    string s;
    cin >> s;
    int n=s.size();
    vector<int>ans(n);
    for(int j=0;j<2;j++){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(s[i]=='R')cnt++;
            else{
                ans[i]+=cnt/2;
                ans[i-1]+=(cnt+1)/2;
                cnt=0;
            }
        }
    
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        for(int i=0;i<n;i++){
            if(s[i] == 'L') s[i] = 'R';
        else s[i] = 'L';
        }
    }
    for(int i=0;i<n;i++)cout << ans[i] << " ";
    cout << endl;
}

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


Measured memory_bytes: 1024
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


/*
* Problem : abc 160 - C
* Acknowledgement : None
* Author : deathnaught_
* GitHub : www.github.com/DeathNaughT-GitHub
* Complexity : O()
*/

public class Main
{

    static int N, H;
    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();
        H = sc.nextInt();
        N = sc.nextInt(); 
        int arr[] = sc.nextArray(N);
        int dif = H - arr[N - 1] + arr[0];
        for (int i = 1; i < N; i++) {
            dif = Math.max(dif, arr[i] - arr[i - 1]);
        }
        System.out.println(H - dif);
        
    }

    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

		boolean hasNext()
		{
		    return st == null ? false : true;
		}

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }
    } 

}

Measured memory_bytes: 49936
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    int a, b;
    cin >> a >> b;

    cout << a * b << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 3584