prithivMLmods/Coder-Stat huggingface dataset:
Problem p03248 (C++)

Buggy submission (status: Runtime Error):
// LightOj Pass : qavajxyq

#include <bits/stdc++.h>
#define deb(x) cerr << (#x) << " : " << x << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll powmod(ll a, ll b, ll mod = MOD) {
  ll res = 1ll;
  b %= (mod - 1ll), a %= mod;
  while (b) {
    if (b % 2 == 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return res;
}
int cnt[100010];
bool comp(int a, int b) { return cnt[a] > cnt[b]; }

int main() {
#ifndef ONLINE_JUDGE
  freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
  freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
#endif

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

  string s;
  cin >> s;

  int n = s.length();
  if (s.back() == '1' or s[0] == '0') {
    cout << -1;
    return 0;
  }
  bool state = true;

  for (int l = 0, r = n - 2; r >= 0; r--, l++) {
    if (s[l] != s[r]) {
      state = false;
    }
  }

  if (!state) {
    cout << -1;
    return 0;
  }

  int cur = 2, ptr = 2;
  cout << 1 << " " << 2 << "\n";
  for (int i = 1; i < n - 1; i++) {
    cur++;
    cout << ptr << " " << cur << "\n";
    if ((s[i] - '0')) {
      ptr = cur;
    }
  }
}

Fixed submission:
// LightOj Pass : qavajxyq

#include <bits/stdc++.h>
#define deb(x) cerr << (#x) << " : " << x << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll powmod(ll a, ll b, ll mod = MOD) {
  ll res = 1ll;
  b %= (mod - 1ll), a %= mod;
  while (b) {
    if (b % 2 == 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return res;
}
int cnt[100010];
bool comp(int a, int b) { return cnt[a] > cnt[b]; }

int main() {

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

  string s;
  cin >> s;

  int n = s.length();
  if (s.back() == '1' or s[0] == '0') {
    cout << -1;
    return 0;
  }
  bool state = true;

  for (int l = 0, r = n - 2; r >= 0; r--, l++) {
    if (s[l] != s[r]) {
      state = false;
    }
  }

  if (!state) {
    cout << -1;
    return 0;
  }

  int cur = 2, ptr = 2;
  cout << 1 << " " << 2 << "\n";
  for (int i = 1; i < n - 1; i++) {
    cur++;
    cout << ptr << " " << cur << "\n";
    if ((s[i] - '0')) {
      ptr = cur;
    }
  }
}
Problem p03248 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l + r) / 2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#define T double
typedef complex<T> pt;
#define x real()
#define y imag()
T dot(pt v, pt w) { return (conj(v) * w).x; }
T cross(pt v, pt w) { return (conj(v) * w).y; }
T orient(pt a, pt b, pt c) { return cross(b - a, c - a); }
T dist(pt a, pt b) { return abs(a - b); }

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s = "0" + s;
  bool ok = true;
  vi one;
  for (int i = 0; i <= n; i++) {
    if (s[i] != s[n - i])
      ok = false;
    if (s[i] == '1')
      one.push_back(i);
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= one.size(); i++)
    cout << i << " " << i + 1 << endl;
  int cnt = one.size() + 2;
  for (int i = 1; i < one.size(); i++) {
    for (int j = 1; j < one[i] - one[i - 1]; j++)
      cout << i + 1 << " " << cnt++ << endl;
  }
  assert(cnt == n + 1);
}


