Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p02881
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long ans = N - 1; for (int i = 2; i <= Math.sqrt(N); i++) { if (N % i != 0) { continue; } else { if (i + N / i < ans) { ans = i + N / i; } } } System.out.println(ans - 2); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long ans = N + 1; for (int i = 2; i <= Math.sqrt(N) + 1; i++) { if (N % i != 0) { continue; } else { if (i + N / i < ans) { ans = i + N / i; } } } System.out.println(ans - 2); } }
[ "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
678,981
678,982
u873167698
java
p02881
import static java.util.Arrays.binarySearch; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } } class Task { private static int mod = 998244353; public void solve(int testNumber, InputReader in, PrintWriter out) { long n = in.nextLong(); long ans = n; for (long x = 2; x * x <= n; x++) { if (n % x == 0) { ans = Math.min(ans, x + n / x - 2); } } out.println(ans); } } class InputReader { private final BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(nextLine()); } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
import static java.util.Arrays.binarySearch; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } } class Task { private static int mod = 998244353; public void solve(int testNumber, InputReader in, PrintWriter out) { long n = in.nextLong(); long ans = n - 1; for (long x = 2; x * x <= n; x++) { if (n % x == 0) { ans = Math.min(ans, x + n / x - 2); } } out.println(ans); } } class InputReader { private final BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(nextLine()); } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
[ "expression.operation.binary.add" ]
680,044
680,045
u575350848
java
p02881
import static java.util.Arrays.binarySearch; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } } class Task { private static int mod = 998244353; public void solve(int testNumber, InputReader in, PrintWriter out) { long n = in.nextInt(); long ans = n; for (long x = 2; x * x <= n; x++) { if (n % x == 0) { ans = Math.min(ans, x + n / x - 2); } } out.println(ans); } } class InputReader { private final BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(nextLine()); } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
import static java.util.Arrays.binarySearch; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[] args) throws Exception { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } } class Task { private static int mod = 998244353; public void solve(int testNumber, InputReader in, PrintWriter out) { long n = in.nextLong(); long ans = n - 1; for (long x = 2; x * x <= n; x++) { if (n % x == 0) { ans = Math.min(ans, x + n / x - 2); } } out.println(ans); } } class InputReader { private final BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(nextLine()); } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
[ "identifier.change", "call.function.change" ]
680,046
680,045
u575350848
java
p02885
import java.io.*; import java.util.*; class Main { void solve() { System.out.println(Math.min(in.nextInt() - in.nextInt() * 2, 0)); } public static PrintWriter out = new PrintWriter(System.out); public static Scanner in = new Scanner(System.in); public static void main(String[] args) { new Main().solve(); out.flush(); } }
import java.io.*; import java.util.*; class Main { void solve() { System.out.println(Math.max(in.nextInt() - in.nextInt() * 2, 0)); } public static PrintWriter out = new PrintWriter(System.out); public static Scanner in = new Scanner(System.in); public static void main(String[] args) { new Main().solve(); out.flush(); } }
[ "misc.opposites", "identifier.change", "call.function.change", "call.arguments.change", "io.output.change" ]
685,521
685,522
u933812390
java
p02886
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int d[] = new int[N]; for (int i = 0; i < N; i++) { d[i] = sc.nextInt(); } int count = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { count += d[i] * d[j]; } } System.out.println(count); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int d[] = new int[N]; for (int i = 0; i < N; i++) { d[i] = sc.nextInt(); } int count = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { count += d[i] * d[j]; } } System.out.println(count); } }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change" ]
686,377
686,378
u918923596
java
p02897
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int odd = 0; int notOdd = 0; for (int i = 1; i <= n; i++) { if (i % 2 == 0) { notOdd++; } else { odd++; } } System.out.println(odd / n); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double n = sc.nextDouble(); double odd = 0; double notOdd = 0; for (int i = 1; i <= n; i++) { if (i % 2 == 0) { notOdd++; } else { odd++; } } System.out.println(odd / n); } }
[ "variable_declaration.type.primitive.change", "identifier.change", "call.function.change" ]
692,855
692,856
u532585581
java
p02898
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int count = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (x < k) { count += 1; } } System.out.println(count); } }
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int count = 0; for (int i = 0; i < n; i++) { int x = sc.nextInt(); if (x >= k) { count += 1; } } System.out.println(count); } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
695,797
695,798
u060569392
java
p02899
import java.util.Scanner; /** * * @author cs18097 */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ary[] = new int[n]; for (int i = 0; i < ary.length; i++) ary[sc.nextInt() - 1] = i; for (int i = 0; i < ary.length; i++) System.out.print(ary[i] + 1); } }
import java.util.Scanner; /** * * @author cs18097 */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ary[] = new int[n]; for (int i = 0; i < ary.length; i++) ary[sc.nextInt() - 1] = i; for (int i = 0; i < ary.length; i++) System.out.print(ary[i] + 1 + " "); } }
[ "expression.operation.binary.add" ]
697,013
697,014
u794927332
java
p02909
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); String w = s.nextLine(); if (w.equals("Sunny")) System.out.print("Cloudy"); else if (s.equals("Cloudy")) System.out.print("Rainy"); else System.out.print("Sunny"); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); String w = s.nextLine(); if (w.equals("Sunny")) System.out.print("Cloudy"); else if (w.equals("Cloudy")) System.out.print("Rainy"); else System.out.print("Sunny"); } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
704,507
704,508
u469281291
java
p02909
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); String T = ""; if ("Sunny".equals(S)) { T = "Cloudy"; } else if ("Cloudy".equals(S)) { T = "Rainy"; } else if ("Rainly".equals(S)) { T = "Sunny"; } System.out.println(T); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); String T = ""; if ("Sunny".equals(S)) { T = "Cloudy"; } else if ("Cloudy".equals(S)) { T = "Rainy"; } else if ("Rainy".equals(S)) { T = "Sunny"; } System.out.println(T); } }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
704,544
704,545
u915981080
java
p02910
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char a[] = s.toCharArray(); int count = 0; for (int i = 0; i < s.length(); i++) { if ((i % 2) == 0) { if (a[i] == 'R' | a[i] == 'U' | a[i] == 'D') count++; } else { if (a[i] == 'L' | a[i] == 'U' | a[i] == 'D') count++; } } if (s.length() == count) System.out.println("YES"); else System.out.println("NO"); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char a[] = s.toCharArray(); int count = 0; for (int i = 0; i < s.length(); i++) { if ((i % 2) == 0) { if (a[i] == 'R' | a[i] == 'U' | a[i] == 'D') count++; } else { if (a[i] == 'L' | a[i] == 'U' | a[i] == 'D') count++; } } if (s.length() == count) System.out.println("Yes"); else System.out.println("No"); } }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
706,031
706,032
u717880434
java
p02912
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int sum = 0; PriorityQueue<Integer> q = new PriorityQueue(Comparator.reverseOrder()); for (int i = 0; i < N; i++) { int A = sc.nextInt(); q.offer(A); sum += A; } for (int i = 1; i <= M; i++) { int maxPrice = q.poll(); int newPrice = maxPrice / 2; sum -= maxPrice - newPrice; q.offer(newPrice); } System.out.println(sum < 0 ? 0 : sum); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); long sum = 0; PriorityQueue<Integer> q = new PriorityQueue(Comparator.reverseOrder()); for (int i = 0; i < N; i++) { int A = sc.nextInt(); q.offer(A); sum += A; } for (int i = 1; i <= M; i++) { int maxPrice = q.poll(); int newPrice = maxPrice / 2; sum -= maxPrice - newPrice; q.offer(newPrice); } System.out.println(sum < 0 ? 0 : sum); } }
[ "variable_declaration.type.primitive.change" ]
709,984
709,985
u507706381
java
p02922
import java.util.Scanner; public class Main { public static int ceil(int a, int b) { int x = (a + (b - 1)) / b; return x; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int ans = ceil(b, a); // 出力 System.out.println(ans); } }
import java.util.Scanner; public class Main { public static int ceil(int a, int b) { int x = (a + (b - 1)) / b; return x; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int ans = ceil(b - 1, a - 1); // 出力 System.out.println(ans); } }
[ "expression.operation.binary.add" ]
719,639
719,640
u777923818
java
p02922
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException, Exception { BufferedReader st = new BufferedReader(new InputStreamReader(System.in)); int[] data = getIntArry(st); int m = data[0]; int t = data[1]; int cnt = 1; int t2 = m; while (t2 < t) { t2 += (m - 1); cnt++; } if (t == 0) { cnt = 0; } anser(cnt); } private static int[] getIntArry(BufferedReader st) throws Exception, IOException { String line = st.readLine(); String[] strData = line.split(" "); int[] intData = new int[strData.length]; for (int i = 0; i < strData.length; i++) { intData[i] = Integer.parseInt(strData[i]); } return intData; } private static void anser(int num) { System.out.println(num); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException, Exception { BufferedReader st = new BufferedReader(new InputStreamReader(System.in)); int[] data = getIntArry(st); int m = data[0]; int t = data[1]; int cnt = 1; int t2 = m; while (t2 < t) { t2 += (m - 1); cnt++; } if (t == 1) { cnt = 0; } anser(cnt); } private static int[] getIntArry(BufferedReader st) throws Exception, IOException { String line = st.readLine(); String[] strData = line.split(" "); int[] intData = new int[strData.length]; for (int i = 0; i < strData.length; i++) { intData[i] = Integer.parseInt(strData[i]); } return intData; } private static void anser(int num) { System.out.println(num); } }
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
719,883
719,884
u522628393
java
p02923
import java.util.*; public class Main { void solve() { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) h[i] = scan.nextInt(); int c = 0; int out = -1; for (int i = 0; i < n - 1; i++) { if (h[i] >= h[i + 1]) c++; else { if (c == 0) continue; c++; out = Math.max(c, out); c = 0; } } out = Math.max(out, c); System.out.println(out); scan.close(); } public static void main(String[] args) { new Main().solve(); } }
import java.util.*; public class Main { void solve() { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) h[i] = scan.nextInt(); int c = 0; int out = -1; for (int i = 0; i < n - 1; i++) { if (h[i] >= h[i + 1]) c++; else { if (c == 0) continue; out = Math.max(c, out); c = 0; } } out = Math.max(out, c); System.out.println(out); scan.close(); } public static void main(String[] args) { new Main().solve(); } }
[ "expression.unary.arithmetic.remove" ]
721,740
721,741
u459100168
java
p02924
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastIO fio = new FastIO(); int n = fio.readInt(); System.out.println(((n - 1) * n) / 2); } private static class FastIO { private StringTokenizer stringTokenizer; private BufferedReader bufferedReader; public FastIO() { bufferedReader = new BufferedReader(new InputStreamReader(System.in)); stringTokenizer = null; } public String read() { if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) { try { stringTokenizer = new StringTokenizer(bufferedReader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return stringTokenizer.nextToken(); } public int readInt() { return Integer.parseInt(read()); } public long readLong() { return Long.parseLong(read()); } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastIO fio = new FastIO(); long n = fio.readInt(); System.out.println(((n - 1) * n) / 2); } private static class FastIO { private StringTokenizer stringTokenizer; private BufferedReader bufferedReader; public FastIO() { bufferedReader = new BufferedReader(new InputStreamReader(System.in)); stringTokenizer = null; } public String read() { if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) { try { stringTokenizer = new StringTokenizer(bufferedReader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return stringTokenizer.nextToken(); } public int readInt() { return Integer.parseInt(read()); } public long readLong() { return Long.parseLong(read()); } } }
[ "variable_declaration.type.primitive.change" ]
725,455
725,456
u808675476
java
p02924
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { MyWriter out = new MyWriter(System.out); MyScanner sc = new MyScanner(System.in); int num = sc.nextInt(); long res = (1 + num - 1) * (num - 1) / 2; out.println(res); out.flush(); } static final class MyScanner { static final int BUFFER_SIZE = 8192; private final InputStream in; private final byte[] buffer = new byte[BUFFER_SIZE]; private int point; private int readLength; MyScanner(InputStream in) { this.in = in; } private int readByte() { if (point < readLength) { int result = buffer[point]; point += 1; return result; } try { readLength = in.read(buffer); } catch (IOException e) { throw new AssertionError(null, e); } if (readLength == -1) { return -1; } point = 1; return buffer[0]; } private static boolean isPrintableCharExceptSpace(int c) { return 33 <= c && c <= 126; } String next() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } StringBuilder b = new StringBuilder(); do { b.appendCodePoint(c); c = readByte(); } while (c != -1 && isPrintableCharExceptSpace(c)); return b.toString(); } long nextLong() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long result = 0L; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } result = result * 10L + (c - '0'); c = readByte(); } while (c != -1 && isPrintableCharExceptSpace(c)); return minus ? -result : result; } int nextInt() { long n = nextLong(); if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) { throw new InputMismatchException(); } return (int)n; } double nextDouble() { return Double.parseDouble(next()); } int[] nextIntArray(int n) { int[] result = new int[n]; for (int i = 0; i < n; i++) { result[i] = nextInt(); } return result; } private static boolean allSameLength(int[] a, int[] b, int[]... c) { if (a.length != b.length) { return false; } for (int[] element : c) { if (a.length != element.length) { return false; } } return true; } private static boolean allSameLength(char[] a, char[] b, char[]... c) { if (a.length != b.length) { return false; } for (char[] element : c) { if (a.length != element.length) { return false; } } return true; } void nextVerticalIntArrays(int[] a, int[] b, int[]... c) { if (!allSameLength(a, b, c)) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextInt(); b[i] = nextInt(); for (int[] d : c) { d[i] = nextInt(); } } } long[] nextLongArray(int n) { long[] result = new long[n]; for (int i = 0; i < n; i++) { result[i] = nextLong(); } return result; } char nextChar() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } return (char)c; } char[] nextCharArray(int n) { char[] result = new char[n]; for (int i = 0; i < n; i++) { result[i] = nextChar(); } return result; } char[][] next2dCharArray(int n, int m) { char[][] result = new char[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { result[i][j] = nextChar(); } } return result; } void nextVerticalCharArrays(char[] a, char[] b, char[]... c) { if (!allSameLength(a, b, c)) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextChar(); b[i] = nextChar(); for (char[] d : c) { d[i] = nextChar(); } } } } static final class MyWriter extends PrintWriter { MyWriter(OutputStream out) { super(out); } void joinAndPrintln(int[] x) { joinAndPrintln(x, " "); } void joinAndPrintln(int[] x, String delimiter) { StringBuilder b = new StringBuilder(); if (x.length > 0) { b.append(x[0]); for (int i = 1; i < x.length; i++) { b.append(delimiter).append(x[i]); } } println(b.toString()); } void joinAndPrintln(long[] x) { joinAndPrintln(x, " "); } void joinAndPrintln(long[] x, String delimiter) { StringBuilder b = new StringBuilder(); if (x.length > 0) { b.append(x[0]); for (int i = 1; i < x.length; i++) { b.append(delimiter).append(x[i]); } } println(b.toString()); } void joinAndPrintln(Iterable<?> iterable) { joinAndPrintln(iterable, " "); } void joinAndPrintln(Iterable<?> iterable, String delimiter) { StringBuilder b = new StringBuilder(); for (Iterator<?> i = iterable.iterator(); i.hasNext();) { b.append(i.next()); while (i.hasNext()) { b.append(delimiter).append(i.next()); } } println(b.toString()); } } }
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { MyWriter out = new MyWriter(System.out); MyScanner sc = new MyScanner(System.in); long num = sc.nextInt(); long res = (1 + num - 1) * (num - 1) / 2; out.println(res); out.flush(); } static final class MyScanner { static final int BUFFER_SIZE = 8192; private final InputStream in; private final byte[] buffer = new byte[BUFFER_SIZE]; private int point; private int readLength; MyScanner(InputStream in) { this.in = in; } private int readByte() { if (point < readLength) { int result = buffer[point]; point += 1; return result; } try { readLength = in.read(buffer); } catch (IOException e) { throw new AssertionError(null, e); } if (readLength == -1) { return -1; } point = 1; return buffer[0]; } private static boolean isPrintableCharExceptSpace(int c) { return 33 <= c && c <= 126; } String next() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } StringBuilder b = new StringBuilder(); do { b.appendCodePoint(c); c = readByte(); } while (c != -1 && isPrintableCharExceptSpace(c)); return b.toString(); } long nextLong() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long result = 0L; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } result = result * 10L + (c - '0'); c = readByte(); } while (c != -1 && isPrintableCharExceptSpace(c)); return minus ? -result : result; } int nextInt() { long n = nextLong(); if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) { throw new InputMismatchException(); } return (int)n; } double nextDouble() { return Double.parseDouble(next()); } int[] nextIntArray(int n) { int[] result = new int[n]; for (int i = 0; i < n; i++) { result[i] = nextInt(); } return result; } private static boolean allSameLength(int[] a, int[] b, int[]... c) { if (a.length != b.length) { return false; } for (int[] element : c) { if (a.length != element.length) { return false; } } return true; } private static boolean allSameLength(char[] a, char[] b, char[]... c) { if (a.length != b.length) { return false; } for (char[] element : c) { if (a.length != element.length) { return false; } } return true; } void nextVerticalIntArrays(int[] a, int[] b, int[]... c) { if (!allSameLength(a, b, c)) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextInt(); b[i] = nextInt(); for (int[] d : c) { d[i] = nextInt(); } } } long[] nextLongArray(int n) { long[] result = new long[n]; for (int i = 0; i < n; i++) { result[i] = nextLong(); } return result; } char nextChar() { int c = readByte(); while (!(c == -1 || isPrintableCharExceptSpace(c))) { c = readByte(); } if (c == -1) { throw new NoSuchElementException(); } return (char)c; } char[] nextCharArray(int n) { char[] result = new char[n]; for (int i = 0; i < n; i++) { result[i] = nextChar(); } return result; } char[][] next2dCharArray(int n, int m) { char[][] result = new char[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { result[i][j] = nextChar(); } } return result; } void nextVerticalCharArrays(char[] a, char[] b, char[]... c) { if (!allSameLength(a, b, c)) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextChar(); b[i] = nextChar(); for (char[] d : c) { d[i] = nextChar(); } } } } static final class MyWriter extends PrintWriter { MyWriter(OutputStream out) { super(out); } void joinAndPrintln(int[] x) { joinAndPrintln(x, " "); } void joinAndPrintln(int[] x, String delimiter) { StringBuilder b = new StringBuilder(); if (x.length > 0) { b.append(x[0]); for (int i = 1; i < x.length; i++) { b.append(delimiter).append(x[i]); } } println(b.toString()); } void joinAndPrintln(long[] x) { joinAndPrintln(x, " "); } void joinAndPrintln(long[] x, String delimiter) { StringBuilder b = new StringBuilder(); if (x.length > 0) { b.append(x[0]); for (int i = 1; i < x.length; i++) { b.append(delimiter).append(x[i]); } } println(b.toString()); } void joinAndPrintln(Iterable<?> iterable) { joinAndPrintln(iterable, " "); } void joinAndPrintln(Iterable<?> iterable, String delimiter) { StringBuilder b = new StringBuilder(); for (Iterator<?> i = iterable.iterator(); i.hasNext();) { b.append(i.next()); while (i.hasNext()) { b.append(delimiter).append(i.next()); } } println(b.toString()); } } }
[ "variable_declaration.type.primitive.change" ]
725,832
725,833
u109985485
java
p02924
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long sum = N * (N - 1) / 2; System.out.println(sum); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long sum = (N * (N - 1)) / 2; System.out.println(sum); } }
[ "variable_declaration.type.primitive.change", "identifier.change", "call.function.change" ]
726,327
726,328
u568787360
java
p02924
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int sum = N * (N - 1) / 2; System.out.println(sum); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long sum = (N * (N - 1)) / 2; System.out.println(sum); } }
[ "variable_declaration.type.primitive.change", "identifier.change", "call.function.change" ]
726,329
726,328
u568787360
java
p02924
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int N = stdIn.nextInt(); System.out.println(N * (N - 1) / 2); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); long N = stdIn.nextInt(); System.out.println(N * (N - 1) / 2); } }
[ "variable_declaration.type.primitive.change" ]
727,656
727,657
u847241179
java
p02924
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = (n - 1) * n; a = a / 2; System.out.println(a); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = (n - 1) * n; a = a / 2; System.out.println(a); } }
[ "variable_declaration.type.primitive.change", "identifier.change", "call.function.change" ]
727,749
727,750
u464457275
java
p02924
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = (n - 1) * n; a = a / 2; System.out.println(a); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = (n - 1) * n; a = a / 2; System.out.println(a); } }
[ "variable_declaration.type.primitive.change", "identifier.change", "call.function.change" ]
727,751
727,750
u464457275
java
p02924
import java.io.PrintStream; import java.util.Scanner; public class Main { static final PrintStream out = System.out; static final Scanner sc = new Scanner(System.in); static final long Mod = 1000_000_007L; public static void main(String[] args) { Main main = new Main(); main.solve(); System.exit(0); } void solve() { long N = nextLong(); long res = (N - 1) * (N / 2); out.println(res); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public String next() { return sc.next(); } }
import java.io.PrintStream; import java.util.Scanner; public class Main { static final PrintStream out = System.out; static final Scanner sc = new Scanner(System.in); static final long Mod = 1000_000_007L; public static void main(String[] args) { Main main = new Main(); main.solve(); System.exit(0); } void solve() { long N = nextLong(); long res = (N - 1) * N / 2; out.println(res); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public String next() { return sc.next(); } }
[]
728,437
728,438
u908039151
java
p02924
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int N = scn.nextInt(); System.out.println(N * (N - 1) / 2); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); long N = scn.nextInt(); System.out.println(N * (N - 1) / 2); } }
[ "variable_declaration.type.primitive.change" ]
728,839
728,840
u517219904
java
p02933
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String s = sc.nextLine(); if (a >= 3200) { System.out.println(s); } else { System.out.println("red"); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String s = sc.next(); if (a >= 3200) { System.out.println(s); } else { System.out.println("red"); } } }
[ "identifier.change", "call.function.change" ]
733,739
733,740
u463844166
java
p02933
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String s = sc.next(); if (a <= 3200) { System.out.println(s); } else { System.out.println("red"); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String s = sc.next(); if (a >= 3200) { System.out.println(s); } else { System.out.println("red"); } } }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
735,466
735,467
u812977645
java
p02935
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Arrays.sort(a); double ans = (double)a[0]; for (int i = 1; i < n - 1; i++) { ans = (double)(ans + a[i]) / 2.0; } System.out.println(ans); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Arrays.sort(a); double ans = (double)a[0]; for (int i = 1; i < n; i++) { ans = (double)(ans + a[i]) / 2.0; } System.out.println(ans); } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
737,055
737,056
u431125128
java
p02937
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 998244353; // static final long MOD = 1000000007; static boolean[] visited; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); TreeSet<Integer>[] letters = new TreeSet[26]; for (int i = 0; i < 26; i++) { letters[i] = new TreeSet<Integer>(); } String s = sc.next(); String t = sc.next(); for (int i = 0; i < s.length(); i++) { int letterNum = (int)s.charAt(i) - 99; letters[letterNum].add(i); } // Check to see if the answer is -1. for (int i = 0; i < t.length(); i++) { int letterNum = (int)t.charAt(i) - 99; if (letters[letterNum].isEmpty()) { System.out.println(-1); return; } } int cycles = 0; int index = -1; for (int i = 0; i < t.length(); i++) { int letterNum = (int)t.charAt(i) - 99; Integer nextIndex = letters[letterNum].higher(index); if (nextIndex == null) { cycles++; index = letters[letterNum].first(); } else { index = nextIndex; } } long ans = ((long)cycles) * s.length() + index; System.out.println(ans + 1); } public static int[] sort(int[] array) { // Sort an array (immune to quicksort TLE) Random rgen = new Random(); for (int i = 0; i < array.length; i++) { int randomPosition = rgen.nextInt(array.length); int temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; } Arrays.sort(array); return array; } public static int[][] sort(int[][] array) { // Sort an array (immune to quicksort TLE) Random rgen = new Random(); for (int i = 0; i < array.length; i++) { int randomPosition = rgen.nextInt(array.length); int[] temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; } Arrays.sort(array, new Comparator<int[]>() { @Override public int compare(int[] arr1, int[] arr2) { // Ascending order. return arr1[0] - arr2[0]; } }); return array; } static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } } class Node { public HashSet<Node> children; public int n; public Node(int n) { this.n = n; children = new HashSet<Node>(); } public void addChild(Node node) { children.add(node); } public void removeChild(Node node) { children.remove(node); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return n; } @Override public boolean equals(Object obj) { if (!(obj instanceof Node)) { return false; } else { Node node = (Node)obj; return (n == node.n); } } public String toString() { return (this.n + 1) + ""; } } class BinaryIndexedTree { public long[] arr; public BinaryIndexedTree(int N) { arr = new long[N + 1]; arr[0] = 0; } // add k to the i-th element. public void add(long k, int i) { int node = i + 1; while (node < arr.length) { arr[node] += k; node += node & (-node); } } // sum up the elements from input[s_i] to input[e_i], from [s_i,e_i). public long sum(int s_i, int e_i) { return sum(e_i) - sum(s_i); } public long sum(int i) { long total = 0; int node = i; while (node > 0) { total += arr[node]; node -= node & (-node); } return total; } } class DSU { public int N; public int[] parent; public int[] rank; public int count; public DSU(int numNodes) { N = numNodes; parent = new int[N]; rank = new int[N]; for (int i = 0; i < N; i++) { parent[i] = i; rank[i] = 1; } count = numNodes; } public boolean isConnected(int p, int q) { return root(p) == root(q); } public int root(int p) { while (p != parent[p]) p = parent[p]; return p; } // only connect p and q if they are disjointed. public void connect(int p, int q) { int rootP = root(p); int rootQ = root(q); if (rank[rootP] >= rank[rootQ]) { parent[rootQ] = rootP; rank[rootP] += rank[rootQ]; } else if (rank[rootQ] > rank[rootP]) { parent[rootP] = rootQ; rank[rootQ] += rank[rootP]; } count--; } }
import java.io.*; import java.math.*; import java.util.*; public class Main { static final long MOD = 998244353; // static final long MOD = 1000000007; static boolean[] visited; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); TreeSet<Integer>[] letters = new TreeSet[26]; for (int i = 0; i < 26; i++) { letters[i] = new TreeSet<Integer>(); } String s = sc.next(); String t = sc.next(); for (int i = 0; i < s.length(); i++) { int letterNum = (int)s.charAt(i) - 97; letters[letterNum].add(i); } // Check to see if the answer is -1. for (int i = 0; i < t.length(); i++) { int letterNum = (int)t.charAt(i) - 97; if (letters[letterNum].isEmpty()) { System.out.println(-1); return; } } int cycles = 0; int index = -1; for (int i = 0; i < t.length(); i++) { int letterNum = (int)t.charAt(i) - 97; Integer nextIndex = letters[letterNum].higher(index); if (nextIndex == null) { cycles++; index = letters[letterNum].first(); } else { index = nextIndex; } } long ans = ((long)cycles) * s.length() + index; System.out.println(ans + 1); } public static int[] sort(int[] array) { // Sort an array (immune to quicksort TLE) Random rgen = new Random(); for (int i = 0; i < array.length; i++) { int randomPosition = rgen.nextInt(array.length); int temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; } Arrays.sort(array); return array; } public static int[][] sort(int[][] array) { // Sort an array (immune to quicksort TLE) Random rgen = new Random(); for (int i = 0; i < array.length; i++) { int randomPosition = rgen.nextInt(array.length); int[] temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; } Arrays.sort(array, new Comparator<int[]>() { @Override public int compare(int[] arr1, int[] arr2) { // Ascending order. return arr1[0] - arr2[0]; } }); return array; } static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } } class Node { public HashSet<Node> children; public int n; public Node(int n) { this.n = n; children = new HashSet<Node>(); } public void addChild(Node node) { children.add(node); } public void removeChild(Node node) { children.remove(node); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return n; } @Override public boolean equals(Object obj) { if (!(obj instanceof Node)) { return false; } else { Node node = (Node)obj; return (n == node.n); } } public String toString() { return (this.n + 1) + ""; } } class BinaryIndexedTree { public long[] arr; public BinaryIndexedTree(int N) { arr = new long[N + 1]; arr[0] = 0; } // add k to the i-th element. public void add(long k, int i) { int node = i + 1; while (node < arr.length) { arr[node] += k; node += node & (-node); } } // sum up the elements from input[s_i] to input[e_i], from [s_i,e_i). public long sum(int s_i, int e_i) { return sum(e_i) - sum(s_i); } public long sum(int i) { long total = 0; int node = i; while (node > 0) { total += arr[node]; node -= node & (-node); } return total; } } class DSU { public int N; public int[] parent; public int[] rank; public int count; public DSU(int numNodes) { N = numNodes; parent = new int[N]; rank = new int[N]; for (int i = 0; i < N; i++) { parent[i] = i; rank[i] = 1; } count = numNodes; } public boolean isConnected(int p, int q) { return root(p) == root(q); } public int root(int p) { while (p != parent[p]) p = parent[p]; return p; } // only connect p and q if they are disjointed. public void connect(int p, int q) { int rootP = root(p); int rootQ = root(q); if (rank[rootP] >= rank[rootQ]) { parent[rootQ] = rootP; rank[rootP] += rank[rootQ]; } else if (rank[rootQ] > rank[rootP]) { parent[rootP] = rootQ; rank[rootQ] += rank[rootP]; } count--; } }
[ "literal.number.integer.change", "expression.operation.binary.change" ]
740,148
740,149
u495186373
java
p02939
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.StringJoiner; class Main { static PrintWriter out; static InputReader sc; public static void main(String[] args) { sc = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static void solve() { String s = sc.next(); int N = s.length(); int[] dp = new int[N]; dp[0] = 1; if (s.charAt(0) == s.charAt(1)) { dp[1] = 1; } else { dp[1] = 2; } if (s.charAt(1) == s.charAt(2)) { dp[2] = dp[1]; } else { dp[2] = dp[1] + 1; } for (int i = 3; i < N; i++) { if (s.charAt(i - 1) != s.charAt(i)) { dp[i] = dp[i - 1] + 1; } else { dp[i] = dp[i - 3] + 2; } } out.println(dp[N - 1]); } static void debug(Object... args) { StringJoiner j = new StringJoiner(" "); for (Object arg : args) { if (arg == null) { j.add("null"); } else if (arg instanceof int[]) { j.add(Arrays.toString((int[])arg)); } else if (arg instanceof long[]) { j.add(Arrays.toString((long[])arg)); } else if (arg instanceof double[]) { j.add(Arrays.toString((double[])arg)); } else if (arg instanceof char[]) { j.add(Arrays.toString((char[])arg)); } else if (arg instanceof boolean[]) { j.add(Arrays.toString((boolean[])arg)); } else if (arg instanceof Object[]) { j.add(Arrays.toString((Object[])arg)); } else { j.add(arg.toString()); } } System.err.println(j.toString()); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (this.curbuf >= this.lenbuf) { this.curbuf = 0; try { this.lenbuf = this.in.read(this.buffer); } catch (IOException e) { throw new InputMismatchException(); } if (this.lenbuf <= 0) { return false; } } return true; } private int readByte() { if (this.hasNextByte()) { return this.buffer[this.curbuf++]; } else { return -1; } } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (this.hasNextByte() && this.isSpaceChar(this.buffer[this.curbuf])) { this.curbuf++; } } public boolean hasNext() { this.skip(); return this.hasNextByte(); } public String next() { if (!this.hasNext()) { throw new NoSuchElementException(); } StringBuilder sb = new StringBuilder(); int b = this.readByte(); while (!this.isSpaceChar(b)) { sb.appendCodePoint(b); b = this.readByte(); } return sb.toString(); } public int nextInt() { if (!this.hasNext()) { throw new NoSuchElementException(); } int c = this.readByte(); while (this.isSpaceChar(c)) { c = this.readByte(); } boolean minus = false; if (c == '-') { minus = true; c = this.readByte(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res = res * 10 + c - '0'; c = this.readByte(); } while (!this.isSpaceChar(c)); return minus ? -res : res; } public long nextLong() { if (!this.hasNext()) { throw new NoSuchElementException(); } int c = this.readByte(); while (this.isSpaceChar(c)) { c = this.readByte(); } boolean minus = false; if (c == '-') { minus = true; c = this.readByte(); } long res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res = res * 10 + c - '0'; c = this.readByte(); } while (!this.isSpaceChar(c)); return minus ? -res : res; } public double nextDouble() { return Double.parseDouble(this.next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = this.nextInt(); } return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = this.nextLong(); } return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) { map[i] = this.next().toCharArray(); } return map; } } }
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.StringJoiner; class Main { static PrintWriter out; static InputReader sc; public static void main(String[] args) { sc = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static void solve() { String s = sc.next(); int N = s.length(); int[] dp = new int[N]; dp[0] = 1; if (s.charAt(0) == s.charAt(1)) { dp[1] = 1; } else { dp[1] = 2; } if (s.charAt(1) == s.charAt(2)) { dp[2] = 2; } else { dp[2] = dp[1] + 1; } for (int i = 3; i < N; i++) { if (s.charAt(i - 1) != s.charAt(i)) { dp[i] = dp[i - 1] + 1; } else { dp[i] = dp[i - 3] + 2; } } out.println(dp[N - 1]); } static void debug(Object... args) { StringJoiner j = new StringJoiner(" "); for (Object arg : args) { if (arg == null) { j.add("null"); } else if (arg instanceof int[]) { j.add(Arrays.toString((int[])arg)); } else if (arg instanceof long[]) { j.add(Arrays.toString((long[])arg)); } else if (arg instanceof double[]) { j.add(Arrays.toString((double[])arg)); } else if (arg instanceof char[]) { j.add(Arrays.toString((char[])arg)); } else if (arg instanceof boolean[]) { j.add(Arrays.toString((boolean[])arg)); } else if (arg instanceof Object[]) { j.add(Arrays.toString((Object[])arg)); } else { j.add(arg.toString()); } } System.err.println(j.toString()); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (this.curbuf >= this.lenbuf) { this.curbuf = 0; try { this.lenbuf = this.in.read(this.buffer); } catch (IOException e) { throw new InputMismatchException(); } if (this.lenbuf <= 0) { return false; } } return true; } private int readByte() { if (this.hasNextByte()) { return this.buffer[this.curbuf++]; } else { return -1; } } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (this.hasNextByte() && this.isSpaceChar(this.buffer[this.curbuf])) { this.curbuf++; } } public boolean hasNext() { this.skip(); return this.hasNextByte(); } public String next() { if (!this.hasNext()) { throw new NoSuchElementException(); } StringBuilder sb = new StringBuilder(); int b = this.readByte(); while (!this.isSpaceChar(b)) { sb.appendCodePoint(b); b = this.readByte(); } return sb.toString(); } public int nextInt() { if (!this.hasNext()) { throw new NoSuchElementException(); } int c = this.readByte(); while (this.isSpaceChar(c)) { c = this.readByte(); } boolean minus = false; if (c == '-') { minus = true; c = this.readByte(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res = res * 10 + c - '0'; c = this.readByte(); } while (!this.isSpaceChar(c)); return minus ? -res : res; } public long nextLong() { if (!this.hasNext()) { throw new NoSuchElementException(); } int c = this.readByte(); while (this.isSpaceChar(c)) { c = this.readByte(); } boolean minus = false; if (c == '-') { minus = true; c = this.readByte(); } long res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res = res * 10 + c - '0'; c = this.readByte(); } while (!this.isSpaceChar(c)); return minus ? -res : res; } public double nextDouble() { return Double.parseDouble(this.next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = this.nextInt(); } return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = this.nextLong(); } return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) { map[i] = this.next().toCharArray(); } return map; } } }
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add" ]
741,471
741,472
u003018968
java
p02947
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long ans = 0; int n = sc.nextInt(); Map<String, Integer> map = new HashMap<>(); for (int i = 0; i < n; i++) { char[] ca = sc.next().toCharArray(); Arrays.sort(ca); String s = String.valueOf(ca); if (map.containsKey(s)) map.put(s, map.get(s) + 1); else map.put(s, 1); } for (String key : map.keySet()) { ans += map.get(key) * (map.get(key) - 1) / 2; } System.out.println(ans); } }
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long ans = 0; int n = sc.nextInt(); Map<String, Long> map = new HashMap<>(); for (int i = 0; i < n; i++) { char[] ca = sc.next().toCharArray(); Arrays.sort(ca); String s = String.valueOf(ca); if (map.containsKey(s)) map.put(s, map.get(s) + 1); else map.put(s, 1L); } for (String key : map.keySet()) { ans += map.get(key) * (map.get(key) - 1) / 2; } System.out.println(ans); } }
[ "literal.number.integer.type.widen.change" ]
746,469
746,470
u886708442
java
p02947
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ArrayList<String> sortedList = new ArrayList<>(); Map<String, Integer> map = new HashMap<>(); int ans = 0; for (int i = 0; i < N; i++) { char[] c = sc.next().toCharArray(); Arrays.sort(c); sortedList.add(String.valueOf(c)); String s = sortedList.get(i); if (map.containsKey(s)) { int num = map.get(s) + 1; ans += num; map.put(s, num); } else { map.put(s, 0); } } System.out.println(ans); sc.close(); } }
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ArrayList<String> sortedList = new ArrayList<>(); Map<String, Integer> map = new HashMap<>(); long ans = 0; for (int i = 0; i < N; i++) { char[] c = sc.next().toCharArray(); Arrays.sort(c); sortedList.add(String.valueOf(c)); String s = sortedList.get(i); if (map.containsKey(s)) { int num = map.get(s) + 1; ans += num; map.put(s, num); } else { map.put(s, 0); } } System.out.println(ans); sc.close(); } }
[ "variable_declaration.type.primitive.change" ]
747,506
747,507
u136477556
java
p02947
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Integer> s = new HashMap<>(); long count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, 0) + 1); } for (int v : s.values()) { count += v * (v - 1) / 2; } System.out.println(count); } }
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Long> s = new HashMap<>(); long count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, 0L) + 1); } for (long v : s.values()) { count += v * (v - 1) / 2; } System.out.println(count); } }
[ "literal.number.integer.type.widen.change" ]
747,670
747,671
u492989229
java
p02947
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Integer> s = new HashMap<>(); int count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, 0) + 1); } for (int v : s.values()) { count += v * (v - 1) / 2; } System.out.println(count); } }
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Long> s = new HashMap<>(); long count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, 0L) + 1); } for (long v : s.values()) { count += v * (v - 1) / 2; } System.out.println(count); } }
[ "variable_declaration.type.primitive.change", "literal.number.integer.type.widen.change" ]
747,672
747,671
u492989229
java
p02947
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Integer> s = new HashMap<>(); int count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, -1) + 1); } for (int v : s.values()) { count += v * (v + 1) / 2; } System.out.println(count); } }
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Long> s = new HashMap<>(); long count = 0; for (int i = 0; i < n; ++i) { char[] ci = sc.next().toCharArray(); Arrays.sort(ci); String si = new String(ci); s.put(si, s.getOrDefault(si, 0L) + 1); } for (long v : s.values()) { count += v * (v - 1) / 2; } System.out.println(count); } }
[ "variable_declaration.type.primitive.change", "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
747,673
747,671
u492989229
java
p02947
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] s = new String[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); } TreeMap<String, Integer> map = new TreeMap<String, Integer>(); for (int i = 0; i < n; i++) { int[] a = new int[10]; for (int j = 0; j < 10; j++) { a[j] = s[i].charAt(j); } Arrays.sort(a); String b = ""; for (int j = 0; j < 10; j++) { b = b + a[j]; } if (map.containsKey(b)) { map.put(b, map.get(b) + 1); } else { map.put(b, 0); } } long ans = 0; Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String key = it.next(); long tmp = map.get(key) * (map.get(key) + 1) / 2; ans += tmp; } System.out.print(ans); } }
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] s = new String[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); } HashMap<String, Integer> map = new HashMap<String, Integer>(); for (int i = 0; i < n; i++) { int[] a = new int[10]; for (int j = 0; j < 10; j++) { a[j] = s[i].charAt(j); } Arrays.sort(a); String b = ""; for (int j = 0; j < 10; j++) { b += b + a[j]; } if (map.containsKey(b)) { map.put(b, map.get(b) + 1); } else { map.put(b, 0); } } long ans = 0; Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String key = it.next(); long tmp = (long)map.get(key) * (map.get(key) + 1) / 2; ans += tmp; } System.out.print(ans); } }
[ "assignment.value.change" ]
748,023
748,024
u623115612
java
p02951
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int ans = b - (a - b); if (ans <= 0) { System.out.println(0); } else { System.out.println(ans); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int ans = c - (a - b); if (ans <= 0) { System.out.println(0); } else { System.out.println(ans); } } }
[ "identifier.change", "expression.operation.binary.change" ]
751,800
751,801
u547010320
java
p02952
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int A = in.nextInt(); int i = 10, res = 0, sign = 1; while (A >= i) { res += (i - 1) * sign; sign *= -1; i *= 10; } if (res < 0) res += A; System.out.println(res); } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int A = in.nextInt(); int i = 10, res = 0, sign = 1; while (A >= i) { res += (i - 1) * sign; sign *= -1; i *= 10; } if (res <= 0) res += A; System.out.println(res); } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
753,624
753,625
u137102614
java
p02952
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) throws IOException { new Main().solve(); } private void solve() throws IOException { try { // solveA(); solveB(); // solveC(); // solveD(); // solveE(); // solveF(); } finally { if (in != null) { in.close(); } if (out != null) { out.flush(); out.close(); } } } private void solveA() { int a = nextInt(); int b = nextInt(); int c = nextInt(); out.println((c - (a - b)) > 0 ? (c - (a - b)) : 0); } private void solveB() { int n = nextInt(); int res = 0; for (int i = 1; i <= 11; i++) { int cnt = 0; int num = i; while (num != 0) { cnt++; num /= 10; } if (cnt % 2 != 0) res++; } out.println(res); } private void solveC() { int n = nextInt(); out.println(""); } private void solveD() { int n = nextInt(); out.println(""); } private void solveE() { int n = nextInt(); out.println(""); } private void solveF() { int n = nextInt(); out.println(""); } /* * 階乗計算の最大値 * もっと大きいのが必要ならここを修正 */ private final int FACTORIAL_NUM = 111111; /* * 階乗の事前計算(mod 済) */ private long[] factorial = new long[FACTORIAL_NUM]; /* * 逆数の事前計算(mod 済) */ private long[] reverseFactorial = new long[FACTORIAL_NUM]; private boolean isInitFactorial = false; /** * 階乗計算の事前累積和 * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM] * mod済 */ private void initFactorial(long mod) { factorial[0] = 1; for (int i = 1; i < FACTORIAL_NUM; i++) { factorial[i] = (factorial[i - 1] * i) % mod; } } /** * 逆数の事前計算 * もっと速い方法があったので修正 */ private void initReverseFactorial(long mod) { reverseFactorial[FACTORIAL_NUM - 1] = modInverse(factorial[FACTORIAL_NUM - 1], mod); for (int i = FACTORIAL_NUM - 2; i >= 0; i++) { /* * 以下を利用する。 * これにより毎回modInverseしなくてよくなる * (N!)^(-1) * N -> ((N - 1)!)^(-1) * (N-1!)^(-1) * N -> ((N - 2)!)^(-1) */ reverseFactorial[i] = (reverseFactorial[i + 1] * (i + 1)) % mod; } // reverseFactorial[0] = 1; // for (int i = 0; i < FACTORIAL_NUM; i++) { // reverseFactorial[i] = modInverse(factorial[i], mod); // } } /** * フェルマーの小定理を用いて逆元を求める。 * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2) * 繰り返し二乗法を用いて計算する。 * http://satanic0258.hatenablog.com/entry/2016/04/29/004730 * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか? * @param x * @return */ private long modInverse(long x, long mod) { long res = 1L; long k = mod - 2L; long y = x; while (k != 0) { if (k % 2 != 0) { res = (res * y) % mod; } y = (y * y) % mod; k /= 2; } return res; } private void initFactorialCalc(long mod) { if (isInitFactorial) { //初期化済みならreturn return; } //階乗の事前計算 initFactorial(mod); //逆数の計算もしておく initReverseFactorial(mod); isInitFactorial = true; } /** * 組み合わせ * nCk -> n! / k!・(n-k)! * @param n * @param k * @param mod * @return */ private long combination(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } //分子の計算 long calResN = factorial[n]; //分母の計算 long calResNK = reverseFactorial[n - k]; long calcResK = reverseFactorial[k]; long denominator = (calResNK * calcResK) % mod; return (calResN * denominator) % mod; } /** * 順列 * nPk -> n! / (n-k)! * @param n * @param k * @return */ private long permutation(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } long calResN = factorial[n]; long calResNK = reverseFactorial[n - k]; return (calResN * calResNK) % mod; } /** * 多項係数 * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方 * n! / p!・q!・r!・s! * @param n * @param strNum * @param mod * @return */ private long multinominalCoefficient(int n, List<Integer> strNum, int mod) { initFactorialCalc(mod); long calResN = factorial[n]; long calResDenomi = 1; for (Integer num : strNum) { calResDenomi *= reverseFactorial[num]; } return (calResN * calResDenomi) % mod; } /** * 重複組合せ nHr (同次積) * nHr = (n+r-1)Cr * 異なるn個のものから重複を許してr個取る組合せの総数 * 例: * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります. * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします * @param n * @param r * @param mod * @return */ private long homogeneousProduct(int n, int r, long mod) { if (n == 0 && r == 0) { return 1; } return combination(n + r - 1, r, mod); } private final PrintWriter out = new PrintWriter(System.out); private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public int nextInt() { return Integer.parseInt(next()); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } }
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) throws IOException { new Main().solve(); } private void solve() throws IOException { try { // solveA(); solveB(); // solveC(); // solveD(); // solveE(); // solveF(); } finally { if (in != null) { in.close(); } if (out != null) { out.flush(); out.close(); } } } private void solveA() { int a = nextInt(); int b = nextInt(); int c = nextInt(); out.println((c - (a - b)) > 0 ? (c - (a - b)) : 0); } private void solveB() { int n = nextInt(); int res = 0; for (int i = 1; i <= n; i++) { int cnt = 0; int num = i; while (num != 0) { cnt++; num /= 10; } if (cnt % 2 != 0) res++; } out.println(res); } private void solveC() { int n = nextInt(); out.println(""); } private void solveD() { int n = nextInt(); out.println(""); } private void solveE() { int n = nextInt(); out.println(""); } private void solveF() { int n = nextInt(); out.println(""); } /* * 階乗計算の最大値 * もっと大きいのが必要ならここを修正 */ private final int FACTORIAL_NUM = 111111; /* * 階乗の事前計算(mod 済) */ private long[] factorial = new long[FACTORIAL_NUM]; /* * 逆数の事前計算(mod 済) */ private long[] reverseFactorial = new long[FACTORIAL_NUM]; private boolean isInitFactorial = false; /** * 階乗計算の事前累積和 * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM] * mod済 */ private void initFactorial(long mod) { factorial[0] = 1; for (int i = 1; i < FACTORIAL_NUM; i++) { factorial[i] = (factorial[i - 1] * i) % mod; } } /** * 逆数の事前計算 * もっと速い方法があったので修正 */ private void initReverseFactorial(long mod) { reverseFactorial[FACTORIAL_NUM - 1] = modInverse(factorial[FACTORIAL_NUM - 1], mod); for (int i = FACTORIAL_NUM - 2; i >= 0; i++) { /* * 以下を利用する。 * これにより毎回modInverseしなくてよくなる * (N!)^(-1) * N -> ((N - 1)!)^(-1) * (N-1!)^(-1) * N -> ((N - 2)!)^(-1) */ reverseFactorial[i] = (reverseFactorial[i + 1] * (i + 1)) % mod; } // reverseFactorial[0] = 1; // for (int i = 0; i < FACTORIAL_NUM; i++) { // reverseFactorial[i] = modInverse(factorial[i], mod); // } } /** * フェルマーの小定理を用いて逆元を求める。 * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2) * 繰り返し二乗法を用いて計算する。 * http://satanic0258.hatenablog.com/entry/2016/04/29/004730 * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか? * @param x * @return */ private long modInverse(long x, long mod) { long res = 1L; long k = mod - 2L; long y = x; while (k != 0) { if (k % 2 != 0) { res = (res * y) % mod; } y = (y * y) % mod; k /= 2; } return res; } private void initFactorialCalc(long mod) { if (isInitFactorial) { //初期化済みならreturn return; } //階乗の事前計算 initFactorial(mod); //逆数の計算もしておく initReverseFactorial(mod); isInitFactorial = true; } /** * 組み合わせ * nCk -> n! / k!・(n-k)! * @param n * @param k * @param mod * @return */ private long combination(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } //分子の計算 long calResN = factorial[n]; //分母の計算 long calResNK = reverseFactorial[n - k]; long calcResK = reverseFactorial[k]; long denominator = (calResNK * calcResK) % mod; return (calResN * denominator) % mod; } /** * 順列 * nPk -> n! / (n-k)! * @param n * @param k * @return */ private long permutation(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } long calResN = factorial[n]; long calResNK = reverseFactorial[n - k]; return (calResN * calResNK) % mod; } /** * 多項係数 * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方 * n! / p!・q!・r!・s! * @param n * @param strNum * @param mod * @return */ private long multinominalCoefficient(int n, List<Integer> strNum, int mod) { initFactorialCalc(mod); long calResN = factorial[n]; long calResDenomi = 1; for (Integer num : strNum) { calResDenomi *= reverseFactorial[num]; } return (calResN * calResDenomi) % mod; } /** * 重複組合せ nHr (同次積) * nHr = (n+r-1)Cr * 異なるn個のものから重複を許してr個取る組合せの総数 * 例: * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります. * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします * @param n * @param r * @param mod * @return */ private long homogeneousProduct(int n, int r, long mod) { if (n == 0 && r == 0) { return 1; } return combination(n + r - 1, r, mod); } private final PrintWriter out = new PrintWriter(System.out); private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public int nextInt() { return Integer.parseInt(next()); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
754,214
754,215
u345932819
java
p02952
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) throws IOException { new Main().solve(); } private void solve() throws IOException { try { // solveA(); solveB(); // solveC(); // solveD(); // solveE(); // solveF(); } finally { if (in != null) { in.close(); } if (out != null) { out.flush(); out.close(); } } } private void solveA() { int a = nextInt(); int b = nextInt(); int c = nextInt(); out.println((c - (a - b)) > 0 ? (c - (a - b)) : 0); } private void solveB() { int n = nextInt(); int res = 0; for (int i = 0; i < 100000; i++) { int cnt = 0; int num = i; while (num != 0) { cnt++; num /= 10; } if (cnt % 2 != 0) res++; } out.println(res); } private void solveC() { int n = nextInt(); out.println(""); } private void solveD() { int n = nextInt(); out.println(""); } private void solveE() { int n = nextInt(); out.println(""); } private void solveF() { int n = nextInt(); out.println(""); } /* * 階乗計算の最大値 * もっと大きいのが必要ならここを修正 */ private final int FACTORIAL_NUM = 111111; /* * 階乗の事前計算(mod 済) */ private long[] factorial = new long[FACTORIAL_NUM]; /* * 逆数の事前計算(mod 済) */ private long[] reverseFactorial = new long[FACTORIAL_NUM]; private boolean isInitFactorial = false; /** * 階乗計算の事前累積和 * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM] * mod済 */ private void initFactorial(long mod) { factorial[0] = 1; for (int i = 1; i < FACTORIAL_NUM; i++) { factorial[i] = (factorial[i - 1] * i) % mod; } } /** * 逆数の事前計算 * もっと速い方法があったので修正 */ private void initReverseFactorial(long mod) { reverseFactorial[FACTORIAL_NUM - 1] = modInverse(factorial[FACTORIAL_NUM - 1], mod); for (int i = FACTORIAL_NUM - 2; i >= 0; i++) { /* * 以下を利用する。 * これにより毎回modInverseしなくてよくなる * (N!)^(-1) * N -> ((N - 1)!)^(-1) * (N-1!)^(-1) * N -> ((N - 2)!)^(-1) */ reverseFactorial[i] = (reverseFactorial[i + 1] * (i + 1)) % mod; } // reverseFactorial[0] = 1; // for (int i = 0; i < FACTORIAL_NUM; i++) { // reverseFactorial[i] = modInverse(factorial[i], mod); // } } /** * フェルマーの小定理を用いて逆元を求める。 * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2) * 繰り返し二乗法を用いて計算する。 * http://satanic0258.hatenablog.com/entry/2016/04/29/004730 * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか? * @param x * @return */ private long modInverse(long x, long mod) { long res = 1L; long k = mod - 2L; long y = x; while (k != 0) { if (k % 2 != 0) { res = (res * y) % mod; } y = (y * y) % mod; k /= 2; } return res; } private void initFactorialCalc(long mod) { if (isInitFactorial) { //初期化済みならreturn return; } //階乗の事前計算 initFactorial(mod); //逆数の計算もしておく initReverseFactorial(mod); isInitFactorial = true; } /** * 組み合わせ * nCk -> n! / k!・(n-k)! * @param n * @param k * @param mod * @return */ private long combination(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } //分子の計算 long calResN = factorial[n]; //分母の計算 long calResNK = reverseFactorial[n - k]; long calcResK = reverseFactorial[k]; long denominator = (calResNK * calcResK) % mod; return (calResN * denominator) % mod; } /** * 順列 * nPk -> n! / (n-k)! * @param n * @param k * @return */ private long permutation(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } long calResN = factorial[n]; long calResNK = reverseFactorial[n - k]; return (calResN * calResNK) % mod; } /** * 多項係数 * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方 * n! / p!・q!・r!・s! * @param n * @param strNum * @param mod * @return */ private long multinominalCoefficient(int n, List<Integer> strNum, int mod) { initFactorialCalc(mod); long calResN = factorial[n]; long calResDenomi = 1; for (Integer num : strNum) { calResDenomi *= reverseFactorial[num]; } return (calResN * calResDenomi) % mod; } /** * 重複組合せ nHr (同次積) * nHr = (n+r-1)Cr * 異なるn個のものから重複を許してr個取る組合せの総数 * 例: * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります. * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします * @param n * @param r * @param mod * @return */ private long homogeneousProduct(int n, int r, long mod) { if (n == 0 && r == 0) { return 1; } return combination(n + r - 1, r, mod); } private final PrintWriter out = new PrintWriter(System.out); private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public int nextInt() { return Integer.parseInt(next()); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } }
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) throws IOException { new Main().solve(); } private void solve() throws IOException { try { // solveA(); solveB(); // solveC(); // solveD(); // solveE(); // solveF(); } finally { if (in != null) { in.close(); } if (out != null) { out.flush(); out.close(); } } } private void solveA() { int a = nextInt(); int b = nextInt(); int c = nextInt(); out.println((c - (a - b)) > 0 ? (c - (a - b)) : 0); } private void solveB() { int n = nextInt(); int res = 0; for (int i = 1; i <= n; i++) { int cnt = 0; int num = i; while (num != 0) { cnt++; num /= 10; } if (cnt % 2 != 0) res++; } out.println(res); } private void solveC() { int n = nextInt(); out.println(""); } private void solveD() { int n = nextInt(); out.println(""); } private void solveE() { int n = nextInt(); out.println(""); } private void solveF() { int n = nextInt(); out.println(""); } /* * 階乗計算の最大値 * もっと大きいのが必要ならここを修正 */ private final int FACTORIAL_NUM = 111111; /* * 階乗の事前計算(mod 済) */ private long[] factorial = new long[FACTORIAL_NUM]; /* * 逆数の事前計算(mod 済) */ private long[] reverseFactorial = new long[FACTORIAL_NUM]; private boolean isInitFactorial = false; /** * 階乗計算の事前累積和 * [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM] * mod済 */ private void initFactorial(long mod) { factorial[0] = 1; for (int i = 1; i < FACTORIAL_NUM; i++) { factorial[i] = (factorial[i - 1] * i) % mod; } } /** * 逆数の事前計算 * もっと速い方法があったので修正 */ private void initReverseFactorial(long mod) { reverseFactorial[FACTORIAL_NUM - 1] = modInverse(factorial[FACTORIAL_NUM - 1], mod); for (int i = FACTORIAL_NUM - 2; i >= 0; i++) { /* * 以下を利用する。 * これにより毎回modInverseしなくてよくなる * (N!)^(-1) * N -> ((N - 1)!)^(-1) * (N-1!)^(-1) * N -> ((N - 2)!)^(-1) */ reverseFactorial[i] = (reverseFactorial[i + 1] * (i + 1)) % mod; } // reverseFactorial[0] = 1; // for (int i = 0; i < FACTORIAL_NUM; i++) { // reverseFactorial[i] = modInverse(factorial[i], mod); // } } /** * フェルマーの小定理を用いて逆元を求める。 * ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2) * 繰り返し二乗法を用いて計算する。 * http://satanic0258.hatenablog.com/entry/2016/04/29/004730 * {@link BigInteger#modInverse(BigInteger)}とどちらが速いか? * @param x * @return */ private long modInverse(long x, long mod) { long res = 1L; long k = mod - 2L; long y = x; while (k != 0) { if (k % 2 != 0) { res = (res * y) % mod; } y = (y * y) % mod; k /= 2; } return res; } private void initFactorialCalc(long mod) { if (isInitFactorial) { //初期化済みならreturn return; } //階乗の事前計算 initFactorial(mod); //逆数の計算もしておく initReverseFactorial(mod); isInitFactorial = true; } /** * 組み合わせ * nCk -> n! / k!・(n-k)! * @param n * @param k * @param mod * @return */ private long combination(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } //分子の計算 long calResN = factorial[n]; //分母の計算 long calResNK = reverseFactorial[n - k]; long calcResK = reverseFactorial[k]; long denominator = (calResNK * calcResK) % mod; return (calResN * denominator) % mod; } /** * 順列 * nPk -> n! / (n-k)! * @param n * @param k * @return */ private long permutation(int n, int k, long mod) { initFactorialCalc(mod); if (k < 0 || n < k) { return 0; } long calResN = factorial[n]; long calResNK = reverseFactorial[n - k]; return (calResN * calResNK) % mod; } /** * 多項係数 * 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方 * n! / p!・q!・r!・s! * @param n * @param strNum * @param mod * @return */ private long multinominalCoefficient(int n, List<Integer> strNum, int mod) { initFactorialCalc(mod); long calResN = factorial[n]; long calResDenomi = 1; for (Integer num : strNum) { calResDenomi *= reverseFactorial[num]; } return (calResN * calResDenomi) % mod; } /** * 重複組合せ nHr (同次積) * nHr = (n+r-1)Cr * 異なるn個のものから重複を許してr個取る組合せの総数 * 例: * リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります. * このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします * @param n * @param r * @param mod * @return */ private long homogeneousProduct(int n, int r, long mod) { if (n == 0 && r == 0) { return 1; } return combination(n + r - 1, r, mod); } private final PrintWriter out = new PrintWriter(System.out); private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public int nextInt() { return Integer.parseInt(next()); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } }
[ "literal.number.integer.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.loop.for.condition.change" ]
754,216
754,215
u345932819
java
p02952
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int count = 0; for (int i = 1; i <= x; i++) { String temp = String.valueOf(i); if (temp.length() % 2 == 0) count++; } System.out.println(count); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int count = 0; for (int i = 1; i <= x; i++) { String temp = String.valueOf(i); if (temp.length() % 2 != 0) count++; } System.out.println(count); } }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
754,371
754,372
u240764465
java
p02953
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = scanner.nextInt(); int[] arr = new int[N]; arr[0] = scanner.nextInt() - 1; for (int i = 1; i < N; i++) { int next = scanner.nextInt(); if (next > arr[i - 1]) arr[i] = next - 1; else arr[i] = next; } boolean bad = false; for (int i = 1; i < N; i++) { if (arr[i - 1] > arr[i]) bad = true; } if (bad) out.println("NO"); else out.println("YES"); out.flush(); } public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(Reader in) { br = new BufferedReader(in); } public FastScanner() { this(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String readNextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner scanner = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = scanner.nextInt(); int[] arr = new int[N]; arr[0] = scanner.nextInt() - 1; for (int i = 1; i < N; i++) { int next = scanner.nextInt(); if (next > arr[i - 1]) arr[i] = next - 1; else arr[i] = next; } boolean bad = false; for (int i = 1; i < N; i++) { if (arr[i - 1] > arr[i]) bad = true; } if (bad) out.println("No"); else out.println("Yes"); out.flush(); } public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(Reader in) { br = new BufferedReader(in); } public FastScanner() { this(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String readNextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
758,009
758,010
u227307124
java
p02958
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; int flg = 0; String ans = "No"; for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); if (p[i] != i + 1) { flg += 1; } } if (flg == 0 || flg == 2) { ans = "Yes"; } System.out.println(ans); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; int flg = 0; String ans = "NO"; for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); if (p[i] != i + 1) { flg += 1; } } if (flg == 0 || flg == 2) { ans = "YES"; } System.out.println(ans); } }
[ "literal.string.change", "literal.string.case.change", "variable_declaration.value.change", "assignment.value.change" ]
763,464
763,465
u229120147
java
p02958
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; for (int i = 0; i < p.length; i++) { p[i] = sc.nextInt(); } int check = 0; for (int i = 0; i < p.length; i++) { if (p[i] != i + 1) { check++; } } if (check == 2 || check == 0) { System.out.println("Yes"); } else { System.out.println("No"); } sc.close(); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; for (int i = 0; i < p.length; i++) { p[i] = sc.nextInt(); } int check = 0; for (int i = 0; i < p.length; i++) { if (p[i] != i + 1) { check++; } } if (check == 2 || check == 0) { System.out.println("YES"); } else { System.out.println("NO"); } sc.close(); } }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
763,558
763,559
u988234231
java
p02958
import java.util.Scanner; public class Main { public static void main(String args[]) throws Exception { Scanner s = new Scanner(System.in); int N = s.nextInt(); // Reading input from STDIN int i = 1; String result = "YES"; int count = 0; while (i++ <= N) { int p = s.nextInt(); count += i != p ? 1 : 0; if (count > 2) { result = "NO"; break; } } System.out.println(result); } }
import java.util.Scanner; public class Main { public static void main(String args[]) throws Exception { Scanner s = new Scanner(System.in); int N = s.nextInt(); // Reading input from STDIN int i = 1; String result = "YES"; int count = 0; while (i <= N) { int p = s.nextInt(); count += i != p ? 1 : 0; if (count > 2) { result = "NO"; break; } i++; } System.out.println(result); } }
[ "control_flow.loop.condition.change", "expression.unary.arithmetic.add" ]
765,292
765,293
u650659913
java
p02959
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); Integer[] a = new Integer[n + 1]; Integer[] b = new Integer[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } int ans = 0; int zan = a[0]; for (int i = 0; i < n; i++) { if (zan < b[i]) { b[i] -= zan; ans += zan; if (a[i + 1] < b[i]) { ans += a[i + 1]; zan = 0; } else { ans += b[i]; zan = a[i + 1] - b[i]; } } else { ans += b[i]; zan = a[i + 1]; } } System.out.println(ans); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); Integer[] a = new Integer[n + 1]; Integer[] b = new Integer[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } long ans = 0; int zan = a[0]; for (int i = 0; i < n; i++) { if (zan < b[i]) { b[i] -= zan; ans += zan; if (a[i + 1] < b[i]) { ans += a[i + 1]; zan = 0; } else { ans += b[i]; zan = a[i + 1] - b[i]; } } else { ans += b[i]; zan = a[i + 1]; } } System.out.println(ans); } } }
[ "variable_declaration.type.primitive.change" ]
766,957
766,958
u325942975
java
p02959
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; n = sc.nextInt(); int[] a = new int[n + 1]; int[] b = new int[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } int ans = 0; for (int i = 0; i < n; i++) { if (a[i] >= b[i]) { ans += b[i]; } else { ans += a[i]; int zan = b[i] - a[i]; if (a[i + 1] >= zan) { ans += zan; a[i + 1] -= zan; } else if (a[i + 1] < zan) { ans += a[i + 1]; a[i + 1] = 0; } } } System.out.println(ans); sc.close(); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; n = sc.nextInt(); int[] a = new int[n + 1]; int[] b = new int[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } long ans = 0; for (int i = 0; i < n; i++) { if (a[i] >= b[i]) { ans += b[i]; } else { ans += a[i]; int zan = b[i] - a[i]; if (a[i + 1] >= zan) { ans += zan; a[i + 1] -= zan; } else if (a[i + 1] < zan) { ans += a[i + 1]; a[i + 1] = 0; } } } System.out.println(ans); sc.close(); } }
[ "variable_declaration.type.primitive.change" ]
766,959
766,960
u325942975
java
p02959
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int[] arrayA = new int[a + 1]; int[] arrayB = new int[a]; for (int i = 0; i < a + 1; i++) { arrayA[i] = sc.nextInt(); } for (int i = 0; i < a; i++) { arrayB[i] = sc.nextInt(); } int sum = 0; for (int i = 0; i < a; i++) { long n = Math.min(arrayA[i], arrayB[i]); sum += n; arrayA[i] -= n; arrayB[i] -= n; n = Math.min(arrayA[i + 1], arrayB[i]); sum += n; arrayA[i + 1] -= n; arrayB[i] -= n; } System.out.println(sum); } }
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int[] arrayA = new int[a + 1]; int[] arrayB = new int[a]; for (int i = 0; i < a + 1; i++) { arrayA[i] = sc.nextInt(); } for (int i = 0; i < a; i++) { arrayB[i] = sc.nextInt(); } long sum = 0; for (int i = 0; i < a; i++) { long n = Math.min(arrayA[i], arrayB[i]); sum += n; arrayA[i] -= n; arrayB[i] -= n; n = Math.min(arrayA[i + 1], arrayB[i]); sum += n; arrayA[i + 1] -= n; arrayB[i] -= n; } System.out.println(sum); } }
[ "variable_declaration.type.primitive.change" ]
767,148
767,149
u920694585
java
p02959
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n + 1]; int b[] = new int[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } int answer = 0; for (int i = 0; i < n; i++) { answer = answer + Math.min(a[i], b[i]); b[i] = Math.max(b[i] - a[i], 0); if (b[i] > 0) { answer = answer + Math.min(a[i + 1], b[i]); a[i + 1] = Math.max(a[i + 1] - b[i], 0); } } System.out.println(answer); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n + 1]; int b[] = new int[n]; for (int i = 0; i < n + 1; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { b[i] = sc.nextInt(); } long answer = 0; for (int i = 0; i < n; i++) { answer = answer + Math.min(a[i], b[i]); b[i] = Math.max(b[i] - a[i], 0); if (b[i] > 0) { answer = answer + Math.min(a[i + 1], b[i]); a[i + 1] = Math.max(a[i + 1] - b[i], 0); } } System.out.println(answer); } }
[ "variable_declaration.type.primitive.change" ]
767,401
767,402
u167206842
java
p02970
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int D = sc.nextInt(); sc.close(); System.out.println((N + D) / (D * 2)); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int D = sc.nextInt(); sc.close(); System.out.println((N + D * 2) / (D * 2 + 1)); } }
[ "expression.operation.binary.add" ]
773,649
773,650
u176590289
java
p02971
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //数字列 ArrayList<Integer> a = new ArrayList<>(); for (int i = 0; i < n; i++) { a.add(sc.nextInt()); } ArrayList<Integer> b = new ArrayList<>(a); Collections.sort(b); int max = Collections.max(b); for (int i = 0; i < n; i++) { if (max == a.get(i)) { System.out.println(b.get(1)); } else { System.out.println(max); } } sc.close(); } }
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //数字列 ArrayList<Integer> a = new ArrayList<>(); for (int i = 0; i < n; i++) { a.add(sc.nextInt()); } ArrayList<Integer> b = new ArrayList<>(a); Collections.sort(b, Collections.reverseOrder()); int max = Collections.max(b); for (int i = 0; i < n; i++) { if (max == a.get(i)) { System.out.println(b.get(1)); } else { System.out.println(max); } } sc.close(); } }
[ "call.arguments.add" ]
775,220
775,221
u083824251
java
p02972
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 2]; int[] x = new int[n + 2]; for (int i = 1; i < n + 1; i++) { a[i] = sc.nextInt(); x[i] = 0; } int count = 0; int sum = 0; List<Integer> b = new ArrayList<>(); for (int i = n; i > 0; i--) { sum = 0; for (int j = 2; j < n - 1; j++) { if (j * i > n) { break; } else { sum = sum + x[i * j]; } } sum = sum % 2; if (sum != a[i]) { x[i] = 1; b.add(i); } } System.out.println(b.size()); for (int i = 0; i < b.size(); i++) { if (i == b.size() - 1) { System.out.println(b.get(i)); } else { System.out.print(String.valueOf(b.get(i)) + " "); } } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n + 2]; int[] x = new int[n + 2]; for (int i = 1; i < n + 1; i++) { a[i] = sc.nextInt(); x[i] = 0; } int count = 0; int sum = 0; List<Integer> b = new ArrayList<>(); for (int i = n; i > 0; i--) { sum = 0; for (int j = 2; j < n + 1; j++) { if (j * i > n) { break; } else { sum = sum + x[i * j]; } } sum = sum % 2; if (sum != a[i]) { x[i] = 1; b.add(i); } } System.out.println(b.size()); for (int i = 0; i < b.size(); i++) { if (i == b.size() - 1) { System.out.println(b.get(i)); } else { System.out.print(String.valueOf(b.get(i)) + " "); } } } }
[ "misc.opposites", "expression.operator.arithmetic.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
778,772
778,773
u801144528
java
p02972
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); int b, c, d, e, f, k, l, m, n, x, y, z; int[] a; int[] ans; Main() { // 整数の入力 n = sc.nextInt(); a = new int[n + 1]; ans = new int[n + 1]; for (int i = 1; i <= n; i++) { a[i] = sc.nextInt(); } for (int s = n; s > 0; s--) { for (int t = s * 2; t < n; t += s) { ans[s] += ans[t]; } ans[s] = ans[s] % 2 == a[s] ? 0 : 1; } // 出力 for (int i = 1; i <= n; i++) m += ans[i]; System.out.println(m); for (int i = 1; i <= n; i++) if (ans[i] == 1) System.out.print(i + " "); } public static void main(String[] args) { new Main(); } }
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); int b, c, d, e, f, k, l, m, n, x, y, z; int[] a; int[] ans; Main() { // 整数の入力 n = sc.nextInt(); a = new int[n + 1]; ans = new int[n + 1]; for (int i = 1; i <= n; i++) { a[i] = sc.nextInt(); } for (int s = n; s > 0; s--) { for (int t = s * 2; t <= n; t += s) { ans[s] += ans[t]; } ans[s] = ans[s] % 2 == a[s] ? 0 : 1; } // 出力 for (int i = 1; i <= n; i++) m += ans[i]; System.out.println(m); for (int i = 1; i <= n; i++) if (ans[i] == 1) System.out.print(i + " "); } public static void main(String[] args) { new Main(); } }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
779,860
779,861
u280715164
java
p02973
import java.util.*; public class Main { public static void main(String[] args) { Main main = new Main(); main.run(); } public void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } ArrayList<Integer> d = new ArrayList<>(); d.add(a[0]); for (int i = 1; i < n; i++) { if (d.get(d.size() - 1) >= a[i]) { d.add(a[i]); } else { int l = -1; int r = d.size(); while (l + 1 < r) { int mid = (l + r) / 2; if (d.get(mid) > a[i]) { l = mid; } else { r = mid; } } d.set(l + 1, a[i]); } } System.out.println(d.size()); sc.close(); } }
import java.util.*; public class Main { public static void main(String[] args) { Main main = new Main(); main.run(); } public void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } ArrayList<Integer> d = new ArrayList<>(); d.add(a[0]); for (int i = 1; i < n; i++) { if (d.get(d.size() - 1) >= a[i]) { d.add(a[i]); } else { int l = -1; int r = d.size(); while (l + 1 < r) { int mid = (l + r) / 2; if (d.get(mid) < a[i]) { r = mid; } else { l = mid; } } d.set(l + 1, a[i]); } } System.out.println(d.size()); sc.close(); } }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.variable.change", "identifier.change" ]
780,917
780,918
u235169423
java
p02981
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); int costTrain = n * a; int costTaxi = n; if (costTrain <= costTaxi) { System.out.println(costTrain); } else { System.out.println(costTaxi); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); int costTrain = n * a; int costTaxi = b; if (costTrain <= costTaxi) { System.out.println(costTrain); } else { System.out.println(costTaxi); } } }
[ "variable_declaration.value.change", "identifier.change" ]
785,307
785,308
u795990458
java
p02981
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); int costTrain = n * a; int costTaxi = n * b; if (costTrain <= costTaxi) { System.out.println(costTrain); } else { System.out.println(costTaxi); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); int costTrain = n * a; int costTaxi = b; if (costTrain <= costTaxi) { System.out.println(costTrain); } else { System.out.println(costTaxi); } } }
[ "expression.operation.binary.remove" ]
785,309
785,308
u795990458
java
p02983
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = 2019; int l = sc.nextInt(); int r = sc.nextInt(); int lm = l % m; int rm = r % m; int ld = l / m; int rd = r / m; int minl = Integer.MAX_VALUE; boolean isLap = rd - ld > 0; if (lm == 0 || rm == 0 || isLap) { minl = 0; } else { for (int i = lm; i <= rm; i++) { for (int j = lm + 1; j <= rm; j++) { int tmp = (i * j) % m; if (minl > tmp) { minl = tmp; } } } } System.out.println(minl); } }
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = 2019; int l = sc.nextInt(); int r = sc.nextInt(); int lm = l % m; int rm = r % m; int ld = l / m; int rd = r / m; int minl = Integer.MAX_VALUE; boolean isLap = rd - ld > 0; if (lm == 0 || rm == 0 || isLap) { minl = 0; } else { for (int i = lm; i < rm; i++) { for (int j = lm + 1; j <= rm; j++) { int tmp = (i * j) % m; if (minl > tmp) { minl = tmp; } } } } System.out.println(minl); } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
788,584
788,585
u452505906
java
p02983
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long a = scan.nextLong(); long b = scan.nextLong(); long diff = b - a; if (diff >= 2019) { System.out.println(2); } else { long min = Integer.MAX_VALUE; HashMap<Long, Integer> ab = new HashMap(); for (long i = a; i <= b; i++) { ab.putIfAbsent(i % 2019, 1); } ArrayList<Long> list = new ArrayList<>(ab.keySet()); for (int i = 0; i < list.size(); i++) { for (int j = i + 1; j < list.size(); j++) { min = Math.min((list.get(i) * list.get(j)) % 2019, min); } } System.out.println(min); } } }
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long a = scan.nextLong(); long b = scan.nextLong(); long diff = b - a; if (diff >= 2019) { System.out.println(0); } else { long min = Integer.MAX_VALUE; HashMap<Long, Integer> ab = new HashMap(); for (long i = a; i <= b; i++) { ab.putIfAbsent(i % 2019, 1); } ArrayList<Long> list = new ArrayList<>(ab.keySet()); for (int i = 0; i < list.size(); i++) { for (int j = i + 1; j < list.size(); j++) { min = Math.min((list.get(i) * list.get(j)) % 2019, min); } } System.out.println(min); } } }
[ "literal.number.integer.change", "call.arguments.change", "io.output.change" ]
790,909
790,910
u860782770
java
p02984
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int ar[] = new int[n]; for (int i = 0; i < n; i++) { ar[i] = 2 * scan.nextInt(); } int sum = 0; for (int i = 0; i < n; i++) { if (i % 2 == 1) { sum -= ar[i]; } else { sum += ar[i]; } } sum /= 2; System.out.print(sum + " "); for (int i = 0; i < n - 1; i++) { int x = ar[i] - sum; System.out.print(x + " "); sum = x; } } }
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long ar[] = new long[n]; for (int i = 0; i < n; i++) { ar[i] = 2 * scan.nextLong(); } long sum = 0; for (int i = 0; i < n; i++) { if (i % 2 == 1) { sum -= ar[i]; } else { sum += ar[i]; } } sum /= 2; System.out.print(sum + " "); for (int i = 0; i < n - 1; i++) { long x = ar[i] - sum; System.out.print(x + " "); sum = x; } } }
[ "variable_declaration.type.primitive.change", "assignment.value.change", "identifier.change", "call.function.change", "expression.operation.binary.change" ]
792,214
792,215
u999238730
java
p02987
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); if (S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(0) != S.charAt(2)) { System.out.println("YES"); } else if (S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(0) != S.charAt(1)) { System.out.println("YES"); } else if (S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1)) { System.out.println("YES"); } else { System.out.println("NO"); } } }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); if (S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(0) != S.charAt(2)) { System.out.println("Yes"); } else if (S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(0) != S.charAt(1)) { System.out.println("Yes"); } else if (S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1)) { System.out.println("Yes"); } else { System.out.println("No"); } } }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
794,829
794,830
u319039941
java
p02987
import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { String S = scanner.next(); Map<String, List<String>> collect = Stream.of(S.split("")) .collect(Collectors.groupingBy(Function.identity())); if (collect.keySet().size() != 2) { System.out.println("false"); } else if (collect.values().stream().anyMatch(l -> l.size() != 2)) { System.out.println("false"); } else { System.out.println("true"); } } } }
import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { String S = scanner.next(); Map<String, List<String>> collect = Stream.of(S.split("")) .collect(Collectors.groupingBy(Function.identity())); if (collect.keySet().size() != 2) { System.out.println("No"); } else if (collect.values().stream().anyMatch(l -> l.size() != 2)) { System.out.println("No"); } else { System.out.println("Yes"); } } } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
795,024
795,025
u001322591
java
p02988
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); int[] p = new int[n]; for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); } int cnt = 0; for (int i = 1; i < n - 1; i++) { if (p[i - 1] < p[i] && p[i] > p[i + 1]) { cnt++; } else if (p[i - 1] > p[i] && p[i] > p[i + 1]) { cnt++; } } System.out.println(cnt); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int n = sc.nextInt(); int[] p = new int[n]; for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); } int cnt = 0; for (int i = 1; i < n - 1; i++) { if (p[i - 1] < p[i] && p[i] < p[i + 1]) { cnt++; } else if (p[i - 1] > p[i] && p[i] > p[i + 1]) { cnt++; } } System.out.println(cnt); } } }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
795,753
795,754
u423952743
java
p02990
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); sc.close(); long m = 1000000007; PrintWriter pw = new PrintWriter(System.out); long a = n - k + 1; long b = k - 1; long val1 = a; long val2 = b; long ans = val1; pw.println(ans); for (int i = 2; i <= k; i++) { val1 = val1 * (a - i + 1) % m; val1 = val1 * modinv(i, m) % m; val2 = val2 * (b - i + 1) % m; val2 = val2 * modinv(i - 1, m) % m; if (val2 == 0) val2 = 1; ans = val1 * val2 % m; pw.println(ans); } pw.flush(); } static long modinv(long a, long m) { long b = m; long u = 1; long v = 0; long tmp = 0; while (b > 0) { long t = a / b; a -= t * b; tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } }
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); sc.close(); long m = 1000000007; PrintWriter pw = new PrintWriter(System.out); long a = n - k + 1; long b = k; long val1 = a; long val2 = 1; long ans = val1; pw.println(ans); for (int i = 2; i <= k; i++) { val1 = val1 * (a - i + 1) % m; val1 = val1 * modinv(i, m) % m; val2 = val2 * (b - i + 1) % m; val2 = val2 * modinv(i - 1, m) % m; if (val2 == 0) val2 = 1; ans = val1 * val2 % m; pw.println(ans); } pw.flush(); } static long modinv(long a, long m) { long b = m; long u = 1; long v = 0; long tmp = 0; while (b > 0) { long t = a / b; a -= t * b; tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } }
[ "expression.operation.binary.remove", "variable_declaration.value.change", "identifier.replace.remove", "literal.replace.add" ]
798,990
798,991
u522636435
java
p02993
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char[] chars = s.toCharArray(); String ans = "Good"; for (int i = 0; i < 2; i++) { if (chars[i] == chars[i + 1]) { ans = "Bad"; break; } } System.out.println(ans); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char[] chars = s.toCharArray(); String ans = "Good"; for (int i = 0; i < 3; i++) { if (chars[i] == chars[i + 1]) { ans = "Bad"; break; } } System.out.println(ans); } }
[ "literal.number.integer.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
802,147
802,148
u978153700
java
p02995
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(System.out); long a = in.nextLong(), b = in.nextLong(), c = in.nextLong(), d = in.nextLong(); long gcd = gcd(c, d); long right = b - ((b / c) + (b / d)) + (b / (c * d / gcd)); long left = a - 1 - (((a - 1) / c) + ((a - 1) / d)) - ((a - 1) / (c * d / gcd)); out.println(right - left); out.close(); } public static long gcd(long a, long b) { if (a == 0 || b == 0) return b + a; else return gcd(b, a % b); } }
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(System.out); long a = in.nextLong(), b = in.nextLong(), c = in.nextLong(), d = in.nextLong(); long gcd = gcd(c, d); long right = b - (b / c + b / d) + (b / (c * d / gcd)); long left = a - 1 - (((a - 1) / c) + ((a - 1) / d)) + ((a - 1) / (c * d / gcd)); out.println(right - left); out.close(); } public static long gcd(long a, long b) { if (a == 0 || b == 0) return b + a; else return gcd(b, a % b); } }
[ "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
805,699
805,700
u074951765
java
p02995
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = Long.parseLong(sc.next()); long b = Long.parseLong(sc.next()); long c = Long.parseLong(sc.next()); long d = Long.parseLong(sc.next()); long cBaisuIndex = a / c; if (a % c != 0) { cBaisuIndex++; } long cMaxIndex = b / c + 1; long dBaisuIndex = a / d; if (a % d != 0) { dBaisuIndex++; } long dMaxIndex = b / d + 1; long koyakusu = 0; koyakusu = getMaxKoyakusu(c, d); long cdBaisuIndex = a / koyakusu; if (a % koyakusu != 0) { cdBaisuIndex++; } long cdMaxIndex = b / koyakusu + 1; long ab = b - a + 1; long ret = ab - (cMaxIndex - cBaisuIndex) - (dMaxIndex - dBaisuIndex) + (cdMaxIndex - cdBaisuIndex); System.out.print(ret); } public static long getMaxKoyakusu(long a, long b) { long temp; long c = a; c *= b; while ((temp = (long)a % b) != 0) { a = b; b = (long)temp; } return (int)(c / b); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = Long.parseLong(sc.next()); long b = Long.parseLong(sc.next()); long c = Long.parseLong(sc.next()); long d = Long.parseLong(sc.next()); long cBaisuIndex = a / c; if (a % c != 0) { cBaisuIndex++; } long cMaxIndex = b / c + 1; long dBaisuIndex = a / d; if (a % d != 0) { dBaisuIndex++; } long dMaxIndex = b / d + 1; long koyakusu = 0; koyakusu = getMaxKoyakusu(c, d); long cdBaisuIndex = a / koyakusu; if (a % koyakusu != 0) { cdBaisuIndex++; } long cdMaxIndex = b / koyakusu + 1; long ab = b - a + 1; long ret = ab - (cMaxIndex - cBaisuIndex) - (dMaxIndex - dBaisuIndex) + (cdMaxIndex - cdBaisuIndex); System.out.print(ret); } public static long getMaxKoyakusu(long a, long b) { long temp; long c = a; c *= b; while ((temp = (long)a % b) != 0) { a = b; b = (long)temp; } return (long)(c / b); } }
[ "function.return_value.change" ]
806,283
806,284
u163859002
java
p03000
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int l[] = new int[n]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); } int total = 0; int count = 0; for (int i = 0; i < n; i++) { if (total <= x) { total += l[i]; count++; } } int sum = 0; for (int i = 0; i < n; i++) { sum += l[i]; } if (sum == x) { System.out.println(count + 1); } else { System.out.println(count); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int l[] = new int[n]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); } int total = 0; int count = 0; for (int i = 0; i < n; i++) { if (total <= x) { total += l[i]; count++; } } int sum = 0; for (int i = 0; i < n; i++) { sum += l[i]; } if (sum <= x) { System.out.println(count + 1); } else { System.out.println(count); } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
811,172
811,173
u127030911
java
p03000
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n - 1; i++) { l[i] = sc.nextInt(); } int d = 0; int count = 1; for (int i = 0; i < n;) { d = d + l[i]; if (d <= x) { count++; i++; } else { break; } } System.out.println(count); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); } int d = 0; int count = 1; for (int i = 0; i < n;) { d = d + l[i]; if (d <= x) { count++; i++; } else { break; } } System.out.println(count); } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
812,836
812,837
u719756793
java
p03000
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n - 1; i++) { l[i] = sc.nextInt(); } int d = 0; int count = 1; for (int i = 0; i < n - 1;) { d = d + l[i]; if (d <= x) { count++; i++; } else { break; } } System.out.println(count); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); } int d = 0; int count = 1; for (int i = 0; i < n;) { d = d + l[i]; if (d <= x) { count++; i++; } else { break; } } System.out.println(count); } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
812,838
812,837
u719756793
java
p03001
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int W = sc.nextInt(); int H = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); System.out.print((long)W * H / 2 + " "); boolean isOK = (double)x == (double)W / 2.0 && (double)y == (double)H / 2.0; System.out.println(isOK ? 1 : 0); } }
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int W = sc.nextInt(); int H = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); System.out.print((double)W * H / 2.0 + " "); boolean isOK = (double)x == (double)W / 2.0 && (double)y == (double)H / 2.0; System.out.println(isOK ? 1 : 0); } }
[ "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
815,883
815,884
u428922728
java
p03024
import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; public class Main { private static final StringBuilder builder = new StringBuilder(); public static void main(String[] args) throws IOException { int buf, lose = 0; while ((buf = System.in.read()) != '\n') { if (buf == 'x') lose++; } if (lose >= 8) System.out.print("YES"); else System.out.print("NO"); } private static void read() { builder.setLength(0); while (true) { try { int b = System.in.read(); if (b == ' ' || b == '\n' || b == -1) { break; } else { builder.appendCodePoint(b); } } catch (IOException e) { break; } } } private static int readInt() { read(); return Integer.parseInt(builder.toString()); } private static int readInt(int radix) { read(); return Integer.parseInt(builder.toString(), radix); } private static long readLong() { read(); return Long.parseLong(builder.toString()); } private static long readLong(int radix) { read(); return Long.parseLong(builder.toString(), radix); } private static BigInteger readBigInteger() { read(); return new BigInteger(builder.toString()); } private static BigInteger readBigInteger(int radix) { read(); return new BigInteger(builder.toString(), radix); } private static double readDouble() { read(); return Double.parseDouble(builder.toString()); } private static BigDecimal readBigDecimal() { read(); return new BigDecimal(builder.toString()); } private static float readFloat() { read(); return Float.parseFloat(builder.toString()); } private static void skipLine() { while (true) { try { int b = System.in.read(); if (b == '\n' || b == -1) { break; } } catch (IOException e) { break; } } } private static void skip() { while (true) { try { int b = System.in.read(); if (b == ' ' || b == '\n' || b == -1) break; } catch (IOException e) { break; } } } }
import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; public class Main { private static final StringBuilder builder = new StringBuilder(); public static void main(String[] args) throws IOException { int buf, lose = 0; while ((buf = System.in.read()) != '\n') { if (buf == 'x') lose++; } if (lose < 8) System.out.print("YES"); else System.out.print("NO"); } private static void read() { builder.setLength(0); while (true) { try { int b = System.in.read(); if (b == ' ' || b == '\n' || b == -1) { break; } else { builder.appendCodePoint(b); } } catch (IOException e) { break; } } } private static int readInt() { read(); return Integer.parseInt(builder.toString()); } private static int readInt(int radix) { read(); return Integer.parseInt(builder.toString(), radix); } private static long readLong() { read(); return Long.parseLong(builder.toString()); } private static long readLong(int radix) { read(); return Long.parseLong(builder.toString(), radix); } private static BigInteger readBigInteger() { read(); return new BigInteger(builder.toString()); } private static BigInteger readBigInteger(int radix) { read(); return new BigInteger(builder.toString(), radix); } private static double readDouble() { read(); return Double.parseDouble(builder.toString()); } private static BigDecimal readBigDecimal() { read(); return new BigDecimal(builder.toString()); } private static float readFloat() { read(); return Float.parseFloat(builder.toString()); } private static void skipLine() { while (true) { try { int b = System.in.read(); if (b == '\n' || b == -1) { break; } } catch (IOException e) { break; } } } private static void skip() { while (true) { try { int b = System.in.read(); if (b == ' ' || b == '\n' || b == -1) break; } catch (IOException e) { break; } } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
835,456
835,459
u097203476
java
p03030
import java.util.PriorityQueue; import java.util.Scanner; class MyClass implements Comparable<MyClass> { String s; int p; int i; @Override public int compareTo(MyClass o) { return this.s.compareTo(o.s) * 100 + Integer.compare(this.p, o.p); } } public class Main { // B Guidebook public static void main(String[] args) { int N; Scanner sc = new Scanner(System.in); N = sc.nextInt(); String[] S = new String[N]; int[] P = new int[N]; PriorityQueue<MyClass> q = new PriorityQueue<MyClass>(); for (int i = 0; i < N; i++) { MyClass m = new MyClass(); m.s = sc.next(); m.p = sc.nextInt(); m.i = i; q.add(m); } for (; !q.isEmpty();) { MyClass m = q.poll(); System.out.println(m.i); } } }
import java.util.PriorityQueue; import java.util.Scanner; class MyClass implements Comparable<MyClass> { String s; int p; int i; @Override public int compareTo(MyClass o) { return this.s.compareTo(o.s) * 100 - Integer.compare(this.p, o.p); } } public class Main { // B Guidebook public static void main(String[] args) { int N; Scanner sc = new Scanner(System.in); N = sc.nextInt(); String[] S = new String[N]; int[] P = new int[N]; PriorityQueue<MyClass> q = new PriorityQueue<MyClass>(); for (int i = 1; i <= N; i++) { MyClass m = new MyClass(); m.s = sc.next(); m.p = sc.nextInt(); m.i = i; q.add(m); } for (; !q.isEmpty();) { MyClass m = q.poll(); System.out.println(m.i); } } }
[ "misc.opposites", "expression.operator.arithmetic.change", "function.return_value.change", "expression.operation.binary.change", "literal.number.integer.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change" ]
840,131
840,132
u313805990
java
p03035
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out = new PrintWriter(System.out); try { String strData = br.readLine(); String strDat[] = strData.split(" ", -1); int intAge = Integer.parseInt(strDat[0]); int intYen = Integer.parseInt(strDat[1]); if (intAge <= 12) intYen /= 2; if (intAge <= 5) intYen /= 0; System.out.print(intYen); out.flush(); } catch (IOException e) { } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out = new PrintWriter(System.out); try { String strData = br.readLine(); String strDat[] = strData.split(" ", -1); int intAge = Integer.parseInt(strDat[0]); int intYen = Integer.parseInt(strDat[1]); if (intAge <= 12) intYen /= 2; if (intAge <= 5) intYen = 0; System.out.print(intYen); out.flush(); } catch (IOException e) { } } }
[ "assignment.value.change" ]
848,288
848,289
u836639944
java
p03036
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int D = s.nextInt(); int x = s.nextInt(); for (int i = 1; i <= 10; i++) { r = r * x - D; System.out.println(r); } } }
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int D = s.nextInt(); int x = s.nextInt(); for (int i = 1; i <= 10; i++) { x = r * x - D; System.out.println(x); } } }
[ "assignment.variable.change", "identifier.change", "call.arguments.change", "io.output.change" ]
849,341
849,342
u180899411
java
p03036
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int D = s.nextInt(); int x = s.nextInt(); for (int i = 0; i < 10; i++) { r = r * x - D; System.out.println(r); } } }
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int D = s.nextInt(); int x = s.nextInt(); for (int i = 1; i <= 10; i++) { x = r * x - D; System.out.println(x); } } }
[ "literal.number.integer.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.variable.change", "identifier.change", "call.arguments.change", "io.output.change" ]
849,343
849,342
u180899411
java
p03037
import java.util.*; public class Main { public static void main(String[] args) { int number_n, number_m, i, max_left = 0, min_right = (int)Double.POSITIVE_INFINITY, answer; Scanner sc = new Scanner(System.in); number_n = Integer.parseInt(sc.next()); number_m = Integer.parseInt(sc.next()); int[] card_left = new int[number_m]; int[] card_right = new int[number_m]; for (i = 0; i < number_m; i++) { card_left[i] = Integer.parseInt(sc.next()); card_right[i] = Integer.parseInt(sc.next()); if (card_left[i] > max_left) max_left = card_left[i]; if (card_right[i] < min_right) min_right = card_right[i]; } answer = (min_right > max_left) ? min_right - max_left + 1 : 0; System.out.println(answer); } }
import java.util.*; public class Main { public static void main(String[] args) { int number_n, number_m, i, max_left = 0, min_right = (int)Double.POSITIVE_INFINITY, answer; Scanner sc = new Scanner(System.in); number_n = Integer.parseInt(sc.next()); number_m = Integer.parseInt(sc.next()); int[] card_left = new int[number_m]; int[] card_right = new int[number_m]; for (i = 0; i < number_m; i++) { card_left[i] = Integer.parseInt(sc.next()); card_right[i] = Integer.parseInt(sc.next()); if (card_left[i] > max_left) max_left = card_left[i]; if (card_right[i] < min_right) min_right = card_right[i]; } answer = (min_right >= max_left) ? min_right - max_left + 1 : 0; System.out.println(answer); } }
[ "expression.operator.compare.change", "assignment.value.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
851,407
851,408
u675751622
java
p03041
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); String ss = s.next(); System.out.println(ss.substring(0, k) + (char)(ss.charAt(k - 1) + 32) + ss.substring(k)); } }
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); String ss = s.next(); System.out.println(ss.substring(0, k - 1) + (char)(ss.charAt(k - 1) + 32) + ss.substring(k)); } }
[ "expression.operation.binary.add" ]
855,695
855,696
u099910634
java
p03041
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); String ss = s.nextLine(); System.out.println(ss.substring(0, k) + (char)(ss.charAt(k - 1) + 32) + ss.substring(k)); } }
import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { public static void main(String args[]) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); String ss = s.next(); System.out.println(ss.substring(0, k - 1) + (char)(ss.charAt(k - 1) + 32) + ss.substring(k)); } }
[ "identifier.change", "call.function.change" ]
855,697
855,696
u099910634
java
p03042
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); int format = Integer.parseInt(S); int left = format / 100; int right = format % 100; if (left >= 1 && left <= 12) { if (right >= 1 && right <= 12) { System.out.println("AMBIGUOS"); } else { System.out.println("MMYY"); } } else { if (right >= 1 && right <= 12) { System.out.println("YYMM"); } else { System.out.println("NA"); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); int format = Integer.parseInt(S); int left = format / 100; int right = format % 100; if (left >= 1 && left <= 12) { if (right >= 1 && right <= 12) { System.out.println("AMBIGUOUS"); } else { System.out.println("MMYY"); } } else if (right >= 1 && right <= 12) { System.out.println("YYMM"); } else { System.out.println("NA"); } } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
857,480
857,481
u466371843
java
p03042
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); int format = Integer.parseInt(S); int left = format / 100; int right = format % 100; if (left >= 1 && left <= 12) { if (right >= 1 && right <= 12) { System.out.println("AMBIGUOS"); } else { System.out.println("MMYY"); } } else if (right >= 1 && right <= 12) { System.out.println("YYMM"); } else { System.out.println("NA"); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); int format = Integer.parseInt(S); int left = format / 100; int right = format % 100; if (left >= 1 && left <= 12) { if (right >= 1 && right <= 12) { System.out.println("AMBIGUOUS"); } else { System.out.println("MMYY"); } } else if (right >= 1 && right <= 12) { System.out.println("YYMM"); } else { System.out.println("NA"); } } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
857,482
857,481
u466371843
java
p03042
import java.io.*; import java.util.*; public class Main { static String[] result = new String[] {"YYMM", "MMYY", "AMBIGUOUS", "NA"}; static int type(int s) { if (0 <= s && s <= 99) { if (1 <= s && s <= 12) { return 1; // M } return 0; // Y } throw new RuntimeException(); } public static void main(String... args) throws Exception { int n = 0, k = 0; String s; try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) { String buf = isr.readLine(); System.err.println(buf); /* String[] input = buf.split(" "); n = Integer.parseInt(input[0]); k = Integer.parseInt(input[1]); buf = isr.readLine(); System.err.println(buf); */ s = buf; } String s1 = s.substring(0, 2); String s2 = s.substring(2, 4); int l = type(Integer.parseInt(s1)); int r = type(Integer.parseInt(s2)); System.err.println(l); System.err.println(r); int res = 0; if ((l & r) == 1) { res = 3; } if ((l | r) == 0) { res = 2; } if ((l ^ r) == 1) { if (l == 1) { res = 1; } else { res = 0; } } System.out.println(result[res]); } }
import java.io.*; import java.util.*; public class Main { static String[] result = new String[] {"YYMM", "MMYY", "AMBIGUOUS", "NA"}; static int type(int s) { if (0 <= s && s <= 99) { if (1 <= s && s <= 12) { return 1; // M } return 0; // Y } throw new RuntimeException(); } public static void main(String... args) throws Exception { int n = 0, k = 0; String s; try (BufferedReader isr = new BufferedReader(new InputStreamReader(System.in))) { String buf = isr.readLine(); System.err.println(buf); /* String[] input = buf.split(" "); n = Integer.parseInt(input[0]); k = Integer.parseInt(input[1]); buf = isr.readLine(); System.err.println(buf); */ s = buf; } String s1 = s.substring(0, 2); String s2 = s.substring(2, 4); int l = type(Integer.parseInt(s1)); int r = type(Integer.parseInt(s2)); System.err.println(l); System.err.println(r); int res = 0; if ((l & r) == 1) { res = 2; } if ((l | r) == 0) { res = 3; } if ((l ^ r) == 1) { if (l == 1) { res = 1; } else { res = 0; } } System.out.println(result[res]); } }
[ "literal.number.integer.change", "assignment.value.change" ]
859,396
859,397
u134856634
java
p03047
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(a); } else { x = a - b; System.out.println(x + 1); } } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(1); } else { x = a - b; System.out.println(x + 1); } } }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "io.output.change" ]
864,710
864,711
u670829424
java
p03047
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(1); } x = a - b; System.out.println(x + 1); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(1); } else { x = a - b; System.out.println(x + 1); } } }
[ "control_flow.branch.else.add" ]
864,712
864,711
u670829424
java
p03047
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(a); } x = a - b; System.out.println(x + 1); } }
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int x = 0; if (a - b == 0) { System.out.println(1); } else { x = a - b; System.out.println(x + 1); } } }
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "io.output.change", "control_flow.branch.else.add" ]
864,713
864,711
u670829424
java
p03054
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); BLRUDGame solver = new BLRUDGame(); solver.solve(1, in, out); out.close(); } static class BLRUDGame { public void solve(int testNumber, InputReader in, OutputWriter out) { int h = in.readInt(); int w = in.readInt(); int n = in.readInt(); int sr = in.readInt(); int sc = in.readInt(); String s = in.readString(); String t = in.readString(); { int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'L') { a[i] = 1; } else if (s.charAt(i) == 'R') { a[i] = -1; } if (t.charAt(i) == 'L') { b[i] = 1; } else if (t.charAt(i) == 'R') { b[i] = -1; } } if (!f(w, sc, a, b)) { out.printLine("NO"); return; } } { int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'D') { a[i] = 1; } else if (s.charAt(i) == 'U') { a[i] = -1; } if (t.charAt(i) == 'D') { b[i] = 1; } else if (t.charAt(i) == 'U') { b[i] = -1; } } if (!f(h, sr, a, b)) { out.printLine("NO"); return; } } out.printLine("YES"); } boolean f(int l, int s, int[] a, int[] b) { int n = a.length; int min = 1; int max = l; for (int i = 0; i < n; i++) { if (b[n - 1 - i] == 1) { min = Math.min(min - 1, 1); } else if (b[n - 1 - i] == -1) { max = Math.max(max + 1, l); } if (a[n - 1 - i] == 1) { max--; } else if (a[n - 1 - i] == -1) { min++; } if (min > max) return false; } return min <= s && s <= max; } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter( new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) { writer.print(' '); } writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int readInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String readString() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.InputMismatchException; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); BLRUDGame solver = new BLRUDGame(); solver.solve(1, in, out); out.close(); } static class BLRUDGame { public void solve(int testNumber, InputReader in, OutputWriter out) { int h = in.readInt(); int w = in.readInt(); int n = in.readInt(); int sr = in.readInt(); int sc = in.readInt(); String s = in.readString(); String t = in.readString(); { int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'R') { a[i] = 1; } else if (s.charAt(i) == 'L') { a[i] = -1; } if (t.charAt(i) == 'R') { b[i] = 1; } else if (t.charAt(i) == 'L') { b[i] = -1; } } if (!f(w, sc, a, b)) { out.printLine("NO"); return; } } { int[] a = new int[n]; int[] b = new int[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'D') { a[i] = 1; } else if (s.charAt(i) == 'U') { a[i] = -1; } if (t.charAt(i) == 'D') { b[i] = 1; } else if (t.charAt(i) == 'U') { b[i] = -1; } } if (!f(h, sr, a, b)) { out.printLine("NO"); return; } } out.printLine("YES"); } boolean f(int l, int s, int[] a, int[] b) { int n = a.length; int min = 1; int max = l; for (int i = 0; i < n; i++) { if (b[n - 1 - i] == 1) { min = Math.max(min - 1, 1); } else if (b[n - 1 - i] == -1) { max = Math.min(max + 1, l); } if (a[n - 1 - i] == 1) { max--; } else if (a[n - 1 - i] == -1) { min++; } if (min > max) return false; } return min <= s && s <= max; } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter( new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) { writer.print(' '); } writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int readInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String readString() { int c = read(); while (isSpaceChar(c)) { c = read(); } StringBuilder res = new StringBuilder(); do { if (Character.isValidCodePoint(c)) { res.appendCodePoint(c); } c = read(); } while (!isSpaceChar(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
[ "control_flow.branch.if.condition.change", "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
869,814
869,815
u038084150
java
p03061
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static int lenbuf = 0, ptrbuf = 0; private static byte[] inbuf = new byte[1024]; // static int gcd(int a, int b) { // while (b != 0) { // int t = a % b; // a = b; // b = t; // } // return a; // } private static int gcd(int a, int b) { if (b == 0L) { return a; } return gcd(b, a % b); } static void solve() { int n = ni(); int[] a = new int[n + 2]; for (int i = 1; i <= n; i++) { a[i] = ni(); } int[] left = new int[n + 2], right = new int[n + 2]; for (int i = 1; i <= n; i++) { left[i] = gcd(left[n - 2], a[i]); } for (int i = n; i >= 1; i--) { right[i] = gcd(right[i + 1], a[i]); } int res = 1; for (int i = 1; i <= n; i++) { int t = gcd(left[i - 1], right[i + 1]); res = Math.max(res, t); } System.out.println(res); } static void execute() throws IOException { solve(); } public static void main(String[] args) throws Exception { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); execute(); out.flush(); long G = System.currentTimeMillis(); tr(G - S + "ms"); } private static boolean eof() { if (lenbuf == -1) { return true; } int lptr = ptrbuf; while (lptr < lenbuf) { if (!isSpaceChar(inbuf[lptr++])) { return false; } } try { is.mark(1000); while (true) { int b = is.read(); if (b == -1) { is.reset(); return true; } else if (!isSpaceChar(b)) { is.reset(); return false; } } } catch (IOException e) { return true; } } private static int readByte() { if (lenbuf == -1) { throw new InputMismatchException(); } if (ptrbuf >= lenbuf) { ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) { return -1; } } return inbuf[ptrbuf++]; } private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } // private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= //126); } private static int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) { ; } return b; } private static double nd() { return Double.parseDouble(ns()); } private static char nc() { return (char)skip(); } private static String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!(isSpaceChar(b))) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while (p < n && !(isSpaceChar(b))) { buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private static char[][] nm(int n, int m) { char[][] map = new char[n][]; for (int i = 0; i < n; i++) { map[i] = ns(m); } return map; } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = ni(); } return a; } private static int ni() { int num = 0, b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) { ; } if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private static long nl() { long num = 0; int b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) { ; } if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { if (INPUT.length() != 0) { System.out.println(Arrays.deepToString(o)); } } }
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static int lenbuf = 0, ptrbuf = 0; private static byte[] inbuf = new byte[1024]; // static int gcd(int a, int b) { // while (b != 0) { // int t = a % b; // a = b; // b = t; // } // return a; // } private static int gcd(int a, int b) { if (b == 0L) { return a; } return gcd(b, a % b); } static void solve() { int n = ni(); int[] a = new int[n + 2]; for (int i = 1; i <= n; i++) { a[i] = ni(); } int[] left = new int[n + 2], right = new int[n + 2]; for (int i = 1; i <= n; i++) { left[i] = gcd(left[i - 1], a[i]); } for (int i = n; i >= 1; i--) { right[i] = gcd(right[i + 1], a[i]); } int res = 1; for (int i = 1; i <= n; i++) { int t = gcd(left[i - 1], right[i + 1]); res = Math.max(res, t); } System.out.println(res); } static void execute() throws IOException { solve(); } public static void main(String[] args) throws Exception { long S = System.currentTimeMillis(); is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); execute(); out.flush(); long G = System.currentTimeMillis(); tr(G - S + "ms"); } private static boolean eof() { if (lenbuf == -1) { return true; } int lptr = ptrbuf; while (lptr < lenbuf) { if (!isSpaceChar(inbuf[lptr++])) { return false; } } try { is.mark(1000); while (true) { int b = is.read(); if (b == -1) { is.reset(); return true; } else if (!isSpaceChar(b)) { is.reset(); return false; } } } catch (IOException e) { return true; } } private static int readByte() { if (lenbuf == -1) { throw new InputMismatchException(); } if (ptrbuf >= lenbuf) { ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) { return -1; } } return inbuf[ptrbuf++]; } private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } // private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= //126); } private static int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) { ; } return b; } private static double nd() { return Double.parseDouble(ns()); } private static char nc() { return (char)skip(); } private static String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while (!(isSpaceChar(b))) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while (p < n && !(isSpaceChar(b))) { buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private static char[][] nm(int n, int m) { char[][] map = new char[n][]; for (int i = 0; i < n; i++) { map[i] = ns(m); } return map; } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = ni(); } return a; } private static int ni() { int num = 0, b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) { ; } if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private static long nl() { long num = 0; int b; boolean minus = false; while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) { ; } if (b == '-') { minus = true; b = readByte(); } while (true) { if (b >= '0' && b <= '9') { num = num * 10 + (b - '0'); } else { return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { if (INPUT.length() != 0) { System.out.println(Arrays.deepToString(o)); } } }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "literal.number.integer.change" ]
873,517
873,518
u950232284
java
p03061
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int A[] = new int[N]; for (int i = 0; i < N; i++) { A[i] = Integer.parseInt(sc.next()); } int L[] = new int[N]; int R[] = new int[N]; L[0] = A[0]; for (int i = 1; i < N; i++) { L[i] = gcd(L[i - 1], A[i]); } R[N - 1] = A[N - 1]; for (int i = N - 2; i > 0; i--) { R[i] = gcd(R[i + 1], A[i]); } int ans = gcd(R[1], L[N - 1]); for (int i = 1; i <= N - 2; i++) { ans = Math.max(ans, gcd(L[i - 1], R[i + 1])); } System.out.println(ans); } static int gcd(int a, int b) { int tmp; if (a < b) { tmp = a; a = b; b = tmp; } while (true) { tmp = a % b; if (tmp == 0) { return b; } a = b; b = tmp; } } }
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int A[] = new int[N]; for (int i = 0; i < N; i++) { A[i] = Integer.parseInt(sc.next()); } int L[] = new int[N]; int R[] = new int[N]; L[0] = A[0]; for (int i = 1; i < N; i++) { L[i] = gcd(L[i - 1], A[i]); } R[N - 1] = A[N - 1]; for (int i = N - 2; i > 0; i--) { R[i] = gcd(R[i + 1], A[i]); } int ans = Math.max(R[1], L[N - 2]); for (int i = 1; i <= N - 2; i++) { ans = Math.max(ans, gcd(L[i - 1], R[i + 1])); } System.out.println(ans); } static int gcd(int a, int b) { int tmp; if (a < b) { tmp = a; a = b; b = tmp; } while (true) { tmp = a % b; if (tmp == 0) { return b; } a = b; b = tmp; } } }
[ "identifier.change", "call.add", "literal.number.integer.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
874,907
874,908
u533482278
java
p03067
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if ((a < b && c < b) || (a > b && b < c && a > c)) { System.out.println("Yes"); } else { System.out.println("No"); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if ((a < c && c < b) || (a > c && b < c)) { System.out.println("Yes"); } else { System.out.println("No"); } } }
[ "identifier.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
877,359
877,360
u563673753
java
p03067
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if ((a < b && c < b) || (a > b && b < c)) { System.out.println("Yes"); } else { System.out.println("No"); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if ((a < c && c < b) || (a > c && b < c)) { System.out.println("Yes"); } else { System.out.println("No"); } } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,361
877,360
u563673753
java
p03068
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { // BufferedReader in = new BufferedReader(new FileReader(new // File("input.txt"))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Byte N = Byte.valueOf(in.readLine()); StringBuilder S = new StringBuilder(in.readLine()); Byte K = Byte.valueOf(in.readLine()); char to = S.charAt(K); for (int i = 0; i < S.length(); i++) { if (S.charAt(i) != to) { S.deleteCharAt(i); S.insert(i, '*'); } } System.out.println(S.toString()); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { // BufferedReader in = new BufferedReader(new FileReader(new // File("input.txt"))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Byte N = Byte.valueOf(in.readLine()); StringBuilder S = new StringBuilder(in.readLine()); Byte K = Byte.valueOf(in.readLine()); char to = S.charAt(K - 1); for (int i = 0; i < S.length(); i++) { if (S.charAt(i) != to) { S.deleteCharAt(i); S.insert(i, '*'); } } System.out.println(S.toString()); } }
[ "expression.operation.binary.add" ]
879,434
879,435
u739791911
java
p03072
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = scan.nextInt(); } int max = h[0]; int counter = 1; for (int j = 0; j < n - 1; j++) { if (max < h[j + 1]) { max = h[j + 1]; counter++; } } System.out.print(counter); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = scan.nextInt(); } int max = h[0]; int counter = 1; for (int j = 0; j < n - 1; j++) { if (max <= h[j + 1]) { max = h[j + 1]; counter++; } } System.out.print(counter); } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
883,192
883,193
u347452770
java
p03072
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = scan.nextInt(); } int max = h[0]; int counter = 1; for (int j = 0; j < n - 1; j++) { if (h[j] < h[j + 1]) { max = h[j + 1]; counter++; } } System.out.print(counter); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = scan.nextInt(); } int max = h[0]; int counter = 1; for (int j = 0; j < n - 1; j++) { if (max <= h[j + 1]) { max = h[j + 1]; counter++; } } System.out.print(counter); } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
883,194
883,193
u347452770
java
p03075
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (int i = 0; i < 5; i++) { int n = sc.nextInt(); min = Math.min(min, n); max = Math.max(max, n); } int k = sc.nextInt(); if (max - min >= k) System.out.println(":("); else System.out.println("Yay!"); } }
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (int i = 0; i < 5; i++) { int n = sc.nextInt(); min = Math.min(min, n); max = Math.max(max, n); } int k = sc.nextInt(); if (max - min > k) System.out.println(":("); else System.out.println("Yay!"); } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
886,351
886,352
u941274418
java
p03075
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int[] num = new int[5]; for (int i = 0; i < 5; i++) { num[i] = sc.nextInt(); } int k = sc.nextInt(); String result = "Yay!"; out: for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (Math.abs(num[i] - num[j]) > 15) { result = ":("; break out; } } } System.out.println(result); } }
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int[] num = new int[5]; for (int i = 0; i < 5; i++) { num[i] = sc.nextInt(); } int k = sc.nextInt(); String result = "Yay!"; out: for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (Math.abs(num[i] - num[j]) > k) { result = ":("; break out; } } } System.out.println(result); } }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change", "control_flow.branch.if.condition.change" ]
886,550
886,551
u353707427
java
p03075
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.hasNext()); if (distance > current) { System.out.println("Yay!"); } else { System.out.println(":("); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.hasNext()); if (distance > current) { System.out.println(":("); } else { System.out.println("Yay!"); } } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
888,263
888,264
u530712718
java
p03075
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.hasNext()); if (distance > current) { System.out.println("Yay!"); } else { System.out.println("Yay!"); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.hasNext()); if (distance > current) { System.out.println(":("); } else { System.out.println("Yay!"); } } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
888,265
888,264
u530712718
java
p03075
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.next() != null); if (distance > current) { System.out.println("Yay!"); } else { System.out.println("Yay!"); } } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int current = sc.nextInt(); int mini = current, maxi = current, distance = 0; do { int res = Math.max(Math.abs(current - mini), Math.abs(current - maxi)); if (res > distance) { distance = res; } current = sc.nextInt(); } while (sc.hasNext()); if (distance > current) { System.out.println(":("); } else { System.out.println("Yay!"); } } }
[ "identifier.change", "call.function.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "expression.operation.binary.remove", "literal.string.change", "call.arguments.change", "io.output.change" ]
888,266
888,264
u530712718
java
p03076
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] data = new int[5]; int[] table = new int[5]; for (int i = 0; i < 5; i++) { data[i] = sc.nextInt(); table[i] = (10 - data[i] % 10) % 10; } Arrays.sort(table); int total = 0; for (int i = 0; i < 5; i++) { total += data[i] + table[i]; } System.out.println(total - (10 - table[4])); } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] data = new int[5]; int[] table = new int[5]; for (int i = 0; i < 5; i++) { data[i] = sc.nextInt(); table[i] = (10 - data[i] % 10) % 10; } Arrays.sort(table); int total = 0; for (int i = 0; i < 5; i++) { total += data[i] + table[i]; } System.out.println(total - table[4]); } }
[ "call.arguments.change" ]
890,401
890,402
u387775763
java
p03077
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') break; buf[cnt++] = (byte)c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static void main(String args[]) throws IOException { Reader in = new Reader(); long n = in.nextLong(); long[] moves = new long[5]; long minPplPM = Long.MAX_VALUE; for (int i = 0; i < moves.length; i++) { moves[i] = in.nextLong(); minPplPM = Math.min(minPplPM, moves[i]); } System.out.println(5 + n / minPplPM); } }
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') break; buf[cnt++] = (byte)c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static void main(String args[]) throws IOException { Reader in = new Reader(); long n = in.nextLong(); long[] moves = new long[5]; long minPplPM = Long.MAX_VALUE; for (int i = 0; i < moves.length; i++) { moves[i] = in.nextLong(); minPplPM = Math.min(minPplPM, moves[i]); } System.out.println(5 + (n - 1) / minPplPM); } }
[ "call.arguments.change" ]
892,833
892,834
u816631826
java
p03080
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int N = scn.nextInt(); char[] str = scn.nextLine().toCharArray(); int ans = 0; for (int i = 0; i < N; i++) { if (str[i] == 'R') { ans++; } } System.out.println(2 * ans > N ? "Yes" : "No"); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int N = scn.nextInt(); scn.nextLine(); char[] str = scn.nextLine().toCharArray(); int ans = 0; for (int i = 0; i < N; i++) { if (str[i] == 'R') { ans++; } } System.out.println(2 * ans > N ? "Yes" : "No"); } }
[ "call.add" ]
896,168
896,169
u517219904
java
p03086
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int max_count = -1; int count = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'C' || s.charAt(i) == 'G') { count += 1; if (count > max_count) { max_count = count; } } else { count = 0; } } System.out.println(max_count); } }
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int max_count = 0; int count = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'C' || s.charAt(i) == 'G') { count += 1; if (count > max_count) { max_count = count; } } else { count = 0; } } System.out.println(max_count); } }
[ "variable_declaration.value.change", "expression.operation.unary.remove" ]
899,518
899,519
u156931988
java