akhauriyash/Code-Regression huggingface dataset:
N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())))[::-1]
W = sum(V[:A])/A
print(W)

f = [1]
for n in range(50):
  f+=[f[-1]*(n+1)]
x = V.count(V[A-1])
if V[0]==V[A-1]:
  print(sum(f[x]//(f[x-n]*f[n]) for n in range(A,B+1)))
else:
  y=V[:A].count(V[A-1])
  print(f[x]//(f[x-y]*f[y]))

Measured memory_bytes: 9136
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 数字の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] a = IntStream.range(0, N).map(i -> scanner.nextInt()).sorted().toArray();
			int k = scanner.nextInt();
			a[N - 1] = a[N - 1] << k;
			System.out.println(Arrays.stream(a).sum());
		}
	}
}


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

int next_combination(int sub) {//組み合わせ全列挙に使うやつ
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  for(ll i = 0; i < N; i++) cin>>v[i];
  ll bit = (1<<K) -1;
  ll ans = INF;
  for(;bit<(1<<N);bit=next_combination(bit)){
    ll h = 0;
    ll cnt = 0;
    for(ll i = 0; i < N; i++){
      if(bit&(1<<i)) {
        if(h>=v[i]) {
          cnt+=h-v[i]+1;
          h++;
        }
        else chmax(h,v[i]);
      }
      else chmax(h,v[i]);
    }
    chmin(ans,cnt);
  }
  cout<<ans<<endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#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 REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N, M;
  cin >> N >> M;

  int dist[105][105] = {};

  rep(i, N)rep(j, N) dist[i][j] = inf / 2;
  rep(i, N) dist[i][i] = 0;

  int A[1005], B[1005], C[1005];
  rep(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
    A[i] = a; B[i] = b, C[i] = c;
  }

  rep(k, N){
    rep(i, N){
      rep(j, N){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = M;

  rep(i, M){
    bool flag = false;
    rep(j, N) if(dist[j][A[i]] + C[i] == dist[j][B[i]]) flag = true;
    if(flag) ans--;
  }

  cout << ans << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  vector<int> x(5);
  int i;
  rep(i,5) cin >> x[i];
  rep(i,5)
  {
    if(x[i] == 0)cout << i+1 << endl;
  }
}

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

int main() {
  int n,m,x;
  cin>>n>>m;
  vector<int> scores(n);
  for(int i=0; i<m*2; i++){
    cin>>x;
    scores.at(x-1)++;
  }
  for(int i=0; i<n; i++){
    cout<<scores.at(i)<<endl;
  }
}

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

int main() {
  int X,Y;
  cin >> X >> Y;
  int ans = 0;
  if (X >= Y) {
    ans = X*2-1;
  }
  else {
    ans = Y*2-1;
  }
  if (X==Y) {
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N  = scanner.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        for(int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }
        for(int i = 0; i < N-1; i++) {
            C[i] = scanner.nextInt();
        }
        int ans = 0;
        int prev = -2;
        for(int i = 0; i < N; i++) {
            int cur = A[i] - 1;
            ans += B[cur];
            if(prev + 1 ==  cur){
                ans += C[prev];
            }
            prev = cur;
        }


        System.out.println(ans);
    }
}

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

int N, M;
typedef pair<int,int> pint;

vector<pint> A;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main() {
  cin >> N >> M;
  A.resize(M);
  for ( int i = 0; i < M; i++ ) {
    cin >> A[i].first >> A[i].second;
  }
  
  //並び替えの判断基準を変更
  //右端の数が小さい順番に並び替え
  sort(A.begin(), A.end(), cmp);
  int res = 0;
  int endtime = 0;
  for ( int i = 0; i < M; i++ ) {
    if ( A[i].first >= endtime ) {
      endtime = A[i].second;
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

long long int min(long long int a, long long int b) {
    if (a < b)
        return a;
    else
        return b;
}

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

    long long int min_num = min(A, B);
    int count = 1;
    bool in_if_check = false;
    for (long int i = 2; i <= sqrt(min_num); i++) {
        bool flag = false;
        if (A % i == 0) {
            flag = true;
            while (A % i == 0)
                A = A / i;
        }

        if (B % i == 0) {
            if (flag)
                count++;
            while (B % i == 0)
                B = B / i;
        }
    }
    if ((A != 1 && B != 1) && (A % B == 0 || B % A == 0))
        count++;

    cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a[0]=a[0]-1

for i in range(n-1):
    if a[i]<=a[i+1]-1:
        a[i+1]=a[i+1]-1
    elif a[i]==a[i+1]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

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

typedef long long ll;

int main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    vector<char> ans(N);
    rep(i, N) {
        if (s[i] == "AB") {
            if (A == 0 && B == 0) {
                cout << "No\n";
                return 0;
            }
            if (A < B) {
                ans[i] = 'A';
                A++;
                B--;
            } else if (A > B) {
                ans[i] = 'B';
                B++;
                A--;
            } else if (i == N - 1) {
                ans[i] = 'A';
                A++;
                B--;
            } else if (s[i + 1] == "AC") {
                ans[i] = 'A';
                A++;
                B--;
            } else if (s[i + 1] == "BC") {
                ans[i] = 'B';
                B++;
                A--;
            } else {
                ans[i] = 'A';
                A++;
                B--;
            }
        } else if (s[i] == "AC") {
            if (A == 0 && C == 0) {
                cout << "No\n";
                return 0;
            }
            if (A < C) {
                ans[i] = 'A';
                A++;
                C--;
            } else if (A > C) {
                ans[i] = 'C';
                C++;
                A--;
            } else if (i == N - 1) {
                ans[i] = 'A';
                A++;
                C--;
            } else if (s[i + 1] == "AB") {
                ans[i] = 'A';
                A++;
                C--;
            } else if (s[i + 1] == "BC") {
                ans[i] = 'C';
                C++;
                A--;
            } else {
                ans[i] = 'A';
                A++;
                C--;
            }
        } else {
            if (B == 0 && C == 0) {
                cout << "No\n";
                return 0;
            }
            if (B < C) {
                ans[i] = 'B';
                B++;
                C--;
            } else if (B > C) {
                ans[i] = 'C';
                C++;
                B--;
            } else if (i == N - 1) {
                ans[i] = 'B';
                B++;
                C--;
            } else if (s[i + 1] == "AC") {
                ans[i] = 'C';
                C++;
                B--;
            } else if (s[i + 1] == "AB") {
                ans[i] = 'B';
                B++;
                C--;
            } else {
                ans[i] = 'B';
                B++;
                C--;
            }
        }
    }
    cout << "Yes\n";
    rep(i, N) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 6392
#include <stdio.h>
int main(void){
    // Your code here!
    int N,K;
    int h[100001];
    scanf("%d %d\n",&N,&K);
    int i,ct;
    ct=0;
    for(i=1;N>=i;i++){
        scanf("%d",&h[i]);
        if(h[i]>=K) ct++;
    }
    
    printf("%d\n",ct);
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
Q = li2(M)
Q = sorted(Q, key=lambda x:x[1])

l = [N]*N
for i in range(M):
    ind = max(0, Q[i][0]-1)
    l[ind] = min(Q[i][1]-1, l[ind])

for i in reversed(range(N-1)):
    l[i] = min(l[i], l[i+1])

cnt = 0
i = 0
#print(l)
while True:
    i = l[i]
    cnt += 1
    if l[i] == N:
        break

print(cnt)

Measured memory_bytes: 31024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES": "NO");

		static void Main(string[] args)
		{
			var a = RIs;
			if (a[0] <= a[1]) Out(a[0]);
			else Out(a[0] - 1);
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using lint = long long;
using ldouble = long double;

void solve() {
    int n;
    std::cin >> n;

    std::set<int> s;
    while (n--) {
        int a;
        std::cin >> a;
        if (s.count(a)) {
            std::cout << "NO" << std::endl;
            return;
        }
        s.insert(a);
    }

    std::cout << "YES" << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    rep(i, n) cin >> x.at(i) >> y.at(i) >> a.at(i);
    vector<vector<bool>> white(h, vector<bool> (w, true));
    rep(i, n) {
        if (a.at(i) == 1) {
            rep(k, x.at(i)) {
                rep(j, h) {
                    white.at(j).at(k) = false;
                }
            }
        }
        else if (a.at(i) == 3) {
            rep(k, y.at(i)) {
                rep(j, w) {
                    white.at(k).at(j) = false;
                }
            }
        }
        else if (a.at(i) == 2) {
            for (int k = x.at(i); k < w; k++) {
                rep(j, h) {
                    white.at(j).at(k) = false;
                }
            }
        }
        else if (a.at(i) == 4) {
            for (int k = y.at(i); k < h; k++) {
                rep(j, w) {
                    white.at(k).at(j) = false;
                }
            }
        }
    }
    int count = 0;
    rep(i, h) {
        rep(j, w) {
            if (white.at(i).at(j)) {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int N;
    cin >> N;
    int count = 0;
    for(int i = 0; i < N; i++){
        int x,y;
        cin >> x >> y;
        count += y - x + 1;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,ans=0;
  cin>>H>>W;
  vector<string> v(H);
  for(int i=0;i<H;i++) cin>>v.at(i);
  for(int i=0;i<W+2;i++) cout<<'#';
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<'#'<<v.at(i)<<'#'<<endl;
  }
  for(int i=0;i<W+2;i++) cout<<'#';
  cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<ll,ll>;
#define w first
#define v second

vector<P> all_enumerate(vector<P> vp, ll W, bool need_sort){
    int N = vp.size();
    vector<P> dp;
    for (int mask = 0; mask < (1<<N); mask++) {
        ll sumV = 0, sumW = 0;
        for (int i = 0; i < N; i++) {
            if (mask & (1<<i)) {
                sumV += vp[i].v;
                sumW += vp[i].w;
            }
        }
        if (sumW <= W) {
            dp.push_back({sumW, sumV});
        }
    }
    if (!need_sort) return dp;
    // V降順
    sort(dp.begin(), dp.end(), [](P a, P b){
        return a.v != b.v ? a.v > b.v : a.w < b.w;
    });
    vector<P> res;
    int w_border = W+1;
    for(P s : dp){
        if( w_border > s.w){
            w_border = s.w;
            res.push_back(s);
        }
    }
    // V昇順 & W昇順
    reverse(res.begin(), res.end());
    return res;
}

int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n+1),w(n+1);
    rep1(i,n){
        cin >> v[i] >> w[i];
    }
    int H2 = log2(n)/2 + 2;
    vector<vector<P>> dp((1<<H2)+1);
    for (int i = 1; i < (1<<H2); i++) {
        if (i > n) break;
        vector<P> vp;
        int x = i;
        while(x) {
            vp.push_back({w[x], v[x]});
            x /= 2;
        }
        dp[i] = all_enumerate(vp, 100000LL, true);
    }
    int Q;
    cin >> Q;
    rep(q,Q){
        int x, L;
        cin >> x >> L;
        vector<P> vp;
        while((1<<H2) <= x) {
            vp.push_back({w[x], v[x]});
            x /= 2;
        }
        vector<P> dp1 = dp[x];
        vector<P> dp2 = all_enumerate(vp, L, false);
        ll max_v = 0;
        for (P p : dp2) {
            int pos = lb(dp1, P({L - p.w + 1, 0LL})) - 1;
            if (pos < 0) {
                if (p.w <= L) {
                    max_v = max(max_v, p.v);
                }
            } else {
                if (p.w + dp1[pos].w <= L) {
                    max_v = max(max_v, p.v + dp1[pos].v);
                }
            }
        }
        cout << max_v << endl;
    }
    return 0;
}




Measured memory_bytes: 16512
#include <iostream>
using namespace std;
const int MAX = 100001;

int par[MAX],rank[MAX],n,m;

void init(){
  for(int i = 0 ; i < MAX ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x) return x;
   return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x); y = find(y);
  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

int main(){
  int a,b,c;
  init();
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> a >> b >> c;
    if(a){
      same(b,c);
      if(par[b] == par[c]) cout << '1' << endl;
      else cout << '0' << endl;
    }
    else unite(b,c);
  }

  return 0;
}

Measured memory_bytes: 1936
s = int(input())
mae   = s // 100
usiro = s % 100
Mflag = True
Uflag = True

if mae < 1 or mae > 12:
    Mflag = False

if usiro < 1 or usiro > 12:
    Uflag = False

if Mflag:
    if Uflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if Uflag:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long D = sc.nextLong();
        long A = sc.nextLong();
        long[][] XH = new long[N][3];
        
        long cnt=0;
        for(int i=0;i<N;i++) {
        	XH[i][0]=sc.nextLong();
        	XH[i][1]=sc.nextLong();
        }
        
        Arrays.sort(XH, (b, c) -> Long.compare(b[0], c[0]));
        
        long damege=0;
        long s[]=new long[N];
		LinkedList<Long> queue = new LinkedList<Long>();
		long sum=0;
		long nextX=0;
		long d=0;
    	for(int i=0;i<N;i++) {
			while(!queue.isEmpty()&&XH[i][0]>2*D+queue.element()) {
				nextX=queue.poll();
				d=queue.poll();
    			sum=sum-d;
			}
			XH[i][1]=XH[i][1]-sum;
    		if(XH[i][1]>0) {
				if(XH[i][1]%A==0) {
					damege=XH[i][1];
				}else {
					damege=(XH[i][1]/A)*A+A;
				}
    			sum=sum+damege;
    			queue.add(XH[i][0]);
    			queue.add(damege);
				cnt=cnt+damege/A;
    		}
    	}
        
        System.out.println(cnt);        	
                		
    }
    
    
}

Measured memory_bytes: 139860
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
int main() {
	// your code goes here
	lli n,q,i,s=0,b,c;
	cin>>n;
	lli a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s^a[i];
	}
	for(i=0;i<n;i++)
	cout<<(s^a[i])<<" ";
	
	
	return 0;
}

Measured memory_bytes: 5180
#include<stdio.h>
int main(){
    int n;
    int a[3];
    int mem;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        mem=0;
        for(int j=0;j<3;j++){
            scanf("%d",&a[j]);
            if(mem<=a[j]){
                mem=a[j];
            }
        }
        if(mem*mem==a[0]*a[0]+a[1]*a[1]+a[2]*a[2]-mem*mem){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1008
// import kotlin.comparisons.*
// import kotlin.math.*
import java.util.*

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val n = readI()
  val x = readIs()
  var ans = Int.MAX_VALUE
  for (p in 1..100) {
    ans = Math.min(ans, x.map { (it - p) * (it - p) }.sum())
  }
  println(ans)
}


Measured memory_bytes: 38240
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
vector<int> arrNums;
bool IsAllEven(){
	register long long i;
	for (i = 0; i < arrNums.size(); ++i){
		if (arrNums[i] % 2 != 0)
			return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	int nCount,iTemp,iAns=0;
	register int i;
	cin >> nCount;
	for (i = 1; i <= nCount; ++i){
		cin >> iTemp;
		arrNums.push_back(iTemp);
	}
	while (IsAllEven()){
		++iAns;
		for (i = 0; i < arrNums.size(); ++i){
			arrNums[i] /= 2;
		}
	}
	cout << iAns << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int max = sc.nextInt();

		int min = max;

		for(int i=0;i<N-1;i++) {

			int a = sc.nextInt();

			if(a>max) {

				max = a;
			}
			if(a<min) {

				min = a;
			}
		}

		System.out.println((max-min));
	}

}



Measured memory_bytes: 23252
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S;
	scan(N>>S);
	int ans=0;
	rep(i,N-2){
		if(S.substr(i,3)=="ABC"){
			ans++;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var abq = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var A = abq[0];
        var B = abq[1];
        var C = abq[2];
        var shrineArray = new long[A];
        var templeArray = new long[B];
        for (int i=0;i<A+B+C;++i)
        {
            if (i < A + B)
            {
                if (i < A) shrineArray[i] = Int64.Parse(Console.ReadLine());
                else templeArray[i-A] = Int64.Parse(Console.ReadLine());
            }
            else
            {
                var startPlace = Int64.Parse(Console.ReadLine());
                var shrineFirstIndex = GetFirstIndex(shrineArray,startPlace);
                var templeFirstIndex = GetFirstIndex(templeArray, startPlace);
                var ans = long.MaxValue;
                for (int j=0;j<2;++j)
                {
                    if (shrineArray.Length <= 1 && j == 1) continue;

                    for (int k=0;k<2;++k)
                    {
                        if (templeArray.Length <= 1 && k == 1) continue;

                        //距離
                        var distance = Math.Abs(shrineArray[j + shrineFirstIndex] - templeArray[k + templeFirstIndex]);
                        //どちらから行く方が早いか
                        var fast = Math.Min(Math.Abs(startPlace- shrineArray[j + shrineFirstIndex]), Math.Abs(startPlace - templeArray[k + templeFirstIndex]));
                        distance += fast;
                        if (distance < ans) ans = distance;
                    }
                }
                Console.WriteLine(ans);
            }
        }
    }

    //二分探索
    static long GetFirstIndex(long[] array,long startPlace)
    {
        if (array.Length <= 1) return 0;

        var top = array.Length-1;
        var bottom = 0;

        //bottom startPlace topになったらおしまい
        while (bottom+1 != top)
        {
            //中央
            var middle = (top + bottom) / 2;

            //中央より大きい
            if (array[middle] < startPlace) bottom = middle;
            //中央より小さい
            else if (startPlace < array[middle]) top = middle;
        }

        return bottom;
    }
}


Measured memory_bytes: 19408
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HW = Sarray();
            var H = HW[0];
            var W = HW[1];
            var ban = new string[H + 2];
            var tuuka = new char[H + 2][];
            ban[0] = new string('.', (int)W + 2);
            tuuka[0] = ban[0].ToCharArray();
            for (var i = 1; i < H + 1; ++i)
            {
                ban[i] = "." + ReadLine() + ".";
                tuuka[i] = ban[0].ToCharArray();
            }
            ban[H + 1] = new string('.', (int)W + 2);
            tuuka[H + 1] = ban[H + 1].ToCharArray();
            var posx = 1;
            var posy = 1;
            tuuka[1][1] = '#';
            tuuka[H][W] = '#';
            while (true)
            {
                //GOAL
                if (W == posx && H == posy)
                    break;
                //右にも下にも行った　または　右にも下にもいっていない
                if (ban[posy + 1][posx] == ban[posy][posx + 1])
                {
                    WriteLine("Impossible");
                    return;
                }
                //どっちかに行った
                if (ban[posy + 1][posx] == '#')
                    ++posy;
                else
                    ++posx;
                tuuka[posy][posx] = '#';
            }
            for (var i = 1; i < H + 1; ++i)
            {
                if (ban[i] != new string(tuuka[i]))
                {
                    WriteLine("Impossible");
                    return;
                }
            }
            WriteLine("Possible");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli n, k;
    cin >> n >> k;
    lli a[n], d[n];
    
    for (lli i = 0; i < n;i++)
    {
        cin >> a[i];
        d[i] = 1;
    }

    // for (lli i = 0; i <= k-1;i++)
    //     d[k - 1] *= a[i];

    // for (lli i = k; i < n;i++)
    //     d[i] = (d[i - 1] * a[i]) / a[i - k];

    // cout << d[k];

    for (lli i = k; i < n;i++)
    {
        if(a[i]>a[i-k])
            cout << "Yes";
        else
            cout << "No";

        cout << '\n';
    }

        cout << endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 6744
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] numbers = new int[3];
    for (int i = 0; i < numbers.length; i++) {
      numbers[i] = sc.nextInt();
    }
    Arrays.sort(numbers);
    System.out.println(numbers[2] * 10 + numbers[1] + numbers[0]);
  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


const int INF = 1001001001;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = INF;

    rep(i, n) {
        stack<vector<int> > s;

        vector<int> tmp(0);
        rep(j, n) {
            if (a[j] < a[i]) {
                if (tmp.size() >= k) s.push(tmp);
                tmp.clear();
            } else {
                tmp.push_back(a[j]);
            }
        }
        if (tmp.size() >= k) s.push(tmp);

        vector<int> xy;
        while (!s.empty()) {
            vector<int> box = s.top(); s.pop();
            sort(box.begin(), box.end());
            rep(j, box.size()-k+1) {
                xy.push_back(box[j]);
            }
        }

        if (xy.size() < q) continue;
        sort(xy.begin(), xy.end());
        ans = min(ans, xy[q-1] - a[i]);
    }
    
    cout << ans << 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)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007

int main()
{
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size())
  {
    cout << "GREATER" << endl;
    return 0;
  }
  else if (a.size() < b.size())
  {
    cout << "LESS" << endl;
    return  0;
  }
  if (a > b)
  {
    cout << "GREATER" << endl;
  }
  else if (a < b)
  {
    cout << "LESS" << endl;
  }
  else
  {
    cout << "EQUAL" << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
n,m = map(int,input().split())
li = list(map(int,input().split()))
li2 = []

li.sort()

for i in range(m-1):
    li2.append(li[i+1]-li[i])

li2.sort()
sum = 0
for i in range(m-n):
    sum += li2[i]

print(sum)


Measured memory_bytes: 13960
#include<stdio.h>

int candy(int n){
    int i;
    int tmp = 0;

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

    return tmp;
}

int main(void){
    int N;

    scanf("%d", &N);

    printf("%d\n", candy(N));

    return 0;
}

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

n,m = map(int, input().split())
t = sorted([tuple(map(int, input().split())) for i in range(m)])
INF = 10 ** 18
dp = [0,0] + [INF] * (n-1)
for l,r,c in t:
  for i in range(r,l,-1):
    if dp[l] + c < dp[i]:
      dp[i] = dp[l] + c
    else:
      break
ans = dp[n]
if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 60508
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
vvl G;
vl dp(MAX_N);
 
void dfs(ll v) {
    vl a;
    dp[v] = G[v].size();
    for(auto u : G[v]) {
        dfs(u);
        a.pb(dp[u]);
    }
    sort(rall(a));
    rep(i, a.size()) {
        chmax(dp[v], a[i] + i + 1);
    }
}
 
int main() {
    ll n;
    cin >> n;
 
    G.resize(n);
    exrep(i, 1, n-1) {
        ll v;
        cin >> v;
        v--;
        G[v].pb(i);
    }

    dfs(0);
    
    out(dp[0]);
    re0;
}

Measured memory_bytes: 17408
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

#define SIZE 400000
#define SIZE0 200000
#define INF 1000000000

typedef long long ll;

struct Segtree {
  int segn2;
  vector<int> data;

  Segtree(int n) {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 1000000000);
  }

  int query(int a, int b, int l = 0, int r = -1, int k = 0) {
    if (r == -1) r = segn2;
    if (a <= l && r <= b) return data[k];
    if (r <= a || b <= l) return INF;
    return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2));
  }

  void set(int k, int x) {
    k += segn2-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = min(data[k*2+1], data[k*2+2]);
    }
  }
};


int N;
ll L;
int M;
pair<ll,ll> p[SIZE0];

int memo[SIZE];
int solve1() {
  Segtree seg(M+1);

  seg.set(0, 0);

  for(int i=0; i<M; i++) {
    memo[i] = INF;
  }
  memo[0] = 0;

  for(int i=0; i<N; i++) {
    int l = p[i].first;
    int r = p[i].second;

    int v = seg.query(l, r);
    memo[r] = min(memo[r], v+1);
    seg.set(r, memo[r]);

  }

  return seg.query(M-1, M);
}

int sum[SIZE];
int solve2() {

  for(int i=0; i<N; i++) {
    sum[p[i].first]++;
    sum[p[i].second]--;
  }

  int ans = 1e9;

  for(int i=0; i<M-1; i++) {
    sum[i+1] += sum[i];
    ans = min(ans, sum[i]);
  }

  return N - ans + 1;
}

int main(){
  vector<ll> vec;
  map<ll, int> dic;

  scanf("%d%lld", &N, &L);

  for(int i=0; i<N; i++) {
    ll l, r;
    scanf("%lld%lld", &l, &r);

    p[i] = {l, r};
    vec.push_back(l);
    vec.push_back(r);
  }

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  M = vec.size();

  for(int i=0; i<vec.size(); i++) {
    dic[vec[i]] = i;
  }

  sort(p, p+N);

  for(int i=0; i<N; i++) {
    p[i].first = dic[p[i].first];
    p[i].second = dic[p[i].second];
  }


  int ans1 = solve1();
  int ans2 = solve2();

  printf("%d %d\n", ans1, ans2);

  return 0;
}



Measured memory_bytes: 38660
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n, m, s, t;
V< V< P< int, P<ll, ll> > > > edges;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> s >> t;
    s--, t--;
    edges.resize(n);

    for (int i = 0; i < m; i++) {
        int v, u;
        ll a, b;
        cin >> v >> u >> a >> b;
        v--, u--;
        edges[v].emplace_back(make_pair(u, make_pair(a, b)));
        edges[u].emplace_back(make_pair(v, make_pair(a, b)));
    }

    vll yen(n, HIGHINF), snuuk(n, HIGHINF);
    priority_queue< P<ll, int> > pq; pq.push(make_pair(0, s));
    yen[s] = 0;
    while (!pq.empty()) {
        P<ll, int> q = pq.top(); pq.pop();
        for (P< int, P<ll, ll> > e: edges[q.second]) {
            if (yen[e.first] > yen[q.second] + e.second.first) {
                yen[e.first] = yen[q.second] + e.second.first;
                pq.push(make_pair(-yen[e.first], e.first));
            }
        }
    }

    pq.push(make_pair(0, t));
    snuuk[t] = 0;
    while (!pq.empty()) {
        P<ll, int> q = pq.top(); pq.pop();
        for (P< int, P<ll, ll> > e: edges[q.second]) {
            if (snuuk[e.first] > snuuk[q.second] + e.second.second) {
                snuuk[e.first] = snuuk[q.second] + e.second.second;
                pq.push(make_pair(-snuuk[e.first], e.first));
            }
        }
    }

    ll tmp = HIGHINF;
    vll ans(n, HIGHINF);
    for (int i = n - 1; i >= 0; i--) {
        chmin(tmp, yen[i] + snuuk[i]);
        ans[i] = (ll)1e15 - tmp;
    }

    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


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

typedef long long ll;

int main() {
	ll n, c, k; cin >> n >> c >> k;
	vector<ll>t(n); for (auto&& x : t)cin >> x;
	sort(t.begin(), t.end());

	ll cnt = 1, time = t[0] + k, ans = 1;
	for (int i = 1; i < n; i++) {
		if (t[i] <= time && cnt < c)cnt++;
		else time = t[i] + k, cnt = 1, ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4056
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let x = read::<i64>();
    let mut bs = vec![0; n];
    let mut ls = vec![0; n];
    let mut us = vec![0; n];
    for i in 0..n {
        bs[i] = read::<i64>();
        ls[i] = read::<i64>();
        us[i] = read::<i64>();
    }
    let mut total = 0;
    let mut values = vec![(0, 0); n];
    for i in 0..n {
        total -= ls[i] * bs[i];
        values[i].0 = ls[i] * bs[i] + us[i] * (x - bs[i]);
        values[i].1 = i;
    }
    values.sort();
    values.reverse();
    let mut sum = 0;
    let mut last_index = n - 1;
    let mut used = vec![false; n];
    for i in 0..n {
        if total + values[i].0 >= 0 {
            last_index = i;
            break;
        }
        total += values[i].0;
        used[values[i].1] = true;
        sum += x;
    }
    let mut ans = sum + x;
    for i in 0..n {
        let mut lsum = sum;
        let mut rest = -total;
        if used[i] {
            rest += ls[i] * bs[i] + us[i] * (x - bs[i]);
            rest -= values[last_index].0;
        }
        if rest <= ls[i] * bs[i] {
            lsum += (rest + ls[i] - 1) / ls[i];
        } else {
            lsum += bs[i];
            rest -= ls[i] * bs[i];
            lsum += (rest + us[i] - 1) / us[i];
        }
        ans = std::cmp::min(ans, lsum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct node 
{ 
    int to, weight; 
}; 
vector<node> edges[1000005]; 
void zeroOneBFS(int src, int V, int dest) 
{ 
    int dist[V]; 
    for (int i=0; i<V; i++) 
        dist[i] = 1e15; 

    deque <int> Q; 
    dist[src] = 0; 
    Q.push_back(src); 
  
    while (!Q.empty()) 
    { 
        int v = Q.front(); 
        Q.pop_front(); 
  
        for (int i=0; i<edges[v].size(); i++) 
        { 
            if (dist[edges[v][i].to] > dist[v] + edges[v][i].weight) 
            { 
                dist[edges[v][i].to] = dist[v] + edges[v][i].weight; 
  
                if (edges[v][i].weight == 0) 
                    Q.push_front(edges[v][i].to); 
                else
                    Q.push_back(edges[v][i].to); 
            } 
        } 
    } 
    if(dist[dest] == 1e15)
        cout << -1;
    else
        cout << dist[dest];
} 

void addEdge(int u, int v, int wt) 
{ 
   edges[u].push_back({v, wt}); 
} 
int check(int w, int h, int i, int j, string str[])
{
    if(i >= 0 && i < h && j >= 0 && j < w && str[i][j] == '.')
        return 1;
    return 0;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    int sx, sy, dx, dy;
    cin >> sx >> sy >> dx >> dy;
    sx--, sy--, dx--, dy--;
    string str[h];
    int i, j;
    for(i=0;i<h;i++)
        cin >> str[i];
    // w*i+j
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(str[i][j] == '#')
                continue;
            //cout << i << " " << j << '\n';
            for(int l=-2;l<=2;l++)
                for(int m = -2;m<=2;m++)
                {
                    if(l == 0 && m == 0)
                        continue;
                    if(check(w, h, i+l, j+m, str))  
                    {   
                        if(abs(l) == 2 || abs(m) == 2 || (abs(l) == 1 && abs(m) == 1))
                            addEdge(w*i+j, w*(i+l)+j+m, 1);
                        else
                            addEdge(w*i+j, w*(i+l)+ j+m, 0);
                    }
                }
        }
    }
    int src = w*sx + sy;
    int dest = w*dx + dy;
    zeroOneBFS(src, w*h, dest); 
}

Measured memory_bytes: 167652
# 初期入力
S = input()
S_list = [i for i in S] # Sをリストに変換
S_rev =S_list[::-1]

# listと rev比較して違う部分の数
count =0
for i in range(len(S)):
    if S_list[i] != S_rev[i]:
        count += 1
        
print(count//2)

Measured memory_bytes: 2940
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        H: i32,
        W: i32,
        N: i32,
    }

    let bigger = if H >= W { H } else { W };
    let ans = ((N as f32) / (bigger as f32)).ceil();

    println!("{}", ans);
}


Measured memory_bytes: 2656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;
const int maxn=1005;
char str[maxn];
int cnt[255];
bool vis[255];
int main(){
	int n,ans=-99999;
	cin>>n;
	scanf("%s",str+1);
	for(register int k=1;k<n;k++){
		memset(cnt,0,sizeof(cnt));
		memset(vis,0,sizeof(vis));
		int tmp=0;
		for(register int i=1;i<=k;i++)cnt[str[i]-'a']++;
		for(register int i=k+1;i<=n;i++){
			if(cnt[str[i]-'a']&&!vis[str[i]-'a'])tmp++,vis[str[i]-'a']=1;
		}
		ans=max(ans,tmp);
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S==U){
    cout << A-1 << ' ' << B << endl;
  }
  if(T==U){
    cout << A << ' ' << B-1 << endl;
  }
}


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> ans(Q);
  vector<int> points(N);
  for(int i = 0; i < Q; i++){
    cin >> ans.at(i);
  }
  
  for(int i = 0; i < Q; i++){
    int x = ans.at(i);
    points.at(x - 1) += 1;
  }
  for(int i = 0; i < N; i++){
    if(K - Q + points.at(i) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

typedef double ll;

int main() {
	int n,i,j;
	cin>>n;
	ll a[n+2];
	for(i=1;i<=n;i++)
	cin>>a[i];
	vector<vector<ll>>dp(n+1,vector<ll>(n+2,0.000000));
	dp[0][0]=1.000000;
	//dp[0][1]=a[1];
	for(i=1;i<=n;i++)
	dp[0][i]=dp[0][i-1]*(1.000000-a[i]);
	for(i=1;i<=n;i++)
	{
	    for(j=1;j<=n;j++)
	    {
	        if(j<i)
	        dp[i][j]=0.000000;
	        else{
	        dp[i][j]=dp[i][j-1]*(1.000000-a[j]);
	        dp[i][j]+=dp[i-1][j-1]*a[j];
	    }}
	}
	ll ans=0.000000;
	for(i=(n+1)/2;i<=n;i++)
	ans+=dp[i][n];
	cout<<setprecision(10)<<ans;
	return 0;
}

Measured memory_bytes: 73760
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<queue>
#define INF 99999999
using namespace std;
typedef pair<int, int> P;
vector<P> point[7];
int x,y;
int dp[6][1001][6];
char mas[1001][1001];
int cx[6],ans;
int sp,ans1;
int solve(int i , int j, int z);
int main(){
  while(1){
    for(int i = 0; i < 7; i++){
      point[i].clear();
    }
    memset(cx, 0, sizeof(cx));
    ans1 = INF;
    sp = INF;
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    for(int i = 0; i < y; i++) cin >> mas[i];
    for(int i = 0; i < y; i++){ 
      for(int j = 0; j < x; j++){
    if(mas[i][j] == 'S'){
      point[0].push_back(P(j,i));
    }
    if(mas[i][j] == 'G'){
      point[6].push_back(P(j,i));
    }
    if(mas[i][j] >= '1' && mas[i][j] <= '5'){
      point[mas[i][j] - '0'].push_back(P(j,i));
      cx[mas[i][j] - '0']++;
    }
      }
    }
    for(int i = 1; i <= 5; i++){
      rotate(point + 1, point + 2, point + 6);
      rotate(cx + 1, cx + 2, cx + 6);
      memset(dp, -1, sizeof(dp));
      ans = solve(0, 0, 0);
      if(ans < ans1){
    ans1 = ans;
    sp = i;
      }
    }
    if(ans1 == INF) cout << "NA" << endl;
    else cout << sp << " " << ans1 << endl;
  }
}
int solve(int i, int j,int z){
  if(dp[i][j][z] >= 0) return dp[i][j][z];
  if(i == 4){
    return abs(point[6][0].first - point[z][j].first) + abs(point[6][0].second - point[z][j].second);
  }
  int res = INF;
  for(int k = 0; k < cx[z + 1]; k++){
    res = min(abs(point[z + 1][k].first - point[z][j].first) + abs(point[z + 1][k].second - point[z][j].second) + solve(i + 1, k, z + 1),res);
  }
  return dp[i][j][z] = res;
}

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

int main() {
	string s;
	getline(cin, s);
	for (auto c : s) {
		if (islower(c))
			cout << (char)toupper(c);
		else if (isupper(c))
			cout << (char)tolower(c);
		else
			cout << c;
	}
	cout << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
using namespace std;

int main(void) {
	int N, A, B;
	cin >> N >> A >> B;

	int max_ans = min(A, B);
	int com = A + B - N;
	int min_ans = max(0, com);

	cout << max_ans << ' ' << min_ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;
ll cnt[3];

int main()
{
  std::cin >> S;

  rep( i, 3 )
    ++cnt[S[i]-'a'];

  puts( cnt[0]==cnt[1]&&cnt[1]==cnt[2]&&cnt[0]==1 ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  ll N;cin>>N;
  vector<ll> A(N+2,0);rep(i,N)cin>>A[i+1];
  ll ans=0;
  rep(i,N+1){
    ans += abs(A[i+1]-A[i]);
  }
  rep(i,N){
    cout << ans - (abs(A[i+1]-A[i])+abs(A[i+2]-A[i+1])-abs(A[i+2]-A[i])) << endl;
  }
}

Measured memory_bytes: 2048