Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n;
cin >> n;
int a[n];
long long int c1 = 0, c2 = 0, c3 = 0;
for (l... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 |
import java.util.Scanner;
public class ProblemA {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a[] = { 0, 0, 0, 0 };
int num;
for (int i = 0; i < n; i++) {
num = in.nextInt();
a[num]++;
}
int max = -1;
for (int i = 1; i < 4; i++)
if... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* Created by wencan on 2015/6/4.
*/
public class Sequence123 {
public static void main(String[] args) throws IOException {
... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
x=[int(x) for x in input().split()]
a=[]
for i in range(1,4):
a.append(x.count(i))
print(n-max(a)) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
str1=input()
print(n-max(str1.count('1'),str1.count('2'),str1.count('3'))) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | a,b = int(input()), input()
c1 = b.count('1')
c2 = b.count('2')
c3 = b.count('3')
if c1>=c2 and c1>=c3: print(c2+c3)
elif c2>=c1 and c2>=c3: print(c1+c3)
else: print(c1+c2) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;
import java.io.IOException;import java.io.PrintStream;import java.io.PrintWriter;
import java.security.AccessControlException;import java.util.Arrays;import java.util.Collection;
import java.util.Comparator;import java.util.List;im... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
int n, x, t[5], maxn;
int read() {
int x = 0;
char c = getchar();
bool flag = 0;
while (c < '0' || c > '9') {
if (c == '-') flag = 1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + c - '0';
c = getchar();
}
return flag ? -x : x;
}
int m... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, cnt[5] = {};
scanf("%d", &n);
for (register int i = 1; i <= n; ++i) {
scanf("%d", &x);
++cnt[x];
}
printf("%d", n - max(cnt[1], max(cnt[2], cnt[3])));
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | from sys import stdin
n = int(stdin.readline())
v = map(int, stdin.readline().split(' '))
c = [v.count(i+1) for i in range(3)]
print n - max(c) | PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | // package Practice2.CF52;
import java.util.HashMap;
import java.util.Scanner;
public class CF052A {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
HashMap<Integer,Integer> map = new HashMap<>();
int n = s.nextInt();
s.nextLine();
int[] arr = n... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
class Array {
private:
int *a;
int idx;
int M1;
int M2;
int M3;
public:
Array(int n);
void set_A(int a);
int Show_r(int n);
void operator>>(istream &);
~Array(void);
};
Array::Array(int n) {
a = new int[n];
idx = 0;
M1 = 0;
M2 = 0;
M3 = 0;
}... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, a[1000001], x = 0, y = 0, z = 0, t;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == 1) {
x++;
}
if (a[i] == 2) {
y++;
}
if (a[i] == 3) {
z++;
}
}
t = max(x, y);
if (t < z) {
co... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
int max(int num1, int num2, int num3) {
int result;
if (num1 >= num2) {
if (num1 >= num3)
result = num1;
else
result = num3;
} else {
if (num2 >= num3)
result = num2;
else
result = num3;
}
return result;
}
int main() {
int n;
while (scanf("%... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.*;
public class A {
static int nextInt() throws IOException {
int m = 0;
int c = System.in.read();
while (c < '0' || c > '9')
c = System.in.read();
while (c >= '0' && c <= '9') {
m = m * 10 + (c - '0');
c = System.in.read();
}
return m;
}
public static void main(String[] args) t... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
a = [int(i) for i in input().split()]
ans = n
s1 = 0
s2 = 0
s3 = 0
for i in range(n):
if a[i] == 1:
s1 += 1
elif a[i] == 2:
s2 += 1
else:
s3 += 1
S = max(s1,s2, s3)
if S == s1:
ans -= s1
elif S == s2:
ans -= s2
else:
ans -= s3
print(ans)
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n;
int a = 0, b = 0, c = 0;
for (int i = 0; i < n; i++) {
cin >> k;
if (k == 1)
a++;
else if (k == 2)
b++;
else
c++;
}
cout << min(n - a, min(n - b, n - c)) << endl;
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[4] = {};
cin >> n;
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
a[x]++;
}
sort(a + 1, a + 4);
cout << a[1] + a[2];
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class P52A {
public P52A() throws NumberFormatException{
try {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
a = list(map(int,input().split()))
b = 0; c = 0; d = 0
for i in range(len(a)):
if a[i] == 1: b += 1
elif a[i] == 2: c += 1
elif a[i] == 3: d += 1
e = b + c
f = c + d
g = b + d
print(min(e,f,g))
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, c1 = 0, c2 = 0, c3 = 0;
cin >> n;
long long int a[n];
for (long long int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 1) {
c1++;
} else if (a[i] == 2) {
c2++;
} else if (a[i] == 3) {
c3++;
}
}
... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
const long long INF = 1e9;
const long long N = 2e5 + 1;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int s[n];
int s1 = 0, s2 = 0, s3 = 0;
for (int i = 0; i < n; i++) {
cin >> s[i];
... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=input()
b=map(int,raw_input().split())
e,t,d=b.count(1),b.count(2),b.count(3)
print n-max(e,t,d)
| PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
a = list(map(int, input().split()))
on = t = tr = 0
for i in a:
if i == 1:
on+=1
elif i == 2:
t+=1
else:
tr+=1
print(n-max(on, t, tr))
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import operator
n = int(input())
numList = list(map(int, input().split()))
dictCount = {}
for x in numList:
dictCount[x] = dictCount.get(x, 0) + 1
itemsList = list(dictCount.items())
itemsList.sort(key = operator.itemgetter(1), reverse = True)
total = 0
for x in range(1, len(itemsList)):
total += itemsList[x][1]
... | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.*;
import java.math.*;
import java.util.*;
/**
*
* @author Togrul Gasimov (ttogrul30@gmail.com)
* Created on 13.09.2013
*/
public class Main {
public static void main(String[] args) /*throws FileNotFoundException*/ {
InputStream inputStream = System.in;
OutputStream outputStream = Syste... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | a=int(input())
b=list(map(int,input().split()))
c=[b.count(i) for i in set(b)]
for i in range(1,4):
if b.count(i) == max(c):
print(a-b.count(i))
break | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | var cnt = new Array(4).fill(0);
cnt[0] = Number.MAX_SAFE_INTEGER;
readline();
readline().split(" ").map((x)=>{ cnt[x]++; });
var out = 0;
var min = Math.min(...cnt);
out += min;
cnt.splice(cnt.indexOf(min),1);
out += Math.min(...cnt);
print(out); | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | # https://codeforces.com/problemset/problem/52/A
# 900
n = int(input())
d = {}
for i in input().split():
d.setdefault(i, 0)
d[i] += 1
m = max(d.values())
print(n-m) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 |
import java.util.*;
public class A
{
public static void main(String[] args)
{
new A(new FastScanner());
}
public A(FastScanner in)
{
int N = in.nextInt();
int[] a = new int[4];
for (int i=0; i<N; i++)
a[in.nextInt()]++;
int res = N-Math.max(a[3], Math.max(a[1], ... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.*;
import java.util.*;
public class A {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
//final String TASKNAME = "";
void solve() throws IOException {
int n = nextInt();
int cnt[] = new int[3];
for (int i = 0; i < n; i++) cnt[nextI... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=input()
arr=input()
a=arr.count('1')
b=arr.count('2')
c=arr.count('3')
if(a<b):a=b
if(a<c):a=c
print(int(n)-a) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #!/usr/bin/env python
# coding = utf-8
import string
n = int(raw_input())
a = 0
b = 0
c = 0
values = map(int, string.split(raw_input()))
for input in values:
if input == 1:
a += 1
elif input == 2:
b += 1
elif input == 3:
c += 1
print min(n - a, min(n - b, n - c))
| PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int a[3];
const int N = 1e6 + 5;
int main() {
int x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
a[x]++;
}
int m = 0;
for (int j = 1; j <= 3; j++) m = max(m, a[j]);
cout << n - m << endl;
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n;
cin >> n;
map<int, int> cnt;
while (n--) {
int x;
... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | a=[0]*4
n=int(input())
b=list(map(int,input().split()))
for i in b:
a[i]+=1
m=max(a)
print(n-m)
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
l = list(map(int, input().split()))
a = [0, 0, 0, 0]
for x in l:
a[x] += 1
print(n - max(a[1], a[2], a[3])) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | if __name__ == "__main__":
t = int(input())
lst = list(map(int,input().strip().split()))
count_1 = count_2 = count_3 = 0
for i in range(len(lst)):
if lst[i] == 1 :
count_1 += 1
elif lst[i] == 2 :
count_2 += 1
else:
count_3 += 1
print(t - ma... | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, z = 0, b = 0, c = 0, maximum, max1, a;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
switch (a) {
case 1:
z++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
}
}
m... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.*;
import java.util.*;
public class Posledovatelnost123 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer in;
static PrintWriter out = new PrintWriter(System.out);
public static String nextToken() throws IOException{
while (in == null || !i... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ar[n];
int x = 0, y = 0, z = 0;
for (int i = 0; i < n; i++) {
cin >> ar[i];
if (ar[i] == 1) x++;
if (ar[i] == 2) y++;
if (ar[i] == 3) z++;
}
cout << n - max(x, max(y, z));
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | from collections import Counter
def main(seq):
return len(seq) - Counter(seq).most_common(1)[0][1]
if __name__ == "__main__":
_, seq = input(), list(map(int, input().split()))
print(main(seq))
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Vaibhav Mittal
*/
public class Main {
public static void main(String[] arg... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
s=input()
x=n-max(s.count('1'),s.count('2'),s.count('3'));
print (x); | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
a=[int(i) for i in input().split()]
b=a.count(1)
c=a.count(2)
d=a.count(3)
e=max(b,max(c,d))
print(len(a)-e) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | size = int(input())
sequence = list(map(int , input().split(" ")))
freq = [sequence.count(i) for i in range(1 , 4)]
freq.sort()
print(size - freq[-1])
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
import threading
import bisect
import heapq
#sys.stdin = open("F:\PY\\test.txt", "r")
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(input())
ar = list(map(int, input().spli... | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.*;
public class OneTwoThreeSequence {
static void solve(){
Scanner sc = new Scanner(System.in);
int NOC=sc.nextInt(), n=NOC;
int o=0,t=0,th=0;
while (NOC-->0) {
int no = sc.nextInt();
if(no==1) o++;
else if(no==2) t++;
... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
count=0
one=0
two=0
three=0
x=list(map(int,input().split()))
for i in x:
if i==1:
one=one+1
elif i==2:
two=two+1
elif i==3:
three=three+1
max_=max(one,two ,three)
answer=n-max_
print(answer) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
public class training_2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int count = Integer.parseInt(scan.nextLine());
String[] nums = scan.nextLine().split(" ");
int a = 0;
int b = 0;
int c = 0;
for(String num:nums){
if(num.equals("1")){
... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int adj[8][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1},
{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
const long long int LLINF = 9e18;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const int SIZE = 1000006;
const double PI = acos(-... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
a=list(map(int,input().split()));b=list(set(a))
c=[a.count(i) for i in b]
print(n-max(c)) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 1) {
c1++;
} else if (a[i] == 2) {
c2++;
} else {
c3++;
}
}
cou... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, a, t1, t2, t3, max1, max2, maxx;
cin >> n;
t1 = 0;
t2 = 0;
t3 = 0;
for (i = 0; i < n; i++) {
cin >> a;
if (a == 1) t1++;
if (a == 2) t2++;
if (a == 3) t3++;
}
max1 = max(t1, t2);
max2 = max(t2, t3);
maxx = max(max1,... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 1)
c1++;
else if (a[i] == 2)
c2++;
else
c3++;
}
cout << n - max(c1, max(c2, c... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[3] = {0};
for (int x, i = 0; i < n; i++) {
cin >> x, arr[x - 1]++;
}
std::cout << n - max(max(arr[0], arr[1]), arr[2]) << "\n";
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
l = list(map(int, input().split()))
c1 = 0
c2 = 0
c3 = 0
for i in l:
if i == 1: c1 += 1
elif i == 2: c2 += 1
else: c3 += 1
print(n - max(c1, c2, c3)) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
C = [0]*4
for a in map(int, input().split()):
C[a] += 1
print(n - max(C)) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
l = list(map(int, input().split()))
br = [0, 0, 0]
for i in range(n):
br[l[i] - 1] += 1
print(sum(br) - max(br))
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
public static void main(String args[]) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer s... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* User: ngupta
* Date: 16/6/2020 AD
* Time: 22:25
*/
public class _123_Sequence {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int one = 0;
int two = 0;
in... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | from collections import Counter
import copy
def solve():
n=int(input())
arr=[int(i) for i in input().split()]
count=Counter(arr)
Max=max(count[1],count[2],count[3])
return n-Max
print(solve())
| PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
int a[4];
int main() {
scanf("%d", &n);
for (int(i) = 0; (i) < (n); ++(i)) {
int first;
scanf("%d", &first);
a[first]++;
}
cout << n - max(max(a[1], a[2]), a[3]) << endl;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #!/usr/bin/python
import sys
n = int (sys.stdin.readline ())
a = [int (x) for x in sys.stdin.readline ().split ()]
p = {1:0, 2:0, 3:0}
for i in range (n):
for j in [1, 2, 3]:
if a[i] != j:
p[j] += 1
print min (p[1], p[2], p[3])
| PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int m[10];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int v;
cin >> v;
m[v]++;
}
cout << n - max(m[1], max(m[2], m[3])) << endl;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
public class sequence123 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[]arr = new int[n];
int[]count = new int[4];
for(int i = 0; i < n; i ++) {
arr[i] = sc.nextInt();
count[arr[i]] ++;
}
System.out.println(n... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int a[MAXN], n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int mx = max(count(a, a + n, 1), max(count(a, a + n, 2), count(a, a + n, 3)));
cout << n - mx;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a[4] = {}, n, x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
a[x]++;
}
cout << n - *max_element(a + 1, a + 4);
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOE... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
public class xyz
{
public static void main(String args[])
{
Scanner sc =new Scanner (System.in);
int n=sc.nextInt();
int[] a=new int[n];
int n1=0;int n2=0;int n3=0;
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
if(a[i]==1)
{
n1=n1+1;
}
else if(a[i]==2)
{
n2=... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.*;
import java.util.*;
public class Main {
static PrintWriter w = new PrintWriter(System.out);
static Reader sc = new Reader();
public static void main(String args[]) throws IOException {
int tc = 1;
while (tc-- > 0) {
solve();
}
w.close();
}
... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | //package round_1;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.valueOf(scanner.nextLine());
String sequence = scanner.nextLine();
int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
for (int index ... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
int n;
cin >> n;
int a[4], b;
a[1] = 0;
a[2] = 0;
a[3] = 0;
for (int i = 0; i < n; i++) {
cin >> b;
a[b]++;
}
cout << n - max(max(a[1], a[2]), a[3]);
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | var getNums = function() {
return readline().split(' ').map(function(a) {return parseInt(a)});
};
var n = parseInt(readline());
var input = getNums();
var hash = {};
for(var j = 1; j <= 3; j++) {
hash[j] = 0;
}
for (var i = 0; i < n; i++) {
hash[input[i]]++;
}
print(Math.min(hash[1] + hash[2], hash[1] + hash[3],... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int N, a, b, c, x;
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> x;
if (x == 1) a++;
if (x == 2) b++;
if (x == 3) c++;
}
cout << N - max(max(a, b), c) << endl;
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin.tie(NULL);
long int n;
cin >> n;
int a[n];
int b[3] = {0};
for (long int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 1)
b[0]++;
else if (a[i] == 2)
b[1]++;
else i... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class A {
static StreamTokenizer st;
public static void main(String[] args) throws I... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void show_vector(vector<int>& a) {
for (vector<int>::iterator it = a.begin(); it != a.end(); ++it) cout << *it;
}
int main() {
int n, v, a = 0, b = 0, c = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> v;
if (v == 1)
a++;
else if (v == 2)
... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
vector<int> v;
int a[1111111];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int mn = 2 * n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i <= 3; i++) {
int t = 0;
for (int j ... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int long long n, h[4] = {0}, x;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
h[x]++;
}
sort(h, h + 4);
cout << endl << n - h[3];
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.*;
import java.io.*;
public class test
{
public static void main(String[] args)
{
new test().run();
}
void run()
{
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int[] counts = new int[3];
for (int i = 0; i < n; i++)
co... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new ... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
int n, x, C[4];
int main() {
scanf("%d", &n);
while (n--) {
scanf("%d", &x);
C[x - 1]++;
}
int a = C[0];
if (C[1] > a) a = C[1];
if (C[2] > a) a = C[2];
printf("%d\n", C[0] + C[1] + C[2] - a);
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | x=int(input())
String1=input()
list1=list(String1)
i=0
a=0
b=0
c=0
for i in list1:
if i=='1':
a+=1
elif i=='2':
b+=1
elif i=='3':
c+=1
p=max(a,b,c)
print(x-p) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Prob052A
{
public static void main( String[] Args ) throws IOException
{
BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
int... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=int(input())
l=list(map(int,input().split()))
a1=l.count(1)
a2=l.count(2)
a3=l.count(3)
v=[]
v.append(a1)
v.append(a2)
v.append(a3)
# l=set(v)
# v=list(l)
a=max(a1,a2,a3)
if len(v)==1:
print('0')
else:
v.remove(a)
print(sum(v)) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[1000000 + 10];
int main() {
int n, m, b[10] = {}, k = 0, x, y, max, ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]]++;
}
x = b[1];
for (int i = 2; i <= 3; i++) {
if (x < b[i]) x = b[i];
}
for (int i = 1; i <= 3; i++) {... | CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Sequence {
public static void main(String[] args) throws NumberFormatException, IOException{
BufferedReader in = new BufferedReader(new Inpu... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
public class x52A {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] nums = new int[4];
for(int a=0;a<n;a++){
nums[sc.nextInt()]++;
}
if(nums[3]>=nums[2]&&nums[3]>=nums[1]){
System.out.printf("%d",nums[1]+nums[2]);
... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n = int(input())
a = list(map(int, input().split()))
print(n - max(a.count(1), max(a.count(2), a.count(3)))) | PYTHON3 |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Scanner;
public class Sequence {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int f = in.nextInt();
int con = 0,con1=0,con2=0,conta=0,conta2=0,conta3=0;
for (int i = 0; i < f; i++) {
String s = in.next();
if ... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | N = int(raw_input())
nums = map(int,raw_input().split())
a = nums.count(1)
b = nums.count(2)
c = nums.count(3)
print min([a+b,b+c,a+c]) | PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | n=input()
A=map(int,raw_input().split())
cnt=[0]*3
for a in A:
cnt[a-1]+=1
s=max(cnt)
print n-s | PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.Pr... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.*;
public class Test {
public BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
public PrintWriter output = new ... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | a = raw_input()
a = raw_input()
def cnt(x):
return len([1 for i in a if i == x])
s = cnt('1') + cnt('2') + cnt('3')
ans = s
ans = min(ans , s - cnt('1'))
ans = min(ans , s - cnt('2'))
ans = min(ans , s - cnt('3'))
print(ans)
| PYTHON |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | import java.util.*;
import java.io.*;
public class Main implements Runnable {
public void solve() throws IOException {
int N = nextInt();
int[] a = new int[3];
for(int i = 0; i < N; i++) a[nextInt() - 1]++;
Arrays.sort(a);
System.ou... | JAVA |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int i = 0, X, N, A[3] = {};
cin >> N;
while (i < N) {
cin >> X;
++A[X - 1];
++i;
};
X = ((A[0] > ((A[1] > A[2]) ? (A[1]) : (A[2])))
? (A[0])
: (((A[1] > A[2]) ? (A[1]) : (A[2]))));
cout << (N - X);
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, t;
int a[4];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
a[x]++;
}
t = max(t, max(a[3], max(a[1], a[2])));
cout << n - t << endl;
return 0;
}
| CPP |
52_A. 123-sequence | There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.
Input
The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[1234567], r[1234567], rr[1234567];
int n, m, k, x, y, b = 0, q, p;
int main() {
cin >> n;
m = n;
while (m--) {
cin >> x;
a[x]++;
}
cout << n - max(a[1], max(a[2], a[3]));
}
| CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.