akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    int a, b, k;
    cin >>a >> b >> k;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) k--;
        if (k == 0) {
            cout << i << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < c && b < c){
        cout << "C" << endl;
    }else if(a < b){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
l=len
s=sorted
a=1e9
for Y in A:
	C=s(sum((v[:l(v)-K+1]for v in(s(v)for k,v in groupby(A,lambda a:a>=Y)if k)if l(v)>=K),[]))
	if l(C)>=Q:a=min(a,C[Q-1]-Y)
print(a)

Measured memory_bytes: 68828
#include <iostream>
#include <algorithm>
int main()
{
  int n[5] = {};
  std::cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4];
  std::sort(std::begin(n), std::end(n), [](int a, int b){return a > b;}) ;
  std::cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << " " << n[4] << std::endl;
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


int main(){
	string s;
	cin >> s;
	map<char,int> m;

	rep(i,0,s.size())m[s[i]]++;

	rep(i,0,26){
        if(m[(char)('a'+i)] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <unordered_map>
#include <map>
#include <istream>
#include <sstream>
#include <stack>
#include <set>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define ull unsigned long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;

typedef long double ld;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<double> p(n + 1);
    for(int i = 1;i <= n;i++){
        cin >> p[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1)); // 0 -tail, a- head
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for(int i = 2;i <= n;i++){
        dp[i][0] += (1 - p[i]) * dp[i-1][0];
        for(int j = 1;j <= i;j++){
            dp[i][j] += (1 - p[i]) * dp[i-1][j];
            dp[i][j] += p[i] * dp[i-1][j-1];
        }
    }
    double ans = 0;
    for(int i = n / 2 + 1;i <= n;i++){
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 70784
s = input()
K = int(input())
idx = [[] for _ in range(26)]

for i in range(len(s)):
    idx[ord(s[i])-ord("a")].append(i)

substr = set()
for i in range(26):
    for j in idx[i]:
        for k in range(j+1,j+6):
            substr.add(s[j:k])
    if len(substr) >= K:
        substr = sorted(list(substr))
        break

print(substr[K-1])

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int r;
	cin >> r;
	cout << 2 * r * acos(-1);*/


	int n, m;
	cin >> n >> m;
	int sum = 0;
	int a;
	rep(i, m) {
		cin >> a;
		sum += a;
	}
	if (sum > n)cout << -1;
	else cout << n - sum;
	return 0;
}

Measured memory_bytes: 3196
use proconio::input;

fn prime_factorization(n: usize) -> std::collections::BTreeMap<usize, usize> {
    let mut p = std::collections::BTreeMap::new();
    if n < 2 {
        return p;
    }
    let mut n = n; // shadowing
    for i in 2.. {
        if i * i > n {
            break;
        }
        while n % i == 0 {
            *p.entry(i).or_insert(0) += 1;
            n /= i;
        }
    }
    if n != 1 {
        *p.entry(n).or_insert(0) += 1;
    }
    p
}

fn main() {
    input! {
        n: u64,
    };
    let pq = prime_factorization(n as usize);
    let mut count = 0;
    for (&_, &q_i) in pq.iter() {
        let mut c = 0;
        for i in 1.. {
            c += i;
            if c > q_i {
                break;
            }
            count += 1;
        }
    }
    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 2164
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S, str string
	fmt.Scan(&S, &str)
	S += S[0 : len(str)-1]
	if strings.Contains(S, str) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}



Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mmm 1000000007
#define pb push_back
									//nestedcode


 int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	ll n,s;
  	double ans;
  	cin>>n;
  	s = (n+1)/2;
  	ans = (double)s/n;
  	cout<<fixed<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

int n,m,X; 
int main(){
	n = read(),m = read(),X = read();
	if (n<m) swap(n,m);
	int ans = 0;
	while (X>0) ++ans,X-=n;
	cout<<ans<<endl; 
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  char b;
  cin >> b;
  if (b == 'A') {
    cout << 'T' << endl;
  } else if (b == 'T') {
    cout << 'A' << endl;
  } else if (b == 'G') {
    cout << 'C' << endl;
  } else {
    cout << 'G' << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int n,k;
  cin>>k>>n;
  int a[n+1];
  FOR(i,1,n)
  {
    cin>>a[i];
  }
  int mx=INT32_MIN;
  int x=1;
  int ans=0;
  int sum=0;
  FOR(i,1,n-1)
  {
    if(a[i+1]-a[i]>mx)
    {mx=a[i+1]-a[i];x=i;}
    sum+=a[i+1]-a[i];
  }
  sum+=k-a[n]+a[1];
  if(k-a[n]+a[1]>mx)
  {
    x=n;
  }
  if(x==n)
  {
    sum-=k+a[n]-a[1];
  }
  else
  {
    sum-=a[x+1]-a[x];
  }
  cout<<abs(sum)<<endl;

  
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int N, K;
  int i = 0;
  cin >> N >> K;

  while(1){
    N /= K;
    i++;
    if (N == 0) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   int c,a,b,x;cin>>a>>b>>c>>x;
   int cnt = 0;
   REP(i,0,a){
       REP(j,0,b){
           REP(k,0,c){
               if(500*i+100*j+50*k == x){
                   cnt++;
               }
           }
       }
   }
   cout<<cnt;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

char board[105][105];

int main()
{
    int w, b;
    scanf("%d %d", &w, &b);

    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 50; y++)
            board[y][x] = '.';

        for (int y = 51; y <= 100; y++)
            board[y][x] = '#';
    }

    w--;
    b--;

    //0개 보다 크게 남으면 반대편 엄청 큰 영역에 하나씩 건너뛰며 그리면 된다

    int wx = 52, wy = 1;
    int bx = 1, by = 1;

    while (w > 0)
    {
        board[wx][wy] = '.';
        w--;
        wy += 2;
        if (wy > 100)
        {
            wx += 2;
            wy = 1;
        }
    }

    while (b > 0)
    {
        board[bx][by] = '#';
        b--;
        by += 2;
        if (by > 100)
        {
            bx += 2;
            by = 1;
        }
    }

    printf("100 100\n");
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
            printf("%c", board[x][y]);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

N = int(input())
data = list(map(int, input().split(" ")))

minus_num = sum([x < 0 for x in data])
abs_data = list(map(abs, data))
if minus_num%2 == 0:
    # すべて正の数に変換
    print(sum(abs_data))
else:
    # 一つだけ負の数
    min_data = min(abs_data)
    print(sum(abs_data) - 2*min_data)


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n;
  cin >> n;
  int a = 0;
  while(1<<a+1 <= n) a++;
  cout << (1<<a) << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<cstdio>
#include<unordered_set>
using namespace std;

int main()
{
	int n, i, j;
	long long int result = 1;
	cin >> n;
	vector<int> h(n);
	vector<int> r(n);
	vector<int> left(n);
	vector<int> right(n);
	for (i = 0; i < n; i++) {
		h[i] = -1;
		r[i] = 1000000007;
	}
	for (i = 0; i < n; i++) {
		cin >> left[i];
	}
	for (i = 0; i < n; i++) {
		cin >> right[i];
	}
	h[0] = left[0];
	r[0] = left[0];
	for (i = 1; i < n; i++) {
		if (left[i] > left[i - 1]) {
			if (h[i] == -1) {
				h[i] = left[i];
				r[i] = left[i];
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		else if (left[i] == left[i - 1]) {
			r[i] = min(r[i], left[i]);
		}
	}
	if (h[n - 1] == -1) {
		h[n - 1] = right[n - 1];
	}
	else if (h[n - 1] != right[n - 1]) {
		cout << 0 << endl;
		return 0;
	}
	if (h[n - 1] > r[n - 1]) {
		cout << 0 << endl;
		return 0;
	}
	r[n - 1] = right[n - 1];
	for (i = n - 2; i >= 0; i--) {
		if (right[i] > right[i + 1]) {
			if ((h[i] == -1 || h[i] == right[i]) && right[i] <= r[i]) {
				h[i] = right[i];
				r[i] = right[i];
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		else if (right[i] == right[i + 1] && r[i] > right[i]) {
			r[i] = right[i];
		}
	}
	for (i = 1; i < n - 1; i++) {
		if (h[i] == -1) {
			result *= r[i];
			result = result % 1000000007;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 1920
<?php
// 入力
$s = trim(fgets(STDIN));

$n = strlen($s);
// 答え出力用配列に0格納
$result = array_fill(0, $n, 0);

$r_top = 0;
// 'R...RL...L'ごとに処理
while($r_top < $n) {
    $l_top = strpos($s, 'L', $r_top);
    $r_last = $l_top - 1;
    if (strpos($s, 'R', $l_top)) { // 次の'R'が見つかった場合
        $l_last = strpos($s, 'R', $l_top) - 1;
    } else { // 次の'R'が見つからない場合
        $l_last = $n - 1;
    }
    $r_cnt = $r_last - $r_top + 1; // 'R'の個数
    $l_cnt = $l_last - $l_top + 1; // 'L'の個数

    // 'RL'の'R'に移動するのは'R'までの距離が偶数の'R'と'L'
    $result[$r_last] = ceil($r_cnt / 2) + floor($l_cnt / 2);
    // 'RL'の'L'に移動するのは'L'までの距離が偶数の'R'と'L'
    $result[$l_top] = floor($r_cnt / 2) + ceil($l_cnt / 2);

    $r_top = $l_last + 1;
}
echo implode(' ', $result).PHP_EOL;

Measured memory_bytes: 35576
N = int(input())
S = str(input())
S = list(S)

if N % 2 != 0:
    print('No')
else:
    S1 = S[:int(N/2)]
    S2 = S[int(N/2):]
    if S1 == S2:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
A = []
for i in range(N):
    A.append(int(input()))


B = sorted(A)
d = {}


for i in range(N):
    d[A[i]] = i % 2

count = 0
for i in range(N):
    # d[B[i]] = (d[B[i]] + i) % 2
    count += (d[B[i]] + i) % 2


print(count//2)


Measured memory_bytes: 62808
#include<stdio.h>

int main(){
	long long a,b,md;
	long long c;
	scanf("%lld %lld %lld", &a,&b,&md);
	if(a%md==0){
		if(a==0)
		{
			c=b/md+1;
		}
		else
		{
			c=(b/md)-(a-1)/md;
		}	
	}
	else
	{
		c=b/md-a/md;
	}
	printf("%lld\n", c);
	
	
	return 0;
}

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



int main() {
	int N;
	cin >> N;
	int **a = new int*[N];
	for (int i = 0; i < N; i++) {
		a[i] = new int[3];
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	for (int i = 1; i < N; i++) {
		a[i][0] += max(a[i - 1][1], a[i - 1][2]);
		a[i][1] += max(a[i - 1][0], a[i - 1][2]);
		a[i][2] += max(a[i - 1][1], a[i - 1][0]);
	}
	

	cout << max(max(a[N - 1][0], a[N - 1][1]), a[N - 1][2]) << endl;

	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;

ll power(int a, int b){
    ll powerd = 1;
    for(int i=0; i<b; i++) powerd *= a;
    return powerd; 
}

int main(){
    int N; cin >> N;
    ll A[N], ans = 0;
    int one[60] = {}, count = 0, amari;
    for(int i=0; i<N; i++) cin >> A[i];

    // A[i] = 2進数で2^i桁目が1になる数字の数
    for(int i=0; i<60; i++){
        for(int j=0; j<N; j++){
            one[i] += A[j]%2;
            A[j] = A[j]/2;
        }
    }
    ll x, y, x_1, x_2;
    for(int i=0; i<60; i++){
        if(one[i] == 0) continue;
        x_1 = one[i]%1000000007;
        x_2 = (N-one[i])%1000000007;
        x = x_1*x_2%1000000007;
        y = pow(2, i);
        y = y%1000000007;
        ans += x*y;
        ans = ans%1000000007;
    }
    cout << ans << endl;
}


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

namespace Shiritori
{
    class Program
    {
        private static char[] c1;
        private static char[] c2;
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());//faxcount

            List<string> mojiretsu = new List<string>();

            int miss = 0;

            for (int i = 0; i < N; i++)
            {
                string W = Console.ReadLine();
                mojiretsu.Add(W);
            }

            for (int i = 0; i < N-1; i++)//siri
            {
                c1 = mojiretsu[i].ToCharArray();
                char last = c1[mojiretsu[i].Length - 1];
                
                c2 = mojiretsu[i+1].ToCharArray();
                char first = c2[0];

                if (last==first)
                {
                    Console.Write("");
                }
                else
                {
                    miss += 1;
                }
            }

            mojiretsu.Sort();

            for (int i = 1; i < N; i++)//double
            {
                if (mojiretsu[i-1] == mojiretsu[i])
                {
                    miss += 1;
                }
                else
                {
                    Console.Write("");
                }
            }
            if (miss == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  vector<vector<int>> F(N, vector<int>(256, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < S[i].size(); j++) {
      F[i][S[i][j]]++;
    }
  }

  string ans = "";
  for(int j = 0; j < 256; j++) {
    int mi = INF;
    for (int i = 0; i < N; i++) {
      mi = min(mi, F[i][j]);
    }
    ans += string(mi, j);
  }
  sort(all(ans));
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B, C;

    cin >> A >> B >> C;

    cout << (B / A > C ? C : B / A) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, y int
	for {
		fmt.Scanln(&x, &y)
		if x == 0 && y == 0 {
			break
		}
		if x > y {
			x, y = y, x
		}
		fmt.Println(x, y)
	}
}


Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int N, T;
int A[100010];

void solve() {
	cin >> N >> T;

	int cnt = 0, cost = 0;
	int small = 1000000010;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i == 0) continue;
		
		small = min(small, A[i-1]);

		int gap = A[i] - small;
		
		if (cost == gap) 
			cnt++;
		
		else if (cost < gap) {
			cnt = 1;
			cost = gap;
		}
	}

	int ans = cnt;
	if (!ans) ans++;

	cout << ans << endl;
}

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<string> v;
  auto dfs = [&](auto&& dfs, int i, string s)->void{
    if(i == n){
      v.push_back(s);
      return;
    }
    char Max = 'a';
    for(int i = 0; i < s.size(); i++){
      Max = max(Max, s[i]);
    }
    for(char c = 'a'; c <= Max+1; c++){
      dfs(dfs, i+1, s+c);
    }
  };
  dfs(dfs, 1, "a");
  sort(v.begin(), v.end());
  for(auto t : v){
    cout << t << endl;
  }

  return 0;
}

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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int maxn=(int)(2e5+5);

int a[maxn];

map<int,int> m1;

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

    int n,k;cin>>n>>k;

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

        a[i]--;
    }

    ll res=0;int curr=0;

    m1[0]=1;

    deque<int> q;q.push_back(0);

    for(int i=1;i<=n;i++)
    {
       curr=(curr+a[i])%k;

       while(q.size()>=k)
       {
           int now=q.front();
           
           m1[now]--;

           q.pop_front();
       }

       res+=m1[curr];

       q.push_back(curr);m1[curr]++;
    }

    cout<<res<<endl;

    return 0;

}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    int x,sm=0;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        sm+=x;
    }
    if(sm>n)    cout<<"-1";
    else 
    {
        n-=sm;
        cout<<n;
    }


} 

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

int main() {
    string s; cin >> s;
    int n = s.size();

    int red = 0; int blue = 0;
    REP(i, n) {
        if (s[i] == '0') ++red;
        else ++blue;
    }

    cout << min(red, blue) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define CONTAINS(x, y) (x.find(y)!=x.end()) //x<T1,T2>, T1 y
#define getPair(x) MP(x->first,x->second)

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
LL x;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    //cout<<setw(4)<<setfill('0')<<"hoge"<<endl;
    cin>>x;
    LL res=x/11*2;
    LL rem=x%11;
    if(rem>0) {
        if (rem <= 6) {
            res+=1;
        }else{
            res+=2;
        }
    }
    cout<< res<<endl;

}

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

def sosu(x):
    
    if x==2:
        return True
    
    else:
        for i in range(2,x-1):
            if x%i==0:
                return False
        
        return True
        
        
for j in range(x,10**6):
    if sosu(j):
        print(j)
        break

Measured memory_bytes: 3060
using System;

namespace Kyu
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] point_low = new int[9];
            int[] point_high = new int[9];
            int[] point_kyu = new int[9];
            int get_kyu;

            for (int i= 0;i < 8; i++)
            {
                point_low[i] = 400 + 200 * i;
                point_high[i] = 599 + 200 * i;
                point_kyu[i] = 8 - i;
            }
            string inD0 = Console.ReadLine();
            int x  = int.Parse(inD0);
            get_kyu = 9;

            for (int i = 0; i < 8; i++)
            {
                if (x >= point_low[i] && x <= point_high[i])
                {
                    get_kyu = point_kyu[i];
                    Console.WriteLine(get_kyu);
                    break;
                }
            }

           
        }
    }
}


Measured memory_bytes: 27460
#include<cstdio>
#include<algorithm>

int main() {
  int N, ans = 0;
  scanf("%d", &N);
  int d[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &d[i]);
  }
  std::sort(d, d+N);
  for (int i = 0; i < N; i++) {
    if (i != N && d[i] == d[i + 1]) continue;
    ans += 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[] zero = new int[C];
		int[] one = new int[C];
		int[] two = new int[C];
		int[][] iwakan = new int[C][C];
		for(int i=0;i<C;++i){
			for(int j=0;j<C;++j){
				iwakan[i][j] = sc.nextInt();
			}
		}
		for(int i=0;i<N;++i){
			for(int j=0;j<N;++j){
				if((i+j)%3==0) zero[sc.nextInt()-1]++;
				else if((i+j)%3==1) one[sc.nextInt()-1]++;
				else two[sc.nextInt()-1]++;
			}
		}
		
		long ans = Long.MAX_VALUE;
		for(int z=0;z<C;++z){
			for(int o=0;o<C;++o){
				for(int t=0;t<C;++t){
					if(z!=o&&o!=t&&t!=z){
						long temp = 0;
						for(int i=0;i<C;++i) temp += zero[i] * iwakan[i][z];
						for(int i=0;i<C;++i) temp += one[i] * iwakan[i][o];
						for(int i=0;i<C;++i) temp += two[i] * iwakan[i][t];
						if(temp<=ans) ans = temp;
					}
				}
			}
		}
		System.out.println(ans);
		return;
	}
}

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

int main() {
  int sum=1, flag;
  vector<int> vec(3), newVec = {};

  for (int i=0; i<3; i++) {cin >> vec.at(i);}

  newVec.push_back(vec.at(0));

  for (int i=1; i<3; i++)
  {
    flag = 0;
    for (int j=0; j<newVec.size(); j++) {
      if (vec.at(i) == newVec.at(j)) flag=1;
    }
    if (flag==0) newVec.push_back(vec.at(i));
  }

  cout << newVec.size() << endl;

  return 0;
}

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

heights = tuple(map(int, input().split(' ')))

dp = [0] * (N + 1)

dp[1] = 0
dp[2] = abs(heights[0] - heights[1])

for hi, i in enumerate(range(3, N + 1), start=2):
    dp[i] = min(
        dp[i - 1] + abs(heights[hi] - heights[hi - 1]),
        dp[i - 2] + abs(heights[hi] - heights[hi - 2]),
    )

print(dp[N])


Measured memory_bytes: 14184
#include<stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
const int N = 2e5+10;
int a[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> a[i];
	}
	int q;
	cin >> q;
	int sum = 0;
	for(int i = 0 ; i < q ; i++)
	{
		int k;
		cin >> k;
		if(*lower_bound(a,a+n,k)==k)
		   sum++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
string solve() {
	var(int, n, y);
	y /= 1000;
	rep(man, 0, min(n, y / 10) + 1) {
		rep(go, 0, min(n - man, (y - man * 10) / 5) + 1) {
			if (n == man + go + (y - man * 10 - go * 5) )
				return to_string(man) + " " + to_string(go) + " " + to_string(y - man * 10 - go * 5);
		}
	}
	return "-1 -1 -1";
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n+1),b(n);
    rep(0,i,n+1){
        cin>>a[i];
    }
    rep(0,i,n)cin>>b[i];
    ll ans=0;
    rep(0,i,n){
        if(b[i]<=a[i]){
            a[i]-=b[i];
            ans+=b[i];
        }else{
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(b[i]<=a[i+1]){
                a[i+1]-=b[i];
                ans+=b[i];
            }else{
                ans+=a[i+1];
                a[i+1]=0;
                b[i]-=a[i+1];
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);

	for(int i=0;i<n;i++)
		cin >> h[i];
	
	int count=0;

	for(int j=0;j<100;j++)
	{
		bool flag=false;
		for(int i=0;i<n;i++)
		{
			if(flag)
			{
				if(h[i]==0)
					flag=false;
				else
					h[i]--;
			}
			else
			{
				if(h[i]!=0)
				{
					flag=true;
					count++;
					h[i]--;
				}
			}
		}
	}

	cout << count << endl;
}


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



int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vector<string> s(n);
    vector<vector<int>> vec(n,vector<int>(26,0));
    
    vector<char> ans;
    
    rep(i,n){
        cin >> s[i];
    }
    
    rep(i,n){
        rep(j,s[i].size()){
            vec[i][s[i][j]-'a']++;
        }
    }
    
    rep(i,26){
        int minv = 51;
        rep(j,n){
            minv = min(minv,vec[j][i]);
        }
        
        rep(k,minv){
            ans.push_back((i+'a'));
        }
    }
    
    sort(ans.begin(),ans.end());
    
    rep(i,ans.size()){
        cout << ans[i];
    }
}


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

using pii = pair<int, int>;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    int sy = -1, sx = -1;
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
        for(int j = 0; j < w; ++j) {
            if(s[i][j] == '@') {
                sy = i, sx = j;
            }
        }
    }

    vector<pii> path;
    for(int i = 0; i < h; ++i) {
        path.emplace_back(i, 0);
    }
    function<void(int, int, int)> snake = [&] (int y, int x, int dx) {
        path.emplace_back(y, x);
        if(x + 2 * dx == 0 && y == 0) {
            path.emplace_back(0, 1);
            return;
        }
        if(x + dx < 2 || w <= x + dx) {
            path.emplace_back(y - 1, x);
            dx *= -1;
            y -= 2;
            snake(y, x, dx);
        } else {
            snake(y, x + dx, dx);
        }
    };
    snake(h - 1, 1, 1);
    rotate(begin(path), find(begin(path), end(path), make_pair(sy, sx)), end(path));
    while(s[path.back().first][path.back().second] != '*') {
        path.pop_back();
    }
    for(auto const& p : path) {
        const int y = p.first, x = p.second;
        if(s[y][x] == '.') {
            s[y][x] = '#';
        }
    }

    for(auto const& t : s) {
        cout << t << endl;
    }
}


Measured memory_bytes: 3248
#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>;

int main() {
  int n, d;
  cin >> n >> d;
  int w = 2*d + 1;
  int ans = (n + (w-1)) / w;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

  vector<vector<int> > c(3);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      int buf;
      cin >> buf;
      c[i].push_back(buf);
    }
  }

  vector<int> a(3);
  vector<int> b(3);

  for (int i = 0; i <= c[0][0]; i++) {
    a[0] = i;
    b[0] = c[0][0] - i;
    for (int j = 0; j <= c[1][1]; j++) {
      a[1] = j;
      b[1] = c[1][1] - j;
      for (int k = 0; k <= c[2][2]; k++) {
        a[2] = k;
        b[2] = c[2][2] - k;
        bool correct = true;
        for (int x = 0; x < 3; x++) {
          for (int y = 0; y < 3; y++) {
            if (a[x] + b[y] != c[x][y]) correct = false;
          }
        }
        if (correct) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <iterator>
#include <queue>
#include <cmath>
#include <cassert>

using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N;
    string S;

    cin >> N >> S;

    int bcnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '#') bcnt++;
    }

    int cnt = 0;
    int ans = 1e9;
    for (int i = 0; i < S.size(); i++) {
        int black = cnt;
        int white = (N - i) - (bcnt - cnt);
        ans = min(ans, black + white);
        if (S[i] == '#') cnt++;
    }

    ans = min(ans, bcnt);

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, a + b - n) << '\n';
    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);
		String s=sc.next(); //入力された文字列
		
		//文字列sから語尾以外の部分を文字列strに入力
		String str=s.substring(0,s.length()-8);
		System.out.println(str);
	}
} 

