akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

int main(){
  int n;
  cin >> n;
  vi a(n), b(n), c(n-1);
  rep(i, n)cin >> a[i];
  rep(i, n)cin >> b[i];
  rep(i, n-1)cin >> c[i];

  int sum=b[a[0]-1];
  for(int i=1; i<n; i++){  
    sum+=b[a[i]-1];
    if(a[i]-a[i-1]==1)sum+=c[a[i-1]-1];
    }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    zoom;
    ll X, Y;
    cin >> X >> Y;
    ll look[3] = {300000, 200000, 100000};
    ll ans = 0;
    if(X <= 3)
    	ans += look[X - 1];
    if(Y <= 3)
    	ans += look[Y - 1];
    if(X == 1 && Y == 1)
    	ans += 400000;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
int n,m,k; 
const int p=1e9+7;
long long ans,f[110000],inv[110000];
inline long long C(int n,int m){
	return f[n]*inv[m]%p*inv[n-m]%p;
}
inline void wor(int pri){
	k=1;
	m/=pri;
	while (m%pri==0){
		k++;
		m/=pri;
	}
	ans=ans*C(n+k-1,n-1)%p;
}
int main(){
	scanf("%d%d",&n,&m);
	ans=1;
	f[0]=1;
	fo(i,1,n+1000) f[i]=f[i-1]*i%p;
	inv[0]=1;inv[1]=1;//!!!!
	fo(i,2,n+1000) inv[i]=(p-p/i)*inv[p%i]%p;//1..n+1000
	fo(i,1,n+1000) inv[i]=inv[i-1]*inv[i]%p;
	//fo(i,n,n+100) printf("%d\n",inv[i]*f[i]%p);
	for(int i=2;i*i<=m;i++) if (m%i==0) wor(i);
	if (m>1) wor(m);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    sc.close();
    if("SSS".equals(input)){
      System.out.println(0);
    } else if("RRS".equals(input) || "SRR".equals(input)){
      System.out.println(2);
    } else if("RRR".equals(input)){
      System.out.println(3);
    } else {
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 35472
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>

#define reps(i,f,n) for(int i = f; i <= n; ++i)
#define rep(i,n) reps(i,0,n-1)
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<int,PII> PIP;

int N,M;
int R;

int G[256][256];
int H[256][256];
int z[1024];
int g[1024][256];
//pos, ship

const int INF = 1e8;

void init(){
	rep(i,1024)rep(j,256) g[i][j] = INF;
	rep(i,256)rep(j,256)G[i][j] = H[i][j] = INF;
	rep(i,256) G[i][i] = H[i][i] = 0;
	rep(i,1024) z[i] = 0;
}

int main(void){
	while(1){
		init();
		int x,y,t;
		string s;
		cin >> N >> M;
		if( N+M == 0)break;
		rep(i,M){
			cin >> x >> y >> t >> s;
			x--;y--;
			if(s[0] == 'L'){
				G[x][y] = t;
				G[y][x] = t;
			} else {
				H[x][y] = t;
				H[y][x] = t;
			}
		}
		
		rep(k,N){
			rep(i,N){
				rep(j,N){
					G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
					H[i][j] = min(H[i][j], H[i][k] + H[k][j]);
				}
			}
		}


		cin >> R;
		rep(i,R) cin >> z[i];
		rep(i,R) z[i]--;


		g[0][z[0]] = 0;
		rep(i,R-1){
			rep(j,N){
				int cost = g[i][j];
				//cout << cost << ":" << i << ":" << j << endl;
				int cc = cost + G[z[i]][z[i+1]];
				
				if( g[i+1][j]  > cc){
					g[i+1][j] = cc;
				}

				cc = cost + G[z[i]][j] + H[j][z[i+1]];
				if(g[i+1][z[i+1]] > cc ){
					g[i+1][z[i+1]] = cc;
				}

				rep(k,N){
					cc = G[z[i]][j] + H[j][k] + G[k][z[i+1]]+cost;
					if(g[i+1][k] > cc){
						g[i+1][k]  = cc;
					}
				}
			}
		}
		int ans = INF;
		
		rep(i,256){
			ans = min(ans, g[R-1][i]);
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

typedef long double ld;
using namespace std;


int main() {
    int N;
    cin>>N;
    map<string,int> mp;
    string s;
    ll count=0;
    REP(i,N){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    sort(s.begin(),s.end());
 
    for(auto&p:mp){
        int s=p.second;
        count+=(ll)s*(s-1)/2;//sC1…combination
    }
    cout<<count<<endl;
    return 0;
}
 

Measured memory_bytes: 11136
from heapq import heappush, heappop


def solve(X, Y, Z, K, As, Bs, Cs):
    As.sort()
    Bs.sort()
    Cs.sort()
    ADs = [a2 - a1 for a1, a2 in zip(As, As[1:])][::-1]
    BDs = [a2 - a1 for a1, a2 in zip(Bs, Bs[1:])][::-1]
    CDs = [a2 - a1 for a1, a2 in zip(Cs, Cs[1:])][::-1]

    m = As[-1] + Bs[-1] + Cs[-1]
    h = []
    ans = [m]
    if ADs:
        heappush(h, (ADs[0], (0, -1, -1)))
    if BDs:
        heappush(h, (BDs[0], (-1, 0, -1)))
    if CDs:
        heappush(h, (CDs[0], (-1, -1, 0)))
    taken = set()

    for i in range(K - 1):
        p, stacks = heappop(h)
        while (p, stacks) in taken:
            p, stacks = heappop(h)
        taken.add((p, stacks))
        ans.append(m - p)

        if stacks[0] + 1 < len(ADs):
            heappush(h, ((p + ADs[stacks[0] + 1]), (stacks[0] + 1, stacks[1], stacks[2])))
        if stacks[1] + 1 < len(BDs):
            heappush(h, ((p + BDs[stacks[1] + 1]), (stacks[0], stacks[1] + 1, stacks[2])))
        if stacks[2] + 1 < len(CDs):
            heappush(h, ((p + CDs[stacks[2] + 1]), (stacks[0], stacks[1], stacks[2] + 1)))

    return "\n".join([str(a) for a in ans])

if __name__ == "__main__":
    X, Y, Z, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    Bs = list(map(int, input().split(" ")))
    Cs = list(map(int, input().split(" ")))
    print(solve(X, Y, Z, K, As, Bs, Cs))


Measured memory_bytes: 5104
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
const int N=21;
int main(){
    int l,now=1,n=1,m=0,temp,cnt=1;
    vector<pi> graph[N];
    scanf("%d",&l);
    while(cnt<l){
        if(cnt*2<=l){
            graph[n].PB({n+1,now});
            graph[n].PB({n+1,0});
            n++;
            m+=2;
            cnt*=2;
            now*=2;
        }
        else {
            temp=1;
            for(int j=1;j<=n;j++){
                if(cnt+temp*2>l){
                    graph[j].PB({n,cnt});
                    cnt+=temp;
                    break;
                }
                else temp<<=1;
            }
            m++;
        }
    }
    
    printf("%d %d\n",n,m);
    for(int i=1;i<=n;i++)for(pi j:graph[i])printf("%d %d %d\n",i,j.F,j.S);
}

Measured memory_bytes: 256
s = int(input())

mae = (s - (s%100))/100
ushiro = s%100

if(1<=mae and mae<=12 and 1<=ushiro and ushiro <= 12):
    print("AMBIGUOUS")
elif(1<=mae and mae<=12):
    print("MMYY")
elif(1<=ushiro and ushiro<=12):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])

N,K = LI()
XY = [LI() for _ in range(N)]

X = []
Y = []
for x,y in XY:
    if not(x in X):
        X.append(x)
    if not(y in Y):
        Y.append(y)
        
X.sort()
Y.sort()
dic_XoYo = {}
dic_XcYo = {}
dic_XoYc = {}
dic_XcYc = {}
for x1 in X:
  for y1 in Y:
    key = x1*(10**10)+y1
    cnt_XoYo = 0
    cnt_XcYo = 0
    cnt_XoYc = 0
    cnt_XcYc = 0
    for x2,y2 in XY:
      if x2<=x1 and y2<=y1:
        cnt_XcYc += 1
      if x2<x1 and y2<=y1:
        cnt_XoYc += 1
      if x2<=x1 and y2<y1:
        cnt_XcYo += 1
      if x2<x1 and y2<y1:
        cnt_XoYo += 1
    dic_XcYc[key] = cnt_XcYc
    dic_XoYc[key] = cnt_XoYc
    dic_XcYo[key] = cnt_XcYo
    dic_XoYo[key] = cnt_XoYo

ans = []
for xl in range(len(X)-1):
  for xr in range(xl,len(X)):
    for yd in range(len(Y)-1):
      for yu in range(yd,len(Y)):
        cnt = dic_XcYc[X[xr]*(10**10)+Y[yu]]
        cnt -= dic_XcYo[X[xr]*(10**10)+Y[yd]]
        cnt -= dic_XoYc[X[xl]*(10**10)+Y[yu]]
        cnt += dic_XoYo[X[xl]*(10**10)+Y[yd]]
        if cnt>=K:
          ans.append((X[xr]-X[xl])*(Y[yu]-Y[yd]))
print(min(ans))



Measured memory_bytes: 118068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    string s;
    int ans=0;
    cin >> s;
    int i;
    for(i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='L'){
                ans++;
            }
        }
        else{
            if(s[i]!='R'){
                ans++;
            }
        }
    }
    if(ans==s.size()) cout << "Yes" << endl;
    else cout << "No" << endl;
    }


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,m:usize,
       mut ab:[(usize,usize);n],
    }
    ab.sort();
    let mut hp = BinaryHeap::new();
    let mut ind = 0;
    let mut ans = 0;
    for day in 1..=m {
        while ind < n && ab[ind].0 <= day {
            hp.push(ab[ind].1);
            ind += 1;
        }
        if let Some(x) = hp.pop() {
            ans += x;
        }
    }
    println!("{}", ans);
}


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

