iidai/codenet huggingface dataset:
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Example test case(s):
input: erasedream

output: YES
Language: C++

#include <algorithm>
#include <cstdio>

int main() {
    int n, m, x;
    int a[105] = {};
    scanf("%d %d %d", &n, &m, &x);

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

    int ansl = 0, ansr = 0, i;
    for (i = x; i <= n; ++i) {
        ansr += a[i];
    }
    for (i = x; i >= 0; --i) {
        ansl += a[i];
    }

    printf("%d\n", std::min(ansl, ansr));
    return 0;
}

Example test case(s):
input: 5 3 3
1 2 4

output: 1
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

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

    cout << (e - a <= k ? "Yay!" : ":(") << endl;

    return 0;
}

Example test case(s):
input: 1
2
4
8
9
15

output: Yay!
Language: C++

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (1 ? 1e9 + 7 : 998244353);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, d, e, f, g, T;
    string z;
    cin >> z;
    a = z.size();
    for (int i = 0; i < a - 1; i++) {
        if (z[i] == z[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Example test case(s):
input: 3776

output: Bad
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define dep(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, a) for (int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 1e5 + 10;

struct edge {
    int to, pre, c;
} e[N << 1];
int u[N], l = 0;
void ins(int a, int b, int c) { e[++l] = (edge){b, u[a], c}, u[a] = l; }
#define v e[i].to
#define ec e[i].c
#define reg(i, a) for (int i = u[a]; i; i = e[i].pre)

int n, m;
bool vis[N], ok;
LL cnt[3];
int d[N];
int T;
void dfs(int x, int l) {
    vis[x] = true;
    cnt[l]++;
    d[x] = l;
    reg(i, x) {
        T++;
        if (!vis[v])
            dfs(v, (l + ec) % 3);
        else if ((l + ec) % 3 != d[v])
            ok = false;
    }
}

int main() {
    scanf("%d%d", &n, &m);
    rep(i, 1, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        ins(a, b, 1), ins(b, a, 2);
    }
    LL ans = 0;
    rep(i, 1, n) if (!vis[i]) {
        T = 0;
        rep(j, 0, 2) cnt[j] = 0;
        ok = true;
        dfs(i, 0);
        LL s = cnt[0] + cnt[1] + cnt[2];
        if (!ok)
            ans += s * s;
        else {
            if (cnt[0] && cnt[1] && cnt[2])
                ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
            else
                ans += T / 2;
        }
    }
    cout << ans << endl;
}

Example test case(s):
input: 3 2
1 2
2 3

output: 3
Language: C++

#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main() {
    int s, x, d = 2;
    cin >> s;
    set<int> a;
    a.insert(s);

    while (1) {
        if (s % 2 == 0) {
            x = s / 2;
            if (a.find(x) != a.end()) {
                cout << d << endl;
                return 0;
            }
            a.insert(x);
        } else {
            x = 3 * s + 1;
            if (a.find(x) != a.end()) {
                cout << d << endl;
                return 0;
            }
            a.insert(x);
        }
        s = x;
        d++;
    }

    cout << d << endl;

    return 0;
}

Example test case(s):
input: 8

output: 5
Language: C++

#include <iostream>

using namespace std;
const int MAX_N = 1e3;
int data[MAX_N];
int main() {
    int m, nmi, nma;
    while (cin >> m >> nmi >> nma && nmi != 0) {
        for (int i = 0; i < m; i++) cin >> data[i];
        int ma = 0;
        int ans = 0;
        for (int i = nmi - 1; i < nma; i++) {
            if (ma <= data[i] - data[i + 1]) {
                ans = i + 1;
                ma = data[i] - data[i + 1];
            }
        }
        cout << ans << endl;
    }
}

Example test case(s):
input: 5 2 4
100
90
82
70
65
5 2 4
100
90
80
75
65
3 1 2
5000
4000
3000
4 2 3
10000
10000
8000
8000
4 2 3
10000
10000
10000
8000
5 2 3
100
80
68
60
45
0 0 0

output: 3
4
2
2
3
2
Language: C++

#include <iostream>
#include <map>

using u64 = unsigned long long;

const u64 B = 13131;
const int N = 500000 + 7;

int n;
char s[N];
u64 f[N];
int g[N];
std::map<u64, u64> map;
u64 cnt;

u64 pow(u64 a, u64 k) {
    if (k < 0) k += (1llu << 63) - 1;
    u64 t = 1;
    for (; k; a = a * a, k >>= 1)
        if (k & 1) t = t * a;
    return t;
}

int main() {
    scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; ++i)
        if (s[i] == '+' || s[i] == '-')
            f[i] = f[i - 1] + (s[i] == '+' ? 1 : -1) * pow(B, g[i] = g[i - 1]);
        else
            f[i] = f[i - 1], g[i] = g[i - 1] + (s[i] == '<' ? -1 : 1);
    for (int i = n; i; --i)
        ++map[f[i]], cnt += map[f[n] * pow(B, g[i - 1]) + f[i - 1]];
    printf("%lld\n", cnt);

    return 0;
}

Example test case(s):
input: 5
+>+<-

output: 3
Language: C++

#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
    ll tmp = 0;
    if (x < y) {
        tmp = x;
        x = y;
        y = tmp;
    }
    while (y > 0) {
        ll r = x % y;
        x = y;
        y = r;
    }
    return x;
}

ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll kaijo(ll k) {
    ll sum = 1;
    for (ll i = 1; i <= k; ++i) {
        sum *= i;
        sum %= 1000000000 + 7;
    }
    return sum;
}

ll lmax(ll s, ll t) {
    if (s > t) {
        return s;
    } else {
        return t;
    }
}

ll lmin(ll s, ll t) {
    if (s < t) {
        return s;
    } else {
        return t;
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    ll sum = 0;
    for (int b = 1; b <= n; b++) {
        int cnt = (n + 1) / b;
        int md = (n + 1) % b;
        sum += cnt * max((b - k), 0) + max((md - k), 0);
        if (k == 0) sum--;
    }
    cout << sum << endl;
    return 0;
}

Example test case(s):
input: 5 2

output: 7
Language: C++

#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)

#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;

typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;

const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;

const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1 << 18);
const ld PI = atan2l(0, -1);

void fast_io() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

void solve() {
    int n;
    cin >> n;
    vi nums(n);
    int last = 0;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    vi dp(n + 1, 0);
    dp[0] = 1;
    map<int, int> kek;
    map<int, int> prev;
    for (int i = 1; i <= n; i++) {
        dp[i] = dp[i - 1] + (prev[nums[i - 1]] != i - 1 ? kek[nums[i - 1]] : 0);
        dp[i] %= MOD;
        kek[nums[i - 1]] = dp[i];
        prev[nums[i - 1]] = i;
    }
    cout << dp[n] << endl;
}

signed main() {
    fast_io();
    srand(time(NULL));
    cout << fixed << setprecision(12);
    int q = 1;

    while (q--) solve();
}

Example test case(s):
input: 5
1
2
1
2
2

output: 3
Language: C++

#include <stdio.h>
int main(void) {
    int n, k, x, y, z;
    scanf("%d", &n);
    scanf("%d", &k);
    x = n / k;
    y = n % k;
    if (y != 0) {
        z = x + 1 - x;
    } else {
        z = x - x;
    }
    printf("%d\n", z);

    return 0;
}

Example test case(s):
input: 7 3

output: 1
Language: C++

#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define ll long long
#define For(i, x, y) for (ll i = x; i <= y; ++i)
#define FOr(i, x, y) for (ll i = x; i >= y; --i)
using namespace std;
inline ll read() {
    ll x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
inline void write(ll x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}
inline void writeln(ll x) {
    write(x);
    puts("");
}

const ll N = 200010;
ll a[N], q[N], n, tot;
int main() {
    n = read();
    For(i, 1, n) a[i] = read();
    sort(a + 1, a + n + 1);
    For(i, 1, n) if (a[i] == a[i + 1]) q[++tot] = a[i], i++;
    writeln(q[tot] * q[tot - 1]);
}

Example test case(s):
input: 6
3 1 2 4 2 1

output: 2
Language: C++

#include <stdio.h>
#include <string.h>
int main(void) {
    char s[1000];
    scanf("%s", s);
    int i, flag = 0;
    for (i = 0; i < strlen(s); i++) {
        if (i % 2 == 0) {
            switch (s[i]) {
                case 'R':
                    break;
                case 'U':
                    break;
                case 'D':
                    break;
                default:
                    flag = 1;
                    break;
            }
        } else {
            switch (s[i]) {
                case 'L':
                    break;
                case 'U':
                    break;
                case 'D':
                    break;
                default:
                    flag = 1;
                    break;
            }
        }
    }
    if (flag == 0) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Example test case(s):
input: RUDLUDR

output: Yes
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int main() {
    int n;
    cin >> n;
    while (n--) {
        int p, q;
        cin >> p >> q;
        int l = sqrt(p * p + q * q);
        bool isprime = 1;
        REP(i, l) REP(j, l) {
            int x = i * i + j * j;
            if (x <= 1 || x >= p * p + q * q) continue;
            if ((i * p + j * q) % x == 0 && (i * q - j * p) % x == 0)
                isprime = 0;
        }
        cout << (isprime ? "P" : "C") << endl;
    }

    return 0;
}

Example test case(s):
input: 8
10 0
0 2
-3 0
4 2
0 -13
-4 1
-2 -1
3 -1

output: C
C
P
C
C
P
P
C
Language: C++

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
using namespace std;
bool debug = false;

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i > k)
            sum += y;
        else
            sum += x;
    }
    cout << sum << endl;

    return 0;
}

