akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int h,w,i,j,k,mp[55][55];
	string s[55];
	fill(mp[0],mp[55],0);
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> s[i];
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			if(s[i][j] == '#'){
				for(k=0; k<9; ++k){
					mp[i+k/3][j+k%3]++;
				}
			}
		}
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			if(s[i][j]=='#'){
				cout << "#";
			}else{
				cout << mp[i+1][j+1];
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
main = do
  (n:a:b:xs) <- (map read) . words <$> getLine
  let (x,y) = solve n a b
  putStrLn . unwords . map show $ [x,y]

solve :: Int -> Int -> Int -> (Int, Int)
solve n a b = (min a b, max 0 (a+b-n))


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
int n=0;
str s;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int m[200],sum=0;
    fill(m,m+200,0);
    rep(i,0,n){
        cin >> m[i];
        sum+=m[i];
    }
    int res=sum/n;
    int ans=1000000000;
    int a=0;
    for(int i=-1;i<2;i++){
        a=0;
        for(int j=0;j<n;j++){
            a+=abs((res+i)-m[j])*abs((res+i)-m[j]);
            //cout << a << "a";
        }
        if(ans>a)ans=a;
        //cout << a;
    }
    cout << ans << endl;
return 0;
}


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

using namespace std;

typedef long long ll;
const int M = 998244353;

int add(int a, int b) {
        a += b;
        if (a >= M)
                return a - M;
        if (a < 0)
                return a + M;
        return a;
}

int mul(int a, int b) {
        return a * (ll) b % M;
}

int pw(int a, int b) {
        int r = 1;
        while (b) {
                if (b & 1)
                        r = mul(r, a);
                a = mul(a, a);
                b /= 2;
        }
        return r;
}

int dv(int a, int b) {
        return mul(a, pw(b, M - 2));
}

const int N = (int) 2e5 + 7;
int n, dp[N], pos[N], t[4 * N];
vector<int> g[N];

struct T {
        int x;
        int d;
};

bool operator < (T a, T b) {
        return a.x < b.x;
}

T a[N];

void upd(int v, int tl, int tr, int p) {
        if (tr < p || p < tl)
                return;
        if (tl == tr) {
                t[v] = pos[p];
                return;
        }
        int tm = (tl + tr) / 2;
        upd(2 * v, tl, tm, p);
        upd(2 * v + 1, tm + 1, tr, p);
        t[v] = max(t[2 * v], t[2 * v + 1]);
}

int get(int v, int tl, int tr, int l, int r) {
        if (tr < l || r < tl)
                return 0;
        if (l <= tl && tr <= r)
                return t[v];
        int tm = (tl + tr) / 2;
        return max(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm + 1, tr, l, r));
}

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin >> n;
        for (int i = 1; i <= n; i++)
                cin >> a[i].x >> a[i].d;
        sort(a + 1, a + n + 1);
        for (int i = n; i >= 1; i--) {
                pos[i] = i;
                if (i + 1 <= n && a[i + 1].x <= a[i].x + a[i].d - 1) {
                        pos[i] = max(pos[i], pos[i + 1]);
                        int l = i, r = n;
                        while (l <= r) {
                                int m = (l + r) / 2;
                                if (a[m].x <= a[i].x + a[i].d - 1) {
                                        pos[i] = max(pos[i], m);
                                        l = m + 1;
                                } else
                                        r = m - 1;
                        }
                        pos[i] = max(pos[i], get(1, 1, n, i, pos[i]));
                        upd(1, 1, n, i);
                }
        }
        for (int i = 1; i <= n; i++)
                g[pos[i]].push_back(i - 1);
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
                dp[i] = dp[i - 1];
                for (auto &j : g[i])
                        dp[i] = add(dp[i], dp[j]);
        }
        cout << dp[n] << "\n";
        return 0;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n;
  cin >> n;
  cout << n*n*n << endl;
}

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

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
#define vvv vector<vector<vector<long long int>>>
#define vvvl(a, b, c, d) vector<vector<vector<long long int>>>(a, vector<vector<long long int>>(b, vector<long long int> (c, d)));

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);re(i, n) std::cin >> a[i];
  bool flag = true;
  re(i, n){
    if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0) flag = false;
  }
  std::cout << (flag?"APPROVED":"DENIED") << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

