akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    ll x; cin >> x;
    ll ans = 0;
    ans += 1000*(x/500);
    x %=500;
    ans += 5*(x/5);
    cout << ans << endl;
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll w,h;
  cin >> w >> h;
  VLL ww(w);
  VLL hh(h);

  vector<PII> v;
  rep(i,w) cin >> ww[i], v.emplace_back(ww[i],0);
  rep(i,h) cin >> hh[i], v.emplace_back(hh[i],1);
  h++,w++;
  sort(all(v));

  ll res = 0;
  rep(i,v.size()){
    if(v[i].second) res += w * v[i].first, h--;
    else res += h * v[i].first, w--;
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  int K;
  cin >> K;
  
  if (K % 2 == 0) {
    int kk = K / 2;
    cout << kk * kk << endl;
  }
  else {
    int kk = (K - 1) / 2;
    cout << kk * kk + kk << endl;
  }
}

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

int main() {
  int N, A;
  string op;
  cin >> N >> A;

  int n_500 = N / 500;
  int remain = N - n_500 * 500; 
  
  if (remain <= A) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a, b; cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }

    if (aa.contains(0)) {
        println(0)
        return
    }

    var current = BigDecimal.ONE

    aa.forEach {
        current *= BigDecimal(it)

        if (current > BigDecimal(1000000000000000000)) {
            println(-1)
            return
        }
    }

    println(current)
}

Measured memory_bytes: 63464
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N,K;
  cin>>N>>K;
  map<int,int>data;
  for(int i=0;i<K;i++){
    int x;
    cin>>x;
    for(int j=0;j<x;j++){
      int tmp;
      cin>>tmp;
      data[tmp]++;
    }
  }
  int count=0;
  for(int i=1;i<=N;i++){
    if(data[i]==0){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int n;
	bool tf = false;
	cin >> n;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (i * j == n) {
				tf = true;
			}
		}
	}
	if (tf) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define print(x) cout << x << '\n';
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;

ll k, n, w, x, y, z, a, b, c, l, m, d;
ll xx = 0, yy = 0, zz = 0, sum = 0, temp = 0;
string ss;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    cin >> k;
    a = k / 100;
    b = a + (a*10) + (a*100);
    if(b < k) b += 111;
    cout << b;
 
    return 0;
}


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

using namespace std;

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    int k;
    cin >> k;
    sort(a.begin(), a.end());
    for(int i = 0; i < k; i++){
        a[2] *= 2;
    }
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <climits>
#include <array>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)

using ll = long long;
using ull = unsigned long long;
constexpr ll mod = 1e9 + 7;
using namespace std;

