Problem:
旅人
問題
あなたは JOI 街道を旅する旅人である.JOI 街道は東西にまっすぐに延びた道路で,JOI 街道上には n 個の宿場町がある.宿場町には西から東の順に 1 から n までの番号が付けられている.JOI 街道上の最も西の宿場町が宿場町 1 であり,最も東の宿場町が宿場町 n である.
あなたは,宿場町 1 から出発して m 日間の旅に出ることになった.あなたの旅程は数列 a1 , a2 , . . . , am に従い,次のように決められている.ai は i 日目の移動方法を表す 0 ではない整数である.i 日目にあなたが出発する宿場町を宿場町 k とおくと,i 日目にあなたは宿場町 k から宿場町 k + ai までまっすぐに移動することを意味する.
宿場町の個数 n,旅の日数 m,宿場町間の距離の情報と,移動方法を表す数列a1 , a2 , . . . , am が与えられたとき,m 日間の旅におけるあなたの移動距離の合計を100000 = 10
5
で割った余りを求めるプログラムを作成せよ.
入出力の例に対応する図
入力
1 行目には整数 n, m が空白区切りで書かれている.n (2 ≤ n ≤ 100000 = 10
5
) はJOI 街道上の宿場町の個数を,m (1 ≤ m ≤ 100000 = 10
5
) は旅の日数を表す.
続く n − 1 行は JOI 街道上の宿場町間の距離を表す.i + 1 行目 (1 ≤ i ≤ n − 1) に
は宿場町 i と宿場町 i + 1 の距離を表す正整数 si (1 ≤ si ≤ 100) が書かれている.
続く m 行には m 日間の移動方法を表す数列が書かれている.i + n 行目 (1 ≤ i ≤ m)
には i 日目のあなたの移動方法を表す 0 ではない整数 ai が書かれている.
採点用データにおいて,宿場町 1 より西に移動することや,宿場町 n より東に移
動することはない.
採点用データのうち,配点の 50% 分については,n ≤ 100 かつ m ≤ 100 を満たす.
出力
出力 は, m 日間の旅におけるあなたの移動距離の合計を 100000 = 10
5
で割った余りを含む 1 行からなる.
入出力例
入力例 1
7 5
2
1
1
3
2
1
2
-1
3
2
-3
出力例 1
18
1 日目に,あなたは宿場町 1 から宿場町 3 まで移動する.2 日目に,あなたは宿場
町 3 から宿場町 2 まで移動する.そして,3 日目に宿場町 2 から宿場町 5 まで移動
し,4 日目に宿場町 5 から宿場町 7 まで移動し,5 日目に宿場町 7 から宿場町 4 ま
で移動する.5 日間の旅におけるあなたの移動距離の合計は 18 である.
上記問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include<utility>
#include<set>
#include<deque>
#include <unordered_map>
#include<string>
#include<cmath>

using namespace std;