inline double square(double x) { return x * x; }
int n, m;
double color[1000][3];
int main() {
  while (scanf("%d %d", &n, &m) > 0) {
    REP(i, n) {
      REP(k, 3) {
        scanf("%lf", &color[i][k]);
      }
    }
    double ans = 0.0;
    REP(bits, 1 << n) {
      if (__builtin_popcount(bits) != m) { continue; }
      double lans = 0.0;
      REP(i, n) {
        if (!((bits >> i) & 1)) { continue; }
        REP(j, i) {
          if (!((bits >> j) & 1)) { continue; }
          REP(k, 3) {
            lans += square(color[i][k] - color[j][k]);
          }
        }
      }
      ans = max(ans, lans);
    }
    printf("%.8f\n", ans);
  }
}

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

struct UnionFind {
  vector<int> r;

  UnionFind(int n) {
    r = vector<int>(n, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x) {
    return -r[root(x)];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
double a,b,c,d,e,f,g,h,i,j,l,r,mid,pi=3.1415926536;
int main()
{
	cin>>a>>b;
	cin>>c;
	if(c<=a*a*b/2)
	{	
	    d=sqrt((c/(a*b)*2)*(c/(a*b)*2)+b*b);
	    e=((c/(a*b)*2)*b)/d;
	    f=e/b;
	    g=asin(f);
	    g=90-(g/pi)*180.0;
	    printf("%.10f",g); 
	    return 0;
    }
    d=sqrt(a*a+b*b);
    e=(a*a*b-c)*2/a/a/a;
	g=atan(e);
	g=(g/pi)*180.0;
	printf("%.10f",g);    
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

class vector2d
{
public:
	vector2d(float vx, float vy) : x(vx), y(vy)
	{}
	void normalize()
	{
		float n = sqrt(x*x + y*y);
		x /= n;
		y /= n;	
	}
public:
	float x,y;
};

float dot(vector2d& v1, vector2d& v2)
{
	return v1.x*v2.x + v1.y*v2.y;
}

float cross(vector2d& v1, vector2d& v2)
{
	return v1.x*v2.y - v2.x*v1.y;
}

int main(int argc, char const *argv[])
{
	float x1, y1, x2, y2, x3, y3, xp, yp;
	while(scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF)
	{
		float miny = (y1 < y2) ? y1 : y2;
		miny = (miny < y3) ? miny : y3;
		if (miny == y2)
		{
			swap(x2, x1);
			swap(y2, y1);
		}
		else if (miny == y3)
		{
			swap(x3, x1);
			swap(y3, y1);
		}
		vector2d v1(x2-x1,y2-y1); v1.normalize();
		vector2d v2(x3-x1,y3-y1); v2.normalize();
		vector2d ve(1.0,0.0);
		bool ans = true;
		vector2d vp1(xp-x1,yp-y1);
		vector2d vp2(xp-x2,yp-y2);
		vector2d vp3(xp-x3,yp-y3);
		if (dot(ve,v1) < dot(ve,v2))
		{
			vector2d v2(x3-x2,y3-y2); v2.normalize();
			vector2d v3(x1-x3,y1-y3); v3.normalize();
			ans &= cross(v1, vp1) < 0;
			ans &= cross(v2, vp2) < 0;
			ans &= cross(v3, vp3) < 0;
		}
		else
		{
			vector2d v1(x3-x1,y3-y1); v1.normalize();
			vector2d v2(x1-x2,y1-y2); v2.normalize();
			vector2d v3(x2-x3,y2-y3); v3.normalize();
			ans &= cross(v1, vp1) < 0;
			ans &= cross(v2, vp2) < 0;
			ans &= cross(v3, vp3) < 0;
		}
		if (ans)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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

int q1,b,c1,c2,q2;

// ????´\?¶???????????????????x??¨??????
bool C(int x){
    if(x*c1 > b || x > q2)
        return false;

    return x + (b-x*c1)/c2 >= q1;
}

int main(){
    while(1){
        cin>>q1;
        if(!q1)break;
        cin>>b>>c1>>c2>>q2;
        
        int lb = 0, ub = 1e+9;
        for(int i=0;i<100;i++){
            int mid = (lb + ub) / 2;
            if(C(mid)) lb = mid;
            else ub = mid;
        }

        if(lb == 0)
            cout<<"NA"<<endl;
        else
            cout<<lb<<" "<<(b-lb*c1)/c2<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
int n,a[200000];
int even=0;
int count;
scanf("%d",&n);
for(count=1;count<=n;count++){
    scanf("%d",&a[count]);
}
for(count=1;count<=n;count++){
    if(a[count]%2==1){even++;}
}
if(even%2!=0){printf("NO");}
else{printf("YES");}
}


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

int main() {
  long min = 1000001,max = -1000001,sum = 0;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    long a;
    cin >> a;
    sum += a;
    if(a < min) min = a;
    if(a > max) max = a;
  }
  cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>

using namespace std;

using ull = unsigned long long;

int main() {

    ull n;

    cin >> n;

    vector<pair<ull, ull>> a;

    ull num = 2;

    while(num * num <= n) {

        if(n % num != 0) {
            num++;
            continue;
        }

        ull count = 0;

        while(n % num == 0) {
            n /= num;
            count++;
        }

        a.push_back(make_pair(num, count));
        num++;

    }

    if(n != 1)
        a.push_back(make_pair(n, 1));

    ull answer = 0;
    for(int i = 0; i < a.size(); ++i) {

        ull count = 1;

        while(a[i].second >= count) {
            answer++;
            a[i].second -= count;
            count++;
        }

    }

    cout << answer << endl;
    return 0;

}

Measured memory_bytes: 3648
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

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


int main() {
    ll N;
    string S;
    cin >> N >> S;

    ll ans=0,result=0;
    rep(i,N){
        if(S[i] == 'I'){
            result++;
        }else{
            result--;
        }
        ans = max(ans,result);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

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

	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}

	if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}

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

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

a = l()

a.sort()

aa = s(a)

ans = 0
dp = [0 for i in range(10**6+1)]
for i in range(len(aa)):
	f = 0
	if aa[i][1] != 1:
		f = 1
	elif dp[aa[i][0]] != 0:
		f = 1
	for _ in range(aa[i][0],10**6+1,aa[i][0]):
		dp[_] = 1
	if not f:
		ans += 1



print(ans)


Measured memory_bytes: 173012
package main

import (
	"fmt"
)

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	if k <= a+b {
		fmt.Println(min(a, k))
	} else {
		fmt.Println(a - (k - a - b))
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1752
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string S,ans;
    cin >> S;
    ans = S.front() + to_string(S.size() - 2) + S.back();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int count(int x) {
    int ret = 2;
    for (int d = 2; d*d <= x; ++d) {
        if (x % d == 0) {
            ++ret;
            if (d*d < x) ++ret;
        }
    }
    return ret;
}

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

    int n;
    cin >> n;

    int ans = 0;
    for (int x = 1; x <= n; x += 2) {
        if (count(x) == 8) ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9);

int main(){
  int V, E;
  cin >> V >> E;
  vector< vector<int> > G(V, vector<int>(V,INF));
  for(int i = 0; i < E; ++i){
    int s, t, d;
    cin >> s >> t >> d;
    G[s][t] = d;
  }
  for(int i = 0; i < V; ++i) G[i][i] = 0;
  vector< vector<int> > DP((1<<V),vector<int>(V,INF));
  DP[1][0] = 0;
  for(int i = 1; i < (1<<V); ++i){
    for(int j = 0; j < V; ++j){
      if(!((i>>j)&1)) continue;
      for(int k = 0; k < V; ++k){
        if(((i>>k) & 1) || j == k) continue;
        DP[i|(1<<k)][k] = min(DP[i|(1<<k)][k], DP[i][j] + G[j][k]);
        //cerr << "DP[" << (i|(1<<k)) << "] = " << DP[i|(1<<k)][k] << endl;
      }
    }
  }
  int ans = INF;
  for(int i = 0; i < V; ++i) ans = min(ans, DP[(1<<V)-1][i] + G[i][0]);
  if(ans < INF) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 6220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    string k;
    cin >> k;
    ll n = k.size();
    reverse(k.begin(),k.end());
    ll d;
    cin >> d;
    vector <vector<ll>> dp(n,vector<ll>(d,0));
    for(int x=0;x<10;x++){
        dp[0][x%d]++; 
    }
    for (int z=1;z<n;z++){
        for (int x=0;x<d;x++){
            for (int y=0;y<10;y++){
                ll temp = (x-y)%d;
                while (temp < 0) temp += d;
                dp[z][x] += dp[z-1][temp];
                dp[z][x] %= mod;
            }
        }
    }
    ll ans = 0;
    ll sum = 0;
    for (int z=1;z<n;z++){
        sum += k[z]-'0';
    }
    for (int z=0;z<=k[0]-'0';z++){
        if ((sum+z)%d == 0) ans++;
    }
    ans %= mod;
    for (int z=1;z<n;z++){
        ll count = k[z]-'0';
        sum -= count;
        for (int y=0;y<count;y++){
            ll temp = (d-(sum%d)-y)%d;
            while (temp < 0) temp += d;
            ans += dp[z-1][temp];
            ans %= mod;
        }
    }
    ans--;
    if (ans < 0) ans += mod;
    cout << (ans)%mod << endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 200000;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
//

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

    vi a(n), b(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> b[i];

    int res = 0;
    forn(i, n) {
        if(a[i] >= b[i]) {
            res += a[i]-b[i];
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;




int main() {

    
    ll n, a, b;
    cin >> n >> a >> b;

    ll c = a + b;
    ll ans = (n / c) * a;
    if (n%c < a) ans += n%c;
    else ans += a;

    out(ans);


}




//              g++ -std=c++1z






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

Int D;
vector<Int> C(26);
vector<vector<Int>> S(365, vector<Int>(26));


// 各日における満足度の配列を返す関数
vector<Int> score(vector<int> schedule){
    vector<int> last_day(26, 0); // 各コンテストを最後に行った日

    vector<Int> res(D, 0);

    rep(d,D){
        int type = schedule[d]-1; // その日に行われるコンテスト

        res[d] += S[d][type];
        rep(i,26){
            if(i == type) continue;
            res[d] -= C[i] * (d+1 - last_day[i]);
        }
        last_day[type] = d+1;

        if(d != D-1) res[d+1] += res[d];
    }

    return res;
}

int main(){
    cin >> D;
    rep(i,26) cin >> C[i];
    rep(i,D) rep(j,26) cin >> S[i][j];

    rep(i,D) cout << 5 << endl;
}

Measured memory_bytes: 3712
dic={}
dic['AC']=0
dic['WA']=0
dic['TLE']=0
dic['RE']=0
for i in range(int(input())):
  S=input()
  dic[S]+=1
print(*['AC','x',dic['AC']])
print(*['WA','x',dic['WA']])
print(*['TLE','x',dic['TLE']])
print(*['RE','x',dic['RE']])

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string a,b;
    cin>>a>>b;
    int res = a.size();
    for(int i=0; i<b.size(); i++)
        res-=b[i]==a[i];

    cout<<res;
}


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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); cout.precision(15);cout.setf(ios::fixed);
int a;

map <int,int> cnt;

for(int i=0;i<3;i++)
		{
		cin>>a;
		cnt[a]++;	
		}

if(cnt[5]==2 && cnt[7]==1)
	cout<<"YES"<<endl;
else
	cout<<"NO"<<endl;

}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,T,t[ohara],limitv[ohara],nowtime=0;
double v[ohara],ans;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;

      rep(i,n){
        cin>>t[i];
        T+=t[i];
      }

        rep(i,ohara)v[i]=1000000000.0;

      rep(i,n){
        cin>>limitv[i];
        rrep(j,nowtime,nowtime+t[i]*2+1)v[j]=min(v[j],(double)limitv[i]);
        nowtime+=t[i]*2;
        v[nowtime]=min(v[nowtime],(double)limitv[i]);
      }
    
      v[0]=0.0;v[2*T]=0.0;

      rrep(i,1,2*T+1){
        v[i]=min(v[i],v[i-1]+0.5);
      }

      v[0]=0.0;v[2*T]=0.0;
      rrrep(i,2*T,0){
        v[i]=min(v[i],v[i+1]+0.5);
      }

      v[0]=0.0;v[2*T]=0.0;

     rep(i,2*T){
       double up,down;
       up=v[i+1];
       down=v[i];
       ans+=(up+down)*0.5/2.0;
     }

     printf("%.15f\n",ans);
   


     

       
return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    int n;cin>>n;
    pair<int,int>xl[n];
    REP(i,n){
        int x,l;cin>>x>>l;
        xl[i]=mp(x+l,x-l);
    }
    sort(xl,xl+n);
    int ans=0;int nowupp=-mod;
    REP(i,n)if(nowupp<=xl[i].se)ans++,nowupp=xl[i].fi;
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int flag = 1;
  int n[100];
  int i,a,b,c=0;

  scanf("%d",&a);

  for(i = 0; i < a; i++){
    scanf("%d",&n[i]);
  }

  while(flag){
    flag = 0;
    for(i = a-1; i >=1; i--){
      if(n[i] < n[i-1]){
	b = n[i];
	n[i] = n[i-1];
	n[i-1] = b;
	flag = 1;
	c++;
      }
    }
  }
    for(i = 0; i < a; i++){
      printf("%d",n[i]);
      if(i < a-1) printf(" ");
    }
    printf("\n");
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 604
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


def odd(n): return n & 1


def even(n): return not odd(n)


def comb(n, m):
    r = 1
    for i in range(1, n+1):
        r *= i
    for i in range(1, m+1):
        r //= i
    for i in range(1, n-m+1):
        r //= i
    return r


def main():
    N, P = map(int, input().split())
    A = [int(n) % 2 for n in input().split()]
    cnt0 = len([a for a in A if a == 0])
    cnt1 = len([a for a in A if a == 1])
    ans = 0
    if odd(P):
        for i in range(cnt1 + 1):
            if odd(i):
                ans += comb(cnt1, i)
    else:
        for i in range(cnt1 + 1):
            if even(i):
                ans += comb(cnt1, i)
    ans *= pow(2, cnt0)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81520
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 1000000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
int a;
ll int ans;

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

    ans = 0;

    REP(i, N){
        scanf("%d", &a);
        ans += a - 1;
    }

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	int cnt4(0), cnt2(0);
	rep(i, 0, N) {
		if (v[i] % 4 == 0)cnt4++;
		else if (v[i] % 2 == 0)cnt2++;
	}
	if (cnt2 >= 2)N -= cnt2-1;
	
	if ((N==1)||(N/2<=cnt4&&cnt4>=1))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;

ll ans=1;

int main(){
    int N;
    cin>>N;
    string S,t;
    cin>>S>>t;
    vector<int> d;
    char memory;
    int i=0;
    if(N==1) d.push_back(1);
    if(N>1){
    while(i<N-1){
        if(S.at(i)==S.at(i+1)){
            d.push_back(2);
            i+=2;
        }
        else{
            d.push_back(1);
            if(i==N-2) d.push_back(1);
            i++;
            
        }
    }
    }
    //for(int i=0;i<d.size();i++) cout<<d.at(i);
    //cout<<endl;

    if(d.at(0)==1) ans=3;
    else ans=6;
    if(d.size()>1){
    for(int i=1;i<d.size();i++){
        if(d.at(i)==1 && d.at(i-1)==1) ans*=2;
        if(d.at(i)==2 && d.at(i-1)==1) ans*=2;
        if(d.at(i)==2 && d.at(i-1)==2) ans*=3;
        ans=ans%mod;
    }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n, k, x, y;
    in >> n >> k >> x >> y;
    out << min(n, k) * x + max((ll)0, n - k) * y << endl;
}


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

int main() {
  int N ,li , ri, sum;
  cin >> N;
  sum = 0;
  for (int i = 0; i < N; i++ ){
   cin >> li >> ri;
   sum = sum + ri - li + 1;
  }
  cout << sum << endl;
    
}


Measured memory_bytes: 256
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
int32_t main(){
	int q,h,s,d;
	int n; 
	cin>>q>>h>>s>>d>>n;
	q*=4;
	h*=2;
	int x=h+2*q;
	int ans=0;
	int mini=min(q,min(h,min(s,x)));
	if(d<2*mini){
		ans+=(n/2)*d;
		n%=2;
	if(n) ans+=mini;		
	}
	else{
		ans+=n*mini;
	}
	cout<<ans<<endl;
}

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

int main(){
  char C;
  string Alphabet="abcdefghijklmnopqrstuvwxyz";
  cin>>C;
  for(unsigned int i=0; i<25; i++){
    if(Alphabet[i]==C){
      cout << Alphabet[i+1] << endl;
      break;
      //iについて暗黙のunsigned intへの符号変換となるが気にしなくて良い
    }
  }
  return 0;
}

Measured memory_bytes: 256
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#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>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int32_t main()
{
	fast();
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n,m;
		cin>>n>>m;
		int a,b;
		int c,d;
		cin>>a>>b>>c>>d;
		string s[n];
		for(int i=0;i<n;i++)
		cin>>s[i];
		using pi=pair<int,pair<int,int>>;
		priority_queue<pi,vector<pi>,greater<pi>> pq;
		pq.push({0,{a-1,b-1}});
		int dist[n][m];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
				dist[i][j]=LLONG_MAX;
		}
		dist[a-1][b-1]=0;
		while(!pq.empty())
		{
			pi p=pq.top();
			pq.pop();
			int x=p.second.first;
			int y=p.second.second;
			//cout<<x<<" "<<y<<endl;
			int c=p.first;
			
			if(x+1<n)
			{
				if(dist[x+1][y]>dist[x][y] and (s[x+1][y]=='.'))
				{
				
					dist[x+1][y]=dist[x][y];//(s[x+1][y]=='#');
					pq.push({dist[x+1][y],{x+1,y}});
				}
			}
			if(x-1>=0)
			{
				if(dist[x-1][y]>dist[x][y] and (s[x-1][y]=='.'))
				{
				
					dist[x-1][y]=dist[x][y];//(s[x-1][y]=='#');
					pq.push({dist[x-1][y],{x-1,y}});
				}
			}
			if(y+1<m)
			{
				if(dist[x][y+1]>dist[x][y] and (s[x][y+1]=='.'))
				{
				
					dist[x][y+1]=dist[x][y];//(s[x][y+1]=='#');
						pq.push({dist[x][y+1],{x,y+1}});
				}
			}
			if(y-1>=0)
			{
				if(dist[x][y-1]>dist[x][y] and (s[x][y-1]=='.'))
				{
				
					dist[x][y-1]=dist[x][y];//(s[x][y-1]=='.');
						pq.push({dist[x][y-1],{x,y-1}});
				}
			}
			for(int i=max((ll)0,x-2);i<=min(n-1,x+2);i++)
			{
				for(int j=max((ll)0,y-2);j<=min(m-1,y+2);j++)
				{
					if(s[i][j]=='.' and dist[i][j]>dist[x][y]+1)
					{
					
						dist[i][j]=dist[x][y]+1;
						pq.push({dist[i][j],{i,j}});
					}
				}
			}
			
		}
		if(dist[c-1][d-1]==LLONG_MAX)
		cout<<"-1"<<endl;
		else
		cout<<dist[c-1][d-1]<<endl;
		//return getans(a,b,c,d,s);	
	}
}








Measured memory_bytes: 12644
#include <iostream>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;
#define C

struct card
{
	card(const card&a) {
		mark = a.mark;
		num = a.num;
	}
	card(const char* str)
	{
		*this = str;
	}
	card() {}

	char mark;
	int	num;

	void operator = (const char * str) {
		mark = str[0];
		num = str[1] - 0x30;
	}
	bool operator < ( const card & right)const {
		return num < right.num;
	}
	bool operator == (const card & right) const {
		return  (num == right.num) && (mark == right.mark);
	}
	

};

template<typename T>
int bubbleSort(list<T>&arr) {
	int cunt = 0;
	bool cont = true;
	int n = arr.size();
	while (cont)
	{
		typename	list<T>::iterator it1 = arr.begin(), it2 = arr.begin();
		advance(it2, 1);
		cont = false;
		for (int i = 1; i < n; ++i, advance(it1, 1), advance(it2, 1))
		{
			if ( *it2 < *it1 ) {
				swap(*it1, *it2);
				cont = true;
				cunt++;
			}
		}
	}
	return cunt;
}

template <typename T>
int selectionSort(list<T>& arr) {
	int cunt = 0;
	int n = arr.size();
	typename list<T>::iterator it1, it2, min, itend = arr.end();
	for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
	{
		min = it1;
		for (it2 = next(it1); it2 != itend; advance(it2, 1))
		{
			if (*it2 < *min)
				min = it2;
		}
		if (it1 != min) {
			cunt++;
			swap(*it1, *min);
		}
	}
	return cunt;	
}

void listPrint(list<int>& arr) {
	list<int>::iterator it = arr.begin(), itend = arr.end();
	cout << *it;
	advance(it, 1);
	for (; it != itend; advance(it, 1))
		cout << " " << *it;
	cout << endl;
}
void listPrint(list<card>& arr) {
	list<card>::iterator it = arr.begin(), itend = arr.end();
	cout << it->mark << it->num;
	advance(it, 1);
	for (; it != itend; advance(it, 1))
		cout << " " << it->mark << it->num;
	cout << endl;
}

bool stableCheck(const vector<card> &origin, const vector<card> & sor) {
	int n = origin.size();
	if (n != sor.size()) return false;  /// ??????????????????
	for (size_t i = 0; i < n-1; i++)
	{
		if (sor[i].num != sor[i + 1].num)
			continue;
		size_t j = 1;
		for (; i + j + 1 < n && sor[i].num == sor[i + j + 1].num; j++) {
			int a =1;
		};

		bool flag = true;
		for (size_t a = 0; a < j && flag; a++)
		{
			for (size_t b = a; b < j &&flag; b++)
			{
				for (size_t k = 0; k < n &&flag; k++)
				{
					if (sor[i + a] == origin[k])
						flag = false;
					if (sor[i + b + 1] == origin[k])
						return false;
				}
					
			}
		}

		i += j;

	}
	return true;


}

#ifdef C
int main(void)
{
	int n;
	cin >> n;
	list<card> arr1(n), arr2(n) ;
	vector<card> aar0(n),aar1(n),aar2(n);
	char str[3];
	for (auto & a :aar0)
	{
		cin >> str;
		a = str;
	}
	std::copy(aar0.begin(), aar0.end(), arr1.begin());
	std::copy(aar0.begin(), aar0.end(), arr2.begin());

	bubbleSort(arr1);
	listPrint(arr1);
	std::copy(arr1.begin(), arr1.end(), aar1.begin());
	arr1.clear();
	if (stableCheck(aar0, aar1))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;


	selectionSort(arr2);
	listPrint(arr2);
	std::copy(arr2.begin(), arr2.end(), aar2.begin());
	arr2.clear();
	if (stableCheck(aar0, aar2))
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;


	return 0;
}
#endif // C

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include <cstdio>
#define ll long long
#define pb push_back
using namespace std;

ll mod=998244353;

int expo(int base,int exponent){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}


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

    int tests=1,asn=0;
   //scanf("%d",&tests);
   //cin>>tests;
    while(tests--)
    {
       ll h,w,i,j;
       cin>>h>>w;
       vector<ll>temp(w,0);
       vector<vector<ll>>cal(h,temp);
       vector<char>tmp(w);
       vector<vector<char>>m(h,tmp);
       for (i=0;i<h;i++)
       {
           for(j=0;j<w;j++)
           cin>>m[i][j];
       }
       ll ans=0;
       for(i=0;i<h;i++)
       {
           for(j=0;j<w;j++)
           {
               if(m[i][j]=='#')
               {
                   ll val1=1,val2=1;
                   if(i>0)
                   {
                       if(m[i-1][j]=='.') val1=cal[i-1][j]+1;
                       else val1=cal[i-1][j];
                   }
                   if(j>0)
                   {
                       if(m[i][j-1]=='.') val2=cal[i][j-1]+1;
                       else val2=cal[i][j-1];
                   }
                   if(i>0 && j>0) cal[i][j]=min(val1,val2);
                   else if(i>0) cal[i][j]=val1;
                   else if(j>0) cal[i][j]=val2;
                   else cal[i][j]=1;
               }
               else
               {
                   ll val1=0,val2=0;
                   if(i>0)
                   {
                       val1=cal[i-1][j];
                   }
                   if(j>0)
                   {
                       val2=cal[i][j-1];
                   }
                   if(i>0 && j>0) cal[i][j]=min(val1,val2);
                   else if(i>0) cal[i][j]=cal[i-1][j];
                   else if(j>0)cal[i][j]=cal[i][j-1];
                   else cal[i][j]=0;
               }
           }
       }

    //    for(i=0;i<h;i++)
    //    {
    //        for(j=0;j<w;j++) cout<<cal[i][j]<<" ";
    //        cout<<"\n";       }

        cout<<cal[h-1][w-1];
    }
    //cout<<asn;
    return 0;
}

Measured memory_bytes: 384
num_list = [int(e) for e in input().split()]

def digitSum(N):
    s = str(N)
    array = list(map(int, s))
    return sum(array)

SUM = 0

for j in range(num_list[0]):
    value = digitSum(j+1)
    if num_list[1] <= value <= num_list[2]:
        SUM += j+1


print(SUM)


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

int main(){
	int n,m;
	cin>>n>>m;
	int k[n];
	int array[31];
	for(int i=0;i<31;i++){
		array[i]=0;
	}

	for(int i=0;i<n;i++){
		cin>>k[i];
		int a[k[i]];
		for(int j=0;j<k[i];j++){
			cin>>a[i];
			array[a[i]]++;
		}
	}
	int ans=0;
	for(int i=0;i<31;i++){
		if(array[i]==n){
			ans++;
		}
	}

	cout<<ans<<endl;

}


Measured memory_bytes: 256
INF=10**6+1
n,*l=map(int,open(0).read().split())
from collections import *
c=Counter(l)
l=sorted(c.keys())
a=[]
b=[0]*INF
for i in l: b[i]=1  
for i in l:
  if b[i]:
    if c[i]<2: a+=[i]
    for j in range(2*i,INF,i): b[j]=0
print(len(a))

Measured memory_bytes: 122152
W,H,N = [int(i) for i in input().split()]

min_x = W
max_x = 0
min_y = H
max_y = 0
for i in range(N):
    x,y,a = [int(i) for i in input().split()]
    if a == 1:
        max_x = max(max_x,x)
    elif a == 2:
        min_x = min(min_x,x)
    elif a == 3:
        max_y = max(max_y,y)
    else:
        min_y = min(min_y,y)

if min_x <= max_x or min_y <= max_y:
    print(0)
else:
    print((min_x-max_x)*(min_y-max_y))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, K; cin >> N >> K;
    map<ll, ll> M;
    rep (i, K) {
        ll d; cin >> d;
        rep(j,d) {
            ll A; cin >> A;
            M[A]++;
        }
    }

    ll sum = 0;
    for (ll i = 1; i<= N; i++) {
        if (M.count(i) == 0) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  
  ans=(n*k+1)/2;
  //ans=(n+1)/2*((k+1)/2);
  //ans+=(n)/2*((k)/2);

  if (n==1||k==1){
    cout<<1<<endl;
    return 0;
  }

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

/*

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;
ll a,b,c;
int main(){
  ll ans=0;
  cin >> a >> b>>c;
  string s;cin>>s;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];
  cout<<ans<<endl;
  return 0;
}*/

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

int insertionSort(int*, int, int);
void shellSort(int*, int);

int insertionSort(int *A, int n, int g){
  int i, j, v;
  int cnt = 0;

  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }

  return cnt;
}

void shellSort(int *A, int n){
  int i, j;
  int cnt = 0;
  int m = 0;
  int *G;

  i = n;
  if(n == 1)  m =1;
  while(i > 1){
    m++;
    i /= 2;
  }

  G = (int *)malloc(sizeof(int) * m);
  /*if(n % 2){
    G[0] = n-1;
    for(i=1;i<m;i++){
      for(j=G[i-1];j>0;j--){
        if(n%j == 0){
          G[i] = j;
          break;
        }
      }
    }
  } else {*/
    G[0] = n/2;
    for(i=1;i<m;i++){
      G[i] = G[i-1]/2;
    }
  //}

  // print
  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",G[i]);
    if(i != m-1) printf(" ");
    else printf("\n");
  }

  for(i=0;i<m;i++){
    cnt += insertionSort(A, n, G[i]);
  }
  printf("%d\n",cnt);
}

int main(){
  int i,n;
  int *A;

  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  shellSort(A, n);

  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }

  return 0;
}



Measured memory_bytes: 5708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	if (a < b)cout << 0 << endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ss,o=1,temp;
int ans=-1;
int di(long long k)
{
	int re=0;
	while(k>0)
	{
		re+=k%10;
		k=k/10;
	}
	return re;
}
int main()
{
	scanf("%lld",&ss);
	ans=di(ss);
	while(o<=ss)
	{
		temp=ss;
		temp-=o;
		temp-=temp%o;
		temp+=o-1;
		ans=max(di(temp),ans);
		o*=10;
	}
	printf("%d",ans);
}


Measured memory_bytes: 256