Fixed submission:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l + r) / 2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#define T double
typedef complex<T> pt;
#define x real()
#define y imag()
T dot(pt v, pt w) { return (conj(v) * w).x; }
T cross(pt v, pt w) { return (conj(v) * w).y; }
T orient(pt a, pt b, pt c) { return cross(b - a, c - a); }
T dist(pt a, pt b) { return abs(a - b); }

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s = "0" + s;
  bool ok = true;
  vi one;
  for (int i = 0; i <= n; i++) {
    if (s[i] != s[n - i])
      ok = false;
    if (s[i] == '1')
      one.push_back(i);
  }
  if (!ok || s[1] == '0') {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= one.size(); i++)
    cout << i << " " << i + 1 << endl;
  int cnt = one.size() + 2;
  for (int i = 1; i < one.size(); i++) {
    for (int j = 1; j < one[i] - one[i - 1]; j++)
      cout << i + 1 << " " << cnt++ << endl;
  }
  assert(cnt == n + 1);
}
Problem p03249 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MN 100005
int T, num, dep[MN], n, id[MN], head[MN];
ll a[MN];
map<ll, int> rea, cnt;
struct node {
  int x, y;
};
vector<node> sc;
struct edge {
  int to, next;
} g[MN];
bool cmp(int x, int y) { return a[x] > a[y]; }
void ins(int u, int v) {
  g[++num].next = head[u];
  head[u] = num;
  g[num].to = v;
}
void dfs(int u, int ff) {
  for (int i = head[u]; i; i = g[i].next)
    if (g[i].to != ff) {
      dep[g[i].to] = dep[u] + 1, dfs(g[i].to, u);
    }
}
int main() {
  //	freopen("test.in","r",stdin);
  //	freopen("mysol.out","w",stdout);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), rea[a[i]] = i, cnt[a[i]] = 1, id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i < n; i++) {
    int t = id[i];
    ll tmp = a[t] - n + 2 * cnt[a[t]];
    if (rea[tmp] && tmp < a[t]) {
      cnt[tmp] += cnt[a[t]];
      sc.push_back((node){t, rea[tmp]});
    } else
      return 0 * puts("-1");
  }
  for (int i = 0; i < sc.size(); i++)
    ins(sc[i].x, sc[i].y), ins(sc[i].y, sc[i].x);
  dfs(id[n], id[n]);
  ll tans = 0;
  for (int i = 1; i <= n; i++)
    tans += dep[i];
  if (tans != a[id[n]])
    return 0 * puts("-1");
  for (int i = 0; i < sc.size(); i++)
    printf("%d %d\n", sc[i].x, sc[i].y);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MN 100005
int T, num, dep[MN], n, id[MN], head[MN];
ll a[MN];
map<ll, int> rea, cnt;
struct node {
  int x, y;
};
vector<node> sc;
struct edge {
  int to, next;
} g[MN << 1];
bool cmp(int x, int y) { return a[x] > a[y]; }
void ins(int u, int v) {
  g[++num].next = head[u];
  head[u] = num;
  g[num].to = v;
}
void dfs(int u, int ff) {
  for (int i = head[u]; i; i = g[i].next)
    if (g[i].to != ff) {
      dep[g[i].to] = dep[u] + 1, dfs(g[i].to, u);
    }
}
int main() {
  //	freopen("test.in","r",stdin);
  //	freopen("mysol.out","w",stdout);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]), rea[a[i]] = i, cnt[a[i]] = 1, id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i < n; i++) {
    int t = id[i];
    ll tmp = a[t] - n + 2 * cnt[a[t]];
    if (rea[tmp] && tmp < a[t]) {
      cnt[tmp] += cnt[a[t]];
      sc.push_back((node){t, rea[tmp]});
    } else
      return 0 * puts("-1");
  }
  for (int i = 0; i < sc.size(); i++)
    ins(sc[i].x, sc[i].y), ins(sc[i].y, sc[i].x);
  dfs(id[n], id[n]);
  ll tans = 0;
  for (int i = 1; i <= n; i++)
    tans += dep[i];
  if (tans != a[id[n]])
    return 0 * puts("-1");
  for (int i = 0; i < sc.size(); i++)
    printf("%d %d\n", sc[i].x, sc[i].y);
}
Problem p03249 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define ln '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (int i = 0; i < to; ++i)
#define cont(i, to) for (int i = 1; i <= to; ++i)
#define circ(i, fr, to) for (int i = fr; i <= to; ++i)
#define foreach(i, dat)                                                        \
  for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long num;

using namespace std;

const int nsz = 1e5;
int n, rt, siz[nsz + 5];
num w[nsz + 5];
map<num, int> id, to;
vector<int> g[nsz + 5];
vector<pair<int, int>> ans;

num inline cmp(num a, num b) { return a > b; }

num calc(int u = rt, int dep = 0) {
  num res = dep;
  for (int v : g[u]) {
    res += calc(v, dep + 1);
  }
  return res;
}

int main() {
  freopen("dat.in", "r", stdin);
  ios_base::sync_with_stdio(0);
  cin >> n;
  rt = n;
  cont(i, n) {
    cin >> w[i];
    to[w[i]] = i;
  }
  fill(siz, siz + sizeof(siz) / sizeof(int), 1);
  sort(w + 1, w + n + 1, cmp);
  cont(i, n) { id[w[i]] = i; }
  cout << ln;
  cont(u, n) {
    if (u == rt)
      continue;
    int v = id[w[u] - n + 2 * siz[u]];
    if (!v) {
      cout << -1 << ln;
      return 0;
    }
    siz[v] += siz[u];
    g[v].push_back(u);
    ans.push_back({to[w[u]], to[w[v]]});
  }
  if (calc() != w[n]) {
    cout << -1 << ln;
    return 0;
  }
  for (pair<int, int> p : ans) {
    cout << p.first << ' ' << p.second << ln;
  }
}


