akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a));

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const long double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100005;

vector<PII> f;

VI g[MAX];
VI gr[MAX];
int n;

void add_edge(int a,int b)
{
	g[a].PB(b);
	gr[b].PB(a);
}


struct RMQ
{
	int n;
	int sh;
	int mx;


	void init(int v,int tl,int tr)
	{
		if(tl == tr)
		{
			mx = max(mx,sh+v+1);
			add_edge(sh+v,f[tl].second);
			return;
		}

		int tm = (tl+tr)/2;
		add_edge(v + sh, 2*v + sh);
		add_edge(v + sh, 2*v+1 + sh);
		init(v*2,tl,tm);
		init(v*2+1,tm+1,tr);
	}

	void init(int n,int sh)
	{
		this->n = n;
		this->sh = sh ;
		mx = 0;
		init(1,0,this->n-1);
	}
	void add(int v,int tl,int tr,int l,int r,int x)
	{
		if(l>r)return;
		if(l==tl && r == tr)
		{
			add_edge(x,v+sh);
			return;
		}

		int tm = (tl+tr)/2;
		add(v*2,tl,tm,l,min(r,tm),x);
		add(v*2+1,tm+1,tr,max(l,tm+1),r,x);
	}

	void add(int l,int r,int x)
	{
		add(1,0,n-1,l,r,x);
	}
} T;


bool us[MAX];
int cInd[MAX];
VI tops;

void dfs1 (int v) {
	us[v] = true;
	FOR(i,0,SZ(g[v]))
		if (!us[ g[v][i] ])
			dfs1 (g[v][i]);
	tops.push_back (v);
}

void dfs2 (int v,int ind) {
	us[v] = true;
	cInd[v] = ind;
	FOR(i,0,SZ(gr[v]))
		if (!us[ gr[v][i] ])
			dfs2 (gr[v][i],ind);
}

int N;
bool ok(int d)
{
	FOR(i,0,N)g[i].clear(),gr[i].clear();
	T.init(2*n,2*n);

	N = T.mx;
	FOR(i,0,SZ(f))
	{
		int nv = f[i].second;
		if(nv<n)nv+=n;
		else nv -= n;

		int ub = upper_bound(ALL(f),MP(f[i].first+d-1,INF))-f.begin()-1;
		T.add(i+1,ub,nv);

		int lb = upper_bound(ALL(f),MP(f[i].first-d,INF))-f.begin();

		T.add(lb,i-1,nv);
	}

	/*FOR(i,0,N)
	{
		cerr<<i<<":"<<endl;
		FOR(j,0,SZ(g[i]))cerr<<g[i][j]<<" ";
		cerr<<endl;
	}*/

	FILL(us,0);
	tops.clear();
	FOR(i,0,N)
	if(!us[i])dfs1(i);

	FILL(us,0);

	reverse(ALL(tops));
	int ind = 0;
	FOR(i,0,N)
	{
		int v=tops[i];
		if(!us[v])dfs2(v,ind++);
	}

	FOR(i,0,n)if(cInd[i]==cInd[i+n])return false;

	return true;

}
int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);

	cin>>n;
	FOR(i,0,n)
	{
		int a,b;
		cin>>a>>b;
		f.PB(MP(a,i));
		f.PB(MP(b,i+n));
	}

	sort(ALL(f));

	//cout<<ok(2);
	int l=0,r=1000000001;

	while(l+1<r)
	{
		int x = (l+r)/2;
		if(ok(x))l=x;
		else r=x;
	}

	cout<<l;
}



Measured memory_bytes: 23928
def main():
    #import sys
    #input = sys.stdin.readline
    K = int(input())
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(A[K-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		boolean b = true;
		for (int i = 0; i < s.length; i++) {
			if (i % 2 != 0) {
				if (s[i] == 'R') {
					b = false;
					break;
				}
			} else if (i % 2 == 0) {
				if (s[i] == 'L') {
					b = false;
					break;
				}
			}
		}
		if (b) {
			sb.append("Yes");
		} else {
			sb.append("No");
		}
		System.out.println(sb);
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<ll> L(N+1);
  L.at(0) = 2;
  L.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }
  
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
while True:
    n=str(input())
    if n=='-':
        break
    N=len(n)
    n_list=list(n)
    m=int(input())
    for i in range(m):
        h=int(input())
        for j in range(h):
            A=n_list[0]
            n_list.remove(n_list[0])
            n_list.append(A)
    C=''.join(n_list)
    print(C)


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

using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define pb push_back;
#define mp make_pair;
#define fi first;
#define se second;

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1 << 29;
const int MOD = 1e9 + 7;

bool check(string &s){
  int i = 0;
  for(auto c : s){
    i++;
    if(i % 2 != 0 && c == 'L') return false;
    if(i % 2 == 0 && c == 'R') return false;
  }
  return true;
}

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

  puts(check(s) ? "Yes": "No");
}


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

