buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
ulong person = ulong.Parse(ReadLine());
List<ulong> input = new List<ulong>();
for (ulong i = 0; i < 5; i++) {
input.Add(ulong.Parse(ReadLine()));
}
ulong max = input.Min();
ulong count = person / max + (max % person == 0 ? 0ul : 1ul);
WriteLine(count + 4);
ReadKey();
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
ulong person = ulong.Parse(ReadLine());
List<ulong> input = new List<ulong>();
for (ulong i = 0; i < 5; i++) {
input.Add(ulong.Parse(ReadLine()));
}
ulong min = input.Min();
ulong count = person / min + (person % min == 0 ? 0ul : 1ul);
WriteLine(count + 4);
ReadKey();
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["-", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["-", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 12, 22]]
| 8
| 143
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
public void Do() {
cin = new Scanner();
long N = cin.nextLong();
long min = -1;
for (int i = 0; i < 5; i++) {
int tmp = cin.nextInt();
if (min == -1 || tmp < min) {
min = tmp;
}
}
if (N % min == 0) {
Console.WriteLine(5 + N / min - 1);
} else {
Console.WriteLine(5 + N / min);
}
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
public void Do() {
cin = new Scanner();
long N = cin.nextLong();
long min = -1;
for (int i = 0; i < 5; i++) {
long tmp = cin.nextLong();
if (min == -1 || tmp < min) {
min = tmp;
}
}
if (N % min == 0) {
Console.WriteLine(5 + N / min - 1);
} else {
Console.WriteLine(5 + N / min);
}
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 566
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var str = IO.GetIntList();
var X = str[0];
var Y = str[1];
var Z = str[2];
var K = str[3];
var A = IO.GetLongList().OrderByDescending(a => a).ToArray();
var B = IO.GetLongList().OrderByDescending(a => a).ToArray();
var C = IO.GetLongList().OrderByDescending(a => a).ToArray();
long[] AB = new long[X * Y];
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
AB[i * Y + j] = (A[i] + B[j]);
}
}
Array.Sort(AB);
Array.Reverse(AB);
var k = Math.Min(AB.Length, K);
long[] ABC = new long[K * Z];
for (int i = 0; i < K; i++) {
for (int j = 0; j < Z; j++) {
ABC[i * Z + j] = AB[i] + C[j];
}
}
Array.Sort(ABC);
Array.Reverse(ABC);
for (int i = 0; i < K; i++) {
Console.WriteLine(ABC[i]);
}
// Console.WriteLine(ans);
}
}
static class IO {
static public string GetString() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public List<string> GetStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> GetIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> GetLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteStrings<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var str = IO.GetIntList();
var X = str[0];
var Y = str[1];
var Z = str[2];
var K = str[3];
var A = IO.GetLongList().OrderByDescending(a => a).ToArray();
var B = IO.GetLongList().OrderByDescending(a => a).ToArray();
var C = IO.GetLongList().OrderByDescending(a => a).ToArray();
long[] AB = new long[X * Y];
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
AB[i * Y + j] = (A[i] + B[j]);
}
}
Array.Sort(AB);
Array.Reverse(AB);
var k = Math.Min(AB.Length, K);
long[] ABC = new long[k * Z];
for (int i = 0; i < k; i++) {
for (int j = 0; j < Z; j++) {
ABC[i * Z + j] = AB[i] + C[j];
}
}
Array.Sort(ABC);
Array.Reverse(ABC);
for (int i = 0; i < K; i++) {
Console.WriteLine(ABC[i]);
}
// Console.WriteLine(ans);
}
}
static class IO {
static public string GetString() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public List<string> GetStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> GetIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> GetLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteStrings<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
}
}
|
[["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 592
| 4
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
public static Scanner cin;
static void Main() {
cin = new Scanner();
long[] xyzk = cin.ArrayLong(4);
long[][] abc = new long [3][];
for (int a = 0; a < abc.Length; a++) {
abc[a] = cin.ArrayLong((int)xyzk[a]);
}
List<long> ab = new List<long>();
for (int a = 0; a < xyzk[0]; a++) {
for (int b = 0; b < xyzk[1]; b++) {
ab.Add(abc[0][a] + abc[1][b]);
}
}
Array.Sort(abc[2]);
Array.Reverse(abc[2]);
ab.Sort();
ab.Reverse();
List<long> abc2 = new List<long>();
for (int a = 0; a < xyzk[2]; a++) {
for (int b = 0; b < Math.Min((int)Math.Ceiling((double)xyzk[3] / (b + 1)),
ab.Capacity);
b++) {
abc2.Add(ab[b] + abc[2][a]);
}
}
abc2.Sort();
abc2.Reverse();
for (int a = 0; a < xyzk[3]; a++) {
Console.WriteLine(abc2[a]);
}
Console.ReadLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
public static Scanner cin;
static void Main() {
cin = new Scanner();
long[] xyzk = cin.ArrayLong(4);
long[][] abc = new long [3][];
for (int a = 0; a < abc.Length; a++) {
abc[a] = cin.ArrayLong((int)xyzk[a]);
}
List<long> ab = new List<long>();
for (int a = 0; a < xyzk[0]; a++) {
for (int b = 0; b < xyzk[1]; b++) {
ab.Add(abc[0][a] + abc[1][b]);
}
}
Array.Sort(abc[2]);
Array.Reverse(abc[2]);
ab.Sort();
ab.Reverse();
List<long> abc2 = new List<long>();
for (int a = 0; a < xyzk[2]; a++) {
for (int b = 0; b < Math.Min((int)Math.Ceiling((double)xyzk[3] / (a + 1)),
ab.Capacity);
b++) {
abc2.Add(ab[b] + abc[2][a]);
}
}
abc2.Sort();
abc2.Reverse();
for (int a = 0; a < xyzk[3]; a++) {
Console.WriteLine(abc2[a]);
}
Console.ReadLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["-", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22]]
| 8
| 732
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) { D(); }
public static void D() {
Scanner cin = new Scanner();
long x = cin.NextLong();
long y = cin.NextLong();
long z = cin.NextLong();
long k = cin.NextLong();
long[] ai = new long[x];
long[] bi = new long[y];
long[] ci = new long[z];
for (int i = 0; i < x; ++i) {
ai[i] = cin.NextLong();
}
for (int i = 0; i < y; ++i) {
bi[i] = cin.NextLong();
}
for (int i = 0; i < z; ++i) {
ci[i] = cin.NextLong();
}
long count = 0;
long w = x * y;
long[] ww = new long[w];
for (int i = 0; i < x; ++i) {
for (int j = 0; j < y; ++j) {
ww[count] = ai[i] + bi[j];
++count;
}
}
Array.Sort(ww);
count = 0;
long vc = Math.Min(3000, Math.Min(w, k));
long[] vv = new long[vc * z];
for (int i = 0; i < vc; ++i) {
for (int j = 0; j < z; ++j) {
vv[count] = ww[i] + ci[j];
++count;
}
}
Array.Sort(vv);
for (int n = 0; n < k; ++n) {
Console.WriteLine(vv[vv.Length - 1 - n]);
}
/*
ci = ci.OrderByDescending(i => i).ToArray();
int wc = 0;
int zc = 0;
for (int n = 0; n < k; ++n) {
long value = ww[wc] + ci[zc];
Console.WriteLine(value);
if (wc < w - 1 && zc < z - 1) {
if (ww[wc] - ww[wc + 1] > ci[zc] - ci[zc + 1]) {
++zc;
} else {
++wc;
}
} else if (wc < w - 1) {
++wc;
} else if (zc < z - 1) {
++zc;
}
}
*/
}
}
public class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) { D(); }
public static void D() {
Scanner cin = new Scanner();
long x = cin.NextLong();
long y = cin.NextLong();
long z = cin.NextLong();
long k = cin.NextLong();
long[] ai = new long[x];
long[] bi = new long[y];
long[] ci = new long[z];
for (int i = 0; i < x; ++i) {
ai[i] = cin.NextLong();
}
for (int i = 0; i < y; ++i) {
bi[i] = cin.NextLong();
}
for (int i = 0; i < z; ++i) {
ci[i] = cin.NextLong();
}
long count = 0;
long w = x * y;
long[] ww = new long[w];
for (int i = 0; i < x; ++i) {
for (int j = 0; j < y; ++j) {
ww[count] = ai[i] + bi[j];
++count;
}
}
Array.Sort(ww);
count = 0;
long vc = Math.Min(3000, Math.Min(w, k));
long[] vv = new long[vc * z];
for (int i = 0; i < vc; ++i) {
for (int j = 0; j < z; ++j) {
vv[count] = ww[ww.Length - 1 - i] + ci[j];
++count;
}
}
Array.Sort(vv);
for (int n = 0; n < k; ++n) {
Console.WriteLine(vv[vv.Length - 1 - n]);
}
/*
ci = ci.OrderByDescending(i => i).ToArray();
int wc = 0;
int zc = 0;
for (int n = 0; n < k; ++n) {
long value = ww[wc] + ci[zc];
Console.WriteLine(value);
if (wc < w - 1 && zc < z - 1) {
if (ww[wc] - ww[wc + 1] > ci[zc] - ci[zc + 1]) {
++zc;
} else {
++wc;
}
} else if (wc < w - 1) {
++wc;
} else if (zc < z - 1) {
++zc;
}
}
*/
}
}
public class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 141, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33]]
| 8
| 774
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
Put(calc(o[0], o[1], o[2]));
}
bool calc(int a, int b, int c) { return (a == b && b == c); }
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
public static long Comb(long n, long r, int MOD = 1000000007) {
if (r > n - r)
r = n - r;
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno = (Deno * i) % MOD;
Nume = Nume * (n - i + 1) % MOD;
}
return (Nume * inv(Deno)) % MOD;
}
public static long Comb2(long n, long r) {
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
public static long inv(long x, int MOD = 1000000007) {
return Power(x, MOD - 2, MOD);
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
public static string ConvertBase(long N, int K) {
StringBuilder ret = new StringBuilder();
while (N > 0) {
var r = N % K;
N /= K;
ret.Append(r);
}
return new string(ret.ToString().ToCharArray().Reverse().ToArray());
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Put(string a) => Console.WriteLine(a);
public static void Put(params object[] i) => Put(string.Join(" ", i));
public static void Put<T>(IEnumerable<T> a) => Put(string.Join(" ", a));
public static void VerticalPut<T>(IEnumerable<T> a) {
foreach (var z in a)
Put(z);
}
public static void YN(bool i) {
if (i)
Put("Yes");
else
Put("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
YN(calc(o[0], o[1], o[2]));
}
bool calc(int a, int b, int c) { return (a == b && b == c); }
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
public static long Comb(long n, long r, int MOD = 1000000007) {
if (r > n - r)
r = n - r;
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno = (Deno * i) % MOD;
Nume = Nume * (n - i + 1) % MOD;
}
return (Nume * inv(Deno)) % MOD;
}
public static long Comb2(long n, long r) {
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
public static long inv(long x, int MOD = 1000000007) {
return Power(x, MOD - 2, MOD);
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
public static string ConvertBase(long N, int K) {
StringBuilder ret = new StringBuilder();
while (N > 0) {
var r = N % K;
N /= K;
ret.Append(r);
}
return new string(ret.ToString().ToCharArray().Reverse().ToArray());
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Put(string a) => Console.WriteLine(a);
public static void Put(params object[] i) => Put(string.Join(" ", i));
public static void Put<T>(IEnumerable<T> a) => Put(string.Join(" ", a));
public static void VerticalPut<T>(IEnumerable<T> a) {
foreach (var z in a)
Put(z);
}
public static void YN(bool i) {
if (i)
Put("Yes");
else
Put("No");
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22]]
| 8
| 1,081
| 2
|
using System;
using System.Linq;
namespace ARegularTriang {
class Program {
private string Read() { return Console.ReadLine(); }
private int[] ReadInt() { return Read().Split().Select(int.Parse).ToArray(); }
public void C() {
var a = ReadInt();
var str = "";
str = a[0] == a[1] && a[1] == a[2] && a[2] == a[0] ? "YES" : "NO";
Console.WriteLine(str);
}
static void Main(string[] args) { new Program().C(); }
}
}
|
using System;
using System.Linq;
namespace ARegularTriang {
class Program {
private string Read() { return Console.ReadLine(); }
private int[] ReadInt() { return Read().Split().Select(int.Parse).ToArray(); }
public void C() {
var a = ReadInt();
var str = "";
str = a[0] == a[1] && a[1] == a[2] && a[2] == a[0] ? "Yes" : "No";
Console.WriteLine(str);
}
static void Main(string[] args) { new Program().C(); }
}
}
|
[["-", 0, 1, 0, 11, 12, 41, 64, 5, 0, 222], ["+", 0, 1, 0, 11, 12, 41, 64, 5, 0, 222], ["-", 0, 1, 0, 11, 12, 41, 75, 5, 0, 222], ["+", 0, 1, 0, 11, 12, 41, 75, 5, 0, 222]]
| 8
| 146
| 4
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a == b && b == c) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a == b && b == c) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 112
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static string ans = "No";
static int Main() {
string[] nyu = Console.ReadLine().Split(' ');
int a = int.Parse(nyu[0]);
int b = int.Parse(nyu[1]);
int c = int.Parse(nyu[2]);
// ここまで入力
if (a == b || b == c) {
ans = "Yes";
}
Console.WriteLine("{0}", ans);
return 0;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static string ans = "No";
static int Main() {
string[] nyu = Console.ReadLine().Split(' ');
int a = int.Parse(nyu[0]);
int b = int.Parse(nyu[1]);
int c = int.Parse(nyu[2]);
// ここまで入力
if (a == b && b == c) {
ans = "Yes";
}
Console.WriteLine("{0}", ans);
return 0;
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 124
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
private static void Yes() { print("YES"); }
private static void No() { print("NO"); }
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
var a = ReadInts();
if (a[0] == a[1] && a[1] == a[2]) {
Yes();
} else {
No();
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
private static void Yes() { print("Yes"); }
private static void No() { print("No"); }
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
var a = ReadInts();
if (a[0] == a[1] && a[1] == a[2]) {
Yes();
} else {
No();
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 288
| 4
|
using System;
namespace B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string[] str = new string[N];
for (int i = 0; i < N; i++) {
str[i] = s.Substring(i, 1);
}
int rnum = 0;
int bnum = 0;
foreach (var item in str) {
if (item == "R") {
rnum++;
} else {
bnum++;
}
}
if (rnum > bnum) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
using System;
namespace B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string[] str = new string[N];
for (int i = 0; i < N; i++) {
str[i] = s.Substring(i, 1);
}
int rnum = 0;
int bnum = 0;
foreach (var item in str) {
if (item == "R") {
rnum++;
} else {
bnum++;
}
}
if (rnum > bnum) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 153
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
public class C {
public static void Main() { (new Solver()).Solve(); }
}
public class Solver {
private int N;
private int Q;
private string s;
private char[] t;
private char[] d;
public Solver() {
N = GetInt();
Q = GetInt();
s = "\0" + GetString();
t = new char[Q];
d = new char[Q];
for (int i = 0; i < Q; i++) {
t[i] = GetString()[0];
d[i] = GetString()[0];
}
}
public void Solve() {
int lbl = 0;
int ubl = N + 1;
while (lbl + 1 < ubl) {
int mid = (lbl + ubl) / 2;
if (move(mid) == 0)
lbl = mid;
else
ubl = mid - 1;
}
int lbr = 0;
int ubr = N + 1;
while (lbr + 1 < ubr) {
int mid = (lbr + ubr) / 2;
if (move(mid) == N + 1)
ubr = mid;
else
lbr = mid + 1;
}
Console.WriteLine(ubr - ubl - 1);
}
private int move(int x) {
if ((x == 0) || (x == N + 1))
return x;
int currentX = x;
for (int i = 0; i < Q; i++) {
if (s[currentX] != t[i])
continue;
if (d[i] == 'L') {
if (currentX == 1)
return 0;
else
currentX--;
} else {
if (currentX == N)
return N + 1;
else
currentX++;
}
}
return currentX;
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
public class C {
public static void Main() { (new Solver()).Solve(); }
}
public class Solver {
private int N;
private int Q;
private string s;
private char[] t;
private char[] d;
public Solver() {
N = GetInt();
Q = GetInt();
s = "\0" + GetString();
t = new char[Q];
d = new char[Q];
for (int i = 0; i < Q; i++) {
t[i] = GetString()[0];
d[i] = GetString()[0];
}
}
public void Solve() {
int lbl = 0;
int ubl = N + 1;
while (lbl + 1 < ubl) {
int mid = (lbl + ubl) / 2;
if (move(mid) == 0)
lbl = mid;
else
ubl = mid;
}
int lbr = 0;
int ubr = N + 1;
while (lbr + 1 < ubr) {
int mid = (lbr + ubr) / 2;
if (move(mid) == N + 1)
ubr = mid;
else
lbr = mid;
}
Console.WriteLine(ubr - ubl);
}
private int move(int x) {
if ((x == 0) || (x == N + 1))
return x;
int currentX = x;
for (int i = 0; i < Q; i++) {
if (s[currentX] != t[i])
continue;
if (d[i] == 'L') {
if (currentX == 1)
return 0;
else
currentX--;
} else {
if (currentX == N)
return N + 1;
else
currentX++;
}
}
return currentX;
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
[["-", 0, 57, 75, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 57, 75, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 57, 75, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 548
| 6
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
long X = nx[1];
//ちゅーごくじょーよてーり
//オーダーによってSの終端が決定する
//まず影響するのは降順のみなことは自明に分かって、
//で、「次」を選ぶことができる順番は
//「確率」「期待値」
// aを取り除いた場合、その後に適用できるのはそれ以前全て。
List<int> s = Console.ReadLine()
.Split()
.Select(int.Parse)
.OrderByDescending(x => x)
.ToList();
ModInt[] dp = new ModInt[X + 1];
dp[X] = 1;
long remain = s.Count - 1;
foreach (var mod in s) {
ModInt[] newDP = new ModInt[X + 1];
for (int i = 0; i < dp.Length; i++) {
newDP[i % mod] += dp[i];
newDP[i] += dp[i] * remain;
}
remain--;
dp = newDP;
}
ModInt res = 0;
for (int i = 0; i < dp.Length; i++) {
res += dp[i] * i;
}
Console.WriteLine(res);
}
}
struct ModInt {
static int MOD;
long Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ModInt(long data) {
if ((Data = data % MOD) < 0)
Data += MOD;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator long(ModInt modInt) => modInt.Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ModInt(long val) => new ModInt(val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, ModInt b) {
long res = a.Data + b.Data;
return new ModInt() { Data = res >= MOD ? res - MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, ModInt b) {
long res = a.Data - b.Data;
return new ModInt() { Data = res < 0 ? res + MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static ModInt Power(ModInt n, long m) {
ModInt res = 1;
while (m > 0) {
if ((m & 1) == 1)
res *= n;
n *= n;
m >>= 1;
}
return res;
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
long X = nx[1];
//ちゅーごくじょーよてーり
//オーダーによってSの終端が決定する
//まず影響するのは降順のみなことは自明に分かって、
//で、「次」を選ぶことができる順番は
//「確率」「期待値」
// aを取り除いた場合、その後に適用できるのはそれ以前全て。
List<int> s = Console.ReadLine()
.Split()
.Select(int.Parse)
.OrderByDescending(x => x)
.ToList();
ModInt[] dp = new ModInt[X + 1];
dp[X] = 1;
long remain = s.Count - 1;
foreach (var mod in s) {
ModInt[] newDP = new ModInt[X + 1];
for (int i = 0; i < dp.Length; i++) {
newDP[i % mod] += dp[i];
newDP[i] += dp[i] * remain;
}
remain--;
dp = newDP;
}
ModInt res = 0;
for (int i = 0; i < dp.Length; i++) {
res += dp[i] * i;
}
Console.WriteLine(res);
}
}
struct ModInt {
static int MOD = 1000000007;
long Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ModInt(long data) {
if ((Data = data % MOD) < 0)
Data += MOD;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator long(ModInt modInt) => modInt.Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ModInt(long val) => new ModInt(val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, ModInt b) {
long res = a.Data + b.Data;
return new ModInt() { Data = res >= MOD ? res - MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, ModInt b) {
long res = a.Data - b.Data;
return new ModInt() { Data = res < 0 ? res + MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static ModInt Power(ModInt n, long m) {
ModInt res = 1;
while (m > 0) {
if ((m & 1) == 1)
res *= n;
n *= n;
m >>= 1;
}
return res;
}
}
|
[["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 665
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;
namespace AtCoderDotNetCore {
class Program {
static void Main(string[] args) { Question.Exec(); }
}
public static class Question {
public static void Exec() {
Dictionary<char, char> dict = new Dictionary<char, char>();
dict.Add('A', 'A');
dict.Add('C', 'T');
dict.Add('G', 'C');
dict.Add('T', 'G');
char c = Console.ReadLine()[0];
Console.WriteLine($"{dict[c]}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;
namespace AtCoderDotNetCore {
class Program {
static void Main(string[] args) { Question.Exec(); }
}
public static class Question {
public static void Exec() {
Dictionary<char, char> dict = new Dictionary<char, char>();
dict.Add('A', 'T');
dict.Add('C', 'G');
dict.Add('G', 'C');
dict.Add('T', 'A');
char c = Console.ReadLine()[0];
Console.WriteLine($"{dict[c]}");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253]]
| 8
| 174
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class393 {
static void Main() {
string b = Console.ReadLine();
Console.WriteLine(bond(b));
}
static string bond(string b) {
if (b == "A")
return "T";
if (b == "T")
return "T";
if (b == "G")
return "C";
return "G";
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class393 {
static void Main() {
string b = Console.ReadLine();
Console.WriteLine(bond(b));
}
static string bond(string b) {
if (b == "A")
return "T";
if (b == "T")
return "A";
if (b == "G")
return "C";
return "G";
}
}
}
|
[["-", 8, 196, 0, 57, 64, 37, 0, 5, 0, 222], ["+", 8, 196, 0, 57, 64, 37, 0, 5, 0, 222]]
| 8
| 114
| 2
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine();
if (a == "A")
Console.WriteLine("T");
else if (a == "C")
Console.WriteLine("");
else if (a == "G")
Console.WriteLine("C");
else
Console.WriteLine("A");
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine();
if (a == "A")
Console.WriteLine("T");
else if (a == "C")
Console.WriteLine("G");
else if (a == "G")
Console.WriteLine("C");
else
Console.WriteLine("A");
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 94
| 1
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ATCode1a {
class Program {
static void Main(string[] args) {
string b = "G";
if (b == "A") {
Console.WriteLine("T");
}
if (b == "T") {
Console.WriteLine("A");
}
if (b == "C") {
Console.WriteLine("G");
}
if (b == "G") {
Console.WriteLine("C");
} else {
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ATCode1a {
class Program {
static void Main(string[] args) {
string b = Console.ReadLine();
if (b == "A") {
Console.WriteLine("T");
}
if (b == "T") {
Console.WriteLine("A");
}
if (b == "C") {
Console.WriteLine("G");
}
if (b == "G") {
Console.WriteLine("C");
} else {
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 132
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var sc = new Scanner();
char s = sc.NextString()[0];
Console.WriteLine(s == 'A' ? 'T' : s == 'T' ? 'A' : s == 'G' ? 'C' : 'D');
}
}
class Scanner {
int index = -1;
string[] buf;
public Scanner() {}
public int NextInt() {
CheckNext();
return int.Parse(buf[index++]);
}
public long NextLong() {
CheckNext();
return long.Parse(buf[index++]);
}
public string NextString() {
CheckNext();
return buf[index++];
}
private void CheckNext() {
if (index >= 0 && index < buf.Length)
return;
buf = Console.ReadLine().Split(' ');
index = 0;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var sc = new Scanner();
char s = sc.NextString()[0];
Console.WriteLine(s == 'A' ? 'T' : s == 'T' ? 'A' : s == 'G' ? 'C' : 'G');
}
}
class Scanner {
int index = -1;
string[] buf;
public Scanner() {}
public int NextInt() {
CheckNext();
return int.Parse(buf[index++]);
}
public long NextLong() {
CheckNext();
return long.Parse(buf[index++]);
}
public string NextString() {
CheckNext();
return buf[index++];
}
private void CheckNext() {
if (index >= 0 && index < buf.Length)
return;
buf = Console.ReadLine().Split(' ');
index = 0;
}
}
|
[["-", 0, 41, 75, 41, 75, 41, 75, 252, 0, 253], ["+", 0, 41, 75, 41, 75, 41, 75, 252, 0, 253]]
| 8
| 226
| 2
|
using System;
namespace ConsoleApp4 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
switch (str) {
case "A":
Console.WriteLine("A");
break;
case "C":
Console.WriteLine("T");
break;
case "G":
Console.WriteLine("C");
break;
case "T":
Console.WriteLine("G");
break;
default:
break;
}
}
}
}
|
using System;
namespace ConsoleApp4 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
switch (str) {
case "A":
Console.WriteLine("T");
break;
case "T":
Console.WriteLine("A");
break;
case "G":
Console.WriteLine("C");
break;
case "C":
Console.WriteLine("G");
break;
default:
break;
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222]]
| 8
| 105
| 8
|
using System;
class Problem {
public static void Main() {
char[] a = { 'A', 'C', 'T', 'G' };
char[] b = { 'C', 'A', 'G', 'C' };
string s = Console.ReadLine();
for (int i = 0; i < 4; i++) {
if (s[0] == a[i]) {
Console.Write(b[i]);
}
}
}
}
|
using System;
class Problem {
public static void Main() {
char[] a = { 'A', 'T', 'C', 'G' };
char[] b = { 'T', 'A', 'G', 'C' };
string s = Console.ReadLine();
for (int i = 0; i < 4; i++) {
if (s[0] == a[i]) {
Console.Write(b[i]);
}
}
}
}
|
[["-", 0, 200, 0, 212, 0, 229, 0, 252, 0, 253], ["+", 0, 200, 0, 212, 0, 229, 0, 252, 0, 253]]
| 8
| 110
| 6
|
using System;
class Program {
static void Main(string[] args) {
// get a char
char a = Convert.ToChar(args[0]);
char val;
if (a == 'A')
val = 'T';
else if (a == 'T')
val = 'A';
else if (a == 'C')
val = 'G';
else
val = 'C';
// output
Console.WriteLine(val);
}
}
|
using System;
class Program {
static void Main(string[] args) {
// get a char
char a = Convert.ToChar(Console.ReadLine());
char val;
if (a == 'A')
val = 'T';
else if (a == 'T')
val = 'A';
else if (a == 'C')
val = 'G';
else
val = 'C';
// output
Console.WriteLine(val);
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 94
| 9
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s.EndsWith("A"))
Console.WriteLine("T");
if (s.EndsWith("T"))
Console.WriteLine("A");
if (s.EndsWith("G"))
Console.WriteLine("C");
if (s.EndsWith("C"))
Console.WriteLine("A");
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s.EndsWith("A"))
Console.WriteLine("T");
if (s.EndsWith("T"))
Console.WriteLine("A");
if (s.EndsWith("G"))
Console.WriteLine("C");
if (s.EndsWith("C"))
Console.WriteLine("G");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 111
| 2
|
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var n = cin.ReadLine[0];
var d = new Dictionary<char, char>() {
{ 'A', 'T' }, { 'T', 'A' }, { 'G', 'C' }, { 'C', 'G' }
};
Console.WriteLine(n);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
public double[] ReadDoubleArray(long N) {
var ret = new double[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadDouble;
return ret;
}
}
}
|
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var n = cin.ReadLine[0];
var d = new Dictionary<char, char>() {
{ 'A', 'T' }, { 'T', 'A' }, { 'G', 'C' }, { 'C', 'G' }
};
Console.WriteLine(d[n]);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
public double[] ReadDoubleArray(long N) {
var ret = new double[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadDouble;
return ret;
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 524
| 3
|
using System;
class Program {
static void Main() {
var b = Console.ReadLine();
var result = "";
switch (b) {
case "A":
result = "T";
break;
case "T":
result = "A";
break;
case "C":
result = "C";
break;
case "G":
result = "C";
break;
}
Console.WriteLine(result);
}
}
|
using System;
class Program {
static void Main() {
var b = Console.ReadLine();
var result = "";
switch (b) {
case "A":
result = "T";
break;
case "T":
result = "A";
break;
case "C":
result = "G";
break;
case "G":
result = "C";
break;
}
Console.WriteLine(result);
}
}
|
[["-", 0, 239, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 239, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 94
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
private static void Yes() { print("YES"); }
private static void No() { print("NO"); }
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
var a = Read();
if (a == "A") {
print("T");
}
if (a == "T") {
print("A");
}
if (a == "C") {
print("G");
}
if (a == "G") {
print("");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
private static void Yes() { print("YES"); }
private static void No() { print("NO"); }
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
var a = Read();
if (a == "A") {
print("T");
}
if (a == "T") {
print("A");
}
if (a == "C") {
print("G");
}
if (a == "G") {
print("C");
}
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 320
| 1
|
using System;
using System.Linq;
public class Program {
static void Main() {
char[] s = Console.ReadLine().ToCharArray();
int max = 0;
for (int i = 0; i < s.Length; i++) {
if (!isAgtc(s[i]))
s[i] = ' ';
}
for (int i = 0; i < s.Length - 1; i++) {
if (s[i] == ' ')
continue;
int count = 1;
for (int j = i + 1; j < s.Length; j++) {
if (s[j] == ' ')
break;
else
count++;
}
max = Math.Max(count, max);
}
Console.WriteLine(max);
}
static bool isAgtc(char c) {
char[] agtc = { 'A', 'G', 'T', 'C' };
bool res = false;
for (int i = 0; i < agtc.Length; i++) {
if (c == agtc[i]) {
res = true;
break;
}
}
return res;
}
}
|
using System;
using System.Linq;
public class Program {
static void Main() {
char[] s = Console.ReadLine().ToCharArray();
int max = 0;
for (int i = 0; i < s.Length; i++) {
if (!isAgtc(s[i]))
s[i] = ' ';
}
for (int i = 0; i < s.Length; i++) {
if (s[i] == ' ')
continue;
int count = 1;
for (int j = i + 1; j < s.Length; j++) {
if (s[j] == ' ')
break;
else
count++;
}
max = Math.Max(count, max);
}
Console.WriteLine(max);
}
static bool isAgtc(char c) {
char[] agtc = { 'A', 'G', 'T', 'C' };
bool res = false;
for (int i = 0; i < agtc.Length; i++) {
if (c == agtc[i]) {
res = true;
break;
}
}
return res;
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 246
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramC {
static void Main() {
var line = Line;
int sum = 0;
for (int i = 0; i < line.Length; i++) {
for (int j = i + 1; j < line.Length; j++) {
if (line.Substring(i, j - i + 1)
.All(x => x == 'A' || x == 'C' || x == 'G' || x == 'T')) {
sum = Math.Max(sum, j - i + 1);
}
}
}
System.Console.WriteLine(sum);
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramC {
static void Main() {
var line = Line;
int sum = 0;
for (int i = 0; i < line.Length; i++) {
for (int j = i; j < line.Length; j++) {
if (line.Substring(i, j - i + 1)
.All(x => x == 'A' || x == 'C' || x == 'G' || x == 'T')) {
sum = Math.Max(sum, j - i + 1);
}
}
}
System.Console.WriteLine(sum);
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
[["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 1,547
| 2
|
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;
class Program {
static void Main() => new Program().solve();
void solve() {
var s = ReadLine().ToCharArray();
var max = 0;
var cnt = 0;
foreach (var ch in s) {
if ("ACGT".Contains(ch)) {
max = ++cnt > max ? cnt : max;
} else {
cnt = 0;
}
}
var ans = cnt;
WriteLine(ans);
}
}
|
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;
class Program {
static void Main() => new Program().solve();
void solve() {
var s = ReadLine().ToCharArray();
var max = 0;
var cnt = 0;
foreach (var ch in s) {
if ("ACGT".Contains(ch)) {
max = ++cnt > max ? cnt : max;
} else {
cnt = 0;
}
}
var ans = max;
WriteLine(ans);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22]]
| 8
| 117
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
class Program {
static void Main(string[] args) { B(); }
static void B() {
var s = Read();
var ans = 0;
for (int i = 0; i < s.Length - 1; i++) {
if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C')
continue;
var count = 1;
for (int j = i + 1; j < s.Length; j++) {
if (s[j] != 'A' && s[j] != 'T' && s[j] != 'G' && s[j] != 'C')
break;
count++;
}
ans = Math.Max(ans, count);
}
Console.WriteLine(ans);
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int DigitsSum(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static IList<string> ReadSplit() => Read().Split().ToList();
static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
class Program {
static void Main(string[] args) { B(); }
static void B() {
var s = Read();
var ans = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C')
continue;
var count = 1;
for (int j = i + 1; j < s.Length; j++) {
if (s[j] != 'A' && s[j] != 'T' && s[j] != 'G' && s[j] != 'C')
break;
count++;
}
ans = Math.Max(ans, count);
}
Console.WriteLine(ans);
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int DigitsSum(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static IList<string> ReadSplit() => Read().Split().ToList();
static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 526
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122 {
class ABC122_B {
static void Main(string[] args) {
var inputLine = Console.ReadLine();
var count = 0;
var currentMax = 0;
foreach (var c in inputLine) {
switch (c) {
case 'A':
case 'G':
case 'C':
case 'T':
count++;
continue;
}
if (currentMax < count) {
currentMax = count;
}
count = 0;
}
Console.WriteLine(currentMax);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122 {
class ABC122_B {
static void Main(string[] args) {
var inputLine = Console.ReadLine();
var count = 0;
var currentMax = 0;
foreach (var c in inputLine) {
switch (c) {
case 'A':
case 'G':
case 'C':
case 'T':
count++;
if (currentMax < count) {
currentMax = count;
}
continue;
}
count = 0;
}
Console.WriteLine(currentMax);
}
}
}
|
[["-", 0, 99, 8, 254, 0, 239, 0, 116, 0, 117], ["-", 0, 99, 8, 254, 0, 239, 0, 116, 0, 35], ["-", 0, 210, 8, 196, 0, 99, 8, 254, 0, 46], ["+", 0, 239, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 254, 0, 239, 0, 57, 64, 196, 0, 46], ["+", 0, 99, 8, 254, 0, 239, 0, 116, 0, 117]]
| 8
| 128
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122B {
class Program {
public static string[] st;
public static int counter = 0;
static void Main(string[] args) {
string s = Console.ReadLine();
st = new string[s.Length];
for (int i = 0; i < s.Length; i++) {
st[i] = s.Substring(i, 1);
}
int max = 0;
int tmp = 0;
for (int i = 0; i < s.Length; i++) {
counter = 0;
tmp = nextString(i);
if (tmp > max)
max = tmp;
}
Console.WriteLine(max);
}
public static int nextString(int n) {
if ((st[n] == "A") || (st[n] == "C") || (st[n] == "G") || (st[n] == "T")) {
counter++;
if (n < st.Length - 2)
nextString(n + 1); //文字列の長さを超えないように
}
return counter;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122B {
class Program {
public static string[] st;
public static int counter = 0;
static void Main(string[] args) {
string s = Console.ReadLine();
st = new string[s.Length];
for (int i = 0; i < s.Length; i++) {
st[i] = s.Substring(i, 1);
}
int max = 0;
int tmp = 0;
for (int i = 0; i < s.Length; i++) {
counter = 0;
tmp = nextString(i);
if (tmp > max)
max = tmp;
}
Console.WriteLine(max);
}
public static int nextString(int n) {
if ((st[n] == "A") || (st[n] == "C") || (st[n] == "G") || (st[n] == "T")) {
counter++;
if (n < st.Length - 1)
nextString(n + 1); //文字列の長さを超えないように
}
return counter;
}
}
}
|
[["-", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 249
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder.ABC122.B {
class Program {
public static void Main() {
// Solve("ATCODER");
// Solve("HATAGAYA");
// Solve("SHINJUKU");
// Solve("ACGTACGT");
Solve(Console.ReadLine());
}
static void Solve(string S) {
var reg = new Regex(@"^[ACGT]+$");
if (reg.IsMatch(S)) {
Console.WriteLine(S.Length);
return;
}
var max = 0;
for (int i = 1; i < S.Length - 1; ++i) {
for (int j = 0; j + i <= S.Length; ++j) {
if (i < max) {
continue;
}
var str = S.Substring(j, i);
max = reg.IsMatch(str) ? i : max;
// Console.WriteLine($"{str}({j},{i}): {reg.IsMatch(str)},
// max={max}");
}
}
Console.WriteLine(max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder.ABC122.B {
class Program {
public static void Main() {
// Solve("A"); //1
// Solve("X"); //0
// Solve("ATCODER"); //3
// Solve("HATAGAYA"); //5
// Solve("SHINJUKU"); //0
// Solve("ACGTACGT"); //8
// Solve("AXAXAXAXAX"); //1
// Solve("AAAAAAAAAA"); //10
// Solve("TGCAXXXXXX"); //4
// Solve("TXCAXXXCGA"); //3
// Solve("XXXXXXXXXA"); //1
// Solve("AXXXXXXXXX"); //1
// Solve("AAAAAAAAAX"); // 9
// Solve("XAAAAAAAAA"); // 9
// Solve("AAX"); // 2
// Solve("XAA"); // 2
// Solve("AX"); // 1
// Solve("XA"); // 1
Solve(Console.ReadLine());
}
static void Solve(string S) {
var reg = new Regex(@"^[ACGT]+$");
if (reg.IsMatch(S)) {
Console.WriteLine(S.Length);
return;
}
var max = 0;
for (int i = 1; i < S.Length; ++i) {
for (int j = 0; j + i <= S.Length; ++j) {
if (i < max) {
continue;
}
var str = S.Substring(j, i);
max = reg.IsMatch(str) ? i : max;
// Console.WriteLine($"{str}({j},{i}): {reg.IsMatch(str)},
// max={max}");
}
}
Console.WriteLine(max);
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 184
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var subStrs = new HashSet<char>() { 'A', 'C', 'G', 'T' };
int maxLen = 0;
for (int i = 0; i < S.Length; i++) {
for (int subLen = S.Length - i; i < subLen; subLen--) {
var sub = S.Substring(i, subLen);
int count = 0;
foreach (var ch in sub) {
if (subStrs.Contains(ch)) {
count++;
if (maxLen < count) {
maxLen = count;
}
} else {
break;
}
}
}
}
Console.WriteLine(maxLen);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var subStrs = new HashSet<char>() { 'A', 'C', 'G', 'T' };
int maxLen = 0;
for (int i = 0; i < S.Length; i++) {
for (int subLen = S.Length - i; i < subLen; subLen--) {
var sub = S.Substring(i, subLen);
int count = 0;
foreach (var ch in sub) {
if (subStrs.Contains(ch)) {
count++;
if (maxLen < count) {
maxLen = count;
}
} else {
count = 0;
continue;
}
}
}
}
Console.WriteLine(maxLen);
}
}
|
[["-", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 116, 0, 117]]
| 8
| 174
| 6
|
using static System.Console;
using static System.Math;
class AtCoder {
public static void Main() {
var s = ReadLine();
int ans = 0;
int ct;
for (int i = 0; i < s.Length; i++) {
ct = 0;
while (i + 1 < s.Length && isACGT(s[i + ct])) {
ct++;
}
ans = Max(ans, ct);
}
WriteLine(ans);
}
static bool isACGT(char c) {
return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}
}
|
using static System.Console;
using static System.Math;
class AtCoder {
public static void Main() {
var s = ReadLine();
int ans = 0;
int ct;
for (int i = 0; i < s.Length; i++) {
ct = 0;
while (i + ct < s.Length && isACGT(s[i + ct])) {
ct++;
}
ans = Max(ans, ct);
}
WriteLine(ans);
}
static bool isACGT(char c) {
return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}
}
|
[["-", 0, 52, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 0, 52, 15, 16, 31, 16, 31, 16, 12, 22]]
| 8
| 136
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace B {
class Program {
static void Main() {
var S = Console.ReadLine().ToList();
int maxLen = 0;
for (int winSize = 1; winSize <= S.Count; winSize++) {
// winSizeは部分文字列の長さ(窓のサイズ)
for (int i = 0; i + winSize < S.Count; i++) {
// Console.WriteLine(i + " ~ " + (i + winSize));
var subS = S.GetRange(i, winSize);
int count = 0;
foreach (var c in subS) {
// Console.Write(c);
if (c != 'A' && c != 'C' && c != 'G' && c != 'T')
break;
count++;
}
// Console.WriteLine();
if (count == subS.Count)
maxLen = count;
}
}
Console.WriteLine(maxLen);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace B {
class Program {
static void Main() {
var S = Console.ReadLine().ToList();
int maxLen = 0;
for (int winSize = 1; winSize <= S.Count; winSize++) {
// winSizeは部分文字列の長さ(窓のサイズ)
for (int i = 0; i + winSize <= S.Count; i++) {
// Console.WriteLine(i + " ~ " + (i + winSize));
var subS = S.GetRange(i, winSize);
int count = 0;
foreach (var c in subS) {
// Console.Write(c);
if (c != 'A' && c != 'C' && c != 'G' && c != 'T')
break;
count++;
}
// Console.WriteLine();
if (count == subS.Count)
maxLen = count;
}
}
Console.WriteLine(maxLen);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 166
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
// マップの作成
List<char> acgt = new List<char>() { 'A', 'C', 'G', 'T' };
// 入力読み込み
string s = Console.ReadLine();
// 出力
string temp = "";
string max = "";
int index = 0;
// charの確認
foreach (char c in s) {
index++;
if (acgt.Contains(c)) {
temp += c;
// 末尾
if (index + 1 == s.Length && temp.Length > max.Length) {
max = temp;
}
} else {
if (temp.Length > max.Length) {
max = temp;
}
temp = "";
}
}
//出力
Console.WriteLine(max.Length);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
// マップの作成
List<char> acgt = new List<char>() { 'A', 'C', 'G', 'T' };
// 入力読み込み
string s = Console.ReadLine();
// 出力
string temp = "";
string max = "";
int index = 0;
// charの確認
foreach (char c in s) {
index++;
if (acgt.Contains(c)) {
temp += c;
// 末尾
if (index == s.Length && temp.Length > max.Length) {
max = temp;
}
} else {
if (temp.Length > max.Length) {
max = temp;
}
temp = "";
}
}
//出力
Console.WriteLine(max.Length);
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203]]
| 8
| 172
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
var targetChars = new Char[] { 'A', 'T', 'C', 'G' };
var maxLenght = 0;
var matchCnt = 0;
var inputChars = input.ToCharArray();
for (var i = 0; i < inputChars.Length; i++) {
var isMatch = false;
// ATCGのうちどれかと合っているか確認
foreach (var targetChar in targetChars) {
if (inputChars[i] == targetChar) {
isMatch = true;
break;
}
}
if (isMatch) {
matchCnt++;
} else {
if (matchCnt > 0 && matchCnt > maxLenght)
maxLenght = matchCnt;
matchCnt = 0;
}
}
Console.WriteLine(maxLenght);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
var targetChars = new Char[] { 'A', 'T', 'C', 'G' };
var maxLenght = 0;
var matchCnt = 0;
var inputChars = input.ToCharArray();
for (var i = 0; i < inputChars.Length; i++) {
var isMatch = false;
// ATCGのうちどれかと合っているか確認
foreach (var targetChar in targetChars) {
if (inputChars[i] == targetChar) {
isMatch = true;
break;
}
}
if (isMatch) {
matchCnt++;
if (matchCnt > 0 && matchCnt > maxLenght)
maxLenght = matchCnt;
} else {
matchCnt = 0;
}
}
Console.WriteLine(maxLenght);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45]]
| 8
| 186
| 6
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) { Solve(); }
private const int MOD = 1000000007;
private const int INF = 100000000;
private static char[] table = new char[] { 'A', 'C', 'G', 'T' };
static void Solve() {
var s = Console.ReadLine();
var sb = new StringBuilder(s);
string ans = "";
for (int len = sb.Length; len >= 1; --len) {
for (int offset = 0; offset + len <= sb.Length; ++offset) {
if (IsAGCT(len, offset, s)) {
ans = s.Substring(offset, len);
Console.WriteLine(ans);
return;
}
}
}
Console.WriteLine("");
}
private static bool IsAGCT(int len, int offset, string s) {
for (int i = 0; i < len; ++i) {
int idx = offset + i;
if (!table.Contains(s[idx])) {
return false;
}
}
return true;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) { Solve(); }
private const int MOD = 1000000007;
private const int INF = 100000000;
private static char[] table = new char[] { 'A', 'C', 'G', 'T' };
static void Solve() {
var s = Console.ReadLine();
var sb = new StringBuilder(s);
string ans = "";
for (int len = sb.Length; len >= 1; --len) {
for (int offset = 0; offset + len <= sb.Length; ++offset) {
if (IsAGCT(len, offset, s)) {
ans = s.Substring(offset, len);
Console.WriteLine(ans.Length);
return;
}
}
}
Console.WriteLine(0);
}
private static bool IsAGCT(int len, int offset, string s) {
for (int i = 0; i < len; ++i) {
int idx = offset + i;
if (!table.Contains(s[idx])) {
return false;
}
}
return true;
}
#region よく使う便利関数
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 1,199
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122_2 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string strACGT;
int ACGTcount = 0;
int maxCount = 0;
for (int i = 0; i < S.Length - 1; i++) {
strACGT = S.Substring(i, 1);
if (strACGT == "A" || strACGT == "C" || strACGT == "G" ||
strACGT == "T") {
++ACGTcount;
} else {
if (maxCount < ACGTcount) {
maxCount = ACGTcount;
}
ACGTcount = 0;
}
}
if (maxCount < ACGTcount) {
maxCount = ACGTcount;
}
Console.WriteLine(maxCount.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC122_2 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string strACGT;
int ACGTcount = 0;
int maxCount = 0;
for (int i = 0; i < S.Length; i++) {
strACGT = S.Substring(i, 1);
if (strACGT == "A" || strACGT == "C" || strACGT == "G" ||
strACGT == "T") {
++ACGTcount;
} else {
if (maxCount < ACGTcount) {
maxCount = ACGTcount;
}
ACGTcount = 0;
}
}
if (maxCount < ACGTcount) {
maxCount = ACGTcount;
}
Console.WriteLine(maxCount.ToString());
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 172
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
string S = NextString();
string _S = new string(S.Reverse().ToArray());
int ans = 0;
string box = "";
char[] cs = { 'A', 'T', 'C', 'G' };
for (int i = 0; i < S.Length; i++) {
for (int j = 0; j < S.Length - i; j++) {
string a = S.Substring(i, j);
string b = _S.Substring(i, j);
int ac = 0;
int bc = 0;
cs.ToList().ForEach(c => ac += a.Count(v => v == c));
cs.ToList().ForEach(c => bc += b.Count(v => v == c));
if (ac == a.Length)
ans = Math.Max(ans, ac);
else if (bc == b.Length)
ans = Math.Max(ans, bc);
}
}
Console.WriteLine(ans);
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
string S = NextString();
string _S = new string(S.Reverse().ToArray());
int ans = 0;
string box = "";
char[] cs = { 'A', 'T', 'C', 'G' };
for (int i = 0; i < S.Length; i++) {
for (int j = 0; j <= S.Length - i; j++) {
string a = S.Substring(i, j);
string b = _S.Substring(i, j);
int ac = 0;
int bc = 0;
cs.ToList().ForEach(c => ac += a.Count(v => v == c));
cs.ToList().ForEach(c => bc += b.Count(v => v == c));
if (ac == a.Length)
ans = Math.Max(ans, ac);
else if (bc == b.Length)
ans = Math.Max(ans, bc);
}
}
Console.WriteLine(ans);
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 556
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC122B {
static class MainClass {
public static void Main(string[] args) {
string s = Console.ReadLine();
int n = s.Length;
var anslst = new List<int>();
anslst.Add(0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i; j++) {
int tmp = 0;
for (int k = 0; k < j; k++) {
if (s[i + k] == 'A' || s[i + k] == 'T' || s[i + k] == 'G' ||
s[i + k] == 'C') {
} else {
tmp = 1;
}
if (k == j - 1 && tmp == 0) {
anslst.Add(j);
}
}
}
}
anslst.Sort();
Console.WriteLine(anslst.Last());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC122B {
static class MainClass {
public static void Main(string[] args) {
string s = Console.ReadLine();
int n = s.Length;
var anslst = new List<int>();
anslst.Add(0);
for (int i = 0; i < n; i++) {
for (int j = 1; j <= n - i; j++) {
int tmp = 0;
for (int k = 0; k < j; k++) {
if (s[i + k] == 'A' || s[i + k] == 'T' || s[i + k] == 'G' ||
s[i + k] == 'C') {
} else {
tmp = 1;
}
if (k == j - 1 && tmp == 0) {
anslst.Add(j);
}
}
}
}
anslst.Sort();
Console.WriteLine(anslst.Last());
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 218
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg122A {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var atcg = new char[4] { 'A', 'T', 'C', 'G' };
var start = false;
var startIndex = 0;
var ans = 0;
var finalCharTrue = false;
for (int i = 0; i < s.Length; i++) {
if (atcg.Contains(s[i])) {
if (!start) {
startIndex = i;
start = true;
}
if (i == s.Length - 1) {
finalCharTrue = true;
}
}
if (start && !atcg.Contains(s[i])) {
ans = Math.Max(ans, i - startIndex);
start = false;
}
}
ans = Math.Max(ans, s.Length - startIndex);
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg122A {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var atcg = new char[4] { 'A', 'T', 'C', 'G' };
var start = false;
var startIndex = 0;
var ans = 0;
var finalCharTrue = false;
for (int i = 0; i < s.Length; i++) {
if (atcg.Contains(s[i])) {
if (!start) {
startIndex = i;
start = true;
}
if (i == s.Length - 1) {
finalCharTrue = true;
}
}
if (start && !atcg.Contains(s[i])) {
ans = Math.Max(ans, i - startIndex);
start = false;
}
}
if (finalCharTrue)
ans = Math.Max(ans, s.Length - startIndex);
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 220
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
Console.WriteLine(Solve());
return;
}
public static string Solve() {
string S = Read();
int ans = 0;
int cnt = 0;
for (int i = 0; i < S.Length; i++) {
for (int j = i; j < S.Length; j++) {
for (int k = i; k < j; k++) {
if (IsACGT(S[k])) {
cnt++;
} else {
break;
}
}
ans = Math.Max(ans, cnt);
cnt = 0;
}
}
return ans.ToString();
}
public static bool IsACGT(char c) {
switch (c) {
case 'A':
case 'C':
case 'G':
case 'T':
return true;
}
return false;
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
Console.WriteLine(Solve());
return;
}
public static string Solve() {
string S = Read();
int ans = 0;
int cnt = 0;
for (int i = 0; i < S.Length; i++) {
for (int j = i; j < S.Length; j++) {
for (int k = i; k <= j; k++) {
if (IsACGT(S[k])) {
cnt++;
} else {
break;
}
}
ans = Math.Max(ans, cnt);
cnt = 0;
}
}
return ans.ToString();
}
public static bool IsACGT(char c) {
switch (c) {
case 'A':
case 'C':
case 'G':
case 'T':
return true;
}
return false;
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 351
| 2
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var ACGT = "ACGT".ToCharArray();
var S = Console.ReadLine();
var max = 0;
for (int i = 0; i < S.Length; i++) {
for (int k = i + 1; k < S.Length; k++) {
var tmp = S.Substring(i, k - i);
if (tmp.All(c => ACGT.Contains(c))) {
if (tmp.Length > max)
max = tmp.Length;
}
}
}
Console.WriteLine(max);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var ACGT = "ACGT".ToCharArray();
var S = Console.ReadLine();
var max = 0;
for (int i = 0; i < S.Length; i++) {
for (int k = i + 1; k <= S.Length; k++) {
var tmp = S.Substring(i, k - i);
if (tmp.All(c => ACGT.Contains(c))) {
if (tmp.Length > max)
max = tmp.Length;
}
}
}
Console.WriteLine(max);
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 139
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var p = Input().ToInt();
var n = p[0];
var q = p[1];
var s = Console.ReadLine();
var t = new int[n + 2];
for (int i = 1; i <= n; i++) {
if (s[i - 1] == 'A' && s[i] == 'C')
t[i] = t[i - 1] + 1;
else
t[i] = t[i - 1];
}
for (int i = 0; i < q; i++) {
p = Input().ToInt();
Console.WriteLine(t[p[1] - 1] - t[p[0] - 1]);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999;
public static void Main(string[] args) {
var p = Input().ToInt();
var n = p[0];
var q = p[1];
var s = Console.ReadLine();
var t = new int[n + 2];
for (int i = 1; i < n; i++) {
if (s[i - 1] == 'A' && s[i] == 'C')
t[i] = t[i - 1] + 1;
else
t[i] = t[i - 1];
}
for (int i = 0; i < q; i++) {
p = Input().ToInt();
Console.WriteLine(t[p[1] - 1] - t[p[0] - 1]);
}
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
| 8
| 408
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace algorithm {
class Program {
static void Main(string[] args) {
int[] q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToArray();
int cnt = 0;
char[] s = Console.ReadLine().ToCharArray();
int[] ans = new int[s.Length + 1];
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'A' && s[i + 1] == 'C') {
cnt++;
}
ans[i + 1] = cnt;
}
int[] a = new int[q[1]];
for (int i = 0; i < q[1]; i++) {
int[] tmp =
Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToArray();
a[i] = ans[tmp[1] - 1] - ans[tmp[0] - 1];
}
foreach (int y in a) {
Console.WriteLine(y);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace algorithm {
class Program {
static void Main(string[] args) {
int[] q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToArray();
int cnt = 0;
char[] s = Console.ReadLine().ToCharArray();
int[] ans = new int[s.Length + 1];
for (int i = 0; i < s.Length - 1; i++) {
if (s[i] == 'A' && s[i + 1] == 'C')
cnt++;
ans[i + 1] = cnt;
}
int[] a = new int[q[1]];
for (int i = 0; i < q[1]; i++) {
int[] tmp =
Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToArray();
a[i] = ans[tmp[1] - 1] - ans[tmp[0] - 1];
}
foreach (int y in a) {
Console.WriteLine(y);
}
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 258
| 4
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
public static Scanner cin;
static void Main() {
cin = new Scanner();
var nq = cin.arrayInt(2);
int n = nq[0];
int q = nq[1];
string s = ReadLine();
int[][] lrArray = new int [q][];
for (int a = 0; a < q; a++) {
lrArray[a] = cin.arrayInt(2);
}
var hits = new List<int>();
int count = 0;
for (int a = 0; a < s.Length + 1; a++) {
if (a > 2 && s[a - 2] == "A"[0] && s[a - 1] == "C"[0]) {
count++;
}
hits.Add(count);
}
for (int a = 0; a < lrArray.Length; a++) {
int left = lrArray[a][0];
int right = lrArray[a][1];
WriteLine(hits[right] - hits[left - 1 + 1]);
}
// WriteLine(string.Join(",",lrArray[0]));
ReadLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string input() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return input();
i = 0;
return s[i++];
}
public int inputInt() { return int.Parse(input()); }
public int[] arrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = inputInt() + add;
}
return Array;
}
public long inputLong() { return long.Parse(input()); }
public long[] arrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = inputLong() + add;
}
return Array;
}
public double inputDouble() { return double.Parse(input()); }
public double[] arrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = inputDouble() + add;
}
return Array;
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
public static Scanner cin;
static void Main() {
cin = new Scanner();
var nq = cin.arrayInt(2);
int n = nq[0];
int q = nq[1];
string s = ReadLine();
int[][] lrArray = new int [q][];
for (int a = 0; a < q; a++) {
lrArray[a] = cin.arrayInt(2);
}
var hits = new List<int>();
int count = 0;
for (int a = 0; a < s.Length + 1; a++) {
if (a >= 2 && s[a - 2] == "A"[0] && s[a - 1] == "C"[0]) {
count++;
}
hits.Add(count);
}
for (int a = 0; a < lrArray.Length; a++) {
int left = lrArray[a][0];
int right = lrArray[a][1];
WriteLine(hits[right] - hits[left - 1 + 1]);
}
// WriteLine(string.Join(",",lrArray[0]));
ReadLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string input() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return input();
i = 0;
return s[i++];
}
public int inputInt() { return int.Parse(input()); }
public int[] arrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = inputInt() + add;
}
return Array;
}
public long inputLong() { return long.Parse(input()); }
public long[] arrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = inputLong() + add;
}
return Array;
}
public double inputDouble() { return double.Parse(input()); }
public double[] arrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = inputDouble() + add;
}
return Array;
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 20]]
| 8
| 641
| 2
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var n = cin.ReadInt;
var q = cin.ReadInt;
var s = cin.Read;
var counts = new List<int>();
counts.Add(0);
var c = 0;
for (var i = 0; i < n - 1; i++) {
c += (s[i] == 'A' && s[i + 1] == 'C') ? 1 : 0;
counts.Add(c);
WriteLine(c);
}
for (var i = 0; i < q; i++) {
var l = cin.ReadInt;
var r = cin.ReadInt;
var sub_counts = counts[r - 1] - counts[l - 1];
WriteLine(sub_counts);
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var n = cin.ReadInt;
var q = cin.ReadInt;
var s = cin.Read;
var counts = new List<int>();
counts.Add(0);
var c = 0;
for (var i = 0; i < n - 1; i++) {
c += (s[i] == 'A' && s[i + 1] == 'C') ? 1 : 0;
counts.Add(c);
}
for (var i = 0; i < q; i++) {
var l = cin.ReadInt;
var r = cin.ReadInt;
var sub_counts = counts[r - 1] - counts[l - 1];
WriteLine(sub_counts);
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 579
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder.ABC122.C {
class Program {
public static void Main() {
// Solve(8, 3, "ACACTACG", new Tuple<int, int>[] {
// new Tuple<int, int>(3, 7),
// new Tuple<int, int>(2, 3),
// new Tuple<int, int>(1, 8)
// });
// Solve(10, 5, "ACACTACGAC", new Tuple<int, int>[] {
// new Tuple<int, int>(1, 9),
// new Tuple<int, int>(2, 9),
// new Tuple<int, int>(3, 9),
// new Tuple<int, int>(2, 10),
// new Tuple<int, int>(1, 10)
// });
var a = Console.ReadLine().Split(' ');
var N = int.Parse(a[0]);
var Q = int.Parse(a[1]);
var S = Console.ReadLine();
var pairs = new Tuple<int, int>[Q];
for (int i = 0; i < Q; ++i) {
var b = Console.ReadLine().Split(' ');
pairs[i] = new Tuple<int, int>(int.Parse(b[0]), int.Parse(b[1]));
}
Solve(N, Q, S, pairs);
}
static void Solve(int N, int Q, string S, Tuple<int, int>[] pairs) {
string searchWord = "AC";
var t = new int[N + 1];
//始めの位置を探す
int foundIndex = S.IndexOf(searchWord);
for (int i = 0; i < N; ++i) {
t[i + 1] = t[i] + ((S[i] == 'A' && S[i + 1] == 'C') ? 1 : 0);
}
for (int i = 0; i < Q; ++i) {
Console.WriteLine(t[pairs[i].Item2 - 1] - t[pairs[i].Item1 - 1]);
}
}
Dictionary<int, int> cache = new Dictionary<int, int>();
static int Count(string S, int begin, int end) {
return CountChar(S.Substring(begin, end - begin + 1), "AC");
}
public static int CountChar(string s, string c) {
return (s.Length - (s.Replace(c, "").Length)) / c.Length;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder.ABC122.C {
class Program {
public static void Main() {
// Solve(8, 3, "ACACTACG", new Tuple<int, int>[] {
// new Tuple<int, int>(3, 7),
// new Tuple<int, int>(2, 3),
// new Tuple<int, int>(1, 8)
// });
// Solve(10, 5, "ACACTACGAC", new Tuple<int, int>[] {
// new Tuple<int, int>(1, 9),
// new Tuple<int, int>(2, 9),
// new Tuple<int, int>(3, 9),
// new Tuple<int, int>(2, 10),
// new Tuple<int, int>(1, 10)
// });
var a = Console.ReadLine().Split(' ');
var N = int.Parse(a[0]);
var Q = int.Parse(a[1]);
var S = Console.ReadLine();
var pairs = new Tuple<int, int>[Q];
for (int i = 0; i < Q; ++i) {
var b = Console.ReadLine().Split(' ');
pairs[i] = new Tuple<int, int>(int.Parse(b[0]), int.Parse(b[1]));
}
Solve(N, Q, S, pairs);
}
static void Solve(int N, int Q, string S, Tuple<int, int>[] pairs) {
string searchWord = "AC";
var t = new int[N + 1];
//始めの位置を探す
int foundIndex = S.IndexOf(searchWord);
for (int i = 0; i < N - 1; ++i) {
t[i + 1] = t[i] + ((S[i] == 'A' && S[i + 1] == 'C') ? 1 : 0);
}
for (int i = 0; i < Q; ++i) {
Console.WriteLine(t[pairs[i].Item2 - 1] - t[pairs[i].Item1 - 1]);
}
}
Dictionary<int, int> cache = new Dictionary<int, int>();
static int Count(string S, int begin, int end) {
return CountChar(S.Substring(begin, end - begin + 1), "AC");
}
public static int CountChar(string s, string c) {
return (s.Length - (s.Replace(c, "").Length)) / c.Length;
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 443
| 2
|
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Get_AC {
class Program {
public static void Main(string[] args) {
using (var sc = new SetConsole()) {
var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
var str = Console.ReadLine();
var array = Enumerable.Repeat(0, nq[0] + 1).ToArray();
for (int i = 0; i < nq[0]; i++) {
if (str[i] == 'A' && str[i + 1] == 'C') {
array[i + 1] = array[i] + 1;
} else {
array[i + 1] = array[i];
}
}
for (int i = 0; i < nq[1]; i++) {
var lr = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(array[lr[1] - 1] - array[lr[0] - 1]);
}
}
}
}
class SetConsole : IDisposable {
public SetConsole() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public void Dispose() { Console.Out.Flush(); }
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Get_AC {
class Program {
public static void Main(string[] args) {
using (var sc = new SetConsole()) {
var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
var str = Console.ReadLine();
var array = Enumerable.Repeat(0, nq[0] + 1).ToArray();
for (int i = 0; i < nq[0] - 1; i++) {
if (str[i] == 'A' && str[i + 1] == 'C') {
array[i + 1] = array[i] + 1;
} else {
array[i + 1] = array[i];
}
}
for (int i = 0; i < nq[1]; i++) {
var lr = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(array[lr[1] - 1] - array[lr[0] - 1]);
}
}
}
}
class SetConsole : IDisposable {
public SetConsole() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public void Dispose() { Console.Out.Flush(); }
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 296
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _20190324_03 {
class Program {
static void Main(string[] args) {
var line0 =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = line0[0];
var q = line0[1];
var s = Console.ReadLine();
var dict = new Dictionary<int, int>();
var count = 0;
bool isA = false;
for (int i = 0; i < n; i++) {
if (s[i] == 'C' || isA) {
count++;
}
if (s[i] == 'A') {
isA = true;
} else {
isA = false;
}
dict[i + 1] = count;
}
var ans = new List<int>();
for (int i = 0; i < q; i++) {
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var l = line[0];
var r = line[1];
ans.Add(dict[r] - dict[l]);
}
foreach (var item in ans) {
Console.WriteLine(item);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _20190324_03 {
class Program {
static void Main(string[] args) {
var line0 =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = line0[0];
var q = line0[1];
var s = Console.ReadLine();
var dict = new Dictionary<int, int>();
var count = 0;
bool isA = false;
for (int i = 0; i < n; i++) {
if (s[i] == 'C' && isA) {
count++;
}
if (s[i] == 'A') {
isA = true;
} else {
isA = false;
}
dict[i + 1] = count;
}
var ans = new List<int>();
for (int i = 0; i < q; i++) {
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var l = line[0];
var r = line[1];
ans.Add(dict[r] - dict[l]);
}
foreach (var item in ans) {
Console.WriteLine(item);
}
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 299
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
// dummy=0,A=1,G=2,C=3,T=4
var dp = new long[N + 1, 5, 5, 5];
dp[0, 0, 0, 0] = 1;
for (int n = 0; n < N; ++n) {
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 5; ++j) {
for (int k = 0; k < 5; ++k) {
for (int l = 1; l < 5; ++l) {
// AGC GAC ACG A?GC AG?C (i,j,k,l)
if (j == 1 && k == 2 && l == 3 || j == 2 && k == 1 && l == 3 ||
j == 1 && k == 3 && l == 2 || i == 1 && k == 2 && l == 3 ||
i == 1 && j == 2 && l == 3) {
continue;
}
dp[n + 1, j, k, l] =
(dp[n + 1, j, k, l] + dp[n, i, j, k]) % 1000000007;
}
}
}
}
}
var ans = 0L;
for (int i = 1; i < 5; ++i) {
for (int j = 1; j < 5; ++j) {
for (int k = 1; k < 5; ++k) {
ans += (dp[N, i, j, k]) % 1000000007;
}
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
// dummy=0,A=1,G=2,C=3,T=4
var dp = new long[N + 1, 5, 5, 5];
dp[0, 0, 0, 0] = 1;
for (int n = 0; n < N; ++n) {
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 5; ++j) {
for (int k = 0; k < 5; ++k) {
for (int l = 1; l < 5; ++l) {
// AGC GAC ACG A?GC AG?C (i,j,k,l)
if (j == 1 && k == 2 && l == 3 || j == 2 && k == 1 && l == 3 ||
j == 1 && k == 3 && l == 2 || i == 1 && k == 2 && l == 3 ||
i == 1 && j == 2 && l == 3) {
continue;
}
dp[n + 1, j, k, l] =
(dp[n + 1, j, k, l] + dp[n, i, j, k]) % 1000000007;
}
}
}
}
}
var ans = 0L;
for (int i = 1; i < 5; ++i) {
for (int j = 1; j < 5; ++j) {
for (int k = 1; k < 5; ++k) {
ans = (ans + dp[N, i, j, k]) % 1000000007;
}
}
}
Console.WriteLine(ans);
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72]]
| 8
| 336
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var b = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
List<int> c = new List<int>();
for (int i = 0; i < n; i++) {
for (int j = n - 1 - i; j >= 0; j--) {
if (b[j] == j + 1) {
c.Add(j + 1);
b.RemoveAt(j);
break;
}
}
}
if (b.Count != 0) {
Console.WriteLine($"{-1}");
}
StringBuilder sb = new StringBuilder();
for (int i = c.Count - 1; i >= 0; --i) {
sb.AppendLine($"{c[i]}");
}
Console.WriteLine(sb.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var b = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
List<int> c = new List<int>();
for (int i = 0; i < n; i++) {
for (int j = n - 1 - i; j >= 0; j--) {
if (b[j] == j + 1) {
c.Add(j + 1);
b.RemoveAt(j);
break;
}
}
}
if (b.Count != 0) {
Console.WriteLine($"{-1}");
return;
}
StringBuilder sb = new StringBuilder();
for (int i = c.Count - 1; i >= 0; --i) {
sb.AppendLine($"{c[i]}");
}
Console.WriteLine(sb.ToString());
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 244
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int[] b = cin.ArrayInt(N, -1);
List<int> L = new List<int>(b);
List<int> ans = new List<int>();
while (L.Count > 0) {
bool flag = false;
for (int i = L.Count - 1; i >= 0; i--) {
if (L[i] == i) {
ans.Add(i);
L.RemoveAt(i);
flag = true;
break;
}
}
if (!flag) {
Console.WriteLine(-1);
return;
}
}
ans.Reverse();
Console.WriteLine(String.Join("\n", ans));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int[] b = cin.ArrayInt(N, -1);
List<int> L = new List<int>(b);
List<int> ans = new List<int>();
while (L.Count > 0) {
bool flag = false;
for (int i = L.Count - 1; i >= 0; i--) {
if (L[i] == i) {
ans.Add(i + 1);
L.RemoveAt(i);
flag = true;
break;
}
}
if (!flag) {
Console.WriteLine(-1);
return;
}
}
ans.Reverse();
Console.WriteLine(String.Join("\n", ans));
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 591
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var l1 = Console.ReadLine();
var l2 = Console.ReadLine();
var num = int.Parse(l1);
var aa = new List<int>();
var bs = l2.Split(' ').Select(n => int.Parse(n)).ToArray();
foreach (int x in bs) {
var xx = x - 1; // 0 based new b
if (xx < 0 || xx >= aa.Count) {
Console.WriteLine(-1);
return;
}
aa.Insert(xx, xx);
}
foreach (var x in aa) {
Console.WriteLine(x + 1);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var l1 = Console.ReadLine();
var l2 = Console.ReadLine();
var num = int.Parse(l1);
var aa = new List<int>();
var bs = l2.Split(' ').Select(n => int.Parse(n)).ToArray();
foreach (int x in bs) {
var xx = x - 1; // 0 based new b
if (xx < 0 || xx > aa.Count) {
Console.WriteLine(-1);
return;
}
aa.Insert(xx, xx);
}
foreach (var x in aa) {
Console.WriteLine(x + 1);
}
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47]]
| 8
| 169
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var b = ReadInts();
var js = new List<int>();
foreach (var i in Enumerable.Range(0, N).Reverse()) {
if (i == 0) {
PrintList(Enumerable.Reverse(js));
return;
}
foreach (var j in Enumerable.Range(0, i + 1).Reverse()) {
if (j == 0) {
// aに一つも一致するものが含まれない
Console.WriteLine(-1);
return;
}
// Console.WriteLine (j);
if (b[j - 1] == j) {
js.Add(j);
b.RemoveAt(j - 1);
break;
}
}
}
}
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
static List<List<int>> ReadSequence(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var seq = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
return Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
}
static void PrintList<T>(IEnumerable<T> list) {
foreach (var item in list) {
Console.WriteLine(item);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var b = ReadInts();
var js = new List<int>();
foreach (var i in Enumerable.Range(0, N + 1).Reverse()) {
if (i == 0) {
PrintList(Enumerable.Reverse(js));
return;
}
// foreach (var m in Enumerable.Range (0, i)) {
// Console.Write ($"{b[m]} ");
// }
// Console.Write ("\n");
foreach (var j in Enumerable.Range(0, i + 1).Reverse()) {
// Console.WriteLine ("ok");
if (j == 0) {
// aに一つも一致するものが含まれない
Console.WriteLine(-1);
return;
}
if (b[j - 1] == j) {
// Console.WriteLine (j);
js.Add(j);
b.RemoveAt(j - 1);
break;
}
}
}
}
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
static List<List<int>> ReadSequence(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var seq = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
return Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
}
static void PrintList<T>(IEnumerable<T> list) {
foreach (var item in list) {
Console.WriteLine(item);
}
}
}
}
|
[["+", 205, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 346
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static long N;
static long X;
static long[] H;
static Node[] Nodes;
static void Main(string[] args) {
// var NX = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray();
var N = long.Parse(Console.ReadLine());
var ans = false;
long sum = (N + 1) * N / 2;
if (N % 2 == 0) {
Console.WriteLine(N * (N - 2) / 2);
for (int i = 1; i <= N; i++) {
for (int j = i + 1; j <= N; j++) {
if (i + j == N + 1) {
continue;
} else {
Console.WriteLine(i + " " + j);
}
}
}
} else {
Console.WriteLine(N * (N - 3) / 2 + (N - 1));
for (int i = 1; i <= N - 1; i++) {
for (int j = i + 1; j <= N - 1; j++) {
if (i + j == N) {
continue;
} else {
Console.WriteLine(i + " " + j);
}
}
}
for (int i = 1; i <= N - 1; i++) {
Console.WriteLine(i + " " + N);
}
}
}
static void WFS() {
var que = new Queue<long>();
que.Enqueue(X);
Nodes[X].parent = 0;
while (que.Count > 0) {
var top = que.Dequeue();
foreach (var item in Nodes[top].adj) {
if (Nodes[item].parent == -1) {
Nodes[item].parent = top;
que.Enqueue(item);
}
}
}
}
}
class Node {
public List<long> adj;
public long parent = -1;
public Node() { adj = new List<long>(); }
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static long N;
static long X;
static long[] H;
static Node[] Nodes;
static void Main(string[] args) {
// var NX = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray();
var N = long.Parse(Console.ReadLine());
var ans = false;
long sum = (N + 1) * N / 2;
if (N % 2 == 0) {
Console.WriteLine(N * (N - 2) / 2);
for (int i = 1; i <= N; i++) {
for (int j = i + 1; j <= N; j++) {
if (i + j == N + 1) {
continue;
} else {
Console.WriteLine(i + " " + j);
}
}
}
} else {
Console.WriteLine((N - 1) * (N - 3) / 2 + (N - 1));
for (int i = 1; i <= N - 1; i++) {
for (int j = i + 1; j <= N - 1; j++) {
if (i + j == N) {
continue;
} else {
Console.WriteLine(i + " " + j);
}
}
}
for (int i = 1; i <= N - 1; i++) {
Console.WriteLine(i + " " + N);
}
}
}
static void WFS() {
var que = new Queue<long>();
que.Enqueue(X);
Nodes[X].parent = 0;
while (que.Count > 0) {
var top = que.Dequeue();
foreach (var item in Nodes[top].adj) {
if (Nodes[item].parent == -1) {
Nodes[item].parent = top;
que.Enqueue(item);
}
}
}
}
}
class Node {
public List<long> adj;
public long parent = -1;
public Node() { adj = new List<long>(); }
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 444
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
bool isOdd = false;
if (n % 2 == 1) {
isOdd = true;
n -= 1;
}
List<Tuple<int, int>> edges = new List<Tuple<int, int>>();
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (i + j == n + 1)
continue;
edges.Add(new Tuple<int, int>(i, j));
}
}
for (int i = 1; i <= n; i++) {
edges.Add(new Tuple<int, int>(i, n + 1));
}
Console.WriteLine(edges.Count);
Console.WriteLine(
string.Join("\n", edges.Select(x => $"{x.Item1} {x.Item2}")));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
bool isOdd = false;
if (n % 2 == 1) {
isOdd = true;
n -= 1;
}
List<Tuple<int, int>> edges = new List<Tuple<int, int>>();
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (i + j == n + 1)
continue;
edges.Add(new Tuple<int, int>(i, j));
}
}
if (isOdd) {
for (int i = 1; i <= n; i++) {
edges.Add(new Tuple<int, int>(i, n + 1));
}
}
Console.WriteLine(edges.Count);
Console.WriteLine(
string.Join("\n", edges.Select(x => $"{x.Item1} {x.Item2}")));
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 279
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
long A = cin.nextInt();
long B = cin.nextInt();
int[] p = cin.ArrayInt(N);
long MAX = long.MaxValue / 4;
long[] dp = new long[N + 1];
for (int i = 0; i < N + 1; i++) {
dp[i] = MAX;
}
dp[0] = 0;
for (int i = 0; i < N; i++) {
long[] nextDP = new long[N + 1];
for (int j = 0; j < N + 1; j++) {
nextDP[j] = MAX;
}
for (int j = 0; j < N; j++) {
if (j < p[i]) {
nextDP[p[i]] = Math.Min(nextDP[p[i]], dp[j]);
nextDP[j] = Math.Min(nextDP[j], dp[j] + A);
} else {
nextDP[j] = Math.Min(nextDP[j], dp[j] + B);
}
}
dp = nextDP;
}
Console.WriteLine(dp.Min());
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
long A = cin.nextInt();
long B = cin.nextInt();
int[] p = cin.ArrayInt(N);
long MAX = long.MaxValue / 4;
long[] dp = new long[N + 1];
for (int i = 0; i < N + 1; i++) {
dp[i] = MAX;
}
dp[0] = 0;
for (int i = 0; i < N; i++) {
long[] nextDP = new long[N + 1];
for (int j = 0; j < N + 1; j++) {
nextDP[j] = MAX;
}
for (int j = 0; j < N + 1; j++) {
if (j < p[i]) {
nextDP[p[i]] = Math.Min(nextDP[p[i]], dp[j]);
nextDP[j] = Math.Min(nextDP[j], dp[j] + A);
} else {
nextDP[j] = Math.Min(nextDP[j], dp[j] + B);
}
}
dp = nextDP;
}
Console.WriteLine(dp.Min());
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 695
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
int N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
int[] t = new int[26];
Initialize(ref t, 0);
for (var i = 0; i < N; i++) {
t[S[i] - 'a']++;
}
long ans = 1;
for (var i = 0; i < N; i++) {
ans = (ans * (1 + t[i])) % mod;
}
Console.WriteLine(ans - 1);
// Console.Out.Flush();
}
}
public class Scanner {
public int[] SplitReader() {
int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
return array;
}
public long[] SplitReaderL() {
long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
return array;
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
}
struct Pair<T> : IComparable<Pair<T>>
where T : IComparable<T> {
public T variable;
public int index;
public Pair(T val, int i) {
variable = val;
index = i;
}
public int CompareTo(Pair<T> otherPair) {
return variable.CompareTo(otherPair.variable);
}
public int CompareIndex(Pair<T> otherPair) {
return index.CompareTo(otherPair.index);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
int N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
int[] t = new int[26];
Initialize(ref t, 0);
for (var i = 0; i < N; i++) {
t[S[i] - 'a']++;
}
long ans = 1;
for (var i = 0; i < 26; i++) {
ans = (ans * (1 + t[i])) % mod;
}
Console.WriteLine(ans - 1);
// Console.Out.Flush();
}
}
public class Scanner {
public int[] SplitReader() {
int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
return array;
}
public long[] SplitReaderL() {
long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
return array;
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
}
struct Pair<T> : IComparable<Pair<T>>
where T : IComparable<T> {
public T variable;
public int index;
public Pair(T val, int i) {
variable = val;
index = i;
}
public int CompareTo(Pair<T> otherPair) {
return variable.CompareTo(otherPair.variable);
}
public int CompareIndex(Pair<T> otherPair) {
return index.CompareTo(otherPair.index);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 441
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = 1L << 60;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main(string[] args) {
int n = sc.Int;
var s = sc.Str;
var cnt = new int[26];
for (int i = 0; i < n; i++) {
++cnt[s[i] - 'a'];
}
long ans = 0;
foreach (var item in cnt) {
ans = ans * (1 + item) % M;
}
Prt((ans + M - 1) % M);
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >
0;
public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <
0;
public static bool operator >=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) >= 0;
public static bool operator <=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) =>
Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T>
Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = 1L << 60;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main(string[] args) {
int n = sc.Int;
var s = sc.Str;
var cnt = new int[26];
for (int i = 0; i < n; i++) {
++cnt[s[i] - 'a'];
}
long ans = 1;
foreach (var item in cnt) {
ans = ans * (1 + item) % M;
}
Prt((ans + M - 1) % M);
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >
0;
public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <
0;
public static bool operator >=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) >= 0;
public static bool operator <=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) =>
Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T>
Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 2,087
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A {
public class Program
{
const int MOD = (int)1e9 + 7;
public static void Main(string[] args) {
int n = RInt();
string s = RSt();
int[] frec = new int[n];
for (int i = 0; i < s.Length; i++) {
frec[s[i] - 'a']++;
}
long res = 1;
for (int i = 0; i < frec.Count(); i++) {
res = res % MOD * (frec[i] + 1) % MOD;
}
Console.WriteLine((res - 1) % MOD);
}
static string RSt() { return Console.ReadLine(); }
static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
static double RDouble() { return double.Parse(Console.ReadLine()); }
static string[] RStAr(char sep = ' ') {
return Console.ReadLine().Trim().Split(sep);
}
static int[] RIntAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => int.Parse(e));
}
static long[] RLongAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => long.Parse(e));
}
static double[] RDoubleAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => double.Parse(e));
}
static string WAr<T>(IEnumerable<T> array, string sep = " ") {
return string.Join(sep, array.Select(x => x.ToString()).ToArray());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace A {
public class Program
{
const int MOD = (int)1e9 + 7;
public static void Main(string[] args) {
int n = RInt();
string s = RSt();
int[] frec = new int[26];
for (int i = 0; i < s.Length; i++) {
frec[s[i] - 'a']++;
}
long res = 1;
for (int i = 0; i < frec.Count(); i++) {
res = res % MOD * (frec[i] + 1) % MOD;
}
Console.WriteLine((res - 1) % MOD);
}
static string RSt() { return Console.ReadLine(); }
static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
static double RDouble() { return double.Parse(Console.ReadLine()); }
static string[] RStAr(char sep = ' ') {
return Console.ReadLine().Trim().Split(sep);
}
static int[] RIntAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => int.Parse(e));
}
static long[] RLongAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => long.Parse(e));
}
static double[] RDoubleAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => double.Parse(e));
}
static string WAr<T>(IEnumerable<T> array, string sep = " ") {
return string.Join(sep, array.Select(x => x.ToString()).ToArray());
}
}
}
|
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203]]
| 8
| 455
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
string S = cin.next();
int[] cnt = new int[26];
for (int i = 0; i < N; i++) {
cnt[S[i] - 'a']++;
}
long mod = 1000000007;
long ans = 1;
for (int i = 0; i < N; i++) {
ans *= cnt[i] + 1;
ans %= mod;
}
ans += mod - 1;
ans %= mod;
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
string S = cin.next();
int[] cnt = new int[26];
for (int i = 0; i < N; i++) {
cnt[S[i] - 'a']++;
}
long mod = 1000000007;
long ans = 1;
for (int i = 0; i < 26; i++) {
ans *= cnt[i] + 1;
ans %= mod;
}
ans += mod - 1;
ans %= mod;
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 547
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program {
static long Solve(int N, int[] C) {
var dp = new long[N];
var pos = Enumerable.Repeat(-1, N).ToArray();
Func<int, long> DP = i => (i < 0) ? 1 : dp[i];
for (int i = 0; i < N; ++i) {
int j = pos[C[i]];
if (0 <= j && j < i - 1) {
dp[i] = (DP(i - 1) + DP(j)) % 1000000007;
} else {
dp[i] = DP(i - 1);
}
pos[C[i]] = i;
}
return dp[N - 1];
}
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var C = new int[N];
for (int i = 0; i < N; ++i) {
C[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine(Solve(N, C));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program {
static long Solve(int N, int[] C) {
var dp = new long[N];
var pos = Enumerable.Repeat(-1, 200001).ToArray();
Func<int, long> DP = i => (i < 0) ? 1 : dp[i];
for (int i = 0; i < N; ++i) {
int j = pos[C[i]];
if (0 <= j && j < i - 1) {
dp[i] = (DP(i - 1) + DP(j)) % 1000000007;
} else {
dp[i] = DP(i - 1);
}
pos[C[i]] = i;
}
return dp[N - 1];
}
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var C = new int[N];
for (int i = 0; i < N; ++i) {
C[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine(Solve(N, C));
}
}
|
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 261
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) { new Program().Calc(); }
Scanner cin;
public Program() {}
void Calc() {
cin = new Scanner();
int n = cin.nextInt();
// int[] c = new int[n + 1];
int[] colorFound = new int[n + 2];
int[] jumpPoint = new int[n + 2];
int[] pointUp = new int[n + 2];
for (int i = 1; i <= n; ++i) {
int color = cin.nextInt();
// c[i] = color;
if (colorFound[color] != 0 && colorFound[color] != i - 1) {
jumpPoint[colorFound[color]] = i;
}
colorFound[color] = i;
}
int dp = 0;
for (int i = 1; i <= n; ++i) {
dp += pointUp[i];
dp %= 1000000007;
if (jumpPoint[i] != 0) {
int dp_ = (pointUp[jumpPoint[i]] + dp + 1) % 1000000007;
pointUp[jumpPoint[i]] = dp_;
}
}
dp += 1;
dp %= 1000000007;
Console.WriteLine(dp);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) { new Program().Calc(); }
Scanner cin;
public Program() {}
void Calc() {
cin = new Scanner();
int n = cin.nextInt();
// int[] c = new int[n + 1];
int[] colorFound = new int[200001];
int[] jumpPoint = new int[n + 1];
int[] pointUp = new int[n + 1];
for (int i = 1; i <= n; ++i) {
int color = cin.nextInt();
// c[i] = color;
if (colorFound[color] != 0 && colorFound[color] != i - 1) {
jumpPoint[colorFound[color]] = i;
}
colorFound[color] = i;
}
int dp = 0;
for (int i = 1; i <= n; ++i) {
dp += pointUp[i];
dp %= 1000000007;
if (jumpPoint[i] != 0) {
int dp_ = (pointUp[jumpPoint[i]] + dp + 1) % 1000000007;
pointUp[jumpPoint[i]] = dp_;
}
}
dp += 1;
dp %= 1000000007;
Console.WriteLine(dp);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203]]
| 8
| 622
| 8
|
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Linq;
using System.IO;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new ConsoleInput(Console.In, ' '));
Console.Out.Flush();
#if DEBUG
ReadLine();
#endif
}
void Solve(ConsoleInput cin) {
int M = 1000000007;
int n = cin.ReadInt;
int[] c = cin.ReadIntArray(n);
int[] left = new int[20001];
for (int i = 0; i <= 20000; i++)
left[i] = -1;
long[] dp = new long[n + 1];
dp[0] = 1;
for (int i = 0; i < n; i++) {
dp[i + 1] = dp[i];
if (i > 0 && c[i] != c[i - 1] && left[c[i]] >= 0 && left[c[i]] < i - 1) {
dp[i + 1] += dp[left[c[i]] + 1];
dp[i + 1] %= M;
}
left[c[i]] = i;
}
Console.WriteLine(dp[n]);
}
class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Linq;
using System.IO;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new ConsoleInput(Console.In, ' '));
Console.Out.Flush();
#if DEBUG
ReadLine();
#endif
}
void Solve(ConsoleInput cin) {
int M = 1000000007;
int n = cin.ReadInt;
int[] c = cin.ReadIntArray(n);
int[] left = new int[200001];
for (int i = 0; i <= 200000; i++)
left[i] = -1;
long[] dp = new long[n + 1];
dp[0] = 1;
for (int i = 0; i < n; i++) {
dp[i + 1] = dp[i];
if (i > 0 && c[i] != c[i - 1] && left[c[i]] >= 0 && left[c[i]] < i - 1) {
dp[i + 1] += dp[left[c[i]] + 1];
dp[i + 1] %= M;
}
left[c[i]] = i;
}
Console.WriteLine(dp[n]);
}
class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
[["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 653
| 4
|
using System;
using System.Collections.Generic;
public class CSharp {
public static void Main() {
Kyopuro chokudai = new Kyopuro();
chokudai.AtCoder();
}
}
public class Kyopuro {
public void AtCoder() {
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int a = int.Parse(s[1]);
int b = int.Parse(s[2]);
int x = 0;
int y = 0;
int ta = a;
int tb = b;
for (int i = 0; i < n; i++) {
if (ta % 2 == 1)
x++;
if (tb % 2 == 1)
y++;
ta /= 2;
tb /= 2;
}
if (x % 2 == y % 2) {
Console.WriteLine("NO");
return;
}
Console.WriteLine("YES");
int[] t = new int[n + 1];
t[0] = 1;
for (int i = 1; i <= n; i++) {
t[i] = t[i - 1] * 2;
}
int[] z = new int[t[n]];
z[0] = 0;
z[1] = 1;
for (int i = 1; i < n; i++) {
for (int j = t[i]; j < t[i + 1]; j++) {
z[j] = z[t[i + 1] - j - 1];
z[j] += t[i];
}
}
int[] z1 = new int[t[n - 1]];
int[] z2 = new int[t[n - 1]];
for (int i = 0; i < t[n]; i++) {
if (a % 2 == 0) {
if (i % 2 == 0)
z1[i / 2] = z[i];
if (i % 2 == 1)
z2[i / 2] = z[i];
}
if (a % 2 == 1) {
if (i % 2 == 0)
z2[i / 2] = z[i];
if (i % 2 == 1)
z1[i / 2] = z[i];
}
}
int start = 0;
while (z1[start] != a)
start++;
int p = start;
while (true) {
Console.Write(z1[p] + " ");
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
p++;
if (p >= t[n - 1])
p = 0;
}
int f = 0;
while (true) {
if (p + 1 == start || (p + 1 == t[n - 1] && start == 0)) {
f = 1;
break;
}
p++;
if (p >= t[n - 1])
p = 0;
Console.Write(z2[p] + " ");
if (p + 1 == start || (p + 1 == t[n - 1] && start == 0)) {
f = 2;
break;
}
p++;
if (p >= t[n - 1])
p = 0;
Console.Write(z1[p] + " ");
}
if (f == 1) {
p++;
if (p >= t[n - 1])
p = 0;
while (true) {
p--;
if (p < 0)
p = t[n - 1] - 1;
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
p--;
if (p < 0)
p = t[n - 1] - 1;
Console.Write(z1[p] + " ");
}
}
if (f == 2) {
p++;
if (p >= t[n - 1])
p = 0;
while (true) {
p--;
if (p < 0)
p = t[n - 1] - 1;
Console.Write(z1[p] + " ");
p--;
if (p < 0)
p = t[n - 1] - 1;
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
}
}
Console.WriteLine(b);
}
public static void DebugWL(object x) {
System.Diagnostics.Debug.WriteLine(x);
}
}
|
using System;
using System.Collections.Generic;
public class CSharp {
public static void Main() {
Kyopuro chokudai = new Kyopuro();
chokudai.AtCoder();
}
}
public class Kyopuro {
public void AtCoder() {
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int a = int.Parse(s[1]);
int b = int.Parse(s[2]);
int x = 0;
int y = 0;
int ta = a;
int tb = b;
for (int i = 0; i < n; i++) {
if (ta % 2 == 1)
x++;
if (tb % 2 == 1)
y++;
ta /= 2;
tb /= 2;
}
if (x % 2 == y % 2) {
Console.WriteLine("NO");
return;
}
Console.WriteLine("YES");
int[] t = new int[n + 1];
t[0] = 1;
for (int i = 1; i <= n; i++) {
t[i] = t[i - 1] * 2;
}
int[] z = new int[t[n]];
z[0] = 0;
z[1] = 1;
for (int i = 1; i < n; i++) {
for (int j = t[i]; j < t[i + 1]; j++) {
z[j] = z[t[i + 1] - j - 1];
z[j] += t[i];
}
}
int[] z1 = new int[t[n - 1]];
int[] z2 = new int[t[n - 1]];
for (int i = 0; i < t[n]; i++) {
if (x % 2 == 0) {
if (i % 2 == 0)
z1[i / 2] = z[i];
if (i % 2 == 1)
z2[i / 2] = z[i];
}
if (x % 2 == 1) {
if (i % 2 == 0)
z2[i / 2] = z[i];
if (i % 2 == 1)
z1[i / 2] = z[i];
}
}
int start = 0;
while (z1[start] != a)
start++;
int p = start;
while (true) {
Console.Write(z1[p] + " ");
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
p++;
if (p >= t[n - 1])
p = 0;
}
int f = 0;
while (true) {
if (p + 1 == start || (p + 1 == t[n - 1] && start == 0)) {
f = 1;
break;
}
p++;
if (p >= t[n - 1])
p = 0;
Console.Write(z2[p] + " ");
if (p + 1 == start || (p + 1 == t[n - 1] && start == 0)) {
f = 2;
break;
}
p++;
if (p >= t[n - 1])
p = 0;
Console.Write(z1[p] + " ");
}
if (f == 1) {
p++;
if (p >= t[n - 1])
p = 0;
while (true) {
p--;
if (p < 0)
p = t[n - 1] - 1;
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
p--;
if (p < 0)
p = t[n - 1] - 1;
Console.Write(z1[p] + " ");
}
}
if (f == 2) {
p++;
if (p >= t[n - 1])
p = 0;
while (true) {
p--;
if (p < 0)
p = t[n - 1] - 1;
Console.Write(z1[p] + " ");
p--;
if (p < 0)
p = t[n - 1] - 1;
if (z2[p] == b)
break;
Console.Write(z2[p] + " ");
}
}
Console.WriteLine(b);
}
public static void DebugWL(object x) {
System.Diagnostics.Debug.WriteLine(x);
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22]]
| 8
| 978
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
int[] bcnt = new int[1 << 20];
for (int i = 0; i < (1 << 20); i++) {
for (int j = 0; j < 20; j++)
if ((i >> j) % 2 == 1)
bcnt[i]++;
}
int xor = A ^ B;
if (bcnt[xor] % 2 != 1) {
Console.WriteLine("NO");
return;
}
if (N == 1) {
Console.WriteLine("YES");
Console.WriteLine("{0} {1}", A, B);
}
int[] g0 = CreateCode(N, bcnt[xor]);
List<int> one = new List<int>();
List<int> zero = new List<int>();
for (int i = 0; i < N; i++) {
if ((xor >> i) % 2 == 0)
zero.Add(i);
if ((xor >> i) % 2 == 1)
one.Add(i);
}
int[] map = new int[N];
for (int i = 0; i < one.Count; i++) {
map[one[i]] = N - 1 - i;
}
for (int i = 0; i < zero.Count; i++) {
map[zero[i]] = N - 1 - (i + one.Count);
}
int[] g = new int[1 << N];
for (int i = 0; i < 1 << N; i++) {
for (int j = 0; j < N; j++) {
int v = (g0[i] >> map[j]) % 2;
g[i] |= (v << j);
}
}
int[] ans = new int[1 << N];
for (int i = 0; i < (1 << N); i++) {
ans[i] = A ^ g[i];
}
Console.WriteLine("YES");
Console.WriteLine(String.Join(" ", ans));
}
int[] CreateCode(int n, int b) {
int[] a = new int[] { 0, 1, 3, 2 };
int[] ax = new int[] { 2, 3, 1, 0 };
int[] aa = new int[] { 2, 0, 1, 3 };
int[] a2 = new int[] { 0, 1 };
int[] a2x = new int[] { 1, 0 };
int[][] dp = new int [n + 1][];
for (int i = 0; i <= n; i++)
dp[i] = new int[1 << i];
dp[1][0] = 0;
dp[1][1] = 1;
int bb = b / 2;
int now = 1;
for (int k = 0; k < bb; k++) {
int nt = now + 2;
for (int j = 0; j < dp[now].Length; j++) {
if (j % 2 == 0) {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + a[t];
}
} else if (j == dp[now].Length - 1) {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + aa[t];
}
} else {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + ax[t];
}
}
}
now = nt;
}
while (now != n) {
int nt = now + 1;
for (int j = 0; j < dp[now].Length; j++) {
if (j % 2 == 0) {
for (int t = 0; t < 2; t++) {
dp[nt][j * 2 + t] = (dp[now][j] << 1) + a2[t];
}
} else {
for (int t = 0; t < 2; t++) {
dp[nt][j * 2 + t] = (dp[now][j] << 1) + a2x[t];
}
}
}
now = nt;
}
return dp[n];
}
int N, A, B;
public Sol() {
var d = ria();
N = d[0];
A = d[1];
B = d[2];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
int[] bcnt = new int[1 << 20];
for (int i = 0; i < (1 << 20); i++) {
for (int j = 0; j < 20; j++)
if ((i >> j) % 2 == 1)
bcnt[i]++;
}
int xor = A ^ B;
if (bcnt[xor] % 2 != 1) {
Console.WriteLine("NO");
return;
}
if (N == 1) {
Console.WriteLine("YES");
Console.WriteLine("{0} {1}", A, B);
return;
}
int[] g0 = CreateCode(N, bcnt[xor]);
List<int> one = new List<int>();
List<int> zero = new List<int>();
for (int i = 0; i < N; i++) {
if ((xor >> i) % 2 == 0)
zero.Add(i);
if ((xor >> i) % 2 == 1)
one.Add(i);
}
int[] map = new int[N];
for (int i = 0; i < one.Count; i++) {
map[one[i]] = N - 1 - i;
}
for (int i = 0; i < zero.Count; i++) {
map[zero[i]] = N - 1 - (i + one.Count);
}
int[] g = new int[1 << N];
for (int i = 0; i < 1 << N; i++) {
for (int j = 0; j < N; j++) {
int v = (g0[i] >> map[j]) % 2;
g[i] |= (v << j);
}
}
int[] ans = new int[1 << N];
for (int i = 0; i < (1 << N); i++) {
ans[i] = A ^ g[i];
}
Console.WriteLine("YES");
Console.WriteLine(String.Join(" ", ans));
}
int[] CreateCode(int n, int b) {
int[] a = new int[] { 0, 1, 3, 2 };
int[] ax = new int[] { 2, 3, 1, 0 };
int[] aa = new int[] { 2, 0, 1, 3 };
int[] a2 = new int[] { 0, 1 };
int[] a2x = new int[] { 1, 0 };
int[][] dp = new int [n + 1][];
for (int i = 0; i <= n; i++)
dp[i] = new int[1 << i];
dp[1][0] = 0;
dp[1][1] = 1;
int bb = b / 2;
int now = 1;
for (int k = 0; k < bb; k++) {
int nt = now + 2;
for (int j = 0; j < dp[now].Length; j++) {
if (j % 2 == 0) {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + a[t];
}
} else if (j == dp[now].Length - 1) {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + aa[t];
}
} else {
for (int t = 0; t < 4; t++) {
dp[nt][j * 4 + t] = (dp[now][j] << 2) + ax[t];
}
}
}
now = nt;
}
while (now != n) {
int nt = now + 1;
for (int j = 0; j < dp[now].Length; j++) {
if (j % 2 == 0) {
for (int t = 0; t < 2; t++) {
dp[nt][j * 2 + t] = (dp[now][j] << 1) + a2[t];
}
} else {
for (int t = 0; t < 2; t++) {
dp[nt][j * 2 + t] = (dp[now][j] << 1) + a2x[t];
}
}
}
now = nt;
}
return dp[n];
}
int N, A, B;
public Sol() {
var d = ria();
N = d[0];
A = d[1];
B = d[2];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 1,309
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
static int F => int.Parse(Str);
static long FL => long.Parse(Str);
static int[] G => Strs.Select(int.Parse).ToArray();
static decimal[] GD => Strs.Select(decimal.Parse).ToArray();
static long[] GL => Strs.Select(long.Parse).ToArray();
static string Str => ReadLine();
static string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
static int N;
void Solve() {
var I = G;
N = I[0];
WriteLine(ToString(Calc(Get(), Get(), I[1] - 1)));
}
static int[] Get() => G.Select(i => i - 1).ToArray();
static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
static int[] Calc(int[] p, int[] q, int K) {
// if (K == 0) return p;
// if (K == 1) return q;
// if (K < 6) return Calc(q, Mult(q, Inv(p)), K - 1);
int[] ip = Inv(p), iq = Inv(q), x = Mult(q, ip, iq, p),
y = Mult(ip, q, p, iq);
switch (K % 6) {
case 0:
return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
case 1:
return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
case 2:
return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
case 3:
return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
case 4:
return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
default:
return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
}
}
static int[] Inv(int[] a) {
var c = new int[N];
for (var i = 0; i < N; i++)
c[a[i]] = i;
return c;
}
static int[] Mult(int[] a, int[] b) {
var c = new int[N];
for (var i = 0; i < N; i++)
c[i] = a[b[i]];
return c;
}
static int[] Mult(params int[][] a) {
if (a.Length == 0)
return MakeArray(N, i => i);
var x = a[0];
for (var i = 1; i < a.Length; i++)
x = Mult(x, a[i]);
return x;
}
static int[] Pow(int[] a, int b) {
var p = new int[N];
var done = new bool[N];
for (var i = 0; i < N; i++)
if (!done[i]) {
done[i] = true;
var cycle = new List<int> { i };
var x = a[i];
while (x != i) {
cycle.Add(x);
done[x] = true;
x = a[x];
}
var L = cycle.Count;
var c = b % L;
for (var j = 0; j < L; j++)
p[cycle[j]] = cycle[(j + c) % L];
}
return p;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
static int F => int.Parse(Str);
static long FL => long.Parse(Str);
static int[] G => Strs.Select(int.Parse).ToArray();
static decimal[] GD => Strs.Select(decimal.Parse).ToArray();
static long[] GL => Strs.Select(long.Parse).ToArray();
static string Str => ReadLine();
static string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
static int N;
void Solve() {
var I = G;
N = I[0];
WriteLine(ToString(Calc(Get(), Get(), I[1] - 1)));
}
static int[] Get() => G.Select(i => i - 1).ToArray();
static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
static int[] Calc(int[] p, int[] q, int K) {
// if (K == 0) return p;
// if (K == 1) return q;
// if (K < 6) return Calc(q, Mult(q, Inv(p)), K - 1);
int[] ip = Inv(p), iq = Inv(q), x = Mult(q, ip, iq, p),
y = Mult(ip, q, p, iq);
switch (K % 6) {
case 0:
return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
case 1:
return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
case 2:
return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
case 3:
return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
case 4:
return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
default:
return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
}
}
static int[] Inv(int[] a) {
var c = new int[N];
for (var i = 0; i < N; i++)
c[a[i]] = i;
return c;
}
static int[] Mult(int[] a, int[] b) {
var c = new int[N];
for (var i = 0; i < N; i++)
c[i] = a[b[i]];
return c;
}
static int[] Mult(params int[][] a) {
if (a.Length == 0)
return MakeArray(N, i => i);
var x = a[0];
for (var i = 1; i < a.Length; i++)
x = Mult(x, a[i]);
return x;
}
static int[] Pow(int[] a, int b) {
var p = new int[N];
var done = new bool[N];
for (var i = 0; i < N; i++)
if (!done[i]) {
done[i] = true;
var cycle = new List<int> { i };
var x = a[i];
while (x != i) {
cycle.Add(x);
done[x] = true;
x = a[x];
}
var L = cycle.Count;
var c = (b + L) % L;
for (var j = 0; j < L; j++)
p[cycle[j]] = cycle[(j + c) % L];
}
return p;
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25]]
| 8
| 1,031
| 4
|
using System;
using System.Linq;
namespace Sample {
class Sample {
static void Main(string[] args) {
string[] str1 = Console.ReadLine().Split(' ');
int H = int.Parse(str1[0]);
int W = int.Parse(str1[1]);
string[] str2 = Console.ReadLine().Split(' ');
int h = int.Parse(str2[0]);
int w = int.Parse(str2[1]);
Console.WriteLine(H * W - ((h * W) + (H * w) - (h * W)));
}
}
}
|
using System;
using System.Linq;
namespace Sample {
class Sample {
static void Main(string[] args) {
string[] str1 = Console.ReadLine().Split(' ');
int H = int.Parse(str1[0]);
int W = int.Parse(str1[1]);
string[] str2 = Console.ReadLine().Split(' ');
int h = int.Parse(str2[0]);
int w = int.Parse(str2[1]);
Console.WriteLine((H * W) - ((h * W) + (H * w) - (h * w)));
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 22]]
| 8
| 144
| 4
|
using System;
namespace abc121A {
class MainClass {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int A = int.Parse(str[0]);
int B = int.Parse(str[1]);
string[] stri = Console.ReadLine().Split();
int C = int.Parse(str[0]);
int D = int.Parse(str[1]);
int E = (A * B) - ((B * C) + (A * D) - (C * D));
Console.WriteLine(E);
}
}
}
|
using System;
namespace abc121A {
class MainClass {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int A = int.Parse(str[0]);
int B = int.Parse(str[1]);
string[] stri = Console.ReadLine().Split();
int C = int.Parse(stri[0]);
int D = int.Parse(stri[1]);
int E = (A * B) - ((B * C) + (A * D) - (C * D));
Console.WriteLine(E);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 141
| 4
|
using System;
class Program {
static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int H = int.Parse(input1[0]);
int W = int.Parse(input1[1]);
int h = int.Parse(input2[0]);
int w = int.Parse(input2[1]);
int all = H * W;
int black = (h * H) + (w * W) - (h * w);
Console.WriteLine(all - black);
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int H = int.Parse(input1[0]);
int W = int.Parse(input1[1]);
int h = int.Parse(input2[0]);
int w = int.Parse(input2[1]);
int all = H * W;
int black = (w * H) + (h * W) - (h * w);
Console.WriteLine(all - black);
}
}
|
[["-", 0, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22]]
| 8
| 143
| 4
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int h = int.Parse(input[0]);
int w = int.Parse(input[1]);
string[] input2 = Console.ReadLine().Split(' ');
int h2 = int.Parse(input2[0]);
int w2 = int.Parse(input2[1]);
int ans = h * w - h2 * h - w2 * w + h2 * w2;
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int h = int.Parse(input[0]);
int w = int.Parse(input[1]);
string[] input2 = Console.ReadLine().Split(' ');
int h2 = int.Parse(input2[0]);
int w2 = int.Parse(input2[1]);
int ans = h * w - h2 * w - w2 * h + h2 * w2;
Console.WriteLine(ans);
}
}
|
[["-", 0, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 212, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 16, 12, 16, 12, 22]]
| 8
| 128
| 4
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var H = cin.ReadInt;
var W = cin.ReadInt;
var h = cin.ReadInt;
var w = cin.ReadInt;
WriteLine(h * W + H * w - h * w);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var H = cin.ReadInt;
var W = cin.ReadInt;
var h = cin.ReadInt;
var w = cin.ReadInt;
WriteLine(H * W - h * W - H * w + h * w);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
| 8
| 468
| 8
|
using System;
class Program {
static void Main(string[] args) {
//入力の受け取り
string[] input = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int row = int.Parse(input[0]);
int column = int.Parse(input[1]);
int rowBlack = int.Parse(input2[0]);
int columnBlack = int.Parse(input2[1]);
int totalCell = row * column;
int totalBlack = rowBlack * column + (rowBlack - row) * columnBlack;
//提出
Console.WriteLine(totalCell - totalBlack);
}
}
|
using System;
class Program {
static void Main(string[] args) {
//入力の受け取り
string[] input = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int row = int.Parse(input[0]);
int column = int.Parse(input[1]);
int rowBlack = int.Parse(input2[0]);
int columnBlack = int.Parse(input2[1]);
int totalCell = row * column;
int totalBlack = rowBlack * column + (row - rowBlack) * columnBlack;
//提出
Console.WriteLine(totalCell - totalBlack);
}
}
|
[["-", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 139
| 4
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var arr = Console.ReadLine().Split();
var N = int.Parse(arr[0]);
var M = int.Parse(arr[1]);
var C = int.Parse(arr[2]);
var B = Console.ReadLine().Split();
var answer = 0;
for (int i = 1; i <= N; i++) {
var A = Console.ReadLine().Split();
var sum = 0;
for (int j = 1; j <= M; j++) {
sum += int.Parse(A[j]) * int.Parse(B[j]);
}
if (sum + C > 0)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var arr = Console.ReadLine().Split();
var N = int.Parse(arr[0]);
var M = int.Parse(arr[1]);
var C = int.Parse(arr[2]);
var B = Console.ReadLine().Split();
var answer = 0;
for (int i = 1; i <= N; i++) {
var A = Console.ReadLine().Split();
var sum = 0;
for (int j = 0; j < M; j++) {
sum += int.Parse(A[j]) * int.Parse(B[j]);
}
if (sum + C > 0)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18]]
| 8
| 216
| 4
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Contest.B {
static class Program {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
int n = cin.NextInt();
int m = cin.NextInt();
int c = cin.NextInt();
var b = cin.ArrayInt(m);
int ans = 0;
for (int i = 0; i < n; i++) {
var a = cin.ArrayInt(m);
int hoge = c;
for (int j = 0; j < m; j++) {
hoge += a[i] * b[i];
}
if (hoge > 0)
ans++;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Contest.B {
static class Program {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
int n = cin.NextInt();
int m = cin.NextInt();
int c = cin.NextInt();
var b = cin.ArrayInt(m);
int ans = 0;
for (int i = 0; i < n; i++) {
var a = cin.ArrayInt(m);
int hoge = c;
for (int j = 0; j < m; j++) {
hoge += a[j] * b[j];
}
if (hoge > 0)
ans++;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 565
| 4
|
using System;
using System.Linq;
namespace CanYouSolveThis {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = input[0];
var m = input[1];
var c = input[2];
var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var result = 0;
for (int i = 0; i < n; i++) {
var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var sum = 0;
for (int j = 0; j < m; j++) {
sum += a[j] * b[j];
}
if (sum - c > 0)
result++;
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
namespace CanYouSolveThis {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = input[0];
var m = input[1];
var c = input[2];
var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var result = 0;
for (int i = 0; i < n; i++) {
var ai = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var sum = 0;
for (int j = 0; j < m; j++) {
sum += ai[j] * b[j];
}
if (sum + c > 0)
result++;
}
Console.WriteLine(result);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72]]
| 8
| 204
| 6
|
using System;
namespace AtCorderBeginnerContest121 {
class B {
static void Main(string[] args) {
string[] vals = Console.ReadLine().Split(' ');
int N = int.Parse(vals[0]), M = int.Parse(vals[1]), C = int.Parse(vals[2]);
int[] B = new int[M];
vals = Console.ReadLine().Split(' ');
for (int i = 0; i < 20 || i <= M; i++) {
B[i] = int.Parse(vals[i]);
}
int ans;
int count = 0;
for (int i = 0; i < 20 || i < N; i++) {
vals = Console.ReadLine().Split(' ');
ans = C;
for (int j = 0; j < 20 || j < M; j++) {
ans += int.Parse(vals[i]) * B[j];
}
if (ans > 0) {
count++;
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace AtCorderBeginnerContest121 {
class B {
static void Main(string[] args) {
string[] vals = Console.ReadLine().Split(' ');
int N = int.Parse(vals[0]), M = int.Parse(vals[1]), C = int.Parse(vals[2]);
int[] B = new int[M];
vals = Console.ReadLine().Split(' ');
for (int i = 0; i < 20 && i < M; i++) {
B[i] = int.Parse(vals[i]);
}
int ans;
int count = 0;
for (int i = 0; i < 20 && i < N; i++) {
vals = Console.ReadLine().Split(' ');
ans = C;
for (int j = 0; j < 20 && j < M; j++) {
ans += int.Parse(vals[j]) * B[j];
}
if (ans > 0) {
count++;
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 106], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 98], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 106], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 98], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 240
| 10
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var NMC = ReadIntegersWithSpaces();
int N = NMC[0];
int M = NMC[1];
int C = NMC[2];
var BList = ReadIntegersWithSpaces();
List<List<int>> AMatrix = new List<List<int>>();
for (int k = 1; k <= N; k++) {
AMatrix.Add(ReadIntegersWithSpaces());
}
int count = 0;
int sum = 0;
foreach (var row in AMatrix) {
for (int k = 0; k <= M - 1; k++) {
sum += row[k] * BList[k];
}
sum += C;
if (sum > 0) {
count++;
}
}
Console.WriteLine(count);
}
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static List<int> ReadIntList(int length) {
var list = new List<int>();
for (int k = 1; k <= length; k++) {
list.Add(ReadInt());
}
return list;
}
public static List<int> ReadIntegersWithSpaces() {
var strings = Console.ReadLine().Split(' ');
var integers = new List<int>();
foreach (var str in strings) {
integers.Add(int.Parse(str));
}
return integers;
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<long> ReadLongList(int length) {
var list = new List<long>();
for (int k = 1; k <= length; k++) {
list.Add(ReadLong());
}
return list;
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var NMC = ReadIntegersWithSpaces();
int N = NMC[0];
int M = NMC[1];
int C = NMC[2];
var BList = ReadIntegersWithSpaces();
List<List<int>> AMatrix = new List<List<int>>();
for (int k = 1; k <= N; k++) {
AMatrix.Add(ReadIntegersWithSpaces());
}
int count = 0;
int sum = 0;
foreach (var row in AMatrix) {
for (int k = 0; k <= M - 1; k++) {
sum += row[k] * BList[k];
}
sum += C;
if (sum > 0) {
count++;
}
sum = 0;
}
Console.WriteLine(count);
}
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static List<int> ReadIntList(int length) {
var list = new List<int>();
for (int k = 1; k <= length; k++) {
list.Add(ReadInt());
}
return list;
}
public static List<int> ReadIntegersWithSpaces() {
var strings = Console.ReadLine().Split(' ');
var integers = new List<int>();
foreach (var str in strings) {
integers.Add(int.Parse(str));
}
return integers;
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<long> ReadLongList(int length) {
var list = new List<long>();
for (int k = 1; k <= length; k++) {
list.Add(ReadLong());
}
return list;
}
}
}
|
[["+", 0, 210, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 210, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35]]
| 8
| 411
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
var d = Console.ReadLine().Split().Select(long.Parse).ToArray();
var B = Console.ReadLine().Split().Select(long.Parse).ToArray();
int ans = 0;
for (int i = 0; i < d[1]; i++)
if (Console.ReadLine()
.Split()
.Select(long.Parse)
.Zip(B, (x, y) => x * y)
.Sum() +
d[2] >
0)
ans++;
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
var d = Console.ReadLine().Split().Select(long.Parse).ToArray();
var B = Console.ReadLine().Split().Select(long.Parse).ToArray();
int ans = 0;
for (int i = 0; i < d[0]; i++)
if (Console.ReadLine()
.Split()
.Select(int.Parse)
.Zip(B, (x, y) => x * y)
.Sum() +
d[2] >
0)
ans++;
Console.WriteLine(ans);
}
}
|
[["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 151
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int m = sc.NextInt();
Tuple<int, int>[] stores = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
stores[i] = Tuple.Create(sc.NextInt(), sc.NextInt());
}
stores = stores.OrderBy(i => i.Item1).ToArray();
long answer = 0;
for (int i = 0; i < n; i++) {
var store = stores[i];
if (store.Item2 >= m) {
answer += store.Item1 * m;
break;
} else {
answer += store.Item1 * store.Item2;
m -= store.Item2;
}
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int m = sc.NextInt();
Tuple<long, int>[] stores = new Tuple<long, int>[n];
for (int i = 0; i < n; i++) {
stores[i] = Tuple.Create(sc.NextLong(), sc.NextInt());
}
stores = stores.OrderBy(i => i.Item1).ToArray();
long answer = 0;
for (int i = 0; i < n; i++) {
var store = stores[i];
if (store.Item2 >= m) {
answer += store.Item1 * m;
break;
} else {
answer += store.Item1 * store.Item2;
m -= store.Item2;
}
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 198, 39, 224, 39, 236, 237, 238, 0, 199], ["+", 0, 198, 39, 224, 39, 236, 237, 238, 0, 199], ["-", 0, 227, 39, 224, 39, 236, 237, 238, 0, 199], ["+", 0, 227, 39, 224, 39, 236, 237, 238, 0, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22]]
| 8
| 503
| 6
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
static void Main() {
int[] NM = ReadInts;
int N = NM[0];
int M = NM[1];
var drinks = ReadTupleInt(N);
Array.Sort(drinks, (a, b) => a.Item1 - b.Item1);
long money = 0;
for (int i = 0; i < N; i++) {
int m = drinks[i].Item1;
int limit = drinks[i].Item2;
if (limit < M) {
M -= limit;
money += limit * m;
} else {
money += M * m;
break;
}
}
WriteLine(money);
}
/// <summary>
/// 最小公倍数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
/// <summary>
/// 最大公約数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long GetInv(long a, long mod) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod) {
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
struct Vector2Int {
public Vector2Int(int x, int y) {
X = x;
Y = y;
}
public int X;
public int Y;
public double Magnitude => Math.Sqrt(X * X + Y * Y);
public static Vector2Int zero => new Vector2Int(0, 0);
public static Vector2Int u => new Vector2Int(0, 1);
public static Vector2Int r => new Vector2Int(1, 0);
public static Vector2Int d => new Vector2Int(0, -1);
public static Vector2Int l => new Vector2Int(-1, 0);
public static Vector2Int[] AllDirections =>
new Vector2Int[4] { u, r, d, l };
public static Vector2Int[] AllDirections8 =>
new Vector2Int[8] { u, r, d, l, u + r, r + d, d + l, l + u };
public static Vector2Int operator +(Vector2Int a, Vector2Int b) {
return new Vector2Int(a.X + b.X, a.Y + b.Y);
}
public static Vector2Int operator -(Vector2Int a, Vector2Int b) {
return new Vector2Int(a.X - b.X, a.Y - b.Y);
}
public static bool operator ==(Vector2Int a, Vector2Int b) {
return a.X == b.X && a.Y == b.Y;
}
public static bool operator !=(Vector2Int a, Vector2Int b) {
return a.X != b.X || a.Y != b.Y;
}
public static Vector2Int operator *(Vector2Int v, int n) {
return new Vector2Int(v.X * n, v.Y * n);
}
public static Vector2Int operator *(int n, Vector2Int v) {
return new Vector2Int(v.X * n, v.Y * n);
}
}
struct Vector3Int {
public Vector3Int(int x, int y, int z) {
X = x;
Y = y;
Z = z;
}
public int X;
public int Y;
public int Z;
public double Magnitude => Math.Sqrt(X * X + Y * Y + Z * Z);
public static Vector3Int zero => new Vector3Int(0, 0, 0);
public static Vector3Int u => new Vector3Int(0, 1, 0);
public static Vector3Int r => new Vector3Int(1, 0, 0);
public static Vector3Int d => new Vector3Int(0, -1, 0);
public static Vector3Int l => new Vector3Int(-1, 0, 0);
public static Vector3Int operator +(Vector3Int a, Vector3Int b) {
return new Vector3Int(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
}
public static Vector3Int operator -(Vector3Int a, Vector3Int b) {
return new Vector3Int(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
}
public static bool operator ==(Vector3Int a, Vector3Int b) {
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}
public static bool operator !=(Vector3Int a, Vector3Int b) {
return a.X != b.X || a.Y != b.Y || a.Z != b.Z;
}
public static Vector3Int operator *(Vector3Int v, int n) {
return new Vector3Int(v.X * n, v.Y * n, v.Z * n);
}
public static Vector3Int operator *(int n, Vector3Int v) {
return new Vector3Int(v.X * n, v.Y * n, v.Z * n);
}
}
#region Reader
static Vector2Int ReadVec2Int {
get {
string[] s = Console.ReadLine().Split(' ');
return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
}
}
static Vector2Int[] ReadVec2Ints(int n) {
List<Vector2Int> list = new List<Vector2Int>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Vector2Int(ab[0], ab[1]));
}
return list.ToArray();
}
static HashSet<Vector2Int> ReadVec2IntHash(int n) {
HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
hash.Add(new Vector2Int(ab[0], ab[1]));
}
return hash;
}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static long mod = (int)Pow(10, 9) + 7;
}
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
static void Main() {
int[] NM = ReadInts;
int N = NM[0];
int M = NM[1];
var drinks = ReadTupleInt(N);
Array.Sort(drinks, (a, b) => a.Item1 - b.Item1);
long money = 0;
for (int i = 0; i < N; i++) {
long m = drinks[i].Item1;
int limit = drinks[i].Item2;
if (limit < M) {
M -= limit;
money += limit * m;
} else {
money += M * m;
break;
}
}
WriteLine(money);
}
/// <summary>
/// 最小公倍数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
/// <summary>
/// 最大公約数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long GetInv(long a, long mod) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod) {
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
struct Vector2Int {
public Vector2Int(int x, int y) {
X = x;
Y = y;
}
public int X;
public int Y;
public double Magnitude => Math.Sqrt(X * X + Y * Y);
public static Vector2Int zero => new Vector2Int(0, 0);
public static Vector2Int u => new Vector2Int(0, 1);
public static Vector2Int r => new Vector2Int(1, 0);
public static Vector2Int d => new Vector2Int(0, -1);
public static Vector2Int l => new Vector2Int(-1, 0);
public static Vector2Int[] AllDirections =>
new Vector2Int[4] { u, r, d, l };
public static Vector2Int[] AllDirections8 =>
new Vector2Int[8] { u, r, d, l, u + r, r + d, d + l, l + u };
public static Vector2Int operator +(Vector2Int a, Vector2Int b) {
return new Vector2Int(a.X + b.X, a.Y + b.Y);
}
public static Vector2Int operator -(Vector2Int a, Vector2Int b) {
return new Vector2Int(a.X - b.X, a.Y - b.Y);
}
public static bool operator ==(Vector2Int a, Vector2Int b) {
return a.X == b.X && a.Y == b.Y;
}
public static bool operator !=(Vector2Int a, Vector2Int b) {
return a.X != b.X || a.Y != b.Y;
}
public static Vector2Int operator *(Vector2Int v, int n) {
return new Vector2Int(v.X * n, v.Y * n);
}
public static Vector2Int operator *(int n, Vector2Int v) {
return new Vector2Int(v.X * n, v.Y * n);
}
}
struct Vector3Int {
public Vector3Int(int x, int y, int z) {
X = x;
Y = y;
Z = z;
}
public int X;
public int Y;
public int Z;
public double Magnitude => Math.Sqrt(X * X + Y * Y + Z * Z);
public static Vector3Int zero => new Vector3Int(0, 0, 0);
public static Vector3Int u => new Vector3Int(0, 1, 0);
public static Vector3Int r => new Vector3Int(1, 0, 0);
public static Vector3Int d => new Vector3Int(0, -1, 0);
public static Vector3Int l => new Vector3Int(-1, 0, 0);
public static Vector3Int operator +(Vector3Int a, Vector3Int b) {
return new Vector3Int(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
}
public static Vector3Int operator -(Vector3Int a, Vector3Int b) {
return new Vector3Int(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
}
public static bool operator ==(Vector3Int a, Vector3Int b) {
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
}
public static bool operator !=(Vector3Int a, Vector3Int b) {
return a.X != b.X || a.Y != b.Y || a.Z != b.Z;
}
public static Vector3Int operator *(Vector3Int v, int n) {
return new Vector3Int(v.X * n, v.Y * n, v.Z * n);
}
public static Vector3Int operator *(int n, Vector3Int v) {
return new Vector3Int(v.X * n, v.Y * n, v.Z * n);
}
}
#region Reader
static Vector2Int ReadVec2Int {
get {
string[] s = Console.ReadLine().Split(' ');
return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
}
}
static Vector2Int[] ReadVec2Ints(int n) {
List<Vector2Int> list = new List<Vector2Int>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Vector2Int(ab[0], ab[1]));
}
return list.ToArray();
}
static HashSet<Vector2Int> ReadVec2IntHash(int n) {
HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
hash.Add(new Vector2Int(ab[0], ab[1]));
}
return hash;
}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static long mod = (int)Pow(10, 9) + 7;
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 2,226
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace test01 {
class Program {
static void Main(string[] args) {
var line = U.GetLineLongParse();
var N = line[0]; // 店の数
var M = line[1]; // 栄養ドリンクの本数
List<MiseInfo> miseInfos = new List<MiseInfo>();
for (int i = 0; i < N; i++) {
var line2 = U.GetLineLongParse();
miseInfos.Add(new MiseInfo() { price = line2[0], cnt = line2[1] });
}
long ans = 0;
long c = M;
miseInfos = miseInfos.OrderBy(e => e.price).ToList();
foreach (var miseInfo in miseInfos) {
var price = miseInfo.price;
var cnt = miseInfo.cnt;
if (cnt == c) {
ans = price * cnt;
break;
} else if (miseInfo.cnt < c) {
ans = ans + price * cnt;
c = c - cnt;
} else {
ans = ans + price * c;
c = c - cnt;
}
if (c <= 0) {
break;
}
}
Console.WriteLine(ans);
}
class MiseInfo {
public long price { get; set; }
public long cnt { get; set; }
}
class U {
public static string GetLine() { return Console.ReadLine(); }
public static List<int> GetLineIntParse() {
return Console.ReadLine().Split().Select(e => int.Parse(e)).ToList();
}
public static List<long> GetLineLongParse() {
return Console.ReadLine().Split().Select(e => long.Parse(e)).ToList();
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace test01 {
class Program {
static void Main(string[] args) {
var line = U.GetLineLongParse();
var N = line[0]; // 店の数
var M = line[1]; // 栄養ドリンクの本数
List<MiseInfo> miseInfos = new List<MiseInfo>();
for (int i = 0; i < N; i++) {
var line2 = U.GetLineLongParse();
miseInfos.Add(new MiseInfo() { price = line2[0], cnt = line2[1] });
}
long ans = 0;
long c = M;
miseInfos = miseInfos.OrderBy(e => e.price).ToList();
foreach (var miseInfo in miseInfos) {
var price = miseInfo.price;
var cnt = miseInfo.cnt;
if (cnt == c) {
ans = ans + price * cnt;
break;
} else if (cnt < c) {
ans = ans + price * cnt;
c = c - cnt;
} else {
ans = ans + price * c;
c = c - cnt;
}
if (c <= 0) {
break;
}
}
Console.WriteLine(ans);
}
class MiseInfo {
public long price { get; set; }
public long cnt { get; set; }
}
class U {
public static string GetLine() { return Console.ReadLine(); }
public static List<int> GetLineIntParse() {
return Console.ReadLine().Split().Select(e => int.Parse(e)).ToList();
}
public static List<long> GetLineLongParse() {
return Console.ReadLine().Split().Select(e => long.Parse(e)).ToList();
}
}
}
}
|
[["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 57, 75, 57, 15, 16, 31, 214, 205, 22], ["-", 0, 57, 75, 57, 15, 16, 31, 214, 0, 131]]
| 8
| 367
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Contest {
public static void Main() {
int n, m;
MyIO.ReadMulti(out n, out m);
Tuple<int, int>[] ab;
MyIO.ReadLines(n, out ab);
Array.Sort(ab, (x, y) => y.Item1 - x.Item1);
long ans = 0;
int rest = m;
foreach (Tuple<int, int> abe in ab) {
if (abe.Item2 < rest) {
ans += (long)abe.Item1 * (long)abe.Item2;
rest -= abe.Item2;
} else {
ans += (long)abe.Item1 * (long)rest;
rest = 0;
break;
}
}
MyIO.WriteMulti(ans);
}
}
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
public static class MyIO {
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private static T cv<T>(string s) =>
eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>()
? ct<T, double>(double.Parse(
s, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c,
out W d, out X e,
out Y f) {
var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(int n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(int n, out Tuple<T, U>[] a) {
a = new Tuple<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new Tuple<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(int n, out Tuple<T, U, V>[] a) {
a = new Tuple<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new Tuple<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadMatrix<T>(int n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
public static void WriteMulti(params object[] a) {
wwp(() => {
foreach (object x in a)
Console.Write("{0} ", x);
Console.WriteLine();
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
foreach (T x in a)
Console.Write("{0} ", x);
Console.WriteLine();
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
foreach (T x in a)
Console.WriteLine(x);
});
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Contest {
public static void Main() {
int n, m;
MyIO.ReadMulti(out n, out m);
Tuple<int, int>[] ab;
MyIO.ReadLines(n, out ab);
Array.Sort(ab, (x, y) => x.Item1 - y.Item1);
long ans = 0;
int rest = m;
foreach (Tuple<int, int> abe in ab) {
if (abe.Item2 < rest) {
ans += (long)abe.Item1 * (long)abe.Item2;
rest -= abe.Item2;
} else {
ans += (long)abe.Item1 * (long)rest;
rest = 0;
break;
}
}
MyIO.WriteMulti(ans);
}
}
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
public static class MyIO {
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private static T cv<T>(string s) =>
eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>()
? ct<T, double>(double.Parse(
s, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c,
out W d, out X e,
out Y f) {
var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(int n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(int n, out Tuple<T, U>[] a) {
a = new Tuple<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new Tuple<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(int n, out Tuple<T, U, V>[] a) {
a = new Tuple<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new Tuple<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadMatrix<T>(int n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
public static void WriteMulti(params object[] a) {
wwp(() => {
foreach (object x in a)
Console.Write("{0} ", x);
Console.WriteLine();
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
foreach (T x in a)
Console.Write("{0} ", x);
Console.WriteLine();
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
foreach (T x in a)
Console.WriteLine(x);
});
}
}
|
[["-", 0, 28, 0, 218, 8, 16, 31, 214, 205, 22], ["+", 0, 28, 0, 218, 8, 16, 31, 214, 205, 22], ["-", 0, 28, 0, 218, 8, 16, 12, 214, 205, 22], ["+", 0, 28, 0, 218, 8, 16, 12, 214, 205, 22]]
| 8
| 1,514
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCore {
public class Program {
private const int MOD = 1000000007;
static void Main(string[] args) {
int[] nm =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int n = nm[0];
int m = nm[1];
AB[] ab = new AB[n];
for (int i = 0; i < n; ++i) {
int[] temp =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
ab[i] = new AB { A = temp[0], B = temp[1] };
}
var ab2 = ab.OrderBy(x => x.A).ToArray();
long ans = 0;
for (int i = 0; i < n; ++i) {
if (m >= ab2[i].B) {
m -= ab2[i].B;
ans += (long)ab2[i].A * ab2[i].B;
} else {
ans += (long)ab2[i].A * m;
}
if (m <= 0) {
break;
}
}
Console.WriteLine(ans);
}
public class AB {
public int A { get; set; }
public int B { get; set; }
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCore {
public class Program {
private const int MOD = 1000000007;
static void Main(string[] args) {
int[] nm =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int n = nm[0];
int m = nm[1];
AB[] ab = new AB[n];
for (int i = 0; i < n; ++i) {
int[] temp =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
ab[i] = new AB { A = temp[0], B = temp[1] };
}
var ab2 = ab.OrderBy(x => x.A).ToArray();
long ans = 0;
for (int i = 0; i < n; ++i) {
if (m >= ab2[i].B) {
m -= ab2[i].B;
ans += (long)ab2[i].A * ab2[i].B;
} else {
ans += (long)ab2[i].A * m;
m = 0;
}
if (m <= 0) {
break;
}
}
Console.WriteLine(ans);
}
public class AB {
public int A { get; set; }
public int B { get; set; }
}
}
}
|
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 313
| 4
|
using System;
using System.Linq;
namespace ABC121_C {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
long kan = nm[1];
var hoge =
Enumerable.Repeat(0, nm[0])
.Select(
x => Console.ReadLine().Split(' ').Select(int.Parse).ToList())
.OrderBy(x => x)
.ToList();
long sum = 0;
foreach (var ch in hoge) {
sum += Math.Min(kan, ch[1]) * ch[0];
kan -= Math.Min(kan, ch[1]);
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Linq;
namespace ABC121_C {
class Program {
static void Main(string[] args) {
var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
long kan = nm[1];
var hoge =
Enumerable.Repeat(0, nm[0])
.Select(
x => Console.ReadLine().Split(' ').Select(long.Parse).ToList())
.OrderBy(x => x[0])
.ToList();
long sum = 0;
foreach (var ch in hoge) {
sum += Math.Min(kan, ch[1]) * ch[0];
kan -= Math.Min(kan, ch[1]);
}
Console.WriteLine(sum);
}
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 204, 206, 207, 0, 70], ["+", 0, 218, 8, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 218, 8, 204, 206, 207, 0, 73]]
| 8
| 171
| 5
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform_Diag<T>(int row, int col, T value,
T defaultValue = default(T)) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = i == j ? defaultValue : value;
}
}
return Ts;
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static void setUniform_Diag<T>(T[,] ts, T value,
T defaultValue = default(T)) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = i == j ? defaultValue : value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
var keys = getKeys();
int N = keys[0];
int M = keys[1];
var shops = new List<Tuple<int, int>>();
for (int i = 0; i < N; i++) {
keys = getKeys();
shops.Add(new Tuple<int, int>(keys[0], keys[1]));
}
shops.Sort();
long answer = 0;
for (int i = 0; i < shops.Count; i++) {
answer += Math.Min(M, shops[i].Item2) * shops[i].Item1;
M -= Math.Min(M, shops[i].Item2);
if (M == 0)
break;
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform_Diag<T>(int row, int col, T value,
T defaultValue = default(T)) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = i == j ? defaultValue : value;
}
}
return Ts;
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static void setUniform_Diag<T>(T[,] ts, T value,
T defaultValue = default(T)) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = i == j ? defaultValue : value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
var keys = getKeys();
long N = keys[0];
long M = keys[1];
var shops = new List<Tuple<long, long>>();
for (int i = 0; i < N; i++) {
keys = getKeys();
shops.Add(new Tuple<long, long>(keys[0], keys[1]));
}
shops.Sort();
long answer = 0;
for (int i = 0; i < shops.Count; i++) {
answer += Math.Min(M, shops[i].Item2) * shops[i].Item1;
M -= Math.Min(M, shops[i].Item2);
if (M == 0)
break;
}
Console.WriteLine(answer);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 39, 236, 237, 238, 0, 236, 237, 238, 0, 199], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 199], ["-", 0, 28, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 28, 0, 230, 39, 236, 237, 238, 0, 199]]
| 8
| 1,550
| 12
|
using System;
class _3 {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
var store = new Store[N];
for (int i = 0; i < N; i++) {
input = Console.ReadLine().Split(' ');
store[i] = new Store();
store[i].A = int.Parse(input[0]);
store[i].B = int.Parse(input[1]);
}
Array.Sort(store);
int money = 0;
int count = 0;
for (int i = 0; i < N; i++) {
int n = 0;
if (M < count + store[i].B) {
n = M - count;
} else {
n = store[i].B;
}
money += n * store[i].A;
count += n;
if (count == M) {
break;
}
}
Console.WriteLine(money);
}
class Store : IComparable<Store> {
public int A { get; set; }
public int B { get; set; }
public int CompareTo(Store other) { return A - other.A; }
}
}
|
using System;
class _3 {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
var store = new Store[N];
for (int i = 0; i < N; i++) {
input = Console.ReadLine().Split(' ');
store[i] = new Store();
store[i].A = int.Parse(input[0]);
store[i].B = int.Parse(input[1]);
}
Array.Sort(store);
long money = 0;
long count = 0;
for (int i = 0; i < N; i++) {
long n = 0;
if (M < count + store[i].B) {
n = M - count;
} else {
n = store[i].B;
}
money += n * store[i].A;
count += n;
if (count == M) {
break;
}
}
Console.WriteLine(money);
}
class Store : IComparable<Store> {
public int A { get; set; }
public int B { get; set; }
public int CompareTo(Store other) { return A - other.A; }
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 292
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BC121C {
class Program {
struct drink {
public int price;
public int stock;
}
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]); // N軒
int M = int.Parse(input[1]); // M本のドリンクを買う
// リストに情報をセットする
List<drink> basket = new List<drink>();
for (var i = 0; i < N; i++) {
drink d = new drink();
string[] inputAB = Console.ReadLine().Split(' ');
d.price = int.Parse(inputAB[0]);
d.stock = int.Parse(inputAB[1]);
basket.Add(d);
}
basket.Sort((a, b) => a.price - b.price); // 価格の安い順に並べた
/*
foreach(drink member in basket)
{
Console.WriteLine(member.price+" "+member.stock);
}
*/
long ans = 0;
for (var i = 0; i < N; i++) {
if (basket[i].stock <= M) {
ans += (long)basket[i].price * (long)basket[i].stock;
M = M - basket[i].stock;
} else {
ans += (long)(basket[i].price * M);
M = 0;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BC121C {
class Program {
struct drink {
public int price;
public int stock;
}
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]); // N軒
int M = int.Parse(input[1]); // M本のドリンクを買う
// リストに情報をセットする
List<drink> basket = new List<drink>();
for (var i = 0; i < N; i++) {
drink d = new drink();
string[] inputAB = Console.ReadLine().Split(' ');
d.price = int.Parse(inputAB[0]);
d.stock = int.Parse(inputAB[1]);
basket.Add(d);
}
basket.Sort((a, b) => a.price - b.price); // 価格の安い順に並べた
/*
foreach(drink member in basket)
{
Console.WriteLine(member.price+" "+member.stock);
}
*/
long ans = 0;
for (var i = 0; i < N; i++) {
if (basket[i].stock <= M) {
ans += (long)basket[i].price * (long)basket[i].stock;
M = M - basket[i].stock;
} else {
ans += (long)basket[i].price * (long)M;
M = 0;
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 1, 0, 11, 12, 74, 51, 23, 0, 24], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 51, 22]]
| 8
| 317
| 5
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
public class D {
public static void Main() {
string[] args = Console.ReadLine().Split(' ');
long A = Int64.Parse(args[0]);
long B = Int64.Parse(args[1]);
Console.WriteLine(fZero(A - 1) ^ fZero(B));
}
private static long fZero(long x) {
switch (x % 4) {
case 0:
return x;
case 1:
return 1;
case 2:
return 1 ^ x;
case 3:
return 0;
default:
throw new Exception();
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
public class D {
public static void Main() {
string[] args = Console.ReadLine().Split(' ');
long A = Int64.Parse(args[0]);
long B = Int64.Parse(args[1]);
Console.WriteLine(fZero(A - 1) ^ fZero(B));
}
private static long fZero(long x) {
switch ((x + 4) % 4) {
case 0:
return x;
case 1:
return 1;
case 2:
return 1 ^ x;
case 3:
return 0;
default:
throw new Exception();
}
}
}
|
[["+", 8, 196, 0, 99, 51, 16, 31, 23, 0, 24], ["+", 0, 99, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 99, 51, 16, 31, 23, 0, 16, 12, 203], ["+", 8, 196, 0, 99, 51, 16, 31, 23, 0, 25]]
| 8
| 146
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC121.Util;
namespace ABC121 {
class Program {
static void Main(string[] args) {
#if DEBUG
while (true) {
#endif
// WhiteCells(); // 12min
// CanYouSolveThis(); // 24min
// EnergyDrinkCollector(); // 45min
XORWorld();
#if DEBUG
}
#endif
}
static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
static int[] CalcGap(long n, int[] binaryArray, bool up = true) {
var lst = new List<int>();
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
if (binaryArray[i] == 0) {
lst.Add(0);
} else {
binaryArray[i] = 0;
long zerorized = BinaryArrayToLong(binaryArray);
lst.Add((n - zerorized + (up ? 0 : 1)) % 2 == 0 ? 0 : 1);
}
}
return lst.ToArray();
}
static void XORWorld() {
long[] tmp = ReadLongArray();
long A = tmp[0];
long B = tmp[1];
var a = CalcGap(A, LongToBinaryArray(A), up: true);
var b = CalcGap(B, LongToBinaryArray(B), up: false);
var alen = a.Length;
var blen = b.Length;
int[] tmp2 = new int[blen];
for (int i = 0; i < blen; i++) {
if (alen <= i) {
tmp2[i] = (b[i] % 2 == 0) ? 0 : 1;
} else {
tmp2[i] = ((a[i] + b[i]) % 2 == 0) ? 0 : 1;
}
}
if (A == 0 && B == 0) {
} else if (A - B == 0) {
tmp2[0] = 0;
} else {
tmp2[0] = (int)(((B - A) / 2 + (A % 2 == 1 ? 1 : 0)) % 2);
}
long ans = BinaryArrayToLong(tmp2);
Console.WriteLine(ans);
}
static void EnergyDrinkCollector() {
var tmp = ReadIntArray();
int N = tmp[0];
int M = tmp[1];
int[][] A = new int [N][];
N.Times(n => { A[n] = ReadIntArray(); });
A = A.OrderBy(i => i[0]).ToArray();
long curPrice = 0;
int curBottle = 0;
for (int i = 0; i < N; i++) {
long price = A[i][0];
int maxBottle = A[i][1];
long maxPrice = price * maxBottle;
if (curBottle + maxBottle >= M) {
while (curBottle < M) {
curPrice += price;
curBottle++;
}
break;
} else {
curPrice += maxPrice;
curBottle += maxBottle;
}
}
Console.WriteLine(curPrice);
}
static void CanYouSolveThis() {
var tmp = ReadIntArray();
int N = tmp[0];
int M = tmp[1];
int C = tmp[2];
int[] B = ReadIntArray();
int[][] A = new int [N][];
N.Times(i => A[i] = ReadIntArray());
int ans = 0;
N.Times(n => {
int sum = 0;
M.Times(m => { sum += A[n][m] * B[m]; });
if (sum + C > 0)
ans++;
});
Console.WriteLine(ans);
}
static void WhiteCells() {
var HW = ReadIntArray();
var H = HW[0];
var W = HW[1];
var hw = ReadIntArray();
var h = hw[0];
var w = hw[1];
bool[,] board = new bool[H, W];
for (int i = 0; i < h; i++) {
for (int j = 0; j < W; j++) {
board[i, j] = true;
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < w; j++) {
board[i, j] = true;
}
}
int ans = 0;
H.Times(i => W.Times(j => {
if (board[i, j] == false)
ans++;
}));
Console.WriteLine(ans);
}
}
#region common
/// <summary>
/// ユーティリティー
/// </summary>
public static class Util {
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string ReadString() { return Console.ReadLine(); }
/// <summary>
/// "00101001010"という様な入力をintの配列にして返す
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray();
}
/// <summary>
/// "00101001010"という様な入力をboolの配列にして返す
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
return Console.ReadLine().Select(c => c == '1').ToArray();
}
/// <summary>
/// ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// 逆順ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyにあるようなやつ
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
}
/// <summary>
/// EqualsとGetHashCodeを提供します。IEqualityComparer<T>を実装するクラスです。
/// HashSetのコンストラクタに渡すために使います。
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T>
where T : IComparable {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
if (_comparison != null)
return _comparison(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC121.Util;
namespace ABC121 {
class Program {
static void Main(string[] args) {
#if DEBUG
while (true) {
#endif
// WhiteCells(); // 12min
// CanYouSolveThis(); // 24min
// EnergyDrinkCollector(); // 45min
XORWorld();
#if DEBUG
}
#endif
}
static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
static int[] CalcGap(long n, int[] binaryArray, bool up = true) {
var lst = new List<int>();
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
if (binaryArray[i] == 0) {
lst.Add(0);
} else {
binaryArray[i] = 0;
long zerorized = BinaryArrayToLong(binaryArray);
lst.Add((n - zerorized + (up ? 0 : 1)) % 2 == 0 ? 0 : 1);
}
}
return lst.ToArray();
}
static void XORWorld() {
long[] tmp = ReadLongArray();
long A = tmp[0];
long B = tmp[1];
var a = CalcGap(A, LongToBinaryArray(A), up: true);
var b = CalcGap(B, LongToBinaryArray(B), up: false);
var alen = a.Length;
var blen = b.Length;
int[] tmp2 = new int[blen];
for (int i = 0; i < blen; i++) {
if (alen <= i) {
tmp2[i] = (b[i] % 2 == 0) ? 0 : 1;
} else {
tmp2[i] = ((a[i] + b[i]) % 2 == 0) ? 0 : 1;
}
}
if (A == 0 && B == 0) {
} else if (A - B == 0) {
tmp2[0] = 0;
} else {
tmp2[0] = (int)((B - A + 1 + (A % 2 == 1 ? 1 : 0)) / 2 % 2);
}
long ans = BinaryArrayToLong(tmp2);
Console.WriteLine(ans);
}
static void EnergyDrinkCollector() {
var tmp = ReadIntArray();
int N = tmp[0];
int M = tmp[1];
int[][] A = new int [N][];
N.Times(n => { A[n] = ReadIntArray(); });
A = A.OrderBy(i => i[0]).ToArray();
long curPrice = 0;
int curBottle = 0;
for (int i = 0; i < N; i++) {
long price = A[i][0];
int maxBottle = A[i][1];
long maxPrice = price * maxBottle;
if (curBottle + maxBottle >= M) {
while (curBottle < M) {
curPrice += price;
curBottle++;
}
break;
} else {
curPrice += maxPrice;
curBottle += maxBottle;
}
}
Console.WriteLine(curPrice);
}
static void CanYouSolveThis() {
var tmp = ReadIntArray();
int N = tmp[0];
int M = tmp[1];
int C = tmp[2];
int[] B = ReadIntArray();
int[][] A = new int [N][];
N.Times(i => A[i] = ReadIntArray());
int ans = 0;
N.Times(n => {
int sum = 0;
M.Times(m => { sum += A[n][m] * B[m]; });
if (sum + C > 0)
ans++;
});
Console.WriteLine(ans);
}
static void WhiteCells() {
var HW = ReadIntArray();
var H = HW[0];
var W = HW[1];
var hw = ReadIntArray();
var h = hw[0];
var w = hw[1];
bool[,] board = new bool[H, W];
for (int i = 0; i < h; i++) {
for (int j = 0; j < W; j++) {
board[i, j] = true;
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < w; j++) {
board[i, j] = true;
}
}
int ans = 0;
H.Times(i => W.Times(j => {
if (board[i, j] == false)
ans++;
}));
Console.WriteLine(ans);
}
}
#region common
/// <summary>
/// ユーティリティー
/// </summary>
public static class Util {
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string ReadString() { return Console.ReadLine(); }
/// <summary>
/// "00101001010"という様な入力をintの配列にして返す
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray();
}
/// <summary>
/// "00101001010"という様な入力をboolの配列にして返す
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
return Console.ReadLine().Select(c => c == '1').ToArray();
}
/// <summary>
/// ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// 逆順ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyにあるようなやつ
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
}
/// <summary>
/// EqualsとGetHashCodeを提供します。IEqualityComparer<T>を実装するクラスです。
/// HashSetのコンストラクタに渡すために使います。
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T>
where T : IComparable {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
if (_comparison != null)
return _comparison(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
[["-", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 85], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 203], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 12, 203], ["+", 12, 74, 51, 23, 0, 16, 31, 16, 17, 85], ["+", 12, 74, 51, 23, 0, 16, 31, 16, 12, 203]]
| 8
| 2,079
| 8
|
using System;
using System.Collections.Generic;
class ABC121_D {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
long A = long.Parse(input[0]);
long B = long.Parse(input[1]);
if (A == B) {
Console.WriteLine(A);
return;
}
int[] A2 = BitCountXOR(A - 1);
int[] B2 = BitCountXOR(B);
long sum = 0;
long exponential = 1;
for (int i = 0; i < B2.Length; i++) {
long a = i < A2.Length ? A2[i] : 0;
long b = B2[i];
if ((a + b) % 2 == 1) {
sum += exponential;
}
exponential *= 2;
}
Console.WriteLine(sum);
}
static int[] BitCountXOR(long num) {
List<int> digit = new List<int>();
long quotient = num + 1;
long exponential = 1;
while (num > exponential / 2) {
long q = quotient / (exponential * 2);
long r = quotient % (exponential * 2);
long bit = r >= exponential ? r - exponential : 0;
bit += q * exponential;
exponential *= 2;
digit.Add((int)bit);
}
return digit.ToArray();
}
}
|
using System;
using System.Collections.Generic;
class ABC121_D {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
long A = long.Parse(input[0]);
long B = long.Parse(input[1]);
if (A == B) {
Console.WriteLine(A);
return;
}
int[] A2 = BitCountXOR(A - 1);
int[] B2 = BitCountXOR(B);
long sum = 0;
long exponential = 1;
for (int i = 0; i < B2.Length; i++) {
long a = i < A2.Length ? A2[i] : 0;
long b = B2[i];
if ((a + b) % 2 == 1) {
sum += exponential;
}
exponential *= 2;
}
Console.WriteLine(sum);
}
static int[] BitCountXOR(long num) {
List<int> digit = new List<int>();
long quotient = num + 1;
long exponential = 1;
while (num > exponential / 2) {
long q = quotient / (exponential * 2);
long r = quotient % (exponential * 2);
long bit = r >= exponential ? r - exponential : 0;
bit += q * exponential;
exponential *= 2;
digit.Add((int)(bit % 2));
}
return digit.ToArray();
}
}
|
[["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 24], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 17, 109], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 25]]
| 8
| 298
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class M {
static void Main(string[] _) {
var I0 = Console.ReadLine().Split(' ');
long A = long.Parse(I0[0]) - 1;
long B = long.Parse(I0[1]);
long a = (A % 2 == 1) ? ((A + 1) / 2) % 2 : (A + (A / 2) % 2);
long b = (B % 2 == 1) ? ((B + 1) / 2) % 2 : (B + (B / 2) % 2);
long r = 0;
long P = 1;
while (P <= a || P <= b) {
r += (((a / P) % 2) != ((b / P) % 2)) ? P : 0;
P *= 2;
}
Console.WriteLine(r);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class M {
static void Main(string[] _) {
var I0 = Console.ReadLine().Split(' ');
long A = long.Parse(I0[0]) - 1;
long B = long.Parse(I0[1]);
long a = (A % 2 != 0) ? ((A + 1) / 2) % 2 : (A + (A / 2) % 2);
long b = (B % 2 != 0) ? ((B + 1) / 2) % 2 : (B + (B / 2) % 2);
long r = 0;
long P = 1;
while (P <= a || P <= b) {
r += (((a / P) % 2) != ((b / P) % 2)) ? P : 0;
P *= 2;
}
Console.WriteLine(r);
}
}
|
[["-", 0, 212, 0, 41, 15, 23, 0, 16, 17, 60], ["-", 0, 212, 0, 41, 15, 23, 0, 16, 12, 203], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 79], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 12, 203]]
| 8
| 205
| 8
|
using System;
using System.Linq;
public class Program {
static void Main() {
var ab = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
Console.WriteLine(F(ab[0] - 1) ^ F(ab[1]));
}
static long F(long b) { return new long[] { b, 1, b + 1, 0 }[b % 4]; }
}
|
using System;
using System.Linq;
public class Program {
static void Main() {
var ab = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
Console.WriteLine(F(ab[0] - 1) ^ F(ab[1]));
}
static long F(long b) { return new long[] { b, 1, b + 1, 0 }[(b + 4) % 4]; }
}
|
[["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 25]]
| 8
| 103
| 4
|
using static System.Console;
using System.Linq;
class P {
static void
Main() => Write(ReadLine()
.Split()
.Select(long.Parse)
.Select((x, i) => new[] { 1, x += i, 0, x ^ 1 }[x & 7])
.Aggregate((a, b) => a ^ b));
}
|
using static System.Console;
using System.Linq;
class P {
static void
Main() => Write(ReadLine()
.Split()
.Select(long.Parse)
.Select((x, i) => new[] { 1, x += i, 0, x ^ 1 }[x % 4])
.Aggregate((a, b) => a ^ b));
}
|
[["-", 8, 204, 206, 207, 0, 28, 0, 16, 17, 67], ["-", 8, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 8, 204, 206, 207, 0, 28, 0, 16, 17, 109], ["+", 8, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 83
| 4
|
using System;
using System.Linq;
namespace ABC121D_3 {
class Program {
static void Main() {
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long A = input[0], B = input[1];
Console.WriteLine(F(A - 1) ^ F(B));
}
static long F(long x) => new[] { x, 1, x + 1, 0 }[x % 4];
}
}
|
using System;
using System.Linq;
namespace ABC121D_3 {
class Program {
static void Main() {
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long A = input[0], B = input[1];
Console.WriteLine(F(A - 1) ^ F(B));
}
static long F(long x) => new[] { x, 1, x + 1, 0 }[(x + 4) % 4];
}
}
|
[["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 25]]
| 8
| 107
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
int F => int.Parse(Str);
long FL => long.Parse(Str);
int[] G => Strs.Select(int.Parse).ToArray();
decimal[] GD => Strs.Select(decimal.Parse).ToArray();
long[] GL => Strs.Select(long.Parse).ToArray();
string Str => ReadLine();
string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
WriteLine(Solve());
Out.Flush();
}
long Solve() {
var I = GL;
long A = I[0], B = I[1];
if (A == B)
return A;
if (A == 0)
A++;
var ans = 0L;
for (var i = 0; i < 50; i++)
if ((Calc(B, i) - Calc(A - 1, i)) % 2 == 0)
ans |= 1L << i;
return ans;
}
// [0,n] の整数のうち k ビット目が 1 のものの個数
long Calc(long n, int k) {
if (k == 0)
return (n + 1) / 2;
var m = 1L << k;
if (n < m)
return 0;
if ((n & m) == 0)
return Calc(n >> k, 0) << k;
return (n & (m - 1)) + 1 + Calc(n ^ m, k);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
int F => int.Parse(Str);
long FL => long.Parse(Str);
int[] G => Strs.Select(int.Parse).ToArray();
decimal[] GD => Strs.Select(decimal.Parse).ToArray();
long[] GL => Strs.Select(long.Parse).ToArray();
string Str => ReadLine();
string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
WriteLine(Solve());
Out.Flush();
}
long Solve() {
var I = GL;
long A = I[0], B = I[1];
if (A == B)
return A;
if (A == 0)
A++;
var ans = 0L;
for (var i = 0; i < 50; i++)
if ((Calc(B, i) - Calc(A - 1, i)) % 2 == 1)
ans |= 1L << i;
return ans;
}
// [0,n] の整数のうち k ビット目が 1 のものの個数
long Calc(long n, int k) {
if (k == 0)
return (n + 1) / 2;
var m = 1L << k;
if (n < m)
return 0;
if ((n & m) == 0)
return Calc(n >> k, 0) << k;
return (n & (m - 1)) + 1 + Calc(n ^ m, k);
}
}
|
[["-", 8, 196, 0, 7, 8, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 57, 15, 16, 12, 203]]
| 8
| 514
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace D {
public class Program
{
public static void Main(string[] args) {
long[] ab = RLongAr();
long a = ab[0];
long b = ab[1];
if (a == b) {
Console.WriteLine(a);
} else {
long res;
if (a == 0) {
res = f(b);
} else {
res = f(a - 1) ^ f(b);
}
Console.WriteLine(res);
}
}
private static long f(long x) {
if (x % 2 == 1) {
return (((x - 1) / 2) % 2 == 0 ? 0 : 1);
} else {
return ((x / 2) % 2 == 0 ? 0 : 1) ^ x;
}
}
static string RSt() { return Console.ReadLine(); }
static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
static double RDouble() { return double.Parse(Console.ReadLine()); }
static string[] RStAr(char sep = ' ') {
return Console.ReadLine().Trim().Split(sep);
}
static int[] RIntAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => int.Parse(e));
}
static long[] RLongAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => long.Parse(e));
}
static double[] RDoubleAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => double.Parse(e));
}
static string WAr<T>(IEnumerable<T> array, string sep = " ") {
return string.Join(sep, array.Select(x => x.ToString()).ToArray());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace D {
public class Program
{
public static void Main(string[] args) {
long[] ab = RLongAr();
long a = ab[0];
long b = ab[1];
if (a == b) {
Console.WriteLine(a);
} else {
long res;
if (a == 0) {
res = f(b);
} else {
res = f(a - 1) ^ f(b);
}
Console.WriteLine(res);
}
}
private static long f(long x) {
if (x % 2 == 1) {
return (((x + 1) / 2) % 2 == 0 ? 0 : 1);
} else {
return ((x / 2) % 2 == 0 ? 0 : 1) ^ x;
}
}
static string RSt() { return Console.ReadLine(); }
static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
static double RDouble() { return double.Parse(Console.ReadLine()); }
static string[] RStAr(char sep = ' ') {
return Console.ReadLine().Trim().Split(sep);
}
static int[] RIntAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => int.Parse(e));
}
static long[] RLongAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => long.Parse(e));
}
static double[] RDoubleAr(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Trim().Split(sep),
e => double.Parse(e));
}
static string WAr<T>(IEnumerable<T> array, string sep = " ") {
return string.Join(sep, array.Select(x => x.ToString()).ToArray());
}
}
}
|
[["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 72]]
| 8
| 481
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = 1L << 60;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main(string[] args) {
long a, b;
sc.Multi(out a, out b);
Prt(xor(a - 1) ^ xor(b));
sw.Flush();
}
static long xor(long a) {
if (a == 0 || a % 4 == 3)
return 0;
if (a % 4 == 1)
return 1;
if (a % 4 == 2)
return a + 1;
return a;
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >
0;
public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <
0;
public static bool operator >=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) >= 0;
public static bool operator <=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) =>
Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T>
Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = 1L << 60;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main(string[] args) {
long a, b;
sc.Multi(out a, out b);
Prt(xor(a - 1) ^ xor(b));
sw.Flush();
}
static long xor(long a) {
if (a <= 0 || a % 4 == 3)
return 0;
if (a % 4 == 1)
return 1;
if (a % 4 == 2)
return a + 1;
return a;
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
public static bool operator>(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) >
0;
public static bool operator<(pair<T, U> a, pair<T, U> b) => a.CompareTo(b) <
0;
public static bool operator >=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) >= 0;
public static bool operator <=(pair<T, U> a,
pair<T, U> b) => a.CompareTo(b) <= 0;
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static T sq<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) =>
Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T>
Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19]]
| 8
| 2,078
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.