int main() {

	int N; cin >> N;
	vector<pair<int, int>> A(N);
	rep(i, N) {
		int a; cin >> a;
		A[i].first = a;
		A[i].second = i + 1;
	}
	sort(A.begin(), A.end());

	rep(i, N) {
		cout << A[i].second << " ";
	}

	return 0;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  bool j = false;
  rep(i, N){
    if(A.at(i) % 2 == 0){
      if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
        break;
      }
    }
    if(i == N-1){
      j = true;
    }
  }
  if(j){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n;
char s[N];
int ans[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> s + 1;
    n = strlen(s + 1);
    int i = 1, j = 1;
    int cntl = 0, cntr = 0;
    while(j <= n) {
        while(s[i] == 'R') i++, j++, cntr++;
        while(s[j] == 'L') j++, cntl++;
        i--;
        int d = abs(cntl - cntr);
        ans[i] = ans[i + 1] = min(cntl, cntr);
        if(d & 1) {
            if(cntl > cntr) {
                if(cntl & 1) ans[i + 1]++;
                else ans[i]++;
            } else {
                if(cntr & 1) ans[i]++;
                else ans[i + 1]++;
            }
        }
        ans[i] += d / 2; ans[i + 1] += d / 2;
        i = j; j = i;
        cntl = cntr = 0;
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << ' ';
    return 0;
}


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

// main.cpp

int main() {
  std::string c1, c2;
  std::cin >> c1 >> c2;
  std::cout << (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0] ? "YES" : "NO") << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        long K = Long.parseLong(st.nextToken());

        String[] A_array = br.readLine().split(" ");
        String[] B_array = br.readLine().split(" ");
  
        long result = 0;
        long A_total = 0;
        long B_total = 0;

        int A_books = 0;
        int B_books = 0;

        for(String str : B_array) {
            long tmp = Long.parseLong(str);
            if(B_total + tmp > K) break;
            B_total += tmp;
            B_books += 1;
        }

        result = B_books;

        for(int i = 0; i < N; i++) {
            A_total += Long.parseLong(A_array[i]);
            A_books += 1;

            while(A_total + B_total > K && B_books > 0) {
                B_total -= Long.parseLong(B_array[B_books - 1]);
                B_books -= 1;
            }

            if(A_total > K) break;
            if(A_books + B_books > result) result = A_books + B_books;

        }

        pw.println(result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 85512
import java.io.PrintWriter

fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
     val n = read().toInt()
    val ans = IntArray(n)
    repeat(n-1) {
        ans[read().toInt()-1]++
    }

    ans.forEach {
        println(it)
    }
}

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
@JvmField val _writer = PrintWriter(OUTPUT, false)
fun readLine(): String? = _reader.readLine()
@JvmField var _ln = ""
@JvmField var _lnPtr = 0
fun read(): String {
    while (_lnPtr >= _ln.length) {
        _ln = readLine() ?: return ""
        _lnPtr = 0
    }
    var j = _ln.indexOf(' ', _lnPtr)
    if(j < 0) j = _ln.length
    val res = _ln.substring(_lnPtr, j)
    _lnPtr = j + 1
    return res
}

Measured memory_bytes: 57172
n = int(input())
def com(call):
  print(call)
  res = input()
  if res == "Vacant":
    exit(0)
  return res

resp = [None]*n
resp[0] = com(0)
resp[n-1] = com(n-1)

l = 0
r = n-1
while r-l>1:
  mid = (r+l)//2
  resp[mid] = com(mid)
  if ((r-mid)%2)==(resp[r]==resp[mid]):
    l = mid
  else:
    r = mid
com(l)
com(r)

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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    
    if (A >= K)
    {
        A -= K;
    } else
    {
        K -= A;
        A = 0;
        B = max(B - K, (ll)0);
    }
    
    cout << A << " " << B << endl;
    
    
  return 0;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

priority_queue<int> pq;
int n,a,t,b;

main(){
	cin>>n;
	rep(i,n){
		cin>>t;
		pq.push(t);
	}
	for(;!pq.empty();){
		a+=pq.top();
		pq.pop();
		if(!pq.empty()){
		b+=pq.top();
		pq.pop();
		}
	}
	dump(a-b);
}

Measured memory_bytes: 256
#include <stdio.h>

int binarySearch(int *,int,int);

int main()
{
  int i,n,q,A[100000+1],key,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(A,key,n)) count++;
  }
    printf("%d\n",count);

    return 0;
}

int binarySearch(int A[],int key,int n)
{
  int left,right,mid;

    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(A[mid] == key) return 1;
      else if(key < A[mid]) right = mid;
      else left = mid + 1;
    }
      return 0;
}



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

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

	int H[n];
	for(int i = 0; i < n; i++){
		cin >> H[i];
	}
	
	int minHeight = H[0];
	int cnt = 0;

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

		if (minHeight <= H[i])
		{
			minHeight = H[i];
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
 int n;
 cin>>n;
 priority_queue<int> que;
 int ala=0,a,k=0,t,s;
 for(int i=0;i<n;i++){
   cin>>a;
   que.push(a);
   ala^=a;
 }
 for(int i=59;i>=0;i--){
   if(que.empty())break;
    if(ala&(1LL<<i)){
     while(!que.empty()&&(que.top()&(1LL<<i))){
       que.push(que.top()^(1LL<<i));
       que.pop();
      // cerr<<que.top()<<' ';
     }
     continue;
   }
   if(!(que.top()&(1LL<<i)))continue;
    if(!(k&(1LL<<i)))k^=que.top();
    t=que.top();que.pop();
    while(!que.empty()&&(que.top()&(1LL<<i))){
      que.push((t^que.top()));
      que.pop();
    //  cerr<<que.top()<<' ';
    }
    

 }
 cerr<<ala<<' '<<k<<endl;
 cout<<(ala^k)+k;
return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
using namespace std;
long long INF = 1000000009;
map<int, int> mp;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> w(n);
	for (int i = 0; i < n; i++) cin >> w[i];
	bool tmp = true;
	for (int i = 0; i < n - 1; i++) {
		if (w[i].back() != w[i + 1].front()) {
			tmp = false;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) {
				tmp = false;
			}
		}
	}
	if (tmp) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  if (S.at(0)=='o') count++;
  if (S.at(1)=='o') count++;
  if (S.at(2)=='o') count++;
  
  cout << 700+count*100 << endl;
}

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