Fixed submission:
#include <bits/stdc++.h>

#define ln '\n'
#define all(dat) dat.begin(), dat.end()
#define loop(i, to) for (int i = 0; i < to; ++i)
#define cont(i, to) for (int i = 1; i <= to; ++i)
#define circ(i, fr, to) for (int i = fr; i <= to; ++i)
#define foreach(i, dat)                                                        \
  for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long num;

using namespace std;

const int nsz = 1e5;
int n, rt, siz[nsz + 5];
num w[nsz + 5];
map<num, int> id, to;
vector<int> g[nsz + 5];
vector<pair<int, int>> ans;

num inline cmp(num a, num b) { return a > b; }

num calc(int u = rt, int dep = 0) {
  num res = dep;
  for (int v : g[u]) {
    res += calc(v, dep + 1);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  rt = n;
  cont(i, n) {
    cin >> w[i];
    to[w[i]] = i;
  }
  fill(siz, siz + sizeof(siz) / sizeof(int), 1);
  sort(w + 1, w + n + 1, cmp);
  cont(i, n) { id[w[i]] = i; }
  cout << ln;
  cont(u, n) {
    if (u == rt)
      continue;
    int v = id[w[u] - n + 2 * siz[u]];
    if (!v) {
      cout << -1 << ln;
      return 0;
    }
    siz[v] += siz[u];
    g[v].push_back(u);
    ans.push_back({to[w[u]], to[w[v]]});
  }
  if (calc() != w[n]) {
    cout << -1 << ln;
    return 0;
  }
  for (pair<int, int> p : ans) {
    cout << p.first << ' ' << p.second << ln;
  }
}
Problem p03249 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>

using namespace std;

#define R register
#define ll long long
const int MAXN = 1e5 + 10;

int n;
ll D[MAXN];
int siz[MAXN];
map<ll, int> loc;
set<ll> st;

struct edge {
  int fr, to, next;
} e[MAXN];
int tot;
int head[MAXN];
int dep[MAXN];

inline void add(int x, int y) {
  tot++;
  e[tot].fr = x;
  e[tot].to = y;
  e[tot].next = head[x];
  head[x] = tot;
}

inline void dfs(int x, int fx) {
  dep[x] = dep[fx] + 1;
  for (R int i = head[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fx)
      continue;
    dfs(y, x);
  }
}

int main() {
  scanf("%d", &n);
  for (R int i = 1; i <= n; i++) {
    scanf("%lld", &D[i]);
    siz[i] = 1;
    loc[D[i]] = i;
    st.insert(D[i]);
  }
  int rt = 0, cnt = 0;
  while (st.size() && cnt < n - 1) {
    ll dx = *st.rbegin(), dy;
    int x, y;
    st.erase(dx);
    x = loc[dx];
    dy = dx + siz[x] * 2 - n;
    y = loc[dy];
    if (y == 0) {
      printf("-1\n");
      return 0;
    }
    siz[y] += siz[x];
    add(x, y);
    add(y, x);
    cnt++;
  }
  rt = loc[*st.begin()];
  dfs(rt, 0);
  ll ans = 0;
  for (R int i = 1; i <= n; i++)
    ans += dep[i];
  if (ans - n != D[rt]) {
    printf("-1\n");
    return 0;
  }

  for (R int i = 1; i <= tot; i += 2) {
    int x = e[i].fr, y = e[i].to;
    if (x > y)
      swap(x, y);
    printf("%d %d\n", x, y);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>

using namespace std;

#define R register
#define ll long long
const int MAXN = 1e5 + 10;

int n;
ll D[MAXN];
int siz[MAXN];
map<ll, int> loc;
set<ll> st;

struct edge {
  int fr, to, next;
} e[MAXN << 1];
int tot;
int head[MAXN];
int dep[MAXN];

inline void add(int x, int y) {
  tot++;
  e[tot].fr = x;
  e[tot].to = y;
  e[tot].next = head[x];
  head[x] = tot;
}

inline void dfs(int x, int fx) {
  dep[x] = dep[fx] + 1;
  for (R int i = head[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fx)
      continue;
    dfs(y, x);
  }
}

int main() {
  scanf("%d", &n);
  for (R int i = 1; i <= n; i++) {
    scanf("%lld", &D[i]);
    siz[i] = 1;
    loc[D[i]] = i;
    st.insert(D[i]);
  }
  int rt = 0, cnt = 0;
  while (st.size() && cnt < n - 1) {
    ll dx = *st.rbegin(), dy;
    int x, y;
    st.erase(dx);
    x = loc[dx];
    dy = dx + siz[x] * 2 - n;
    y = loc[dy];
    if (y == 0) {
      printf("-1\n");
      return 0;
    }
    siz[y] += siz[x];
    add(x, y);
    add(y, x);
    cnt++;
  }
  rt = loc[*st.begin()];
  dfs(rt, 0);
  ll ans = 0;
  for (R int i = 1; i <= n; i++)
    ans += dep[i];
  if (ans - n != D[rt]) {
    printf("-1\n");
    return 0;
  }

  for (R int i = 1; i <= tot; i += 2) {
    int x = e[i].fr, y = e[i].to;
    if (x > y)
      swap(x, y);
    printf("%d %d\n", x, y);
  }
  return 0;
}
Problem p03250 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + sum(a, b, c))


Fixed submission:
a, b, c = map(int, input().split())
print(max([a, b, c]) * 9 + sum([a, b, c]))
Problem p03250 (Python)

Buggy submission (status: Runtime Error):
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + sum(a, b, c))


Fixed submission:
a, b, c = map(int, input().split())
print(max(a, b, c) * 9 + a + b + c)
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> N(3);
  for (int i = 0; i < 3; i++)
    cin >> N.at(i);
  sort(N.begin(), N.end());
  int ans = N.at(0) + N.at(2) + N.at(3) * 10;
  cout << ans << endl;
}


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

