akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <algorithm>
#include <string>

/*
Organize Your Train part II(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1142)
?§£?????????:??????L?????????????????????????????????????????????????????????L-1???????????????????????¢????????????4???????????\???????????????????????????2????????????????????£????????????????????°?????????8(L-1)??????????????§???>??¨??????????¢??????????set????????£???????????¨????????????????????°?????????
*/

using namespace std;

//split_string("abcd",out1,out2,1)??¨????????¨
//out1 = "a"
//out2 = "bcd"

void split_string(const string &in,string &out1,string &out2,int idx);
int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;++i){
    set<string> s;
    string train;
    cin>>train;
    int len = train.length();
    for(int j=1;j<len;++j){
      string sub1,sub2;
      split_string(train,sub1,sub2,j);
      for(int k=0;k<2;++k){
        swap(sub1,sub2);
        s.insert(sub1+sub2);
        reverse(sub1.begin(),sub1.end());
        s.insert(sub1+sub2);
        reverse(sub2.begin(),sub2.end());
        s.insert(sub1+sub2);
        reverse(sub1.begin(),sub1.end());
        s.insert(sub1+sub2);
      }
    }
    cout<<s.size()<<endl;
  }


  return 0;
}

void split_string(const string &in,string &out1,string &out2,int idx){
  int i;
  for(i=0;i<idx;++i)
    out1 += in[i];
  for(;i<in.length();++i)
    out2 += in[i];
}

Measured memory_bytes: 3160
import sys
input = sys.stdin.readline

def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    st = []
    seen = set()
    st.append(0)
    while(st):
        x = st.pop()
        if(x in seen):continue
        seen.add(x)
        for i in gp[x]:
            if(i in seen):continue
            li[i]+=li[x]
            st.append(i)
    print(*li)

if __name__ == '__main__':
    main()


Measured memory_bytes: 102780
#include <stdio.h>

int main(void){
  long N;
  long long ans = 0;
  char S[10];
  int data[5] = {0,0,0,0,0};
  scanf("%ld",&N);

  for(int i = 0;i < N;i++){
    scanf("%s",S);
    switch(S[0]){
      case 'M':
        data[0]++;
        break;
      case 'A':
        data[1]++;
        break;
      case 'R':
        data[2]++;
        break;
      case'C':
        data[3]++;
        break;
      case 'H':
        data[4]++;
        break;
    }
  }

  for(int i = 0;i < 32;i++){
    int counter = 0;
    int sample = i;
    int flag = 0;
    long long  kari = 1;
    while(counter < 5){
      if(sample%2 == 1){
        flag++;
        kari *= data[counter];
      }
      sample /= 2;
      counter++;
    }
    if(flag == 3){
      ans += kari;
    }
  }

  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

int n,i,j,s,k;

scanf("%d\n ",&n);

int a[n];
 k=n;

for(i=0;i<n;i++){
  scanf("%d ",&a[i]);
}

 for(k=0;k<n-1;k++){
  printf("%d ",a[k]);
 }
printf("%d\n",a[n-1]);


for(i=1;i<n;i++){

  j=i-1;
  s=a[i];
   while(j>=0 && a[j]>s){

     a[j+1]=a[j];
     a[j]=s; 
     j--;
   }
  for(k=0;k<n-1;k++){
  printf("%d ",a[k]);
 }
printf("%d\n",a[n-1]);

}

return 0;
}










Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    
    int k,x;cin >>  k >> x;

    if((k*500)>= x)cout << "Yes"<< endl;
    else cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  char c;
  cin >> c;
  
  if(c=='a' || c=='e' || c=='i' || c=='o' ||c=='u') {
    
    cout << "vowel" << endl;
    
  } else {
    
    cout << "consonant" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
def main():
    N = list(map(int, list(input())))
    N = N[::-1] + [0]

    ans = 0
    for i in range(len(N)-1):
        if N[i] < 5:
            ans += N[i]
        elif N[i] > 5:
            ans += 10 - N[i]
            N[i+1] += 1
        else:
            ans += 5
            if N[i+1] >= 5:
                N[i+1] += 1

    print(ans + N[len(N)-1])

main()

Measured memory_bytes: 26488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int H[] = new int[N];

		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}

		loop: while (true) {
			for (int i = N - 1; i > 0; i--) {

				if (H[i] < H[i - 1]) {
					H[i - 1]--;
				}

				if (H[i] < H[i - 1]) {
					System.out.print("No");
					break loop;
				}

			}
			System.out.print("Yes");
			break;
		}

	}
}