ll solve() {
    ll N, M, a, s = 0;
    cin >> N >> M;
    map<ll, int> c;
    c[0]++;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s += a;
        s %= M;
        ans += c[s];
        c[s]++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a, b/2);
	tmp = mulMod(tmp, tmp);
	if(b % 2 == 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////

const int N = 100;

int cnt = 0;
int num[N + 5], low[N + 5];
bool flag[N + 5];
ll tmpVal[N + 5][N + 5], val[N + 5];
stack < int > st;
vi scc[N + 5];
int idx;
vi G[N + 5];
int n,m,k;

int tarjan(int u, int p){
	if(num[u] != -1) return num[u];
	num[u] = low[u] = ++cnt;
	st.push(u);
	for(int v : G[u]){
		if(v == p) continue;
		if(num[v] != -1){
			low[u] = min(low[u], num[v]);
		}
		else{
			low[u] = min(low[u], tarjan(v,u));
			if(num[u] <= low[v]){
				scc[idx].PB(u);
				while(!st.empty() && st.top() != v){
					scc[idx].PB(st.top());
					st.pop();
				}
				scc[idx].PB(st.top());
				st.pop();
				idx++;
			}
		}
			
	}
	return low[u];
}

void getVal(){
	FOR(i,N+3) tmpVal[0][i] = 1; 
	REP(len,1,N){
		REP(last,1,k){
			REP(i,1,last){
				tmpVal[len][last] = addMod(tmpVal[len][last], tmpVal[len-1][i]);
			}
		}
	}
	REP(len,1,N){
		val[len] = tmpVal[len][k];
	}
	val[0] = 1;
}

void input(){
	cin >> n >> m >> k;
	int u,v;
	FOR(i,m){
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);
	}
}

void reset(){
	memset(flag,0,sizeof flag);
	memset(num,-1,sizeof num);
	while(!st.empty()) st.pop();
	idx = 0;
}

int getSize(int id){
	int ret = 0;
	memset(flag,0,sizeof flag);
	FOR(i,scc[id].size()) flag[scc[id][i]] = true;
////	printf("SCC %d contains ", id);
	FOR(i,scc[id].size()){
		int u = scc[id][i];
//		printf("%d ",u);
		FOR(j,G[u].size()){
			int v = G[u][j];
			if(flag[u] && flag[v]) ret++;
		}
	}
//	puts("");
	return ret / 2;
}

ll polya(int sz){
	ll ret = 0;
	FOR(i,sz){
		ll d = __gcd(i,sz);
		ret = addMod(ret, fast(k, d));
	}
	return mulMod(ret, fast(sz, MOD-2));
}

ll solve(){
	int ct = 0;
	ll ret = 1;
	int sz;
	FOR(i,idx){
		sz = getSize(i);
		ct += sz;
//		printf("	sz %d\n",sz);
		if(sz == scc[i].size()){
			// 1 cycle
//			printf("polya %lld\n",polya(sz));
			ret = mulMod(ret, polya(sz));
		}
		else{
			// nested
//			printf("mult %lld\n",val[sz+1]);
			ret = mulMod(ret, val[sz]);
		}
	}
//	printf("remainder edge %d\n",m-ct);
	return mulMod(ret, fast(k, m-ct));
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	reset();
	input();
	getVal();
	REP(i,1,n) if(num[i] == -1) tarjan(i,0);
	cout << solve() << endl;
	return 0;
}

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

