akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include "stdio.h"

using namespace std;

void insertionSort(vector<int> &A, int N)
{
	for (int i = 1; i < N; i++) {
		int v = A[i];
		int j;
		for (j = i - 1; j >= 0 && A[j] > v; j--) {
			A[j + 1] = A[j];
		}
		A[j + 1] = v; 
		
		for (int k = 0; k < N; k++) {
			if (k > 0) cout << ' ';
			cout << A[k];
		}
		cout << '\n';
	}
}
	

int main(void)
{
	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int k = 0; k < N; k++) {
		if (k > 0) cout << ' ';
		cout << A[k];
	}
	cout << '\n';

	insertionSort(A, N);

	return 0;
}


Measured memory_bytes: 3100
import Data.Array.IO
import Control.Monad

main = do
  s <- getLine
  let [n,m] = map (read::String->Int) . words $ s
  s <- replicateM n getLine
  t <- replicateM m getLine

  let mult x = show $ sum $ zipWith (*) (map (read::String->Int) . words $ x) (map (read::String->Int) $ t)
  mapM_ putStrLn $ map mult s

Measured memory_bytes: 7448
#include<stdio.h>

int main(){
  int i,j,k;
  int N;
  scanf("%d",&N);
  int A[N+1];
  int flg=0;
  for(i=1;i<=N;i++)
    scanf("%d ",&A[i]);
  int tmp;
  for(i=1;i<=N;i++){
    if(i!=A[i]){
      if(flg==1){
        puts("NO");
        return 0;
      }
      if(A[A[i]] != i){
        puts("NO");
        return 0;
      }
      else{
        tmp=A[A[i]];
        A[A[i]]=A[i];
        A[i] = tmp;
        flg=1;
      }
    }
  }
  puts("YES");
  return 0;
}




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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll x(n), y(n);
    vll h(n);
    rep(i,n){
        cin>>x[i]>>y[i]>>h[i];
    }
    rep(i,101)rep(j,101){
        bool ng = false;
        ll tall=1e10;
        rep(k,n){
            tall = min(tall, h[k]+abs(x[k]-j)+abs(y[k]-i));
        }
        rep(k,n){
            ll tmp = max(0ll, tall-abs(x[k]-j)-abs(y[k]-i));
            if (tmp!=h[k]){
                ng = true;
                break;
            }
        }
        if (ng) continue;
        cout<<j<<" "<<i<<" "<<tall<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-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)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

ll n, m, q;
ll ans;
vector<int> a, b, c;
vector<ll> d;
int v[15];

void rec(ll num,int cnt=0){
 // cerr << num << endl;
  if (cnt == n)
  {
    ll cul = 0;
    rep(i, q)
    {
      if(v[b[i]]-v[a[i]]==c[i]){
        cul += d[i];
      }
    }
    chmax(ans, cul);
    return;
  }
  for (ll i = num; i <= m;++i){
    v[cnt] = i;
    rec(i, cnt + 1);
  }
}

