akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
        using namespace std;
         
        int main(){
          long long int i,n,a,b,x[100010],y[100010],cnt=0;
          cin>>n>>a>>b;
          for(i=0; i<n; i++) cin>>x[i];
          for(i=0; i<n-1; i++) y[i]=x[i+1]-x[i];
          for(i=0; i<n-1; i++){
            cnt+=min(y[i]*a,b);
          }
          cout<<cnt<<endl;
          return 0;
        }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main()
{
  ll n, k;
  cin >> n >> k;
  ll ans = 0;

  int sum[200100] = {};
  repi(i, 1, 200100)
  {
    sum[i] = (sum[i - 1] + i) % mod;
  }

  for (ll i = k; i < n + 2; i++)
  { // k ~ n+1
    ans += ((n * i - sum[i - 1]) - sum[i - 1] + 1) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4420
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N, P;
	cin >> N >> P;

	string S;
	cin >> S;

	long long result = 0;
	if (P == 2 || P == 5)
	{
		for (int i = 0; i < N; i++)
		{
			if ((S[i] - '0') % P == 0)
			{
				result += (i + 1);
			}
		}
	}
	else
	{
		vector<int> base(N, 1);
		for (int i = N - 1; i >= 1; i--)
		{
			base[i - 1] = (base[i] * 10) % P;
		}

		vector<int> mod_count(P, 0);
		mod_count[0] = 1;

		int mod = 0;
		for (int i = 0; i < N; i++)
		{
			mod = (mod + ((S[i] - '0') % P) * base[i]) % P;
			mod_count[mod]++;
		}

		for (long long val : mod_count)
		{
			result += (val * (val - 1)) / 2;
		}
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 1428
import math

a, b, h, m = list(map(float, list(map(int, input().split()))))

m_abs_deg = 6.0 * m
h_abs_deg = 0.5 * m + 30.0 * h
rel_deg = math.fabs(m_abs_deg - h_abs_deg)
if rel_deg > 180.0:
    rel_deg = 360.0 - rel_deg

cos_c = math.cos(math.radians(rel_deg))
c_sq = a * a + b * b - 2.0 * a * b * cos_c
c = math.sqrt(c_sq)

print(c)

Measured memory_bytes: 9296
import sys
input = lambda: sys.stdin.readline().rstrip() 
import bisect as bs

def resolve():
    N = int(input())
    S = input()

    R = []
    G = []
    B = []
    for i in range(N):
        if S[i]=='R':
            R.append(i)
        if S[i]=='G':
            G.append(i)
        if S[i]=='B':
            B.append(i)

    ans = 0
    for i in R:
        index_G = bs.bisect_left(G, i)
        index_B = bs.bisect_left(B, i)
        # print(i, index_G, index_B)
        ans += index_G*(len(B)-index_B)
        # print('ansGRB', i, ans)
        for j in range(index_G):
            if 2*i-G[j]<N and S[2*i-G[j]]=='B':
                ans -= 1
        ans += index_B*(len(G)-index_G)
        for j in range(index_B):
            if 2*i-B[j]<N and S[2*i-B[j]]=='G':
                ans -= 1
    # print('ansR', ans)
    for i in G:
        index_R = bs.bisect_left(R, i)
        index_B = bs.bisect_left(B, i)
        # print(i, index_R, index_B)
        ans += index_R*(len(B)-index_B)
        for j in range(index_R):
            if 2*i-R[j]<N and S[2*i-R[j]]=='B':
                ans -= 1
        # print('ansRGB', ans)
        ans += index_B*(len(R)-index_R)
        for j in range(index_B):
            if 2*i-B[j]<N and S[2*i-B[j]]=='R':
                ans -= 1
        # print('ansBGR', ans)
    # print('ansG', ans)
    for i in B:
        index_G = bs.bisect_left(G, i)
        index_R = bs.bisect_left(R, i)
        # print(i, index_G, index_B)
        ans += index_G*(len(R)-index_R)
        for j in range(index_G):
            if 2*i-G[j]<N and S[2*i-G[j]]=='R':
                ans -= 1
        ans += index_R*(len(G)-index_G)
        for j in range(index_R):
            if 2*i-R[j]<N and S[2*i-R[j]]=='G':
                ans -= 1
    # print('ansB', ans)

    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9344
#include <cstdio>
#include <string>
#include <queue>
#include <algorithm>

bool is_pa(int n) {
  std::string s = std::to_string(n);
  std::string t(s.rbegin(), s.rend());
  return s == t;
}

int main() {
  int n;
  scanf("%d", &n);

  std::vector<bool> vis(100000);
  std::queue<int> q;
  q.push(n);
  vis[n] = true;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    if (i < 0) continue;
    vis[i] = true;
    if (is_pa(i)) return !printf("%d\n", i);
    if (!vis[i-1]) q.push(i-1);
    if (!vis[i+1]) q.push(i+1);
  }
}



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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int x = 0; x <= k; x++) {
    for(int y = 0; y <= k; y++) {
      int z = s-(x+y);
      if(z <= k && z >= 0) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

vi v[MAX];
ll val[MAX];
vi h;
ll ans[MAX];
void dfs(ll root, ll par)
{
    ll f=0;ll rev=-INF;
    ll j= upper_bound(h.begin(),h.end(),val[root])-h.begin();
    ll dd=j;
    if( h[j-1]<val[root] && val[root]<h[j]){rev=h[j];h[j]=val[root];f=1;}
    j=lower_bound(h.begin(),h.end(),INF)-h.begin();j--;
    ans[root]=j;
    
    for(auto it:v[root])
    {
        if(it!=par)
        {
            dfs(it,root);
        }
    }
    if(f)
    h[dd]=rev;
}
void solve()
{
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>val[i];
    }
    fore(i,0,n-1)
    {
        ll a,b;cin>>a>>b;
        v[b].pb(a);v[a].pb(b);
    }
    for(ll i=0;i<=n+1;i++)h.pb(INF);
    h[0]=-INF;
    dfs(1,0);
    for(ll i=1;i<=n;i++)cout<<ans[i]<<endl;
    
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 35588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#include <queue>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(3,0);
    //a[0] - 奇数
    //a[1] - 4の倍数でない偶数
    //a[2] - 4の倍数
    rep(i,n){
        int ai; std::cin >> ai;
        if(ai%2) a[0]++;
        else if(ai%4) a[1]++;
        else a[2]++;
    }

    if(a[0]<=a[2]+(a[1]==0)){
        std::cout << "Yes" << "\n";
    }else{
        std::cout << "No" << "\n";
    }
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> s(m);
    for (auto &si: s) {
        int k; cin >> k; si.resize(k);
        for (int &sij: si) cin >> sij, sij--;
    }
    vector<int> p(m);
    for (int &pi: p) cin >> pi;
    int ans = 0;
    for (int switches = 0; switches < 1 << n; switches++) {
        int cnt_on = 0;
        for (int i = 0; i < m; i++) {   // for bulbs
            int cnt_sw = 0;
            for (int sij: s[i]) if (switches >> sij & 1) cnt_sw++;
            if (cnt_sw % 2 == p[i]) cnt_on++;
        }
        if (cnt_on == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = []
for _ in range(N):
    s = input()
    C = Counter(s)
    S.append(C)

dp = [float('inf')]*26
uni_a = ord('a')
for s in S:
    for i in range(26):
        dp[i] = min(dp[i], s[chr(uni_a+i)])

ans = ''

for i in range(26):
    ans += chr(uni_a+i)*dp[i]
print(ans)


Measured memory_bytes: 3316
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (H, W) = Scanner.Scan<int, int>();
            var G = new bool[H][];
            for (var i = 0; i < H; i++)
            {
                G[i] = Scanner.Scan<string>().Select(x => x == '.').ToArray(); ;
            }

            var dh = new[] { -1, 0, 1, 0 };
            var dw = new[] { 0, -1, 0, 1 };
            var answer = 0;
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    if (!G[i][j]) continue;
                    var queue = new Queue<(int h, int w)>();
                    queue.Enqueue((i, j));
                    var depths = new int[H][].Select(x => Enumerable.Repeat(-1, W).ToArray()).ToArray();
                    depths[i][j] = 0;
                    var tmp = 0;
                    while (queue.Any())
                    {
                        var (ch, cw) = queue.Dequeue();
                        for (var k = 0; k < 4; k++)
                        {
                            var (nh, nw) = (ch + dh[k], cw + dw[k]);
                            if (nh < 0 || H <= nh) continue;
                            if (nw < 0 || W <= nw) continue;
                            if (!G[nh][nw]) continue;
                            if (depths[nh][nw] != -1) continue;
                            depths[nh][nw] = depths[ch][cw] + 1;
                            tmp = Math.Max(tmp, depths[nh][nw]);
                            queue.Enqueue((nh, nw));
                        }
                    }
                    answer = Math.Max(answer, tmp);
                }
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

const int N=1e7+7,mo=998244353;
inline int fk(int x) { return x>=mo ? x-mo : x; }
int n,fac[N],facinv[N];
int ksm(int x,int y)
{
    int res=1;
    while(y) { if(y&1) res=1ll*res*x%mo; x=1ll*x*x%mo; y>>=1; }
    return res;
}
inline int C(int x,int y) { return 1ll*fac[x]*facinv[y]%mo*facinv[x-y]%mo; }
int main()
{
    cin>>n;
    fac[0]=1;
    for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mo;
    facinv[n]=ksm(fac[n],mo-2);
    for(int i=n-1;i>=0;i--) facinv[i]=1ll*facinv[i+1]*(i+1)%mo;
    int ans=ksm(3,n);
    for(int k=n/2+1;k<=n;k++)
        ans=fk(ans-2ll*C(n,k)*ksm(2,n-k)%mo+mo);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 78336
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        int m = Integer.parseInt(stdIn.next());
        int[] p = new int[m];
        String[] s = new String[m];
        int ac = 0;
        int wa = 0;
        boolean[] acList = new boolean[n];
        for (int i = 0; i < m; i++) {
            p[i] = Integer.parseInt(stdIn.next());
            s[i] = stdIn.next();
            if (!acList[p[i] - 1] && s[i].equals("AC")) {
                ac++;
                acList[p[i] - 1] = true;
            }
        }

        boolean[] notCount = new boolean[n];
        for (int i = 0; i < m; i++) {
            if (!notCount[p[i] - 1] && acList[p[i] - 1] && s[i].equals("WA")) {
                wa++;
            } else if (!notCount[p[i] - 1] && s[i].equals("AC")) {
                notCount[p[i] - 1] = true;
            }
        }

        System.out.println(ac + " " + wa);
    }
}

Measured memory_bytes: 65952
import collections

def main():
    n = int(input())
    v = list(map(str, input().split()))

    c1 = collections.Counter(v[0::2])
    c2 = collections.Counter(v[1::2])
    
    def most(c, x, y):
        return c.most_common()[x][y]
    
    if most(c1, 0, 1) == most(c2, 0, 1) == n//2 and most(c1, 0, 0) == most(c2, 0, 0):
        print(n // 2)
    elif most(c1, 0, 0) != most(c2, 0, 0):
        print(n - most(c1, 0, 1)- most(c2, 0, 1))
    else:
            a  = n - most(c1, 1, 1)- most(c2, 0, 1)
            b  = n - most(c1, 0, 1)- most(c2, 1, 1)
            print(min(a, b))
         
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 22496
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    int n;
    cin >> n;
    long long a[n];
    rep(i,n){
        cin >> a[i];
    }
    int ans = 0;
    int nows = 0;
    for(int i = 1;i<n;i++){
        if(nows == 0){
            if(a[i]>a[i-1]){
                nows = 1;
            }
            else if(a[i] < a[i-1]){
                nows = 2;
            }
        }
        else if(nows == 1){
            if(a[i] < a[i-1]){
                ans++;
                nows = 0;
            }
        }
        else{
            if(a[i] > a[i-1]){
                ans++;
                nows = 0;
            }
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 100005
int n, ar[N], f[N], f1[N];
int main() {
        cin >> n;
        lp (i, 0, n) cin >> ar[i];
        for (int i = 0; i < n; i += 2) f[ar[i]]++;
        for (int i = 1; i < n; i += 2) f1[ar[i]]++;
        vector<pair<int, int>> s, s1;
        lp (i, 0, N) if (f[i]) {
                        s.push_back({f[i], i});
        }
        lp (i, 0, N) if (f1[i]) {
                        s1.push_back({f1[i], i});
        }
        sort(all(s));
        sort(all(s1));
        ll ans = 0;
        int i = sz(s) - 1, j = sz(s1) - 1;
        if (s[i].second == s1[j].second) {
                ans = n / 2 - max(s[i].first, s1[j].first);
                if (s[i].first > s1[j].first) {
                        if (--j >= 0) {
                                ans += n / 2 - s1[j].first;
                        } else {
                                ans += n / 2;
                        }
                } else if (s[i].first < s1[j].first){
                        if (--i >= 0) {
                                ans += n / 2 - s[i].first;
                        } else {
                                ans += n / 2;
                        }
                } else {
                        if (sz(s) == 1) {
                                ans = n / 2;
                        } else {
                                ans = n - (s[i].first + max(s[--i].first, s1[--j].first));
                        }
                }

        } else {
                ans = n - (s[i].first + s1[j].first);
        }
        cout << ans;
        return 0;
}


Measured memory_bytes: 2552
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll D;
    cin>>D;
    v c(26);
    rep(i,0,26)cin>>c[i];
    vv s(D,v(26));
    rep(i,0,D)rep(j,0,26)cin>>s[i][j];
    v t(D);
    rep(i,0,D){
        cin>>t[i];
        t[i]--;
    }

    v last_d(26,-1);
    ll p = 0;
    rep(d,0,D){
        p += s[d][t[d]];
        last_d[t[d]] = d;
        rep(i,0,26)p -= c[i] * (d-last_d[i]);
        cout<<p<<endl;
    }
    return 0;
}

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

namespace Atcoder00
{
    class Class1
    {
        static void Main(string[] args)
        {
            char[] c = Console.ReadLine().ToCharArray();
            char[] rc = c.Reverse().ToArray();
            if (rc[0] == '3')
            {
                Console.WriteLine("bon");
            }
            else if (rc[0] == '0'|| rc[0] == '1'|| rc[0] == '6'|| rc[0] == '8')
            {
                Console.WriteLine("pon");
            }
            else if(rc[0] == '2' || rc[0] == '4' || rc[0] == '5' || rc[0] == '7' || rc[0] == '9')
            {
                Console.WriteLine("hon");
            }
        }
    }
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define dbg(x) cout << #x << " = " << x << endl
#define F_OR(i, a, b, s) for(int i = (a); (s) > 0 ? i < (b) : i >= (b); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define ite(i, x) for(auto& i: x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef vector<pii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;


int main() {
    #ifdef LOCAL
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    int ans = 1;
    bool a, b;
    a = b = 0;
    int ant; cin >> ant;
    FOR(i, n - 1){
        int m; cin >> m;
        if(m > ant) a = 1;
        if(m < ant) b = 1;
        if(a && b) a = b = 0, ++ans;
        ant = m;
    }
    cout << ans << endl;
    return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    int ans = 0;

    rep(i, 4){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   map<int,string> m;
   m.insert({22,"Christmas Eve Eve Eve"});
   m.insert({23,"Christmas Eve Eve"});
   m.insert({24,"Christmas Eve"});
   m.insert({25,"Christmas"});
   int n;
   cin>>n;
   cout<<m[n]<<endl; 
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll cnt = 0;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while(b >= c) {
        c *= 2;
        cnt++;
    }
    if (cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int dp[3000][3000];
int main()
{
    int N; cin >> N;
    string S; cin >> S;
    vector<int> A(N), B(N);
    B[0] = 1;
    for (int i = 2; i <= N; i++) {
        if (S[N-i] == '>') {
            A[0] = 0;
            for (int j = 1; j < i; j++) {
                A[j] = (A[j-1] + B[j-1]) % MOD;
            }
        } else {
            A[i-1] = 0;
            for (int j = i - 2; j >= 0; j--) {
                A[j] = (A[j+1] + B[j]) % MOD;
            }
        }
        A.swap(B);
    }
    cout << accumulate(begin(B), end(B), 0LL) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
mr=0
for l,r in lr:
  mr=max(mr,r)
l=[1 for _ in range(mr+1)]
l[0],l[1]=0,0
s=[0 for _ in range(mr+1)]
for i in range(2,int(mr**(1/2))+1):
  x=i*2
  while x<=mr:
    l[x]=0
    x+=i
for i in range(2,mr+1):
  if l[i]==1 and l[(i+1)//2]==1:
    s[i]=s[i-1]+1
  else:
    s[i]=s[i-1]
for l,r in lr:
  print(s[r]-s[l-1])

Measured memory_bytes: 28792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define N 1000005 
#define ll long long 
int n,a,b,c,d;
char s[N];
bool check(int x,int y)
{
	for(int i=x;i<=y-1;i++)
		if(s[i]=='#'&&s[i+1]=='#')
			return 0;
	return 1;
}
int main() 
{
	//freopen("jump.in","r",stdin);
	//freopen("jump.out","w",stdout);
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	bool f=0;
	for(int i=1;i<=n;i++)
		if(s[i]=='#') 
		{
			f=1;
			break;
		}
	if(f==0)
	{
		puts("Yes");
		return 0;
	}//以上为特判
	s[0]=s[n+1]='#';
	if(!check(a,c))
	{
		puts("No");
		return 0;
	} 
	if(!check(b,d))
	{
		puts("No");
		return 0;
	}
	if(c>d)
	{
		for(int i=b;i<=d;i++)
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
			{//超车 
				puts("Yes");
				return 0;
			}
		puts("No");
		return 0;
	}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
int main()
{
    int n,c,k,t[100000],i,j;

    scanf("%d %d %d",&n,&c,&k);
    for (i = 0; i < n; i++)scanf("%d",&t[i]);
    qsort(t,n,sizeof(int),asc);
    int num = 1,time = 0,ans = 0;
    for (i = 0; i < n; i++)
    {
        num++;
        if(time < t[i] || num > c)
        {
            ans++;
            time = t[i] + k;
            num = 1;
        }
    }
    printf("%d",ans);
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	set<int> st;
  int n, k, a;
  cin >> n >> k;
  rep(i, n) {
    cin >> a;
    st.insert(a);
  }
  int result = (st.size() - 1) / (k - 1);
  if((st.size() - 1) % (k - 1)) result++;
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 4992
K,S = map(int,input().split())
def main(K,S):
    if S > 3*K:
        print(0)
        
    else:
        count = 0
        for i in range(K+1):
            for j in range(K+1):
                if 0 <= S - i - j <= K:
                    count += 1
        print(count)
if __name__ == '__main__':
   main(K,S)


Measured memory_bytes: 3064
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type Monster [][]int
func (M Monster) Len() int { return len(M) }
func (M Monster) Less(i, j int) bool { return M[i][0] < M[j][0] }
func (M Monster) Swap(i, j int) { M[i], M[j] = M[j], M[i] }

func Solve() {
  NDA := NextIntVec()
  N, D, A := NDA[0], NDA[1], NDA[2]
  M := make([][]int, N)
  for i := range M {
    M[i] = NextIntVec()
  }
  sort.Sort(Monster(M))
  ans := 0
  Q := make([][]int, 0)
  B := 0
  for _, m := range M {
    X, H := m[0], m[1]
    for 0 < len(Q) && Q[0][0] + 2 * D < X {
      B -= Q[0][1]
      Q = Q[1:]
    }
    H -= B
    if H <= 0 { continue }
    cnt := H / A
    if 0 < H % A { cnt++ }
    B += A * cnt
    Q = append(Q, []int{X, A * cnt})
    ans += cnt
  }
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 25728
S = input()
N = len(S) - 1
ans = 0
for i in range(2**N):
  now = S[0]
  for j in range(N):
    if i & 1:
      ans += int(now)
      now = S[j+1]
    else:
      now += S[j+1]
    i >>= 1
  ans += int(now)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define all(a)      a.begin(),a.end()
#define getc getchar_unlocked
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n,sum=0;
  cin >> n;
  int a[n];
  map<int,int> m;
  f(i,n)
  {
      cin >> a[i];
      m[a[i]]++;
      sum+=a[i];
  }
  int q;
  cin >> q;
  while(q--)
  {
      int b,c;
      cin >> b >> c;
      m[c]+=m[b];
      sum-=(b*m[b]);
      sum+=(c*m[b]);
      m[b]=0;
      cout << sum << '\n';
  }
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10332
import java.util.Scanner;
public class Main{

    public static void main(final String args[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int c = S.length();
        int cnt=0;
    for(int i=0; i<c; i++)
        if(S.charAt(i)!=T.charAt(i)){
            cnt++;
        }
    System.out.println(cnt);
    sc.close();

    }
}

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

int vis[200010];
queue<int>que;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        long long int ans1=0,ans2=0;
        for(int i=1;i<=n;i++)
        {
            if(i%k==0) ans1++;
        }
//        printf("%d\n",ans1);
        if(k%2==0)
        {
            for(int i=1;i<=n;i++)
            {
                if((i%k)==k/2) ans2++;
            }
        }
//        printf("%d\n",ans2);
        printf("%lld\n",ans1*ans1*ans1+ans2*ans2*ans2);
    }
}


Measured memory_bytes: 256
#include <stdio.h>

#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

#define INF 1000000000

int adj[100][100];
int d[100], flag[100];

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++) {
		d[i] = INF;
		flag[i] = 0;
	}

	d[s] = 0;
	while (1) {
		int min, from, to;

		min = INF;
		for (i = 0; i < n; i++)
			if (!flag[i] && d[i] < min)
				min = d[from = i];
		if (min == INF)
			break;

		flag[from] = 1;

		for (to = 0; to < n; to++)
			d[to] = min(d[to], min + adj[from][to]);
	}
}

int main(void) {
	int i, j, o;
	int n, m, l, k, a, h;

	while (scanf("%d %d %d %d %d %d", &n, &m, &l, &k, &a, &h), n) {
		int canFreeze[100] = {0};

		canFreeze[a] = canFreeze[h] = 1;
		for (i = 0; i < l; i++) {
			int x;
			scanf("%d", &x);
			canFreeze[x] = 1;
		}

		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				adj[i][j] = INF;
		for (i = 0; i < k; i++) {
			int x, y, t;
			scanf("%d %d %d", &x, &y, &t);
			adj[x][y] = adj[y][x] = t;
		}

		for (o = 0; o < n; o++)
			for (i = 0; i < n; i++)
				for (j = 0; j < n; j++)
					adj[i][j] = min(adj[i][j], adj[i][o] + adj[o][j]);

		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (!canFreeze[i] || !canFreeze[j] || adj[i][j] > m)
					adj[i][j] = INF;

		dijkstra(n, a);

		if (d[h] != INF)
			printf("%d\n", d[h] + max(0, d[h] - m));
		else
			puts("Help!");
	}

	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
  int n = s.size();
  int ans = 0;
  rep(i,n){
    if(i%2 && s[i]=='g') ans++;
    if(!(i%2) && s[i]=='p') ans--;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N; cin >> N;
  set<int> st;
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    st.insert(a);
  }
  if(st.size() == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

int main()
{
  std::string c, c2;

  std::cin >> c;
  std::cin >> c2;

  if (c[0] == c2[2] && c[1] == c2[1] && c[2] == c2[0]) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')

def kai?(arr)
  (arr.size / 2).times do |i|
    if arr[i] != arr[arr.size - 1 - i]
      return false
    end
  end
  true
end

if kai?(s) && kai?(s[0..((s.size-1)/2 - 1)]) && kai?(s[((s.size+3)/2 - 1)..s.size-1])
  puts 'Yes'
else
  puts 'No'
end


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

int main(){
  int d[1001],n,m,a,b,c;
  stack<int> s;
  cin>>n>>m>>a>>b;
  for(int i=0;i<n;i++)cin>>d[i];
  for(int i=0;i<n;i++){
    if(d[i]>=a){
      s.push(d[i]);
    } else {
      break;
    }
  }
  if(n-s.size()>=m){
    cout << s.size() << endl;
  }else{
    while(!s.empty()){
      if(s.top()>b){
	break;
      }else s.pop();
    }
    c=s.size();
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
//16, 02, 2019, 10:02:02 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 100;
int cnt[N];

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

    int n, m;

    cin >> n >> m;

    for(int i = 0 ; i < n ; i++){
        int ki;

        cin >> ki;

        for(int j = 0 ; j < ki ; j++){
            int ai;

            cin >> ai;
            cnt[ai]++;
        }
    }

    int tot = 0;

    for(int i = 1 ; i <= m ; i++){
        tot += (cnt[i] == n);
    }

    cout << tot << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL ans = (n-2) * 180;
	pll(ans); nl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n1,t1;
    cin>>n1>>t1;
    int c[n1],t[n1],r=1001;
    for(int i=0;i<n1;i++)
    {
        cin>>c[i];
        cin>>t[i];
        if(t[i]<=t1)
        {
            r=min(r,c[i]);
        }
    }
    if(r==1001)
        cout<<"TLE"<<endl;
    else
        cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 3110.cc: Many Decimal Integers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

int dsums[10 + 1];
char s[MAX_N + 4], t[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < 10; i++) dsums[i + 1] = dsums[i] + i;

  scanf("%s%s", s, t);
  int n = strlen(s);

  int dp0 = 0, n0 = 1;
  int dp1 = 0, n1 = 0;

  for (int i = 0; i < n; i++) {
    int si = s[i] - '0';
    int tdp0 = (ll)dp0 * 10 % MOD;
    int tdp1 = (ll)dp1 * 10 % MOD;

    if (t[i] != '?') {
      int ti = t[i] - '0';
      int nd0 = (tdp0 + (ll)ti * n0 % MOD) % MOD;
      int nd1 = (tdp1 + (ll)ti * n1 % MOD) % MOD;

      dp1 = nd1;
      if (ti == si)
	dp0 = nd0;
      else if (ti < si) {
	dp1 = (dp1 + nd0) % MOD;
	dp0 = 0;
	n1 = (n1 + n0) % MOD;
	n0 = 0;
      }
      else {
	dp0 = 0;
	n0 = 0;
      }
    }
    else { // t[i] == '?'
      int nd0 = (tdp0 + (ll)si * n0 % MOD) % MOD;
      int nd1 = ((ll)tdp0 * si % MOD + (ll)dsums[si] * n0 % MOD) % MOD;
      int nd2 = ((ll)tdp1 * 10 % MOD + (ll)dsums[10] * n1 % MOD) % MOD;

      dp0 = nd0;
      dp1 = (nd2 + nd1) % MOD;
      n1 = ((ll)n0 * si % MOD + (ll)n1 * 10 % MOD) % MOD;
    }
  }

  printf("%d\n", (dp0 + dp1) % MOD);
  return 0;
}



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

int H, W, K;
int A[1005][1005];
int cnt[11];

int coba(int mask) {
//  cout << "mask -> " << mask << "\n";
  memset(cnt, 0, sizeof(cnt));
  int p = 1;
  vector<int> grup[15];
  for(int i = 1; i <= H; i++) {
    grup[p].push_back(i);
    if(mask & 1) {
      p++;
    }
    mask >>= 1;
  }/*
  for(int i = 1; i <= H; i++) {
    for(int now : grup[i]) {
      cout << now << " ";
    }
    cout << "\n";
  }*/
  int lastcut = 0, cutcnt = 0;
  for(int c = 1; c <= W; c++) {
//    cout << "col " << c << "\n";
    for(int i = 1; i <= p; i++) {
      int res = 0, res0 = 0;
//      cout << i << " -> ";
      for(int now : grup[i]) {
//        cout << now << " [" << A[now][c] << "] ";
        res += cnt[now] + A[now][c];
        res0 += A[now][c];
      }
//      cout << "sum -> " << res << "\n";
      if(res > K) {
        if(res0 > K) return 1000000000;
        else {
          cutcnt++;
          memset(cnt, 0, sizeof(cnt));
          lastcut = c;
          break;
        }
      }
    }
    for(int r = 1; r <= H; r++) {
      cnt[r] += A[r][c];
    }
  }
  return cutcnt;
}

int main() {
  scanf("%d %d %d", &H, &W, &K);
  getchar();
  char tp;
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      tp = getchar();
      A[i][j] = (tp == '1');
    }
    getchar();
  }
  int way = 1 << (H - 1);
  int ans = 1000000000;
  for(int i = 0; i < way; i++) {
    ans = min(ans, __builtin_popcount(i) + coba(i));
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
ll h[100005],l[100005];
int n,m;
ll x[100005],y[100005];
ll dx[100005],dy[100005];
int main() {
	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++){
		int aa;
		scanf("%d",&aa);
		x[i]=(ll)aa;
	}
	for(int i=1;i<=m;i++){
		int aa;
		scanf("%d",&aa);
		y[i]=(ll)aa;
	}
	n--;m--;
	for(int i=1;i<=n;i++){
		dx[i]=x[i+1]-x[i];
		
	}
	for(int i=1;i<=m;i++){
		dy[i]=y[i+1]-y[i];
	}
	for(int i=1;i<=n;i++){
		h[i]=i*(n-i+1);
	}
	for(int i=1;i<=m;i++){
		l[i]=i*(m-i+1);
	}
	ll xx=0,yy=0;
	
	for(int i=1;i<=n;i++){
		ll res=(ll)i*(ll)(n-i+1);
		xx=(xx+res*dx[i])%1000000007;
	}
	for(int i=1;i<=m;i++){
		ll res=(ll)i*(ll)(m-i+1);
		yy=(yy+res*dy[i])%1000000007;
	}
	cout<<xx*yy%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 4992
$a=[]
class Tree
    attr_accessor :id, :parent, :depth, :children, :type
    def initialize(id, children)
        @id = id
        @parent = -1
        @children = children
        @type = (children == [] ? 'leaf' : 'internal node')
    end

    def print
        puts "node #{id}: parent = #{parent}, depth = #{depth}, #{type}, #{children}"
    end

    def setDepth
        children.each {|c|
            $a[c].depth = depth + 1
            $a[c].setDepth
        }
    end
end

N = gets.to_i

N.times {
    id, d, *children = gets.split.map(&:to_i)
    $a << Tree.new(id, children)
}
$a.sort_by! {|e| e.id}
$a.each {|ele|
    ele.children.each {|e|
        $a[e].parent = ele.id
    }
}
$a.each {|e|
    if e.parent == -1
        e.type = 'root'
        e.depth = 0
        e.setDepth
    end
}
$a.each {|e| e.print}

Measured memory_bytes: 92916
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define mii             map<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul             1000000007
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define mod             998244353 
#define pll             pair<ll,ll>
#define endl            '\n'
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    int h,n; cin>>h>>n;
    pii p[n];
    rep(i,0,n) cin>>p[i].F>>p[i].S;
    vll dp(h+1,INF);
    dp[0] = 0;
    rep(i,1,h+1)
    {
        rep(j,0,n)
        {
            {
                dp[i] = min(dp[i], dp[max(0,i-p[j].F)]+p[j].S);
            }
        }
    }
    cout<<dp[h];
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    while(t--){
       solve();
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))

ll = []
ll.append(l[0])

for i in range(len(l)-1):
  if l[i] > l[i+1]:
    ll.append(min(l[i+1], ll[i]))
  else:
    ll.append(ll[i])

count = 0
for i in range(len(ll)):
  if l[i] <= ll[i]:
    count+=1

print(count)


Measured memory_bytes: 25716
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def solve(n):
    prime = 1
    m = n
    for i in range(2,int(sqrt(n))+1):
        pri = False
        while m%i==0:
            m//=i
            pri = True
        if pri:
            prime += 1
    if m!=1:
        prime+=1
    return prime
def main():
    A,B = MI()
    G = gcd(A,B)
    ans = solve(G)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 65388