int n;
string w[100];

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	
	for (int i = 1; i < n; i++) {
		if (w[i-1][w[i-1].length()-1] != w[i][0]) { cout << "No" << endl; return 0; }
		for (int j = 0; j < i; j++) {
			if (w[j] == w[i]) { cout << "No" << endl; return 0; }
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {
    int N;
    char s[256];
    ll C[100][100] = {};

    Scd(N);

    Scs(s);

    C[0][0] = 1;
    Rep(i,N*2+1){
        Rep(k,N+1){
            C[i+1][k] += C[i][k];
            C[i+1][k+1] += C[i][k];
        }
    }

    char t[256];
    Rep(i,N){
        t[i] = s[N*2-1-i];
    }

    map<pair<string,string>, ll> S;
    map<pair<string,string>, ll> T;

    Rep(i,1<<N){
        string sr;
        string sb;
        string tr;
        string tb;
        Rep(j,N){
            if( 1<<j & i ){
                sr.push_back(s[j]);
                tr.push_back(t[j]);
            }else{
                sb.push_back(s[j]);
                tb.push_back(t[j]);
            }
        }
        S[{sr,sb}]++;
        T[{tr,tb}]++;
    }

    ll ans = 0;

    for( auto it = S.begin(); it != S.end(); it++ ){
        ans += it->second*T[it->first];
    }

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


    return 0;
}
/*
11

ippiisssis/ssiipsspii
2!*__**!_2 2?**_**?*2

mip       i
mip

*/


Measured memory_bytes: 108288
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <time.h>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define ss(s) scanf("%s",&s)
#define pi(n) printf("%d\n",n)
#define pl(n) printf("%lld\n",n)
#define newline cout << endl;
using namespace std;

int main(){
  clock_t tStart = clock();
  ll n; sl(n);
  n*=2;
  ll arr[n];
  for(int i=0;i<n;i++){
    sl(arr[i]);
  }
  sort(arr, arr+n);
  ll ans = 0;
  for(int i=0;i<n;i+=2){
    ans+=arr[i];
  }
  pl(ans);
  //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();
            int N, M;
            var p = cin.SplitRead();
            N = p[0];
            M = p[1];
            List<Tuple<int, int>> ab = new List<Tuple<int, int>>();
            for(var i = 0; i < M; i++)
            {
                var input = cin.SplitRead();
                ab.Add(new Tuple<int, int>(input[0], input[1]));
            }

            ab.Sort((x, y) => (x.Item2 - y.Item2));

            int pre = -1;
            long ans = 0;
            for(var i = 0; i < M; i++)
            {
                if (ab[i].Item1 <= pre) { continue; }
                pre = ab[i].Item2 - 1;
                ans++;
            }
            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}






Measured memory_bytes: 23480
def comp(sf, s1, s2):
    s = s1+s2
    if not(s in sf): sf.append(s)

m = int(raw_input())
for i in xrange(m):
    s = raw_input()
    c = ['', '']
    sf = []
    for j in xrange(1, len(s)):
        c = s[:j],s[j:]
        comp(sf, c[0], c[1])
        comp(sf, c[0], c[1][::-1])
        comp(sf, c[0][::-1], c[1])
        comp(sf, c[0][::-1], c[1][::-1])
        comp(sf, c[1], c[0])
        comp(sf, c[1], c[0][::-1])
        comp(sf, c[1][::-1], c[0])
        comp(sf, c[1][::-1], c[0][::-1])

    print len(sf)

Measured memory_bytes: 4268
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long b, long long h, long long m){
    double d1 = M_PI / 2 - (2 * M_PI) * h / 12.0 - (M_PI / 6) * m / 60.0;
    double d2 = M_PI / 2 - (2 * M_PI) * m / 60.0;
    double d1_y = sin(d1) * a;
    double d1_x = cos(d1) * a;
    double d2_y = sin(d2) * b;
    double d2_x = cos(d2) * b;

    double dx = abs(d1_x - d2_x);
    double dy = abs(d1_y - d2_y);

    printf("%.20lf\n", sqrt(dx * dx + dy * dy));
}


signed main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);
    solve(A, B, H, M);
    return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<double>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  ll b=2;
  for(ll i=a-1;i>=0;i--){
    vec.at(i)=vec.at(i)/b;
    b=b*2;
  }
  vec.at(0)=2*vec.at(0);
  double c=0;
  for(ll i=0;i<a;i++){
    c+=vec.at(i);
  }
  cout<<fixed<<setprecision(6);
  cout<<c<<endl;
  return 0;
}
    
  
  
    
  

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

