akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


const int MAXN = 1e6 + 100;
int bit[MAXN];
void update(int idx, int val)
{
	while(idx < MAXN)
	{
		bit[idx]+= val;
		idx += idx & (-idx);
	}
}

int query(int idx)
{
	int sum = 0;
	while(idx)
	{
		sum += bit[idx];
		idx -= idx & (-idx);
	}
	return sum;
}
pair<int,pair<int,int> >que[MAXN];
int v[MAXN];
int last[2 * MAXN];
int ans[MAXN];
int main()
{
	memset(last,-1,sizeof(last));
	int n;
	scanf("%d",&n);
	int q;
	scanf("%d",&q);
  
  for(int i = 1; i <= n; i++)
	{
		scanf("%d",&v[i]);
	}
	for(int i = 0; i < q; i++)
	{	
		scanf("%d",&que[i].second.first);
		scanf("%d",&que[i].first);
		que[i].second.second = i;
	}
	sort(que,que + q);
	int qt = 0;
	for(int r = 1; r <= n; r++)
	{
		update(r,1);
		if(last[v[r]] != -1)
			update(last[v[r]], -1);
		last[v[r]] = r;
	
		while(qt < q && que[qt].first == r)
		{
			ans[que[qt].second.second] = query(que[qt].first) - query(que[qt].second.first - 1);
			qt++;
		}
		if(qt == q)
			break;
	}
	for(int i = 0; i < q; i++)
	{
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 23328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VI A(N);
    map<int,LL> mp;
    REP(i,N){
        int a; cin >> a;
        A[i] = a;
        mp[a]++;
    }
    LL ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second-1) / 2;
    }
    REP(i,N){
        cout << ans - (mp[A[i]]-1) << endl;
    }

}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    
    rep(i,n){
        vector<int>a(26),b(26);
        int num=0;
        rep(j,i+1){
            a[s[j]-'a']++;
        }
        arep(j,i+1,n)b[s[j]-'a']++;
        for(int i=0;i<26;i++){
            if(a[i]>0&&b[i]>0)num++;
        }
        ans=max(ans,num);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
 
#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)
 
//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

int main() 
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N;
    cin >> N;
    vector<ll> A(N), pl(N + 1), xo(N + 1);
    rep(i, 0, N) cin >> A[i];
 
    rep(i, 0, N) 
	{
        pl[i + 1] = pl[i] + A[i];
        xo[i + 1] = xo[i] ^ A[i];
    }
 
    int l = 0, r = 1;
    ll ans = 0ll;
    while (r < N + 1) 
	{
        while (pl[r] - pl[l] != (xo[r] ^ xo[l])) 
		{
            l++;
        }
        ans += r - l;
        r++;
    }
 
    cout << ans << endl;
 
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::string> W){
    for(long long i = 1; i < N; ++i){
        //cout << W[i-1].size()-1 << endl;
        //cout << W[i-1][W[i-1].size()-1] << " " << W[i][0] << endl;
        if((count(W.begin(), W.end(), W[i-1]) != 1) || (W[i-1][W[i-1].size()-1] != W[i][0])){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> W(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> W[i];
    }
    solve(N, std::move(W));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b&&b==c){
    cout << 1 << endl;
  }
  else if (a!=b&&b!=c&&c!=a){
      cout << 3 << endl;
  }
  else {
       cout << 2 << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aizu {
    class OnlineJudge {
        static void Main() {
            var dict = Enumerable.Range(0, int.Parse(Console.ReadLine())).Select(p => {
                var input = Console.ReadLine().Split();
                return new { t = input[0], w = input[1], d = Convert.ToDateTime(input[2]) };
            }).ToList();
            var output = new System.Text.StringBuilder();
            for (int i = int.Parse(Console.ReadLine()) - 1; i >= 0; --i) {
                var input = Console.ReadLine().Split();
                var ds = Convert.ToDateTime(input[2] == "*" ? "1970/01/01" : input[2]);
                var db = Convert.ToDateTime(input[3] == "*" ? "2037/12/31" : input[3]);
                foreach (var item in dict.Where(p => (input[0] == "*" || p.t.Contains(input[0])) && (input[1] == "*" || p.w.Contains(input[1])) && (p.d >= ds) && (p.d <= db) )) {
                    output.AppendLine(item.t);
                }
                if (i != 0) {
                    output.AppendLine();
                }
            }
            Console.Write(output.ToString());
        }
    }
}

Measured memory_bytes: 11252
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
using namespace std;

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

	int ret = 0;
	priority_queue<int> que;
	for(int i=0; i<N; i++)
	{
		int s;
		cin >> s;

		ret += s;
		que.push(-s);
	}

	while(que.size()>1 && ret%10==0)
	{
		int a = que.top();
		que.pop();
		if(a%10 != 0)
		{
			ret += a;
			continue;
		}

		int b = que.top();
		que.pop();
		if(b%10 != 0)
		{
			ret += b;
			que.push(a);
			continue;
		}

		que.push(a+b);
	}

	if(ret%10 == 0)
	{
		ret += que.top();
		que.pop();
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
blue = k
red = n-k

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for i in range(1,k+1):
    if red < i-1 :
        ans = 0
    else:
        ans = int( cmb(blue - 1 ,i-1)* cmb (red + 1 , i))
    print(ans % (10**9 + 7))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/


int main() {
  int H,W;
  string s;
  cin >> H >> W;
  const int INF = 1000000;

  vector<string> S(1,string(W+2,'#'));
  vector<Vl> v(H*W, Vl(H*W,INF));
  REP(i,H) {
    cin >> s;
    s = '#' + s + '#';
    S.push_back(s);
  }
  S.push_back(string(W+2,'#'));
// cout << S.at(0) << endl;
  FOR(i,1,H+1){
    // cout << S.at(i) << endl;
    FOR(j,1,W+1) {
      // cout << (i-1)*W+j-1 << endl;
      if (S.at(i).at(j) == '.' && S.at(i).at(j+1) == '.') v.at((i-1)*W+j-1).at((i-1)*W+j) = v.at((i-1)*W+j).at((i-1)*W+j-1) = 1;
      if (S.at(i).at(j) == '.' && S.at(i+1).at(j) == '.') v.at((i-1)*W+j-1).at((i)*W+j-1) = v.at((i)*W+j-1).at((i-1)*W+j-1) = 1;
      if (S.at(i).at(j) == '.') v.at((i-1)*W+j-1).at((i-1)*W+j-1) = 0;
    }
  }
  // cout << S.at(H+1) << endl;

REP(k,H*W){
  REP(i,H*W) {
    REP(j,H*W) {
      v.at(i).at(j) = min(v.at(i).at(j),v.at(i).at(k)+v.at(k).at(j));
      }
  }
}
ll ans=0;
REP(i,H*W) {
  REP(j,H*W) {
    if (v.at(i).at(j) > ans && v.at(i).at(j) < INF) ans = v.at(i).at(j);
  }
}
  
  cout << ans << endl;
}

Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var keyWord = Console.ReadLine();

            if (keyWord == "A") Console.WriteLine("T");
            if (keyWord == "T") Console.WriteLine("A");
            if (keyWord == "C") Console.WriteLine("G");
            if (keyWord == "G") Console.WriteLine("C");
        }
    }
}


Measured memory_bytes: 9044
n = int(input())
import numpy as np
a = np.array(list(map(int,input().split())))
g = []
ans = 0
for j in range(60):
    d = np.count_nonzero(a&1)
    a >>= 1
    g.append(d)
for i in range(60):
    ans += g[i]*(n-g[i])*(pow(2,i,1000000007))
    ans = ans % (1000000007)
print(ans%(1000000007))

Measured memory_bytes: 48788
n = int(input())
s_l = []
h_l = []
c_l = []
d_l = []
for i in range(1, 14):
  s_l.append(i)
  h_l.append(i)
  c_l.append(i)
  d_l.append(i)

for i in range(0, n):
  mark, num = input().split()
  if mark == "S":
    s_l.remove(int(num))
  if mark == "H":
    h_l.remove(int(num))
  if mark == "C":
    c_l.remove(int(num))
  if mark == "D":
    d_l.remove(int(num))

for s in s_l:
  print("S {}".format(s))
for h in h_l:
  print("H {}".format(h))
for c in c_l:
  print("C {}".format(c))
for d in d_l:
  print("D {}".format(d))

Measured memory_bytes: 7728
#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
using namespace std;

#define MAX_M 110

struct edge{int to,cost;};
typedef pair<int,int> P;

vector<edge> c[2][MAX_M];

int dijkstra(int s,int e,bool r){
	bool use[MAX_M];
	for(int i=0;i<MAX_M;i++){
		use[i]=0;
	}
	priority_queue<P,vector<P>,greater< P > > que;
	
	que.push(P(0,s));
	int ans;
	while(!que.empty()){
		P p=que.top();que.pop();
		//cout<<"pop "<<p.second<<" "<<p.first<<endl;
		int v=p.second;
		if(v==e){
			ans=p.first;
			break;
		}
		
		if(use[v]) continue;
		use[v]=1;
		//cout<<"use "<<p.second<<" "<<p.first<<endl;
		for(int i=0;i<c[r][v].size();i++){
			edge e=c[r][v][i];
			//if(!use[e.to]){
				que.push(P(p.first+e.cost,e.to));
			//}
		}
	}
	
	return ans;
}

int main(){
	int n,m;
	while(cin>>n>>m,n!=0||m!=0){
		for(int r=0;r<2;r++){
			for(int i=0;i<MAX_M;i++){
				c[r][i].clear();
			}
		}
		for(int i=0;i<n;i++){
			int a,b,cos,tim;
			cin>>a>>b>>cos>>tim;
			edge co,t;
			co.to=b;co.cost=cos;
			t.to=b;t.cost=tim;
			c[0][a].push_back(co);
			c[1][a].push_back(t);
			co.to=a;t.to=a;
			c[0][b].push_back(co);
			c[1][b].push_back(t);
		}
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int s,e;
			bool r;
			cin>>s>>e>>r;
			int ans=dijkstra(s,e,r);
			cout<<ans<<endl;
		}
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  int tmax = max(a,max(b,c));
  int result=tmax;
  rep(i,k)result *= 2;
  result += (a+b+c-tmax);
  cout<<result;

  return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<bool> pos(100001, false);
	int a[100001], b[100001];
	vector<int> num(100001, 1);
	for (int i = 0; i < m; ++i)
	{
		cin >> a[i] >> b[i];
	}
	pos[1] = true;
	for (int i = 0; i < m; ++i)
	{
		if (pos[a[i]])
		{
			pos[b[i]] = true;
		}
		num[a[i]] -= 1;
		num[b[i]] += 1;
		if(num[a[i]] == 0)
		{
			pos[a[i]] = false;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (pos[i])
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    string s;
    cin >> s;

    cout << s.substr(0, 3) << endl;

    return 0;
}



Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
    char s[6];
    scanf("%s",s);
    if (s[2]==s[3])
    {
        if (s[4]==s[5])
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i,n) cin >> a[i];
	
	bool even=true;
	REP(i,n){
		if(a[i]%2!=0){
			even = false;
			break;
		}
	}
	
	if(even){
		cout << "second" << endl;
	}else{
		cout << "first" << endl;
	}
	
	return 0;
}

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

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

mint dp[2005][2005];

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

  vector<int> s(n), t(m);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < m; i++) cin >> t[i];

  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      dp[i + 1][j] += dp[i][j];
      dp[i][j + 1] += dp[i][j];
      if(s[i] == t[j]) dp[i + 1][j + 1] += dp[i][j];
      dp[i + 1][j + 1] -= dp[i][j];
    }
  }
  mint answer = dp[n][m];
  cout << answer.x << '\n';
}


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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

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


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, m, a;
    cin>>n>>m;
    while (m--) {
        cin>>a;
        n -= a;
    }
    cout<<(n<0?-1:n)<<endl;
}



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