Measured memory_bytes: 50636
using System;
using System.Linq;

namespace rensyuu1
{

    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] numb = Console.ReadLine().Trim().Split(' ');
                int h = int.Parse(numb[0]);
                int w = int.Parse(numb[1]);
                if (h == 0 && w == 0) break;
                int w1 = w / 2;
                int h1 = h / 2;
                string str1 = string.Concat(Enumerable.Repeat("#.", w1));
                string str2 = string.Concat(Enumerable.Repeat(".#", w1));
                if (w % 2 == 0)
                {
                    if (h % 2 == 0)
                    {
                        for (int i1 = 0; i1 < h1; i1++)
                        {
                            Console.WriteLine(str1);
                            Console.WriteLine(str2);
                        }
                    }
                    else if (h % 2 == 1)
                    {
                        for (int i2 = 0; i2 < h1; i2++)
                        {
                            Console.WriteLine(str1);
                            Console.WriteLine(str2);
                        }
                        Console.WriteLine(str1);
                    }
                }


                if (w % 2 == 1)
                {
                    if (h % 2 == 0)
                    {
                        for (int i1 = 0; i1 < h1; i1++)
                        {
                            Console.WriteLine("{0}#", str1);
                            Console.WriteLine("{0}.", str2);
                        }
                    }
                    else if (h % 2 == 1)
                    {
                        for (int i2 = 0; i2 < h1; i2++)
                        {
                            Console.WriteLine("{0}#", str1);
                            Console.WriteLine("{0}.", str2);
                        }
                        Console.WriteLine("{0}#", str1);
                    }

                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 16240
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            //var line = consoleReader.SplitInt32();
            //var D = line[0];
            var N = consoleReader.Int32();
            var p = consoleReader.RepeatInt32(N).OrderByDescending(i => i).ToArray();
            p[0] /= 2;
            return p.Sum();
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>

using namespace std;

void solve()
{
	int a, b;
	int sum = 0;
	int num = 0;
	int count = 0;
	while(~scanf("%d,%d", &a, &b))
	{
		count++;
		sum += a * b;
		num += b;
	}
	cout << sum << endl;
	cout << (int)((double)num / count + 0.5) << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
module mod_modulo_operations
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: f(0:100000), invf(0:100000)
  integer(8) :: dp(0:200,0:100000)
  integer :: s(200), leq(100000)
contains
  subroutine init(n)
    implicit none
    integer, intent(in) :: n
    integer :: i
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    invf(0) = 1_8
    dp = -1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
      invf(i) = inv(f(i))
    end do
    return
  end subroutine init
  integer(8) function perm(n,k)
    implicit none
    integer, intent(in) :: n, k
    perm = 0_8
    if (n.lt.0.or.k.gt.n) return
    perm = mod(f(n)*invf(n-k),md)
    return
  end function perm
  integer(8) function comb(n,k)
    implicit none
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
    return
  end function comb
  function inv(n) result(y)
    implicit none
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0
    y = 1
    do while(b.ne.0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    do while (y.lt.0_8)
      y = y+md
    end do
    y = mod(y,md)
    return
  end function inv
  recursive function dfs(n,x) result(c)
    implicit none
    integer :: n, x, sml, big, i
    integer(8) :: c, k
    c = dp(n,x)
    if (c.ge.0_8) return
    c = int(x,8)
    if (n.eq.0) return
    c = 0_8
    if (x.eq.0) return
    sml = leq(x)
    big = n-sml+1
    c = mod(f(n)*int(x,8),md)
    if (sml.eq.1) return
    k = mod(comb(n,sml-1)*f(big),md)
    c = 0_8
    do i = 1, sml-1
      c = mod(c+dfs(sml-2,mod(x,s(i))),md)
    end do
    c = mod(k*c,md)
    dp(n,x) = c
    return
  end function dfs
end module mod_modulo_operations
program modulo_operations
  use mod_modulo_operations
  implicit none
  integer :: n, x, i, j
  s = 0
  leq = 0
  read(*,*) n, x
  read(*,*) s(1:n)
  call quick_sort(s(1:n))
  j = 1
  do i = 1, 100000
    do while (j.le.n.and.s(j).le.i)
      j = j+1
    end do
    leq(i) = j
  end do
  call init(100000)
  write(*,'(i0)') dfs(n,x)
  stop
contains
  recursive subroutine quick_sort(a)
    implicit none
    integer, intent(inout) :: a(:)
    integer :: n, l, r, p, c
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)+a(l)+a(r)-max(a((l+r)/2),a(l),a(r))-min(a((l+r)/2),a(l),a(r))
    do
      do while (a(l).lt.p)
        l = l+1
      end do
      do while (a(r).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1))
    if (n.gt.r+1) call quick_sort(a(r+1:n))
  end subroutine quick_sort
end program modulo_operations

Measured memory_bytes: 159232
use std::io;


fn main() {
    let n = read_one::<usize>();
    let m: usize = 10usize.pow(9) + 7;
    let mut ans = 1;
    for i in 0..n {
        ans *= i + 1;
        ans %= m;
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	ll a,b,ta,tb;
	cin >> a >> b;
	ta = a,tb = b;
	map<ll,ll> mp;
	mp[1]++;
	for(ll i = 2; i*i <= max(ta,tb); i++){
		if(a%i == 0 && b%i == 0){
			while(a%i == 0) a /= i;
			while(b%i == 0) b /= i;
			mp[i]++;
		}	
		//while(a%i == 0) a /= i;
		while(b%i == 0) b /= i;
	}

	if(a < b) swap(a,b);
	if(a%b == 0) mp[b]++;

	cout << mp.size() << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int A, B;

int main(){
    cin >> A >> B;

    cout << max({A + B, A - B, A * B}) << endl;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    n <- readLn :: IO Int
    putStrLn $ show $ solve n 100000

solve :: Int -> Int -> Int
solve a b = if a == 0 then b else solve (a-1) (g $ f b)

f :: Int -> Float
f n = (fromIntegral n) * 1.05

g :: Float -> Int
g n =  1000 * ( ceiling (n/1000) )

Measured memory_bytes: 3748
#include <array>
#include <iostream>
using namespace std;

int main()
{
    int N, D;
    cin >> N >> D;
    int X[10][10];
    for (int k = 0; k < N; ++k) {
        for (int l = 0; l < D; ++l) {
            cin >> X[k][l];
        }
    }

    int count = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            int distance2 = 0;
            for (int l = 0; l < D; ++l) {
                distance2 += (X[i][l] - X[j][l]) * (X[i][l] - X[j][l]);
            }
            for (int n = 1; n < 127; ++n) {
                if (distance2 == n * n) {
                    ++count;
                    break;
                }
            }
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int n;
int main() {
    cin>>n;
    ll x[n],y[n];
    REP(i,n){
        cin>>x[i];
        y[i]=x[i];
    }

    sort(x,x+n);

    ll medianl=x[n/2-1];
    ll medianh=x[n/2];

    REP(i,n){
        if(y[i]<=medianl)cout<<medianh<<endl;
        else cout<<medianl<<endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    vector<int> p;
    int x;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        p.push_back(x);
    }
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < N - 1; i++)
    {
        sum += p[i];
    }
    sum += p[N - 1] / 2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
tri, rig, small, large = 0, 0, 0, 0
for line in stdin:
    line = list(map(int, line.split()))
    line.sort()
    if line[0] + line[1] <= line[2]:
        break
    tri += 1
    tmp = line[0] ** 2 + line[1] ** 2 - line[2] ** 2
    if tmp == 0:
        rig += 1
    elif tmp < 0:
        large += 1
    else:
        small += 1
print(tri, rig, small, large)



Measured memory_bytes: 5600
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <tuple>
#include <vector>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;
using lint = long long int;

int main() {
	int n;
	cin >> n;
	string s;
	string* strs = new string[n];
	for (int i = 0; i < n; i ++) {
		cin >> s;
		char cstr[11];
		int j = 0;
		for (; j < s.length(); j++)
			cstr[j] = s[j];
		sort(cstr, cstr + s.length());
		cstr[j] = 0;
		strs[i] = cstr;
	}

	sort(strs, strs + n);

	lint count = 0;
	for (int i = 0; i < n-1; ) {
		int j = i + 1;
		for (j = i + 1; ; j++) {
			if (j == n || strs[i] != strs[j]) {
				int n = j - i;
				if (n >= 2) {
					for (int k = 1; k < n; k++)
						count += k;
				}
				break;
			}
		}
		i = j;
	}

	cout << count;

	delete[] strs;
	return 0;
}

Measured memory_bytes: 5760
import numpy as np
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(N)]

dp=np.zeros(W+1,int)
for i in range(N):
  w,v=WV[i]
  dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[-1])

Measured memory_bytes: 21668
s=input()
a=len(s)
b=[0]
c=0
for i in range(a):
  if s[i]in"ACGT":
    for j in range(a-i):
      if s[i+j]in"ACGT":
        c+=1
      else:
        break
    b.append(c)
    c=0
print(max(b))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::map;
using std::multimap;
using std::set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll a, b;
	cin >> a >> b;
	cout << ((a < 9 && b < 9) ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 768
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
S =  sys.stdin.readline().rstrip()

ans = 0
for i in range(1, N):
    A = set(S[:i:])
    B = set(S[i::])
    ans = max(ans, len(A & B))

print(ans)

Measured memory_bytes: 64492
#!/usr/bin/env python3

N, K = map(int, input().split())
A = list(map(int, input().split()))

def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)

def gcd_many(l):
    # if len(l) == 1:
    #     return l
    # elif len(l) == 2:
    #     return gcd(l[0], l[1])
    # else:
    #     return gcd(l[0], gcd_many(l[1:]))
    if len(l) == 1:
        return l[0]
    g = l[0]
    for i in range(1,len(l)):
        g = gcd(g, l[i])
    return g

Amax = max(A)
g = gcd_many(A)

possible = "POSSIBLE"
impossible = "IMPOSSIBLE"


if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)


Measured memory_bytes: 62576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 998244353;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A > B) swap(A, B);
	if (A < C && C < B) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define FOR for(int i=1; i<=n; ++i)

int a[105];

int main() {

    int n;
    sc("%d", &n);

    FOR {
        sc("%d", &a[i]);
    }

    ll ans = 0;

    for(int i=1; i<=n-2; ++i) {

        for(int j=i+1; j<=n-1; ++j) {
            for(int k=j+1; k<=n; ++k) {
                if(a[i] != a[j] && a[j] != a[k] && a[k] != a[i] && (a[i]+a[j] > a[k]) && (a[j]+a[k] > a[i]) && (a[k]+a[i] > a[j])) {
                    ans++;
                }
            }
        }
    }

    printf("%lld\n", ans);
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << min(a,b) + min(c,d) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int H, W;
  cin >> H >> W;

  int c[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (int k = 0; k < 10; k++) for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) {
    c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  }
  
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int A;
      cin >> A;
      if (A < 0) continue;
      ans += c[A][1];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int cnt[n+1];
  memset(cnt,0,sizeof(cnt));
  while(k--){
  	int d;
    cin>>d;
    while(d--){
      int t;
      cin>>t;
      cnt[t]++;
    }
  }
 	int ans = 0;
  for(int i = 1; i <= n;i++){
  	if(cnt[i] == 0)ans++;
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ll a,b;
    double c;
    
    cin >> a;
    cin >> c;
    
    b = (c*100+.5);
    
    ll res = (a*b);
    res/=100;
    
    cout << res; 
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3712
#include<bits/stdc++.h>

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int N, as[3030];
  ll dp[3030][3030][2];

  void init() {
    cin >> N;
    rep(i, N) {
      cin >> as[i];
    }
  }

  ll rec(int l, int r, bool turn) {
    if(dp[l][r][turn] > -L_INF) return dp[l][r][turn];
    int k = 1;
    if(turn) k = -1;
    if(l == r-1) return dp[l][r][turn] = k * as[l];
    ll left = rec(l+1, r, !turn) + k * as[l];
    ll right = rec(l, r-1, !turn) + k * as[r-1];
    if(turn) {
      return dp[l][r][turn] = min(left, right);
    } else {
      return dp[l][r][turn] = max(left, right);
    }
  }

  void solve() {
    repc(i, N) repc(j, N) rep(k, N) dp[i][j][k] = -L_INF;
    cout << rec(0, N, 0) << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 143872
require 'prime'
primes = Prime.each(10000).to_a

while true
  n = gets.to_i
  break if n.zero?
  res = 0
  for i in (0...primes.size) do
    sum = 0
    for j in (i...primes.size) do
      sum += primes[j]
      if(sum == n)
        res += 1
        break
      end 
      break if(sum > n)
    end
  end
  puts res
end

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;

  char c = S[K-1];
  for (int i=0; i<N; i++) {
    if (S[i] != c) S[i] = '*';
  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

long memo[11][1001][101];

long combi(int n, int s, int x){
	if (!n) return !s;
	if (x > 100) return 0;
	if (s < 0) return 0;
	if (memo[n][s][x] != -1) return memo[n][s][x];
	
	return memo[n][s][x] = combi(n - 1, s - x, x + 1) + combi(n, s, x + 1);
}

int main(void)
{
	int i, j;
	int N, S;
	
	memset(memo, -1, sizeof(memo));
	while (scanf("%d %d", &N, &S), N || S){
		printf("%ld\n", combi(N, S, 0));
	}
	
	return 0;
}

Measured memory_bytes: 9300
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " "
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    queue<ll> que;
    rep(i,9){
        que.push(i + 1);
    }
    ll now = 0;
    rep(i,N){
        ll res = 0;
        now = que.front();que.pop();
        string S = to_string(now);
        ll s = S.size();
        if(S[s - 1] == '0'){
            res = stoll(S + '0');
            que.push(res);
            res++;
            que.push(res);
        }
        else if(S[s - 1] == '9'){
            res = stoll(S + '8');
            que.push(res);
            res++;
            que.push(res);
        }
        else{
            char c = S[s - 1] - 1;
            res = stoll(S + c);
            que.push(res);que.push(res + 1);que.push(res + 2);
        }
        //cout << now << "\n";
    }
    cout << now << endl;
}


Measured memory_bytes: 4840
#coding:utf-8
N = int(input())
H = list(map(int,input().split()))
flag = False
for i in range(len(H)-1):
    if (H[i] - 1) > H[i+1]:
        print ("No")
        exit()
    elif (H[i] - 1 )== H[i+1]:
        if flag:
            print ("No")
            exit()
        else:
            flag = True
    elif H[i] == H[i+1]:
        pass
    else:
        flag = False
    #print (flag)
print ("Yes")

Measured memory_bytes: 15020
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] a = s.split("");
		int zero = 0;
		for(int i = 0; i < a.length; i++) {
			if(a[i].equals("0")) {
				zero ++;
			}
		}
		int one = a.length - zero;
		int ans = Math.min(zero, one) * 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 32704
def main():
    from itertools import tee
    S = input()

    it1, it2 = tee(iter(S), 2)
    next(it2)
    for i, (c1, c2) in enumerate(zip(it1, it2), start=1):
        if c1 == c2:
            print(i, i + 1)
            return

    it1, it2, it3 = tee(iter(S), 3)
    next(it2)
    next(it3)
    next(it3)
    for i, (c1, c2, c3) in enumerate(zip(it1, it2, it3), start=1):
        if c1 == c3:
            print(i, i + 2)
            return

    print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
    int x,i;

    
    i =1;
        while(1){
            cin >> x;
        if ( x == 0 ) break;
            cout << "Case " << i << ": " <<  x <<endl; 
             i =i+1;
        }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++) 
using namespace std;

int main() {
  
  string s;
  cin >> s;
  
  bool ans = false;
  
  if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0])
    ans = true;

  cout << ((ans) ? "Yes" : "No") << endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int a[100];

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    sort(a, a + n, greater<int>());
    // for (int i = 0; i < n - 1; i++)
    // {
    //     for (int j = 1; j < n; j++)
    //     {
    //         if (a[i] < a[j])
    //         {
    //             int tmp = a[i];
    //             a[i] = a[j];
    //             a[j] = tmp;
    //         }
    //     }
    // }

    int sum_alice = 0;
    int sum_bob = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            sum_alice += a[i];
        }
        else
        {
            sum_bob += a[i];
        }
    }

    cout << sum_alice - sum_bob << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c;
  cin >> a >> b >> c;
  int mn = min(a, min(b, c));
  int mx = max(a, max(b, c));
  int md = a + b + c - mn - mx;
  if (mn == 5 && md == 5 && mx == 7) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int k = sc.nextInt();
      	int x = sc.nextInt();
      	if(k*500 >= x) System.out.println("Yes");
      	else System.out.println("No");
    }
}