int main() {
  vector<int> N(3);
  for (int i = 0; i < 3; i++)
    cin >> N.at(i);
  sort(N.begin(), N.end());
  int ans = N.at(0) + N.at(1) + N.at(2) * 10;
  cout << ans << endl;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> ans(3);
  for (int i = 0; i < 5; i++)
    cin >> ans.at(i);
  sort(ans.begin(), ans.end());
  cout << ans.at(0) + ans.at(1) + ans.at(2) * 10;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> ans(3);
  for (int i = 0; i < 3; i++)
    cin >> ans.at(i);
  sort(ans.begin(), ans.end());
  cout << ans.at(0) + ans.at(1) + ans.at(2) * 10;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  int a[3];
  scanf("%d %d %d", a[0], a[1], a[2]);
  sort(a, a + 3);
  cout << 10 * a[2] + a[1] + a[0] << endl;
  return 0;
}


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

int main() {
  int a[3];
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  sort(a, a + 3);
  cout << 10 * a[2] + a[1] + a[0] << endl;
  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;

int main() {

  vi v;

  REP(i, 3) { cin >> v[i]; }

  sort(ALL(v));

  cout << v[2] * 10 + v[1] + v[0] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;

int main() {

  vi v(3);

  REP(i, 3) { cin >> v[i]; }

  sort(ALL(v));

  cout << v[2] * 10 + v[1] + v[0] << endl;

  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> a;
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans;
  ans = a[0] + a[1] + a[2] * 10;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans;
  ans = a[0] + a[1] + a[2] * 10;
  cout << ans << endl;
  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
/* Author - Ankur Kumar Singh
        IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
/* variable type :- */
#define ll long long int
#define ld long double
#define I int
#define mod 1000000007
/* map */
#define abc pair<long long int, long long int>
map<pair<abc, abc>, long long int> pqr;
map<pair<long long int, long long int>, long long int> xyz;
/* vector */
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define mp make_pair
#define ac accumulate
vector<pair<ll, string>> a1;
vector<pair<ll, string>> a2;
vector<pair<ll, string>> a3;
vector<pair<ll, string>> a4;
vector<pair<ll, string>> a5;
vector<pair<ll, string>> a6;
vector<pair<ll, string>> a7;
vector<pair<pair<ll, ll>, ll>> b;
bool compare(const pair<long long int, long long int> &x,
             const pair<long long int, long long int> &y) {
  return x.ff > y.ff;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.ss < b.ss);
}
bool isPowerOfTwo(ll n) { return (ceil(log2(n)) == floor(log2(n))); }
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output2.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll arr[4];
  for (ll i = 0; i < 3; i++)
    cin >> arr[i];
  sort(arr, arr + 3);
  cout << arr[2] * 10 + arr[1] + arr[0];
}

Fixed submission:
/* Author - Ankur Kumar Singh
        IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
/* variable type :- */
#define ll long long int
#define ld long double
#define I int
#define mod 1000000007
/* map */
#define abc pair<long long int, long long int>
map<pair<abc, abc>, long long int> pqr;
map<pair<long long int, long long int>, long long int> xyz;
/* vector */
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define mp make_pair
#define ac accumulate
vector<pair<ll, string>> a1;
vector<pair<ll, string>> a2;
vector<pair<ll, string>> a3;
vector<pair<ll, string>> a4;
vector<pair<ll, string>> a5;
vector<pair<ll, string>> a6;
vector<pair<ll, string>> a7;
vector<pair<pair<ll, ll>, ll>> b;
bool compare(const pair<long long int, long long int> &x,
             const pair<long long int, long long int> &y) {
  return x.ff > y.ff;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.ss < b.ss);
}
bool isPowerOfTwo(ll n) { return (ceil(log2(n)) == floor(log2(n))); }
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll arr[4];
  for (ll i = 0; i < 3; i++)
    cin >> arr[i];
  sort(arr, arr + 3);
  cout << arr[2] * 10 + arr[1] + arr[0];
}
Problem p03250 (Python)