int calculate(int num) {
	if (num / 10 == 0) {
		return num % 10;
	} else {
		return num % 10 + calculate(num / 10);
	}
	return -1;
}

int main() {
	int n, a, b; cin >> n >> a >> b;
	int answer = 0;
	
	for (int i = 1; i <= n; i++) {
		int sum = calculate(i);
		if (sum >= a && sum <= b) answer += i;
	}
	
	cout << answer << endl;
}

Measured memory_bytes: 256
from collections import defaultdict 
import heapq
N,M = map(int, input().split())


"""
最終日から、現在選べるアルバイトの中から最も稼ぎの大きいものから選んでいく
"""
works = defaultdict(list)
for i in range(N):
    a,b = map(int, input().split())
    works[a].append(b)


candidates = []
ans = 0
for i in range(M):
    for money in works[i+1]:
        heapq.heappush(candidates, -money)
    
    if len(candidates) > 0: ans += heapq.heappop(candidates)

print(-ans)

Measured memory_bytes: 27880
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
      mut  t:Chars,
    }

    for i in 0..t.len() {
        if t[i] == '?' {
            print!("D");
        } else {
            print!("{}", t[i]);
        }
    }
    println!();
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
template <class T>
void extgcd(T a, T b, T &x, T &y) {
	T r0 = a, r1 = b, r2;
	T a0 = 1, a1 = 0, a2;
	T b0 = 0, b1 = 1, b2;
	while (r1 > 0) {
		T q1 = r0 / r1;
		T r2 = r0 % r1;
		T a2 = a0 - q1 * a1;
		T b2 = b0 - q1 * b1;
		r0 = r1, r1 = r2;
		a0 = a1, a1 = a2;
		b0 = b1, b1 = b2;
	}
	x = a0, y = b0;
}
int main() {
	int p, q, x, y;
	cin >> p >> q;
	extgcd(p, q, x, y);
	cout << x << ' ' << y << endl;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int n;
int x[105];
int y[105];
int h[105];

int dist(int yy, int xx, int idx) {
	return abs(yy - y[idx]) + abs(xx - x[idx]);
}

int isValid(int yy, int xx) {
	int hh = 0;

	rep(i,0,n) {
		if(h[i] == 0) continue;
		hh = h[i] + dist(yy,xx,i);
		if(hh) break;
	}

	rep(i,0,n) {
		if(h[i] != max(hh - dist(yy,xx,i), 0)) {
			return 0;
		}
	}
	return hh;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(i,0,n) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int ret;
	rep(y,0,101) rep(x,0,101) {
		ret = isValid(y,x);
		if(ret) {
			cout << x << " " << y << " " << ret << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=18;
using namespace std;
typedef long long ll;
const ll inf=1e18;
int n,a[N],x,y,nx,ny,di;
ll f[N][N][1<<N],pl[N],pr[N],now;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",a+i),pl[i]=pr[i]=inf;
	pl[0]=pr[n-1]=0;
	for(int s=(1<<n-1)-1;s;s--){
		x=y=1,nx=ny=0;
		for(di=1;di<<1<=s;di<<=1)
		if(s&di)ny++,y+=x;else nx++,x+=y;
		for(int i=nx;i<n;i++)
		for(int j=i+2;j+ny<n;j++){
			now=inf;
			for(int k=i+1;k<j;k++)
			now=min(now,f[i][k][s^(di<<1)]+
			f[k][j][s^di^(di<<1)]+a[k]*1ll*(x+y));
			f[i][j][s]=now;
		}
	}
	printf("%lld",f[0][n-1][1]+a[0]+a[n-1]);
}

Measured memory_bytes: 278912
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool Getmin(T &a,T b){return ((a<=b)?false:(a=b,true));}
template<typename T> bool Getmax(T &a,T b){return ((a>=b)?false:(a=b,true));}

/*
	 -<Unlimited Blade Works>-
 */

#define LL long long
const int N=1e5+10;

int n,m,q;
LL a[N],c[N],p[N],k;

void Song(int x,LL y)
{
	if(y<=a[1]){p[y]+=k;return;}
	int t=upper_bound(a+1,a+x,y)-a-1;
	//Whats(t);
	if(!a[t])while(true);
	c[t]+=k*(y/a[t]);
	Song(t,y%a[t]);
}

int main()
{
	scanf("%d%d",&n,&q);
	a[m=1]=n;
	for(int i=1;i<=q;++i)
	{
		LL x;
		scanf("%lld",&x);
		for(;m&&a[m]>=x;--m);
		a[++m]=x;
		//Whats(x);
	}
	//exit(0);
	c[m]=1;
	for(int i=m;i>=1;--i)
	{
		k=c[i];
		//Whats(i);
		Song(i,a[i]);
		//exit(0);
	}
	for(int i=n;i>=1;--i)p[i]+=p[i+1];
	for(int i=1;i<=n;++i)printf("%lld\n",p[i]);
	return 0;
}

Measured memory_bytes: 4096
from numba import njit
import numpy as np
import heapq
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=1<<18

@njit(cache=True)
def pos(W,h,w):
    return h * W + w


# @njit(cache=True)
def solve(H,W,Ch,Cw,Dh,Dw,G):
    Ch-=1
    Cw-=1
    Dh-=1
    Dw-=1

    s = (Ch,Cw)
    t = (Dh,Dw)

    hq = [(0,s)]
    heapq.heapify(hq)
    
    dist = [INF] *(H*W) # sからxでの最短距離
    dist[pos(W,*s)] = 0
    while hq: 
        d,x = heapq.heappop(hq) # sからxまでの最短経路を探索する
        if dist[pos(W,*x)] < d: continue

        h,w = x
        normal = set([(h-1,w),(h+1,w),(h,w+1),(h,w-1)])
        for dh in range(-2,3):
            for dw in range(-2,3):
                new_h,new_w = h+dh,w+dw
                e = (new_h,new_w)
                cost = 1

                if dh == 0 and dw == 0: continue
                if not (0<=new_h<H and 0<=new_w<W): continue
                if G[pos(W,*e)] == 1:  continue
                if e in normal:
                    cost -= 1
                
                if dist[pos(W,*e)] > dist[pos(W,*x)] + cost:
                    dist[pos(W,*e)] = dist[pos(W,*x)] + cost
                    heapq.heappush(hq,(dist[pos(W,*e)],e))

    # print(dist)
    if dist[pos(W,*t)] == INF: 
        dist[pos(W,*t)] = -1
        
    return dist[pos(W,*t)]



def main():
    H,W=mi()
    Ch,Cw=mi()
    Dh,Dw=mi()

    G = [0] * H*W
    for i in range(H):
        g = []
        for j,s in enumerate(list(input())):
            G[i*W+j] = s == "#"

    ans = solve(H,W,Ch,Cw,Dh,Dw,np.array(G))
    print(ans)

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')

    cc.export('pos', '(i8,i8,i8,)')(pos)
    cc.export('solve', '(i8,i8,i8,i8,i8,i8,b1[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    try:
        from my_module import solve
        from my_module import pos
    except:
        cc_export()
        exit()

    main()


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

int xplus1(int r, int D, int x) {
  return r*x - D;
}

int main(void){
  int r, D, x2000;
  cin >> r >> D >> x2000;
  
  int ret = x2000;
  for(int i=0; i<10; i++) {
    ret = xplus1(r, D, ret);
    cout << ret << endl;
  }
}

Measured memory_bytes: 256
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

N,M = map(int,input().split())
A = tuple(map(lambda x:int(x)-1,input().split()))

A = [a for a,b in zip(A,A[1:]) if a != b]+[A[-1]]


def it():
    events = [(a+1,-1) for a in A[:-1]] + [(a,p+1) for p,a in zip(A,A[1:])]
    events.sort()
    discount = 0
    cnt = 0
    for a,b in zip(A,A[1:]):
        discount += max2(0, (b-a)%M - 1 - b)
        cnt += int(b < a)
    yield discount
    last = 0
    for a,p in events:
        discount += (a-last)*cnt
        yield discount
        if p < 0:
            cnt += 1
        else:
            cnt -= 1
            discount -= (a-p)%M
        last = a

    yield discount

total = sum((b-a)%M for a,b in zip(A,A[1:]))
print(total - max(it()))

Measured memory_bytes: 36488
#include <bits/stdc++.h>
using namespace std;
map <int,int> m;
vector <int> v;
int main()
{
	int n,x,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(m[x]==0)
		{
			v.push_back(x);
		}
		m[x]++;
	}
	for(int i=0;i<v.size();i++)
	{
		if(v[i]>m[v[i]])
		{
			ans+=m[v[i]];
		}
		else if(v[i]<m[v[i]])
		{
			ans+=m[v[i]]-v[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int COUNT[2001];

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    for (int i = 1; i < N; i ++) {
        for (int j = i + 1; j <= N; j ++) {
            int d = min(j - i, abs(j - Y) + abs(i - X) + 1);
            COUNT[d] ++;
        }
    }
    for (int k = 1; k < N; k ++) {
        cout << COUNT[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php

list($k) = explode(" ", trim(fgets(STDIN)));

$sum=0;
for($i=1;$i<=$k;$i++){
  for($j=1;$j<=$k;$j++){
    $x = gcd($i, $j);
    for($l=1;$l<=$k;$l++){
      $sum+=gcd($x, $l);
    }
  }
}

echo $sum;

// 最小公約数（２つ）（ユークリッドの互除法）
function gcd($a, $b){
  if($b===0){
    return $a;
  }
  return gcd($b, $a%$b);
}


Measured memory_bytes: 16172
MOD = 1000000007

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

array_sum = 0
for i in range(0, n, 1): 
    array_sum += a[i]
    #array_sum%=MOD

array_sum_square = pow(array_sum,2)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2)
    #individual_square_sum%=MOD

ans=(array_sum_square - individual_square_sum) //2
print(ans%MOD)

Measured memory_bytes: 31716
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans=0,temp=0;
    for(size_t i =0;i<S.size();++i){
        
        temp=0;
        for(size_t j =i;j<S.size();++j){

            if(S[j]=='A'||S[j]=='T'||S[j]=='C'||S[j]=='G'){
                temp++;
                ans=max(ans,temp); 
            }else{
                break;
            }
            
        }
        
    }
    cout << ans <<endl;
    return 0;
}

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

int main() {
  int r, g, b, ret;
  cin >> r >> g >> b;
  ret = 100*r + 10*g + b;
  if (ret % 4 == 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    
    double ten_a = h*30 + m*0.5;
    double ten_b = m*6;
    
    double ax = Math.cos(Math.toRadians(ten_a)) * a;
    double ay = Math.sin(Math.toRadians(ten_a)) * a;
    
    double bx = Math.cos(Math.toRadians(ten_b)) * b;
    double by = Math.sin(Math.toRadians(ten_b)) * b;
    
    double ans = (Math.sqrt(Math.pow((ax-bx), 2) + Math.pow((ay-by), 2)));

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 37548
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());
            if (n == 0) break;
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Integer.parseInt(sc.next());
            int max = 0;
            for (int i = 0; i < n; i++)
                for (int j = i + 1; j < n; j++)
                    max = Math.max(max, (a[i] + a[j] <= m)? a[i] + a[j] : 0);
            System.out.println((max == 0)? "NONE" : max);
        }
    }
}


Measured memory_bytes: 43504
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cassert>
#include <random>
#include <time.h>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define re return
#define mp make_pair

using namespace std;

typedef long long ll;

const double pi = 3.14159265;
const ll mod = 1e9 + 7;
const ll N = 3e5 + 5;
const int OMG = 9e6 + 5;
const ll P0 = 281;
const ll P1 = 257;

ll Do (ll n)
{
    if(n == 1)
        return 1;
    return Do(n / 2) * 2 + 1;
}


int main()
{
    //freopen("ladder.in ", "r", stdin);
    //freopen("OMOMOMMG.txt", "w", stdout);
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    cout << Do(n);
}




Measured memory_bytes: 256
local k, a, b = io.read("*n", "*n", "*n")
if b - a <= 2 then
  print(k + 1)
elseif k < a + 1 then
  print(k + 1)
else
  k = k - (a - 1)
  local mul = k // 2
  print(a + mul * (b - a) + k % 2)
end


Measured memory_bytes: 760
ss=input()[::-1]
t=input()[::-1]
# ssの出来るだけ後ろに t を入れ、それ以外は "a" を入れる.

for i in range(len(ss)-len(t)+1):
    match_len=0
    for j in range(len(t)):
        if ss[i+j]=="?" or ss[i+j]==t[j]:
            match_len+=1
        else:
            break
        if match_len==len(t):
            ss=ss[:i]+t+ss[i+len(t):]
            ss=ss.replace("?","a")
            print(ss[::-1])
            exit()
print("UNRESTORABLE")
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_V 100001 //10^5
int d[2][MAX_V];
int V,E;

//numは辺番号。消しても良いし、他の用途に使っても良し
struct edge{
    int to,num;
};
vector<edge> G[MAX_V];

void input_graph(int E){
    int s,t;
    REP(i,E){
        cin>>s>>t;s--;t--;
        G[s].push_back({t,i});
        G[t].push_back({s,i}); //無向グラフの場合
    }
}

//幅優先探索。引数は開始ノード。
void bfs(int stt){
  queue<int> q;q.push(stt);
  vector<bool> used(V,false);used.at(stt)=true;
  int f=(stt?1:0);
  d[f][stt]=0;

  while(!q.empty()){
    int now=q.front();q.pop();
    REP(i,G[now].size()){
      int next=G[now].at(i).to;
      if(!used.at(next)){
        used.at(next)=true;
        d[f][next]=d[f][now]+1;
        q.emplace(next);
      }
    }
  }
}

int main(){
  int ans=0;cin>>V;E=V-1;
  input_graph(E);
  bfs(0);bfs(V-1);
  REP(i,V) if(d[0][i]<=d[1][i]) ans++;
  cout<<(ans>V-ans?"Fennec":"Snuke")<<endl;
}

Measured memory_bytes: 10508
#include <stdio.h>
int main(void)
{
   
       	int n,i;
	
    scanf("%d",&n);

    int a[n],b[n],c[n-1];

    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    for(i=0;i<n-1;i++) scanf("%d",&c[i]);
    
    int t = b[a[0]-1];
    for(i=1;i<n;i++){
        t+=b[a[i]-1];
        if(a[i]-1==a[i-1]) t+=c[a[i-1]-1];
    }
    printf("%d",t);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    int now = INF;
    int p[n];
    REP(i,n){
        cin >> p[i];
        if(p[i] < now) ans++;
        now = min(now, p[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long L){
  double p = L / 3.0;
  printf("%.12f\n", pow(p, 3.0));
}

signed main(){
  long long L;
  scanf("%lld",&L);
  solve(L);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string str;
  cin >> str;
  int x = 700;
  if(str[0]=='o')x += 100;
  if(str[1]=='o')x += 100;
  if(str[2]=='o')x += 100;

  cout<<x<<endl;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    t=max(0,(a*4-b)//2)
    k=max(a-t,0)
    if k*4+t*2==b:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

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

        if (x >= 400 && x <= 599) cout << 8 << endl;
        if (x >= 600 && x <= 799) cout << 7 << endl;
        if (x >= 800 && x <= 999) cout << 6 << endl;
        if (x >= 1000 && x <= 1199) cout << 5 << endl;
        if (x >= 1200 && x <= 1399) cout << 4 << endl;
        if (x >= 1400 && x <= 1599) cout << 3 << endl;
        if (x >= 1600 && x <= 1799) cout << 2 << endl;
        if (x >= 1800 && x <= 1999) cout << 1 << endl;


        return 0;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
  double W,H,x,y,z;
  cin >> W>>H>>x>>y;
  z=W*H/2;
  cout << z<<endl;
  if(W/2==x && H/2==y){
    cout << 1 <<endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

bool check(int sum){
	if(sum>0) return true;
	else return false;
}

int main(){
	string O,E;
	cin>>O>>E;
	REP(i,(int)(O.length()+E.length())){
		if(i%2==0) printf("%c",O[i/2]);
		else printf("%c",E[i/2]);
	}
	puts("");
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	cout << a + b + c + d - min(min(min(a, b), c), d) + max(e, f) << endl;
	cin >> c;
}

Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<vector<long double>> dp;

void solve()
{
	int n;

	cin >> n;

	dp.assign(2, vector<long double>(n + 1, 0));


	long double res = 0;

	for (int i = 0; i < n; i++)
	{
		long double p;
		cin >> p;
		if (i == 0)
		{
			dp[0][1] = p;
			dp[0][0] = 1 - p;

			continue;
		}

		for (int k = 0; k <= i + 1; k++)
		{
			dp[i & 1][k] = (1 - p) * dp[(i + 1) & 1][k];
			
			if (k)
			{
				dp[i & 1][k] += p * dp[(i + 1) & 1][k - 1];
			}

			//cout << dp[i & 1][k] << " ";
		}
		//cout << "\n";
	}

	for (int i = n / 2 + 1; i <= n; i++)
	{
		res += dp[(n - 1) & 1][i];
	}

	cout << fixed << setprecision(12) << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

typedef struct
{
	double x;
	double y;
}POSITION;

int main( void )
{
	POSITION pos[4];
	int n;
	int i;
	int j;
	
	scanf( "%d\n", &n );
	for( i = 0; i < n; i++ )
	{
		for( j = 0; j < 4; j++ )
		{
			scanf( "%lf %lf", &pos[j].x, &pos[j].y );
		}
		if( (pos[0].y - pos[1].y) / (pos[0].x - pos[1].x) == (pos[2].y - pos[3].y) / (pos[2].x - pos[3].x) )
		{
			printf( "YES\n" );
		}
		else
		{
			printf( "NO\n" );
		}
	}
	
	return (0);
}

Measured memory_bytes: 620
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int n;
deque<int> Q;

int main() {
	n=read();
	for (int i=1;i<=n;++i) {
		int w=read();
		if (i&1) Q.push_back(w);
		else Q.push_front(w);
	}
	if (n&1) {
		while (!Q.empty()) printf("%d ",Q.back()),Q.pop_back();
	} else {
		while (!Q.empty()) printf("%d ",Q.front()),Q.pop_front();
	}
	return 0;
}

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

#define int long long

int a,b;

signed main()
{
	cin>>a>>b;
	if(abs(a-b)%2==1)
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<min(a,b)+abs(a-b)/2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    ll L,R; cin>>L>>R;
    ll ans = 1e19;
    if(R-L>=2019){
        cout<<0<<endl;
        return 0;
    }

    for (ll i = L; i < R; ++i) {
        for (ll j = L+1; j <= R; ++j) {
            ans = min(ans,(i*j % 2019));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		cout << a * b;
		return 0;
	}
	cout <<- 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
typedef long double ld;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;
const ll inf = 1e18;
const int maxn = 200005;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())    s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

int main(int argc, char const *argv[])
{
	ll k, n;
	int a[maxn];
	cin >> k >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	for (int i = n; i >= 1; --i)
	{
		a[i] = a[i] - a[i - 1];
	}

	ll sum = 0;
	for (int i = 2; i <= n; ++i)
	{
		sum += a[i];
	}
    a[1] = k - sum;
    ll max = -1;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] > max)
		{
			max = a[i];
		}
	}
	cout << k - max;
	return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll n,a;
ll x[51]={};
ll dp[55][55][2505]={};

ll dfs(int i, int cnt, int sum){
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    ll res=0;
    if (i == n){
        if(cnt != 0){
            res = ((double)sum/cnt == (double)a);
        }else{
            res = 0;
        }
    }else{
        res = dfs(i + 1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);
    }

    return dp[i][cnt][sum] = res;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Measured memory_bytes: 59392
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main(){
   ll n,a[202020],ans=0,l=0,x=0,c=0;
   cin>>n;
   rep(i,n){
      cin>>a[i];
   }
   rep(i,n){
      while((x+a[i])!=(x^a[i])){
         
         x-=a[i-c];
         c--;

      }
      x+=a[i];
      c++;
      ans+=c;
   }
   cout<<ans<<endl;

}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}

int main(){
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n) {
        int a;
        cin >> a;
        if(!m[a]) m[a] = 1;
        else m[a] = 0;
    }

    int cnt = 0;
    for(auto p : m) {
        if(p.second != 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 4992