akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (1<<18) + 10;

int n, v[N], w[N], pre[N];
vector<pii> dp[N];

void clean(vector<pii> &dp) {
    sort(all(dp));
    int mx = -1;
    vector<pii> ndp;
    int i = 0;
    while (i < si(dp)) {
        while (i+1 < si(dp) && dp[i].first == dp[i+1].first) ++i;
        if (dp[i].second > mx) {
            mx = dp[i].second;
            ndp.pb(dp[i]);
        }
        ++i;
    }
    dp = ndp;
}

int query(const vector<pii> &a, const vector<pii> &b, int L) {
    int n = si(a), m = si(b);
    int j = m-1, ans = 0;
    forn(i,n) {
        while (j >= 0 && a[i].first + b[j].first > L) --j;
        if (j < 0) break;
        ans = max(ans, a[i].second + b[j].second);
    }
    return ans;
}

vector<pii> merge(const vector<pii> &a, const vector<pii> &b) {
    vector<pii> ans;
    ans.reserve(si(a)+si(b));
    int n = si(a), m = si(b), mx = -1;
    int i = 0, j = 0;
    while (i < n && j < m) {
        if (a[i].first < b[j].first || (a[i].first == b[j].first && a[i].second >= b[j].second)) {
            if (a[i].second > mx) {
                ans.pb(a[i]);
                mx = a[i].second;
            }
            i++;
        }
        else {
            if (b[j].second > mx) {
                ans.pb(b[j]);
                mx = b[j].second;
            }
            j++;
        }
    }
    while (i < n) {
        if (a[i].second > mx) {
            ans.pb(a[i]);
            mx = a[i].second;
        }
        i++;
    }
    while (j < m) {
        if (b[j].second > mx) {
            ans.pb(b[j]);
            mx = b[j].second;
        }
        j++;
    }
    return ans;
}

void compute_dp(int i) {
    if (!dp[i].empty()) return;

    vi nodes;
    int u,lvl;
    for (u = i, lvl = 0; u != 0 && lvl < 9; u = u/2, lvl++) {
        nodes.pb(u);
    }
    pre[i] = u;

    int sz = 1;
    dp[i].eb(0,0);
    for (auto j : nodes) {
        vector<pii> ndp(sz);
        forn(k,sz) ndp[k] = {dp[i][k].first + w[j], dp[i][k].second + v[j]};
        dp[i] = merge(dp[i], ndp);
        sz = si(dp[i]);
    }
}

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

    cin >> n;
    dp[0].eb(0,0);
    for (int i = 1; i <= n; i++) 
        cin >> v[i] >> w[i];

    int q; cin >> q;
    while (q--) {
        int v,L; cin >> v >> L;
        compute_dp(v);
        compute_dp(pre[v]);
        cout << query(dp[v], dp[pre[v]], L) << '\n';
    }

    return 0;
}


Measured memory_bytes: 404960
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>

using namespace std;
int gcd(int x,int y)
{
	if (y==0)
	{
		return x;
	}
	else
	{
		return gcd(y, x%y);
	}
}
int lcm(int x, int y)
{
	return x / gcd(x, y)*y;
}