Measured memory_bytes: 23764
List = []
N, M = (int(x) for x in input().split())
for i in range(N):
    a, b = (int(x) for x in input().split())
    List.append([a, b])

num_of_drink, total_fee = 0, 0
List = sorted(List, key=lambda x:x[0])

temp_M = M
list_of_num = []
for i in range(N):
    if temp_M <= List[i][1]:
        list_of_num.append(temp_M)
        break
    else:
        list_of_num.append(List[i][1])
        temp_M += -List[i][1]
index = 0
for x in list_of_num:
    total_fee += List[index][0] * x
    index += 1
print(total_fee)

Measured memory_bytes: 21984
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C, X, Y);
  ll ans = 0;
  if (C <= A / 2) {
    ans += C * X * 2ll;
    Y = max(Y - X, 0);
    X = 0;
  }
  if (C <= B / 2) {
    ans += C * Y * 2ll;
    X = max(X - Y, 0);
    Y = 0;
  }
  if (C <= (A + B) / 2) {
    int cnt = min({X, Y});
    ans += C * cnt * 2ll;
    Y -= cnt;
    X -= cnt;
  }
  ans += A * max(X, 0) + B * max(Y, 0);
  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    sort(rng(as));
    ll l = -1, r = n - 1;
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        ll s = 0;
        rep(i, m + 1) s += as[i];
        bool f = true;
        for (int i = m + 1; i < n - 1; ++i) {
            if (s * 2 < as[i]) {
                f = false;
                break;
            }
            s += as[i];
        }
        if (f) r = m;
        else l = m;
    }
    cout<<n - r<<endl;
}

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