Measured memory_bytes: 35708
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int count = 0;
  for (int i=0; i<s.size()/2; i++) {
    if (s.at(i) != s.at(s.size()-1-i)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    String ABCD = sc.next();

	    String[] ABCD_Array = ABCD.split("", 0);



	    int a = Integer.parseInt(ABCD_Array[0]);
	    int b = Integer.parseInt(ABCD_Array[1]);
	    int c = Integer.parseInt(ABCD_Array[2]);
	    int d = Integer.parseInt(ABCD_Array[3]);

	    String op1 = "";
	    String op2 = "";
	    String op3 = "";

	    loop: for (int i = -1; i <= 1; i +=2) {
	    	int tmp_answer = 0;
	    	 for (int j = -1; j <= 1; j +=2) {
	    		 for (int k = -1; k <= 1; k +=2) {
	    			 tmp_answer = a + b * i + c * j + d * k;
	    			 if (tmp_answer == 7) {

	    				 if (i == -1) {
	    					 op1 = "-";
	    				 }
	    				 else {
	    					 op1 = "+";
	    				 }

	    				 if (j == -1) {
	    					 op2 = "-";
	    				 }
	    				 else {
	    					 op2 = "+";
	    				 }

	    				 if (k == -1) {
	    					 op3 = "-";
	    				 }
	    				 else {
	    					 op3 = "+";
	    				 }

	    				 break loop;
	    			 }
	    		 }
	    	 }
	    }
	    System.out.println(String.valueOf(a) + op1 + String.valueOf(b) + op2 + String.valueOf(c) + op3 + String.valueOf(d) + "=7");
	}
}