Example test case(s):
input: 5
3
10000
9000

output: 48000
Language: C++

#include <iostream>
#include <vector>

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

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

    std::vector<long long> abs_a = a;

    for (int i = 0; i < n; i++) {
        if (abs_a[i] < 0) {
            abs_a[i] = -abs_a[i];
        }
    }

    long long ans = 0;
    long long min = abs_a[0];
    for (auto e : abs_a) {
        ans += e;
        if (min > e) {
            min = e;
        }
    }
    int num_negative = 0;
    for (auto e : a) {
        if (e < 0) {
            num_negative++;
        }
    }

    if (num_negative % 2) {
        ans -= min * 2;
    }

    std::cout << ans << std::endl;
}

Example test case(s):
input: 3
-10 5 -4

output: 19
Language: C++

#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9 + 7;

bool is_prime(ll x) {
    for (ll i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

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

    ll ans = 1;
    for (int i = 2; i <= N; i++) {
        if (is_prime((ll)i)) {
            int NN = N;
            int cnt = 0;
            while (NN) {
                cnt += NN / i;
                NN /= i;
            }
            ans *= cnt + 1;
            ans %= mod;
        }
    }

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

Example test case(s):
input: 3

output: 4
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for (int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
}

Example test case(s):
input: 5
1 1 2 2

output: 2
2
0
0
0
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        Y[i] = X[i];
    }

    sort(Y.begin(), Y.end());

    int y = Y[N / 2];
    for (int i = 0; i < N; i++) {
        if (X[i] < Y[N / 2]) {
            cout << Y[N / 2];
        } else {
            cout << Y[N / 2 - 1];
        }
        cout << endl;
    }
    return 0;
}

