akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, K; cin >> N >> K;
  
  //main
  ll ans = 0;
  ans = min(N%K,K-(N%K));
  
  // output
  cout << ans << endl;

  return 0;
}



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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  vector<char> c(n);
  for(int i=0; i<n; i++) c[i] = s[i];
  
  sort(c.begin(),c.end());
  
  vector<int> w(26);
  
  int j = 0;
  
  for(int i=0; i<n; i++){
    if(i == 0) w[0]++;
    
    else{
      if(c[i] == c[i-1]) w[j]++;
      
      else{
        j++;
        w[j]++;
      }
    }
  }
  
    int count = 0;
    
    for(int i=0; i<26; i++){
      if(w[i]%2 == 0) count++;
    }
    
    if(count == 26) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define p pair<ll,ll>
#define pb push_back
#define mp make_pair
#define PI 3.14159265359

using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >>c;
    
    if(a+b+c > 21){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for _ in range(N):
    t, x, y = map(int,input().split())
    tn = t - t0
    xn = x - x0
    yn = y - y0
    if abs(xn) + abs(yn) <= tn and (abs(xn) + abs(yn)) % 2 == (tn % 2):
        t0 = t
        x0 = x
        y0 = y
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

set<int> v;

template <typename Edge, typename T>
bool BellmanFord(const vector<Edge> &edge, int V, int s, int t, T &ans, T inf = 1e15) {
    vector<T> dist(V, inf);
    dist[s] = 0;
    for (int i = 0; i < V; i++) {
        for (auto &e : edge) {
            if (dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i + 1 == V && v.count(e.to) && v.count(e.from)) {
                    return false;
                }
            }
        }
    }
    ans = dist[t];
    return true;
}

struct Edge {
    i64 from, to, cost;
};

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<Edge> edge_all(M), edge_valid;
    vector<set<int>> edge_list[2] = {vector<set<int>>(N), vector<set<int>>(N)};
    for(int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        A--, B--;
        edge_all[i] = {A, B, -(C - P)};
        edge_list[0][A].insert(B);
        edge_list[1][B].insert(A);
    }
    {
        set<int> s[2];
        for(int b = 0; b < 2; b++) {
            queue<int> q;
            s[b].insert(b ? N - 1 : 0);
            q.push(b ? N - 1 : 0);
            while (q.size()) {
                int p = q.front();
                q.pop();
                for (auto x : edge_list[b][p]) {
                    if (!s[b].count(x)) {
                        s[b].insert(x);
                        q.push(x);
                    }
                }
            }
        }
        set_intersection(WHOLE(s[0]), WHOLE(s[1]), inserter(v, v.end()));
    }
    for(auto e : edge_all) {
        if(v.count(e.from) && v.count(e.to)) {
            edge_valid.push_back(e);
        }
    }
    i64 ans;
    if(BellmanFord<Edge, i64>(edge_valid, N, 0, N - 1, ans)) {
        cout << max<i64>(0, -ans) << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
h,w,a,b=map(int,input().split())
mod=pow(10,9)+7

# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1]
for i in range( 2, 200000 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans=0
for k in range(1,h-a+1):
  tmp=cmb(k-1+b-1,k-1,mod)
  tmp*=cmb(h-k+w-b-1,h-k,mod)
  ans+=tmp
  ans%=mod
print(ans)

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

int main() {
	string s; cin>>s;
	for(int len=s.size(),i=0;i<len;i++)
		if(s[i]=='?') printf("%c",'D');
		else printf("%c",s[i]);
	return 0;
}

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

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)

using ll = int64_t;

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

const ll inf = 2e18;

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

	int n, w; cin >> n >> w;
	ll v[n], c[n]; rep(i, 0, n) cin >> c[i] >> v[i];

	ll dp[n][w + 1];
	rep(i, 0, n) dp[i][0] = 0;
	rep(x, 0, w + 1) dp[0][x] = c[0] <= x ? v[0] : 0;
	rep(i, 1, n)
		rep(x, 1, w + 1) {
			dp[i][x] = dp[i - 1][x];
			if (c[i] <= x)
				ckmax(dp[i][x], dp[i - 1][x - c[i]] + v[i]);
		}
	cout << dp[n - 1][w];
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
  double a, b, c;
  cin >> a >> b;
  c = (1 / a) + (1 / b);
  c = 1 / c;
  cout << fixed << setprecision(20) << c << endl;
    return 0;
}