const int MOD = 100000;
int main() {
	int m, n;
	cin >> m >> n;
	int s = 1;
	vector<int>A(m-1);
	vector<int>B(m+1,0);
	for (int i = 0; i < m-1; i++) {
		cin >> A[i];
	}
	int x;

	for (int i = 0; i < n; i++) {
		
		cin >> x;

		int y = s+x;
		int s2 = y;
		if (s>y) {
			swap(s, y);
		}
		B[s - 1] += 1;
		B[y-1] -= 1;
		s = s2;
	}
	
	
	for (int i = 1; i < m; i++) {
		B[i] = B[i] + B[i - 1];
	}
	
	
	int ans = 0;
	
	for (int i = 0; i < m - 1; i++) {
		ans += A[i] * B[i];
		ans %= 100000;
	}
	cout << ans<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3792
final_rank: 3

code_snippet: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n, m, a[200000], b[200000], c[200000], s;
int main() {
	cin >> n >> m; for (int i = 1; i <= n - 1; i++)cin >> a[i];
	for (int i = 1; i <= m; i++) cin >> b[i]; b[0] = 1;
	for (int i = 1; i <= m; i++)b[i] += b[i - 1];
	for (int i = 1; i <= m; i++) { int J1 = b[i], J2 = b[i - 1]; if (J1 > J2)swap(J1, J2); c[J1]++; c[J2]--; }
	for (int i = 1; i <= n; i++)c[i] += c[i - 1];
	for (int i = 1; i < n; i++) { s += a[i] * c[i]; s %= 100000; }
	cout << s << endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4624
final_rank: 12

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

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

    const int MOD = 100000;

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

    // s[i] = 宿場町 i と i+1 の距離 (1-indexed, i=1..n-1)
    vector<int> s(n);
    for(int i = 1; i < n; i++){
        cin >> s[i];
    }

    // d[i] = 宿場町 1 から i までの累積距離
    // d[1] = 0, d[i] = d[i-1] + s[i-1]
    vector<long long> d(n+1, 0);
    for(int i = 2; i <= n; i++){
        d[i] = d[i-1] + s[i-1];
    }

    long long answer = 0;
    int pos = 1;  // 現在の宿場町（1 からスタート）

    for(int day = 0; day < m; day++){
        int a;
        cin >> a;
        int nxt = pos + a;  // 移動先
        // 絶対距離
        long long dist = llabs(d[nxt] - d[pos]);
        answer = (answer + dist) % MOD;
        pos = nxt;
    }

    cout << answer << "\n";
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4240
final_rank: 10

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s(n-1);
    rep(i,n-1){
        cin >> s[i];
    }
    vector<int> a(m);
    rep(i,m){
        cin >> a[i];
    }

    vector<int> x(n);
    x[0]=0;
    rep(i,n-1){
        x[i+1]=x[i]+s[i];
    }
    int now=0;//0-based
    int res=0;
    rep(i,m){
        int next=now+a[i];
        res+=abs(x[now]-x[next]);
        now=next;
        res %= 100000;
    }
    cout << res << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4164
final_rank: 8

code_snippet: #line 1 "/opt/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'001'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
#define inf infty<ll>

using pi = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

#define rep1(a) for (ll _ = 0; _ < (ll)(a); ++_)
#define rep2(i, a) for (ll i = 0; i < (ll)(a); ++i)
#define rep3(i, a, b) for (ll i = a; i < (ll)(b); ++i)
#define rep4(i, a, b, c) for (ll i = a; i < (ll)(b); i += (c))
#define rrep1(a) for (ll i = (a)-1; i >= (ll)(0); --i)
#define rrep2(i, a) for (ll i = (a)-1; i >= (ll)(0); --i)
#define rrep3(i, a, b) for (ll i = (b)-1; i >= (ll)(a); --i)
#define rrep4(i, a, b, c) for (ll i = (b)-1; i >= (ll)(a); i -= (c))
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()
#define len(x) (ll)(x.size())
#define elif else if
#define bit(x, i) (((x)>>(i))&1)

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll
#define abs llabs

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

ll popcnt(ll x) { return __builtin_popcountll(x); }
ll popcnt(u64 x) { return __builtin_popcountll(x); }
ll popcnt_mod_2(ll x) { return __builtin_parityll(x); }
ll popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
ll topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
ll topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
ll lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
ll lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template<typename T> T SUM(const vector<T> &A) {
  T s = 0; for (auto &&a: A) s += a;
  return s;
}

template <typename T>
T POP(queue<T> &que) {
  T a = que.front();
  que.pop();
  return a;
}
template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, ll iter = 100) {
  rep(iter) {
    double x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return (ok + ng) / 2;
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  rep(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vc<T> cumsum(vc<U> &A, ll off = 1) {
  ll N = A.size();
  vc<T> B(N + 1);
  rep(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vi argsort(const vector<T> &A) {
  vi ids(len(A));
  iota(all(ids), 0);
  sort(all(ids),
       [&](ll i, ll j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vi &I) {
  vc<T> B(len(I));
  rep(i, len(I)) B[i] = A[I[i]];
  return B;
}

template<typename T> inline bool chmax(T &a, T b) {return ((a<b)?(a=b,true):(false));}
template<typename T> inline bool chmin(T &a, T b) {return ((a>b)?(a=b,true):(false));}

inline void wt(const char c) { cout << c; }
inline void wt(const string s) { cout << s; }
inline void wt(const char *s) { cout << s; }

template <typename T>
void wt_integer(T x) {
  if (x < 0) { cout << (i64)(x); }
  else { cout << (u64)(x); }
}
template <typename T>
void wt_real(T x) {
  cout << fixed << setprecision(15) << (long double)(x);
}

inline void wt(int x) { wt_integer(x); }
inline void wt(ll x) { wt_integer(x); }
inline void wt(i128 x) { wt_integer(x); }
inline void wt(u32 x) { wt_integer(x); }
inline void wt(u64 x) { wt_integer(x); }
inline void wt(u128 x) { wt_integer(x); }
inline void wt(double x) { wt_real(x); }
inline void wt(long double x) { wt_real(x); }
inline void wt(f128 x) { wt_real(x); }

template <class T, class U>
void wt(const pair<T, U> val) {
  wt(val.first); wt(' '); wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
  if constexpr (N < std::tuple_size<T>::value) {
    if constexpr (N > 0) { wt(' '); }
    const auto x = std::get<N>(t);
    wt(x);
    wt_tuple<N + 1>(t);
  }
}
template <class... T>
void wt(tuple<T...> tpl) {
  wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}
template <class T>
void wt(const vector<T> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}

void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  wt(head);
  if (sizeof...(Tail)) wt(' ');
  print(forward<Tail>(tail)...);
}

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
void onez(bool t = 1) { print(t ? 1 : 0); }
#define endl '\n'
#define dump(x) {cerr << #x " = " << x << '\n';}
#line 2 "/opt/library/mod/modint_common.hpp"

struct has_mod_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};

template <typename mint>
mint inv(ll n) {
  static const ll mod = mint::get_mod();
  static vector<mint> dat = {0, 1};
  assert(0 <= n);
  if (n >= mod) n %= mod;
  while (len(dat) <= n) {
    ll k = len(dat);
    ll q = (mod + k - 1) / k;
    dat.eb(dat[k * q - mod] * mint::raw(q));
  }
  return dat[n];
}

template <typename mint>
mint fact(ll n) {
  static const ll mod = mint::get_mod();
  assert(0 <= n && n < mod);
  static vector<mint> dat = {1, 1};
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint::raw(len(dat)));
  return dat[n];
}

template <typename mint>
mint fact_inv(ll n) {
  static vector<mint> dat = {1, 1};
  if (n < 0) return mint(0);
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
  return dat[n];
}

template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
  return (mint(1) * ... * fact_inv<mint>(xs));
}

template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
  return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}

template <typename mint>
mint C_dense(ll n, ll k) {
  static vvc<mint> C;
  static ll H = 0, W = 0;
  auto calc = [&](ll i, ll j) -> mint {
    if (i == 0) return (j == 0 ? mint(1) : mint(0));
    return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
  };
  if (W <= k) {
    rep(i, H) {
      C[i].resize(k + 1);
      rep(j, W, k + 1) { C[i][j] = calc(i, j); }
    }
    W = k + 1;
  }
  if (H <= n) {
    C.resize(n + 1);
    rep(i, H, n + 1) {
      C[i].resize(W);
      rep(j, W) { C[i][j] = calc(i, j); }
    }
    H = n + 1;
  }
  return C[n][k];
}

template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  if constexpr (dense) return C_dense<mint>(n, k);
  if constexpr (!large) return multinomial<mint>(n, k, n - k);
  k = min(k, n - k);
  mint x(1);
  rep(i, k) x *= mint(n - i);
  return x * fact_inv<mint>(k);
}

template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
  assert(n >= 0);
  assert(0 <= k && k <= n);
  if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
  return mint(1) / C<mint, 1>(n, k);
}

// [x^d](1-x)^{-n}
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
  assert(n >= 0);
  if (d < 0) return mint(0);
  if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
  return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "/opt/library/mod/modint.hpp"

template <ll mod>
struct modint {
  static constexpr u32 umod = u32(mod);
  static_assert(umod < u32(1) << 31);
  u32 val;

  static modint raw(u32 v) {
    modint x;
    x.val = v;
    return x;
  }
  constexpr modint() : val(0) {}
  constexpr modint(u32 x) : val(x % umod) {}
  constexpr modint(u64 x) : val(x % umod) {}
  constexpr modint(u128 x) : val(x % umod) {}
  constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x){};
  constexpr modint(ll x) : val((x %= mod) < 0 ? x + mod : x){};
  constexpr modint(i128 x) : val((x %= mod) < 0 ? x + mod : x){};
  bool operator<(const modint &other) const { return val < other.val; }
  modint &operator+=(const modint &p) {
    if ((val += p.val) >= umod) val -= umod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((val += umod - p.val) >= umod) val -= umod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    val = u64(val) * p.val % umod;
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint::raw(val ? mod - val : u32(0)); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  modint inverse() const {
    ll a = val, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(ll n) const {
    assert(n >= 0);
    modint ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  static constexpr ll get_mod() { return mod; }
  // (n, r), r は 1 の 2^n 乗根
  static constexpr pair<ll, ll> ntt_info() {
    if (mod == 120586241) return {20, 74066978};
    if (mod == 167772161) return {25, 17};
    if (mod == 469762049) return {26, 30};
    if (mod == 754974721) return {24, 362};
    if (mod == 880803841) return {23, 211};
    if (mod == 943718401) return {22, 663003469};
    if (mod == 998244353) return {23, 31};
    if (mod == 1045430273) return {20, 363};
    if (mod == 1051721729) return {20, 330};
    if (mod == 1053818881) return {20, 2789};
    return {-1, -1};
  }
  static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};

template <ll mod>
void wt(modint<mod> x) {
  wt(x.val);
}

using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 3 "main.cpp"
using mint = modint<100000>;

int solve();
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  while (!solve()) {break;}
  return 0;
}

int solve() {
  ll n, m;
  cin >> n >> m;
  vi s(n-1), a(m);
  rep(i, n-1) cin >> s[i];
  rep(i, m) cin >> a[i];
  auto b = cumsum<ll>(s);
  mint ans = 0;
  ll p = 0;
  rep(i, m) {
    ans += abs(b[p+a[i]] - b[p]);
    p += a[i];
  }
  print(ans);
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5408
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int ki=0,i,n,m,c=0;
	int s[100001],b[100001],sum[100001],wa=0,ta=0;
	cin>>n>>m;
	for(i=1;i<n;i++) cin>>s[i];	
	for(i=0;i<m;i++) cin>>b[i];
	sum[0]=0;
	for(i=1;i<n;i++){
		sum[i]=s[i]+sum[i-1];
	}
	for(i=0;i<m;i++){
		c+=b[i];
		ki=sum[c];
		if(i==0) wa=ki;
		else if(ki-ta<=0)wa+=ta-ki;
		else if(ta-ki<=0) wa+=ki-ta;
		ta=ki;
		
		
	}
	cout<<wa%100000<<endl;
	return 0;
}
accuracy: 0.5
time_ms: 30
memory_kb: 4236
final_rank: 20

code_snippet: #include <iostream>
#include <queue>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
using namespace std;
long long ans;
int n,m;
int S[100010],Psum[100010];
void make_prefix_sum(){
    rep(i, n-1){
        rep(j, i+1){
            Psum[i+1]+=S[j];
        }
    }
}
int main(){
    cin >> n >> m;
    rep(i, n-1){
        cin >> S[i];
    }
    make_prefix_sum();
    int cur=0;
    rep(i, m){
        int a,l;
        cin >> a;
        if(a>0) l=Psum[cur+a]-Psum[cur];
        else l=Psum[cur]-Psum[cur+a];
        ans+=l;
        cur=cur+a;
    }
    cout << ans%100000 << endl;
}
accuracy: 1
time_ms: 1600
memory_kb: 3868
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define all(v) v.begin(), v.end()
#define rep(i, begin, end) for(auto i = (begin); i < (end); i++)
#define rrep(i, end, begin) for(auto i = (end) - 1; i >= (begin); 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; }
template<class T> inline T roundup(T a, T b){ return (a + b - 1) / b; }
constexpr int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int dx[] = {1, 0, -1, 0, 1, -1, 1, -1, 0};
using ll = long long;
constexpr ll INF = 1e9;
struct Edge{ int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} };
using Graph = vector<vector<int>>;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    const int MOD = 100000;
    
    int n, m;
    cin >> n >> m;
    vector s(n - 1, 0);
    for(auto&& e : s) cin >> e;
    
    vector sum(n, 0);
    sum[0] = s[0];
    rep(i, 1, n) sum[i] = sum[i - 1] + s[i - 1];
    int ans = 0;
    int pos = 0;
    while(m--){
        int a;
        cin >> a;
        
        int l = pos, r = pos + a;
        if(l > r) swap(l, r);
        ans += sum[r] - sum[l];
        ans %= MOD;
        
        pos += a;
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3876
final_rank: 6

code_snippet: #include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
void Yes(){printf("Yes\n");}
void No(){printf("No\n");}

int main(void)
{
	const ll MOD = 100000;

	ll n, m; cin >> n >> m;
	vector<ll> a(n-1);
	rep(i, n-1) cin >> a[i];
	vector<ll> s(n);
	s[0] = 0;
	rep(i, n-1)
	{
		s[i+1] = s[i] + a[i];
	}

	ll now = 0;
	ll ans = 0;
	rep(i, m)
	{
		ll v; cin >> v;
		if (v >= 0)
		{
			ans += (s[now+v] % MOD - s[now] % MOD) % MOD;
		}
		else
		{
			ans += (s[now] % MOD - s[now+v] % MOD) % MOD;
		}
		now += v;
	}
	ans %= MOD;
	cout << ans << endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4668
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)


int main() {
	ll N,K;
	cin>>N>>K;
	vll A(N+1,0);
	rep(i,N-1){
		ll B;
		cin>>B;
		A[i+1]=A[i]+B;

	}
	ll an=0;
	ll n=0;
	ll mod=100000;
	rep(k,K){
		ll S;
		cin>>S;
		if(S>0){
			an+=A[n+S]-A[n];
			n+=S;
		}
		else{
			an+=A[n]-A[n+S];
			n+=S;
		}
		an%=mod;
		//cout<<an<<endl;
	}
	cout<<an<<endl;

}
accuracy: 1
time_ms: 20
memory_kb: 3860
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main(){
    int n,m; cin >> n >> m;
    vector<long long> S(n-1); rep(i,n-1) cin >> S[i];
    vector<long long> A(m); rep(i,m) cin >> A[i];

    vector<long long> accumS(n,0); rep(i,n-1) accumS[i+1] = accumS[i] + S[i];

    long long ans = 0;
    int cur = 0;
    rep(i,m){
        int next = cur + A[i];
        ans += abs(accumS[next] - accumS[cur]);
        ans %= 100000;
        cur = next;
    }

    cout << ans << endl;

}
accuracy: 1
time_ms: 30
memory_kb: 5164
final_rank: 15

code_snippet: #include <stdio.h>
#include <string.h>
#include <stdlib.h>

int g_pos[100001];



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

	for (int i = 2; i <=n; i++)
	{
		scanf("%d", &val);
		g_pos[i] = val + g_pos[i - 1];
	}

	int sum = 0, tmp = 0;
	int npos = 1, mk = 0;
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &mk);
		if (mk >= 0)
			npos += mk;
		else
		{
			tmp = (g_pos[npos] - g_pos[npos + mk]) * 2;
			sum = (sum + tmp) % 100000;
			npos += mk;
		}
	}

	sum = (sum + g_pos[npos]) % 100000;
	printf("%d\n", sum);
	return 0;

}
accuracy: 1
time_ms: 10
memory_kb: 3140
final_rank: 1

