akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int d[120][120];
int main(){
	cin>>n;
	for(int i =0;i < n;i++){
		int u,k;
		cin>>u>>k;
		for(int j =0;j <k;j++){
			int c;
			cin>>c;
			d[u][c]=1;
		}
	}
	for(int i =1;i <=n;i++){
		for(int j =1;j <=n;j++){
			if(j==1)cout <<d[i][j];
			else cout <<" "<<d[i][j];
		}
		cout <<endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(3, 0);
    string ans;
    for(int i=0; i<n; i++){
        int aa;
        cin >> aa;

        if(aa%4==0){
            a[2]++;
        }else if(aa%4==2){
            a[1]++;
        }else{
            a[0]++;
        }
    }

    // 1の隣は必ず4, 2の隣は2か4

    // 2がない時、1の数は4の数+1以下 1414141

    if(a[1]==0){
        if(a[0] <= a[2]+1){
            ans = "Yes";
        }else{
            ans = "No";
        }
    }else{
        if(a[0] <= a[2]){
            ans = "Yes";
        }else{
            ans = "No";
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
a_list = list(map(int, input().split()))

sort_dict = collections.Counter(a_list)
remove_counter = 0
for key, value in sort_dict.items():
    if value < key:
        remove_counter += value
    else:
        remove_counter += (value - key)     
print(remove_counter)

Measured memory_bytes: 18676
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>

using namespace std;
int w[1000001];
int n,k;
bool ok(int P) {
	int t = 0;
	int count = 1;
	for (int i = 0; i < n; i++) {
		if (w[i] <= P ) {
		if (t + w[i] <= P ) 
			t += w[i];
		else {
			t = w[i];
			count += 1;
			}
		}
		else count = k+1;
	}
	return count <= k ;
}
int main() {
	cin >> n >> k ;
	for (int j = 0; j < n; j++ ) {
		cin >> w[j];
	}
	int l = 0, h = 10000000000;
	while ( l + 1 < h ) {
		int m = (l+h)/2;
		if( ok(m) ) h = m; 
		else l = m;
	}
	cout << h << endl;
}

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

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int q = in.readInt();
		char s[] = in.readString().toCharArray(); 
		int arr[] = new int[s.length]; 
		for(int i = 1; i<s.length; i++) {
			arr[i] = arr[i-1]; 
			if(s[i] == 'C' && s[i-1] == 'A')arr[i]++; 
		}
		for(int i = 0; i<q; i++) {
			int a = in.readInt();
			int b = in.readInt();
			System.out.println(arr[b-1] - arr[a-1]); 
		}
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 53776
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    BigInteger k = new BigInteger(sc.next());
    ArrayList<BigInteger> a = new ArrayList<>();
    ArrayList<BigInteger> b = new ArrayList<>();

    int indexA = -1;
    int indexB = -1;
    BigInteger sum = BigInteger.ZERO;
    boolean boo = true;
    for (int i = 0; i < n; i++) {
      BigInteger aTmp = new BigInteger(sc.next());
      BigInteger tmp = sum.add(aTmp);
      if (boo && tmp.compareTo(k) <= 0) {
        indexA = i;
        sum = tmp;
      } else {
        boo = false;
      }
      a.add(aTmp);
    }
    boo = sum.compareTo(k) <= 0;
    for (int i = 0; i < m; i++) {
      BigInteger bTmp = new BigInteger(sc.next());
      BigInteger tmp = sum.add(bTmp);
      if (boo && tmp.compareTo(k) <= 0) {
        indexB = i;
        sum = tmp;
      } else {
        boo = false;
      }
      b.add(bTmp);
    }

    int max = (indexA + 1) + (indexB + 1);
    for (int i = indexA; i >= 0; i--) {
      if (indexB == m - 1) {
        break;
      }
      sum = sum.subtract(a.get(i));
      BigInteger tmp = sum;
      while (true) {
        if (indexB == m - 1) {
          break;
        }
        tmp = tmp.add(b.get(indexB + 1));
        if (tmp.compareTo(k) <= 0) {
          indexB++;
          sum = tmp;
        } else {
          break;
        }
      }
      int t = i + (indexB + 1);
      if (t > max) {
        max = t;
      }
    }
    System.out.println(max);
  }


}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  ll n, m, x, ans = INF;
  cin >> n >> m >> x;
  vector<ll> c(n);
  ll a[n][m];

  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  rep(i, 1 << n) {
    ll t[m] = {0}, tcost = 0;
    for (int j = 0; j < n; ++j) {
      if (i >> j & 1) {
        tcost += c[j];
        rep(k, m) t[k] += a[j][k];
      }
    }
    bool ok = true;
    rep(j, m) if (t[j] < x) ok = false;
    if (ok) ans = min(ans, tcost);
  }

  cout << (ans == INF ? -1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#ifdef ATCODER
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = (1<<30)-1;
const ll INFLL = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

  REP(i, N){
    cout << "ACL";
    debug(i);
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

string S;

int main(void) {

	cin >> S;
	int N = S.size();
	string ans = "Yes";

	for (int i = 0; i < N; i += 2) {
		if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {}
		else {
			ans = "No";
		}
	}

	for (int i = 1; i < N; i += 2) {
		if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {

		}
		else {
			ans = "No";
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main()
{
    int n;
    cin >>n;
    int sum=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                sum+=gcd(gcd(i,j),k);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------

int n, m, x;
int c[12];
int a[12][12];
int ans = INF;

int main() {

  cin >> n >> m >> x;
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }

  for(int bit = 0; bit < (1<<n); ++bit) {
    vector<int> v;
    for(int i=0; i<n; ++i) {
      if(bit & (1<<i)) {
        v.push_back(i);
      }
    }
    vector<int> w(m);
    int res = 0;
    for(int i=0; i<(int)v.size(); ++i) {
      res += c[v[i]];
      for(int j=0; j<m; ++j) w[j] += a[v[i]][j];
    }

    bool flag = true;
    for(int i=0; i<m; ++i) {
      if(w[i]<x) {
        flag = false;
        break;
      }
    }

    if(flag) ans = min(ans, res);
  }

  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 1000005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    // ll tt;
    // w(tt){

    // }
    ll l, r, m = INT_MAX;
    cin >> l >> r;
    fo(i, l, l+2019){
        fo(j, i+1, l+2019){
            if(j > r)   break;
            ll x = (i%2019 * j%2019)%2019;
            m = min(m, x); 
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int price,num,sump=0,sum=0,i=0;
	double ave;
	while(scanf("%d,%d",&price,&num)!=EOF){
		sump += price*num;
		sum += num;
		i++;
	}
	ave = sum/(double)i;
	ave += 0.5;
	cout<<sump<<endl<<(int)ave<<endl;
	
	return 0;
}

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

int main(){
      int N,tmp;
      string S,S_copy;
      
      cin >> N >> S;
      S_copy = S; 

      for(int i = 0;S[i]!='\0';i++){
            if(S[i] + N <= 'Z'){
                  tmp = 'Z' - S[i];
            }
            S[i] = (S[i] - 'A' + N) % 26 + 'A';

      }
      cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
 
const double PI = 3.14159265358979323846;
/*Graph t;
void dfs(int v, int pv=-1){
    for(int vn: t[v]){
        if (vn == pv) continue;
        dfs(vn, v);
    }
}*/
int main() {
  ll n,k;
  cin >> n >> k;
  ll ma;
  cin >> ma;
  ll g=ma;
  rep(i,n-1){
    ll o;
    cin >> o;
    ma=max(o,ma);
    g=gcd(g,o);
  }
  if(n==1){
    if(ma==k)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
  else if(k%g==0&&ma>=k) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,d,a[N];
main() {
    file("balance");
    ios;
    cin>>n;
    multiset <int> st;
    fo(i,1,n,1) {
        cin>>a[i];
        st.ins(a[i]);
    }
    fo(i,1,n,1) {
        st.erase(st.find(a[i]));
        cout<<*st.rbegin()<<"\n";
        st.ins(a[i]);
    }
    return 0;
}
/**

*/


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int m;
string s, t, u;
vector<int> dis, to;

void zalgo(string s, vector<int>& z){
	int c = 0, n = s.size();
	z.resize(m, 0);
	for(int i=1; i<m; i++){
		if(i+z[i-c] < c+z[c]){
			z[i] = z[i-c];
		}else{
			int j = max(0, c+z[c]-i);
			while(i+j < n && s[j] == s[i+j]) j++;
			z[i] = j;
			c = i;
		}
	}
	z[0] = n;
}

int dfs(int v, int c=0){
	if(c > s.size()) return dis[v] = INF;
	if(dis[v] != -1) return dis[v];
	if(to[v] == -1) return dis[v] = 0;
	if(dfs(to[v], c+1) == INF) return dis[v] = INF;
	return dis[v] = dfs(to[v], c+1) + 1;
}

int main(){
	cin >> s >> t;
	m = s.size() + t.size();
	vector<int> z;
	u = t+s;
	rep(i, t.size()/s.size() + 1) u += s;
	zalgo(u, z);
	dis.resize(s.size(), -1);
	to.resize(s.size(), -1);
	rep(i, s.size()){
		if(z[t.size()+i] >= t.size()){
			to[i] = (i+t.size())%s.size();
		}
	}
	int ans = 0;
	rep(i, s.size()){
		if(dis[i] != -1) continue;
		chmax(ans, dfs(i));
		if(ans == INF){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 26640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, M;
    cin >> N;
    map<int, int> D;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        D[tmp]++;
    }
    cin >> M;
    bool flag = true;
    for (int i = 0; i < M; i++)
    {
        int tmp;
        cin >> tmp;
        if (D[tmp] <= 0)
        {
            flag = false;
            break;
        }
        else
        {
            D[tmp]--;
        }
    }
    if (flag)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n,k;
cin>>n>>k;
ll l[n];
for (ll i = 0; i < n; i++) cin >> l[i];
sort(l, l + n, greater<ll>());
ll ans = 0;
for (ll i = 0; i < k; i++) ans += l[i];
cout << ans << endl;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

template<int64_t mod> struct Combination{
    vector<int64_t> f, rf;
 
    Combination(int max_n): f(max_n+1), rf(max_n+1){
        f[0] = 1;
        for(int i = 1;i <= max_n;i++) f[i] = f[i-1] * i % mod;
		int64_t a = f[max_n], inv = 1;
		for(int64_t b = mod-2;b > 0;b>>=1){
			if(b & 1) inv = inv*a % mod;
			a = a * a % mod;
		}
		for(int i = max_n;i >= 0;i--) inv = (rf[i] = inv) * i % MOD;
    }
 
    int64_t operator()(int n, int r){
        return (r < 0 || n < r) ? 0 : f[n] * rf[r] % mod * rf[n-r] % mod;
    }
};
signed main(){
	int n, k;
	cin >> n >> k;
	Combination<MOD> combi(100000);
	cout << combi(k, n) << endl;
	return 0;
}




Measured memory_bytes: 4432
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int ans1=0,ans2=0,a[10],b[10];
  for(int i=0;i<10;i++) cin>> a[i];
  for(int i=0;i<10;i++) cin >> b[i];
  sort(a,a+10);
  sort(b,b+10);
  for(int i=7;i<=9;i++){
    ans1 +=a[i];
    ans2 +=b[i];
  }cout << ans1<< " " << ans2<< endl;
}

Measured memory_bytes: 1180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    string s;
    int k;
    cin >> k >> s;

    int len_s = s.size();

    if (len_s <= k) {
        cout << s << endl;
    } else {
        REP(i, k) cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
/**
 *     author: qodjf
 *     created: 05.03.2020 01:40:44
 */
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

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

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int N;
const int MAXN = 2e5 + 10;
int a[MAXN];
vector<vector<int>> g;
vector<int> ans;
vector<int> l2MinEndVal;
int maxAns = 0;

void dfs(int x, int par) {
  int idx = lower_bound(all(l2MinEndVal), a[x]) - begin(l2MinEndVal);
  int tmp = l2MinEndVal[idx];
  l2MinEndVal[idx] = a[x];

  int tmpMaxAns = maxAns;
  chmax(maxAns, idx + 1);
  ans[x] = maxAns;

  for (int child : g[x]) {
    if (child != par) {
      dfs(child, x);
    }
  }

  l2MinEndVal[idx] = tmp;
  maxAns = tmpMaxAns;
}

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

  cin >> N;
  g.resize(N);
  ans.resize(N);
  l2MinEndVal = vector<int>(N, INF);
  rep(i, 0, N) { cin >> a[i]; }
  rep(i, 1, N) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  dfs(0, -1);
  for (int x : ans) {
    cout << x << endl;
  }
}


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

//ABC132 B
int main() {
	int n;
	cin >> n;
	int A[50];
	for (int i=0; i<n; i++) {
		cin >> A[i];
	}

	int cnt = 0;
	for (int i=1; i<n-1; i++) {
		if (A[i]<A[i+1] && A[i]>A[i-1]) {
			cnt++;
		}
		else if (A[i]>A[i+1] && A[i]<A[i-1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main(){
	string s;cin>>s;
  	string k="keyence";
  	int starti=0,endi=0;
  	for(int i=1;i<=7;i++){
    	if(s[i-1]!=k[i-1]){
        	starti=i-1;
          	break;
        }
    }
  	if(starti==7){
    	cout<<"YES"<<endl;
      	return 0;
    }
  	reverse(s.begin(),s.end());
  	reverse(k.begin(),k.end());
  	for(int i=1;i<=7-starti;i++){
    	if(s[i-1]!=k[i-1]){
        	cout<<"NO"<<endl;
          	return 0;
        }
    }
    	cout<<"YES"<<endl;
      	return 0;
  
}    


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

typedef long long lint;

int N, M, K, S, C[100005];
lint P, Q;
vector< vector< int > > edge;

int dominated[100005];

void computeDomination() {
	memset(dominated, 0, sizeof(dominated));
	
	queue< int > que;
	for (int i=0; i<K; ++i) {
		que.push(C[i]);
		dominated[C[i]] = 2;
	}
	
	for (int i=0; i<S; ++i) {
		queue< int > nxt_que;
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (int u : edge[v]) {
				if (dominated[u] > 0) continue;
				nxt_que.push(u);
				dominated[u] = 1;
			}
		}
		swap(que, nxt_que);
	}
}

lint cost[100005];

void dijkstra() {
	memset(cost, -1, sizeof(cost));
	
	struct State {
		int v; lint c;
		bool operator > (const State& s) const { return c > s.c; }
	};
	
	priority_queue< State, vector< State >, greater< State > > que;
	que.push(State{0,0});
	cost[0] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		if (cost[s.v] < s.c) continue;
		
		for (int u : edge[s.v]) {
			if (dominated[u] == 2) continue;
			lint nxt_c = s.c + (u == N-1 ? 0 : (dominated[u] == 1 ? Q : P));
			if (cost[u] == -1 || cost[u] > nxt_c) {
				cost[u] = nxt_c;
				que.push(State{u, nxt_c});
			}
		}
	}
}

void solve() {
	computeDomination();
	dijkstra();
	cout << cost[N-1] << endl;
}

int main() {
	cin >> N >> M >> K >> S;
	cin >> P >> Q;
	
	for (int i=0; i<K; ++i) {
		cin >> C[i];
		--C[i];
	}
	
	edge.assign(N, vector< int >());
	for (int i=0; i<M; ++i) {
		int A, B;
		cin >> A >> B;
		--A; --B;
		edge[A].push_back(B);
		edge[B].push_back(A);
	}
	
	solve();
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const double eps = 1e-9;
const ll N = 1e6 + 10;
const int M = 1e9 + 7;
const ll MAX = 1e18 + eps;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};

ll solvex(ll n) {
    return ((ll) (sqrt(8 * n + 1) + eps) - 1) / 2;
}

int main() {
    ll n;
    cin >> n;
    map<ll, int> pf;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            pf[i]++;
            n /= i;
        }
    }
    if (n > 1)
        pf[n]++;
    ll ans = 0;
    for (auto x: pf) {
        ans += solvex(x.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
const int N = 1010;
int a[N];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < k; i++)
	{
		ans += a[i];
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3820
#include <stdio.h>

int main (void){
    int a, b, c, i, i2, i3;
    char str[100];
    char cp[50];
    i3 = 0;

    scanf("%s", str);
    for ( i = 0; str[i] != '\0'; i++ ){		//入力された文字数を探索 ~7
//        printf("%d", i);
    }
    for ( i2 = 0; i2 <= (i-1)/2-1; i2++ ){	//前半の文字列をコピー ~2
        cp[i2] = str[i2];
    }
//  	printf("%c %c\n", str[0], cp[0] );
    for ( i2 = (i+3)/2-1; i2 < i; i2++, i3++ ){	//コピー文字列と後半文字列を比較 4~
        if ( str[i2] != cp[i3] ){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
//======================================
//author @Amit Singh : global_const
//======================================

#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<climits>
using namespace std;
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
signed main()
{ yeah;
  int t;
  cin>>t;
  long long  arr[t];
  long long  multi=1;
  bool flag=0;
  loop(i,t)
  {cin>>arr[i];
   if(arr[i]==0)
   {flag=1;
    break; 
   }
  }	
 if(flag==1)
 cout<<0<<endl;
 else
 {loop(i,t)
   {multi*=arr[i];
    if(arr[i]>multi||multi>1000000000000000000)
    {cout<<-1<<endl;
   	return 0;
   	}
   }
   cout<<multi<<endl;
  }
 return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<29;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    int N,K;cin>>N>>K;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    sort(all(A));
    
    vector<ll> B(N+1);
    
    for(int i=1;i<=N;i++){
        B[i]=B[i-1]+comb(K-3+i,i-1);
        B[i]%=mod;
        
        //cout<<B[i]<<endl;
    }
    
    ll ans=0;
    
    for(int i=0;i<=N-K;i++){
        ans+=B[N-K+1-i]*((mod-A[i])%mod);
        ans%=mod;
    }
    
    reverse(all(A));
    
    for(int i=0;i<=N-K;i++){
        ans+=B[N-K+1-i]*((mod+A[i])%mod);
        ans%=mod;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 4224
#include <iostream>
#include <cmath>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vii vector < pair<int,int> >
#define pii pair<int,int>
const int INF=1e9+2;
const int eps=1e-9;
using namespace std;

int main(){
    int h, w, r, c, cnt, ans;
    char temp;
    bool grid[1002][1002];
    cin>>h>>w;
    queue<pair< pii, int> > bfs;
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            cin>>temp;
            if (temp=='#'){
                grid[i][j]=1;
                bfs.push(pair<pii,int>(pii(i,j),0));
            }
            else grid[i][j]=0;
        }
    }
    while (!bfs.empty()){
        r=bfs.front().fi.fi;
        c=bfs.front().fi.se;
        cnt=bfs.front().se;
        bfs.pop();
        if (cnt!=0 && (r<1 || r>h || c<1 || c>w || grid[r][c])) continue;
        ans=cnt;
        //cout<<r<<c<<cnt<<endl;
        grid[r][c]=1;
        bfs.push(pair<pii,int>(pii(r+1,c),cnt+1));
        bfs.push(pair<pii,int>(pii(r,c+1),cnt+1));
        bfs.push(pair<pii,int>(pii(r,c-1),cnt+1));
        bfs.push(pair<pii,int>(pii(r-1,c),cnt+1));
    }
    cout<<ans;
}


Measured memory_bytes: 49608
#include<iostream>
#include<algorithm>
#include<vector>
#include<complex>
using namespace std;
typedef long long ll;

using namespace std;
#define N 10010
int NOEL(ll ans){
  cout<<ans<<endl;
  return 0;
}
vector<ll> x,y;
ll n;
int main(){
    string s,t;cin>>n>>s>>t;
    if(n==1)return NOEL(s!=t);
    if(n==2)return NOEL((s[0]!=t[0])+(s[1]!=t[1]));
    for(int i=1;i<n;i++){
      if(s[i]!=s[i-1])x.push_back(i);
      if(t[i]!=t[i-1])y.push_back(i);
    }
    ll ans=1e17;
    for(int k=-N;k<N;k++){
      if(k%2==0 xor t[y[0]]==s[x[0]])continue;
      ll cur=0;
      for(int i=-N;i<N;i++){
	int j=i+k; ll vx,vy;
	if(j<0)vx=0;
	else if(j>=x.size())vx=n;
	else vx=x[j];
	
	if(i<0)vy=0;
	else if(i>=y.size())vy=n;
	else vy=y[i];
	
	cur+=abs(vx-vy);
      }
      ans=min(ans,cur);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let _ = Scanf.scanf "%s" @@ fun s ->
  let l, a = Array.fold_left (fun (l,a) -> function
    | 'S' -> (l,a+1)
    | _ -> if a = 0 then (l+1,0) else (l,a-1)) (0,0) (arr_of_str s)
  in Printf.printf "%d\n" (l+a)

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

int main() {
    long long N; cin >> N;
    long long W; cin>>W;
    long long a[N+10]; long long b[N+10];
    long long dp[W+1][N+10]={};
    long long counter=0;
    for (long long j = 0; j < N; ++j) cin >> a[j]>>b[j];
  
    for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j <=W; ++j) {
    if(j-a[i]>=0){ dp[j][i+1]=max(dp[j-a[i]][i]+b[i],dp[j][i]);}
    else{chmax( dp[j][i+1],dp[j][i]);}}}
    cout<<dp[W][N]<<endl;}
    


Measured memory_bytes: 86144
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int xx = 1e5 +  10;
const int mod = 1e9+7;
vector<int>g[xx];
int ans = 1;
int n,k;
void dfs(int c , int p , int num){
	ans = ans * num % mod;
	//cout << c <<"  " << p <<" " << num << endl;
	if(c == 1) num = k-1;
	else num = k-2;
	for(auto e:g[c]){
		if(e != p){
			dfs(e,c,num);
			num--;
		}
	}
}
signed main(){
	
	cin >> n >> k;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,-1 , k);

	cout << ans << '\n';

}

Measured memory_bytes: 9216
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
typedef int64_t ll;
const ll INF = 1000000000000000000;


int main() {
	ll N;
	cin >> N;
	vector<ll> L(N);
	for (int i = 0; i < N; ++i) cin >> L[i];

	sort(L.begin(), L.end());
	ll hen = 0;
	for (int i = 0; i < N - 1; ++i) hen += L[i];
	if (hen > L.back()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100
#define MAX_V 1000
#define INF 1e9
using namespace std;
int n,W[100][100],E[100][100];
string F[100];
int N,K;

struct edge{int to, cap,cost,rev;};
int V;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  while(f>0){
    fill(dist,dist+V,INF);
    dist[s]=0;
    bool update = true;
    while(update){
      update = false;
      for(int v=0; v<V ;v++){
	if(dist[v]==INF) continue;
	for(int i=0; i<G[v].size(); i++){
	  edge &e = G[v][i];
	  if(e.cap > 0 && dist[e.to] > dist[v]+e.cost) {
	    dist[e.to] = dist[v] + e.cost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[t]==INF) return -1;     
    int d = f;
    for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d*dist[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int Biparite_Matching(){
  int s = N+K, t = s+1;
  for(int i=0; i<N; i++) add_edge(s,i,1,0);
  for(int i=0; i<K; i++) add_edge(N+i,t,1,0);
  int res=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(F[i][j]=='o')res+=E[i][j],add_edge(i,N+j,1,-E[i][j]);
      else add_edge(i,N+j,1,W[i][j]);    
  return res+min_cost_flow(s,t,N);
}


int main(){
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>W[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>E[i][j];
  for(int i=0;i<n;i++)cin>>F[i];
  N=K=n,V=2*n+2;
  cout<<Biparite_Matching()<<endl;
  int cnt=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<(int)G[i].size();j++)
      if(G[i][j].cap<=0&&F[i][G[i][j].to-n]=='.')cnt++;
      else if(G[i][j].cap>0&&F[i][G[i][j].to-n]=='o')cnt++;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++)
    for(int j=0;j<(int)G[i].size();j++)
      if(G[i][j].cap<=0&&F[i][G[i][j].to-n]=='.')
	cout<<i+1<<" "<<G[i][j].to-n+1<<" write"<<endl;
      else if(G[i][j].cap>0&&F[i][G[i][j].to-n]=='o')
	cout<<i+1<<" "<<G[i][j].to-n+1<<" erase"<<endl;
  return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include<stdio.h>   
#include<stdlib.h>

int main(){
    int a = 0;
    scanf("%d",&a);
    a %= 1000;
    if(a == 0) a = 1000;
    printf("%d\n",1000-a);
}


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

int main() {
    int n;
    cin >> n;
    for (int i = 1;i <= 50000;i++) {
        if ((int)floor(1.08 * i) == n) {
     	    printf("%d", i);
            return 0;
        }
    }
    
    printf(":(");
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,cnt=0;
    string s;
    vector<string>v;
    cin>>n;
    for(int i=0;i<n;i++)
        {
            cin>>s;
            v.push_back(s);
        }
    sort(v.begin(),v.end());
   for(int i=0;i<n;i++)
    {
        if(v[i]!=v[i+1])
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 9092
N=int(input())
S=list(map(int,input().split( )))
S = sorted(S)
tri_num=0
for i in range(N-2):
    k = i+2
    for j in range(i+1,N-1):
        while k < N:
            if S[i] + S[j] <= S[k]:
                tri_num = tri_num + k-j-1
                if k == i+2:
                    k+=1
                break
            if k == N-1:
                tri_num = tri_num + k-j
                break
            k+=1
print(tri_num)

Measured memory_bytes: 3188
N=int(input())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
a=AB[0][1]
b=0
for i in range(1,N):
    if AB[i][1]<a:
        a=AB[i][1]
        b=i
print(a+AB[b][0])

Measured memory_bytes: 89832
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;

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

  if(n==1)cout<<k<<endl;
  else if(n==2)cout<<k*(k-1)<<endl;
  else if(n>=3){
    int sum=1;
    for(int i=0;i<n-1;i++){
      sum*=(k-1);
    }
    cout<<k*sum<<endl;
  }

  return 0;
  }


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

using namespace std;
const int maxn = 1e3;
char s[maxn];
int main()
{
    cin >> s;
    int sum = 0;
    for (int i = 0; i < strlen(s); i++)
        if (s[i] == '1')
            sum++;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N; cin >> N;
   
    vei A(100003);

    rep(i,N){
        int k; cin >> k;
        A[k]++;
        A[k+1]++;
        A[k+2]++;
    }
    sort(rall(A));
    cout << A[0] << endl;
}



Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m;
  cin >> n >> m;
  vi e(m);
  rep(i, m) cin >> e[i];
  reverse(all(e));
  vi used(n + 1);
  for (int &x : e) {
    if (used[x]) continue;
    used[x] = true;
    cout << x << endl;
  }
  loop(x, 1, n + 1) if (!used[x]) cout << x << endl;
}

Measured memory_bytes: 5192
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-12 21:06:00
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    for (int i = 0; i < m; i++)
        cin >> p[i] >> s[i];

    vector<int> cleared(n, 0), penalty(n, 0);
    for (int i = 0; i < m; i++) {
        if (s[i] == "AC") {
            cleared[p[i]-1] = 1;
        } else {
            if (cleared[p[i]-1]) {
                ;
            } else {
                penalty[p[i]-1]++;
            }
        }
    }

    int cle, pen;
    cle = pen = 0;
    for (int i = 0; i < n; i++) {
        if (cleared[i]) {
            cle++;
            pen += penalty[i];
        }
    }

    cout << cle << " " << pen << endl;
    return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'
#define INF 1000000007

const int maxn=2e6+5;
ll f[maxn];

ll pow(ll val, ll exp, ll MOD)
{
    ll x=1,y=val; 
    while(exp > 0)
    {
        if(exp%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD; 
        exp /= 2;
    }
    return x;
}
ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

void compute(int mod)
{
    f[0] = 1;
	for(int i = 1 ; i < maxn ; i++)
		f[i] = (f[i-1]*i)%mod;
}

int mul(int x, int y)
{
    return (x * 1ll * y) % INF;
}

int main()
{
    IOS;
    compute(INF);
    string s;
    ll k;
    cin>>k;
    cin>>s;
    ll n=s.size();

    ll ans=0;

    for (int i = 0; i <= k; i++)
        ans=(ans+mul(pow(25,k-i,INF),mul(pow(26,i,INF),C(n-1+k-i,k-i,INF))))%INF;
    
    cout<<ans;
}

Measured memory_bytes: 19876
import sys
input = sys.stdin.readline

N,A,B = list(map(int,input().split()))
X = sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
    if (X[i+1]-X[i])*A >B:
        cnt+=B
    else:
        cnt +=A*(X[i+1]-X[i])
print(cnt)


Measured memory_bytes: 20252