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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll l,a,b,MOD;

typedef vector<long long> vec;
typedef vector<vec> mat;

mat make_mat(int n, int m) {
  return mat(n, vec(m));
}

mat mat_mul(const mat &a, const mat &b) {
  mat r = mat(a.size(), vec(b[0].size()));
  for (int i = 0; i < (int)a.size(); i++) {
    for (int k = 0; k < (int)a[i].size(); k++) {
      for (int j = 0; j < (int)b[k].size(); j++)
        r[i][j] = (r[i][j] + a[i][k] * b[k][j] % MOD) % MOD;
    }
  }
  return r;
}

mat mat_pow(mat a, long long b) {
  mat r = mat(a.size(), vec(a[0].size()));
  for (int i = 0; i < (int)a.size(); i++)
    r[i][i] = 1;
  while (b > 0) {
    if (b&1) r = mat_mul(r,a);
    a = mat_mul(a,a);
    b >>= 1;
  }
  return r;
}

ll d9(int d) {
  ll res = 0;
  forn(i,d) res = 10LL*res + 9;
  return res;
}

ll c(int d) {
  ll mx = d9(d);
  ll l = 0, r = (mx-a)/b+2;
  while (r - l > 1) {
    ll mid = l + (r - l) / 2;
    if (a+b*mid <= mx)
      l = mid;
    else
      r = mid;
  }
  return l+1;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> l >> a >> b >> MOD;

  ll prev = 0;
  int d = 1;
  ll ten = 10;
  mat res = mat{{0,a%MOD,1}};
  while (l > 0) {
    ll cur = c(d);
    mat A = mat{{ten,0,0},{1,1,0},{0,b%MOD,1}};
    ll k = min(l,cur - prev);

    mat B = mat_pow(A, k);

    res = mat_mul(res, B);

    l -= k;
    prev = cur;
    d++;
    ten = (ten * 10) % MOD;
  }

  cout << res[0][0] << endl;

  return 0;
}


Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 097
  D - Equals
*/

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

class DisjointSet {
public:
  DisjointSet(int size): size(size) {
    id.resize(size, -1);
  }

  void unite(int x, int y) {
    x = getId(x);
    y = getId(y);

    if (x != y) {
      if (id[x] > id[y]) swap(x,y);
      id[x] += id[y];
      id[y] = x;
      --size;
    }
  }

  int getId(int x) {
    return id[x] < 0 ? x : id[x] = getId(id[x]);
  }

  void show() {
    printf("\n");
    for (int i = 0; i < id.size(); ++i) printf("%d ", id[i]);
    printf("\n");
  }

private:
  vector<int> id;
  int size;
};

int N, M;
int p[100000];

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }

  DisjointSet ds(N);
  int x, y;
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", &x, &y);
    --x, --y;
    ds.unite(x,y);
    //ds.show();
  }

  int count = 0;
  for (int i = 0; i < N; ++i) if (ds.getId(i) == ds.getId(p[i])) ++count;

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (  0 <= (x - r) && (x+r) <= W &&  0 <= (y-r)&& (y+r) <= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

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

    int s;
    cin >> s;
    set<int> st;

    int i = 1;
    while (i++) {
        st.insert(s);
        s = s % 2 ? 3 * s + 1 : s / 2;
        if (st.find(s) != st.end()) break;
    }
    print(i);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it) {
        if(it != v.begin())
            os << ",";
        os << *it;
    }
    return os << "}";
}

using ll = int64_t;

