akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    InitRand();
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    REP(i,D) {
        T[i] = rand()%26;
    }
    int M; M = 1e5;
    veci B(M),Q(M);
    REP(i,M) {
        B[i] = rand()%D;
        Q[i] = rand()%26;
    }

    veci last_d(26);
    ll old_ans = 0;
    REP(i,D) {
        int d = i+1;
        last_d[T[i]] = d;
        old_ans += S[i][T[i]];
        REP(j,26) {
            old_ans -= C[j]*(d-last_d[j]);
        }
    }

    REP(i,M) {
        int old_p = T[B[i]];
        T[B[i]] = Q[i];
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        if(old_ans < score) {
            old_ans = score;
        }
        else {
            T[B[i]] = old_p;
        }
    }
    REP(i,D) cout << T[i]+1 << endl;
}

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

namespace String
{
    class Transformation
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var q = int.Parse(Console.ReadLine());
            for (int i = 0; i < q; i++)
            {
                var token = Console.ReadLine().Split(' ');
                int a = int.Parse(token[1]);
                int b = int.Parse(token[2]);
                var pre = str.Substring(0, a);
                var suf = str.Substring(b+1);
                switch (token[0])
                {
                    case "print":
                        Console.WriteLine(str.Substring(a,b-a+1));
                        break;
                    case "reverse":
                        var array = new string(str.Substring(a, b - a+1).Reverse().ToArray());
                        str = pre + array + suf;
                        break;
                    case "replace":
                        str = pre + token[3] + suf;
                        break;
                }
            }
        }
    }
}

Measured memory_bytes: 9448
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli sv, se;
vector<lli> e[100001];

vector<lli> ts;
bool seen[100001];

void dfs(lli u) {
  if (seen[u]) return;
  seen[u] = true;
  for (lli v : e[u]) {
    dfs(v);
  }
  ts.push_back(u);
}

int main() {
  cin >> sv >> se;
  for (lli i=0; i<se; ++i) {
    lli u, v; cin >> u >> v;
    e[u].push_back(v);
  }
  for (lli u=0; u<sv; ++u) dfs(u);
  for (lli i=sv-1; i>=0; --i) cout << ts[i] << '\n';
  return 0;
}



Measured memory_bytes: 6208
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout<<c<<' '<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
    double r;
    double s,fai;
    scanf("%lf",&r);
    s=r*r*M_PI;
    fai=r*M_PI*2.00;
    printf("%lf %lf\n",s,fai);
    return 0;
}


Measured memory_bytes: 2104
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N; std::cin >> N;
    long long prd(1);
    std::vector<long long> A(N);
    for(int i(0); i < N; ++i){
        std::cin >> A[i];
        if(!A[i]){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    for(int i(0); i < N; ++i){
        if(A[i] > LINF/prd){
            std::cout << -1 << std::endl;
            return 0;
        }
        prd *= A[i];
    }
    std::cout << prd << std::endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  cout << (N >= 30 ? "Yes" : "No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N,M;
    cin >> N >> M;
    int ans=0;
    vector<pair<int,int>> v(M);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        v[i]=make_pair(b,a);
    }
    sort(all(v));
    int br=-1;
    rep(i,M){
        if(br>v[i].second)continue;
        else{
            ans++;
            br=v[i].first;
        }
    }
    cout << ans;
    


}

/*



 */



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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> count(N);
  int answer=1000000000;
  for(int i=0;i<N;i++){
    cin >> A[i];
    while(A[i] % 2 == 0){
      A[i] /= 2;
      count[i]++;
    }
    if(count[i] < answer){
      answer = count[i];
    }
  }
  cout << answer << endl;
}

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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll N,maxh;
    cin >> N;
    vll H(N);
    // vll lowered(N);
    REP(i,N){
        cin >> H[i];
        // lowered[i] = false;
    }

    maxh = H[0];

    //2 2 2 1

    bool flag = true;
    FOR(i,1,N-1){
        if((H[i] - maxh) < -1){
            flag = false;
            break;
        }else if((H[i]- maxh)==-1){
            // H[i-1]--;
            // lowered[i-1] = true;
        } else {

        }
        maxh = max(maxh, H[i]);
    }


    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 1024