Buggy submission (status: Runtime Error):
input_data = [int(i) for i in input().split(" ")]

ans = 0
for k1, v1 in enumerate(input_data):
    for k2, v2 in enumerate(input_data):
        for k3, v3 in enumerate(input_data):
            if k1 == k2 or k2 == k3 or k3 == k1:
                continue
            kou1 = int(f"{v1}{v2}")
            if ans < kou1 + v3:
                ans = kou1 + v3
print(ans)


Fixed submission:
input_data = [int(i) for i in input().split(" ")]

ans = 0
for k1, v1 in enumerate(input_data):
    for k2, v2 in enumerate(input_data):
        for k3, v3 in enumerate(input_data):
            if k1 == k2 or k2 == k3 or k3 == k1:
                continue
            kou1 = int(str(v1) + str(v2))
            kou2 = v3
            if ans < kou1 + kou2:
                ans = kou1 + v3
print(ans)
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> x;
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(), x.end());
  cout << x[2] * 10 + x[1] + x[0] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(), x.end());
  cout << x[2] * 10 + x[1] + x[0] << endl;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> v;
  for (int i = 0; i < 3; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  cout << v[0] * 10 + v[1] + v[2] << endl;
  return 0;
}


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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());
  cout << v[0] * 10 + v[1] + v[2] << endl;
  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A + 3);
  cout << (A[0] + A[1] + A[2] * 10);
  return 0;
}


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

int main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A + 3);
  cout << (A[0] + A[1] + A[2] * 10);
  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair

// random generator
// mt19937 rndm(time(0));

ll gcd(ll a, ll b) {
  while (b > 0) {
    int tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

const int M = 1e9 + 7;
ll powmod(ll a, ll b, ll mod) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
} /* a^b%mod */
const int N = 1e5 + 10;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  a[2] *= 10;
  a[2] += a[1] + a[0];
  cout << a[2];

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair

// random generator
// mt19937 rndm(time(0));

ll gcd(ll a, ll b) {
  while (b > 0) {
    int tmp = a;
    a = b;
    b = tmp % b;
  }
  return a;
}

const int M = 1e9 + 7;
ll powmod(ll a, ll b, ll mod) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
} /* a^b%mod */
const int N = 1e5 + 10;

int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  a[2] *= 10;
  a[2] += a[1] + a[0];
  cout << a[2];

  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  std::vector<int> vec(3);
  std::cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

  std::sort(vec.begin(), vec.end());
  std::cout << vec.at(3) * 10 + vec.at(0) + vec.at(1) << std::endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  std::vector<int> vec(3);
  std::cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

  std::sort(vec.begin(), vec.end());
  std::cout << vec.at(2) * 10 + vec.at(0) + vec.at(1) << std::endl;

  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  vector<int> A;
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[0] + A[1] + A[2] * 10 << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[0] + A[1] + A[2] * 10 << endl;
  return 0;
}
Problem p03250 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;