Measured memory_bytes: 256
int main(void){
  int a,b,n,x,i;

  for(;;){
    i=0;
    scanf("%d%d",&n,&x);
    if(n+x == 0) break;

    for(a=1;a<=n;a++)
      for(b=a+1;b<=n;b++)
        if(b < x-a-b && x-a-b <= n)
          i++;

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

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

ll N, D;

ll v(ll i, ll j) {
	return i * D + j;
}

ll w(ll i, ll j) {
	return D * D + i * D + j;
}

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

	vector<ll> x(N + 1), y(N + 1);
	repn(i, N) cin >> x[i] >> y[i];

	vector<vector<ll>> a(D, vector<ll>(D, 0));

	repn(i, N) {
		a[x[i] % D][y[i] % D]++;
	}

	ll m = 0;

	rep(i, D)rep(j, D) {
		m = max(m, a[i][j]);
	}

	ll K = sqrt(m - 1) + 1;

	//cout << K << endl;

	vector<vector<ll>> c(D, vector<ll>(D, 0));

	rep(i, D)rep(j, D) {
		if (a[i][j] <= (K - 1)*(K - 1)) { c[i][j] = 0; }
		else if (a[i][j] <= (K - 1)*K) { c[i][j] = 1; }
		else { c[i][j] = 2; }
		//cout << i << j << c[i][j] << endl;
	}

	ll M = D * D *2;

	vector<vector<ll>> g(M);
	
	rep(i, D)rep(j, D) {
		rep(k, 4) {
			ll I = (i + k / 2) % D;
			ll J = (j + k % 2) % D;
			g[v(i, j)].push_back(w(I,J));
			g[w(I,J)].push_back(v(i, j));
		}
	}

	vector<ll> dis(M, -1);
	queue<ll> q;

	vector<ll> ver(D, 0);
	vector<ll> hor(D, 0);
	rep(i, D)rep(j, D) {
		if(c[i][j]==2){
			ver[i] = 1;
			hor[j] = 1;
		}
	}

	rep(i, D)rep(j, D) {
		if (ver[i] == 1 || hor[j] == 1 || c[i][j] == 1) {
			dis[v(i, j)] = 0;
			q.push(v(i, j));
		}
	}

	ll maxdis = 0;

	while (!q.empty()) {
		ll x = q.front();
		q.pop();

		for (ll y : g[x]) {
			if (dis[y] == -1) {
				q.push(y);

				dis[y] = dis[x] + 1;
				maxdis = dis[y];

				//cout << y << dis[y] << endl;
			}
		}
	}

	//cout << maxdis << endl;

	ll ans = D * K - maxdis;
	cout << ans;



	system("PAUSE");
}


Measured memory_bytes: 182288
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b,c; cin>>a>>b>>c;
  int m=max({a,b,c});
  int n=min({a,b,c});
  int t=a+b+c-m-n;
  cout<<m*10+t+n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a, a + n);
  vector<int> num(9,0);
  rep(i,n) {
    if(a[i] >= 3200) {
      num[8]++;
      continue;
    }
    rep(j, 8) {
      if(a[i] < 400 * (j+1)) {
        num[j]++;
        break;
      }
    }
  }
  int c = count(num.begin(), num.end(), 0);
  int k = num[8];
  if(k == 0) c--;
  int mi = 8 - c, mx = (8 - c) + k;
  if(mi == 0) mi++;
  cout << mi << " " << mx << endl;

  return 0;
}


Measured memory_bytes: 256
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

const gcd = (args: number[]) => {
  let f: (a: number, b: number) => number = (a,b) => b ? f(b, a%b) : a;
  let ans = args[0];
  for(let i=0; i<args.length; i++) {
    ans = f(ans, args[i]);
  }
  return ans;
} 

input.shift();
console.log(gcd(input.map(mp => +mp)));

Measured memory_bytes: 26572
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll N, M;
vl ed[100100];
vl dist;

ll dfs(ll x){
    if(dist[x] != -1) return dist[x];
    ll ans = 0;
    for(auto y : ed[x]){
        ans = max(ans, dfs(y)+1);
    }
    return dist[x] = ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    dist = vl(N+1, -1);
    REP(i, M){
        ll x, y; cin >> x >> y;
        ed[x].pb(y);
    }
    ll ans = 0;
    REP(i, N){
        ans = max(ans, dfs(i+1));
    }
    cout << ans << endstr;
    return 0;
}


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