int main(){
  string S;
  cin >> S;
  if(S=="RRR"){
    cout << 3 << endl;
  }
  else if(S=="RRS" || S=="SRR"){
    cout << 2 << endl;
  }
  else if(S=="SSS"){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3620
n, m = gets.split.map &:to_i
arr = Array.new(n)
n.times do |i|
  arr[i] = gets.split.map &:to_i
  arr[i].shift
end
num = Array.new(m, 0)
m.times do |i|
  n.times do |j|
    if arr[j].any? { |e| e == (i+1) }
      num[i] += 1
    end
  end
end
puts num.count(n)

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

int main(){
  int n,m; cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  vector<pair<int,int>> bc(m);
  rep(i,m){
    int b,c; cin >> b >> c;
    bc[i].first=c; bc[i].second=b;
  }
  sort(bc.begin(),bc.end());
  reverse(bc.begin(),bc.end());

  int current=0; bool aa=true;
  rep(i,m){
    rep(j,bc[i].second){
    if(bc[i].first>a[current]){
    a[current] = bc[i].first;
    current++;
    }else{
      aa=false; break;
    }
    }
      if(!aa) break;
  }
  long long ans=0;
  rep(i,n) ans+=a[i];
  cout << ans << endl;
 return 0;
}


Measured memory_bytes: 1408
import java.util.*;
import java.math.*;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int sum = 0;

    for (int i = 0; i < n; i++) {
      sum += sc.nextInt();
    }

    if (sum >= h) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}


Measured memory_bytes: 48288
#include<bits/stdc++.h>
using namespace std;
int check(int val)
{
  int cnt=0;
  while(val>0)
  {
    cnt++;
  val=val/10;
  }
  if(cnt&1)
    return 1;
  return 0;
}
int main()
{
int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(check(i))
      ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

ll fa[MAX], rf[MAX];


int main(void) {
  ll N, M;
  cin >> N >> M;
  
  if(N<M) swap(N, M);
  
  if(abs(N-M)>1) {
    pt(0);
    return 0;
  }
  
  fa[0]=rf[0]=1;
  for(ll i=1; i<=N+1; i++) {
    fa[i]=fa[i-1]*i%MOD;
    rf[i]=moP(fa[i], MOD-2);
  }
  
  
  if(N-M==1) {
    pt(fa[N]*fa[M]%MOD);
  }else {
    pt(fa[N]%MOD*fa[M]%MOD*2%MOD);
  }
  
  
  
}






Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;

int main(){
    string a;
    cin >> a;
    if(a == "abc" ||a == "acb" ||a == "bac" ||a == "bca" ||a == "cab" ||a == "cba"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int stop;
	int A[7] = {1,3,5,7,8,10,12};
	int B[4] = {4,6,9,11};
	int C[1] = {2};
	int X, Y;
	
	cin >> X >> Y;
	
	for (int i = 0;i<=6; ++i) {
		if (X == A[i]) X = 20;
		if (Y == A[i]) Y = 20;
	}
	for (int i = 0; i <= 3; ++i) {
		if (X == B[i]) X = 21;
		if (Y == B[i]) Y = 21;
	}
	for (int i = 0; i <= 0; ++i) {
		if (X == C[i]) X = 22;
		if (Y == C[i]) Y = 22;
	}
	
	if (X == Y) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  char s[200000+1];
  scanf("%s", s);
  int min_a = -1;
  int max_z;
  for (int i = 0; i < 200000+1; i++) {
    if (s[i] < 'A' || s[i] > 'Z') {
      break;
    }
    if (min_a == -1 && s[i] == 'A') {
      min_a = i;
    }
    if (s[i] == 'Z') {
      max_z = i;
    }
  }
  printf("%d\n", max_z-min_a+1);

  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    rep(i, 3) {
        if (s[i] == 'R') cnt++;
        else {
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    string n;
    long long digsum = 0;
    
    cin >> n;
    int len = (int)(n.length());

    for(int i=0; i<len; i++){
        digsum += int(n[i]-'0');
    }

    if(digsum%9==0){
        cout << "Yes";
    }else{
        cout << "No";
    }


}

Measured memory_bytes: 3684
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    IN(ll, b);
    string x, y;
    REP(i, a)
    {
        x.push_back('0' + b);
    }
    REP(i, b)
    {
        y.push_back('0' + a);
    }
    OUT(min(x, y));
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int A, B;

    int x = 0;

    cin >> A >> B;

    REP(i, 2)
    {
        if( A > B )
        {
            x += A;
            A--;
        }
        else
        {
            x += B;
            B--;
        }
    }
    cout << x << endl;


    return 0;
}


Measured memory_bytes: 256
import sys

def powmod(a, n, _mod):
    res = 1
    for i in range(n):
        res = a * res % mod
    return res
N = int(input())

mod = 1000000007

ans = powmod(10, N, mod) - powmod(9, N, mod) - powmod(9, N, mod) + powmod(8, N, mod)
ans %= mod
if ans < 0:
    ans = (ans + mod) % mod
print(ans)


Measured memory_bytes: 9072
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(a+b-n,0ll)<<endl;
}


Measured memory_bytes: 888
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- 

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 	
 	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N;
    vector<int> a;
    int count[9] = {};
    cin >> N;
    for(int i=0; i<N; i++)
    {
    	int b;
    	cin >> b;
    	a.push_back(b);
    }
    for(int i=0; i<N; i++)
    {
    	int x = a[i]/400;
        if(x<8) count[x]++;
        else count[8]++;
    }

    int ans1 = 0, ans2 = 0; 
    for(int i=0; i<8; i++)
    {
       if(count[i]>0) ans1++;
    }
    ans2 = ans1 + count[8];
    ans1 = max(ans1,1);
    cout << ans1 << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e4 + 9, M = 1e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if(a < 0)
    a += MOD;
  return a;
}

ll mem[N][M][3], n;
string mx;

ll solve(int len, int sum, int can) {
  if(len == (int)mx.size())
    return (can > 0) && (!sum);
  ll& ret = mem[len][sum][can];
  if(~ret)
    return ret;
  ret = 0;
  for (int i = 0; i < 10; ++i) {
    int nwVal;
    if(can != 2)
      nwVal = can;
    else {
      if(i + '0' < mx[len])
        nwVal = 1;
      else if(i + '0' == mx[len])
        nwVal = 2;
      else
        nwVal = 0;
    }
    ret = add(ret, solve(len + 1, ((sum + i ) % n), nwVal ));
  }
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> mx >> n;
  memset(mem, -1, sizeof mem);
  ll ans = add(solve(0, 0, 2), -1);
  cout << ans;
  return 0;
}


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

int main(){
    int n,c,ans=1;
    cin >> n >> c;
    vector<pair<int,int>> span[30];
    map<int,int> s,t;
    for(int i = 0;i < n;i ++){
        int s0,t0,c0;
        cin >> s0 >> t0 >> c0;
        span[c0-1].push_back(make_pair(s0,t0));
        s[s0] ++;
        t[t0] ++;
    }
    for(int i = 0;i < c;i ++){
        if(!span[i].size()) continue;
        sort(span[i].begin(),span[i].end());
        for(int j = 0;j < span[i].size()-1;j ++){
            if(span[i][j].second==span[i][j+1].first){
                s[span[i][j].second] --;
                t[span[i][j].second] --;
            }
        }
    }
    int cnt = 0;
    for(int i = 1;i < 1e5+1;i ++){
        cnt += s[i];
        ans = max(ans,cnt);
        cnt -= t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10624
#include <iostream>
using namespace std;
int main(void){
	int n,a[21],v[21],max=0,num=21;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i]>>v[i];
		if(v[i]>=max){
			if(max!=v[i]) num=a[i];
			else if(num>a[i]) num=a[i];
			max=v[i];
		}
	}
	cout<<num<<" "<<max<<endl;
	return 0;
}

Measured memory_bytes: 1168
import math
from functools import reduce

def getD(num):
    input_list = [2 if i % 2 == 0 else i for i in range(num+1)]
    input_list[0] = 0
    bool_list = [False if i % 2 == 0 else True for i in range(num+1)]
    sqrt = int(math.sqrt(num))
    
    for serial in range(3, sqrt + 1, 2):
        if bool_list[serial]:
            for s in range(serial ** 2, num+1, serial):
                if bool_list[s]:
                    input_list[s] = serial
                    bool_list[s] = False
    return input_list

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

D = getD(max(A))

flag = True

d_set = set()
for a in A:
    while a != 1:
        d = D[a]
        if d in d_set:
            flag = False
            break
        else:
            d_set.add(d)
        while a > 1 and a % d == 0:
            a = a // d
    if not(flag):
        break



if flag:
    print('pairwise coprime')
    exit()

if reduce(math.gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 127960
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>

using namespace std;

#define INF 999999999

vector< vector<int> > in( 10 );
int dp[10][2001]; //[genre x までで][y冊売った]ときの最大値

int main(){
	long long int ans=0;
	int N, K, C, G, i, j, k;
	cin >> N >> K;
	for(j=0;j<10;j++) in[j].push_back(INF);
	for(i=0;i<N;i++){
		cin >> C >> G;
		in[G-1].push_back(C);
	}
	for(j=0;j<10;j++) sort(in[j].begin(),in[j].end(),greater<int>());
	for(j=0;j<10;j++) in[j][0] = 0;
	for(j=0;j<10;j++){
		for(i=1;i<(int)in[j].size();i++){
			in[j][i] += 2*(i-1) + in[j][i-1];
			//cout << in[j][i] << " ";
		}
		//cout << endl;
	}
	for(i=0;i<N;i++){
		if(i >= in[0].size()) dp[0][i] = 0;
		else dp[0][i] = in[0][i];
	}
	for(j=1;j<10;j++){
		for(i=0;i<=K;i++){
			dp[j][i] = 0;
			for(k=0;k<in[j].size();k++){
				if(i-k>=0) dp[j][i] = max(dp[j-1][i-k] + in[j][k], dp[j][i]);
			}
			//cout << dp[j][i] << " ";
		}
		//cout << endl;
	}
	ans = dp[9][K];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1308
from bisect import bisect_left

INF = 30000000000

if __name__ == '__main__':
    a, b, q = map(int, input().split())
    ss = [- INF] + [int(input()) for _ in range(a)] + [INF]
    ts = [- INF] + [int(input()) for _ in range(b)] + [INF]
    xs = [int(input()) for _ in range(q)]

    for x in xs:
        sr = bisect_left(ss, x)
        tr = bisect_left(ts, x)
        sl = sr - 1
        tl = tr - 1
        can1 = ss[sr] - ts[tl] + min(ss[sr] - x, x - ts[tl])
        can2 = ts[tr] - ss[sl] + min(ts[tr] - x, x - ss[sl])
        can3 = max(ss[sr], ts[tr]) - x
        can4 = x - min(ss[sl], ts[tl])
        print(min(can1, can2, can3, can4))


Measured memory_bytes: 17752
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan =new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String str=scan.nextLine();
    if(str.substring(0,N/2).equals(str.substring(N/2))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
#include<stdio.h>

int main()
{
  int i;
  char s[5];
  int ans;
  scanf("%s",s);
  if(s[0]=='R'){
    if(s[1]=='R'){
      if(s[2]=='R'){
        ans=3;
      }
      if(s[2]=='S'){
        ans=2;
      }
    }
    if(s[1]=='S'){
      ans=1;
    }
  }
  if(s[0]=='S'){
    if(s[1]=='R'){
      if(s[2]=='R'){
        ans=2;
      }
      if(s[2]=='S'){
        ans=1;
      }
    }
    if(s[1]=='S'){
      if(s[2]=='R'){
        ans=1;
      }
      if(s[2]=='S'){
        ans=0;
      }
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int i, j, n, m, s;
    scanf("%d%d", &n, &m);
    vi x(n+1, 1), r(n+1, 0);
    r[1]=1;
    while(m--) {
        scanf("%d%d", &i, &j);
        x[i]--;
        x[j]++;
        if(r[i]==1) r[j]=1;
        if(x[i]==0) r[i]=0;
    }
    for(s=0, i=1; i<=n; i++) s+=r[i];
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main() {
    int A, B;
    std::cin >> A >> B;
    int ans = 0;
    if (13 <= A) {
        ans = B;
    } else if (6 <= A) {
        ans = B / 2;
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
const int maxn = 1e5 + 10;
struct Query
{
	int v, d, c;
}a[maxn];
vector<int> E[maxn];
int n, m, q;
int c[maxn], col[maxn];
void calc(int d)
{
	for(int i = q; i; --i) 
		if(a[i].d == d)
			col[a[i].v] = max(col[a[i].v], i);
	if(d > 0)
	{
		for(int i = 1; i <= n; ++i) c[i] = col[i];
		for(int i = 1; i <= n; ++i)
			for(auto v : E[i])
				c[v] = max(c[v], col[i]);
		for(int i = 1; i <= n; ++i)
			col[i] = c[i];
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i) 
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	scanf("%d", &q);
	for(int i = 1; i <= q; ++i) scanf("%d%d%d", &a[i].v, &a[i].d, &a[i].c);
	for(int i = 10; ~i; --i) calc(i);
	for(int i = 1; i <= n; ++i)
		printf("%d\n", a[col[i]].c);
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += a;
  }

  cout << ans - N << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i=0;i<=m;i++)
     for(int j=0;j<=m;j++)
      for(int k=0;k<=m,i+j+k<=m;k++)
       {
            if(i+j+k==m && i*1000+j*5000+k*10000==n)
            {
                printf("%d %d %d",k,j,i);
                return 0;   
            }
       }
    printf("-1 -1 -1");
    return 0;
}

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

#define int		long long

using namespace std;

void solve()
{
	int n,k,sum=0;
	cin>>n>>k;
	int arr[n];
	for(int i =0;i<n;i++){
		cin>>arr[i];
		if(i<k)
			sum+=arr[i];
	}
	for(int i =k;i<n;i++){
		int temp=arr[i-k];
		if(sum-temp+arr[i] > sum)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	//int t;cin >> t;while(t--)
		solve();;
	
	return 0;
}

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

int N;
vector<vector<pair<int, int> > > tree;
vector<int> color;
vector<int> dist;

void dfs(int x) {
    if (dist.at(x) % 2 == 0) {
        color.at(x) = 0;
    } else {
        color.at(x) = 1;
    }
    for (auto &p : tree.at(x)) {
        if (dist.at(p.first) == -1) {
            dist.at(p.first) = (dist.at(x) + p.second) % 2;
            dfs(p.first);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    tree.resize(N);
    color.resize(N, -1);
    dist.resize(N, -1);
    dist.at(0) = 0;
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        tree.at(u - 1).push_back(make_pair(v - 1, w));
        tree.at(v - 1).push_back(make_pair(u - 1, w));
    }
    dfs(0);
    for (auto &x : color) {
        cout << x << endl;
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n-1) cin >> a[i];
  vector<int> b(n,0);
  rep(i,n-1){
    b[a[i]-1]++;
  }
  rep(i,n) cout << b[i] << endl;
  return 0;
}

Measured memory_bytes: 4788
#include <stdio.h>
#include <stdlib.h>

void	swap(char *i, char *j)
{
	char tmp;
	tmp = *i;
	*i = *j;
	*j = tmp;
}

int main()
{
	int N;
	scanf("%d", &N);
	char *c;
	c = malloc(N * sizeof(char));
	scanf("%s", c);
	int ans = 0;
	int i = 0;
	int j = N - 1;
	// 最初に出てきたWを探す
	for (; i < j; i++)
	{
		if (c[i] == 'W')
		{
			for (; i < j; j--)
			{
				if (c[j] == 'R')
				{
					swap(&c[i], &c[j]);
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n", ans);

	return (0);
}


Measured memory_bytes: 1924
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>
#include <atcoder/all>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N, Q;
    cin >> N >> Q;
    atcoder::fenwick_tree<ll> fw(N);
    Rep (i, N) {
        ll a;
        cin >> a;
        fw.add(i, a);
    }

    while (Q--) {
        ll t, x, y;
        cin >> t >> x >> y;
        if (t) {
            cout << fw.sum(x, y) << "\n";
        } else {
            fw.add(x, y);
        }
    }

}

Measured memory_bytes: 8256
#include <iostream>
#include <algorithm>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = ((n)-1); i >= 0; --i)

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<vector<int>> S(H, vector<int>(W));
	REP(i, H) {
		string s;
		cin >> s;
		REP(j, W) {
			S[i][j] = (s[j] == '#');
		}
	}

	vector<vector<int>> L(H, vector<int>(W, 0));
	vector<vector<int>> R(H, vector<int>(W, 0));
	vector<vector<int>> U(H, vector<int>(W, 0));
	vector<vector<int>> D(H, vector<int>(W, 0));
	REP(y, H) {
		REP(x, W) {
			if (S[y][x]) continue;
			U[y][x] = (y == 0) ? 1 : (U[y - 1][x] + 1);
			L[y][x] = (x == 0) ? 1 : (L[y][x - 1] + 1);
		}
	}
	REPR(x, W) {
		REPR(y, H) {
			if (S[y][x]) continue;
			D[y][x] = (y == H-1) ? 1 : (D[y + 1][x] + 1);
			R[y][x] = (x == W-1) ? 1 : (R[y][x + 1] + 1);
		}
	}

	int max_lighted = 0;
	REP(y, H) {
		REP(x, W) {
			const int num_lighted = L[y][x] + R[y][x] + U[y][x] + D[y][x] - 3;
			max_lighted = max(max_lighted, num_lighted);
		}
	}
	printf("%d\n", max_lighted);
	return 0;
}


Measured memory_bytes: 78720
import math
string=input().split()
while not ('?' in string):
    if string[1]=='+':
        print(int(string[0])+int(string[2]))
    elif string[1]=='-':
        print(int(string[0])-int(string[2]))
    elif string[1]=='*':
        print(int(string[0])*int(string[2]))
    else:
        print(int(string[0])//int(string[2]))
    string=input().split()



Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[6];
int main(){
  int i, res=0;
  rd(S);
  for(i=0;i<4;i++){
    if(S[i]=='+'){
      res ++;
    }
    else{
      res --;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// char S[6];
// {
//   int i, res = 0;
//   rd(S);
//   rep(i,4) res if[S[i]=='+',++,--];
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,m,l;
    int a[100][100],b[100][100];
    long long int c[100][100];
        for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
          a[i][j]=0;
           b[i][j]=0;
            c[i][j]=0;
      }
    }
    cin>>n>>m>>l;
    
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cin>>a[i][j];
      }
    }
    
    for(int i=0;i<m;i++){
      for(int j=0;j<l;j++){
          cin>>b[i][j];
      }
    }
    
     
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
          for(int k=0;k<m;k++){
          c[i][j]+=a[i][k]*b[k][j];
      }
     }
    }
    
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
          cout<<c[i][j];
          if(j!=l-1) cout<<" ";
      }
      cout<<endl;
    }
    return 0;
}

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

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

  int maxr = r[1] - r[0];
  int minr = min(r[1],r[0]);

  for(int i = 2;i < n;i++){
    maxr = max(maxr,r[i]-minr);
    minr = min(minr,r[i]);
  }

  cout << maxr << endl;
}



Measured memory_bytes: 3852
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int ans = 0;
    for (int i = 1; i < n; i++){
        int cnt = 0;
        
        for (char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;
            
            for (int j = 0; j < i; j++){
                if(s.at(j) == c) left = true;
            }
            for (int j = i; j < n; j++){
                if(s.at(j) == c) right = true;
            }
            if(left && right) cnt++;
        }
        if (ans < cnt) ans = cnt;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    string w; cin >> w;
    vint s('z'-'a'+1, 0);
    rep(i, w.length()) {
        s[w[i] - 'a']++;
    }
    each(n, s) {
        if(n % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
# coding: utf-8
N,K=map(int,input().split())
okashi=[1 for i in range(N)]

for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        okashi[A[j]-1]=0

print(sum(okashi))



Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int a;
    int ans = 0;
    int m = 9;
    int cnt = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> a;
        if (a % 10 == 0)
        {
            cnt++;
            ans += a;
        }
        else
        {
            m = min(m, a % 10);
            ans += (a + 10 - a % 10);
        }
    }

    if (cnt == 5)
        cout << ans;
    else
        cout << ans + m - 10;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	int32_t main(){
		string s;
		string t;
		cin>>s>>t;
		s=s+t;
		int x=stoi(s);;
		int y=sqrt(x);
		if(y*y==x) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}


Measured memory_bytes: 256
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    a = np.asarray([0] + a)
    for i in range(n // 2, 0, -1):
        a[i] = a[i::i].sum() % 2
    ans = np.where(a == 1)[0]
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(map(str, ans)))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 24172
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const ll MOD = 1000000000+7;

int main(){
    int n, m;
    cin >> n >> m;

    if(!m){
        if(n == 1){
            cout << 0 << endl;
        }else{
            if(n == 2){
                cout << 10 << endl;
            }else{
                cout << 100 << endl;
            }
        }
        return 0;
    }

    int s, c;
    vector<int> ans(n+1, -1);
    for(int i = 0; i < m; i++){
        cin >> s >> c;
        if(ans[s] == -1){
            ans[s] = c;
        }else{
            if(ans[s] != c){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(n == 1 && ans[1] == 0){
        cout << 0 << endl;
        return 0;
    }

    if(ans[1] == 0){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 1; i <= n; i++){
        if(ans[i] == -1){
            if(i == 1){
                cout << ans[i] + 2;
            }else{
                cout << ans[i] + 1;
            }
        }else{
            cout << ans[i];
        }
    }

    cout << endl;

    return 0;
}


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

vector<bool> num(10);

bool ok(int n) {
  while (n > 0) {
    if (num.at(n % 10)) return false;
    n /= 10;
  }
  return true;
}

int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i ++) {
    int tmp; cin >> tmp;
    num.at(tmp) = true;
  }

  int ans = n;
  while (!ok(ans)) {
    ans ++;
  }

  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;


const int N=1e5+100;

ll qpow(int x)
{
    ll sum=1;
    for(int i=1;i<=5;i++)
        sum*=x;
    return sum;
}
int main()
{
    int x;scanf("%d",&x);
    for(int i=1;i<=1000;i++){
        ll kk=qpow(i);
        kk-=x;
        for(int j=-1000;j<=1000;j++){
            ll zz=qpow(j);
             if(zz==kk){
                cout<<i<<" "<<j<<endl;
                return 0;
             }
        }

    }
    return 0;
}


Measured memory_bytes: 3688
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a,b) memset(a, b, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        char a,b; cin >> a >> b;
        if(a=='H' and b=='H')cout<<'H'<<endl;
        else if(a=='D' and b=='H')cout<<'D'<<endl;
        else if(a=='D' and b=='D')cout<<'H'<<endl;
        else cout<<'D'<<endl;



return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.length();
	for(int i=0;i<l-2;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2;
			return 0;
		}
		else if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3;
			return 0;
		}
	}
	if(s[l-2]==s[l-1]){
		cout<<l-1<<" "<<l;
		return 0; 
	}
	cout<<-1<<" "<<-1; 
	return 0;
}

Measured memory_bytes: 512
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let x = get!();
    
    let mut ys = vec![];
    for _ in 0..n {
    	ys.push(get!());
    }
    ys.push(x);
    ys.sort();
    let mut ans = ys[1] - ys[0];
    for i in 1..ys.len() {
    	let p = ys[i] - ys[i-1];
        if p < ans {
    		ans = gcd(p, ans);
		} else {
        	ans = gcd(ans, p);
        }
    }
  	println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
	if a == 0 { return b; }
    gcd(b % a, a)
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,x,y;
    ll ans=INF;
    cin>>a>>b>>c>>x>>y;
    rep(i,0,max(x,y)+1){
        ll tmp=i*c*2;
        tmp+=max(0ll,x-i)*a+max(0ll,y-i)*b;
        ans=min(ans,tmp);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main() {
    int H, W;

    cin >> H >> W;

    char s, S[H][W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> s;
            S[i][j] = s;
        }
    }

    int A[H][W], B[H][W], cnt = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            A[i][j] = 0;
            B[i][j] = 0;
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(S[i][j] == '.') cnt++;
            if(S[i][j] == '#') {
                for(int k = j - cnt; k < j; k++) {
                    A[i][k] = cnt;
                }
                cnt = 0;
            } else if(j == W - 1) {
                for(int k = j - cnt + 1; k < j + 1; k++) {
                    A[i][k] = cnt;
                }
                cnt = 0;
            }
        }
    }

    for(int j = 0; j < W; j++) {
        for(int i = 0; i < H; i++) {
            if(S[i][j] == '.') cnt++;
            if(S[i][j] == '#') {
                for(int k = i - cnt; k < i; k++) {
                    B[k][j] = cnt;
                }
                cnt = 0;
            } else if(i == H - 1) {
                for(int k = i - cnt + 1; k < i + 1; k++) {
                    B[k][j] = cnt;
                }
                cnt = 0;
            }
        }
    }

    int max = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(max < A[i][j] + B[i][j] - 1) max = A[i][j] + B[i][j] - 1;
        }
    }

    cout << max << endl;


    return 0;
}

Measured memory_bytes: 35456