void solve()
{
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  ans = 0;
  rep(i, q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  rec(1);
  cout << ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<long double> a(n);
    rep(i,0,n){
        long double w;
        cin >> w;
        a[i] = (w+1)/2;
    }
    long double sum = 0;
    for(int i = 0 ; i < k ; i++){
        sum += a[i];
    }
    long double maxim = sum;
    for(int i = 0 ; i < n - k ; i++){
        sum = sum - a[i] + a[i + k];
        maxim = max(maxim, sum);
    }
    cout << fixed << setprecision(10) << maxim;
}

Measured memory_bytes: 3328
pattern = [('S','S'), ('S','W'), ('W', 'S'), ('W','W')]
N = int(input())
S = input()

ret = '-1'

def check(s, animal, neighbor1, neighbor2):
    if animal == 'W': s = 'x' if s == 'o' else 'o'
    return (s == 'o' and neighbor1 == neighbor2) or (s == 'x' and neighbor1 != neighbor2)

for p in pattern:
    ret_temp = p[0]+p[1]
    first, second = p[0], p[1]
    for i in range(1, N-1):
        equalty = 0 if S[i] == 'o' else 1
        if second == 'W':
            equalty = equalty^1
        if equalty == 0:
            next_animal = first
        else:
            next_animal = 'W' if first == 'S' else 'S'
        ret_temp += next_animal

        first = second
        second = next_animal
        if not check(S[i], ret_temp[i], ret_temp[i-1], ret_temp[i+1]): break
            
    if check(S[0], ret_temp[0], ret_temp[1], ret_temp[-1]) and check(S[N-1], ret_temp[N-1], ret_temp[N-2], ret_temp[0]):
        # print('ok:', ret_temp)
        ret = ret_temp
        break
    # else: print('ng:', ret_temp)

print(ret)

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int A,B;
    cin >> A >> B;
    if(A<=9 && B<=9) cout << A*B << endl;
    else cout << -1 << endl;
}

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

using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        100005
#define mod         998244353  
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){
        cout<<"hon";
    }
    else if(n==1 || n==0 || n==6 || n==8){
        cout<<"pon";
    }
    else{
        cout<<"bon";
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int merge_sort(int a[],int left,int right){
    if(left+1<right)
    {   int mid=(left+right)/2;
        return merge_sort(a,left,mid)+merge_sort(a,mid,right)+right-left;}
    else return 0;
};
int main()
{   int n;
    cin>>n;int a[n];for(int i=0;i<n;i++) {cin>>a[i];}
    sort(a,a+n);
    for(int i=0;i<n;i++)
        if(i==n-1)cout<<a[i]<<endl; else cout<<a[i]<<' ';
    cout<<merge_sort(a,0,n)<<endl;
    return 0;
}


Measured memory_bytes: 5096
#include<bits/stdc++.h>
const int N=100+5;
using namespace std;
int a[N];
int main()
{
	int n;
	(void)scanf("%d",&n);
	int k=0;
	for(int i=0;i<n;i++){
		(void)scanf("%d",&a[i]);
		if((i+1)%2!=0 && a[i]%2!=0)
		    k++;
	}
	printf("%d\n",k);
	return 0;
} 

Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x, y; cin >> n >> x >> y;
    x--; y--;
    vector<int> dist(n);
    // int k = n - (y - x + 1);
    // rep (i, k) dist[i] += k - i;
    int center = (x + y) / 2;
    rep (i, n) {
        rep (j, i + 1, n) {
            eprintf("%d %d: %d\n", i, j, min(j - i, abs(x - i) + abs(j - y) + 1));
            dist[min(j - i, abs(x - i) + abs(j - y) + 1)]++;

        }
    }
    rep (i, 1, n) cout << dist[i] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

const int N=100005;

int n,m,k,x,rt;
int f[N];
vector<int> lev[N];

int find(int k){
	if (f[k]!=k) f[k]=find(f[k]);
	return f[k];
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%d",&k);
		for (j=1;j<=k;j++){
			scanf("%d",&x);
			lev[x].push_back(i);
		} 
	}
	for (i=1;i<=n;i++) f[i]=i;
	for (i=1;i<=m;i++){
		if (!lev[i].size()) continue;
		rt=find(lev[i][0]);
		for (j=1;j<lev[i].size();j++){
			x=find(lev[i][j]);
			f[x]=rt;
		}
	}
	for (i=2;i<=n;i++)
		if (find(i)!=find(i-1)){
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
} 

Measured memory_bytes: 4608
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M; cin >> N >> M;
    vl A(N); rep(i, N) cin >> A[i];
    unordered_map<ll, ll> m;
    ll sum = 0;
    rep(i, N){
        sum += A[i];
        m[sum%M]++;
    }
    
    ll ans = m[0];
    FORMAP(it, m){
        ans += it->ss * (it->ss - 1) / 2;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 4492
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        for (int i = -100; i < 101; i++) {
            int tmp = 0;
            for(int b :a){
                tmp += Math.pow(i - b, 2);
            }
            ans = Math.min(ans, tmp);
        }

        System.out.println(ans);
        sc.close();
    }

}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1010;
int n;
char s[N][N];
char a[4][5] = {
	"aabc",
	"ddbc",
	"efgg",
	"efhh"
};
char b[5][6] = {
	"aabbc",
	"dee.c",
	"d..fg",
	"h..fg",
	"hiijj"
};
char c[7][8] = {
	"aabbc..",
	"d...cee",
	"dffgg..",
	"hh...ij",
	"..k..ij",
	"..k..lm",
	"...nnlm"
};