int main() {

  ll x;
  cin >> x;

  ll ans = 0;
  ll md;

  // 500
  ans += ( x / 500) * 1000;
  md = x % 500;
  // 5
  ans += (md / 5) * 5;

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
        else if(a>b){
            printf("a > b\n");
        }   
            else{
                printf("a == b\n");
            }
        
    
    return 0;
}


Measured memory_bytes: 2108
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> v(H, vector<int>(W, 1));
    int x, y, a;
    int s, e;
    rep(i, N) {
        cin >> x >> y >> a;
        if (a == 1 || a == 2) {
            if (a == 1) {
                s = 0;
                e = x;
            } else {
                s = x;
                e = W;
            }
            rep(j, H) {
                FOR(k, s, e) {
                    v[j][k] = 0;
                }
            }
        } else {
            if (a == 3) {
                s = 0;
                e = y ;
            } else {
                s = y;
                e = H ;
            }
            FOR(j, s, e) {
                rep(k, W) {
                    v[j][k] = 0;
                }
            }
        }
//        rep(j,H){
//            rep(k,W){
//                cout << v[j][k];
//            }cout<<endl;
//        }
    }

    int sum = 0;
    rep(i, H) rep(j, W) sum += v[i][j];
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const int N = 1100000;
int vis[2010][2010];