N, M = map(int, input().split())

par = list(range(N))
rank = [1]*N
size = [1]*N

def find(x):
  if par[x] == x:
    return x
  else:
    return find(par[x])
  
def unite(x,y):
  x = find(x)
  y = find(y)
  
  if x == y:
    return
  if rank[x]<rank[y]:
    par[x]=y
    size[y]+= size[x]
  else:
    par[y] = x
    size[x] += size[y]
    if rank[x]==rank[y]:
      rank[x]+=1
    
for i in range(M):
  a,b = [int(i)-1 for i in input().split()]
  unite(a,b)
  
print(max(size))

Measured memory_bytes: 19920
#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;


int main(){
  int n; cin >> n;
  if (n == 3 || n == 5 || n == 7) cout << "YES" << endl;
  else cout << "NO" << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846

int main(void)
{
	double a,b,c,s,l,h,d;

	scanf("%lf %lf %lf",&a,&b,&c);
	d=PI*c/180;
	s=(a*b*sin(d))/2;
	c=sqrt((a*a)+(b*b)-(2*a*b*cos(d)));
	l=a+b+c;
	h=2*s/a;
	printf("%f\n%f\n%f\n",s,l,h);
	
	return 0;
}

Measured memory_bytes: 648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] array = new int[m][3];
        for (int i = 0; i < m; i++) {
            array[i][0] = sc.nextInt();
            array[i][1] = sc.nextInt();
            array[i][2] = i;
        }
        
        Arrays.sort(array, (a, b) -> Integer.compare(a[1], b[1]));    // foo[][1]で
        Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));    // foo[][0]で
        
        String[] id = new String[m];
        int nowp = -1;
        int nowy = -1;
        int y = 0;
        for (int i = 0; i < m; i++) {
            int px = array[i][0];
            int yx = array[i][1];
            if (yx != nowy) {
                nowy = yx;
                y++;
            }
            if (px != nowp) {
                nowp = px;
                
                nowy = yx;
                y = 1;
            }
            
            String upper = String.valueOf(px);
            while (upper.length() < 6) {
                upper = "0" + upper;
            }
            String lower = String.valueOf(y);
            while (lower.length() < 6) {
                lower = "0" + lower;
            }
            int index = array[i][2];
            id[index] = upper + lower;
        }
        
        for (int i = 0; i < m; i++) {
            System.out.println(id[i]);
        }
    }
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 2e5 + 10;

int n, arr[2][MAXN], cnt[2][MAXN], val;
vector<int> pos;

int main() {
    IO::read(n);
    rep(_, 0, 1) rep(i, 1, n) IO::read(arr[_][i]), cnt[_][arr[_][i]]++;
    reverse(arr[1] + 1, arr[1] + n + 1);
    rep(i, 1, n) if (arr[0][i] == arr[1][i]) val = arr[0][i], pos.push_back(i);
    int l = 1, r = n; bool flg = false;
    for (auto cur_pos : pos) {
        if (flg == false) {
            if (arr[0][l] != val && arr[1][l] != val) {
                swap(arr[1][l], arr[1][cur_pos]);
                ++l;
            } else flg = true;
        }
        if (flg == true) {
            if (arr[0][r] != val && arr[1][r] != val) {
                swap(arr[1][r], arr[1][cur_pos]);
                --r;
            } else return puts("No"), 0;
        }
    }
    puts("Yes");
    rep(i, 1, n) printf("%d ", arr[1][i]);
    return 0;
}