int main() {

  int num[3];
  for (int i = 0; i < 3; i++) {
    cin >> num[i];
  }
  sort(num, num + 3, greater<int>());
  return (num[0] * 10 + num[1] + num[2]);
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;

int main() {

  int num[3];
  for (int i = 0; i < 3; i++) {
    cin >> num[i];
  }
  sort(num, num + 3, greater<int>());

  int ret = (num[0] * 10 + num[1] + num[2]);
  cout << ret << endl;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n, m, x, y;
  cin >> n >> m >> x >> y;
  vl a(n + 1), b(m + 1);
  rep(i, n) { cin >> a[i]; }
  a[n] = x;
  rep(i, m) { cin >> b[i]; }
  b[n] = y;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a[n] < b[0])
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n, m, x, y;
  cin >> n >> m >> x >> y;
  vl a(n + 1), b(m + 1);
  rep(i, n) { cin >> a[i]; }
  a[n] = x;
  rep(i, m) { cin >> b[i]; }
  b[m] = y;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a[n] < b[0])
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n + 1), b(n + 1);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  for (int i = 0; i < m; i++)
    cin >> b.at(i);
  a.at(n) = x;
  b.at(m) = y;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a.at(n) < b.at(0) || a.at(0) > b.at(m))
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n + 1), b(m + 1);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  for (int i = 0; i < m; i++)
    cin >> b.at(i);
  a.at(n) = x;
  b.at(m) = y;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a.at(n) < b.at(0) || a.at(0) > b.at(m))
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n), b(m);
  a[0] = x;
  b[0] = y;
  int t;
  rep(i, n) cin >> a[i + 1];
  rep(i, m) cin >> b[i + 1];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a[n] < b[0])
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}

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

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n + 1), b(m + 1);
  a[0] = x;
  b[0] = y;
  int t;
  rep(i, n) cin >> a[i + 1];
  rep(i, m) cin >> b[i + 1];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a[n] < b[0])
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  vector<int> a(n);
  vector<int> b(n);

  REP(i, n) cin >> a[i];

  REP(i, m) cin >> b[i];

  sort(ALL(a));
  sort(ALL(b));

  if (a[n - 1] < b[0]) {
    if (x < b[0] && b[0] <= y) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  vector<int> a(n);
  vector<int> b(m);

  REP(i, n) cin >> a[i];

  REP(i, m) cin >> b[i];

  sort(ALL(a));
  sort(ALL(b));

  if (a[n - 1] < b[0]) {
    if (x < b[0] && b[0] <= y) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;

  string res = "War";
  vector<int> x(n), y(m);
  cin >> x[0] >> y[0];
  for (int i = 1; i < n + 1; i++) {
    cin >> x[i];
  }
  for (int i = 1; i < m + 1; i++) {
    cin >> y[i];
  }

  int mx = *max_element(x.begin(), x.end());
  int my = *min_element(y.begin(), y.end());
  if (mx < my) {
    res = "No War";
  }
  cout << res << "\n";
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;

  string res = "War";
  vector<int> x(n + 1), y(m + 1);
  cin >> x[0] >> y[0];
  for (int i = 1; i < n + 1; i++) {
    cin >> x[i];
  }
  for (int i = 1; i < m + 1; i++) {
    cin >> y[i];
  }

  int mx = *max_element(x.begin(), x.end());
  int my = *min_element(y.begin(), y.end());
  if (mx < my) {
    res = "No War";
  }
  cout << res << "\n";
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
  }
  int maxx = -101, miny = 101;
  for (int i = 0; i < N; i++) {
    if (maxx < x.at(i)) {
      maxx = x.at(i); // xの最大値
    }
  }
  for (int i = 0; i < M; i++) {
    if (miny > y.at(i)) {
      miny = y.at(i); // ｙの最小値
    }
  }
  if (maxx < X) {
    maxx = X;
  }
  if (miny > Y) {
    miny = Y;
  }
  if (maxx < miny) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
  }
  int maxx = -101, miny = 101;
  for (int i = 0; i < N; i++) {
    if (maxx < x.at(i)) {
      maxx = x.at(i); // xの最大値
    }
  }
  for (int i = 0; i < M; i++) {
    if (miny > y.at(i)) {
      miny = y.at(i); // ｙの最小値
    }
  }
  if (maxx < X) {
    maxx = X;
  }
  if (miny > Y) {
    miny = Y;
  }
  if (maxx < miny) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