int main()
{
    int s1, e1, s2, e2;
    scanf("%d %d %d %d", &s1, &e1, &s2, &e2);
    for(int i=1;i<=(e2-e1);i++) printf("U");
    for(int i=1;i<=(s2-s1);i++) printf("R");
    for(int i=1;i<=(e2-e1);i++) printf("D");
    for(int i=1;i<=(s2-s1);i++) printf("L");

    printf("L");
    for(int i=1;i<=(e2-e1)+1;i++) printf("U");
    for(int i=1;i<=(s2-s1)+1;i++) printf("R");
    printf("D");

    printf("R");
    for(int i=1;i<=(e2-e1)+1;i++) printf("D");
    for(int i=1;i<=(s2-s1)+1;i++) printf("L");
    printf("U\n");
    return 0;
}
















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int fabs(int n){
    if(n<0)return -n;
    return n;
}
signed  main(){
    //int n,k;cin>>n>>k;
    int n;cin>>n;
    vector<int>v(n+1,0);
    
    for(int i=1;i<=n;++i){cin>>v[i];v[i]+=v[i-1];}
    int ans=1e18+3;
    for(int i=1;i<n;++i){
        ans=min(ans,fabs(v[i]-(v[n]-v[i])));
    }
                cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
ma = max(a)
a = a[:a.index(ma)] + a[a.index(ma)+1:]
l = []
for i in range(n-1):
    l.append([abs(ma-2*a[i]), "-" if ma-2*a[i] >= 0 else "+"])
l.sort()
print(ma,end=" ")
print((ma-l[0][0])//2) if l[0][1] == "-" else print((ma+l[0][0])//2)

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll x;
	cin >> x;
	ll a = x / 11;
	ll b = x % 11;
	if (b == 0) {
		cout << 2 * a << endl;
	} else if (b <= 6) {
		cout << 2 * a + 1 << endl;
	} else {
		cout << 2 * (a + 1) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
    	char buff[20];
    	memset(buff, 0, sizeof(buff));
    	scanf("%s", buff);
    	int ans = 0;
    	int t = 0;
    	for (int i = 0; i < strlen(buff); i++) {
    		ans = max(ans, t + (buff[i] - '1') + (int)(strlen(buff) - i - 1) * 9);
    		t += buff[i] - '0';
    	}
    	printf("%d\n", max(ans, t));
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<sstream>
#include<set>
#include<list>
#define ll long long
#define ull unsigned long long
#define op std::ios::sync_with_stdio(false); std::cin.tie(0);
const int INF = 0x3f3f3f3f;
const int maxn = (100000 + 10);
const int mod = (1e9+7);
int main()
{
    int n,k,h;
    int cnt=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&h);
        if(h>=k) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>

using namespace std;

#define fs first
#define sc second

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

const ll mod = 1e9+7;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll dp[3010][3010];

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

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i <= N-1; i++){
        dp[0][i] = 1;
    }

    for(int i = 0; i < N-1; i++){
        if(s[i] == '<'){
            for(int j = 0; N-i-j-1 > 0; j++){
                dp[i+1][j] = dp[i][j];
            }
            for(int j = 1; j <= N-i-2; j++){
                dp[i+1][j] = add(dp[i+1][j], dp[i+1][j-1]);
            }
        }
        else{
            for(int j = 1; N-i-j-1 >= 0; j++){
                dp[i+1][j-1] = dp[i][j];
            }
            for(int j = N-i-3; j >= 0; j--){
                dp[i+1][j] = add(dp[i+1][j], dp[i+1][j+1]);
            }
        }
    }

    cout << dp[N-1][0] << endl;


    return 0;
}

Measured memory_bytes: 71936
import math
n=input()
s=input()

def f(b,n):
	if n<b:
		return n
	elif n>=b:
		return f(b, math.floor(n/b))+n%b

if s==n:
	print n+1
	quit()


# 2 <= b <= sqrt(n)
n_sqrt=int(math.sqrt(n))
for i in range(2, n_sqrt+1):
	if f(i,n)==s:
		print i
		quit()



# sqrt(n) < b <= n
# yakusuu
l=[]
for i in range(1, n_sqrt+1):
	if (n-s)%i==0:
		l.append(i)
		l.append((n-s)/i)
l.sort()

for i in l:
	b=i+1
	if b**2<=n:
		continue
	p=n/b
	q=n%b
	if p+q==s:
		print b
		quit()

print -1
	
	

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

#if 0
array<array<int, 2048>, 2048> nCr_dp;
ll nCr(ll n, ll r, ll mod = 1e9 + 7)
{
    if (nCr_dp[0][0] == 0) {
        nCr_dp[0][0] = 1;
        for (ll i = 1; i < 2048; i++) {
            nCr_dp[i][0] = 1;
            for (ll j = 1; j <= i; j++) {
                nCr_dp[i][j] = (nCr_dp[i - 1][j] + nCr_dp[i - 1][j - 1]) % mod;
            }
        }
    }
    return nCr_dp[n][r];
}
#endif

constexpr ll powm(ll x, ll y, ll mod = 1e9 + 7)
{
    ll ans = 1;
    while (y > 0) {
        if (y % 2) {
            ans = (ans * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}

constexpr ll nCr(ll n, ll r, ll mod = 1e9 + 7)
{
    auto min_r = min(r, n - r);
    ll x = 1;
    for (ll i = 0; i < min_r; i++) {
        x *= n - i;
        x %= mod;
    }
    ll y = 1;
    for (ll i = 0; i < min_r; i++) {
        y *= i + 1;
        y %= mod;
    }

    x *= powm(y, mod - 2, mod);
    return x % mod;
}

void main_()
{
    ll N, K;
    cin >> N >> K;

    const ll MOD = 1e9 + 7;

    for (ll i = 1; i <= K; i++) {
        if (i <= N - K + 1) {
            cout << (nCr(N - K + 1, i, MOD) * nCr(K - 1, i - 1, MOD)) % MOD << "\n";
        } else {
            cout << 0 << "\n";
        }
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int tei[31] = {0}, i, hikaku = 1, j = 0, k;
	
	for(i = 0; i < 28; i ++){
		cin >> k;
		tei[k] = 1;
	}
	for(i = 1; i <= 30; i ++){
		if(tei[i] != 1){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n;
  double x[3],y[3];
  cin >> n;
  for(int i=0;i<n;i++){
    for(int i=0;i<3;i++) cin >> x[i] >> y[i];
    double a1 = 2 * (x[1] - x[0]);
    double b1 = 2 * (y[1] - y[0]);
    double c1 = x[0] * x[0] - x[1] * x[1] + y[0] * y[0] - y[1] * y[1];
    double a2 = 2 * (x[2] - x[0]);
    double b2 = 2 * (y[2] - y[0]);
    double c2 =  x[0] * x[0] - x[2] * x[2] + y[0] * y[0] - y[2] * y[2];
    double ansx = (b1*c2-b2*c1)/(a1*b2-a2*b1);
    double ansy = (c1*a2-c2*a1)/(a1*b2-a2*b1);
    double ans = sqrt((ansx-x[0])*(ansx-x[0])+(ansy-y[0])*(ansy-y[0]));
    cout << fixed << setprecision(3) << ansx << ' ' << ansy << ' ' << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
from collections import Counter
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
d = Counter(d)
t = Counter(t)
f = 1
for a,b in t.items():
    if d[a] < b:
        f = 0
        break
print("YES" if f else "NO")

Measured memory_bytes: 127572
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int p, q, r, result;
    string s;
    cin >> s;
    bool flag = true;

    for (int i = 0; i < 3; i++)
    {
      if (s.at(i) == s.at(i+1)){
            flag = false;
      }
    }

    if (flag)
        cout << "Good" << endl;
    else
    {
        cout << "Bad" << endl;
    }
}


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

using namespace std;
using ll = long long;

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

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
    int a = 0;
    int b = 0;

    cin >> a >> b;

    int k = (a + b) / 2;

    if ( abs(a-k) == abs(b-k)) {
        cout << k << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


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

int main () {
	int k;
	char a[100];
	scanf("%d", &k);
	scanf("%s", a);
	if (strlen(a) <= k) {
		printf("%s", a);
	} else{
		for (int i = 0; i < k; i++) {
			printf("%c", a[i]);
		}
		printf("...");
	}
	
	return 0;
	
}

Measured memory_bytes: 1696
h, w = gets.split.map(&:to_i)
a = h.times.map { gets.chomp }
(w - 1).downto(0) do |j|
  flag = false
  for i in 0...h do
    if a[i][j] == "#"
      flag = true
      break
    end
  end
  if !flag
    for i in 0...h do
      a[i].slice!(j)
    end
  end
end
for i in 0...h do
  puts a[i] if a[i].include?("#")
end


Measured memory_bytes: 1788
/*input
1 100 1

*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 1e5+100;
typedef long long int lld;
typedef long long ll;


ll A[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,val,countA,indicator=0,pos,h,minA,maxA,type;
    ans=0;
    cin>>l>>r>>d;
    for(int i=d;i<=100;i+=d) {
        if(i>=l and i<=r) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
from sys import stdin

EPS = 1e-10

class Vector:
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, k):
        return Vector(self.x * k, self.y * k)

    def __gt__(self, other):
        return self.x > other.x and self.y > other.yb

    def __lt__(self, other):
        return self.x < other.x and self.y < other.yb

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    # usually cross operation return Vector but it returns scalor
    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

class Point(Vector):
    def __init__(self, *args, **kargs):
        return super().__init__(*args, **kargs)

class Segment:
    def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
        self.p1 = p1
        self.p2 = p2

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if a.cross(b) > EPS:
        return 1
    elif a.cross(b) < -EPS:
        return -1
    elif a.dot(b) < -EPS:
        return 2
    elif a.norm() < b.norm():
        return -2
    else:
        return 0

def intersect(p0, p1, p2, p3):
    return (ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 and
                ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0)

def read_and_print_results(n):
    for _ in range(n):
        line = stdin.readline().strip().split()
        p0 = Vector(int(line[0]), int(line[1]))
        p1 = Vector(int(line[2]), int(line[3]))
        p2 = Vector(int(line[4]), int(line[5]))
        p3 = Vector(int(line[6]), int(line[7]))
        if intersect(p0, p1, p2, p3):
            print(1)
        else:
            print(0)

n = int(input())
read_and_print_results(n)


Measured memory_bytes: 5772
from collections import Counter
import numpy as np
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
n, m = map(int, input().split())
lst = list(map(int, input().split()))
blst = [0]
total = 0
for i in range(n):
    total += lst[i]
    blst.append(total)
modblst = np.array(blst)%m
count = Counter(modblst)

ans = 0
for val in count.values():
    if val == 1:
        continue
    ans += cmb(val, 2)
print(ans)

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

int main(void){
  int N; cin >> N;
  vector<long long> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end());
  
  long long res = 0;
  
  for (int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
      int k = lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin();
      res += max(k-(j+1), 0);
    }
  }
  cout << res << endl;
  return 0;
}

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

pair<int, int> ad(pair<int, int> p, int v){
    p.first += v;
    return p;
}
int ad(int a, int v){
    return a+v;
}

template<typename T>
struct StarrySky {
    int n, n_org;
    T e;
    vector<T> dat;
    vector<int> added;
    typedef function<T(T a, T b)> Func;
    Func f;
 
    StarrySky(){}
    StarrySky(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        n_org = n_input;
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.assign(2*n-1, e);
        added.assign(2*n-1, 0);
    }
 
    void build(vector<T>& A){
        for(int k=0; k<int(A.size()); k++) dat[k+n-1] = A[k];
        for(int k=n-2; k>=0; k--) dat[k] = f(dat[2*k+1], dat[2*k+2]);
    }
 
    void add_between(int a, int b, int x){
        add(a, b+1, x, 0, 0, n);
    }
 
    void add(int a, int b, int x, int k, int lb, int rb){
        if(b <= lb || rb <= a) return;
        if(a <= lb && rb <= b){
            added[k] += x;
        }else{
            int mb = (lb+rb)>>1;
            add(a, b, x, 2*k+1, lb, mb);
            add(a, b, x, 2*k+2, mb, rb);
            dat[k] = f(ad(dat[2*k+1], added[2*k+1]), ad(dat[2*k+2], added[2*k+2]));
        }
    }
 
    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }
 
    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return ad(dat[k], added[k]);
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return ad(f(vl, vr), added[k]);
    }
};

int main(){
    string str;
    cin >> str;
    int N = str.size();

    vector<int> Q;
    vector<int> SS(N+1);
    for(int i=0; i<N; i++){
        SS[i+1] = SS[i] + (str[i] == '1' ? 1 : -1);
        if(str[i] == '?') Q.push_back(i);
    }
    int MX = *max_element(SS.begin(), SS.end());
    int ans = 1e9;

    for(int mx=MX; mx<=MX+2; mx++){
        auto S = SS;
        StarrySky<int> stmax(N+1, [](int a, int b){ return max(a, b); }, -1e9);
        stmax.build(S);
        vector<int> added(N+1);
        for(int i : Q){
            int now = stmax.between(i+1, N);
            if(now+2 <= mx){
                added[i+1] += 2;
                stmax.add_between(i+1, N, 2);
            }
        }
        int mn = 0;
        for(int i=1; i<=N; i++){
            added[i] += added[i-1];
            mn = min(mn, S[i] + added[i]);
        }
        ans = min(ans, mx-mn);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 37176
#include <bits/stdc++.h>
#include <string>
#include <array>

using namespace std;

int main(){
	
	
	
	int a, b, c, x, y, z;
	
	cin >> x >> y >> z;
	
	a = x;
	b = y;
	c = z;
	
	b = a;
	a = y;
	
	c = a;
	a = z;
	
	cout <<  a << " " << b << " " << c;
	

}


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

using namespace std;

int paint(vector< vector<int> > &field, int x, int y, int c){
	int W = field[0].size(), H = field.size();
	if(x < 0 || x >= W || y < 0 || y >= H || field[y][x] != c){ return 0; }
	field[y][x] = -1;
	int count = 1;
	count += paint(field, x - 1, y, c);
	count += paint(field, x + 1, y, c);
	count += paint(field, x, y - 1, c);
	count += paint(field, x, y + 1, c);
	return count;
}

int solve(vector< vector<int> > field, int c, int depth = 4){
	int W = field[0].size(), H = field.size();
	int result = 0, prev = field[0][0];
	if(depth == 0){
		paint(field, 0, 0, prev);
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				if(field[i][j] < 0){ field[i][j] = c; }
			}
		}
		result = paint(field, 0, 0, c);
	}else{
		for(int i = 1; i <= 6; ++i){
			if(i == prev){ continue; }
			vector< vector<int> > next = field;
			paint(next, 0, 0, prev);
			for(int j = 0; j < H; ++j){
				for(int k = 0; k < W; ++k){
					if(next[j][k] < 0){ next[j][k] = i; }
				}
			}
			result = max(result, solve(next, c, depth - 1));
		}
	}
	return result;
}

int main(){
	while(true){
		int h, w, c;
		cin >> h >> w >> c;
		if(h == 0 && w == 0 && c == 0){ break; }
		vector< vector<int> > p(h, vector<int>(w));
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){ cin >> p[i][j]; }
		}
		cout << solve(p, c) << endl;
	}
	return 0;
}

Measured memory_bytes: 920
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

/*
1. minv = R[0]
2. for j が 1 から n-1 まで
    maxv = max(maxv, R[j] - minv)
    minv = min(minv, R[j])
*/

int main(){
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main() {
  int coinA_500 ;
  int coinB_100 ; 
  int coinC_50  ; 
  int total     ;
  int count = 0;
  
  cin >> coinA_500;
  cin >> coinB_100;
  cin >> coinC_50;
  cin >> total;
  
  for(int A = 0; A <= coinA_500; A++){
    for(int B = 0; B <= coinB_100; B++){
      for(int C = 0; C <= coinC_50; C++){
        if(500*A + 100*B + 50*C == total){
          count++;
        }
      }
    }
  }
//  cout << "count :" + to_string(count) << endl;
  cout << count << endl;
}

Measured memory_bytes: 256
S = list(input())
n = int(input())

for _ in range(n):
    O = input().split()
    o = O[0]
    a = int(O[1])
    b = int(O[2])
    if o == 'print':
        print(''.join(S[a:b+1]))
    elif o == 'replace':
        S[a:b+1] = list(O[3])
    elif o == 'reverse':
        S[a:b+1] = reversed(S[a:b+1])


Measured memory_bytes: 5620
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const ll INF = 1e10;
ll dp[105][100005];
int main() {
	int n, W;
	cin >> n >> W;
	vector<ll>w(n), v(n);
	rep(i, n+1)rep(j, 100001)dp[i][j] = INF;
	rep(i, n) {
		cin >> w[i] >> v[i];
	}
	dp[0][0] = 0;
	rep(i, n+1)rep(j, 100001) {
		//cout << i << endl;
		if (i == 0)continue;
		if (j - v[i-1] < 0) {
			dp[i][j] = dp[i - 1][j];
		}
		else {
			dp[i][j] = min(dp[i - 1][j - v[i-1]] + w[i-1], dp[i - 1][j]);
		}
	}
	//cout << 1;
	ll ans = INF;
	ll l = 100000;
	while (1) {
		if (dp[n][l] <= W) {
			//cout << dp[n][l];
			cout << l;
			return 0;
		}
		--l;
	}
	return 0;
}

Measured memory_bytes: 82556
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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


    int N, M;
    cin >> N >> M;

    vector<pair<long long, int>> drink(N);
    for (int i = 0; i < N; ++i) cin >> drink[i].first >> drink[i].second;
    sort(drink.begin(), drink.end());

    long long ans = 0;
    int shop = 0;
    while (M > 0) {
        if (M > drink[shop].second) {
            ans += drink[shop].first * drink[shop].second;
            M -= drink[shop].second;
            ++shop;
        } else {
            ans += drink[shop].first * M;
            M = 0;
        }
    }

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


Measured memory_bytes: 1792
n=int(input())
h=list(map(int,input().split()))
ans=0
while h!=[0]*n:
  b=(h[0]!=0)+0
  for i in range(n):
    if b==1 and h[i]==0:ans+=1;b=0
    if h[i]!=0:h[i]-=1;b=1
  if b==1:ans+=1
print(ans)

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 5e5+5;

int main()
{
	init();
	set<int> arr[30];
	int n, q;
	string str;
	cin >> n >> str >> q;
	for(int i = 0; i < n; ++i){
		arr[str[i] - 'a'].insert(i);
	}
	for(int i = 0; i < q; ++i){
		int typ, i1, i2;
		char c;
		cin >> typ;
		if(typ == 1){
			cin >> i1 >> c;
			if(str[i1-1] != c){
				arr[str[i1-1] - 'a'].erase(i1-1);
				arr[c - 'a'].insert(i1-1);
				str[i1-1] = c;
			}
		}
		else{
			cin >> i1 >> i2;
			int ans = 0;
			for(int j = 0; j < 26; ++j){
				set<int>::iterator it = arr[j].lower_bound(i1-1);
				if((it != arr[j].end()) && ((*it) < i2)){
					++ans;
//					cout << (char)(j+'a') << endl;
				}
			}
			cout << ans << "\n";
		}
	}
	return 0;
}


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

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

  cout << (H - h) * (W - w) << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#define MAX 2000005

int n,A[MAX],B[MAX];
void CountingSort(void){
  int i,j,C[MAX];
  for(i=0;i<MAX;i++){
   C[i]=0;
  }
  for(j=1;j<=n;j++){

    C[A[j]]++;
  }
  for(i=1;i<=MAX;i++){
    C[i]=C[i]+C[i-1];
  } 
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}
int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  CountingSort();
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
 }
  printf("%d\n",B[n]);



  return 0;
}



Measured memory_bytes: 25156
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int money = sc.nextInt();
		int cakePrice = sc.nextInt();
		int donutPrice = sc.nextInt();

		int result = getBuyingSweetsResult(money, cakePrice, donutPrice);
		System.out.println(result);
	}

	public static void TestBuyingSweets() {
		System.out.println(getBuyingSweetsResult(1234, 150, 100)); // 84
		System.out.println(getBuyingSweetsResult(1000, 108, 108)); // 28
		System.out.println(getBuyingSweetsResult(579, 123, 456)); // 0
	}

	public static int getBuyingSweetsResult(int money, int cakePrice, int donutPrice) {
		return (money - cakePrice) % donutPrice;
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    sort(all(s));
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


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

void CountingSort(int A[], int n, int B[], int k){
    int C[k+1];
    for(int i=0; i<=k; i++)
        C[i] = 0;
    for(int i=0; i<n; i++)
        C[A[i]]++;
    for(int i=1; i<=k; i++)
        C[i] = C[i] + C[i-1];
    
    int x=0;
    if(C[0]!=0){
        int y=C[0];
        while(y!=0){
            B[x] = 0;
            x++;
            y--;
        }
    }
    for(int i=1; i<=k; i++){
        if(C[i]-C[i-1]!=0){
            int y=C[i]-C[i-1];
            while(y!=0){
                B[x] = i;
                x++;
                y--;
            }
        }    
    }
}

void printArray(int A[], int n){
    for(int i=0; i<n-1; i++)
        printf("%d ",A[i]);
    printf("%d",A[n-1]);
    printf("\n");
}

int main(){
    int n;
    scanf("%d",&n);
    int A[n], B[n];
    int max=0;
    for(int i=0; i<n; i++){
        scanf("%d",&A[i]);
        if(max < A[i])
            max = A[i];
    }
    CountingSort(A,n,B,max);
    printArray(B,n);
    
    return 0;
}


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

int main(){
  int h, w, i, j;
  int count = 0;
  char tmp[10];
  // char tmp;

  scanf("%d %d", &h, &w);

  char s[h][w]; // [rows][columns]
  for(j = 0; j < h; j++){
    scanf("%s", &s[j][0]);
  }

  printf(" \n");
  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      count = 0;
      if(s[i][j] == '.'){
        if(i >= 1 && j >= 1 && s[i - 1][j - 1] == '#')count++; // upper left
        if(i >= 1 && s[i - 1][j] == '#')count++; // upper middle
        if(i >= 1 && j <= w - 2 && s[i - 1][j + 1] == '#')count++; // upper right
        if(j >= 1 && s[i][j - 1] == '#')count++; // middle left
        if(j <= w - 2 && s[i][j + 1] == '#')count++; // middle right
        if(i <= h - 2 && j >= 1 && s[i + 1][j - 1] == '#')count++; // lower left
        if(i <= h - 2 && s[i + 1][j] == '#')count++; // lower middle
        if(i <= h - 2 && j <= w - 2 && s[i + 1][j + 1] == '#')count++; // lower right
        sprintf(tmp, "%d", count);
        printf("%s", tmp);
        continue;
      }
      printf("%c", s[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 128
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t n;
  cin >> n;
  string s;
  cin >> s;
  int64_t count=0;
//  int64_t testcount=0;
  int c = 0;
  int sa = 0;
  for(int a=0; a<=n-3; a++){
    for(int b=a+1; b<=n-2; b++){
      sa = b - a;
      if(b + sa < n){
        if(s.at(a)!=s.at(b) && s.at(b)!=s.at(b+sa) && s.at(b+sa)!=s.at(a)) count++;
      }
    }
  }
  int64_t Rcount=0;
  int64_t Gcount=0;
  int64_t Bcount=0;
  rep(i,n) if(s.at(i)=='R') Rcount++;
  rep(i,n) if(s.at(i)=='G') Gcount++;
  rep(i,n) if(s.at(i)=='B') Bcount++;
//  cout << Rcount << endl;
//  cout << Gcount << endl;
//  cout << Bcount << endl;
  int64_t num = Rcount * Gcount * Bcount;
//  cout << num << endl;
//  cout << count << endl;
  cout << num - count << endl;
//  cout << testcount <<endl;
}

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

int main()
{
  ll n;
  cin >> n;
  vector<ll> p(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> p[i];
  }

  ll minn = 1e5 * 2;
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (minn >= p[i])
    {
      ans++;
    }
    minn = min(minn, p[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4836
def op(x):
    return '+' if x==0 else '-'
# -*- coding: utf-8 -*-
N = int(input())
a=N//1000
b=N%1000//100
c=N%100//10
d=N%10
for i in range(2**3):
    total=0
    for j,num in zip(range(3),[b,c,d]):
        if (i>>j)&1==0:
            total+=num
        else:
            total-=num
    if a+total==7:
        print('{}{}{}{}{}{}{}=7'.format(a,op(i>>0&1),b,op(i>>1&1),c,op(i>>2&1),d))
        break


Measured memory_bytes: 3064
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int n;
  while (true) {
    cin >> n;
    if (!n) break;
    vector<int> a(n);
    vector<int> sub_sum(n+1); // a[0] + ... + a[i]
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sub_sum[0] = 0;
    int max_sum = -1000000000;
    for (int i = 0; i <= n; i++) {
      sub_sum[i] = sub_sum[i-1] + a[i-1];
    }
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j < i; j++) {
        max_sum = max(max_sum, sub_sum[i] - sub_sum[j]);
      }
    }
    cout << max_sum << endl;
  }
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

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

    string s;
    cin >> s;

    int max_count = 0;
    for (int i = 1; i < n - 1; ++i) {
        int count = 0;
        map<char, int> m;

        for (int j = 0; j < i; ++j) {      // left side
            for (int k = i; k < n; ++k) {  // right side
                if (m.find(s[j]) == m.end() && s[j] == s[k]) {
                    ++count;
                    m.insert(make_pair(s[j], 1));
                    break;
                }
            }
        }
        max_count = max(max_count, count);
    }
    cout << max_count << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N;
    cin >> N;

    int64_t power = 1;
    for(int i = 1; i <= N; i++){
        power *= i;
        power %= mod;
    }

    cout << power << endl;

    return 0;
}

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

/*
struct Edge
{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll A = 1; A <= 1000; A++)
    {
        for (ll B = A; B <= 1000000; B++)
        {
            if (A * B > 1000000)
                continue;
            ll C = N - A * B;
            if (C >= 1)
            {
                if (A != B)
                    ans += 2;
                else
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

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

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

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 4;

ll w, h;
ll q[N], p[N];

void read() {
    cin >> w >> h;
    for (int i = 0; i < w; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < h; ++i) {
        cin >> q[i];
    }
}

void calc() {
    ll res = 0;
    ll v = 0, g = 0;
    sort(p, p + w);
    sort(q, q + h);

    int ip = 0, iq = 0;
    while (ip < w || iq < h) {
        ll pcost = (ip == w ? 1e18 : p[ip]);
        ll qcost = (iq == h ? 1e18 : q[iq]);

        if (pcost < qcost) {
            res += (h + 1 - g) * pcost;
            ++v;
            ++ip;
        } else {
            res += (w + 1 - v) * qcost;
            ++g;
            ++iq;
        }
    }
    cout << res << "\n";
}

void solve() {
    read();
    calc();
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 5220
import java.util.*;

class Main{
    public static void main(String[]args){
        String result;
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        if(a+b>=c){
            result = "Yes";
        }
        else{
            result = "No";
        }
        System.out.print(result);
    }
}

Measured memory_bytes: 23636
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <vector>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long ll;

const int MAXN=200000+10;
int a[MAXN];

int main()
{
    int n;
    ll minn=0,x=0,y=0,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    /*for(int i=0;i<n;i++)
        cout<<a[i]<<endl;*/
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
        minn+=abs(a[i]);
    }
    //cout<<sum<<endl;
    for(int i=0;i<n-1;i++)
    {
        x+=a[i];//cout<<x<<endl;
        y=sum-x;//cout<<y<<endl;
        if(x-y<0)
        {
            if(minn>y-x)minn=y-x;
        }
        else if(x-y>=0)
        {
            if(minn>x-y)minn=x-y;
        }
    }
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}



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

  ll A, B , C ; cin >> A >> B >> C;
  if( (A%2 == 1 ) && (B%2 == 1 ) && (C%2 == 1 ) ){
    cout << min( min(A*B, A*C), B*C) << endl;
  }
  else cout << 0 << endl;
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int A, B; scanf("%d%d", &A, &B);
	printf("%d", (B - 1 + (A-2)) / (A - 1));

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long age = sc.nextLong();
		if(age == 3 || age == 5 || age == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 21844
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""

N = int(input())

if N%2 == 1:
	print(0)
else:
	ans = 0
	N = N//10
	ans += N
	while N > 1:
		ans += N//5
		N = N//5
	print(ans)

Measured memory_bytes: 4080
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))

bad=[]
for i in range(M):
	A,B=list(map(int,input().split()))
	if (H[A-1]<=H[B-1])and(A-1 not in bad): bad.append(A-1)
	if (H[A-1]>=H[B-1])and(B-1 not in bad): bad.append(B-1)

print(N-len(bad))

Measured memory_bytes: 85540