Measured memory_bytes: 6908
#include <stdio.h>
int main(void){
  int n,m,a[200000],e[100000],f[200001]={0},i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
    a[i]=i+1;
  for(i=0;i<m;i++)
    scanf("%d",&e[i]);
  for(i=m-1;i>=0;i--){
    if(f[e[i]])
      continue;
    printf("%d\n",e[i]);
    f[e[i]]++;
  }
  for(i=0;i<n;i++){
    if(f[a[i]])
      continue;
    printf("%d\n",a[i]);
  }
  return 0;
}

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

const int N = 1e5 + 50;
int n, L, a[N];

int main() {
	scanf("%d%d", &n, &L);
	for(int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	for(int i = 1; i < n; ++i)
		if(a[i] + a[i + 1] >= L) {
			puts("Possible");
			for(int j = 1; j < i; ++j)
				printf("%d\n", j);
			for(int j = n - 1; j > i; --j)
				printf("%d\n", j);
			printf("%d\n", i);
			return 0;
		}
	puts("Impossible");
	return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class18
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int R=0;
            foreach(int i in X)
            {
                R += Math.Min(i, K - i)*2;
            }
            Console.WriteLine(R);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<vector<int>> g(200010);
bool visited[200010];
int ans[200010];

void dfs(int v, int from) {
    visited[v] = true;
    if (from != -1)ans[v] += ans[from];
    for (int nv : g[v]) {
        if (visited[nv]) continue;
        dfs(nv, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, 0, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0, -1);
    rep(i, 0, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 20608
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  if((a*100+b*10+c)%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}



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

int main(int argc, char **argv)
{
	ll n; cin >> n;
	vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i];

	ll res{0};
	for (int i = 0; i < n;)
	{
		ll i1{-(1ll<<30)}, i2{-(1ll<<30)};
		if (a[i] <= a[i+1])
		{
			// not decrease
			i1 = i + 1;
			while (a[i1] <= a[i1+1] && i1 < n) ++i1;
		}
		if (a[i] >= a[i+1])
		{
			// not increase
			i2 = i + 1;
			while (a[i2] >= a[i2+1] && i2 < n) ++ i2;
		}

		// std::cout << "(i1, i2) = (" << i1 << ", " << i2 << ")" << std::endl;
		i = max(++i1, ++i2);
		res++;
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string s;
  cin >> s;
  int one = 0;
  int zero = 0;
  rep(i, s.size()) {
    if (s[i] == '0')
      zero++;
    else
      one++;
  }
  cout << min(one, zero) * 2 << endl;
  return 0;
}


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

typedef long long ll;

int main(){
    ll N,X;
    cin>>N>>X;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin>>a[i];

    ll ans  = 0;

    for(int i=1; i<N; i++){
        ll sum = a[i] + a[i-1];
        if(sum > X){
            ans += sum-X;
            if(sum-X > a[i]){
                a[i] = 0;
                a[i-1] -= sum-X-a[i];
            }else{
                a[i] -= sum-X;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4028
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    long long N, K;cin >> N >> K;
    vector<pair<int, int> > C(N);
    REP(i, N)
    {
        int a, b;
        cin >> a >> b;
        C.at(i) = make_pair(a, b);
    }
    
    SORT(C);
    REP(i, N)
    {
        K -= C.at(i).second;
        if (K<=0) 
        {
            cout << C.at(i).first << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> X(M);
  rep(i, M) cin >> X[i];

  sort(all(X));
  vector<long long> dist(M-1);
  rep(i, M-1) dist[i] = X[i+1] - X[i];
  sort(all(dist));

  long long ans = 0;
  rep(i, M-N) ans += dist[i];

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 1792
x,y = map(int,input().split())

if y*x<0:
    print(abs(abs(y)-abs(x))+1)
elif y-x<0:
    if x==0 or y==0:
        print(abs(abs(y)-abs(x))+1)
    else:
        print(abs(abs(y)-abs(x))+2)
else:
    print(abs(abs(y)-abs(x)))

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
class Card {
	private String suit;
	private int number;
	
	Card(String suit, int number){
		this.suit = suit; this.number = number;
	}
	
	String getCard() { return suit + number;} 
	String getSuit() { return suit;}
	int getNum() { return number;}
	
	
	void setSuit(String suit) { this.suit = suit;}
	void setNum(int number) { this.number = number;}
	public String toString() {
		return this.suit + this.number;
	}
}

public class Main {
	
	//カードの並び替え前と後で同じ数字における絵柄の順序は変化していないかの判断
	static String stableJudge(Card[] bubble, Card[] selection) {
		for(int i = 0 ; i < bubble.length;i++) {
			if(!(bubble[i].getSuit().equals(selection[i].getSuit()))) {
				return "Not stable";
			}
		}
		return "Stable";
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		Card[] cardB = new Card [n];
		Card[] cardS = new Card [n];
		
		for(int i = 0; i < cardB.length; i++) {
			String m = stdIn.next();
			cardB[i] = new Card(m.substring(0, 1),Integer.valueOf(m.substring(1, 2)));
			cardS[i] = new Card(m.substring(0, 1),Integer.valueOf(m.substring(1, 2)));
		}

		
		//Bubble sort
				for(int i = 0; i < cardB.length; i++) {
					for(int j = cardB.length - 1; j - 1 >= i; j--) {
						if(cardB[j].getNum() < cardB[j - 1].getNum()){
						Card t  = cardB[j - 1];
						cardB[j - 1] = cardB[j];
						cardB[j] = t;
						}
					}
				}
				for(int i = 0; i < cardB.length - 1; i++) {
					System.out.print(cardB[i] + " ");
				}	System.out.println(cardB[cardB.length - 1]);
				System.out.println("Stable");
				
		//selection sort
				for(int i = 0 ; i < cardS.length; i++) {
					int minj = i;
					for(int j = i + 1; j < cardS.length; j++) {
						if(cardS[minj].getNum() > cardS[j].getNum()){
						minj = j;
						} 
					}
					Card s = cardS[i];
					cardS[i] = cardS[minj];
					cardS[minj] = s;
				}
				for(int i = 0; i < cardS.length - 1; i++) {
					System.out.print(cardS[i] + " ");
				}	System.out.println(cardS[cardS.length - 1]);
				System.out.println(stableJudge(cardB, cardS));
		}
}



Measured memory_bytes: 26264
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    int k = read(), q = read();
    vector<int> d(k);
    generate_n(begin(d), k, read);
    while (q--) {
        int n = read() - 1, x = read(), m = read();
        LL sum = 0;
        int cnt = 0;
        for (int x : d) {
            sum += x % m;
            if (x % m == 0) {
                ++cnt;
            }
        }
        sum *= n / k;
        cnt *= n / k;
        sum += x % m;
        for (int i = 0, _ = n % k; i < _; ++i) {
            sum += d[i] % m;
            if (d[i] % m == 0) {
                ++cnt;
            }
        }
        int ans = n - cnt - sum / m;
        printf("%d\n", ans);
    }
    return 0;
}


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

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N){

  op(N*N*N)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N, K;
  cin >> N >> K;
  if(N%K==0) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[123456];
int n,m;
int main(){
    string s;
    cin>>s;
    string ans = "";
    for (int i = 0; i < s.length(); i += 2)
    {
        ans += s[i];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll n,k; cin >> n >> k;
    ll ans = 0;
    for(ll i = k+1; i <= n; i++){
        ans += (n/i)*(i-k);
        ans += max(0LL, (n%i)-k+1);
    }
    if(k == 0) ans = n*n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 1, y = 1, ans = 1, k;
        ll a[5];
        for(int i = 0; i < 5; i++) cin >> a[i];
        for(int i = 0; i < 5; i++)
        {
            if(a[i] == 0)
                ans = i + 1;
        }
        cout << ans << "\n";
     }
     return 0;
}


Measured memory_bytes: 3648
h,w,k=map(int,input().split())
ans=10**9
choco=[list(input()) for i in range(h)]
sumL=[[0 for i in range(w+1)] for j in range(h+1)]
for i in range(h):
    for j in range(w):
        sumL[i][j]=sumL[i-1][j]+sumL[i][j-1]-sumL[i-1][j-1]+int(choco[i][j])
for stat in range(2**(h-1)):
    cnt=0;previous=-1
    flg=0
    cut=format(stat,"b").zfill(h-1)
    cutl=[]
    for hi in range(h-1):
        if cut[hi]=="1":
            cutl.append(hi)
            cnt+=1
    cutl.append(h-1)
    cutl.append(-1)
    for yoko in range(w):
        for seg in range(len(cutl)):
            if sumL[cutl[seg]][yoko]-sumL[cutl[seg]][previous]-sumL[cutl[seg-1]][yoko]+sumL[cutl[seg-1]][previous]>k and yoko-previous<=1:flg=1
            elif sumL[cutl[seg]][yoko]-sumL[cutl[seg]][previous]-sumL[cutl[seg-1]][yoko]+sumL[cutl[seg-1]][previous]>k:previous=yoko-1;cnt+=1
            
    if not flg and cnt < ans:ans=cnt
    
print(ans)


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

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

auto convert(int a, int L) -> string {
  string res, s;
  s = to_string(a);
  while(true) {
    if(res.size() == L-s.size()) break;
    res += '0';
  }
  res += s;
  return res;
}

int memo[1000001];

int main(void){
  int a, L;
  while(cin>>a>>L, L!=0) {
    fill(memo, memo+1000000, 1e+9);
    int j = 0;
    memo[a] = 0;
    while(true) {
      j++;
      string s = convert(a, L);
      sort(s.begin(), s.end());
      string min_s = s;
      reverse(s.begin(), s.end());
      string max_s = s;

      int diff = stoi(max_s) - stoi(min_s);
      if(memo[diff]!=1e+9) {
        cout << memo[diff] << " " << diff << " " << j - memo[diff] << endl;
        break;
      }
      else {
        memo[diff] = j;
      }
      a = diff;
    }
  }

  return 0;
}

Measured memory_bytes: 7092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<map>
#define M 1000010
using namespace std;
int read()
{
	char ch=getchar();int x=0;
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
struct point{
	int to,next,dis;
}e[M<<1];
int n,m,num,cnt;
int head[M],dis[M];bool vis[M];
void add(int from,int to,int dis)
{
	e[++num].next=head[from];
	e[num].to=to;
	e[num].dis=dis;
	head[from]=num;
}
void SPFA()
{
	memset(dis,127,sizeof(dis));
	queue<int>q;
	q.push(1);
	vis[1]=true;
	dis[1]=0;
	while(!q.empty())
	{
		int x=q.front(); q.pop();
		for(int i=head[x];i;i=e[i].next)
		{
			int to=e[i].to;
			if(dis[to]>dis[x]+e[i].dis)
			{
				dis[to]=dis[x]+e[i].dis;
				if(!vis[to])
				{
					vis[to]=true;
					q.push(to);
				}
			}
		}
		vis[x]=false;
	}
}
map<pair<int,int>,int>P;
int get(int x,int y)
{
	if(P.find(make_pair(x,y))!=P.end()) return P[make_pair(x,y)];
	else return P[make_pair(x,y)]=++cnt;
}
int main()
{
	n=cnt=read(); m=read();
	for(int i=1;i<=m;i++)
	{
		int a=read(),b=read(),c=read();
		int id1=get(a,c),id2=get(b,c);
		add(id1,id2,0); add(id2,id1,0);
		add(a,id1,1); add(id1,a,1);
		add(b,id2,1); add(id2,b,1);
	}
	SPFA();
	printf("%d\n",dis[n]>2*n?-1:dis[n]/2);
	return 0;
}

Measured memory_bytes: 49792
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long xM,xm,yM,ym;
  long long a,b;
    cin>>a>>b;
    long long c,d;
    c=a-b;
    d=a+b;
    xM=c;
    xm=c;
    yM=d;
    ym=d;
  for(int i=1;i<N;i++){
    long long x,y;
    cin>>x>>y;
    long long j,k;
    j=x-y;
    k=x+y;
    xM=max(xM,j);
    xm=min(xm,j);
    yM=max(yM,k);
    ym=min(ym,k);
  }
  cout<<max(xM-xm,yM-ym)<<endl;
  
  return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    vector<int> edge;
    for(int i=0,x; i<3; i++){
      cin >>x;
      edge.push_back(x*x);
    }
    sort(edge.begin(),edge.end());
    if(edge[2] == edge[1]+edge[0]){cout <<"YES"<<endl;}
    else{cout <<"NO"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



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

Measured memory_bytes: 256
N = gets.to_i

ans = Hash.new(0) # 0で初期化したhash

# 最大10^6回くらいしかまわらないので，間に合う
1.upto Math.sqrt(N).floor do |x|
  1.upto Math.sqrt(N).floor do |y|
    1.upto Math.sqrt(N).floor do |z|
      pol = x*x + y*y + z*z + x*y + y*z + z*x
      if pol > N
        break
      end
      ans[pol] += 1
    end
  end
end

N.times do |i|
  puts ans[i+1]
end

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

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

  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else if (N % 500 >= A) {
    cout << "No" << endl;
  }  
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long

using namespace std;

string s[5]={"dream","dreamer","erase","eraser"},a;

void dfs(int pos)
{
	if(pos==a.size())
	{
		printf("YES");
		exit(0);
	}
	if(a.substr(pos,5)==s[0])dfs(pos+5);
	if(a.substr(pos,5)==s[2])dfs(pos+5);
	if(a.substr(pos,6)==s[3])dfs(pos+6);
	if(a.substr(pos,7)==s[1])dfs(pos+7);
}

int main()
{
	cin>>a;
	dfs(0);
	printf("NO");
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i, N+1) cin >> A[i];
  vector<ll> B(N);
  rep(i, N) cin >> B[i];

  ll answer {};
  ll primary = A[N];
  drep(i, N) {
    if (B[i] > primary) {
      answer += primary;
      ll atack = B[i] - primary;
      if (atack < A[i]) {
        primary = A[i] - atack;
        answer += atack;
      } else { // atack >= A[i]
        primary = 0;
        answer += A[i];
      }
    } else {
      answer += B[i];
      primary = A[i];
    }
  }
  cout << answer << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll X;cin>>X;

  ll res = 0;
  ll v = 100;
  while(v<X){
    v*=1.01;++res;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300000;
const int mod = 998244353;
const int K = 60;
const int M = 16;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (i % 15 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }
    cout << ans;
}


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

using namespace std;

#define PII pair<int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int i,j,k,m,n,x,y,z,dx,dy;
    cin >> n >> m >> k;
    int dist[n+5][m+5];
    char grid[n+5][m+5];
    cin >> x >> y >> dx >> dy;
    for(i=1;i<=n;i++)
    {
        cin >> grid[i]+1;
        for(j=1;j<=m;j++)dist[i][j]=INT_MAX;
    }
    priority_queue<pair<int,PII>,vector<pair<int,PII> >,greater<pair<int,PII> > >pq;
    dist[x][y]=0;
    pq.push({0,{x,y}});
    while(!pq.empty())
    {
        z=pq.top().first+1;
        x=pq.top().second.first;
        y=pq.top().second.second;
        pq.pop();
        for(i=x-1;i>=x-k;i--)
        {
            if(i == 0  ||  dist[i][y] < z  ||  grid[i][y] == '@')break;
            else
            {
                if(dist[i][y] == z)continue;
                dist[i][y]=z;
                pq.push({z,{i,y}});
            }
        }
        for(i=x+1;i<=x+k;i++)
        {
            if(i > n  ||  dist[i][y] < z  ||  grid[i][y] == '@')break;
            else
            {
                if(dist[i][y] == z)continue;
                dist[i][y]=z;
                pq.push({z,{i,y}});
            }
        }
        for(i=y-1;i>=y-k;i--)
        {
            if(i == 0  ||  dist[x][i] < z  ||  grid[x][i] == '@')break;
            else
            {
                if(dist[x][i] == z)continue;
                dist[x][i]=z;
                pq.push({z,{x,i}});
            }
        }
        for(i=y+1;i<=y+k;i++)
        {
            if(i > m  ||  dist[x][i] < z  ||  grid[x][i] == '@')break;
            else
            {
                if(dist[x][i] == z)continue;
                dist[x][i]=z;
                pq.push({z,{x,i}});
            }
        }
    }
    if(dist[dx][dy] == INT_MAX)cout << "-1";
    else cout << dist[dx][dy];
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli n,m;
vector<lli> a;
lli data[9]={2,5,5,4,5,6,3,7,6};

#define MINUINF "("

//i本使ったときの dp[i]:桁数
string dp[10100];

void chmax(string &a,string b){
	if(a==MINUINF)a = b;
	else if(a.size()<b.size())a = b;
	else if(a.size()==b.size()){
		if(a<b)a=b;
	}
}

signed main(){

	cin>>n>>m;

	lli data[9]={2,5,5,4,5,6,3,7,6};
	a.resize(m);
	REP(i,0,m){
		cin>>a[i];
	}

	sort(a.begin(),a.end(),greater<lli>());

	REP(i,0,10100)dp[i]=MINUINF;
	dp[0]="";

	REP(i,0,m){
		REP(j,0,10090){
			if(dp[j]==MINUINF)continue;
			chmax(dp[j+data[a[i]-1]],dp[j]+(char)(a[i]+'0'));
	//		dp[j+data[a[i]]] = max(dp[j+data[a[i]]],dp[j]+(char)a[i]+'1');
		}
	}
	cout<<dp[n]<<endl;

	return 0;
}

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

int main() {
  string S;
  int count=0, Ans=0;
  cin >> S;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'G' || S.at(i) == 'C'){
      count +=1;
    }
    else{
      if(Ans < count){
        Ans = count;
        count = 0;
      }
    }
  }
  if(Ans < count){
    cout << count;
  }
  else{
    cout << Ans;
  }
}


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

using namespace std;

int main(){
	string x;
	int ans,i,n,s,t;
	cin >> x;
	n = x.size();
	s = 0;
	t = 0;
	for(i=0;i<n;i++){
		if(x[i]=='S'){
			s++;
		}else{
			if(s>0){
				s--;
			}else{
				t++;
			}
		}
	}
	cout << 2*t << endl;
}
			


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define INF 0x3f3f3f3f3f3f3f3f
#define PI acos(-1.0)
#define MOD 1000000007
//#define eps 1e-10
#define R freopen("555input.txt","r",stdin);
#define W freopen("medical.out","w",stdout);
//
#define N 105
#define M 1000000005
int n,i,j,a,b,c,d,ans,f[N];
int main ()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(i=a;i<b;i++)
        f[i]=1;
    for(i=c;i<d;i++)
        f[i]++;
    for(i=0;i<100;i++)
        if(f[i]==2)ans++;
    cout<<ans;





    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

string s;
int d;

void add(int& x, int v) {
  x = (x + v) % MOD;
}

void solve() {
  // dp[i][j][k]: 到第i位为止，和为k mod d的数有几个。j代表是否前面都和s中第i位相同
  vector<vector<vector<int> > > dp(s.size() + 1, vector<vector<int> >(2, vector<int>(d, 0)));
  dp[0][1][0] = 1;
  for (int i=1; i<=s.size(); ++i) {
    for (int g=0; g<=9; ++g) {
      for (int p=0; p<d; ++p) {
        int digit = s[i-1] - '0';
        int q = (g + p) % d;
        if (g < digit) {
          add(dp[i][0][q], dp[i-1][0][p]);
          add(dp[i][0][q], dp[i-1][1][p]);
        } else if (g == digit) {
          add(dp[i][0][q], dp[i-1][0][p]);
          add(dp[i][1][q], dp[i-1][1][p]);
        } else {
          add(dp[i][0][q], dp[i-1][0][p]);
        }
      }
    }
  }
  cout << ((dp[s.size()][0][0] + dp[s.size()][1][0] - 1) % MOD + MOD) % MOD << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  cin >> d;
  solve();
  return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll a,b,c,d;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num[100005];
ll n,k,x,y;

string s;
int main()
{
    //IOS
    while(cin>>n)
    {

        rep1(i,n) cin>>num[i];
        sort(num+1,num+n+1);
        cout<<num[n/2+1]-num[n/2]<<"\n";
    }


}


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

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	string ans;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    vector<int> carrot(l+1);
    for (int i = 0; i < n; ++i) {
        int d;
        scanf("%d", &d);
        carrot[d]++;
    }
    int boost = 0, cnt = 0;
    double ans = 0;
    for (int cur = 0; cur < l; ++cur) {
        if(carrot[cur]) {
            if(cnt == k) boost = t*v;
            else {
                cnt++;
                if(boost == 0){
                    boost = t*v;
                    cnt--;
                }
            }
        }
        if(boost){
            ans += 1.0 / v;
            boost--;
            if(boost == 0 && cnt){
                boost = t*v;
                cnt--;
            }
        }else {
            ans += 1.0 / u;
        }
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3264
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int l,r;
int get_bit(int x,int p){
	return (x>>p)&1;
}
signed main(){
	cin>>l>>r;
	if(l==r){
		cout<<1<<endl;
		return 0;
	}
	int high=62;
	while(high&&get_bit(l,high)==get_bit(r,high))high--;
	l&=(1ll<<high+1)-1ll;r&=(1ll<<high+1)-1ll;
	cerr<<l<<" "<<r<<" "<<(1ll<<high)<<endl;
	pair<int,int>segl=make_pair(l,(1ll<<high)-1ll);
	pair<int,int>segr=make_pair(1ll<<high,r);
	int hr=-1;
	for(int i=high-1;i>=0;i--){
		if(r&(1ll<<i)){
			hr=i;break;
		}
	}
	int ans=(1ll<<high)-l+(1ll<<hr+1);
	//r->all(0,hr) l->get(hr+1,high-1)
	int mask=0,tot=0;
	for(int i=hr+1;i<=high-1;i++)mask|=(1ll<<i),tot++;
	int cur=l&mask;cur>>=(hr+1);
	ans+=((1ll<<tot)-cur-1ll)*(1ll<<hr+1); 
	if(cur){
		int tmp=l-(cur<<hr+1);
		ans+=(1ll<<hr+1)-tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
		DMP(cusum);
	}
	CuSum(const int N) : cusum(N + 1) {}
	void add(const int i, const T &x) { cusum[i + 1] += x; }
	void build() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	const T &operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	CuSum<lint> cuA(A);

	unordered_map<lint, vector<lint>> mp;
	for (int i = 0; i <= N; i++) mp[(cuA(0, i) - (i + 1) % K + K) % K].emplace_back(i);

	lint ans = 0;
	for (const auto &e : mp) {
		auto vec = e.second;
		for (int i = 0; i < vec.size(); i++) {
			ans += lower_bound(vec.begin(), vec.end(), vec[i] + K) - vec.begin() - i - 1;
		}
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int ans = 1;
  rep(i, n) (ans *= (i+1)) %= mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256