Measured memory_bytes: 21460
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int X, Y;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> X >> Y;
   if (Y - 2 * X >= 0 && (Y - 2 * X) % 2 == 0 && (Y - 2 * X) / 2 <= X) cout << "Yes";
   else cout << "No";    
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int n, cnt = 0, a[62][3], tot = 0;
int main()
{
    scanf("%d", &n); n--;
    int ed = 1, x = 1;
    for(int i=1;i<20 && n;i++,x<<=1) {
        if(x > n) break;
        a[++cnt][0] = i; a[cnt][1] = i+1; a[cnt][2] = x;
        a[++cnt][0] = i; a[cnt][1] = i+1; a[cnt][2] = 0;
        n -= x; tot += x; ed = i+1;
    }
    if(n) {
        for(int i=ed; i>=1; i--) {
            while(1<<(i-1) <= n) {
                n -= (1<<(i-1));
                a[++cnt][0] = i; a[cnt][1] = ed; a[cnt][2] = tot + 1;
                tot = tot + (1<<(i-1));
            }
        }
    }
    printf("%d %d\n", ed, cnt);
    for(int i=1;i<=cnt;i++) printf("%d %d %d\n", a[i][0], a[i][1], a[i][2]);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = [i for i in input().strip()]
k = int(input())

while k:
    v = s.pop(0)
    if v != '1':
        print(v)
        sys.exit(0)
    else:
        k -= 1
print(1)


Measured memory_bytes: 61792
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
    sort(s.at(i).begin(), s.at(i).end());
  }
  sort(s.begin(), s.end());
  long long cnt = 0, x;
  for (long long i = 0; i < n - 1; i++) {
    x = 1;
    while (s.at(i) == s.at(i + 1)) {
      if (i + 1 == n - 1) {
        x++;
        break;
      }
      i++;
      x++;
    }
    cnt += x * (x - 1) / 2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;
    
    vector<int> a(n);
    int mostmax=0,secmax=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]>mostmax){
            secmax=mostmax;
            mostmax=a[i];
        }else if(a[i]>secmax){
            secmax=a[i];
        }
    }
    
    for(int i=0;i<n;i++){
        if(a[i]==mostmax){
            cout << secmax << endl;
        }else{
            cout << mostmax << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back #define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << '\n'
#define prs(XX) cout << XX << ' '
#define TEST cout << "TEST\n";

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = acos(-1.0);
const double EPS = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=MOD; x += (y%MOD); x %= MOD; }
void mul(ll &x, ll y){ x%=MOD; x *= (y%MOD); x %= MOD; }

ll us(ll n, ll x, ll m){
    if(x == 0) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

ll N, Q, sq, n;
string S;


ll decomp[750][30];

void generate(void){
    for(ll i = 0; i < N; ++i){
        decomp[i/sq][S[i]-'a']++;
    }
}

void change(ll iq, char cq){
    decomp[iq/sq][S[iq]-'a']--;
    decomp[iq/sq][cq-'a']++;
    S[iq] = cq; 
    return;
}

ll getres(ll l, ll r){
    ll startkok = l/sq, endkok = r/sq;

    ll ans[30] = {0};
    if(startkok == endkok or startkok == endkok - 1){
        for(ll i = l; i <= r; ++i){ ans[S[i]-'a']++; }
    }
    else{
        for(ll i = startkok+1; i <= endkok-1; ++i){
            for(ll j = 0; j < 27; ++j)
                if(decomp[i][j] > 0) ans[j]++;
        }
        for(ll i = l; i < (startkok+1)*sq; ++i){ ans[S[i]-'a']++; }
        for(ll i = r; i >= endkok*sq; --i){ ans[S[i]-'a']++; }
    }
    ll res = 0;
    forn(30, i) if(ans[i]) res++;
    return res;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N >> S >> Q;

    sq = (ll)(ceil(sqrt(N)));
    n = N/sq + 13;
    
    generate();
    while(Q--){
        ll qtype; cin >> qtype;
        if(qtype == 1){
            ll iq; char cq; cin >> iq >> cq; iq--;
            change(iq, cq);
        }
        if(qtype == 2){
            ll l, r; cin >> l >> r; l--; r--;
            cout << getres(l, r) << endl;
        }
    }

    return 0;
}

//cikisir



Measured memory_bytes: 1172
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;

}

void solve()
{
	int k;
	string s;
	cin >> k >> s;
	rep(i, min(k, sz(s))){
		cout << s[i];
	}
	if(k < sz(s)) cout << "...";
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	// precalc();
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);


int main() {
	int N;
	string S;
	cin >> N >> S;

	int cnt = 0;
	rep(i, N-2) {
		if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') {
			cnt++;		
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define A 1000000007
typedef long long ll;
ll FIB(int a){
	ll b,c;
	ll ans=1;
	b=c=1;
	if(a<3){
		return 1;
	}else{
		rep(i,a-2){
			ans=((b+c)%A);
			c=b;
			b=ans;
		}
		return ans;
	}
	
	
}
int main(){
	int m,n,t,s;
	t=0;
	ll ans=1;
	cin>>n>>m;
	rep(i,m){
		cin>>s;
		if(s==t){
			ans=0;
			break;
		}
		ans*=((FIB(s-t))%A);
		ans%=A;
		t=(s+1);
		
	}
	ans*=(FIB(n-t+1)%A);
	ans%=A;
	cout<<ans<<endl;
	return 0;
}	


Measured memory_bytes: 256