code_snippet: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
static const ll MOD=100000;

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

  int distance[n];
  distance[0]=0;
  for(int i=1; i<n; i++) {
    cin >> distance[i];
  }
  ll ruiseki[n];
  ruiseki[0]=0;
  for(int i=1; i<n; i++) {
    ruiseki[i]=ruiseki[i-1]+distance[i];
  }
  
  int process[m];
  for(int i=0; i<m; i++) {
    cin >> process[i];
  }

  int before_index=0;
  int after_index;
  ll ans=0;

  for(int i=0; i<m; i++) {
    after_index=before_index+process[i];
    ans=ans+(abs(ruiseki[after_index]-ruiseki[before_index]));
    before_index=after_index;
  }
  cout << ans%MOD << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 4656
final_rank: 14

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

int main(){
  int n,m; cin >> n >> m;
  vector<int>s(n);
  vector<int>move(m);
  for(int i = 0; i < n-1; ++i){
    cin >> s[i];
  }
  for(int i = 0; i < m; ++i){
    cin >> move[i];
  }
  vector<int>cumsum(n,0);
  for(int i = 0; i < n-1; ++i){
    cumsum[i+1] = cumsum[i] + s[i];
  }

  ll sum = 0;
  int moBe = 0;
  int moAf = 0;
  for(int i = 0; i < m; ++i){
    moBe += move[i];
    sum += abs(cumsum[moBe] -cumsum[moAf]) % 100000;
    moAf += move[i];
    
  }
  cout << sum % 100000 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4320
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<long long, long long> P;
const long long INF = 1e18;
const ll MOD = INF;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
int main() {
	ll N, M; cin >> N >> M;
	vector<ll>A(N, 0);
	for (ll i = 1; i < N; i++) {
		ll x; cin >> x;
		A[i] = A[i - 1] + x;
	}
	ll ans = 0, pos = 0;
	for (ll i = 0; i < M; i++) {
		ll x; cin >> x;
		if (x > 0) ans += A[pos + x] - A[pos];
		if (x < 0) ans += A[pos] - A[pos + x];
      	pos += x;
		ans %= 100000;
	}
	cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3860
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rep2(i, l, n) for(int i = int(l); i < int(n); i++)

int main(){
    int n, m;
    cin >> n >> m;
    lint dist[n];
    dist[0] = 0;
    rep(i, n - 1){
        int s;
        cin >> s;
        dist[i + 1] = dist[i] + s;
    }
    
    int at = 0;
    lint ans = 0;
    rep(i, m){
        int a;
        cin >> a;
        ans += abs(dist[at] - dist[at + a]);
        at += a;
    }
    
    cout << ans % int(1e5) << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4132
final_rank: 7

code_snippet: #define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<sstream>
#include<regex>
#include<random>
using namespace std;
#define int long long
#define uint unsigned long long
const int mod=1e9+7;
const int Mod=998244353;
const int inf=mod*mod;
const double eps=1e-9;
signed main(){
	int n,m,s[100000],a,tmp=0,ans=0;
	cin>>n>>m;
	s[0]=0;
	for(int i=1;i<n;i++){
		cin>>s[i];
		s[i]+=s[i-1];
	}
	while(cin>>a){
		ans+=abs(s[tmp]-s[tmp+a]);
		tmp+=a;
	}
	cout<<ans%100000<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4220
final_rank: 9

code_snippet: #include<iostream>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int* d = new int[n + 1];
	d[1] = 0;
	for (int i = 2; i <= n; i++)
	{
		cin >> d[i];
		d[i] += d[i - 1];
	}
	int a;
	int ans = 0, cr = 1;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		if (a > 0)
			ans += d[cr + a] - d[cr];
		else
			ans += d[cr] - d[cr + a];
		ans %= 100000;
		cr += a;
	}
	cout << ans << endl;

	//system("pause");
}
accuracy: 1
time_ms: 30
memory_kb: 3496
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < N; i++)

int main()
{
  ll n, m; cin >> n >> m;
  ll dist[n-1];
  ll dist2[n];
  dist2[0] = 0;
  rep(i,n-1) cin >> dist[i];
  ll mm[m];
  rep(i,m) cin >> mm[i];
  for(int i=0;i<n-1;i++){
    dist2[i+1] = dist2[i] + dist[i];
  }
//  rep(i,n) cout << dist2[i] << " | ";
  int mod = 1e5;
  ll ans = 0;
  int loc = 0;
  rep(i,m){
  //  cout << " ans " << ans  << " loc " << loc << " i " << i <<  " mmi " << mm[i] << endl;
    if(i == 0){
      ans = (ans + dist2[loc + mm[i]])%mod;
      loc = mm[i];
    }
    else{
      if(mm[i] <0){
        ans = (ans + dist2[loc] - dist2[loc + mm[i]] ) % mod;
      }
      else {
        ans = (ans + dist2[loc + mm[i]] - dist2[loc] ) % mod;        
      }
      loc += mm[i];
    }
  }
  cout << ans << endl;

}
accuracy: 1
time_ms: 30
memory_kb: 5412
final_rank: 17

code_snippet: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n,m);
    vector<ll> a(n-1),b(m),sumv(1,0);
    in(a,b);
    rep(i,a.size()){
        sumv.push_back(sumv[i]+a[i]);
    }
    ll pre=0,ans=0;
    rep(i,m){
        assert(pre+b[i]>=0&&pre+b[i]<sumv.size());
        assert(pre>=0&&pre<sumv.size());
        if(sumv[pre+b[i]]>sumv[pre])ans+=sumv[pre+b[i]]-sumv[pre];
        else ans+=sumv[pre]-sumv[pre+b[i]];
        pre=pre+b[i];
    }
    out(ans%100000);
}
accuracy: 1
time_ms: 10
memory_kb: 5480
final_rank: 18