// #define MAX_N 100
bool is_war(vector<int> x, vector<int> y) {
  loop(Z, -100, 101) {
    bool is_ok = true;
    rep(i, x.size()) {
      if (x[i] >= Z) {
        is_ok = false;
      }
    }
    rep(i, y.size()) {
      if (y[i] < Z) {
        is_ok = false;
      }
    }
    if (is_ok)
      return false;
  }
  return true;
}
int main() {
  int X, Y, N, M;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];
  x[N] = X, y[M] = Y;
  if (is_war(x, y)) {
    cout << "War" << endl;
  } else {
    cout << "No War" << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
// #define MAX_N 100
bool is_war(vector<int> x, vector<int> y) {
  loop(Z, -100, 101) {
    bool is_ok = true;
    rep(i, x.size()) {
      if (x[i] >= Z) {
        is_ok = false;
      }
    }
    rep(i, y.size()) {
      if (y[i] < Z) {
        is_ok = false;
      }
    }
    if (is_ok)
      return false;
  }
  return true;
}
int main() {
  int X, Y, N, M;
  cin >> N >> M >> X >> Y;
  vector<int> x(N + 1), y(M + 1);
  rep(i, N) cin >> x[i];
  rep(i, M) cin >> y[i];
  x[N] = X, y[M] = Y;
  if (is_war(x, y)) {
    cout << "War" << endl;
  } else {
    cout << "No War" << endl;
  }
  return 0;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d, g;
  cin >> a >> b >> c >> d;
  vector<int> e(a);
  vector<int> f(b);
  for (int i = 0; i < a; i++)
    cin >> e.at(i);
  for (int i = 0; i < b; i++)
    cin >> f.at(i);
  sort(e.begin(), e.end());
  sort(f.begin(), f.end());
  /*if(e.at(a)<g && g<=f.at(1) && a<g && g<=b)
    cout << "No War";
  else
    cout << "War"*/
  for (int i = c + 1; i <= d; i++) {
    if (e.at(a) < i && i <= f.at(0)) {
      cout << "No War" << endl;
      break;
    } else if (i == d)
      cout << "War" << endl;
  }
}


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

int main() {
  int a, b, c, d, g;
  cin >> a >> b >> c >> d;
  vector<int> e(a);
  vector<int> f(b);
  for (int i = 0; i < a; i++)
    cin >> e.at(i);
  for (int i = 0; i < b; i++)
    cin >> f.at(i);
  sort(e.begin(), e.end());
  sort(f.begin(), f.end());
  /*if(e.at(a)<g && g<=f.at(1) && a<g && g<=b)
    cout << "No War";
  else
    cout << "War"*/
  for (int i = c + 1; i <= d; i++) {
    if (e.at(a - 1) < i && i <= f.at(0)) {
      cout << "No War" << endl;
      break;
    } else if (i == d)
      cout << "War" << endl;
  }
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> kuni_x(N);
  vector<int> kuni_y(N);
  for (int i = 0; i < N; i++) {
    cin >> kuni_x.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> kuni_y.at(i);
  }
  int max_x = kuni_x.at(0);
  for (int i = 1; i < N; i++) {
    max_x = max(max_x, kuni_x.at(i));
  }
  int min_y = kuni_y.at(0);
  for (int i = 1; i < M; i++) {
    min_y = min(min_y, kuni_y.at(i));
  }
  if (min_y <= max_x) {
    cout << "War" << endl;
  } else {
    int count = 0;
    for (int i = max_x; i < min_y; i++) {
      if (X <= i && i < Y) {
        count++;
      }
    }
    if (count >= 1) {
      cout << "No War" << endl;
    } else {
      cout << "War" << endl;
    }
  }
}


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> kuni_x(N);
  vector<int> kuni_y(M);
  for (int i = 0; i < N; i++) {
    cin >> kuni_x.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> kuni_y.at(i);
  }
  int max_x = kuni_x.at(0);
  for (int i = 1; i < N; i++) {
    max_x = max(max_x, kuni_x.at(i));
  }
  int min_y = kuni_y.at(0);
  for (int i = 1; i < M; i++) {
    min_y = min(min_y, kuni_y.at(i));
  }
  if (min_y <= max_x) {
    cout << "War" << endl;
  } else {
    int count = 0;
    for (int i = max_x; i < min_y; i++) {
      if (X <= i && i < Y) {
        count++;
      }
    }
    if (count >= 1) {
      cout << "No War" << endl;
    } else {
      cout << "War" << endl;
    }
  }
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

  cin >> N >> M >> L >> R;
  vector<int> v(L);
  for (int i = 0; i < L; i++)
    cin >> v[i];
  v.push_back(N);
  sort(v.begin(), v.end());
  vector<int> w(R);
  for (int i = 0; i < R; i++)
    cin >> w[i];
  w.push_back(M);
  sort(w.begin(), w.end());
  if (v.back() < w.front()) {
    cout << "No War\n";
  } else {
    cout << "War\n";
  }
  return 0;
}