int main()
{
	long long a, b;
	long long Gcd, Lcm;
	while (scanf("%lld%lld",&a,&b) != EOF)
	{
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, m;
  cin >> n >> m;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int covered = 0;
  vector<int> cover_vector(n + 1);
  vector<int> count_vector(n + 1);
  auto inc = [&](int k) {
    if (DEBUG) cout << "inc: " << k << endl;
    int count = count_vector[k];
    int cover_index = k - count;
    if (cover_index >= 1)  {
      cover_vector[cover_index]++;
      if (cover_vector[cover_index] == 1) {
        covered++;
      }
    }
    count_vector[k]++;
  };

  auto dec = [&](int k) {
    if (DEBUG) cout << "dec: " << k << endl;
    int count = count_vector[k];
    int uncover_index = k - count + 1;
    if (uncover_index >= 1) {
      if (DEBUG) cout << "uncover_index: " << uncover_index << endl;
      cover_vector[uncover_index]--;
      if (cover_vector[uncover_index] == 0) {
        if (DEBUG) cout << "decrement covered" << endl;
        covered--;
      }
    }
    count_vector[k]--;
  };

  for (int x : xs) {
    inc(x);
  }

  auto dump_cover_vector = [&]() {
    cout << "covered: ";
    for (int i = n; i >= 1; i--) {
      cout << cover_vector[i] << " ";
    }
    cout << endl;
  };
  if (DEBUG) dump_cover_vector();

  for (int i = 0; i < m; i++) {
    int index, value;
    cin >> index >> value;
    index--;
    dec(xs[index]);
    inc(value);
    xs[index] = value;

    if (DEBUG) dump_cover_vector();
    cout << n - covered << endl;
  }
}

Measured memory_bytes: 3840
#include <stdio.h>

void dice(int saikoro[6], char *direct);
int main(void){
	int i;
	int saikoro[6];
	char direct[101];

	for(i=0; i<6; i++){
		scanf("%d",&saikoro[i]);
	}
	scanf("%s",direct);
	dice(saikoro,direct);

	printf("%d\n",saikoro[0]);
	return 0;
}
void dice(int saikoro[6], char *direct){
	int i,tmp;

	for(i=0; i<strlen(direct); i++){
		switch(direct[i]){
			case 'N':
	            tmp = saikoro[0];
	            saikoro[0] = saikoro[1];
	            saikoro[1] = saikoro[5];
	            saikoro[5] = saikoro[4];
	            saikoro[4] = tmp;
	            
	            break;
	        case 'W':
	        	tmp = saikoro[0];
	            saikoro[0] = saikoro[2];
	            saikoro[2] = saikoro[5];
	            saikoro[5] = saikoro[3];
	            saikoro[3] = tmp;         
	            break;
	        case 'E':
	        	tmp = saikoro[0];
	            saikoro[0] = saikoro[3];
	            saikoro[3] = saikoro[5];
	            saikoro[5] = saikoro[2];
	            saikoro[2] = tmp;
	            break;
	        case 'S':
	        	tmp = saikoro[0];
	            saikoro[0] = saikoro[4];
	            saikoro[4] = saikoro[5];
	            saikoro[5] = saikoro[1];
	            saikoro[1] = tmp;
	            break;
	        default:
	        	break;
		}
	}

}

Measured memory_bytes: 604
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/
#include <bits/stdc++.h>
#define newline ("\n")
#define deb(x) cerr << (#x) << " = " << (x) << '\n'
#define FOR(x, n) for (int x = 0; x < n; x++)
#define PI (3.141592653589)

#define MOD 1000000007
using namespace std;

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

    // Pikachu, I choose you
    int n;
    cin >> n;
    int arr[n+1][3];
    for(int i = 1;i<=n;i++)
    {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2] ;
    }
    int dp[n+1][3];
    for(int i = 1;i<=n;i++)
    {
        for(int j = 0;j < 3;j++)
        {
            if(i == 1)
            {
                dp[i][j] = arr[i][j];
            }
            else
            {
                dp[i][j] = dp[i-1][(j+1)%3] + arr[i][j];
                dp[i][j] = max(dp[i][j], dp[i-1][(j+2)%3] + arr[i][j]);
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    string S;
    cin >> S;


    string ans;
    ans = "Good";

    if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]) ans = "Bad";



    cout << ans << endl;



}


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

int main()
{
    int n, count = 0;
    bool flag = 1;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    while (flag)
    {
        rep(i, n) {
            if (a[i] % 2 != 0) {
                flag = 0;
                break;
            } else {
                a[i] /= 2;
            }
        }
        if (flag) count++;
    }
    
    cout << count;

    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  long long A, B;
  while (cin >> A >> B) {
    int step = 0;
    if (A == 0 && B == 0)
      break;
    if (A < B)
      swap(A, B);
    for (int i = 0; B > 0; i++) {
      A = A % B;
      swap(A, B);
      step++;
    }
    cout << A << ' ' << step << endl;
  }
  return 0;
}

Measured memory_bytes: 2992
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	S := make([]string, N)

	var ac, wa, tle, re int

	for i := 0; i < N; i++ {
		fmt.Scan(&S[i])
	}

	for i := 0; i < N; i++ {
		switch S[i] {
		case "AC":
			ac += 1
		case "WA":
			wa += 1
		case "TLE":
			tle += 1
		case "RE":
			re += 1
		}
	}
	fmt.Printf("AC x %d\n", ac)
	fmt.Printf("WA x %d\n", wa)
	fmt.Printf("TLE x %d\n", tle)
	fmt.Printf("RE x %d\n", re)

}


Measured memory_bytes: 6872
#include<bits/stdc++.h>
using namespace std;
int N,K;
vector<int>a,dp;
bool dfs(int k) {
	if(dp[k]>-1) return dp[k];
	for(int i=0;i<N;i++)
		if(a[i]<=k&&!dfs(k-a[i])) {
			dp[k]=1;
			return 1;
		}
	dp[k]=0;
	return 0;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	a.resize(N),dp.resize(K+1,-1);
	for(int i=0;i<N;i++) cin>>a[i];
	cout<<(dfs(K)==1?"First\n":"Second\n");
	return 0;
}