Example test case(s):
input: 4
2 4 4 3

output: 4
3
3
4
Language: C++

#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt++;
        int j = i + 1;
        for (; j < n; j++) {
            if (s[i] != s[j]) {
                break;
            }
        }
        i = j - 1;
    }
    cout << cnt << endl;
}

Example test case(s):
input: 10
aabbbbaaca

output: 5
Language: C++

#include <algorithm>
#include <cstring>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>

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

using namespace std;
typedef long long ll;

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

    rep(i, n) {
        string s;
        cin >> s;

        set<string> st;
        st.insert(s);

        REP(j, 1, s.size()) {
            stringstream ss;
            rep(k, j) { ss << s[k]; }
            string res = ss.str();

            stringstream ss2;
            REP(k, j, s.size()) { ss2 << s[k]; }

            string res2 = ss2.str();

            string t = res;
            reverse(res.begin(), res.end());
            string t2 = res2;
            reverse(res2.begin(), res2.end());

            st.insert(t + t2);
            st.insert(t2 + t);

            st.insert(t + res2);
            st.insert(res2 + t);

            st.insert(res + t2);
            st.insert(t2 + res);

            st.insert(res + res2);
            st.insert(res2 + res);
        }

        cout << st.size() << endl;
    }

    return 0;
}

Example test case(s):
input: 4
aa
abba
abcd
abcde

output: 1
6
12
18
Language: C++

#include <iostream>
using namespace std;