void solve(vector<int> w) {
	int p = 0;
	for (int x : w) {
		if (x == 4) {
			for (int i = 0; i < x; i++)
				for (int j = 0; j < x; j++)
					s[p + i][p + j] = a[i][j];
		} else if (x == 5) {
			for (int i = 0; i < x; i++)
				for (int j = 0; j < x; j++)
					s[p + i][p + j] = b[i][j];
		} else if (x == 7) {
			for (int i = 0; i < x; i++)
				for (int j = 0; j < x; j++)
					s[p + i][p + j] = c[i][j];
		}
		p += x;
	}
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	if (n == 2) {
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			s[i][j] = '.';
	
	if (n % 3 == 0) {
		for (int i = 0; i < n; i += 3) {
			s[i][i] = s[i][i + 1] = s[i + 1][i + 2] = s[i + 2][i + 2] = 'a';
		}
	} else {
		if (n == 7) {
			solve({7});
		} else if (n == 11) {
			solve({4, 7});
		} else {
			vector<int> w;
			int x = n;
			while(x % 4 != 0) {
				w.push_back(5);
				x -= 5;
			}
			if (x < 0) throw;
			while(x > 0) {
				w.push_back(4);
				x -= 4;
			}
			solve(w);
		}
	}
	for (int i = 0; i < n; i++) {
		s[i][n] = '\0';
		printf("%s\n", s[i]);
	}

	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

bool f(ull n, int i)
{
  if (i == 0) {
    return ((n / 2) + (n % 2)) % 2;
  }

  ull x = ull(1) << (i + 1);
  ull y = 1LL << i;
  return (n % x) >= y && ((n % x) - y) % 2 == 0;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  ull a, b;
  while (cin >> a >> b) {
    ull c = 0;
    for (int i = 0; i < 63; ++i) {
      c |= (ull(1) << i) * (f(a - 1, i) != f(b, i));
    }
    cout << c << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	while(a--){
		long long A,B;
		scanf("%lld%lld",&A,&B);
		if(A>B)swap(A,B);
		long long ret=A-1;
		long long tmp=A*B-1;
		long long val=(long long)((sqrt(4*tmp+1+0.5)-1)/2);
		ret+=max(0LL,val-A);
		val=max(val,A);
		
	//	printf("%lld: %f %f\n",val,(double)(A*B-1)/val,(double)(A*B-1)/(val+1));
		ret+=(A*B-1)/(val+1);
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b+c)
	{
		cout<<"Yes"<<endl;
	}
	
	else if(b==a+c)
	{
		cout<<"Yes"<<endl;
	}
		
	else if(c==a+b)
	{
		cout<<"Yes"<<endl;
	}	
	
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,k,i;
    while(scanf("%d%d%d",&a,&b,&k)!=EOF)
    {
        if(k<1||k>100)
            break;
        if(b-a+1<k*2)
        {
            for(i=a;i<=b;i++)
                printf("%d\n",i);
        }
        else
        {
            for(i=a;i<=a+k-1;i++)
                printf("%d\n",i);
            for(i=b-k+1;i<=b;i++)
                printf("%d\n",i);
        }
    }
    return 0;
}


Measured memory_bytes: 128
S = input()
flag = True
for i in range(len(S)):
    s = S[i]
    # print(i+1 % 2)
    if (i+1) % 2 == 1:
        if not(s == "R" or s == "U" or s == "D"):
            flag = False
            break
    elif (i+1) % 2 == 0:
        if not(s == "L" or s == "U" or s == "D"):
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int result(int,int);

int main(){
  int n,num1,num2,sum1=0,sum2=0;
  int i;
  
  while(scanf("%d",&n),n!=0){
    for(i=0;i<n;i++){
      scanf("%d%d",&num1,&num2);
      sum1+=result(num1,num2);
      sum2+=result(num2,num1);
    }
    printf("%d %d\n",sum1,sum2);
    sum1=0; sum2=0;
  }
  return 0;
}

int result(int n1,int n2){
  if(n1 > n2)
    return n1+n2;
  else if(n1 == n2)
    return n1;
  else
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n;
	cin>>n;
	if(n==7||n==5||n==3){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

int m, dp[MAX];
vector<int>v;
int solve(int need){
    if(need<2) return need;
    if(dp[need]!=-1) return dp[need];
    int ret=1e7;
    for(int i=0; i<m; i++){
        if(v[i]<=need) ret = min(ret, 1+solve(need-v[i]));
    }
    dp[need]=ret;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x=6;
    for(int i=1; ;i++){
        v.pb(x);
        x = x*6;
        if(x>MAX) break;
    }
    x=9;
    for(int i=1; ;i++){
        v.pb(x);
        x = x*9;
        if(x>MAX) break;
    }
    v.pb(1);
    sort(all(v));
    reverse(all(v));
    m=v.size();
    int n; cin>>n;
    mem(dp,-1);
    cout<<solve(n)<<endl;
	return 0;
}


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

int main() {
  vector<char> S(15,'o');
  int count = 0;
  for(int i=0;i<15;i++){
    cin >> S.at(i);
    if(S.at(i) == 'x')
      count++;
  }
  if(count >7)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    cout << (N - K + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");
    else if(b>=0)puts("Zero");
    else if((a&1)^(b&1))puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vl a(n);
    FOR(i,0,n){
        cin>>a[i];
    }
    LL ans=100LL*mod;
    FOR(i,1,101){
        LL t=0;
        FOR(j,0,n){
            t+=1LL*(i-a[j])*(i-a[j]);
        }
        if(t<ans){
            ans=t;
        }
    }
    cout<<ans;

}


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

int main(){
  int N;
  int ans;
  int Flag=0;
  cin>>N;

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      ans = i*4+j*7;
      if(ans==N)break;
    }
    if(ans==N){
      Flag=1;
      break;
    }
  }
  if(Flag==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson10C n 人の学生を含むクラスでプログラミングの試験を行った。
 * それぞれの得点をs1, s2 ...
 * snとしたときの、標準偏差を求めるプログラム
 *  得点の平均値をｍとすれば、
 *  分散α2は以下の式で得られる：
 *   α2 = (?ni=1(si - m)2)/n
 * 分散の正の平方根が標準偏差αとなる。
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 平均M　全部足して/個数で割る
		double dbAverage = 0.0;

		// 標準偏差
		// aa = (s1-m)2乗 + (s2-m)2乗 + ・・・
		//あとでNで割る
		// a = ・・・
		double dbStandarddeviatio = 0.0;

		// 答えの格納場所
		ArrayList<Double> dbAryAnswer = new ArrayList<Double>();

		// 1行目を取得
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			while (true) {

				String strLine = insBR.readLine();

				// 数字を取得
				int intNum = Integer.parseInt(strLine);

				if (intNum == 0) {
					break;
				}

				// 2行目を取得
				strLine = insBR.readLine();

				// 分解
				String[] strAryLine = strLine.split(" ");

				// 配列に全部格納しておく
				int[] intLine = new int[strAryLine.length];

				for (int i = 0; i < strAryLine.length; i++) {
					intLine[i] = Integer.parseInt(strAryLine[i]);

					// 平均M　全部足して/個数で割る
					dbAverage += intLine[i];

				}

				// 平均M　全部足して/個数で割る
				dbAverage = dbAverage / strAryLine.length;

				// 標準偏差
				// aa = (s1-m) + (s2-m) + ・・・

				for (int i = 0; i < strAryLine.length; i++) {

					dbStandarddeviatio += (intLine[i] - dbAverage) * (intLine[i] - dbAverage);

				}

				// aaをnで割る
				dbStandarddeviatio /= strAryLine.length;

				// a ＝・・・・
				dbStandarddeviatio = Math.sqrt(dbStandarddeviatio);

				dbAryAnswer.add(dbStandarddeviatio);

				//初期化
				dbAverage = 0.0;
				
				dbStandarddeviatio =0.0;

			}

			// 答えが何個あるか取得
			int intSize = dbAryAnswer.size();

			// 出力
			for (int i = 0; i < intSize; i++) {
				System.out.println(dbAryAnswer.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

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

int main(){
  string s;
  cin >> s;
  int l = s.size();
  cout << s[0] << l-2 << s[l-1];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define INF 1e9
int N,a,b,c,Ma,Mb;
int dp[2][401][401];
int main(){
	cin >> N >> Ma >> Mb;
	for(int k=0;k<2;++k)
		for(int i=0;i<=400;++i){
			for(int j=0;j<=400;++j){
				dp[k][i][j] = INF;
			}
		}
	dp[0][0][0] = dp[1][0][0] = 0;
	int cur = 1;
	while(N--){
		cin >> a >> b >> c;
		for(int i=0;i<=400;++i){
			for(int j=0;j<=400;++j){
				if(i >= a && j >= b){
					dp[cur][i][j] = min(dp[(cur+1)%2][i][j],dp[(cur+1)%2][i-a][j-b]+c);
				}else{
					dp[cur][i][j] = dp[(cur+1)%2][i][j];
				}
			}
		}

		++cur;
		cur %= 2;
	}
	++cur;
	cur%=2;
	int res = INF;
	for(int i=1;i*Ma<=400;++i){
		if(i*Mb <= 400) res = min(res,dp[cur][i*Ma][i*Mb]);
	}
	if(res == INF) cout << -1 << endl;
	else cout << res << endl;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int N;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<int> P(N);
  REP(i, N) cin >> P[i];

  int mi = N + 1, ans = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] <= mi) ans++;
    mi = min(mi, P[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<bitset>
#include<functional>
#include<climits>
using namespace std;
typedef pair<int,int>pii;
const int INF=1e9;
const int dx[]={0,-1,0,1},dy[]={-1,0,1,0};

int a[7],b[7];
int cnt,to;
int n;
void dfs(int pos,int sum){
    if(pos==n){
        if(sum==to)cnt++;
        return;
    }
    for(int i=0;i<=b[pos];i++){
        dfs(pos+1,sum+a[pos]*i);
    }
}
int main(){
    while(scanf("%d",&n),n){
        for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
        int m;
        scanf("%d",&m);
        while(m--){
            scanf("%d",&to);
            cnt=0;
            dfs(0,0);
            printf("%d\n",cnt);
        }
    }
    return 0;
}

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

int main(){ 
    int N, M;
    cin >> N >> M;

    vector<Int> H(N);
    rep(i,N) cin >> H[i];

    vector<vector<int>> G(N, vector<int>(0));

    rep(i,M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<bool> not_good(N, false);

    vector<pair<Int,int>> heights(0);

    rep(i,N) {
        heights.push_back(make_pair(H[i], i));
    }

    sort(heights.begin(),heights.end());
    reverse(heights.begin(),heights.end());

    /* rep(i,N) {
        cout << heights[i].first << heights[i].second << endl;
    } */

    int ans = 0;

    rep(i,N) {
        if (!not_good[heights[i].second]) {
            bool flag = true;
            rep(j,G[heights[i].second].size()) {
                if (H[heights[i].second] == H[G[heights[i].second][j]]) flag = false;
            }
            if (flag) ans++;
        }

        rep(j,G[heights[i].second].size()) {
            not_good[G[heights[i].second][j]] = true;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11296
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string t;
  cin >> t;
  REP(i, t.length()) {
    if(t[i] == '?') {
      t[i] = 'D';
    }
  }

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
using namespace std;	
 
	int main(){
		int goke;
		int hon;
		int count=0;

	while(true){
		if(count==0){
		cin>>goke;
		if(goke==0){
		break;
		}
	count++; 
		}else{
		cin>>hon;
		goke-=hon;
		count++;
		}
		if(count==10){
		cout<<goke<<'\n';
		count=0;
		}
	}
	return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, k; cin >> n >> k;
    int ans = 0;
    REP(i, 0, n){
        int a; cin >> a;
        if(a >= k){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct fd {
	int ind;
	ll typ,del;
	bool operator<(const fd& masik) const {
		return del<masik.del;
	}
};
int main() {
	int n,k;
	cin>>n>>k;
	vector<fd> t(n);
	for(int i=0;i<n;++i) {
		cin>>t[i].typ>>t[i].del;
		t[i].ind=i;
	}
	sort(t.begin(), t.end());
	stack<ll> st; ll szum=0;
	vector<int> volt(n+1); ll distinct=0;
	ll ans=0;
	for(int i=n-1;i>=0;i--) {
		if(!volt[t[i].typ]) {
			distinct++;
			volt[t[i].typ]=1;
			szum+=t[i].del;
		}else {
			st.push(t[i].del);
			szum+=t[i].del;
		}
		
		while(distinct+(int)st.size()>k && !st.empty()) {
			szum-=st.top();
			st.pop();
		}
		
		if(distinct+(int)st.size()>k) break ;
		ans=max(ans, szum+distinct*distinct);
	}
	
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3200
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    ll n,c=0,w;
    cin>>n>>w;
    ll weights[n+1];
    ll vals[n+1];
    fora(i,1,n)cin>>weights[i]>>vals[i];
    ll dp[n+1][w+1];
    //dp[0][0]=0;
    for(int i=0;i<=w;i++)dp[0][i]=0;
    for(int i=0;i<=n;++i)dp[i][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(weights[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weights[i]]+vals[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
   /* forn(i,n+1)
    {
        forn(j,w+1)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][w]<<endl;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 79232
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,flg,len;
	long long k,x;
	char s[101];
	scanf("%s",s);
	scanf("%lld",&k);
	len=strlen(s);
	for(i=0;i<len;i++)	{
		if(s[i]!='1')	{
			x=i;
			break;
		}
	}
	k=k-1;
	if(k<x)	printf("1\n");
	else 	printf("%c\n",s[x]);
	return 0;
}

Measured memory_bytes: 128
use std::cmp::{self, Ordering};
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: usize = sc.read().unwrap();
    let x: usize = sc.read().unwrap();
    let mut l: Vec<usize> = sc.read_vec(n).unwrap();
    l.push(0);

    let ans = l
        .iter()
        .scan(0, |state, &li| {
            let di = *state;
            *state = di + li;
            Some(di)
        })
        .take_while(|di| di <= &x)
        .count();

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

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
N = int(input())
S = input()

ans = 0

for i in range(1, N):
    a = S[:i]
    b = S[i:]
    # print(i, a, b)
    a = set(a)
    b = set(b)
    c = a & b
    # print(c)
    n = len(c)
    ans = max(ans, n)

print(ans)


Measured memory_bytes: 9084
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
//string s;
bool flag;

//--------------------------------------------------------------------------

#define MAX 100000

int main(void) {
  string s[110], t[110];
  cin >> n;
  FOR(i, 0, n) {
	cin >> s[i];
  }

  cin >> m;
  FOR(i, 0, m) {
	cin >> t[i];
  }

  FOR(i, 0, n) {
	temp = 0;
	FOR(j, 0, n) {
	  if (s[i] == s[j]) temp++;
	}
	FOR(j, 0, m) {
	  if (s[i] == t[j]) temp--;
	}
	ans = max(ans, temp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
    #define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

void solve() {
    int a , b , c;
    cin >> a >> b >> c;
    if(c/a > b/a || (b % a == 0 || c%a == 0)) {
        cout << "OK";
    }
    else {
        cout << "NG";
    }
}
/*
4 3
RLRL

*/

main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*
++>
+++>
<[<+>-]<
++++++++++++++++++++++++++++++++++++++++++++++++.

500000000000000000000000000000000000000000000000

1 1 2 3 6


*/


Measured memory_bytes: 3596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    k = int(readline())
    a, b = map(int, readline().split())
    for i in range(100000):
        x = k*i
        if (a <= x) and (x<=b):
            print('OK')
            return 
    print('NG')
if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

s = input()
data = []
for x in s:
    if x == "B":
        try:data.pop()
        except:pass
    else:
        data.append(x)
print(*data,sep="")

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define INF 9999999

typedef struct{
    int a;
    int b;
    int c;
}data;

int main(void){
    int N,MA,MB;
    scanf("%d%d%d",&N,&MA,&MB);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N+1);
    for(int i=1;i<=N;i++){
        scanf("%d%d%d",&A[i].a,&A[i].b,&A[i].c);
    }

    //DP[a][b][c]...a番目までの薬で、Aがbg、Bがcgとなる最小価格
    int DP[N+1][401][401];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++) DP[i][j][k]=INF;
        }
    }

    //初期値
    DP[0][0][0]=0;

    //DPの更新
    for(int i=1;i<=N;i++){
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                if(DP[i-1][j][k]!=INF) DP[i][j][k]=DP[i-1][j][k];

                if(j-A[i].a>=0 && k-A[i].b>=0){
                    if(DP[i-1][j-A[i].a][k-A[i].b]!=INF) DP[i][j][k]=MIN(DP[i][j][k],DP[i-1][j-A[i].a][k-A[i].b]+A[i].c);
                }
            }
        }
    }

    int ans=INF;
    for(int j=1;j<=400;j++){
        for(int k=1;k<=400;k++){
            if(j*MB == k*MA) ans=MIN(ans,DP[N][j][k]);
        }
    }

    if(ans==INF) printf("-1\n");
    else printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if(a+b == c+d) {
     cout << "Balanced" << endl;
  }
  else {
     cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i,m) {
    int x;
    string y;
    cin >> x >> y;
    x--;
    p[i] = x;
    s[i] = y;
  }
  vector<bool> check(n);
  vector<int> cnt(n);
  rep(i,m) {
    if (check[p[i]]) continue;

    if (s[i] == "AC") check[p[i]] = true;
    else cnt[p[i]]++;
  }
  int res1 = 0;
  int res2 = 0;
  rep(i,n) {
    if (check[i]) {
      res1++;
      res2 += cnt[i];
    }
  }
  cout << res1 << " " << res2 << endl;
}

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

Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    ll N;
    cin >> N;
    vector <ll> A(N);
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    ll S = sum;
    ll num = 0;
    for(int i = 0; i < N; i++){
        num += A.at(i);
        S = min(S , abs(num - (sum - num)));
    }
    cout << S << endl;
    return 0;
}


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

int main(){
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = min(A*X+B*Y, 2*C*max(X,Y));
    if(X > Y) ans = min(ans, A*(X-Y)+2*C*Y);
    else ans = min(ans, B*(Y-X)+2*C*X);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
char s[4];
int main()
{
    while(~scanf("%s",s)){
        if(s[0]==s[2]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256