Measured memory_bytes: 8220
//AtCoder ABC096 C - Grid Repainting 2
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll H,W; cin>>H>>W;
    vector<string> sw(H);
    for(auto&& s:sw){
        cin>>s;
    }
    auto check_func = [&](ll y,ll x){
        if(y>=0&&y<H&&x>=0&&x<W){
            return (sw[y][x]=='#');
        }
        return false;
    };
    bool ans=true;
    for(ll y=0;y<H;++y){
        for(ll x=0;x<W;++x){
            //隣接があるかチェック
            if(sw[y][x]=='#'){
				if(!check_func(y - 1, x) && !check_func(y + 1, x) &&
				   !check_func(y, x - 1) && !check_func(y, x + 1))
                {
					ans = false;
					break;
				}
			}
		}
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double dis(double,double,double,double);

int main(){
  double x1,y1,x2,y2;
  double distance;

  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  printf("%.8f\n",dis(x1,y1,x2,y2));

  return 0;
}

double dis(double x1,double y1,double x2,double y2){
  double dis;

  dis=sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));

  return dis;
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  rep(i, N) {
    int p;
    cin >> p;
    if (p != i + 1)
      cnt++;
  }
  if (cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
// priority queue
#include<iostream>
#include<string>
#define MAX 2000000
#define nINF -1
int parent(int);
int left(int);
int right(int);
void maxHeapify(int*, int);
void buildMaxHeap(int*);
void insert(int*, int);
void heapIncreaseKey(int*, int);
int extractMax(int*);
int n=0;
int main(){
  int *T, key;
  std::string func, ins="insert", ext="extract", end="end";
  T = new int[MAX];
  while(1){
    std::cin >> func;
    if(func == end) break;
    else if(func == ins){
      std::cin >> key;
      insert(T, key);
    }
    else if(func == ext) std::cout << extractMax(T) << "\n";
  }
  return 0;
}
int parent(int x){
  return x/2;
}
int left(int x){
  return 2*x;
}
int right(int x){
  return 2*x+1;
}
  void maxHeapify(int *A, int i){
    int l=left(i), r=right(i), largest, temp;
    if(l <= n && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= n && A[r] > A[largest]) largest = r;
    if(largest != i){
      temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;
      maxHeapify(A,largest);
    }
  }
  void buildMaxHeap(int *A){
    int i;
    for(i=n/2; i>0; i--) maxHeapify(A,i);
  }
  void insert(int *A, int key){
    n++;
    A[n] = nINF;
    heapIncreaseKey(A, key);
  }
  void heapIncreaseKey(int *A, int key){
    int temp, i=n;
    if(key < A[i]) std::cout << "Error\n";
    A[i] = key;
    while(i > 1 && A[parent(i)] < A[i]){
      temp = A[i];
      A[i] = A[parent(i)];
      A[parent(i)] = temp;
      i = parent(i);
    }
  }
  int extractMax(int *A){
    int max;
    if(n < 1) std::cout << "Error\n";
    max = A[1];
    A[1] = A[n];
    n--;
    maxHeapify(A,1);
    return max;
  }

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

const int INF = 1e6;

struct RMQ {
	using type = int;
	static type id() { return INT_MAX; }
	static type op(const type& l, const type & r) { return min(l, r); }
};

template <typename M>
class starry_sky_tree {
	using T = typename M::type;
	const int n;
	vector<T> data, lazy;
	int size(int x) {
		int res = 1;
		while (res < x) res <<= 1;
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (r <= lb || ub <= l) return M::id();
		if (l <= lb && ub <= r) return data[node];
		return M::op(sub(l, r, node << 1, lb, (lb + ub) >> 1)
			, sub(l, r, (node << 1) | 1, (lb + ub) >> 1, ub)) + lazy[node];
	}
	void suc(int l, int r, int node, int lb, int ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data[node] += val;
			lazy[node] += val;
			return;
		}
		suc(l, r, node << 1, lb, (lb + ub) >> 1, val);
		suc(l, r, (node << 1) | 1, (lb + ub) >> 1, ub, val);
		data[node] = M::op(data[node << 1], data[(node << 1) | 1]) + lazy[node];
	}
public:
	starry_sky_tree(int n_) : n(size(n_)), data(n << 1), lazy(n << 1) {}
	void add(int l, int r, T val) {
		suc(l, r, 1, 0, n, val);
	}
	T find(int l, int r) {
		return sub(l, r, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	int Q;
	cin >> Q;
	vector<pair<int, int>> lr;
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r; --l;
		lr.emplace_back(l, r);
	}
	sort(lr.begin(), lr.end());
	starry_sky_tree<RMQ> dp(N + 1);
	int it = 0;
	dp.add(1, N + 1, INF);
	for (int i = 0; i < N; i++) {
		while (it < Q && lr[it].first == i) {
			int l, r;
			tie(l, r) = lr[it++];
			int x = dp.find(0, r);
			int v = dp.find(r, r + 1);
			dp.add(r, r + 1, min(0, x - v));
		}
		if (b[i]) {
			dp.add(0, i + 1, 1);
		}
		else {
			dp.add(i + 1, N + 1, 1);
		}
	}
	cout << dp.find(0, N + 1) << endl;
	return 0;
}


Measured memory_bytes: 7280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n, k, r, s, p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    char u[n];
    for(int i = 0; i < n; i++){
        if(i < k){
            if(t.at(i) == 'r'){
                ans += p;
                u[i] = 'p';
            }
            else if(t.at(i) == 's'){
                ans += r;
                u[i] = 'r';
            }
            else{
                ans += s;
                u[i] = 's';
            }
        }
        else{
            if(t.at(i) == 'r'){
                if(u[i - k] == 'p')
                    u[i] = '1';
                else{
                    u[i] = 'p';
                    ans += p;
                }
            }
            else if(t.at(i) == 's'){
                if(u[i - k] == 'r')
                    u[i] = '1';
                else{
                    u[i] = 'r';
                    ans += r;
                }
            }
            else{
                if(u[i - k] == 's')
                    u[i] = '1';
                else{
                    ans += s;
                    u[i] = 's';
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3828
N, K = map(int, input().split())

Bs = [0 for i in range(N + 1)]
for _ in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As:
        Bs[a] += 1
cnt = 0
for b in Bs[1:]:
    if b == 0:
        cnt += 1
# print(Bs)
print(cnt)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double lb;
const ll MOD=1;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
void IOS(){	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return ;}
string x,y;
ll n,v[105],w[105],dp[3005][3005],k;

ll f(int a,int b){
	if(a>=x.size()||b>=y.size())return 0;
	if(dp[a][b]!=-1)return dp[a][b];
	ll tmp=0;
	if(x[a]==y[b]){tmp=1+f(a+1,b+1);}
	tmp=max(tmp,f(a,b+1));
	tmp=max(tmp,f(a+1,b));
	return dp[a][b]=tmp;
}

int main(){
	IOS();
	memset(dp,-1,sizeof(dp));
	cin>>x>>y;
	f(0,0);
	ll d=0,u=0;
	while(d<x.size()&&u<y.size()){
		if(x[d]==y[u]&&1+dp[d+1][u+1]>=max(dp[d+1][u],dp[d][u+1])){
			cout<<x[d];
			d++;u++;
		}else{
			if(dp[d+1][u]>dp[d][u+1]){
				d++;
			}else{
				u++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 71296
#include <stdio.h>
#define N 20000001

int B[N], C[N], A[N], n;

void CountingSort(int k)
{
  int i, j;
  for(i = 0; i <= k; i++)
    {
      C[i] = 0;
    }
  for(j = 1;j <= n;j++)
    {
      C[A[j]]++;
    }
  for(i = 1;i <= k;i++)
    {
      C[i] = C[i] + C[i - 1];
    }
  for(j = n;j > 0;j--)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
}

int main()
{

  int i;
  int max = 0;

  scanf("%d",&n);

  for(i = 1;i <= n;i++)
    {
      scanf("%d", &A[i]);
      if(max < A[i])
	{
	  max = A[i];
	}
    }

  CountingSort(max);

  for(i = 1;i <= n;i++)
    {
      if(i > 1) printf(" ");
      printf("%d",B[i]);
    }
  printf("\n");
  return 0;
}

     

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

int main(){
  
  int a,b,t,i;
  cin >> a >> b >> t;
  
  i=0;
  
  while(i*a < t+0.5){
    i++;
  }
  
  cout << b*(i-1) << endl;
 
  return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
vector<vector<int>> set_pascal(int N) {
    vector<vector<int>> c(N, vector<int>(N, 0));

    for (int i = 0; i < N; i++) {
        c[i][0] = 1;

        for (int j = 1; j <= i; j++) {
            c[i][j] = c[i-1][j] + c[i-1][j-1];
        }
    }

    return move(c);
}

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

    int v[N];
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v, v + N, greater<>());

    vector<vector<int>> comb = set_pascal(N + 1);

    int ret = -1;
    int ret_p = 0;
    int num = -1;

    for (int p = A; p <= B; p++) {
        int sum = 0;
        int min_elem_selected_num = 0;
        int min_elem_unselected_num = 0;

        for (int i = 0; i < p; i++) sum += v[i];
        if (sum * ret_p < ret * p) continue;

        int min_elem = v[p-1];

        for (int i = 0; i < p; i++) {
            if (v[i] == min_elem) min_elem_selected_num++;
        }

        for (int i = p; i < N; i++) {
            if (v[i] == min_elem) min_elem_unselected_num++;
        }

        if (ret * p == sum * ret_p) {
            num += comb[min_elem_selected_num + min_elem_unselected_num][min_elem_selected_num];
        } else {
            num = comb[min_elem_selected_num + min_elem_unselected_num][min_elem_selected_num];
        }

        ret = sum;
        ret_p = p;
    }

    cout << fixed << setprecision(6) << 1.0 * ret / ret_p << endl;
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
unordered_map<ll, ll> mp;

const int MAX_N = 100;
int prime[MAX_N];
bool isPrime[MAX_N+1];

int seive(int n){
    int p = 0; //p番目の素数
    for(int i=0;i<=n;i++) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for(int i=2; i<=n; i++){
        if(isPrime[i]){
            prime[p++] = i;
            for(int j=2*i; j<=n; j+=i) isPrime[j] = false;
        }
    }
    return p; //n以下の素数の数を返す.
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    ll n; cin >> n;

    int num = seive(n);
    for(int i=0; i<num; i++) {
        int cur = prime[i];
        while(cur <= n) {
            mp[prime[i]] += n/cur;
            cur *= prime[i];
        }
    }

    ll ans = 0;
    // 14, 4
    int cnt14=0, cnt4=0;
    for(auto &[k,v]: mp) {
        if(v >= 4) cnt4++;
        if(v >= 14) cnt14++;
    }
    ans += cnt14 * (cnt4-1);

    int cnt24=0, cnt2=0;
    int cnt74=0;
    for(auto &[k,v]: mp) {
        if(v >= 24) cnt24++;
        if(v >= 2) cnt2++;
        if(v >= 74) cnt74++;
    }
    ans += cnt24 * (cnt2-1);

    ans += cnt4 * (cnt4-1) / 2 * (cnt2-2);
    ans += cnt74;

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


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

int main(){
	int A,B,C,D;
    cin >> A >> B >> C >> D;
    int l,r;
    l = A + B;
    r = C + D;
    if(l<r){
    	cout << "Right" << endl;
    }
    else if(l>r){
    	cout << "Left" << endl;
    }
	else cout << "Balanced" << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 998244353;

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

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  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;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  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;
  }
};

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int M = S.size();
  S.pb('x');

  vector<ll> fact(N + 1);
  fact[0] = 1;
  fact[1] = 1;
  repp(i, 2, N) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= MOD;
  }

  vector<int> rgb(3);
  map<char, int> m;
  m['R'] = 0;
  m['G'] = 1;
  m['B'] = 2;

  mint ans = 1;
  rep(i, M) {
    char now = S[i];
    rgb[m[now]]++;
    int x = rgb[m[now]];
    int y = rgb[(m[now] + 1) % 3];
    int z = rgb[(m[now] + 2) % 3];

    if (y < z)
      swap(y, z);

    if (x > y) {
      int temp = x - y;
      ans *= temp;
    } else if (x <= y && x > z) {
      int temp = x - z;
      ans *= temp;
    }
  }
  ans *= fact[N];
  cout << ans.x << endl;
}

Measured memory_bytes: 1412
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  
  for (int i = 0; i < 10000; i++) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      cout << i << endl;
      return (0);
    }
  }
  
  cout << -1 << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
    ll ans=0;
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++){
        if(i==n-1){
            ans+=(a[i])/2;
            continue;
        }
        if(a[i]==0)continue;
        ans+=(a[i]/2);
        if(a[i]%2==1){
            if(a[i+1]>0){
                ans++;
                a[i+1]--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll a[n+3];
    F(i,0,n-1)cin>>a[i];
    ll kq[n+99];
    kq[0]=0;
    F(i,1,min(n,k))kq[i]=abs(a[i]-a[0]);
    F(i,k+1,n-1)
    {
        kq[i]=LONG_MAX;
        F(j,1,k)
        kq[i]=min(kq[i],kq[i-j]+abs(a[i]-a[abs(i-j)]));
    }
    cout<<kq[n-1];
}



Measured memory_bytes: 1792
import numpy
from operator import add
from functools import reduce

N = int(input())
A = list(map(int, input().split()))

minus_num = 0
abs_A = []
for a in A:
    if a < 0:
        minus_num += 1
    abs_A.append(numpy.abs(a))

if minus_num % 2 == 0:
    print(reduce(add, abs_A))
else:
    abs_A.sort()
    print(reduce(add, abs_A[1:])-abs_A[0])


Measured memory_bytes: 23296
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		UL p = 0;
		UL ans = 0;
		while (p < N) {
			if (p == N - 1) { ans++; p++; break; }
			if (A[p] == A[p + 1]) { p++; continue; }
			bool inc = A[p] < A[p + 1];
			p++;
			if (inc) {
				while (p < N) {
					if (A[p - 1] <= A[p]) p++; else break;
				}
			}
			else {
				while (p < N) {
					if (A[p - 1] >= A[p]) p++; else break;
				}
			}
			ans++;
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

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

int main() {
  string S;
  cin >> S;
  int res = 0;
  int a = 0;
  rep(i,S.size()){
    if (S[i] == 'R')
      a++;
    else{
      res = max(res,a);
      a = 0;
    }
  }
  cout << max(res,a) << endl;
}

Measured memory_bytes: 3628
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
mod = 10**9 + 7
n, m = map(int, input().split())
diff = max(n, m) - min(n, m)

if diff >=  2:
    print(0)
    exit()

inup = math.factorial(n)
sarup = math.factorial(m)
if diff == 0:
    val = inup * sarup * 2
    print(val%mod)
elif diff == 1:
    val = inup * sarup
    print(val%mod)

Measured memory_bytes: 55152
#include <iostream>
#include <string>

using namespace std;

class Card {
public:
  int init_order;
  char pattern[3];
public:
  int value(){
    //if(pattern.length() == 2){
      return pattern[1] - '0';
    //}
    //return 0;
  }
  int InitOrder(){
    return init_order;
  }
  string Pattern(){
    string x = pattern;
    return x;
  }
  Card(string pattern,int order){
    this->pattern[0] = pattern[0];
    this->pattern[1] = pattern[1];
    this->pattern[2] = '\0';
    this->init_order = order;
  }
  Card(){}
};

class CardList {
  int count;
  int capacity;
  Card *data;
public:
  int Count(){return count;}
  CardList(CardList &original);
  CardList(int capacity){
    this->data = new Card[capacity];
    this->capacity = capacity;
    this->count = 0;
  }
  ~CardList(){
    delete [] data;
  }
  void Add(string pattern){
    Card c(pattern, count);
    data[count] = c;
    count++;
  }
  Card &operator[](int i){
    return data[i];
  }
  void output();
  bool isStable();
};

CardList::CardList(CardList &original){
  this->data = new Card[original.capacity];
  //cout << "debug original.capacity = " << original.capacity << endl;
  for(int i = 0; i < original.capacity; i++){
    this->data[i] = original.data[i];
    //cout << "debug this->data[i] = " << this->data[i].Pattern();
    //cout << " original.data[i] = " << original.data[i].Pattern();
    //cout << endl;
  }
  this->capacity = original.capacity;
  this->count = original.count;
}

bool CardList::isStable(){
    for(int i = 1; i < count; i++){
      if(data[i].value() == data[i- 1].value() &&
        data[i].InitOrder() < data[i-1].InitOrder()){
        return false;
      }
    }
    return true;
}
void CardList::output(){
  for (int i = 0; i < count; i++) {
    //cout << "debug i = " << i << endl;
    cout << data[i].Pattern();
    if (i == count - 1){
      cout << endl;
    } else {
      cout << " ";
    }
  }
  if (isStable()){
    cout << "Stable\n";
  } else {
    cout << "Not stable\n";
  }
}
void swap(Card &a,Card &b){
  Card tmp = a;
  a = b;
  b = tmp;
}

void BubbleSort(CardList &C){
  for (int i = 0; i < C.Count(); i++) {
    for (int j = C.Count() - 1; j >= i + 1; j--) {
      if(C[j].value() < C[j - 1].value()){
        swap(C[j], C[j - 1]);
      }
    }
  }
}

void SelectionSort(CardList &C){
  for(int i = 0; i < C.Count(); i++){
    int minJ = i;
    for(int j = i; j < C.Count(); j++){
      if(C[j].value() < C[minJ].value()){
        minJ = j;
      }
    }
    swap(C[i], C[minJ]);
  }
}

int main(){
  int num;
  cin >> num;
  CardList c(num);
  for(int i = 0; i < num; i++){
    string pattern;
    cin >> pattern;
    c.Add(pattern);
  }

  CardList c1 = c;
  BubbleSort(c1);
  c1.output();

  CardList c2 = c;
  SelectionSort(c2);
  c2.output();

}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
char s[20],t[50];

void registration(int i)
{
    while(i>=0)
    {
        if(s[i]==t[i])
            i--;
        else
        {
            printf("No");
            cout<<endl;
            return;
        }
    }
    printf("Yes");
    cout<<endl;

    return;

}

main()
{
    int i=0;
    scanf("%s%s",s,t);
    i=strlen(s);
    //cout<<i<<endl;
    registration(i-1);



}

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {
    //Strings with the Same Length
    //
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        System.out.println(helper(s, t, n));
        sc.close();
    }

    static String helper(String s, String t, int n) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(s.charAt(i));
            sb.append(t.charAt(i));
        }
        return sb.toString();
    }
}


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

int main()
{
    string s;
    cin >> s;

    rep (i, 3)
        if (s[i] == '1')
            cout << "9";
        else
            cout << "1";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramE
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] ss = Console.ReadLine().Split(' ');
            long x = long.Parse(ss[0]);
            long y = long.Parse(ss[1]);
            long a = long.Parse(ss[2]);
            long b = long.Parse(ss[3]);
            long c = long.Parse(ss[4]);
            string[] pi = Console.ReadLine().Split(' ');
            string[] qi = Console.ReadLine().Split(' ');
            string[] ri = Console.ReadLine().Split(' ');
            long[] p = new long[a];
            long[] q = new long[b];
            long[] r = new long[c];
            long[] s = new long[x + y + c];

            for(long i = 0;i < a;i++)
                p[i] = long.Parse(pi[i]);

            for(long i = 0;i < b;i++)
                q[i] = long.Parse(qi[i]);

            for(long i = 0;i < c;i++)
                r[i] = long.Parse(ri[i]);

            
            Array.Sort(p);
            Array.Sort(q);

            for(long i = 0;i < x;i++)
                s[i] = p[a- 1- i];

            for(long i = 0;i < y;i++)
                s[x + i] = q[b - 1- i];
            
            for(long i = 0;i < c;i++)
                s[x + y+ i] = r[i];

            Array.Sort(s);

            long ans = 0;
            
            
            for(long i = 0; i < x + y;i++)
                ans +=s[x + y+ c-1 - i];


            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 43620
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
ll MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> s;
    vector<ll> g;
    ll m;
    cin >> m;
    for (int i = 0;i<m;i++){
        ll a, b;
        cin >> a >> b;
        if(a==1){
            s.push_back(b);
        }
        if(b==1){
            s.push_back(a);
        }
        if(a==n){
            g.push_back(b);
        }
        if(b==n){
            g.push_back(a);
        }
    }
    sort(g.begin(), g.end());
    for (int i = 0;i<s.size();i++){
        if(binary_search(g.begin(),g.end(),s[i])){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 2004
#include<bits/stdc++.h>
    using namespace std;
    #define PAIN___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < ll, ll >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 100005
    #define sqr(i) i*i;
   /* string with spaces   getline(cin,s);*/
   /*
          integer to string              ll n=0;  ostringstream o1;  string s; o1<<n; s=o1.str();
    */



int main()
{

map<string ,int>m;
ll n;
cin>>n;
forl(i,0,n,n)
{

    string s;
    cin>>s;
    sort(s.begin(),s.end());
    m[s]++;
}
ll ans=0;
map<string ,int>::iterator itr;
for(itr=m.begin();itr!=m.end();itr++)
{

    ll k=itr->se;
    ans+=(k)*(k-1)/2;
}
cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m;
    cin>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [*map(int, input().split())]
MOD = (10**9)+7
S = [0] * (n+1)
for i in range(n): S[i+1] = S[i] + A[i]
ans = 0
for i in range(n): ans = (ans + A[i] * (S[-1] - S[i+1])) % MOD
ans = (ans + MOD) % MOD
print(ans)


Measured memory_bytes: 31524
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if (y-(i*10000+j*5000))/1000==(n-i-j):
            print(str(i)+' '+str(j)+' '+str(n-i-j))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			long N=Long.parseLong(sc.next());
			long A=Long.parseLong(sc.next());
			long B=Long.parseLong(sc.next());
			long nowX=Long.parseLong(sc.next());;
			
			long nextX;
			long degree=0;
			for(int i=1;i<N;i++){
				nextX=Long.parseLong(sc.next());
				degree+=((nextX-nowX)*A>B)?B:((nextX-nowX)*A);
				nowX=nextX;
			}
			
			
			
			System.out.println(degree);
		}
	}
}


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

using namespace std;


int main(){
  int n;
  cin >> n;
  for(int i=0;i<3;i++){
    int tmp=n%10;
    n=n/10;
    if(tmp==7){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int b, e, k;
        std::cin >> b >> e >> k;
        int count = std::count(A.begin() + b, A.begin() + e, k);
        std::cout << count << std::endl;
    }
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

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

    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    cout << ceil((float)(n-1) / (k-1)) << endl;
    return 0;
}

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

#include <iostream>
using namespace std;
int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double c2 = a * a + b * b -
              2 * a * b * cos((m / 60. - (h / 12 + m / 60. / 12.)) * 2 * M_PI);
  cout << fixed << setprecision(10) << sqrt(c2) << endl;
  return 0;
}


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

int greatest(int a, int b, int c){
    int hcf,st;
	
 	st=a<b?(a<c?a:c):(b<c?b:c);
 
	 for (hcf=st;hcf>=1;hcf--)
 	{
  	  if (a%hcf==0 && b%hcf==0 && c%hcf==0)
  		 break;
 	} 
 
	return hcf;
}

int main(void){
  int k;
  cin>>k;
  
  long long int sum = 0;
  for(int i = 1; i <= k; i++) {
      for(int j = 1; j <= k; j++) {
          for(int a = 1; a <= k; a++) {
              sum += greatest(a,i,j);
          }
      }
  }
  
  cout<<sum;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(){
	int N,M,j=0;
	long long int mod=1000000007;
	scanf("%d%d",&N,&M);
	int a[M];
	long long int dp[N+1];
	for(int i=0;i<M;i++){
		scanf("%d",&a[i]);
	}
	dp[0]=0;
	for(int i=1;i<=N;i++){
		if(a[j]==i){
			//printf("a[%d]==%d\n",j,i);
			dp[i]=0;
			j++;
		}else if(i==1)dp[1]=1;
		else if(i==2 && dp[1]==1)dp[2]=2%mod;
		else if(i==2 && dp[1]==0)dp[2]=1%mod;
		else dp[i]=(dp[i-1]+dp[i-2])%mod;
		//printf("dp[%d]=%lld\n",i,dp[i]);
	}
	printf("%lld\n",dp[N]);
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if(A % 2 + B % 2 + C % 2 != 0) return !printf("0\n");
    if((A == B) && (B == C)) return !printf("-1\n");
    for(int i=1; ; i++) {
        if(A>>i&1 && B>>i&1 && C>>i&1)      return !printf("%d\n", i+1);
        else if(A>>i&1 || B>>i&1 || C>>i&1) return !printf("%d\n", i);
    }
}

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

Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';
int64 res[110][101000] = {0};
int64 calc(vpii &inp, int w) {
	int p = 1;
	for (auto t : inp) {
		for (int i = 1; i <= w; i++) {
			if (i < t.F)
				res[p][i] = res[p - 1][i];
			else
				res[p][i] = max(res[p - 1][i] , res[p - 1][i - t.F] + (int64)t.S);
		}
		p++;
	}
	// for1(i, w) {
	// 	cout << res[i] << " ";
	// }
	// cout << nwl;
	return res[p - 1][w];
}



int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, w;
	cin >> n >> w;
	vpii inp;
	for0(i, n) {
		int w, v;
		cin >> w >> v;
		inp.pb({w, v});
	}
	sort(all(inp));
	int64 ans = calc(inp, w);
	cout << ans;

	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	bool ok = true;
	map<string, int> m;
	char moji;
	for (int ii = 0; ii < N; ++ii){
		string w;
		cin >> w;

		if (ii > 0){
			if(m[w] || w[0] != moji){
				ok = false;
				break;
			}
		}

		m[w] = 1;
		moji = w[w.size()-1];
	}

	if (ok){
	cout << "Yes" << "\n";
	} else {
	cout << "No" << "\n";
	}


	return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

string f(int a, int b) {
    if (a > b && a > b * 2) {
        return ":(";
    }
    if (a < b && a * 2 < b) {
        return ":(";
    }

    return "Yay!";
}

int main() {

    int a, b;
    cin >> a >> b;

    string result = f(a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<tuple>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	int s[100][100]={};
	for(int i=0; i<n; i++){
		int x, y, a;
		cin >> x >> y >> a;
		if(a==1){
			for(int j=0; j<x; j++){
				for(int k=0; k<h; k++)
					s[j][k]++;
			}
		}
		else if(a==2){
			for(int j=x; j<w; j++){
				for(int k=0; k<h; k++)
					s[j][k]++;
			}
		}
		else if(a==3){
			for(int j=0; j<w; j++){
				for(int k=0; k<y; k++)
					s[j][k]++;
			}
		}
		else if(a==4){
			for(int j=0; j<w; j++){
				for(int k=y; k<h; k++)
					s[j][k]++;
			}
		}
	}
	int sum=0;
	for(int i=0; i<w; i++){
		for(int j=0; j<h; j++){
			if(!s[i][j])
				sum++;
		}
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	int n = 0, m = 0, x = 0, y = 0;
	cin >> n >> m >> x;
	//人数、初期ｐ、問題数
	int B[100001];
	rep(i, n)B[i] = 0;
	rep(i, x) {
		cin >> y;
		B[y-1]++;
	}
	rep(i, n) {
		B[i] += m;
	}
	rep(i, n) {
		B[i] -= x;
		if (B[i] <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;

	}
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define slmt 101    /*slmt:手札文字数限界*/
#define winp 3    /*勝利ポイント*/
#define drowp 1    /*引き分けポイント*/

int main(void){
    char tarou[slmt], hanako[slmt];    /*tarou:太郎手札, hanako:花子手札*/
    int times, x;    /*times:ゲーム回数, x:ループ変数*/
    int twin=0, hwin=0;    /*twin:太郎勝利回数, hwin:花子勝利回数*/
    
    /*入力部*/
        scanf("%d\n", &times);    /*回数を読み取る*/
        /*ゲーム状況は読み込みは判定とともに行う*/
        
    /*判定部*/
        for(x=0; times>x; x++){    
            scanf("%s %s\n", &tarou, &hanako);    /*ゲーム状況読み込み*/
            if (strcmp(&tarou, &hanako) > 0){    /*勝敗判定＆ポイント加算*/
                twin += winp;    /*太郎勝利加算*/
            }else if (strcmp(&tarou, &hanako) < 0){
                hwin += winp;    /*花子勝利加算*/
            }else{
                twin += 1;    /*引き分け加算*/
                hwin += 1;
            }
        }
        
    /*出力部*/
        printf("%d %d\n", twin, hwin);    /*各ポイントを1行出力*/
        
    return 0;
}

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  bool reversing = false;
  str(s4);
  int lenn = length(s4);
  deque<string> s(lenn);
  for (int i = 0; i < lenn; ++i) {
    s[i] = s4[i];
  }

  int1(q);
  for (int i=0; i < q; ++i) {
    int1(t);
    if(t==2){
      int1(f);
      str(c);
      if(f==1){
        if(reversing){
          s.push_back(c);
        }else{
          s.push_front(c);
        }
      }else{
        if(!reversing){
          s.push_back(c);
        }else{
          s.push_front(c);
        }
      }
    }else{
      reversing = !reversing;
    }
  }
  if(reversing){
    for (int i = length(s)-1; i >= 0; i--) {
      cout << s[i];
    }
  }else{
    for (int i = 0; i < length(s); ++i) {
    cout << s[i];
  }
  }
  cout<<endl;

}


Measured memory_bytes: 17152
n=int(input())
out=[0,0]
for _ in range(n):
    lst=input().split()
    if lst[0]==lst[1] :
        out[0]+=1
        out[1]+=1
    elif lst[0]<lst[1]:
        out[1]+=3
    else : out[0]+=3

print(" ".join(map(str,out)))



Measured memory_bytes: 5596