int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string ans = "";
	int f = 0;
	for (int i = 0; i < n;) {
		if (f) {
			ans += t[i];
			++i;
		}
		else {
			ans += s[i];
		}
		f ^= 1;
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    set<char> cset1, cset2, csetM;
    string s1, s2;
    int ans = 0;
    for (int i = 0; i <= s.size(); ++i) {
        cset1.clear(), cset2.clear(), csetM.clear();
        s1 = s.substr(0, i);
        s2 = s.substr(i);
        for (int a = 0; a < s1.size(); ++a) cset1.insert(s1[a]);
        for (int b = 0; b < s2.size(); ++b) cset2.insert(s2[b]);
        set_intersection(cset1.begin(), cset1.end(), cset2.begin(), cset2.end(), inserter(csetM, csetM.end()));
        int cnt = csetM.size();
        ans = max(cnt, ans);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(){
    string s;
    cin >> s;
    ll check = 0;
    ll ans = 0;
    //cout << s << endl;
    for(ll i = 0; i < s.length(); i++){
        if(s[i]=='A')
            check++;
        else if(s[i]!='A' && i > 0){
            if(s[i]=='B' && s[i+1]=='C'){
                ans+=check;
                i--;
                s.erase(i,2);
            }
            else check = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < m; i++){
    cin >> s.at(i) >> c.at(i);
  }
  int ans = -1;
  
  if (n == 1){
    for (int i = 0; i < 10;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != '0' + c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }
  
  if (n == 2){
    for (int i = 10; i < 100;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != '0' + c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }
  
  if (n == 3){
    for (int i = 100; i < 1000;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != '0' + c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }  
  cout << ans << endl;
}


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

main(){
    int a=1, b=0;
    char c = '\0';
    while(true){
        cin >> a >> c >> b;
        switch(c){
            case '+':
                cout << a+b << endl;
                break;
            case '-':
                cout << a-b << endl;
                break;
            case '*':
                cout << a*b << endl;
                break;
            case '/':
                cout << a/b << endl;
                break;
            case '?':
                return 0;
        }
    }
}


Measured memory_bytes: 3096
#
import sys
import math
import numpy as np
import itertools
# いくつか入力
n,t = (int(i) for i in input().split())

# n行の複数列ある数値を二次元配列へ。x[n][?]
ab = [[int(i) for i in input().split()] for i in range(n)]
# 0:weight 1:value

ab = sorted(ab,key=lambda x: x[1])

dp = np.zeros((n+1,t),int)
dp2 = np.zeros((n+1,t),int)

for i in range(n):
    w = ab[i][0]
    dp[i+1][w:] = np.fmax(dp[i][:-w] + ab[i][1], dp[i][w:])
    dp2[i+1][w:] = np.fmax(dp2[i][:-w] + ab[i][1],dp[i][w:] + ab[i][1], dp2[i][w:])
    dp[i+1][:w] = dp[i][:w]
    dp2[i+1][:w] = np.fmax(dp[i][:w] + ab[i][1], dp2[i][:w])

answer = np.amax(dp2)
print(answer)



Measured memory_bytes: 153236
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
#define ll long long int

using namespace std;


  // maxのよりを計算すれば良い。

  int drop;
  string s;
  int N; int Q;

vector <char> t; 
  vector <char> d;

//左に落ちる
  bool judge(int x){
    int now = x;
    for(int i=1;i<=Q;i++){

      if(s[now] != t[i]) continue;
      if(d[i] == 'R') now++;
      else now--;
      if( now <1) return true;
    }
    return false;
  }

  bool judge2(int x){
    int now = x;
    for(int i=1;i<=Q;i++){
      if(s[now] != t[i]) continue;
      if(d[i] == 'R') now++;
      else now--;
      if(now > N) return true;
    }
    return false;
  }
 


int main(){
 cin>>N;
  cin>>Q;
  t.resize(Q+10); // 動かすとこ
  d.resize(Q+10);// 方向
   cin>>s; s = '#' + s; s = s+ '#';
  
  for(int i=1;i<=Q;i++){
    cin>>t[i]>>d[i];
   
  }
  int Lans=10000000;

  // 右の判定
  int left = 1;
  int right = N+1;

  int mid = N/2;
  int ans = mid;
  

  while(right - left > 1){

    if(judge(mid)){
      left = mid;
      mid = (left + right)/2;
    } else {
      right = mid;
      mid = (left + right)/2;
    }

    //if(mid == left) break;



  }

  if(judge(mid)) Lans = mid; 

  int Rans=10000000;

   left = 0;
   right = N;

      mid = N/2;
      ans = mid;

  while(right - left >1){
    if(judge2(mid)){
      right = mid;
      mid =(left + right)/2;
    } else {
      left = mid;
      mid =(left + right)/2;
    }

    //if(mid == right) break;


  }

  if(judge2(mid+1)) Rans=mid+1;

for(int i=1;i<=N;i++){
  if(1<=i and i<=Lans) {drop++; continue;}
  if(Rans <= i and i<=N) drop++;
}
//cout<<Lans<<" "<<Rans<<endl;
cout<<N-drop<<endl;






 
  



  return 0;
}

  

Measured memory_bytes: 1156
MOD = 10 ** 9 + 7

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

maxf = 2 * N + 10
f = [1 for _ in range(maxf)]
invf = [1 for _ in range(maxf)]

for i in range(1, maxf):
    f[i] = (i * f[i - 1]) % MOD

invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)
for i in range(maxf - 1, 0, -1):
    invf[i - 1] = (i * invf[i]) % MOD


def comb(a, b):
    if b > a:
        return 0
    return (((f[a] * invf[b]) % MOD) * invf[a - b]) % MOD


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

res = 0
for i in range(N):
    res = (res + comb(i, K - 1) * (A[i] - A[N - i - 1])) % MOD

print(res)


Measured memory_bytes: 30224