int main() {
	int N, a[100000][2] = {}, ans = 0, tmp = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> a[i][0];
	for (int i = 0; a[i][0] != 2; ++ans) {
		if (a[i][1] == 1) {
			tmp = 1;
			break;
		}
		a[i][1] = 1;
		i = a[i][0] - 1;
	}
	if (tmp == 0) cout << ans + 1;
	else cout << -1;
}

Measured memory_bytes: 1024
N = int(input())
p = list(map(int, input().split()))
plen = len(p)

count = 0

for i in range(plen):
    if p[i] == i + 1:
        if p[i] == N:
            p[i - 1], p[i] = p[i], p[i - 1]
        else:
            p[i], p[i + 1] = p[i + 1], p[i]
        count += 1
    
            
print(count)


Measured memory_bytes: 14008
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,a[nmax],i,mx;
map<int,int>mp;
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i],mp[a[i]]++;
	for(i=1;i<=n;i++)mx=max(mx,mp[a[i]-1]+mp[a[i]]+mp[a[i]+1]);
	cout<<mx<<endl;
	return 0;
}

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

using namespace std;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

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

    int inf = 1000000000, dp_n = 401;
    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(dp_n, vector<int>(dp_n, inf)));
    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < dp_n; j++) {
            for (int k = 0; k < dp_n; k++) {
                if (dp[i][j][k] < inf) {
                    dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                    dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
                }
            }
        }
    }

    int res = inf;
    for (int i = 1; i * ma < dp_n && i * mb < dp_n; i++) {
        res = min(res, dp[n][i * ma][i * mb]);
    }

    if (res < inf) {
        cout << res << endl;
    } else {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int ans[60001];
  scanf("%d",&n);
  memset(ans,0,sizeof(ans));
  for(int x=1;x<=100;x++)
  {
    for(int y=1;y<=100;y++)
    {
      for(int z=1;z<=100;z++)
        ans[x*x+y*y+z*z+x*z+y*z+x*y]++;
    }
  }
  for(int i=1;i<=n;i++)
    printf("%d\n",ans[i]);
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,q,a;
main(){
	cin>>n;
	vector<int>v(n);
	r(i,n)cin>>v[i];;
	cin>>q;
	while(q--){
		cin>>a;
		vector<int>::iterator it= lower_bound(v.begin(),v.end(),a);
		if(it==v.end()||(*it)!=a)cout<<0<<endl;
		else cout<<1<<endl;
	}
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int W, H; cin >> W >> H;
	int N; cin >> N;
	vector<int> x(N), y(N), a(N);
	for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> a[i];
	int left = 0, right = W, up = H, down = 0;
	for(int i = 0; i < N; i++) {
		if(a[i] == 1) left = max(left, x[i]);
		else if(a[i] == 2) right = min(right, x[i]);
		else if(a[i] == 3) down = max(down, y[i]);
		else up = min(up, y[i]);
	}
	int ans = max(0, max(0,(right - left)) * max(0,(up - down)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
using System;

class Program
{
	public static void Main(string[] args)
	{
		string S = Console.ReadLine();
		int w = int.Parse(Console.ReadLine());

		string outputS = "";
        
		int i = 0;
		while(true){
			outputS += S.Substring(i, 1);
			i += w;
			if (i >= S.Length) break;
		}
		Console.WriteLine(outputS);
	}
}



Measured memory_bytes: 13140
from collections import defaultdict

N = int(input())
S = input()
Q = int(1e9 + 7)

d = defaultdict(int)

for s in S:
    d[s] += 1

ans = 1
for k, v in d.items():
    ans *= (v + 1)
    ans %= Q
ans -= 1
print(ans)

Measured memory_bytes: 3444
//https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d
#include<bits/stdc++.h>
using namespace std;

#define ll long long

const int N = 1e6 + 3;
int m;
pair<int, ll> a[N];

void init() {
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %lld", &a[i].first, &a[i].second);
	}
}

pair<int, ll> combine(pair<int, ll> p1, pair<int, ll> p2) {
	auto tmp = p1;
	tmp.first += p2.first;
	tmp.second += p2.second + 1;
	if (tmp.first > 9) {
		tmp.first -= 9;
		tmp.second++;
	}
	return tmp;
}

vector<int> v;

pair<int, ll> get(pair<int, ll> p) {
	//cerr << p.first << " " << p.second << "\n";
	int num = p.first;
	ll cnt = p.second;
	ll steps = 0;
	while (cnt > 1) {
		steps += cnt / 2;	
		if (cnt % 2) {
			v.push_back(num);
		}
		cnt /= 2;
		num *= 2;
		if (num > 9) {
			num -= 9;
			steps += cnt;
		}
	}
	pair<int, ll> ret = {num, steps};
	while (v.size()) {
		ret = combine(ret, {v.back(), 0});
		v.pop_back();
	}
	return ret;
}

void solve() {
	auto ans = get(a[0]);
	for (int i = 1; i < m; i++) {
		//cerr << ans.first << " " << ans.second << "\n";
		ans = combine(ans, get(a[i]));
	}
	//cerr << ans.first << " " << ans.second << "\n";
	printf("%lld\n", ans.second);
}

int main() {
	init();
	solve();
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    ans += B[i] - ((A[i] + ans + B[i] - 1) % B[i] + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template
set <int> st,en;
set <int> :: iterator itr1,itr2;
int n,m;
vpii v;
int ans;
int main(){
	//IO();
//    ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int s,e;
        cin>>s>>e;
        v.pb(mp(e,s));
    }
    ans = 1;
    sort(v.begin(),v.end());
    int cur = v[0].fi;
    for(int i=0;i<v.size();i++){
        if(v[i].se < cur )continue;
        else{
            ans++;
            cur = v[i].fi;
        }
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 1400
A,B,C,D = list(map(int, input().split()))

from fractions import gcd

g = gcd(C,D)
l = C*D //g
k = l - (l//C) - (l//D) + 1 #l以下で、割り切れないのはk個
#print(g,l,k)
def n_not_devided_c_or_d(n):
  if n//l:
    return n_not_devided_c_or_d(n%l) + k * (n//l)
  return n - n//C - n//D

#print(n_not_devided_c_or_d(B))
#print(n_not_devided_c_or_d(A-1))

print(n_not_devided_c_or_d(B) - n_not_devided_c_or_d(A-1))

Measured memory_bytes: 5688
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define sc second
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define pb push_back
#define endl '\n'
#define po(x) (1ll<<x)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> satan_set;
const ll DIM = 10E4+7;
const ll INF = 10E16;
ll A[DIM],pref[DIM],suf[DIM];
int main()
{
    //freopen("input.txt","r",stdin);
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;

    forn(i,n)cin>>A[i];

    sort(A+1,A+1+n);
    ll l = 0,r = DIM*2;
    while(l!=r){
        ll tm = (l+r+1)/2;
        ll p = 1;
        ll cnt = 0;
        for(ll i = n;i>=1;i--){
            while(p<n && A[i]+A[p]<tm)p++;
            if (A[i]+A[p]>=tm)cnt+=n-p+1;
        }
        //cout<<cnt<<endl;
        if (cnt<m)r = tm-1;
        else l = tm;
        //cout<<l<<' '<<r<<' '<<cnt-m<<endl;
    }

    ll cnt = 0;

    ll p = 1;
    for(ll i = n;i>=1;i--){
        while(p<n && A[i]+A[p]<l)p++;
        if (A[i]+A[p]>=l)cnt+=n-p+1;
    }
   // cout<<cnt-m<<endl;
    ll c = l+1;
    for(ll i = n;i>=1;i--)suf[i] = suf[i+1]+A[i];
    ll res = 0;
    p = 1;
    for(ll i = n;i>=1;i--){
        while(p<n && A[i]+A[p]<c)p++;
        if (A[i]+A[p]>=c){
            res+=suf[p]+(n-p+1)*A[i];
            m-=(n-p+1);
        }
    }
    res+=m*l;
    cout<<res<<endl;
   // cout<<l<<endl;
    return 0;
}

// 1 2 3
//


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            // {0, 1, ..., n-1} の部分集合の全探索
            int n = S.Length - 1;
            long sum = 0;
            for (int bit = 0; bit < (1 << n); ++bit)
            {
                string part = S[0].ToString();
                for (int i = 0; i < n; ++i)
                {
                    if ((bit & (1 << i)) != 0)
                    {
                        sum += long.Parse(part);
                        part = S[i + 1].ToString();
                    }
                    else
                    {
                        part += S[i + 1];
                    }
                }

                sum += long.Parse(part);
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
n, m = map(int, input().split())
cnt = [0] * m
for i in range(n):
    a = list(map(int, input().split()))
    for x in a:
        cnt[x - 1] += 1
    cnt[a[0]-1] -= 1

ans = 0
for i in range(m):
    ans += cnt[i] == n
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int a[1005],b[1005],c[1005];

typedef long long ll;
ll dp[1 << 12];
const ll INF = 1e14;

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

  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    for(int j = 0; j < b[i]; j++) {
      int cc;
      cin >> cc;
      c[i] |= (1 << (cc - 1));
    }
  }
  for(int i = 0; i < (1 << n); i++) dp[i] = INF;
  dp[0] = 0;
  
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < (1 << n); j++) {
      if(dp[j] == INF) continue;
      dp[j | c[i]] = min(dp[j | c[i]],dp[j] + a[i]);
    }
  }

  if(dp[(1 << n) - 1] == INF) cout << -1 << endl;
  else cout << dp[(1 << n) - 1] << endl;
}

      
  
    


Measured memory_bytes: 256
// Author - Sumit

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define int ll
#define ps push
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

const int N=1e5+5;
vi v[N];
bool vis[N];
int dis[N];

void dfs(int p){
    // cout<<p<<" ";
    vis[p]=true;
    for(auto x:v[p]){
        if(!vis[x])
            dfs(x);
        dis[p] = max(dis[p],dis[x]+1);
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    rep(i,1,n+1){
        if(!vis[i])
            dfs(i);
    }
    int res=0;
    rep(i,1,n+1){
        res = max(res,dis[i]);
    }
    debug(res);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t=1;
    // cin>>t;
    WL(t){
        solve();
    }    
}

Measured memory_bytes: 8704
import sys

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


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

    a_max = max(A)
    a_len = len(A)
    keta = 0

    while True:
        a_max = a_max // 2
        keta += 1
        if a_max == 0:
            break

    # print(keta)
    t = [[0 for _ in range(keta)] for _ in range(2)]

    for k in range(keta):
        for a in A:
            a = a & (2**k)
            a = a >> k
            t[a][k] += 1

    # print(t)

    ans = 0
    for k in range(keta):
        ans += (t[0][k] * t[1][k]) * pow(2, k, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 124304
#include<cstdio>
#include<iostream>
using namespace std;
int n,a,b,ans;
int mi[300010],inv[300010];
long long k;
const int mod=998244353;
int fast_pow(int x,int a)
{
	int ans=1;
	for (;a;a>>=1,x=1ll*x*x%mod) if (a&1) ans=1ll*ans*x%mod;
	return ans;
}
int C(int n,int m)
{
	return 1ll*mi[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	mi[0]=1;for (int i=1;i<=n;i++) mi[i]=1ll*mi[i-1]*i%mod;
	inv[n]=fast_pow(mi[n],mod-2);
	for (int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for (int i=0;i<=n;i++)
	{
		long long j=(k-1ll*a*i)/b;if (j>n||j<0) continue;
		if (1ll*a*i+1ll*b*j==k)
			ans=(1ll*C(n,i)*C(n,j)+ans)%mod;
	}
	printf("%d",ans);
}

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

ll gcd(ll m, ll n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {//最小公倍数
    return m / gcd(m, n) * n;
}

int main() {
  ll a,b,c,d,l;
  cin>>a>>b>>c>>d;
  l= lcm(c, d);
  a--;
  cout<<b-a-((b/c+b/d-b/l)-(a/c+a/d-a/l)) <<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
 
int main()
{
	LL a, b, n ,m;
	cin >> a >> b;
	m = max(a, b);
	n = min(a, b);
	if(n == 1)
	{
		if(m == 1) printf("1\n");
		else if(m == 2)
			cout << 0 << endl;
		else
			cout << m - 2 << endl;
	}
	else if(n == 2)
		cout << 0 << endl;
	else
	cout << n * m - (2 * n + 2 * m - 4) << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[3];
    scanf("%s",s);
    if(s[0]=='a'&&s[1]=='b'&&s[2]=='c'){
        printf("Yes\n");
    }
    else if(s[0]=='a'&&s[1]=='c'&&s[2]=='b'){
        printf("Yes\n");
    }
    else if(s[0]=='b'&&s[1]=='a'&&s[2]=='c'){
        printf("Yes\n");
    }
    else if(s[0]=='b'&&s[1]=='c'&&s[2]=='a'){
        printf("Yes\n");
    }
    else if(s[0]=='c'&&s[1]=='a'&&s[2]=='b'){
        printf("Yes\n");
    }
    else if(s[0]=='c'&&s[1]=='b'&&s[2]=='a'){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
MOD = 10**9 + 7
class mint:
    def __init__(self, i):
        self.i = i
    def __add__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __radd__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __mul__(self, m):
        return mint(self.i * (m.i if isinstance(m, mint) else m) % MOD)
    def __sub__(self, m):
        t = self.i - (m.i if isinstance(m, mint) else (m % MOD))
        if t < 0:
            t += MOD
        return mint(t)
    def __pow__(self, m):
        i = self.i
        return mint(pow(i, m, MOD))
    def __truediv__(self, m):
        return mint(self.i * pow(m, MOD - 2, MOD) % MOD)
    def __repr__(self):
        return repr(self.i)


n, k = map(int, input().split())

l, r = 1, n + 1
while r - l > 1:
    c = (l + r) // 2
    if c ** 2 <= n:
        l = c
    else:
        r = c
r = l # less than or equal to sqrt(n)
# 1 ... r - 1, r, (r, n/r], ... (n/3, n/2], (n/2, n]
# (a, b] ... count for each elem in (a, b], not sum
# (r, n/r] is ignored if r*r == n
dp = [mint(0) for _ in range(2 * r)]
dp[0] = mint(1)
for _ in range(k):
    ndp = [mint(0) for _ in range(2 * r)]
    for i in range(1, r + 1):
        pre_cnt = dp[i - 1]
        if i == r and r ** 2 == n:
            ndp[r - 1] += pre_cnt
        else:
            ndp[-i] += pre_cnt
    for i in range(1, r + 1):
        if i == r and r ** 2 == n:
            continue
        pre_cnt = dp[-i]
        upper = n // i
        lower = r + 1 if i == r else 1 + n // (i + 1)
        ndp[i - 1] += pre_cnt * (upper - lower + 1)
    acc = mint(0)
    for i in range(r * 2 - 1, -1, -1):
        if i == r and r ** 2 == n:
            continue
        acc += ndp[i]
        dp[i] = acc

ans = mint(0)
for i in range(1, r + 1):
    ans += dp[i - 1]
for i in range(1, r + 1):
    upper = n // i
    lower = r + 1 if i == r else 1 + n // (i + 1)
    ans += dp[-i] * (upper - lower + 1)
print(ans)


Measured memory_bytes: 148260
N,M = map(int,input().split())
swi = [[]for i in range(N)]
for i in range(M):
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:
        swi[j-1].append(i)
p = list(map(int,input().split()))
ans = 0
for i in range(2**N,2**(N+1)):
    ramp = [0]*M
    i = bin(i)
    for j in range(N):
        if i[j+3] == "1":
            for k in swi[j]:
                ramp[k] += 1
    for i in range(M):
        ramp[i] = ramp[i]%2
    if ramp == p:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  ll m,d;
  cin>>m>>d;
  auto cul=[](ll m,ll d)->int{
             if(d%10>=2 && d/10>=2 && (d%10)*(d/10)==m){return 1;}
             return 0;
           };
  ll ans=0;
  for(ll i=1;i<=m;i++){
    for(ll j=1;j<=d;j++){
      ans+=cul(i,j);
    }
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

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




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    ll N = S.size();
    vl L, R;
    rep(i, N){
        if(S[i] == 'L') L.pb(i);
        if(S[i] == 'R') R.pb(i);
    }
    
    vl ans(N, 0);
    rep(i, N){
        if(S[i] == 'L'){
            auto didx = --lower_bound(ALL(R), i)-R.begin();
            auto d = R[didx];
            ll mv = d-i;
            if(mv%2 == 0) ans[d]++;
            else ans[d+1]++;
        }
        else if(S[i] == 'R'){
            auto didx = lower_bound(ALL(L), i)-L.begin();
            auto d = L[didx];
            ll mv = d-i;
            if(mv%2 == 0) ans[d]++;
            else ans[d-1]++;
        }
    }
    rep(i, N) cout << ans[i] << " ";
    cout << endstr;
    return 0;
}


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

int main()
{
  int N; cin >> N;
  vector<vector <int>> hap(N, vector<int> (3));
  for (int i = 0; i < N; i++) {
    cin >> hap[i][0] >> hap[i][1] >> hap[i][2];
  }

  vector<vector<int>> dp(N+1, vector<int>(3, 0));

  for (int i = 0; i < N; i++)
  {
    dp[i + 1][0] = max(dp[i][1] + hap[i][0], dp[i][2] + hap[i][0]);
    dp[i + 1][1] = max(dp[i][0] + hap[i][1], dp[i][2] + hap[i][1]);
    dp[i + 1][2] = max(dp[i][0] + hap[i][2], dp[i][1] + hap[i][2]);
  }

  int ans = max({ dp[N][0], dp[N][1], dp[N][2] });
  cout << ans << endl;
}

Measured memory_bytes: 11136
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut c_map = HashMap::new();
    c_map.entry(&'a').or_insert(0);
    c_map.entry(&'b').or_insert(0);
    c_map.entry(&'c').or_insert(0);
    for c in s.iter() {
        let count = c_map.entry(c).or_insert(0);
        *count += 1;
    }
    let mut ans = true;

    if (*c_map.get(&'a').unwrap() as i32 - *c_map.get(&'b').unwrap() as i32).abs() > 1 {
        ans = false;
    }
    if (*c_map.get(&'a').unwrap() as i32 - *c_map.get(&'c').unwrap() as i32).abs() > 1 {
        ans = false;
    }
    if (*c_map.get(&'b').unwrap() as i32 - *c_map.get(&'c').unwrap() as i32).abs() > 1 {
        ans = false;
    }

    println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

bool check(int n){
    int l=to_string(n).length();
    return l%2;
}

int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(check(i))ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    double R;
    in(R);
    double pi = 3.1415926;
    cout << 2*R*pi << endl;

	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];
    int ans[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        ans[i] = arr[i];
    }
    sort(ans, ans + n);
    int index_1 = -1;
    int index_2 = -1;
    for (int i = 0; i < n; i++) {
        if (arr[i] != ans[i] && index_1 == -1) index_1 = i;
        else if (arr[i] != ans[i] && index_1 != -1 && index_2 == -1) index_2 = i;
        else if (arr[i] != ans[i] && index_1 != -1 && index_2 != -1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}

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

signed main(){
	int n, sum = 0;
	scanf("%lld", &n);
	for(int i = 0;;i++){
		sum += i;
		if(n <= sum){
			printf("%lld\n", i);
			return 0;
		}
	}
	return 0;
}

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

using namespace std;
const long INF=1L<<30;

int w[105];
int v[105];
long dp[105][MAX];
int main(){
	int n,maxW;
	scanf("%d %d",&n,&maxW);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&w[i],&v[i]);
	}
	for(int i=0;i<=MAX;i++){
		dp[0][i]=INF;
	}
	dp[0][0]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=100000;j++){
			dp[i][j] = dp[i-1][j];
			if(j-v[i]>=0)
				dp[i][j]=min(dp[i][j], dp[i-1][j-v[i]]+w[i]);
		}
	}
	
	int res=0;
	for(int i=100000;i>=1;i--){
		if(dp[n][i]<=maxW){
			res=i;
			break;
		}
	}
	printf("%d",res); 
	return 0;
}

Measured memory_bytes: 88192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	string out="";
	rep(i,s.size()){
		if(s[i]=='B'){
			if(out.size())out=out.substr(0,out.size()-1);
		}else{
			out+=s[i];
		}
	}
	cout<<out<<endl;
}
 
 







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, a, b;

vector <int> solve(int n, int a, int b){
    vector <int> ans(n);
    int cur = 0;
    for(int i = 0 ; i < n ; i++){
        if(i % a == 0){
            cur = max(1, n - i / a * a - a + 1);
        }
        ans[i] = cur;
        cur++;
    }
    bool ok = (n + a - 1) / a == b;
    for(int i = a ; i < n ; i++){
        int d = (i + a - 1) / a;
        if(d + n - i == b){
            ok = 1;
            int cur = 1;
            for(int j = n - 1 ; j >= i ; j--){
                ans[j] = cur;
                cur++;
            }
            int l = i / a * a, r = min(n - 1, (i / a + 1) * a - 1);
            int g = r - i + 1;
            for(int j = l ; j < i ; j++){
                ans[j] += g;
            }
            break;
        }
    }
    if(ok == 0) return {};
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b;
    if(a > n || b > n) finish(-1);
    vector <int> ans = solve(n, a, b);
    if(ans.size() == 0){
        ans = solve(n, b, a);
        for(auto &i : ans){
            i = n - i + 1;
        }
    }
    if(ans.size() == 0) finish(-1);
    for(auto &i : ans) cout << i << " ";
    cout << endl;
}


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

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

    int ans=0;

    for (int i = 0; i < n-2; i++)
    {
        if((p[i] > p[i+1] && p[i+1]> p[i+2]) ||(p[i] < p[i+1] && p[i+1]< p[i+2])){
            ans++;
        }
    }
    
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
day = input()

if day == "SUN":
    print(7)
elif day == "MON":
    print(6)
elif day == "TUE":
    print(5)
elif day == "WED":
    print(4)
elif day == "THU":
    print(3)
elif day == "FRI":
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int a[n];
    for(int x=0;x<n;x++){
        cin>>a[x];
    }
    // int s1=0,s2=0;
    if(n==1){
        cout<<a[0];
        return 0;
    }
    if(n==2){
        cout<<max(a[0],a[1]);
        return 0;
    }
    if(n%2==0){
        int s[n][2];
        for(int x=0;x<n;x++){
            s[x][0]=-1*inf,s[x][1]=-1*inf;
        }
        s[0][1]=a[0];
        s[0][0]=-1*inf;
        s[1][1]=a[1];
        s[1][0]=-1*inf;
        s[2][1]=s[0][1]+a[2];
        s[2][0]=a[2];
        for(int x=3;x<n;x++){
            s[x][1]=s[x-2][1]+a[x];
            s[x][0]=max(s[x-2][0]+a[x],s[x-3][1]+a[x]);
        }
        int ans=max(s[n-1][0],s[n-2][1]);
        // ans=max(ans,s[n-1][0]);
        ans=max(ans,s[n-1][1]);
        cout<<ans;
        return 0;



    }else{
        int s[n][3];
        for(int x=0;x<n;x++){
            s[x][0]=-1*inf,s[x][1]=-1*inf,s[x][2]=-1*inf;
        }
        s[0][2]=a[0];
        s[0][0]=-1*inf;
        s[0][1]=s[0][0];
        s[1][2]=a[1];
        s[1][0]=-1*inf;
        s[1][1]=s[1][0];
        s[2][2]=s[0][2]+a[2];
        s[2][1]=a[2];
        s[2][0]=-1*inf;
        for(int x=3;x<n;x++){
            s[x][2]=s[x-2][2]+a[x];
            s[x][0]=max(s[x-2][0]+a[x],s[x-3][1]+a[x]);
            if(x!=3){
                s[x][0]=max(s[x][0],s[x-4][2]+a[x]);
            }
            s[x][1]=max(s[x-2][1]+a[x],s[x-3][2]+a[x]);
            // if(x!=3){
            //     s[x][1]=max(s[x][1],s[x-4][2]+a[x]);
            // }
        }
        int ans=max(s[n-2][1],s[n-2][2]);
        // ans=max(ans,s[n-2][2]);  
        ans=max(ans,s[n-1][0]);
        ans=max(ans,s[n-1][1]);
        ans=max(ans,s[n-3][2]);
        cout<<ans;
    }








	
return 0;
}


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

string hd = "HD";

int main() {
    char a, b;
    cin >> a >> b;

    int ai, bi;

    for(int i=0;i<2;i++){
        if(a == hd[i])ai = i;
        if(b == hd[i])bi = i;
    }

    cout << hd[ai^bi] << endl;
    
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
 
 
int main(){
     
  int n,i,size[1000];
    
  scanf("%d",&n);
    
  for (i = 1; i <= n; i++) {
        scanf("%d",&size[i]);
    }
 
  n++;

    for(i = 1; i < n; i++){
        printf("node %d: key = %d, ",i,size[i]);
         
        if(i != 1){
            printf("parent key = %d, ",size[i/2]);
        }
        if(2*i < n){
            printf("left key = %d, ",size[2*i]);
        }
        if(2*i + 1 < n) {
            printf("right key = %d, ",size[2*i+1]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 604