void dfs(int g, int k, const vector<vector<int>>& edge, vector<int>& group){
    if(group[k] >= 0)
        return;
    group[k] = g;
    for(int i: edge[k]){
        dfs(g, i, edge, group);
    }
}

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

    int n, m;
    cin >> n >> m;

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

    vector<vector<int>> edge(n);
    for (int i = 0; i < m; i++){
        int f, t;
        cin >> f >> t;
        f--;
        t--;
        edge[f].push_back(t);
        edge[t].push_back(f);
    }

    vector<int> group(n, -1);
    int g = 0;
    for (int i = 0; i < n; i++) {
        if(group[i] == -1){
            dfs(g, i, edge, group);
            g++;
        }
    }

    int ret = 0;
    for (int i = 0; i < n; i++) {
        int k = p[i];
        if(group[k] == group[i])
            ret++;
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
long long n, k, ans;
void solve() {
    cin >> n >> k;
    vector<long long> mod_arr(k, 0);
    for (int i = 1; i <= n; ++i) {
        mod_arr[i % k]++;
    }
    for (int a = 0; a < k; ++a) {
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k != 0) {
            continue;
        }
        ans += (mod_arr[a] * mod_arr[b] * mod_arr[c]);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,c; cin>>a>>b>>c;
  int k=in();
  if(a>=b&&a>=c) print(a*pow(2,k)+b+c);
  else if(b>=a&&b>=c) print(b*pow(2,k)+a+c);
  else print(a+b+c*pow(2,k));

  return 0;
}

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

int main(){
	int x, n, z;
	cin >> x >> n;
	vector<int> d(102);
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		d[p] = 1;
	}
	pair<int, int> ans(99999, -1);
	for(int i = 0; i <= 101; ++i){
		if(d[i] == 1) continue;
		int dif = abs(x - i);
		ans = min(ans, pair(dif, i));
	}
	cout << ans.second << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int A = N % 10;
    int B = (N - A) % 100;
    int C = N - B - A;
    if (A == 7 || B == 70 || C == 700){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, A; cin >> N >> A;
    cout << N*N - A << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
H=list(map(int,input().split()))
c=[]#0->good
for i in range(n):
    c.append(0)

for i in range(m):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        c[b-1]+=1
    elif H[a-1]<H[b-1]:
        c[a-1]+=1
    else:
        c[a-1]+=1
        c[b-1]+=1
s=0
for i in range(n):
    if c[i]==0:
        s+=1

print(s)

Measured memory_bytes: 84776
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [1]+a
flg = [0] * (n + 1)

now = 0
i = 1
flg2 = 1
loop = 0
while (i < k+1):
    if (flg2 and flg[a[now]] != 0):
        flg2 = 0
        loop = i-flg[a[now]]
        i += ((k - i) // loop - 1) * loop
    now = a[now]
    flg[now] = i
    i += 1
print(a[now])


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

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

  bool flg = false;
  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    int p;
    cin >> p;

    if(i==p){
      ans++;
      if(flg){
        ans--;
        flg = false;
      }
      else flg = true;
    }
    else{
      if(flg) flg = false;
    }
  }

  cout << ans << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int a[3][6];

    REP(i,3){
        REP(j,6)
            scanf("%d",&a[i][j]);
    }

    REP(i,3){
        int s = a[i][0] * 3600 + a[i][1] * 60 + a[i][2];
        int e = a[i][3] * 3600 + a[i][4] * 60 + a[i][5];
        e -= s;

        printf("%d %d %d\n",e / 3600,e % 3600 / 60,e % 60);
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
bool judge(int N) {
    for(int i = 2; i <= sqrt(N) + 1 && i != N; i++) {
        if(N % i == 0) {
            return false;
        }
    }
    return true;
}
int main() {
    int X;
    cin >> X;
    for(int i = X; ; i++) {
        if(judge(i)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

int main() {

    int A, B;
    cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string str;
  cin >> str;
  
  int ans=0;
  int temp=0;
  for(int i=0; i<N; i++){
    if(str[i]=='I'){
      temp++;
      ans=max(ans,temp);
    }
    if(str[i]=='D') temp--;
  }
  cout << ans <<endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;


ll gcd(ll m,ll n){
    if(n == 0)return m;
    else if(m>n){return gcd(n,m%n);
    }else{return gcd(m,n%m);}}

ll lcm(ll m,ll n){return m*n/gcd(m,n);}

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b,c;
    cin >>a>>b>>c;

    int lim = lcm(a,b);

    for (int i = a; i <= lim; i+=a){
        if(i%b==c){
            flag=true;
            break;
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "YES" <<endl;
    else cout << "NO" <<endl;
    
    return 0;
}


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

using namespace std;

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

	set<int>a;

	int x;

	for (int i = 0; i < n; i++) {
		cin >> x;
		a.insert(x);
		
	}
	if (a.size() == n) cout << "YES" << endl;
	else cout << "NO"<< endl;




	return 0;
}

Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1791791791;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) {
        cin >> i;
        i--;
    }
    int cur = 0;
    vector<int> cycle;
    vector<bool> used(n);
    used[0] = true;
    for (int i = 0; i < k; i++) {
        cur = a[cur];
        cycle.push_back(cur);
        if (used[cur]) break;
        used[cur] = true;
    }
    if (cycle.size() == k) cout << cur + 1 << endl;
    else {
        if (cur) {
            reverse(all(cycle));
            while (cycle.back() != cur) {
                cycle.pop_back();
                k--;
            }
         //   k--;
            reverse(all(cycle));
            cycle.pop_back();
        }
        cout << cycle[(k % cycle.size() + cycle.size() - 1) % cycle.size()] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5068
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

int main() {

    int N, tmp1, i=0;

    std::cin >> N ;

    int W[N], ans = 1000;

    while(std::cin >> tmp1){
        W[i] = tmp1;
        i++;
        if(i >= N){
            break;
        }
    }
    int s1, s2;

    for(int j = 0; j <= N-1 ; j++){
        s1 = 0;
        s2 = 0;
        for(int k = 0; k <= N-1; k++){
            if(k <= j)s1 += W[k];
            else s2 += W[k];
        }
        if(abs((s1-s2)) <= ans){
            ans = abs((s1-s2));
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll N ; cin >> N ;
    ll mi = 1000000000000001;
    rep(i, 5) {
        ll inp; cin >> inp;
        mi = min(mi, inp);
    }
    ll ans = 4 ;
    ans += (N / mi);
    if(N % mi != 0) ans ++;
    cout << ans << endl;



    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import copy

N = int(input())
T = list(map(int, input().split()))
M = int(input())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))

for i in range(M):
  TP = copy.copy(T)
  TP[l[i][0]-1] = l[i][1]
  print(sum(TP))

Measured memory_bytes: 3444
#include<stdio.h>
#define MAX 101
#define INFTY 1000000
#define WHITE 0//未訪問
#define GRAY 1//訪問(未確定)
#define BLACK 2//最小値決定済み
#define NIL -1

/*
gcolor[];//color[v]にvへの訪問状態を色で記録
gmatrix[][];//gmatrix[u][v]にuからvへの重みを記録した隣接行列
weight[];//weight[v]にTに属する頂点とV-Tに属する頂点を繋ぐ辺の中で、重みが最小の辺の重みを記録する
parent[];//parent[v]にMSTにおける頂点vの親を記録
*/

int gmatrix[MAX][MAX];

void dijkstra(int n){
  int i,v,u;//頂点u
  int minv; //// 最小の重みを記録する
  int weight[MAX]; // weight[v]に始点sからvまでの最短コストを保存する
  int parent[MAX];//MSTにおける頂点vの親を記録する
  // 訪問状態を記録
  int color[MAX];
  // 1.初期化
  for(int i = 0;i < n;++i){
    weight[i] = INFTY;
    color[i] = WHITE;
  }
  //初回探索地点をindex0にする
  weight[0] = 0;
  color[0] = GRAY;
  // printf("ok1\n");
  while(1){
    minv = INFTY;
    u = NIL;
    //隣接する地点で
    for(i=0; i<n ;++i){
      if(minv > weight[i] && color[i] != BLACK){
	//最小の重みを記録する
	u = i;
	minv = weight[i];
      }
    }
    // printf("ok2\n");
    //全て訪問した
    if(u == NIL) break;
    //訪問済み
    color[u] = BLACK;
    // printf("ok2.9\n");
    for(v=0; v<n ;++v){
      // printf("ok3\n");
      //uとvの間に辺が存在する
      if(color[v] != BLACK && gmatrix[u][v] != INFTY ){
	if(weight[v] > weight[u] + gmatrix[u][v]){
	  //隣接する辺に重みを割り当てる
	  weight[v] = weight[u] + gmatrix[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  
for(i=0;i<n;++i){
  printf("%d %d\n",i,weight[i]);
 }
}

int main(){
  int n,i,j,k,u,c,v;
  scanf("%d",&n);

  for(i=0;i<n;++i){
    for(j=0;j<n;++j){
      gmatrix[i][j] = INFTY;
    }
  }

  for(i=0;i<n;++i){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;++j){
      scanf("%d%d",&v,&c);
      gmatrix[u][v] = c;
    }
  }
  dijkstra(n);
  return 0;
}




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

const int INF = 0x7f7f;
int d[11][11];

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        
        for(int i=0;i<=11;i++)fill(d[i],d[i]+11,INF);        
        
        for (int i = 0; i < 11; i++) d[i][i] = 0;
        int x, y, z, v = 0;
        while (n--) {
            cin >> x >> y >> z;
            v = max(max(v, x), y);
            d[x][y] = z;
            d[y][x] = z;
        }

		for (int k = 0; k <= v; k++) {
            for (int i = 0; i <= v; i++) {
                for (int j = 0; j <= v; j++)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
        
		int sum = INF,number;
        for (int i = 0; i <= v; i++) {
            int t = 0;
            for (int j = 0; j <= v; j++) t += d[i][j];
            if(sum>t){
            	sum=t;
            	number=i;
			}
        }
        cout<<number<<" "<<sum<<"\n";
    }
}


Measured memory_bytes: 3032
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]


ans = []
for i in range(H):
    for j in range(W):
        if i == H-1 and j == W-1:
            continue
        elif a[i][j] % 2 == 0:
            continue
        if j == W-1:
            a[i+1][j] += 1
            ans.append([i+1, j+1, i+2, j+1])            
        else:
            a[i][j+1] += 1
            ans.append([i+1, j+1, i+1, j+2])

print(len(ans))
for i in ans:
    print(" ".join(map(str, i)))
    

Measured memory_bytes: 32324
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string A, B;
	cin >> A >> B;
	if (A[0] == B[2] && A[1] == B[1] && A[2] == B[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007

typedef long long int lli;

int x[MAX];
int acs(const void *a, const void *b) { 
  return x[*(int*)a] - x[*(int*)b];
} /* 1,2,3,4.. */

int main(void) {
  int n;
  scanf("%d", &n);
  rep(i, 0, n) scanf("%d", &x[i]);

  int idx[MAX];
  rep(i, 0 ,n) idx[i] = i;
  qsort(idx, n, sizeof(int), acs);

  int mid = n / 2 - 1;
  int ans[MAX];
  rep(i, 0, n) {
    if (i <= mid) ans[idx[i]] = x[idx[mid + 1]];
    else ans[idx[i]] = x[idx[mid]];
  }
  rep(i, 0, n) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 4472
def ken(l,x):
    c=str(x)
    if c in l:
        return l.index(c)
    else:
        return -1



n=int(input())
s=input()

#print(s[5:])
#print(ken(s[100:],2))

ans=0
gen=0
for i in range(10):
    ban1=ken(s,i)
    if(ban1==-1):
        continue
    #print(str(ban1)+"番目")
    gen=ban1
    #print(i,gen)
    for j in range(10):
        ban2=ken(s[ban1+1:],j)
        if(ban2==-1):
            continue
        #print(s[ban1+1:])

        #print(ban+gen+1,i,j)
        gen+=ban2+1
        #print(gen,i,j)
        for k in range(10):
            ban3=ken(s[ban1+ban2+2:],k)
            if(ban3==-1):
                continue
            #print(i,j,s[ban1+ban2+2:])
            ans+=1
            #ban3=ken(s[ban1+1:],k)
            #if(ban3==-1):
            #    continue
            #print(ban3+gen+1,i,j,k)
            #ans+=1

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

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

    int h, w, n, sx, sy;
    cin >> h >> w >> n >> sx >> sy;

    string s, t;
    cin >> s >> t;

    int l = 1, r = w;
    bool yoko = false;
    for (int i = n-1; i >= 0; i--) {
        if (i < n-1) {
            if (t[i] == 'L') if (r < w) r++;
            if (t[i] == 'R') if (l > 1) l--;
        }

        if (s[i] == 'L') l++;
        if (s[i] == 'R') r--;

        if (r < l) yoko = true; // 落ちる
    }
    if (sy < l || sy > r) yoko = true;


    l = 1, r = h;
    bool tate = false;
    for (int i = n-1; i >= 0; i--) {
        if (i < n-1) {
            if (t[i] == 'U') if (r < h) r++;
            if (t[i] == 'D') if (l > 1) l--;
        }

        if (s[i] == 'U') l++;
        if (s[i] == 'D') r--;

        if (r < l) tate = true; // 落ちる
    }
    if (sx < l || sx > r) tate = true;


    if (yoko || tate) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }

    return 0;
}

Measured memory_bytes: 1020
a,b,c,x,y =map(int,input().split())
cnt = 0
if a+b>=2*c:
    if x<=y:
        cnt += 2*c*x
        cnt += min(2*c,b)*(y-x)
    else:
        cnt += 2*c*y
        cnt += min(2*c,a)*(x-y)
else:
    if x<=y:
        cnt += (a+b)*x
        cnt += min(2*c,b)*(y-x)
    else:
        cnt += (a+b)*y
        cnt += min(2*c,a)*(x-y)
print(cnt)

Measured memory_bytes: 3064
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

\

N = int(input())
SS = [input() for _ in range(N)]
T = input()
before = 0
after = 0

for S in SS:
    sS = S.replace('?','a')
    lS = S.replace('?','z')
    if T < sS:
        after += 1
    elif lS < T:
        before += 1

print (' '.join(map(str,list(range(before+1,N-after+2)))))


Measured memory_bytes: 5600
# imos 法
N, K, Q = map(int, input().split())
cs = [0] * N
cs[0] = K
for _ in range(Q):
    A = int(input())
    if A == 1:
        cs[1] -= 1
    elif A == N:
        cs[0] -= 1
        cs[N - 1] += 1
    else:
        cs[0] -= 1
        cs[A - 1] += 1
        cs[A] -= 1
for i in range(1, N):
    cs[i] += cs[i - 1]
for i in cs:
    if i <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 7856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

struct UnionFind{
    vector<ll> arr;
    UnionFind(ll k):arr(k){
      rep(i,k){
        arr[i] = i;
      }
    }

    bool same(ll x,ll y){
      return root(x) == root(y);
    }

    void unite(ll x,ll y){
      ll rootx = root(x);
      ll rooty = root(y);
      if(rootx != rooty){
        arr[rootx] = arr[rooty];
      }
    }

    ll root(ll x){
      if(arr[x] == x){
        return x;
      }
      return arr[x] = root(arr[x]);
    }
};

int main(){
  ll n,q;
  cin >> n >> q;
  UnionFind uf(n);
  ll x,y;
  rep(i,q){
    cin >> t1;
    cin >> x >> y;
    if(t1 == 0){
      uf.unite(x,y);
    }else{
      if(uf.same(x,y)){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 3216
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;

	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

ans = 0
player_hand = [None]*(n+3)
for i,a in enumerate(t):
    if a == "r":
        if player_hand[i-k] == "r":
            player_hand[i] == "kyomu"
        else:
            ans += p 
            player_hand[i] = "r"
    if a == "s":
        if player_hand[i-k] == "s":
            player_hand[i] == "kyomu"
        else:
            ans += r 
            player_hand[i] = "s"
    if a == "p":
        if player_hand[i-k] == "p":
            player_hand[i] == "kyomu"
        else:
            ans += s
            player_hand[i] = "p"
print(ans)
    

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

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    ll ans = 0;
    repd(i, K + 1, N + 1) {
        ll a, b;
        a = N / i;
        b = N % i;
        ans += a * (i - K);
        ans += max(0LL, b - (K - 1));
    }

    if (K == 0) ans = N * N;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
vector<vector<ll>> g;
vector<ll> res;
vector<bool> vis;

ll findL(ll v){
      if(vis[v]){
          return res[v];
      }
      else{
          ll i;
          vis[v] = true; 
          
          res[v] = 0;
          for(i = 0;i < g[v].size();i++){
               if(!vis[g[v][i]]){
                   res[v] = max(res[v], 1 + findL(g[v][i]));
               }
               else{
                   res[v] = max(res[v], 1+res[g[v][i]]);
               }
          }
          return res[v];
      }
}

int main(){
   ll n, m, i, j;
    
    cin>>n>>m;

    ll a, b;
    
    g.clear();
    g.resize(n);
    res.clear();
    res.resize(n);
    vis.clear();
    vis.resize(n, false);

    for(i = 0 ;i < m;i++){
        cin>>a>>b;
        g[a-1].push_back(b-1);
    }
    ll maxRes = 0;
    for(i = 0;i < n;i++)
     if(!vis[i])
      ll res1 = findL(i);
    for(i = 0;i < res.size();i++)
       if(res[i] > maxRes)
        maxRes = res[i];

     cout<<maxRes;   

} 


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct segt
{
	int l,r,maxv;
}tree[2400010];
int a[300010],dp[300010];
void build(int le,int ri,int i)
{
	tree[i].l=le;
	tree[i].r=ri;
	tree[i].maxv=0;
	if(le==ri)
		return;
	int mid=(le+ri)>>1;
	build(le,mid,i<<1);
	build(mid+1,ri,i<<1|1);
}
void change(int p,int x,int i)
{
	if(tree[i].l==tree[i].r)
	{
		tree[i].maxv=max(tree[i].maxv,x);
		return;
	}
	if(tree[i<<1].r>=p)
		change(p,x,i<<1);
	else
		change(p,x,i<<1|1);
	tree[i].maxv=max(tree[i<<1].maxv,tree[i<<1|1].maxv);
}
int ask(int le,int ri,int i)
{
	if(le<=tree[i].l&&tree[i].r<=ri)
		return tree[i].maxv;
	int cnt=0;
	if(tree[i<<1].r>=le)
		cnt=ask(le,ri,i<<1);
	if(tree[i<<1|1].l<=ri)
		cnt=max(cnt,ask(le,ri,i<<1|1));
	return cnt;
}
signed main()
{
	int n,k,i,ans=0;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	build(1,300002,1);
	for(i=1;i<=n;i++)
	{
		dp[i]=ask(max(0ll,a[i]-k)+1,min(300000ll,a[i]+k)+1,1)+1;
		change(a[i]+1,dp[i],1);
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 32856
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int a[100000];

int f(int n){
    if(n % 2 == 0){
        return n/2;
    }
    return 3*n+1;
}


int main(){
    for(int &i : a) {
        i = 0;
    }
    int s;
    cin >> s;
    int b = s;
    a[s] = 1;
    for(int i = 1; i <= 1000000; i++){
        b = f(b);
//        cout << b << " " << a[b] << endl;
        if(a[b] != 0){
            cout << i+1 << endl;
            return 0;
        }
        a[b] = 1;
    }
    
    return 0;
}


Measured memory_bytes: 1272
import java.util.*;

class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int kihon = scan.nextInt();
        int zyougen = scan.nextInt();
        int tuika = scan.nextInt();
        int joi = scan.nextInt();
        int ryokin = x * joi;
        int hikaku = 0;

        if (zyougen >= joi) {
            if (ryokin > kihon) {
                ryokin = kihon;
                System.out.println(kihon);
            } else {
                System.out.println(ryokin);
            }
        } else {
            hikaku = kihon + (joi - zyougen) * tuika;
            if (hikaku > ryokin) {
                System.out.println(ryokin);
               
            }else
                System.out.println(hikaku);
        }
    }
}



Measured memory_bytes: 26256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

const int N=5005;
const ll inf=(ll)1e15;

struct node{
	ll h,p;
}a[N];
int n,ans;
ll dp[N][N];

bool cmp(node a,node b){
	return a.h+a.p<b.h+b.p;
}

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d%d",&a[i].h,&a[i].p);
	sort(a+1,a+1+n,cmp);
	for (i=0;i<=n;i++)
		for (j=0;j<=n;j++) dp[i][j]=inf;
	dp[0][0]=0;
	for (i=1;i<=n;i++)
		for (j=0;j<i;j++) if (dp[i-1][j]<inf){
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if (a[i].h>=dp[i-1][j]) dp[i][j+1]=min(dp[i][j+1],dp[i-1][j]+a[i].p);
		}
	for (i=1;i<=n;i++) if (dp[n][i]<inf) ans=i;
	printf("%d\n",ans);
	return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 998244353;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  operator ll() const { return v; }
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

void solve() {
  int n;
  cin >> n;
  vi d(n);
  rep(i, n) cin >> d[i];
  // sort(d.begin(), d.end());
  map<int, int> mp;
  rep(i, n) mp[d[i]]++;
  if (mp[0] != 1 || d[0] != 0) {
    cout << 0 << endl;
    return;
  }
  vector<mint> a(n);
  rep(i, n) {
    a[i] = mp[d[i] - 1];
  }
  dump(a);
  mint ans = 1;
  for (int i = 1; i < n; i++) ans *= a[i];
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector <int> a(N); //次どこにいくか
  
  for (int i=0; i<N; i++){
    cin >> a.at(i); //aの中身が入力された
  }
  
  vector <int> b(1); //光る行程
  b.at(0) = 1; //スタート地点
  
  for (int i=0; i<N; i++){
    b.push_back(a.at(b.at(i)-1));
    
    if (b.at(i+1)==2){
      cout << b.size()-1 << endl;
      break;
    }
    

  }
   if (b.size() == N+1){
      cout << -1 << endl;
   }


}


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

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

	int len = S.length() - 2;
	while (len > 2) {
		string s1 = S.substr(0, len / 2);
		string s2 = S.substr(len / 2, len / 2);
		if (s1 == s2)
			break;
		len -= 2;
	}

	cout << len << '\n';
	return 0;
}


Measured memory_bytes: 256
while 1:
    H,W=map(int,input().split())
    if W==0 and H==0:
        break
    elif W%2==1:
        if H%2==1:
            for char in range(H//2):
                print("#."*(W//2)+"#")
                print(".#"*(W//2)+".")
            print("#."*(W//2)+"#")
        else:
            for char in range(H//2):
                print("#."*(W//2)+"#")
                print(".#"*(W//2)+".")
    else:
        if H%2==1:
            for char in range(H//2):
                print("#."*(W//2))
                print(".#"*(W//2))
            print("#."*(W//2))
        else:
            for char in range(H//2):
                print("#."*(W//2))
                print(".#"*(W//2))
    print()


Measured memory_bytes: 5608
#include <stdio.h>

int main()
{
    int a, b, uncov_part;
    scanf("%d", &a);
    scanf("%d", &b);
    uncov_part = (a - (2 * b));
    if (uncov_part > 0)
    {
        printf("%d", uncov_part);
    }
    else if (uncov_part <= 0)
    {
        printf("%d", 0);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <numeric>

#define LL long long

using namespace std;



const LL INF = 1000000000;

LL N, D = 0, X = 0;
LL x[100010] = {};
LL diff[100010] = {};

LL GCD(LL a, LL b) {
	if (a < b) GCD(b, a);
	LL r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

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


	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		diff[i] = abs(X - x[i]);
	}
	if (N >= 2) {
		LL a = GCD(diff[0], diff[1]);
		if(N >= 3)
		for (int i = 2; i < N; i++) {
			a = GCD(a, diff[i]);
		}

		cout << a << endl;
	}
	else {
		cout << diff[0];
	}
}



Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import math

a, b = map(int, input().split())

x1 = math.ceil(a / 0.08)
y1 = math.floor((a+1) / 0.08)
if y1 == (a+1) / 0.08:
    y1 -= 1

x2 = math.ceil(b / 0.1)
y2 = math.floor((b+1) / 0.1)
if y2 == (b+1) / 0.1:
    y2 -= 1

if max(x1, x2) > min(y1, y2):
    print(-1)
elif x1 > y1 or x2 > y2:
    print(-1)
else:
    print(max(x1, x2))

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


int main(){
string S;
cin >>S;
int lo = S.size();
string ans = "AC";

if(S[0]!='A')ans = "WA";
    int count = 0;
for(int i = 1; i < lo; i++){
if(isupper(S[i])){
if(i==1 || i==lo-1 || S[i]!='C') ans = "WA";
count++;
}






}
if(count!=1)ans="WA";

cout<<ans<<endl;

}


Measured memory_bytes: 256
while True:
    try:
        Hflag,Bflag=0,0
        a = map(int,raw_input().split())
        b = map(int,raw_input().split())
        for i in range(4):
            if a[i] == b[i]:
                Hflag += 1
            else:
                continue
        for j in range(4):
            for k in range(4):
                if a[j] == b[k]:
                    Bflag += 1
                else:
                    continue
        Bflag = Bflag - Hflag
        print Hflag, Bflag
    except:
        break


Measured memory_bytes: 4648
import javax.swing.plaf.synth.SynthEditorPaneUI;
import java.io.*;
import java.util.*;

public class Main {
    static long[][]memo;
    static int[]a;
    static int mod = 998244353;
    static long dp(int idx,int sum){
        if (sum<0)
            return 0;
        if (idx==a.length)
            return sum==0?1:0;
        if (memo[idx][sum]!=-1)
            return memo[idx][sum];
        if (sum==0)
            return memo[idx][sum]=(2l*dp(idx+1,sum))%mod;
        long ans = 2*dp(idx+1,sum);
        ans%=mod;
        ans+=dp(idx+1,sum-a[idx]);
        return memo[idx][sum]=ans%mod;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int s = sc.nextInt();
        a= new int[n];
        memo = new long[n+1][s+1];
        for (long[]z:memo)Arrays.fill(z,-1);
        int[]pow= new int[n+1];
        pow[0]=1;
        for (int i =1;i<=n;i++){
           pow[i]=(2*pow[i-1])%mod;
        }
        for (int i =0;i<n;i++)a[i]=sc.nextInt();
        long ans=0;
        pw.println(dp(0,s));
        pw.flush();
    }
    static long gcd(long a,long b){
        if (a==0)
            return b;
        return gcd(b%a,a);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const ll INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll N,K;
    cin>>N>>K;
    vector<vector<ll>> C(2001,vector<ll>(2001,0));
    C[0][0]=1;
    rep(i,N+1){
        rep(j,i+1){
            if(i-1<0)continue;
            if(j-1<0)C[i][j]=1;
            else C[i][j]=(C[i-1][j]+C[i-1][j-1])%INF;
            //cout<<C[i][j]<<" ";
        }
        //cout<<endl;
    }

    REP(i,1,K+1){
        cout<<(C[N-K+1][i]*C[K-1][i-1])%INF<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 31616