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
n=int(input()) List=list(input().split()) List=list(map(int,List)) minimum_replacement=None for i in range(1,4): count=0 for j in range(n): if List[j]!=i: count +=1 if minimum_replacement is None: minimum_replacement=count elif count<minimum_replacement: minimum_repl...
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { //MScanner sc = new MScanner(System.in); BufferedR...
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
def sequence(lst): a = lst.count(1) b = lst.count(2) c = lst.count(3) if a > b and a > c: return len(lst) - a elif b > a and b > c: return len(lst) - b elif c > a and c > b: return len(lst) - c elif a == b == c: return len(lst) - a elif a == 0 and b == c o...
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 Counter def convert(arr): arr = arr.split(" ") for i in range(len(arr)): arr[i] = int(arr[i]) return arr t = int(input()) s = input() n_num = convert(s) n = len(n_num) data = Counter(n_num) get_mode = dict(data) mode = [k for k, v in get_mode.items() if v == max(list(d...
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 Counter n = int(input()) l = list(map(int, input().split())) cc = Counter(l) vals = list(cc.values()) print(n - max(vals))
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.util.Arrays; import java.util.StringTokenizer; /** * * @author Prateep */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // TODO code application logic here 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> int main() { int n; scanf("%d", &n); int vec[4] = {0}; for (int i = 0; i < n; i++) { int a; scanf("%d", &a); vec[a]++; } int x = vec[1] + vec[2]; int y = vec[1] + vec[3]; int z = vec[3] + vec[2]; if (x > y) x = y; if (x > z) x = z; printf("%d\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
n=int(input()) l=list(map(int,input().split())) a=l.count(1) b=l.count(2) c=l.count(3) print(n-max(a,b,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 d, n, k = 0, b = 0, l = 0, a, i; int main() { scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a); if (a == 1) { k++; } else if (a == 2) { l++; } else { b++; } } d = (k > l) ? k : l; d = (d > b) ? d : b; cout << 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(3); int t; for (int i = 0; i < n; i += 1) { cin >> t; a[t - 1] += 1; } sort(a.begin(), a.end()); cout << a[0] + a[1] << "\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
from collections import Counter n = int(input()) s = Counter(input().split()) print(n - s.most_common(1)[0][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.util.Scanner; public class Ishu { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n,i,j; int[] a=new int[1000000]; int[] no=new int[3]; n=scan.nextInt(); for(i=0;i<n;++i) { a[i]=scan.nextInt();...
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.lang.*; import java.io.*; import java.util.*; import java.math.*; public class Solution implements Runnable{ private static BufferedReader br = null; private static PrintWriter out = null; private static StringTokenizer stk = null; public static void main(String[] args) { br = ...
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() { ios::sync_with_stdio(0); int n; cin >> n; int a[4]; memset(a, 0, sizeof(a)); int x; int cnt = n; while (cnt--) { cin >> x; a[x]++; } int ans = max(a[1], max(a[2], a[3])); ans = n - ans; cout << ans << 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
# -*- coding: utf-8 -*- import sys def hh(a,b): if a>b: return a else: return b if __name__ == '__main__': num= map(int,sys.stdin.readline().split()) lit1=[] lit1 = map(int,sys.stdin.readline().split()) a = lit1.count(1) b = lit1.count(2) c = lit1.count(3) d = hh(...
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 statistics x = int(input()) seq = input().split() seq = [int(i) for i in seq] occ1 = seq.count(1) occ2 = seq.count(2) occ3 = seq.count(3) print (x-max(occ1,occ2,occ3))
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()] one=two=three=0 for x in a: if x==1: one+=1 if x==2: two+=1 if x==3: three+=1 y=max(one,two,three) print(one+two+three-y)
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 = input() s = raw_input().split() print n - max(s.count('1'),s.count('2'),s.count('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
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { SpeedScanner speedScanner = new SpeedScanner(); PrintWriter out = new PrintWriter(System.out); taskSolver(speedScanner, out); out.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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int one = 0, two = 0, three = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) one++; else if (a[i] == 2) two++; else three++; } cout << n - max(one, max(two, three)) << 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
n=int(raw_input()) l=[int(x) for x in raw_input().split()] print min(n-l.count(1),n-l.count(2),n-l.count(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
import java.util.*; import java.io.*; public class Posledov { /** * @param args */ int[] arr = new int[4]; static StreamTokenizer st; private int nextInt() throws IOException{ st.nextToken(); return (int) st.nval; } public void go() throws IOException{ st = new StreamTokenizer(new BufferedReader(new 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
from collections import Counter n = int(raw_input()) c = Counter(map(int, raw_input().split())) print min(map(lambda x:n-x, c.values()))
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.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
n=int(input()) alist=list(map(int,input().split())) a=alist.count(1) b=alist.count(2) c=alist.count(3) print(min(a+b,b+c,a+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; const double PI = acos(-1.0); const long long INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 1000 * 1000 + 47; int C[3]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = (0); i < (n); 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
items = int(raw_input()) line = raw_input().strip().split() x = [] for i in line: x.append(int(i)) count = [0,0,0] for i in range(3): count[i] = x.count(i+1) print sum(count)-max(count)
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 Codeforces { static StreamTokenizer in = new StreamTokenizer(new BufferedReader (new InputStreamReader(System.in))); // static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException{ in.nextToken(); int 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
n=input() s=raw_input() print n-max(s.count(str(i))for i in[1,2,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; signed main() { long long n; cin >> n; long long arr[n]; long long count[4] = {0}; for (long long i = 0; i < n; i++) { cin >> arr[i]; count[arr[i]]++; } long long max = 0; for (long long i = 0; i < 4; i++) { if (count[i] > max) max = count[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.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Test { public BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); public PrintWrit...
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()) a = raw_input().split(' ') c = [0,0,0] for i in range(n): if a[i] == "1": c[0] += 1 elif a[i] == "2": c[1] += 1 else: c[2] += 1 print min( c[0] + c[1], c[0] + c[2], c[1] + c[2] )
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 main() { int i, j; int t; int a = 0, b = 0, c = 0; cin >> t; for (i = 0; i < t; i++) { cin >> j; if (j == 1) a++; if (j == 2) b++; if (j == 3) c++; } int d; d = a > b ? a : b; d = d > c ? d : c; cout << t - d; 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
n = int(input()) arr = list(map(int,input().split())) arr.sort() a = arr.count(1) b = arr.count(2) c = arr.count(3) r1 = a + b r2 = b + c r3 = a + c print(min(r1 , r2 , r3))
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 -*- def main(): n = int(raw_input()) s = [0, 0, 0] for i in raw_input().split(): s[int(i)-1] += 1 print n - max(s[0], max(s[1], s[2])) return 0 if __name__ == '__main__': main()
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.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.InputStream; public class A { public static void main(String[] args) { InputStream ...
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 main() { int n, max = 0; int c[4] = {0}; scanf("%d", &n); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); c[a]++; if (c[a] > c[max]) max = a; } printf("%d\n", n - c[max]); }
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()) count1 = count2 = count3 = 0 input_str = input() input_list = input_str.split(' ') for i in range(n): number = int(input_list[i]) if number == 1: count1 += 1 elif number == 2: count2 += 1 else: count3 += 1 rez = [] rez.append(count1 + count2) rez.append(cou...
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.util.*; import java.math.*; import static java.lang.Math.*; public class Main implements Runnable { StreamTokenizer in; BufferedReader reader; PrintWriter out; StringTokenizer tok; boolean timus = System.getProperty("ONLINE_JUDGE")!=null; boolean codeforces = true...
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 = (int)(1e3 + 1e1); const double PI = acos(-1.0); long long n, z, q, w, e; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> z; if (z == 1) q++; if (z == 2) w++; if (z == 3) e++;...
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 N = int(input()) Counter = Counter(list(map(int, input().split()))) print(N - max(Counter.values())) # Hope the best for Ravens # Never give up
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 length(int k) { int c = 0; while (k) { k /= 10; c++; } return c; } int bigmod(string s, int k) { int i, rem = 0; for (i = 0; i < s.size(); i++) { rem = (rem * 10 + s[i] - '0') % k; } return rem; } void bigdiv(string s, int k) { char q[20]; ...
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, c = 0, c2 = 0, c3 = 0, max = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) { c++; } if (a[i] == 2) { c2++; } if (a[i] == 3) { c3++; } } int p[] = {c, c2, 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> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; template <typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << p.first << ',' << p.second; } template <typename T> struct point { T x, y; point(T xx = 0, T yy = 0) : x(xx), y(...
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()) numbers = list(map(int, input().split())) a = numbers.count(1) b = numbers.count(2) c = numbers.count(3) print(n - max(a,b,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, num1, num2, num3 = int(input()), 0, 0, 0 for item in [int(item) for item in input().split(' ')]: if item == 1: num1 += 1 elif item == 2: num2 += 1 else: num3 += 1 if num1 < num2: t = num1 num1 = num2 num2 = t if num1 < num3: t = num1 num1 = num3 num3 = t ...
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, *a; int main() { int n1 = 0, n2 = 0, n3 = 0; cin >> n; a = (int*)malloc(n * sizeof(int)); for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) n1++; else if (a[i] == 2) n2++; else n3++; } cout << n - max(max(n1, n2),...
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 dust i have come dust i will be n=int(input()) a=list(map(int,input().split())) uno=0 dos=0 tres=0 for i in range(n): if a[i]==1: uno+=1 elif a[i]==2: dos+=1 else: tres+=1 print(uno+dos+tres-max(uno,dos,tres))
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 one = 0, two = 0, three = 0; for (int i = 0; i < n; i++) { if (a[i] == 1) one++; if (a[i] == 2) two++; if (a[i] == 3) three++; } cout << n - max(one, max(two, th...
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()))[:n] b=a.count(1) z=a.count(2) c=a.count(3) print(n-max(b,c,z))
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> int num[5]; int main() { int n, i, Num, max; scanf("%d", &n); num[1] = num[2] = num[3] = 0; for (i = 0; i < n; i++) { scanf("%d", &Num); num[Num]++; } max = num[1]; if (num[2] > max) max = num[2]; if (num[3] > max) max = num[3]; printf("%d\n", n - max); 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 CF52A { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { int n = nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++) { arr[i] = nextInt(); }...
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.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); int n; String line; StringTokenizer st; n = Integer.parseInt(s.readLine()); 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
n=input() a = [int(j) for j in raw_input().split(' ')] # for i in a: # b=a.count(i) # x.append(b) x=[a.count(1),a.count(2),a.count(3)] m=max(x) print n-m
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=raw_input() print n-max(a.count(i)for i in'123')
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; template <typename... T> void scan(T&... args) { ((cin >> args), ...); } template <typename... T> void print(T... args) { ((cout << args), ...); } class Solution_To_Problem { int n, x; int count1, count2, count3, m; public: void solution_function() { scan(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
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, l, n; cin >> n; int a[n]; long long int b[3] = {0}; for (i = 0; i < n; i++) { cin >> a[i]; b[a[i] - 1]++; } sort(b, b + 3); cout << b[0] + b[1] << "\n"; 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.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class TestA { static InputStreamReader inp = new InputStreamReader(System.in); static BufferedReader in = new Buffered...
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; int one = 0; int two = 0; int three = 0; int in; cin >> n; for (int i = 0; i < n; i++) { cin >> in; switch (in) { case 1: { one++; } break; case 2: { two++; } break; case 3: { th...
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[n + 1]; int a = 0, b = 0, c = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n; i++) { if (arr[i] == 1) a++; else if (arr[i] == 2) b++; else c++; } int mx = max(...
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()) l1 = [int(x) for x in input().split()] l2 = set(l1) c = [] for x in l2: c.append(l1.count(x)) 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> int main() { int A = 0, M, N, i, B = 0, C = 0, sum; scanf("%d", &N); for (i = 1; i <= N; i++) { scanf("%d", &M); if (M == 1) { A++; } if (M == 2) { B++; } if (M == 3) { C++; } } if (A >= B && A >= C) { sum = B + C; } if (B >= A && ...
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 n=int(input()) arr=list(map(int,input().split())) c=Counter(arr) v=sorted(dict(c).values()) print(n-v[-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.util.*; public class Task { public static void main(String[] args) { solve(); } static void solve() { int n = nextInt(); int[] a = nextAi(n); int[] counts = new int[3]; for (int i = 0; i < n; ++i) { counts[a[i] - 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; long n, x, a, b, c; int main() { scanf("%ld", &n); a = b = c = 0; for (long i = 1; i <= n; i++) { scanf("%ld", &x); if (x == 1) a++; else if (x == 2) b++; else c++; } printf("%ld", n - max(c, max(a, b))); 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
n=int(input()) l=list(map(int,input().split())) x=l.count(1) y=l.count(3) z=l.count(2) print(n-max(x,y,z))
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 = input() s = raw_input() print n - max(s.count('1'),s.count('2'),s.count('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
/** * Created by IntelliJ IDEA. * User: shakhov * Date: 15.06.2011 * Time: 15:22:46 * To change this template use File | Settings | File Templates. */ //6 //86 402 133 524 405 610 6 4 1 import java.io.*; import java.util.*; public class CodeForces { public void solve() 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, a = int(input()), input().split() print(sum(sorted([a.count('1'), a.count('2'), a.count('3')])[:2]))
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
q=int(input()) a = [int(x) for x in input().split()] n=[0,0,0] for i in range(q): n[a[i]-1]+=1 print(q-max(n))
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, p = 0, q = 0, v = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i] == 1) { v++; } else if (a[i] == 2) { p++; } else { q++; } } int w = max(v, ...
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[1000000]; int num[3]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) num[a[i] - 1]++; int ans = n; for (int i = 0; i < 3; ++i) { ans = min(ans, num[i] + num[(i + 1) % 3]); } cout << ans << 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.io.*; import java.util.*; public class MAIN{ private static BufferedReader reader = null; private static BufferedWriter writer = null; public static void main(String[] args) throws Exception{ reader = new BufferedReader(new InputStreamReader(System.in)); String[] s = reader....
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())) one=0 two=0 three=0 for i in a: if(i==1): one+=1 elif(i==2): two+=1 elif(i==3): three+=1 one_two=one+two one_three=one+three two_three=two+three print(min(one_two,one_three,two_three))
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()) seq = [int(i) for i in input().split(' ')] count = [seq.count(1), seq.count(2), seq.count(3)] print(abs(max(count)-n))
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.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
import java.awt.Point; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger...
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()) arr = [int(i) for i in input().split()] min=arr.count(2)+arr.count(3) if min>(arr.count(1)+arr.count(3)): min=arr.count(1)+arr.count(3) if min>(arr.count(1)+arr.count(2)): min=(arr.count(1)+arr.count(2)) print(min)
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> int main() { int n, c = 0; scanf("%d", &n); int a[3]; int i; for (i = 0; i < 3; i++) a[i] = 0; for (i = 0; i < n; i++) { int x; scanf("%d", &x); if (x == 1) a[0]++; else if (x == 2) a[1]++; else a[2]++; } int max = 0; if (a[0] >= a[1] && a...
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; void scanint(int &x) { register int c = getchar(); x = 0; int neg = 0; for (; ((c < 48 || c > 57) && c != '-'); c = getchar()) ; if (c == '-') { neg = 1; c = getchar(); } for (; c > 47 && c < 58; c = getchar()) { x = (x << 1) + (x << 3) + c - 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; public class A { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in.readLine(); String[] S = in.readLine().spl...
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, s[1000000]; int main() { scanf("%d", &n); for (int x, i = 1; i <= n; i++) scanf("%d", &x), s[x]++; cout << n - max(s[1], max(s[2], s[3])); }
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
__author__ = 'dwliv_000' n=int(input()) c={} c[1]=0 c[2]=0 c[3]=0 s=input().split() for j in s: c[int(j)]+=1 print(n-max(c.values()))
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=input().split() s1=s2=s3=0 for i in range(0,len(a)): if int(a[i])==1: s1+=1 elif int(a[i])==2: s2+=1 else: s3+=1 if s1==max(s1,s2,s3): print(s2+s3) elif s2==max(s1,s2,s3): print(s1+s3) else: print(s1+s2)
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.util.*; import java.math.*; public class Z implements Runnable{ BufferedReader in; StringTokenizer st; PrintWriter out; String FileName = "input"; void solve() throws IOException{ int n = nextInt(); int[] a = new int[4]; for(int i = 0; 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
import java.util.*; public class A { public static void main(String[] args) { Scanner inp = new Scanner(System.in); int a[] = new int[3]; int n = inp.nextInt(); String st; for(int i = 0 ; i < n ; i++) { st = inp.next(); if(st.equals("1")) a[0]++; else if(st.equals("2"))a[1]++; else a[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
import java.util.Scanner; public class Change{ public static int change(int n, int elem[]){ int [] c = {0,0,0}; for (int i = 0; i < n; i++){ switch(elem[i]){ case 1:c[0]++;break; case 2:c[1]++;break; case 3:c[2]++;break; } ...
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; map<int, int> d; for (int i = 0; i < n; ++i) { int in; scanf("%d", &in); d[in]++; } if (d.size() == 1) { cout << 0 << endl; } else if (d.size() == 2) { int ans = 10000000; for (auto it = d.begin(); it != d....
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=[int(x) for x in input().split()] one=l.count(1) two=l.count(2) print(n-max(one, two, n-one-two))
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().strip().split()[:n])) a1=l.count(1) a2=l.count(2) a3=l.count(3) if a1>=a2 and a1>=a3:print(a3+a2) elif a2>=a1 and a2>=a3:print(a1+a3) elif a3>=a2 and a3>=a1:print(a1+a2) else: print(n-(max(a1,a3,a2)))
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
'use strict' let N = +readline() let lll = readline().split(' ').map(v => parseInt(v)) let c = [0, 0, 0] for (let i = 0; i < N; i++) { c[lll[i] - 1]++ } print(c[0] + c[1] + c[2] - Math.max(c[0], c[1], c[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
#include <bits/stdc++.h> using namespace std; int main() { int n, a1 = 0, a2 = 0, a3 = 0, i; cin >> n; int arr[n]; for (i = 0; i < n; i++) cin >> arr[i]; for (i = 0; i < n; i++) { if (arr[i] == 1) a1++; else if (arr[i] == 2) a2++; else a3++; } int res; res = min(a1 + a2, mi...
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 mas[3] = {0, 0, 0}; int tmp; for (int i = 0; i < n; ++i) { cin >> tmp; mas[tmp - 1]++; } sort(mas, mas + 3); cout << mas[0] + mas[1]; 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.Arrays; import java.util.Scanner; public class Q { public static void main(String[]args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[]A = new int[n]; for (int i = 0; i<n;i++){ A[i] = sc.nextInt(); } int q1 = ...
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
# Codeforces Testing Round #1 # Problem A -- 123-sequence n = input() a = map(int, raw_input().split()) print n - max(a.count(1), max(a.count(2), a.count(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
n = int(input()) int_arr = [int(num) for num in input().split()] counts_dict = {} for num in int_arr: counts_dict[num] = counts_dict.get(num, 0) + 1 print(n - max(counts_dict.values()))
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; long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, ed, maxi, maxj, mini, minj, sum, res; long long aa[100007], bb[10007]; long double d1, d2, d3, d4, d5, d6, d7, d8, d9, d0; string s1, s2, s3, s4, s5, s6, s7, s8, s9, s0; set<long lon...
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());s=input().split() print(min(n-s.count('1'),n-s.count('2'),n-s.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
#include <bits/stdc++.h> using namespace std; int ar[5]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int ans = n, mx = 0; while (n--) { int a; cin >> a; ar[a]++; } for (int i = 1; i <= 3; i++) mx = max(mx, ar[i]); cout << ans - mx << 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int n1 = n; int count1 = 0; int count2 = 0; int count3 = 0; while (n1--) { int g; cin >> g; if (g == 1) count1++; else if (g == 2) count2++; else if (g == 3) count3++; } int x1 = max(count...
CPP