akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

  int n,m;
  cin >> n >> m;

  int pn = 0, ac = 0;
  vector<bool> isac(n+1);
  vector<int> cnt(n+1);

  rep(i,m){
    int p;
    string s;
    cin >> p >> s;
    if(s == "AC"){
      isac[p] = true;
    }else{
      if(isac[p] == false) ++cnt[p];
    }
  }

  reps(i,n){
    if(isac[i]){
      pn += cnt[i];
      ++ac;
    }
  }

  cout << ac << ' ' << pn << '\n';

  return 0;
}

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

using namespace std;

int main() {
  long long n, k; //n たい　k回
  cin >> n >> k;
  vector<long long> hs(n);
  // long long sum = 0;
  
  // long long max = 0;
  long long ans = 0;
  
  for(int i=0; i<n; ++i){
    // long long a;
    // long long temp;
    cin >> hs[i];
    // if (max < temp) {
    //   max = temp;
    //   ++ans;
    // } else {
    //   hs[i] = temp;
    // }
  }
  
  sort(hs.begin(), hs.end(), greater <>());
  long long sum =0;
  if (k == 0){
    for (int i=0; i<n; ++i){
      sum += hs[i];
    }
  }else if (n < k){
    sum = 0;
  } else {
    for (int i=k; i<n; ++i){
      sum += hs[i];
    }
  }
  
  cout << sum << endl;
  
  // if (h > sum) {
  //   cout << "No" << endl;
  // } else {
  //   cout << "Yes" << endl;
  // }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
//#include <boost/foreach.hpp>
using namespace std;
int main(){
    int n,c,k;
    cin >>n >> c >> k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int c_s=c;
    int t_s=vec[n-1];
    int count=1;
    for(int i=n-1;i>=0;i--){
        if(c_s>0&&t_s-vec[i]<=k){
            c_s--;
        }else{
            count++;
            //cout<<vec[i]<<endl;
            t_s=vec[i];
            c_s=c-1;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll cnt(int a, int b){
    ll ans = 0;
    int tmp = b;
    while(b <= a){
        ans += (a/b);
        b *= tmp;
    }
    return ans;
}

int main() {
    int n; cin >> n;
    bool isprime[1007];
    for(int i = 0; i<1007; i++) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i=2; i*i < 1005; i++){
        if(isprime[i]){
            for(int j=i*i; j<1007; j+=i)
                isprime[j] = false;
        }
    }
    vector<int> v;
    for(int i=2; i<1001; i++){
        if(isprime[i]) v.push_back(i);
    }
    //for(int i=0; i<v.size(); i++) cout << v[i] << " ";
    //cout << endl;
    ll total = 1;
    for(int i=0; i<v.size(); i++){
        total *= (cnt(n, v[i])+1);
        total %= mod;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
def solution(w):
    pre = { }
    cur = w[0]
    pre[cur] = True
    for i in xrange(1, len(w)):
        if cur[-1] != w[i][0]:
            return False
        cur = w[i]
        if cur in pre:
            return False
        pre[cur] = True
    return True

def main():
    n = int(raw_input().strip())
    a = [raw_input().strip() for i in xrange(n)]
    if solution(a):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 3e5 + 2, intf = 2e9;
const ll inf = 2e18, mod = 998244353;
const ld eps = 1e-9;

const int D = 10 , S = 12;

ll dp[D][S];

int cur = 0;

void find_ans(string &ans , int id , int k , int pr = -1){
	if (id == -1){
		cur++;
		//cout << ans << '\n';
		if (cur == k){
			while(ans[0] == '0') {
				reverse(all(ans));
				ans.pop_back();
				reverse(all(ans));
			}
			cout << ans;
			exit(0);
		}
		return;
	}
	for (int i = (pr == -1); i < D; i ++){
		if (pr != -1 && abs(pr - i) > 1) continue;
		ans += i + '0';
		find_ans(ans , id - 1 , k , i);
		ans.pop_back();
	}
}

void solve(){
	int k; cin >> k;

	for (int i = 0; i < D; i ++)
		dp[i][0] = 1;
	for (int i = 1; i < S; i ++){
		for (int j = 0; j < D; j ++){
			dp[j][i] = dp[j][i - 1];
			if (j > 0) dp[j][i] += dp[j - 1][i - 1];
			if (j + 1 < D) dp[j][i] += dp[j + 1][i - 1];
		}
	}

	for (int i = 0; i < S; i ++){
		dp[0][i] = 0;
		for (int j = 1; j < D; j ++){
			dp[j][i] += dp[j - 1][i];
		}
	}


	string ans = "";
	int sum = 0;
	for (int i = 0; i < S; i ++){
		if (sum + dp[9][i] >= k){
			//cout << i << ' ' << k - sum << '\n';
			find_ans(ans , i , k - sum);
		}
		sum += dp[9][i];
	}
	//cout << ans << '\n';
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



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

  int main(){
      int h,w,k;
      cin >> h >> w >>k;
      vector<string> s(h);
      rep(i,h)cin >> s[i];
     int ans=0;
    rep(is,1<<h)rep(js,1<<w){
      int count=0;
      rep(i,h)rep(j,w){
        if(is>>i&1)continue;
        if(js>>j&1)continue;
        if(s[i][j] == '#')count++;
      }
      if(count==k){
        ans++;
      }
    }
    cout << ans << endl;
        
      
      
  }

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N,M,X;cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }

    int ans = 9999999;
    for(int bit = 0;bit < (1 << N);bit++){
        vector<int> ch(M,0);
        int val = 0;
        rep(i,N){
            if(bit & (1 << i)){
                val += C[i];
                rep(j,M){
                    ch[j] += A[i][j];
                }
            }
            bool ok = true;
            rep(j,M){
                if(ch[j] < X)ok = false;
            }

            if(ok){
                ans = min(ans,val);
            }
        }
    }

    if(ans == 9999999)ans = -1;

    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Deque<Character> a = new LinkedList<Character>();

		for (int i = 0; i < s.length(); i++) {
			if (a.size() > 0 && a.peekLast() == 'S' && s.charAt(i) == 'T') {
				a.pollLast();
			} else {
				a.add(s.charAt(i));
			}
		}

		System.out.println(a.size());
	}
}


Measured memory_bytes: 18804
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z -> key = k;
  z -> right = NIL;
  z -> left = NIL;

  while(x != NIL){ // xとNILのアドレスが違うかぎりループする。
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    }else{
      x = x -> right;
    }
  }
  z -> parent = y;

  if(y == NIL){ // 最初のkeyはrootにする。
    root = z;
  }else{
    if(z -> key < y -> key){
      y -> left = z;
    }else{
      y -> right = z;
    }
  }
  return;
}

void find(Node *u, int k){
  if(u == NIL){
    cout << "no" << endl;
    return;
  }else if(k == u -> key){
    cout << "yes" << endl;
    return;
  }else if(k < u -> key){
    find(u -> left, k);
  }else{
    find(u -> right, k);
  }
}

void inPerse(Node *u){
  if(u == NIL) return;
  inPerse(u -> left);
  cout << " " << u -> key;
  inPerse(u -> right);
}

void prePerse(Node *u){
  if(u == NIL) return;
  cout << " " << u -> key;
  prePerse(u -> left);
  prePerse(u -> right);
}

int main(void){
  int n, key;
  string order;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> order;
    if(order[0] == 'i'){
      cin >> key;
      insert(key);
    }else if(order[0] == 'f'){
      cin >> key;
      find(root, key);
    }else if(order[0] == 'p'){
      inPerse(root);
      cout << endl;
      prePerse(root);
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21936
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int i = 0;
    while(i < S.length()){
        cout << S[i];
        i += 2;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    
    int n, m;
    cin >> n >> m;
    int ans;
    if(n>1 && m>1){
        ans=n*(n-1)/2 + m*(m-1)/2;
        cout << ans << endl;
    }
    else if(n>1 && m<=1){
        ans=n*(n-1)/2;
        cout << ans << endl;
        }
    else if(m>1 && n<=1){
        ans=m*(m-1)/2;
        cout << ans << endl;
    }
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int N, ans;
int main(){
	scanf("%d %d", &N, &ans);
	if (N % 2 == 1 && ans % 2 == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
    int n,on,i;
    scanf("%d",&n);
    int a[n+1];
    on=n;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(n=n;n>=1;n=n-2)
        printf("%d\t",a[n]);
    if(n==0)
        for(n=n+1;n<on;n=n+2)
            printf("%d\t",a[n]);
    else
        for(n=n+3;n<on;n=n+2)
            printf("%d\t",a[n]);
    return 0;
}


Measured memory_bytes: 2816
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n); cin >> as;
    ll maxi = -M;
    int i1, j1;
    vector<int> es1;
    for(int i = 0; i < n; i++){
        ll cand = 0;
        vector<int> es;
        for(int j = 0; i + j < n; j += 2){
            bool neg = as[i + j] < 0 && j;
            cand += as[i + j];
            // cand += as[i + j];
            if(maxi < cand){
                es1 = es;
                maxi = cand;
                i1 = i;
                j1 = j;
            }
            cand -= neg ? as[i + j] : 0;
            if(neg){
                es.push_back(j);
            }
        }
    }
    printd(i1, i1 + j1, es1);
    vector<int> anss;
    for(int i = n; i > i1 + j1 + 1; i--){
        anss.push_back(i);
    }
    for(int i = 0; i < i1; i++){
        anss.push_back(1);
    }
    reverse(es1.begin(), es1.end());
    for(auto& e : es1){
        anss.push_back(e + 1);
    }
    for(int i = 0; i < (j1 + 1) / 2 - (int)es1.size(); i++){
        anss.push_back(2);
    }
    cout << maxi << '\n';
    cout << anss.size() << '\n';
    cout << anss << '\n';
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll X(N);
  REP(i,N) IN(X[i]);

  ll ans = INFLL;
  REP(P,101){
    ll tmp = 0;
    REP(i,N) tmp+=(X[i]-P)*(X[i]-P);
    chmin(ans,tmp);
  }

  OUT(ans);

  return 0;
}


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

int main() {
	int n,d,k;
	cin >> n >> d ;
	vector<vector<int>> x(n,vector<int>(d,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin >> x.at(i).at(j);
		}
	}
	int nn = n*(n+1)/2;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int sm =0;
			for(int l=0;l<d;l++)
			{
				int sa = x.at(i).at(l) 
                  - x.at(j).at(l);
				sm += sa * sa;
			}
			for(int l=1;l*l<=sm;l++)
			{
				if(l*l == sm)
				{
					k++;
				}
			}
		}
	}
    cout << k << endl;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
s = list(input())
x = a + b
xb = b
for i in range(n):
    if s[i] == "c" or x == 0:
        print("No")
    else:
        if s[i] == "b":
            if xb == 0:
                print("No")
            else:
                print("Yes")
                x -= 1
                xb -= 1
        else:
            print("Yes")
            x -= 1

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

int main() {
    string s;
    cin >> s;
    bool value[26];
    for(int i=0; i<26; i++) value[i]=0;
    for(int i=0; i<s.length(); i++) value[s[i]-'a']=1;
    for(int i=0; i<26; i++) {
        if(!value[i]) {
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}


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

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	int A, B, C;

	cin >> A >> B >> C;

	if (B / A < C) cout << B / A;
	else cout << C;
	cout << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 384
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

n = i()
fs = []
n.times{
  fs << s().gsub(" ", "")
}
ps = []
n.times{
  ps << li()
}

bits = get_bits(10)[1..-1]

max =-10000000000000000
bits.each{|b|
  sum = 0
  n.times{|i|
    pindex=(fs[i].to_i(2) & b.to_i(2)).to_s(2).count("1")
    sum += ps[i][pindex]
  }
  max = max > sum ? max : sum
}

puts max


Measured memory_bytes: 2172
'use strict';
function main(input) {
    var args = input.split('\n').map((n) => parseInt(n, 10))
    args.shift()
  	    console.log(args.filter((n, i) => args.indexOf(n) === i).length);

}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	char a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	if (a == '1') cnt++;
	if (b == '1') cnt++;
	if (c == '1') cnt++;
	cout << cnt << endl;
	return 0;
}

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

int dp[110][11000] = {};

int main() {
    int N, W;
    cin >> N >> W;

    int v[N], w[N];
    rep(i, N) cin >> v[i] >> w[i];

    dp[0][0] = 0;
    rep(i, N) rep(j, W+1) {
        dp[i+1][j] = dp[i][j];
        if (j>=w[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
    }

    cout << dp[N][W] << endl;

    return 0;
}




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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    
    if((t.size()-s.size())==1 && s == t.substr(0, s.size())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll f(ll N, ll C, ll D) {
  return N - (N/C + N/D - N/lcm(C,D));
}

int main() {
  ll A,B,C,D; cin >> A >> B >> C >> D;
  cout << f(B,C,D)-f(A-1,C,D) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String n = sc.next();
        for(int i = 0; i<n.length(); i++) pp("x");
        p(""); 
        

    }
    public static int gcd(int a, int b) {
        if(a%b==0) return b;
        return gcd(b, a%b);
    }
    public static <T> void p(T element) {
	    System.out.println(element);
    }
    public static <T> void pp(T element) {
	    System.out.print(element);
    }
    public static <T> void pe(T element) {
        System.err.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

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

    set<ll> s;

    for (ll i = 0; i < k; i++)
    {
        if (a + i > b)
        {
            break;
        }
        s.insert(a + i);
    }

    for (ll i = k - 1; i >= 0; i--)
    {
        if (b - i < a)
        {
            break;
        }
        s.insert(b - i);;
    }
    
    for (ll i : s)
    {
        println(i);
    }
    
}

Measured memory_bytes: 3628
n = int(input())
i = 0
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

while i < n:
    l = input()
    l = [x for x in map(int, l.split())]
    tbl[l[0]-1][l[1]-1][l[2]-1] += l[3]
    i += 1

i = 0
for x in tbl:
    for y in x:
        print(" ",end="")
        # for z in y:
        #     print(z, end=" ")
        # print()
        print(" ".join(map(str, y)))
    if i < 3:
        print("####################")
    i += 1


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
 
void solve(){
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;

int main()
{
	while (1) {
		int m, n; cin >> m >> n;
		if (n == 0)break;

		vector<bool>saku(10000000);

		int cnt = 0;
		while (1) {
			if (saku[m] == false) {
				for (int i = m; i < 10000000; i+=m) {
					saku[i] = true;
				}
				cnt++;
				if (cnt == n)break;
			}
			m++;
		}

		for (int i = m; i < 10000000; i++) {
			if (saku[i] == false) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

  int K, A, B, pnt = 0;
  cin >> K >> A >> B;
  for(int i=A; i<=B; i++){
    if(i % K == 0){
      pnt = 1;
      break;
    }
  }
  if(pnt==1){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main(){
	int a, b;
	int ans = 0;
	cin >> a >> b;
	if (a > b)
		ans = a * 2 - 1;
	else if (b > a)
		ans = b * 2 - 1;
	else
		ans = a + b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
map<int, int>cnt;
int n, m;
long long qz[N], ans, a[N];
int main() {
  scanf ("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf ("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    qz[i] = qz[i - 1] + a[i];
    if (qz[i] % m == 0) ans++;
    ans += cnt[qz[i] % m];
    cnt[qz[i] % m]++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int a, p;
    cin >> a >> p;
    int ans = (3*a + p) / 2;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int K; cin >> K;
  if (K == 1) { cout << "1\n1\n"; return 0; }
  int N = (K + 3) / 4 * 2;
  cout << N << '\n';
  for (int r = 0; r < N; r++) {
    for (int c = 0; c < N; c++) {
      int v = (r + c) % N;
      if (r & 1 && v + N < K) {
        cout << v+N+1;
      } else {
        cout << v+1;
      }
      cout << " \n"[c+1==N];
    }
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll cur = 100;
    ld x; cin >> x;
    ld ans = 0;
    while(1){
        ans++;
        cur = cur*1.01;
        if(x <= cur) break;
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    long long n, w; cin >> n >> w;
    long long ans = 0;
    if(n == 1 && w == 1) ans = 1;
    else if(n == 1 || w == 1) ans = n * w - 2;
    else if(n == 2 || w == 2) ans = 0;
    else ans += (n-2)*(w-2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define MAX_N 100000
typedef long long ll;

int main(){
    int N;
    bool ans = true;
    cin >> N;
    REP(i,N){
        int A;
        cin >> A;
        if(A%2 == 1) ans = !ans;
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int p=0,j=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='a'){
      if(A+B>p){
  		cout << "Yes" << endl;
        p++;
      }else
        cout << "No" << endl;
    }else if(S.at(i)=='b'){
      if(A+B>p&&B>j){
        cout << "Yes" << endl;
        j++;
      	p++;
      }else
        cout << "No" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

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


int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> light(m);
	for (int i = 0; i < m; i++) {
		int k_in;
		cin >> k_in;
		vector<int> s(k_in);
		for (int j = 0; j < k_in; j++) {
			cin >> s.at(j);
		}
		light.at(i) = s;
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p.at(i);
	}
	
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		bitset<10> bs(i);

		bool flag = true;
		for (int j = 0; j < m; j++) {
			int cnt = 0;
			for (int k = 0; k < light.at(j).size(); k++) {
				if (bs.test(light.at(j).at(k) - 1)) {
					cnt++;
				}
			}
			if (cnt % 2 != p.at(j)) {
				flag = false;
			}
		}
		if (flag) {
			ans++;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
using System;
class p
{
 static void Main()
 {
   string[] ipt = Console.ReadLine().Split(' ');
   int N = int.Parse(ipt[0]);
   int M = int.Parse(ipt[1]);
   int[] arr = new int[N];
   for (int i = 0; i < N; i++) {
     arr[i] = -1;
   }
   bool exist = true;
   for (int i = 0; i < M; i++) {
     ipt = Console.ReadLine().Split(' ');
     int s = int.Parse(ipt[0]);
     int c = int.Parse(ipt[1]);
     if ((arr[s-1] != -1 && arr[s-1] != c) ||
         (N == 2 && s == 1 && c == 0) ||
         (N == 3 && s == 1 && c == 0) ||
         (N == 3 && s == 2 && c == 0)) {
       exist = false;
       break;
     }
     arr[s-1] = c;
   }
   if (!exist) {
     Console.WriteLine(-1);
     return;
   }
   int result = 0;
   if (N == 1) {
     result += (arr[0] == -1) ? 0 : arr[0];
   } else if (N == 2) {
     result += (arr[0] == -1) ? 10 : arr[0] * 10;
     result += (arr[1] == -1) ? 0 : arr[1];
   } else {
     result += (arr[0] == -1) ? 100 : arr[0] * 100;
     result += (arr[1] == -1) ? 0 : arr[1] * 10;
     result += (arr[2] == -1) ? 0 : arr[2];
   }
   Console.WriteLine(result);
 }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N; cin >> N;
  int ans = 0;
  vector<pair<int, int> > red(N), blue(N);
  for(int i = 0; i < N; ++i) {
    cin >> red[i].second >> red[i].first;
  }
  for(int i = 0; i < N; ++i) {
    cin >> blue[i].first >> blue[i].second;
  }
  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());
  for(int i = 0; i < N; ++i) {
    for(int j = N-1; j >= 0; --j) {
      if(red[j].second < blue[i].first && red[j].first < blue[i].second) {
        ans++;
        red[j] = make_pair(300, 300);
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()
left = 0
s0 = 0
s1 = 0
res = 0
for right, x in enumerate(ls):
    s0 += x
    s1 ^= x
    while s0 != s1:
        s0 -= ls[left]
        s1 ^= ls[left]
        left += 1
    res += right - left + 1
print(res)

Measured memory_bytes: 23984
from itertools import product
N, K = list(map(int, input().split()))
D = set(range(10)) - set(list(map(int, input().split())))
ans = float("inf")
for i in range(2):
    for s in product(D, repeat=len(str(N))+i):
        n = int("".join(map(str, s)))
        if n >= N and ans - N > n - N:
            ans = n
print(ans)


Measured memory_bytes: 3572
import re
S = input().replace('?', '.')
T = input()
for i in range(len(S)-len(T), -1, -1):
    if re.match(S[i:i+len(T)], T):
        S = S.replace('.', 'a')
        print(S[:i]+T+S[i+len(T):])
        exit()
print('UNRESTORABLE')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)

using namespace std;

const double eps = 1e-9;
const double PI = acos(-1.0);
const int INF = 1e9+7;
const int N = int (2e5+7);
    
int n, a[300];
string s;

int main () { 
   	//freopen("input.txt", "r", stdin);
   	//freopen("output.txt", "w", stdout);  
   	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> s;
	n = s.size();
	for(int i = 0; i < n; i ++)
		a[s[i]] ++;
	if((a['N'] && !a['S']) || (!a['N'] && a['S']) || (a['E'] && !a['W']) || (a['W'] && !a['E']))
		cout << "No";
	else
		cout << "Yes";	
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int max(long long int a,long long int b)
{
    if(a>=b)
    return a;
    else
    return b;
    
}
long long int min(long long int a,long long int b)
{
    if(a>=b)
    return b;
    else
    return a;
    
}
int main()
{
    long long int n;
    cin>>n;
    vector<long long int> arr;
    for(long long int i =0;i<n;i++)
    {
        long long int a;
        cin>>a;
        arr.push_back(a);
    }
    vector<vector<long long int> > dp(n,vector<long long int>(n,0));
    for(long long int l=1;l<=n;l++)
    {
        for(long long int i = 0;i<=n-l;i++)
        {   
            if(l==1)
             dp[i][i+l-1] = arr[i];
             else if(l==2)
              dp[i][i+l-1] = abs(arr[i]-arr[i+l-1]);
              else
             dp[i][i+l-1] = max(min(arr[i]-arr[i+1]+dp[i+2][i+l-1],arr[i]-arr[i+l-1]+dp[i+1][i+l-2]),min(arr[i+l-1]-arr[i]+dp[i+1][i+l-2],arr[i+l-1]-arr[i+l-2]+dp[i][i+l-3]));
        }
    }
  
       
           cout<<dp[0][n-1];
       
       
   
}

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

int a[25];
bool b[25];
int main() {
    int N; cin >> N;
    int ans = 0;
    a[0] = -1;
    for (int i = 0; i < 25; ++i) b[i] = false;
    
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        if (a[i] == a[i-1]+1) b[a[i-1]] = true;
    }
    for (int i = 1; i <= N; i++) {
        int k; cin >> k;
        ans += k;
    }
    for (int i = 1; i <= (N - 1); i++) {
        int k; cin >> k;
        if (b[i]) ans += k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  ull N,M;in(N,M);
  vector<ull>A(M);ins(A);
  ull sum=0;
  rep(i,M)sum+=A[i];
  if(sum>N)out(-1);
  else out(N-sum);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
	string str;
	cin >> str;
	int i;

  	for (i=1; i<str.size()+1; i++){
		if (i % 2 == 1 && str[i-1] == 'L'){
        	cout << "No" << endl;
          	return 0;
		} else if (i % 2 == 0 && str[i-1] == 'R'){
        	cout << "No" << endl;
        	return 0;
        }
    }
  
    	
  	cout << "Yes" << endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int* a = new int[n];
    int k = 0;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
    }
    for (int i = 0; i+k < n; i++) {
        if (a[i + k] == i+1) {

        }else {
            k++;
            i--;
        }
    }
    if (k == n)
        k = -1;
    std::cout << k<<"\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    char f = s[0];
    int ans = 0;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] != f) ans++;
        f = s[i];
    }
    cout << ans << endl;
    return 0;
}



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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int n;
    scn(n);
    int a[n+1];
    for(int i=1; i<=n; i++)scn(a[i]);
    vector<int>L(n+3,0),R(n+3,0);

    for(int i=1; i<=n; i++) L[i] = __gcd(L[i-1],a[i]);
    for(int i=n;  i ; i--) R[i] = __gcd(R[i+1],a[i]);
    int ans = L[n];
    for(int i=1; i<=n; i++){
        ans = max(ans , __gcd(R[i+1],L[i-1]));
    }
    cout<<ans;

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 1408
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inline flip f a b = f b a  

// memoization
let inline memo size f =
  let dp = Array.create size None
  let rec g x =
    match dp.[x] with
    | None ->
      let v = f g x
      dp.[x] <- Some v
      v
    | Some v -> v
  g

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match Array2D.get dp x y with
    | None ->
      let v = f g x y
      Array2D.set dp x y (Some v)
      v
    | Some v -> v
  g

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let S = readStr().ToCharArray()
let N = S.Length

let kaibun s =
  let l = s |> Array.length
  [0..(l-1)]
  |> List.forall (fun i -> s.[i] = s.[l-i-1])

let r = (kaibun S) && (kaibun S.[..((N-1)/2-1)]) && (kaibun S.[((N+3)/2-1)..])
match r with
| true -> "Yes"
| false -> "No"
|> printfn "%s"

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

/*int gcd(int a, int b, int c) {
  int cnt = 1;
  for (int i = 1; i <= min(a, min(b, c)); i++) {
    
    if (a%i==0 && b%i==0 && c%i==0) {
      cnt = i;
    }
  }
  return cnt;
}*/

int main() {
  int k;
  cin >> k;
  ll cnt = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 1; l <= k; l++) {
        
        cnt += __gcd(i, __gcd(j, l));
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3620
class Main
{
	static int count = 0;
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int n = sc.nextInt();
		int[] data = new int[n];
		for( int i = 0 ; i < n ; i++ )
			data[i] = sc.nextInt();
		data = bubbleSort( data, n );
		for( int i = 0 ; i < n-1 ; i++ )
			System.out.printf( "%d " ,data[i] );
		System.out.println( data[n-1] );
		System.out.println( count );
	}
	static int[] bubbleSort( int[] data, int n )
	{
		boolean flag = true;
		int work;
		while( flag )
		{
			flag = false;
			for( int j = n-1 ; j > 0 ; j-- )
			{
				if( data[j] < data[j-1] ){
					work = data[j];
					data[j] = data[j-1];
					data[j-1] = work;
					flag = true;//????????£??\????´?????????¨????????´???
					count++;
				}
			}
		}
		return data;
	}
}

Measured memory_bytes: 26388
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  cout << W*H/2.0 << ' ' << ((W/2.0==x&&H/2.0==y) ? 1 : 0) << endl;

  return 0;
}


Measured memory_bytes: 256