int main(){
  int N;
  int T = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    T += (b - a + 1);
  }
  cout << T << endl;
}

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

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int N;
    // for removing duplication
    set<int> x_set, y_set;

    cin >> N;
    vector<int> x(N), y(N);

    int M = 2e5;
    auto uf = UnionFind(M+1);

    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        x_set.insert(x[i]);
        y_set.insert(y[i]);
    }

    for(int i = 0; i < N; i++) {
        int x_idx = *x_set.lower_bound(x[i]);
        int y_idx = *y_set.lower_bound(y[i]);
        uf.unite(x_idx, 1e5+y_idx);
    }
    vector<set<int>> xs(M+1), ys(M+1);
    for(int i = 0; i < N; i++) {
        int x_idx = *x_set.lower_bound(x[i]);
        int y_idx = *y_set.lower_bound(y[i]);
        int root = uf.root(x_idx);
        xs[root].insert(x_idx);
        ys[root].insert(y_idx);
    }

    set<int> s;
    for(int i = 0; i < M; i++) {
        s.insert(uf.root(i));
    }

    long long ans = 0;
    for(auto& i : s) {
        ans += (long long)xs[i].size() * ys[i].size();
    }

    cout << ans - N << endl;
}


Measured memory_bytes: 34688
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<int>v(n); rep(i, 0, n)cin >> v[i];
		string s; cin >> s;
		int x = 0;
		rep(i, 0, s.size()) {
			rep(j, 0, v[x%n]) {
				if (s[i] == 'a') {
					s[i] = 'Z';
					continue;
				}
				else if (s[i] == 'A') {
					s[i] = 'z';
					continue;
				}
				s[i]--;
			}
			x++;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
  int N,T,A;
  cin>>N>>T>>A;
  int ans,tmp;
  ans = 0;
  tmp = 1e8 + 1;
  for (int i = 1; i <= N; i++) {
    int h;
    cin>>h;
    int res = (T * 1000 - 6 * h) - A * 1000;
    if (res < 0) res = -res;
    if (res < tmp) {
      tmp = res;
      ans = i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

const long long MOD = 1e9 + 7;

inline long long add(long long a, long long b) {
	return ((a % MOD) + (b % MOD)) % MOD;
}

inline long long multiply(long long a, long long b) {
	return ((a % MOD) * (b % MOD)) % MOD;
}

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

  	int n;
  	long long k;
  	cin >> n >> k;

  	vector<long long> a(n);
  	
  	for(int i = 0; i < n; i++) {
  		cin >> a[i];
  	}

  	long long ans = 0;

  	for(int i = 0; i < n; i++) {
  		long long tot = 0, aft = 0;
  		for(int j = 0; j < n; j++) {
  			if(a[j] < a[i]) {
  				tot++;
  				if(j > i) aft++;
  			}
  		}

  		ans = add(ans, multiply(k, aft));
  		ans = add(ans, multiply(tot, k*(k-1)/2));
  	}

  	cout << ans;

    return 0;
}


Measured memory_bytes: 256
//test code
import java.util.*
import kotlin.math.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem169d(n))
}

fun problem169d(n: Long): Int {
    if (n == 1L) return 0
    /**
     * エラトステネスのふるい。1からnまでの素数を列挙する
     */
    fun sieveOfEratosthenes(n: Int): List<Long> {
        val primes : MutableList<Long> = mutableListOf()
        val isprime = MutableList<Boolean>(n+1){true}
        for (i in 2..n) {
            if (isprime[i]) {
              primes.add(i.toLong())
                for (j in i * 2..n step i) {
                    isprime[j] = false
                }
            }
        }
        return primes
    }

    val sosu = sieveOfEratosthenes(1000010)
    
    fun computePrimeFactorList(n: Long): List<Pair<Long, Long>> {
        val p = mutableListOf<Pair<Long, Long>>()
        var primeFactor = n
        for (i in sosu) {
            var count = 0L
            while (primeFactor % i == 0L) {
                primeFactor /= i
                count++
                if (primeFactor == 1L) break
            }
            p.add(i to count)
        }
        if (primeFactor != 1L) p.add(primeFactor to 1L)
        return p
    }
 
    val pf = computePrimeFactorList(n)
    var count = 0
    for (i in 0 until pf.size) {
        var (a, b) = pf[i]
        var j = 1
        while (b > 0) {
            if (b < j) break
            b -= j
            count++
            j++
        }
    }
    return count
}