Fixed submission:
#include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

  cin >> L >> R >> N >> M;
  vector<int> v(L);
  for (int i = 0; i < L; i++)
    cin >> v[i];
  v.push_back(N);
  sort(v.begin(), v.end());
  vector<int> w(R);
  for (int i = 0; i < R; i++)
    cin >> w[i];
  w.push_back(M);
  sort(w.begin(), w.end());
  if (v.back() < w.front()) {
    cout << "No War\n";
  } else {
    cout << "War\n";
  }
  return 0;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

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

  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i, n) { cin >> x.at(i); }
  rep(i, m) { cin >> y.at(i); }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  for (int i = x.at(n) + 1; i <= y.at(0); i++) {
    if (X < i && i <= Y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

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

  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i, n) { cin >> x.at(i); }
  rep(i, m) { cin >> y.at(i); }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  for (int i = x.at(n - 1) + 1; i <= y.at(0); i++) {
    if (X < i && i <= Y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}
Problem p03251 (C++)

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

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

  vector<int> A(n);
  rep(i, n) cin >> A[i];
  A.push_back(x);
  sort(A.rbegin(), A.rend());
  int AMax = A[0];

  vector<int> B(n);
  rep(i, m) cin >> B[i];
  B.push_back(y);
  sort(B.begin(), B.end());
  int BMin = B[0];

  if (AMax < BMin)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}


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

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

  vector<int> A(n);
  rep(i, n) cin >> A[i];
  A.push_back(x);
  sort(A.rbegin(), A.rend());
  int AMax = A[0];

  vector<int> B(m);
  rep(i, m) cin >> B[i];
  B.push_back(y);
  sort(B.begin(), B.end());
  int BMin = B[0];

  if (AMax < BMin)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// for(int i = 0; i<n; i++)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1), b(n + 1);
  cin >> a[0] >> b[0];
  int amax = a[0];
  int bmin = b[0];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    amax = max(amax, a[i]);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    bmin = min(bmin, b[i]);
  }
  cout << (amax < bmin ? "No War" : "War") << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// for(int i = 0; i<n; i++)

int main() {
  int n, m;
  cin >> n >> m;
  int a[105], b[105];
  cin >> a[0] >> b[0];
  int amax = a[0];
  int bmin = b[0];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    amax = max(amax, a[i]);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    bmin = min(bmin, b[i]);
  }
  cout << (amax < bmin ? "No War" : "War") << endl;
  return 0;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int n, m, xx, yy;
  std::cin >> n >> m >> xx >> yy;
  std::vector<int> x(n);
  rep(i, n) std::cin >> x[i];
  std::vector<int> y(n);
  rep(i, m) std::cin >> y[i];
  int maxx = xx, miny = yy;
  bool han = false;
  rep(i, n) { maxx = max(maxx, x[i]); }
  rep(i, m) { miny = min(miny, y[i]); }
  if (maxx < miny)
    std::cout << "No War" << std::endl;
  else
    std::cout << "War" << std::endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int n, m, xx, yy;
  std::cin >> n >> m >> xx >> yy;
  std::vector<int> x(n);
  rep(i, n) std::cin >> x[i];
  std::vector<int> y(m);
  rep(i, m) std::cin >> y[i];
  int maxx = xx, miny = yy;
  bool han = false;
  rep(i, n) { maxx = max(maxx, x[i]); }
  rep(i, m) { miny = min(miny, y[i]); }
  if (maxx < miny)
    std::cout << "No War" << std::endl;
  else
    std::cout << "War" << std::endl;
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <vector>

int main() {
  int N, M, X, Y;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  std::vector<int> x(N);
  std::vector<int> y(N);
  int xmax = -100;
  int ymin = 100;
  for (int i = 0; i < N; i++) {
    scanf("%d", &x[i]);
    if (x[i] > xmax)
      xmax = x[i];
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &y[i]);
    if (y[i] < ymin)
      ymin = y[i];
  }
  X = std::max(X, xmax);
  Y = std::min(Y, ymin);
  if (X < Y)
    printf("No War");
  else
    printf("War");
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <vector>

int main() {
  int N, M, X, Y;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  std::vector<int> x(N);
  std::vector<int> y(M);
  int xmax = -100;
  int ymin = 100;
  for (int i = 0; i < N; i++) {
    scanf("%d", &x[i]);
    if (x[i] > xmax)
      xmax = x[i];
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &y[i]);
    if (y[i] < ymin)
      ymin = y[i];
  }
  X = std::max(X, xmax);
  Y = std::min(Y, ymin);
  if (X < Y)
    printf("No War");
  else
    printf("War");
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N + 1);
  vector<int> y(M + 1);
  x[N] = X;
  y[M] = Y;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (x[N] < y[0])
    cout << "No War";
  else
    cout << "War";
}

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N + 1);
  vector<int> y(M + 1);
  x[N] = X;
  y[M] = Y;
  for (int i = 0; i < N; i++)
    cin >> x[i];
  for (int i = 0; i < M; i++)
    cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  if (x[N] < y[0])
    cout << "No War";
  else
    cout << "War";
}
Problem p03251 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> v(n);
  vector<int> w(m);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> w[i];
  }
  sort(v.begin(), v.end());
  sort(w.begin(), v.end());
  if (v[n - 1] < w[0]) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> v(n);
  vector<int> w(m);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> w[i];
  }
  sort(v.begin(), v.end());
  sort(w.begin(), w.end());
  if (v[n - 1] < w[0] && v[n - 1] < y && x < w[0]) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}