int main() {
    int A, B;
    int ans = 0;
    int out = 1;
    cin >> A >> B;

    while (out < B) {
        out--;
        out += A;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Example test case(s):
input: 4 10

output: 3
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a, b, c;

    cin >> a >> b >> c;

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

Example test case(s):
input: 4 3 2

output: YES
Language: C++

#include <algorithm>
#include <iostream>
using namespace std;

long long N, A[1 << 18];
long long dp[1 << 18][2][20];

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 20; j++) {
            dp[i][0][j] = -(1LL << 60);
            dp[i][1][j] = -(1LL << 60);
        }
    }
    dp[0][0][10] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 6; j <= 14; j++) {
            if (dp[i - 1][0][j] != (1LL << 60)) {
                dp[i][1][j + 1] = max(dp[i][1][j + 1], dp[i - 1][0][j] + A[i]);
                dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][0][j]);
            }
            if (dp[i - 1][1][j] != (1LL << 60)) {
                dp[i][0][j - 1] = max(dp[i][0][j - 1], dp[i - 1][1][j]);
            }
        }
    }

    long long V = 10LL + (N / 2) - (N - (N / 2));
    long long T1 = dp[N][0][V];
    long long T2 = dp[N][1][V];
    cout << max(T1, T2) << endl;
    return 0;
}

Example test case(s):
input: 6
1 2 3 4 5 6

output: 12
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <vector>

using namespace std;

const int maxn = 1e5 + 5;

struct Node {
    int x, y, id;
} node[maxn];

struct Edge {
    int u, v, val;
    bool operator<(const Edge &rhs) const { return val < rhs.val; }
} e[maxn << 1];

int par[maxn];
int n;

bool cmp1(const Node &a, const Node &b) { return a.x < b.x; }

bool cmp2(const Node &a, const Node &b) { return a.y < b.y; }

void init() {
    for (int i = 0; i <= n; i++) par[i] = i;
}

int findpar(int x) { return par[x] = (par[x] == x ? x : findpar(par[x])); }

void unite(int x, int y) {
    x = findpar(x), y = findpar(y);
    if (x == y) return;
    par[x] = y;
}

int main(int argc, char const *argv[]) {
    cin >> n;

    init();

    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &node[i].x, &node[i].y);
        node[i].id = i;
    }

    sort(node + 1, node + n + 1, cmp1);

    int cnt = 0;
    for (int i = 2; i <= n; i++)
        e[cnt++] =
            (Edge){node[i - 1].id, node[i].id, node[i].x - node[i - 1].x};

    sort(node + 1, node + n + 1, cmp2);
    for (int i = 2; i <= n; i++)
        e[cnt++] =
            (Edge){node[i - 1].id, node[i].id, node[i].y - node[i - 1].y};

    sort(e, e + cnt);

    long long ans = 0;
    for (int i = 0; i < cnt; i++) {
        int u = e[i].u, v = e[i].v, val = e[i].val;
        if (findpar(u) == findpar(v)) continue;
        unite(u, v);
        ans += val;
    }

    cout << ans << endl;

    return 0;
}

Example test case(s):
input: 3
1 5
3 9
7 8

output: 3
Language: C++

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
    ll N, X;
    cin >> N >> X;

    ll ans = 0;
    ll min = 1000000000;
    for (int i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        X -= tmp;
        ans++;
        if (tmp < min) min = tmp;
    }

    ans += X / min;

    cout << ans << endl;

    return 0;
}

Example test case(s):
input: 3 1000
120
100
140

output: 9
Language: C++

#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    string bstr = to_string(b);
    int num = a * pow(10, bstr.length()) + b;

    int i;
    for (i = 1; i <= 100100; i++) {
        if (i * i == num) break;
    }

    if (i > 100100)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Example test case(s):
input: 1 21

output: Yes
Language: C++

#include <math.h>

#include <iostream>
#include <string>
using namespace std;

int main(void) {
    int n, x;
    string s;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        x = i;
        s = std::to_string(x);
        if (x % 3 == 0 || x % 10 == 3) {
            cout << " " << i;
            continue;
        } else {
            int k = s.size();
            while (k > 0) {
                k = k - 1;
                int j = pow(10, k);
                if ((x / j) % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;

    return 0;
}

Example test case(s):
input: 30

output:  3 6 9 12 13 15 18 21 23 24 27 30
Language: C++

#include <iostream>
using namespace std;
int main() {
    int n, a[101], i;
    cin >> n;
    for (i = 0; i < n; i++) cin >> a[i];
    cout << a[n - 1];
    for (i = 1; i < n; i++) cout << " " << a[n - i - 1];
    cout << endl;
    return 0;
}

Example test case(s):
input: 5
1 2 3 4 5

output: 5 4 3 2 1