Measured memory_bytes: 58260
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,a[N],m,b[N],ty,bucket[10];
bool cmp(int x,int y){
	return (x&ty)<(y&ty);
}
int jw(){
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+m+1,cmp);
	int dpos=m+1,res(0);
	for (int i=1; i<=n; ++i){
		while (dpos>1&&(b[dpos-1]&ty)+(a[i]&ty)>ty) --dpos;
		//cerr<<dpos<<" "<<ty<<endl; 
		if ((m+1-dpos)&1) res^=1;
	}
	return res;
} 
int main(){
	scanf("%d",&n); m=n;
	for (int i=1; i<=n; ++i) scanf("%d",&a[i]);
	for (int i=1; i<=m; ++i) scanf("%d",&b[i]);
	int ans=0;
	for (int i=0; i<29; ++i){
		if (i) ans^=jw()<<i; 
		//cerr<<"ans"<<ans;
		ty|=1<<i;
		if (m&1)
		for (int j=1; j<=n; ++j) ans^=a[j]&(1<<i);
		//cerr<<"i"<<i<<" "<<ans<<" "<<ty<<endl;
		if (n&1)
		for (int j=1; j<=m; ++j) ans^=b[j]&(1<<i);
		//cerr<<"i"<<i<<" "<<ans<<" "<<ty<<endl;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

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

		boolean n = S.chars().anyMatch(c -> c == 'N');
		boolean w = S.chars().anyMatch(c -> c == 'W');
		boolean s = S.chars().anyMatch(c -> c == 'S');
		boolean e = S.chars().anyMatch(c -> c == 'E');

		if (n ^ s || w ^ e) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 15564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

// 最大公約数
long GreatestCommonDivisor(long a, long b) {
	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		long tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	/* 最大公約数を出力 */
	return b;
}

// 素因数分解
vector<int> CalcYakusu(int n)
{
	vector<int> vdec;
	// 割る数の初期値
	int a = n;
	while (a >= 1) {
		if (n % a == 0) {
			vdec.push_back(a);
			a--;
		}
		else {
			a--;
		}
	}

	return vdec;
}

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

	int A, B, K;
	cin >> A >> B >> K;


	int GCD = GreatestCommonDivisor(A, B);
	vector<int> vdecom = CalcYakusu(GCD);
	 


	cout << vdecom[K-1] << endl;

	return 0;
}

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

using namespace std;

int main()
{
	int N, M, D;

	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);

		if (N == 0 && M == 0) { break; }

		vector<int> C(N + 1); C.push_back(0);

		for (int i = 1; i <= N; i++)
		{
			scanf("%d", &C[i]);
		}

		vector<int> r;

		for (int i = 0; i <= N; i++)
		{
			for (int j = i; j <= N; j++)
			{
				if (C[i] + C[j] <= M)
				{
					r.push_back(C[i] + C[j]);
				}
			}
		}

		sort(r.begin(), r.end());

		int ret = 0, lc = 0, rc = r.size() - 1;

		while (rc - lc >= 0)
		{
			if (r[lc] + r[rc] > M)
			{
				rc--;
			}
			else
			{
				ret = max(ret, r[lc++] + r[rc]);
			}
		}

		printf("%d\n", ret);
	}

	return 0;
}

Measured memory_bytes: 6888
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

int main() {
    LL n, k;
    LL h[100000];
    LL c[100000];

    cin >> n >> k;
    for (LL i=0; i < n; i++){
        cin >> h[i];
    }

    c[0] = 0;
    for(LL i=1; i < n; i++){
        LL min = 1000000000000000;
        for (LL m = 1; m <= k; m++){
            if (i - m < 0){
                break;
            }
            LL dist = abs(h[i] - h[i - m]) + c[i - m];
            if (dist < min) min = dist;
        }
        c[i] = min;
    }
    

    std::cout << c[n - 1] << endl;


    return 0;
}


