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()) l=[int(x) for x in input().split()] d=[l.count(i) for i in set(l)] print(n-max(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
import java.util.*; public class Sequ { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] freq = new int[3]; in.nextLine(); String[] tmp = in.nextLine().split(" "); for (int i = 0; i < n; 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 team { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int i,max=-1,no; int a[]=new int[n]; int c[]={0,0,0}; for(i=0;i<n;i++) { a[i]=sc.nextInt(); c[a[...
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=[int(x) for x in input().split(' ')] d=[l.count(i) for i in set(l)] print(n-max(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
num=int(input()) arr=[0]*9 arr=input().split() for i in range (num): arr[i]=int(arr[i]) one=0 two=0 three=0 for k in range (num): if arr[k]==1: one+=1 if arr[k]==2: two+=1 if arr[k]==3: three+=1 find=max(one,two,three) print (num-find)
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], b[3]; for (int i = 0; i < 3; i++) b[i] = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] == 1) b[0]++; else if (a[i] == 2) b[1]++; else b[2]++; } if (b[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, x, a = 0, b = 0, c = 0, max1; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x == 1) a++; else if (x == 2) b++; else c++; } max1 = max(a, b); max1 = max(max1, c); cout << n - max1 << 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
N = input() mas = map(int, raw_input().split()) print N - max([mas.count(i) for i in xrange(1, 4)])
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.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(input()) a=list(map(int,input().split()))[:n] x=a.count(1) y=a.count(2) z=a.count(3) 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
cases = int(input()) arr = list(map(int, input().split())) mx = max(arr.count(1), arr.count(2), arr.count(3)) print(cases-mx)
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, x, maxx, counter[4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> x; counter[x]++; } for (int i = 1; i <= 3; i++) { maxx = max(maxx, counter[i]); } n -= maxx; cout <...
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, t = int(raw_input()), raw_input() a, b = t.count('1'), t.count('2') print n - max(a, b, n - a - b)
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.Scanner; public class Sequence123 { public static void main(String[] args) { Scanner scan= new Scanner(System.in); int n=scan.nextInt(); int[] a =new int[n]; int o=0,t=0,th=0; for(int i=0;i<n;i++) { a[i]=scan.nextInt(); if(a[i]==1) o++; else if(a[i]==2) t++; else th++; } ...
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 implements Runnable { private void solve() throws IOException { int n = nextInt(); int[] a = new int[3]; for (int i = 0; i < n; i++) { a[nextInt() - 1]++; } int ans = 0; for (int i : a) { ans = Math.max(ans, i); } System.out.println(n - ans);...
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 java { public static void main(String args[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(),c=0,cnt=0,count=0; int arr[]=new int[n]; for(int i=0;i<n;i++) { arr[i]=in.nextInt(); if(arr[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
import sys if __name__=="__main__": n=int(sys.stdin.readline()) l=[]; d={}; a=sys.stdin.readline().strip().split(" ") for i in a: d[i]=d.get(i,0)+1; l=list(d.values()); l.remove(max(l)); print(sum(l));
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; using ll = long long; constexpr ll mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<ll> A(n); for (auto& _a : A) cin >> _a; int cnt[4] = {}; for (int x : A) ++cnt[x]; ll ans = max({cnt[1], cnt[2], cnt[3]}); n -= ans...
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
raw_input() s = raw_input().split() p = [0,0,0,0] for x in s: p[int(x)] += 1 print len(s) - max(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
import java.io.*; import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 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
#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> int main() { int n; std::cin >> n; std::vector<int> v(4); int max_freq{}; for (int i{0}, x; i < n; ++i) { std::cin >> x; max_freq = std::max(max_freq, ++v[x]); } std::cout << n - max_freq << std::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.*; public class A { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; int one = 0; int two = 0; int three = 0; for(int i=0; i<n; i++){ arr[i] = sc.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
A = [0] * 1000001 N = int(input()) L = list(map(int, input().split())) for l in L: A[l] += 1 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
import java.util.Scanner; public class CodeForces2 { public static void main(String[] args) { // BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int a =0, b=0,c=0; ...
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()) v=input().split() x=v.count("1") y=v.count('2') z=v.count('3') g=max(x,y,z) l=x+y+z-g print(l)
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()) counts = 4 * [0] for a in map(int, input().split()): counts[a] += 1 result = n - max(counts) print(result)
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(s) for s in input().split(' ')] a_dict = {} for x in a: if x in a_dict.keys(): a_dict[x] += 1 else: a_dict[x] = 1 ans = n - a_dict[max(a_dict, key=lambda x: a_dict[x])] 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
import java.util.*; import java.io.*; import java.util.Date; public class Code{ public static void main(String [] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int c1=0,c2=0,c3=0; int arr[]=new int[n]; for(int i=0;i<n;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.*; import java.util.stream.Collectors; public class Sequence { public static void main(String [] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); List<Integer> numbers = new ArrayList<>(); for(int i = 0; i < n; i++) numbers.add(input.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.*; public class min { public static void main(String args[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; int c1=0,c2=0,c3=0; for(int i=0;i<n;i++) { a[i]=in.nextInt(); if(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> int main() { int n; scanf("%d", &n); int a[n], i, x = 0, y = 0, z = 0; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); if (a[i] == 1) x++; if (a[i] == 2) y++; if (a[i] == 3) z++; } if (x >= y && x >= z) printf("%d", n - x); else if (y >= z && y >= x) printf(...
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]; } sort(a, a + n); int count = 1; int temp = 1; for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) { temp++; if (temp > count) { count = temp...
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); for (int i = 1; i <= N; i++) { int m; cin >> m; a[m - 1]++; } sort(a.begin(), a.end()); cout << a[0] + a[1] << 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.*; public class x { public static void main(String args[]) { Scanner obj=new Scanner(System.in); int n,p,a=0,b=0,c=0,d=0,i; n=obj.nextInt(); for (i=0;i<n;i++) { p=obj.nextInt(); if (p==1) { a++; ...
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 Trying { public static void main (String[] args) { Scanner enter = new Scanner(System.in); int n = enter.nextInt(), repeat[] = new int [3], max = 0, pos = 0; enter.nextLine(); String sequence = enter.nextLine(); for(int i = 0 ; i < 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 = [int(x) for x in input().split()] answer = [0, 0, 0] for i in a: answer[i - 1] += 1 print(n - max(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
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt1 = 0, cnt2 = 0, cnt3 = 0; cin >> n; int s[n], i; for (i = 0; i < n; i++) { cin >> s[i]; if (s[i] == 1) ++cnt1; if (s[i] == 2) ++cnt2; if (s[i] == 3) ++cnt3; } int temp0, temp; temp0 = max(cnt1, cnt2); temp = max(temp0,...
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; signed main() { cout.tie(0), cin.tie(0), ios::sync_with_stdio(0); long long n, temp; cin >> n; long long cnt1 = 0, cnt2 = 0, cnt3 = 0; for (long long i = 0; i < n; i++) { cin >> temp; if (temp == 1) cnt1++; else if (temp == 2) cnt2++; 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
#include <bits/stdc++.h> #pragma GCC optimize(5) int main() { std::ios::sync_with_stdio(false); std::map<int, int> map; register int n; std::cin >> n; for (register int i = 1; i <= n; ++i) { int t; std::cin >> t; ++map[t]; } int max = 0; for (const auto &i : map) max = std::max(max, i.second...
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 main() { int i, j, arr, ma = 0, s[3] = {0}; scanf("%d", &j); for (i = 0; i < j; i++) { scanf("%d", &arr); if (arr == 1) s[0]++; else if (arr == 2) s[1]++; else if (arr == 3) s[2]++; } ma = (s[0] > s[1]) ? (s[0] > s[2]) ? s[0] : s[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
import sys n = int(sys.stdin.readline()) s = map(int, sys.stdin.readline().rstrip().split(' ')) counts = [ None, 0, 0, 0 ] for i in range(len(s)): counts[s[i]] += 1 m = min(counts[1]+counts[2], counts[1]+counts[3], counts[2]+counts[3]) print(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
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, b = 0, c = 0, max = 0; cin >> n; int data[n]; for (int i = 0; i < n; i++) { cin >> data[i]; if (data[i] == 1) { a++; } else if (data[i] == 2) { b++; } else if (data[i] == 3) { c++; } } int arr[] = ...
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
//package com.company; import java.util.*; public class Main { public static int findMax(int[] list) { int currentMax = 0; for (int i = 0; i < list.length; i ++) { if (list[i] > currentMax) { currentMax = list[i]; } } return curren...
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, m, s, i, l = 0, k = 0, j = 0, t = 0, p = 0, max = 0; cin >> n; int a[n]; for (i = 0; i < n; i++) { k++; cin >> a[i]; if (a[i] == 1) { l++; } if (a[i] == 2) { j++; } if (a[i] == 3) { t++; } if ...
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() s=input() x=s.count('1') y=s.count('2') z=s.count('3') s=[x,y,z] s.sort() print(s[0]+s[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
#include <bits/stdc++.h> using namespace std; int main() { int a; int num[3] = {0}; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a; num[a - 1]++; } if (num[0] >= num[1] && num[0] >= num[2]) { printf("%d\n", n - num[0]); } else if (num[1] >= num[0] && num[1] >= num[2]) { printf("...
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
# Codeforces Testing Round 1 # Problem A: 123-sequence def replace(n, sequence): num1 = 0 num2 = 0 num3 = 0 for i in xrange(n): if (sequence[i] == 1): num1 += 1 elif (sequence[i] == 2): num2 += 1 else: num3 += 1 if (max(num1, num2, num3) =...
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() l=list(map(int,input().split())) a=l.count(1) b=l.count(2) c=l.count(3) if(a>=b and a>=c): print(b+c) elif(b>=a and b>=c): print(a+c) else: print(a+b)
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 Main { void solve() throws IOException { int n = nextInt(); int[] arr = new int[3]; for( int i = 0; i < n; i++ ) arr[nextInt()-1]++; int max = Math.max(Math.max(arr[0], arr[1]), arr[2]); out.println(n-max); ...
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 = map(int, raw_input().split()) print n - max([a.count(x) for x in range(1, 4)])
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 gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int LCM(int a, int b) { return (a * b) / gcd(a, b); } long long fast_exp(long long base, long long exp) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = ((res ...
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
cnt = [0]*4 N = int(raw_input()) for a in map(int,raw_input().split()): cnt[a]+=1 print N-max(cnt)
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() l=input() o=l.count('1') t=l.count('2') th=l.count('3') l=[o,t,th] l.sort() print(l[0]+l[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.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import static java.lang.Math.*; public class Solution implements Runnable{ public static void main(String[] args) { new Threa...
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 { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int n = Integer.parseInt(br.readLine()); St...
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
# 123-sequence from collections import Counter n = int(raw_input()) count = Counter(x for x in raw_input().split()) print n-count.most_common(1)[0][1]
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()) ai = list(map(int,input().split())) dic = {} for i in ai: if i not in dic: dic[i] = 1 else: dic[i] += 1 #print(dic) print(n - max(dic.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; int main() { ::ios::sync_with_stdio(false); long long n, cnt1 = 0, cnt2 = 0, cnt3 = 0, max = 0; int num[1000010]; cin >> n; for (int i = 0; i < n; i++) { cin >> num[i]; if (num[i] == 1) cnt1++; if (num[i] == 2) cnt2++; if (num[i] == 3) cnt3++; } ...
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()) daf = list(map(int, input().split())) num1 = daf.count(1) num2 = daf.count(2) num3 = daf.count(3) num = max(num1, num2, num3) print(n - num)
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 l=[] n=int(input()) c=Counter(list(map(int,input().split()))) for key,value in c.items():l.append(value) if len(l)==1:print(0) elif len(l)==2:print(min(l[0],l[1])) else:print(min(l[0]+l[1],l[0]+l[2],l[1]+l[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
import java.util.*; import java.io.*; public class Seq { public static void main(String[]args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String input = br.readLine(); StringTokenizer tk =...
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 sys import math import itertools import functools import collections import operator import fileinput import copy ORDA = 97 def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return [int(i) for i in input().split()] def lcm(a, b): return abs(a * b) // math.gcd(a, b) def revn(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.*; import java.util.*; import static java.lang.Math.*; public class timelly { final boolean text = true; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws IOException { if (text) ...
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 test{ 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; ...
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()) arr = map(int, raw_input().split()) a, b, c = arr.count(1), arr.count(2), arr.count(3) print min(a+b, a+c, b+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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; /** * Created by wencan on 2015/6/4. */ public class Sequence123 { public static void main(String[] args) throws IOException { Sequence123 sequence123 = new Sequence123(); Syst...
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; ios_base::sync_with_stdio(false); cin >> n; int cnt1 = 0, cnt2 = 0, cnt3 = 0; for (int i = 0; i < n; i++) { int h; cin >> h; if (h == 1) cnt1++; if (h == 2) cnt2++; if (h == 3) cnt3++; } cout << min(cnt1 + cnt2, min(cnt2...
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()) nums = map(int,raw_input().split()) print "%d" % (N-max(nums.count(1),nums.count(2),nums.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
#include <bits/stdc++.h> int main() { long long int tes, i, b = 0, c = 0, d = 0; int a; scanf("%I64d", &tes); for (i = 0; i < tes; i++) { scanf("%d", &a); if (a == 1) b++; else if (a == 2) c++; else d++; } if (b >= c && b >= d) printf("%I64d\n", c + d); else if (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; long long a, b[1000005], cnt[4]; int main() { cin >> a; for (int i = 1; i <= a; i++) { cin >> b[i]; cnt[b[i]]++; } cout << a - max(cnt[1], max(cnt[2], cnt[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
import java.util.Scanner; import java.util.StringTokenizer; /** * * @author Mohamed Ibrahim (MIM) */ public class Sequence123 { public static void main(String[] args) { Scanner s=new Scanner(System.in); s.nextLine(); String nums=s.nextLine(); int[] sums=new int[3]; sums[...
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
var n=Number(readline()); var w=readline().split(" ").map(Number); var q={1:0, 2:0, 3:0}; for (var i=0; i<n; i++) { q[w[i]]+=1; } print(n-Math.max(q[1], q[2], q[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
o = input() s = raw_input() L = list(s) a1 = L.count('1') a2 = L.count('2') a3 = L.count('3') max1 = max(a1, a2, a3) print(len(L) - L.count(" ") - max1)
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
#coding: utf-8 def main(): N = input() inp = map(int, raw_input().split()) ans = sorted([inp.count(i) for i in set(inp)] + [0], reverse=True) print sum(ans[1:]) 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.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 }; int num; for (int i = 0; i < n; i++) { num = in.nextInt(); --num; ++a[num]; } int max= Math.max(a[0], Math.max(a[1], 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 static java.util.Arrays.deepToString; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.uti...
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.util.stream.IntStream; import java.lang.Math; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if(n == 1){ System.out.println(0); } else 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() { float a, c; cin >> a; const int b = a; int A[b], B[3]; for (int i = 0; i < 3; i++) { B[i] = 0; } for (int i = 0; i < b; i++) { cin >> A[i]; } for (int i = 0; i < b; i++) { B[A[i] - 1]++; } c = 0; for (int i = 0; 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
#include <bits/stdc++.h> using namespace std; int n, x[4], y, i; int main() { ios::sync_with_stdio(false); cin >> n; for (i = 0; i < n; i++) { cin >> y; x[y]++; } sort(x + 1, x + 4); cout << n - x[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
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A52 { public static void main (String args[]){ FastScanner 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
#include <bits/stdc++.h> int min(int a, int b) { return a < b ? a : b; } int main() { int n; scanf("%d", &n); int i, c[3]; memset(c, 0, sizeof(c)); for (i = 0; i < n; i++) { int a; scanf("%d", &a); a--; c[a]++; } printf("%d\n", min(c[0] + c[1], min(c[0] + c[2], c[1] + c[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
n=int(raw_input()) one=0 two=0 three=0 a=map(int,(raw_input()).split()) for i in a: if i==1: one+=1 elif i==2: two+=1 elif i==3: three+=1 print min(two+three,one+three,two+one)
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; const long long maxN = 1e6 + 5; const long long inf = 1e10; const long long mod = 1e9 + 7; long long n; long long f[4]; int main() { ios_base::sync_with_stdio(0); cin >> n; long long x; for (long long i = 1; i <= n; i++) { cin >> x; f[x]++; } long long r...
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())) v=list(set(l)) if len(v)==1: print('0') elif len(v)==2: c=0 for i in range(n): if l[i]==v[0]: c+=1 if c>n//2: print(n-c) else: print(c) else: a,b,c=0,0,0 for i in range(n): if l[i]==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.*; import java.io.*; import java.math.*; public class Main { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (nu...
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 = input() print(n - max(A.count(a) for a in '123'))
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 b[4], c, n, l = 0, a, i; int main() { scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a); b[a]++; } cout << n - max(b[1], max(b[2], b[3])) << 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
n = int(input()) a = [int(x) for x in input().split()] print(n - max([a.count(1), 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
n=input() A=raw_input() print n-max(A.count(str(x)) for x in xrange(1,4))
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.*; import java.math.*; public class test1A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); char[] c = in.nextLine().toCharArray(); int ones = 0; int twos = 0; int threes = 0; for(int i=0; i<n; 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=int(input()) l=input() if(l.count('1')>=l.count('2') and l.count('1')>=l.count('3')): print(l.count('2')+l.count('3')) elif(l.count('2')>=l.count('1') and l.count('2')>=l.count('3')): print(l.count('3')+l.count('1')) else: print(l.count('1')+l.count('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
#include <bits/stdc++.h> using namespace std; int f() { int n; cin >> n; vector<int> v(3); for (int i = 0; i < n; i++) { int t; cin >> t; v[t - 1]++; } int maxI = distance(v.begin(), max_element(v.begin(), v.end())); int res = 0; for (int i = 0; i < 3; i++) { if (i != maxI) res += v[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.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int count1 = 0; int count2 =0; int count3 =0; for(int i =0; i<n;i++){ int a = scanner.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
from statistics import mode tot = int(input()) num = list(map(int, input().strip().split())) max_num = mode(num) z = 0 for i in num: if i == max_num: z += 1 print(tot-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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class A { public static void main(String[] args){ try{ // Scanner scanner = new Scanner(System.in); BufferedReader read=new Buffer...
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; import java.io.BufferedReader; import java.io.InputStreamReader; public class T1 { public static void main(String args[]){ Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n=sc.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
#include <bits/stdc++.h> using namespace std; long n; int a = 0, b = 0, c = 0; void solve() { cin >> n; int tmp; for (long i = (0); i < (n); i++) { cin >> tmp; switch (tmp) { case 1: a++; break; case 2: b++; break; case 3: c++; break; }...
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 sys n = int(sys.stdin.readline()) idxs = map(int, sys.stdin.readline().split(' ')) count = [0,0,0] for i in idxs: count[i-1] += 1 count.sort() print count[0]+count[1]
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() v=map(int,raw_input().split()) print n-max(len([x for x in v if x==1]),len([x for x in v if x==2]),len([x for x in v if x==3]))
PYTHON