Measured memory_bytes: 1792
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    A.sort()

    already = set()
    cnt = collections.Counter(A)
    mx = max(A)
    ret = 0
    for a in A:
        if a in already: continue
        if cnt[a] == 1:
            ret += 1

        i = 1
        while a * i <= mx:
            already.add(a * i)
            i += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 131424
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  REP(i, N) cin >> X[i];
  ll ans = 0;
  REP(i, N - 1) {
    ll dis = X[i + 1] - X[i];
    if (dis * A > B)
      ans += B;
    else
      ans += dis * A;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#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>
#include <iterator>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//input
	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	ll max_A = 0, tmp_B = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		if (max_A < A[i])
		{
			max_A = A[i];
			tmp_B = B[i];
		}
	}

	cout << max_A + tmp_B;


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> stone(N);
  vector<int> place(M);
  vector<int> data(M - 1);
 
  for(int i = 0;i < M;i++){
    cin >> place[i];
  }

  sort(place.begin(),place.end());
  int counter = place[M - 1] - place[0];

  //まずはM < N
  if(M <= N)cout << "0" << endl;
  //M > N
  else{
    //隣あった距離を求める
    for(int i = 0;i < M - 1;i++){
      data[i] = place[i + 1] - place[i];
    }
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    //上からN - 1個を選ぶ
    for(int i = 0;i < N - 1;i++){
      counter -= data[i];
    }
    cout << counter << endl;
  }

}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

bool dislike(int n, set<int> &dig) {
	while (n) {
		if (dig.find(n % 10) != dig.end()) {
			return true;
		}

		n /= 10;
	}

	return false;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	set<int> disliked;
	int d;
	for (int i = 0; i < k; ++i) {
		cin >> d;
		disliked.insert(d);
	}

	for (int i = n; i <= 100000; ++i) {
		if (!dislike(i, disliked)) {
			cout << i << "\n";
			return 0;
		}
	}

	return 0;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);

	int n;
	long long w;
	cin >> n >> w ;

	vector<long long>weight(n),value(n);
	for(int i=0;i<n;i++){
		cin >> weight[i] >> value[i];
	}

	long long sum_val = accumulate( all( value ), 0ll );
	vector<long long>dp(sum_val+1,INT_MAX);

	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=sum_val;j>=value[i];j--){
			dp[j] = min(dp[j],dp[j-value[i]]+weight[i]);
		}
	}

	long long ans = 0;
	for(int i=0;i<=sum_val;i++){
		if(dp[i] <= w) ans = i;
	}

	cout << ans << endl ;

	return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> ans(200100, 0);

    for (ll i = 1; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        ++ans[temp - 1];
    }
    for (ll i = 0; i < N; ++i)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4844
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 二分探索、浮き沈みの沈みに注意
N, K = lr()
A = np.array(lr()); A.sort()
F = np.array(lr()); F.sort()
F = F[::-1]

def check(x):
    limit = x // F # このラインまでにAを落とす
    Y = A - limit
    if np.any(Y > K):
        return False
    cost = Y[Y>=0].sum()
    if cost <= K:
        return True
    else:
        return False

ok = 10 ** 15; ng = -1
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)


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

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

  for (int i = 0; i < 8; ++i) {
    if ( N < std::pow(2, i) ) {
      std::cout << std::pow(2, i - 1) << std::endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 1000000007
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
int main()
{io
ll n;cin>>n;vector<vector<ll>>v(n,vector<ll>(n,0));vector<int>mm(n);
vector<ll>dp((1<<n),0);int cc=0;dp[0]=1;
for(int i=0;i<n;i++)
{cc=0;
    for(int j=0;j<n;j++)
    {
        cin>>v[i][j];
    }
}ll ans=0;
for(ll i=0;i<(1<<n)-1;i++)
{
    cc=__builtin_popcount(i);
    for(ll j=0;j<n;j++ )
    {
      if(v[cc][j]&&(!(i&(1<<j))))
      dp[i|(1<<j)]=(dp[i]%mod+dp[i|(1<<j)]%mod)%mod;
    }
}cout<<dp[(1<<n)-1];







}

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

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int x = sc.nextInt();
        if(x == 1) pw.println(0);
        else pw.println(1);
        pw.close();

    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        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 long nextLong() throws IOException {
            return Long.parseLong(next());
        }

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

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

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


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

double A, B; 

void solve() {
	for (int i = 1; i < 1010; i++) {
		if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
			cout << i; return;
		}
	}
	cout << -1;
	return;
}
 
int main() {
	cin >> A >> B;
	solve();
}


Measured memory_bytes: 256