akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

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

	void run() {
		for (;;) {

			int n = sc.nextInt();
			int m = sc.nextInt();
			int p = sc.nextInt();
			if ((n | m | p) == 0) {
				break;
			}

			n += 2;
			int map[][][] = new int[n][n][n];
			String res = "Draw";

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j][0] = -1;
					map[i][j][n - 1] = -1;
					map[i][0][j] = -1;
					map[i][n - 1][j] = -1;
					map[0][i][j] = -1;
					map[n - 1][i][j] = -1;
				}
			}
			boolean ok = false;
			for (int i = 0; i < p; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int z = 1;
				for (;; z++) {
					if (map[x][y][z] == 0) {
						map[x][y][z] = (i & 1) + 1;
						break;
					}
				}

				if (ok) {
					continue;
				}

				for (int j = 0; j < 13; j++) {
					int xx = x;
					int yy = y;
					int zz = z;
					int cnt = 0;
					for (;;) {
						xx -= dx[j];
						yy -= dy[j];
						zz -= dz[j];

						if (map[xx][yy][zz] != (i & 1) + 1) {
							break;
						}
					}
					for (;;) {
						xx += dx[j];
						yy += dy[j];
						zz += dz[j];

						if (map[xx][yy][zz] != (i & 1) + 1) {
							break;
						}
						cnt++;
						if (cnt >= m) {
							break;
						}
					}

					if (cnt >= m) {
						res = (((i & 1) == 1 ? "White" : "Black") + " " + (i + 1));
						j = 1000;
						ok = true;
					}
				}
			}
			System.out.println(res);
		}

	}

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

Measured memory_bytes: 12000
(defun f (p)
  (concatenate 'list (write-to-string p)))


(defun g (lst)
  (if (and (char= (car lst) (car (reverse lst)))
           (char= (cadr lst) (cadr (reverse lst))))
    t
    nil))


(let ((a (read))
      (b (read)))

  (format t "~A~%"
          (loop for i from a to b
                when (g (f i))
                count i)))



Measured memory_bytes: 44712
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(n):
  p[i] = (p[i] + 1)/2
  
a = sum(p[:k])
s = a

for i in range(n-k):
  a = a - p[i] + p[i+k]
  if s < a:
    s = a
  
print(s)

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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[2001][2001];
ll check(vector<pair<ll,ll> >v,ll l,ll r,ll i)
{ 
   //cout<<l<<" "<<r<<endl;
   if(l>r)
    return 0; 
   if(dp[l][r]!=-1)
    return dp[l][r]; 
   ll ans=0;
   ll p1=v[i].first;
   ll p2=v[i].second;
   ans=max(p1*(p2-l)+check(v,l+1,r,i+1),p1*(r-p2)+check(v,l,r-1,i+1));
   return dp[l][r]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
       ll x;
       cin>>x;
       ll p=x/500;
       x=x%500;
       ll p1=x/5;
       cout<<p*1000+p1*5;
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

long gcd(long m, long n);
long lcm(long m, long n);

int main( void ){

	int a, b;
	int ans = 0;
	cin >> a >> b;
	if( a >=13 ) ans = b;
	else if ( a >= 6 ) ans = b/2;

	cout << ans;
	return 0;

}

//最大公倍数
long gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
long lcm(long m, long n)
{
	return m * n / gcd(m,n); 
}

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

using namespace std;

#pragma GCC optimize("-O3")
#pragma GCC target("avx2")

#define int long long

const int INF = 1e18;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int i = 2;
    int ans = 0;
    while (i * i <= n)
    {
        int cnt = 0;
        while (n % i == 0)
        {
            n /= i;
            ++cnt;
        }
        int p = 1;
        while (cnt >= p)
        {
            cnt -= p;
            ++p;
            ++ans;
        }
        ++i;
    }
    if (n > 1)
    {
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int i,j;
  int key;
  int n;
  int *array;

  //Initial
  scanf("%d",&n);

  array = (int *)malloc(n * sizeof(int));

  for(i=0;i<n;i++) {
    scanf("%d",&array[i]);
  }
  //printf("\n");

  //sort start
  for(i=0;i<n-1;i++) {
    printf("%d ",array[i]);
  }
  printf("%d\n",array[n-1]);

  for(j=1;j<n;j++) {
    key = array[j];
    i=j-1;
    for(i=j-1;i>=0;i--) {
      if(array[i+1]<array[i]) {
        array[i+1] = array[i];
        array[i] = key;
      }
    }


    for(i=0;i<n-1;i++) {
      printf("%d ",array[i]);
    }
    printf("%d\n",array[n-1]);
  }
  return 0;
}



Measured memory_bytes: 2136
#include <iostream>
using namespace std;
int main(void){
    int k,s,z,kumachan_Count=0;
    cin>>k>>s;
    for(int x=0; x<=k; x++)
    for(int y=0; y<=k; y++){
        z = s - x - y;
        if(z <= k && 0<=z){
            kumachan_Count++;
        }
    }
    cout << kumachan_Count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include <climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A') s[k-1]='a';
    else if(s[k-1]=='B') s[k-1]='b';
    else if(s[k-1]=='C') s[k-1]='c';
    cout<<s<<endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// long long a ,b;
	// cin>>a>>b;

	string s, t;
	cin >> s >> t;

	ll a = s.length();
	ll b = t.length();



	if (a > b)
	{
		cout << "GREATER" << endl;
	}

	else if (a < b)
	{
		cout << "LESS" << endl;
	}

	else
	{
		loop(i, s.length())
		{
			if (s[i] > t[i])
			{
				cout << "GREATER";
				return 0;
			}

			else
			{
				if (s[i] < t[i])
				{
					cout << "LESS";
					return 0;
				}
			}
		}
		cout<<"EQUAL";
		
	}



}


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

typedef long long ll;

int N, W;
vector<ll> w, v;
vector<ll> DP;

int main()
{
    scanf("%d %d", &N, &W);
    w.assign(N, 0);
    v.assign(N, 0);
    DP.assign(2*W+5, 0);

    ll sol = 0;

    for(int i = 0; i < N; i++) {
        scanf("%d %lld", &w[i], &v[i]);
        for(int j = W; j >= 0; j--) {
            if(j==0 || DP[j] != 0) {
                DP[j+w[i]] = max(DP[j+w[i]], DP[j] + v[i]);
                if(j+w[i] <= W) {
                    sol = max(sol, DP[j+w[i]]);
                }
            }
        }
    }

    printf("%lld\n", sol);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

int main()
{
  int n;
  cin >> n;
  int p = 0;
  int q = 0;
  vector<int> vec;
  rep(i, n)
  {
    int x;
    cin >> x;
    p += x * pow(10, (n - i - 1));
    vec.push_back(i + 1);
  }

  rep(i, n)
  {
    int x;
    cin >> x;
    q += x * pow(10, (n - i - 1));
  }

  vector<int> perms;

  do
  {
    int tmp = 0;
    rep(i, n)
    {
      tmp += vec[i] * pow(10, (n - i - 1));
    }
    perms.push_back(tmp);
  } while (next_permutation(vec.begin(), vec.end()));

  sort(perms.begin(), perms.end());

  int a = find(perms.begin(), perms.end(), p) - vec.begin();
  int b = find(perms.begin(), perms.end(), q) - vec.begin();
  cout << abs(a - b) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef pair<int, int> P;
bool fnc(string str) {
	string tmp = str;
	reverse(tmp.begin(), tmp.end());
	return str.compare(tmp);
}
int main()
{
	string str,ftr,btr;
	cin >> str;
	int n = str.size();
	ftr = str.substr(0, (n - 1) / 2);
	btr = str.substr((n + 3) / 2-1);
	bool ok = true;
	if (fnc(str))ok=false;
	if (fnc(ftr))ok = false;
	if (fnc(btr))ok = false;

	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

map<string, vector<int>> t;
int n, m;

void solve() {
    cin >> n;
    rep(i,n) {
        string str; int d;
        cin >> str >> d;
        t[str].push_back(d);
    }
    for (auto it = t.begin(); it != t.end(); it++) {
        auto& v = (*it).second;
        sort(v.begin(), v.end());
    }
    cin >> m;
    int val = -1;
    rep(i,m) {
        string o; cin >> o;
        int pos = upper_bound(t[o].begin(), t[o].end(), val) - t[o].begin();
        if (pos == t[o].size()) {
            cout << "No" << endl;
            return;
        }
        val = t[o][pos];
    }
    cout << "Yes" << endl;
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    solve();
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}



Measured memory_bytes: 20344
#include <stdio.h>
int main(){
   int n;
   scanf("%d",&n);
   int a[n];
   for(int b=0;b<n;b++){
       scanf("%d",&a[b]);
   }
   int c,d;
   c=0;
    for(int e=0;e<n;e++){if(c<a[e]){c=a[e];d=e;}}
    a[d]=0;
    int h=0;
    for(int g=0;g<n;g++){if(h<a[g]){h=a[g];}}
    for(int f=0;f<n;f++){if(f!=d){printf("%d\n",c);}
                         else{printf("%d\n",h);}
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<ll> v(n);
    read(v);
    ll c = 0;
    for (int i = 2; i < n; i++) c ^= v[i];
    ll a = v[0], b = v[1];
    ll d = a + b - c;
    if (d < 0 || (d & 1LL) || ((d >> 1) & c)) {
        cout << -1 << newl;
        return 0;
    }
    d >>= 1;
    if (d > a) {
        cout << -1 << newl;
        return 0;
    }
    ll na = d;
    for (int i = 61; i >= 0; i--) {
        if (kbit(d, i)) continue;
        if (kbit(c, i)) {
            if (na + (1LL << i) <= a) na += (1LL << i);
        }
    }
    if (na == 0) {
        cout << -1 << newl;
        return 0;
    }
    cout << a - na << newl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
const long long mod=1000000007;
int main()
{
    long long i,j,n,x,h=0,s;
    cin>>n;    
    vector<long long>a,b,c;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        a.push_back(x);
    }
    for(i=1;i<=n;i++)
    {
        cin>>x;
        b.push_back(x);
    }
    s=(n>>1);
    for(i=s;i<n;i++)
    {
        c.push_back(b[i]);
    }
    for(i=0;i<s;i++)
    {
        c.push_back(b[i]);
    }
        h=0;
        for(j=0;j<n;j++)
        {
            if(a[j]==c[j])
            {
                h++;
                break;
            }
        }
        if(h==0)
        {
            cout<<"Yes"<<endl;
            for(j=0;j<n;j++)
            {
                cout<<c[j]<<" ";
            }
            cout<<endl;
        }
        else
        {
            reverse(b.begin(),b.end());
            h=0;
            for(j=0;j<n;j++)
            {
               if(a[j]==b[j])
               {
                   h++;
                   break;
               }
            }
            if(h==0)
            {
                cout<<"Yes"<<endl;
                for(j=0;j<n;j++)
                {
                    cout<<b[j]<<" ";
                }
                cout<<endl;
            }
            else
            {
                cout<<"No"<<endl;
            }
        }
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	map<string, int>mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int mx = 0;
	for (auto p : mp) {
		mx = max(mx, p.second);
	}
	for (auto p : mp) {
		if (p.second != mx) {
			continue;
		}
		cout << p.first << endl;
	}
	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> count(50,0);
    int i=1,ans=0,mx=0;
    for(int i=0;i+1<N;i++){
        for(int j=0;j<=i;j++){
            if(count[s[j]-'a']==0){
                count[s[j]-'a']++;
            }
        }
        for(int j=i+1;j<N;j++){
            if(count[s[j]-'a']==1){
                count[s[j]-'a']++;
                mx++;
            }
        }
        ans = max(ans,mx);
        for(int j=0;j<50;j++){
            count[j]=0;
        }
        mx=0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, h;
ll b[100100], a[100100];
ll bsum, asum;

ll solve(ll hh) {
	if (hh == 0)return 0;
	int res = 0;
	rep(i, n) {
		hh -= b[i];
		res++;
		if (hh <= 0)return res;
	}
}

int main() {
	ll MAX = 0;
	cin >> n >> h;
	rep(i, n) {
		cin >> a[i] >> b[i];
		MAX = max(MAX, a[i]);
	}
	asum = MAX * n;
	rep(i, n) {
		b[i] = max(b[i], MAX);
		bsum += b[i];
	}
	sort(b, b + n);
	reverse(b, b + n);
	ll cnt = 0;
	if (h <= bsum) {
		cnt += solve(h);
	}
	else {
		h -= bsum;
		cnt += n;
		//cout << cnt << endl;
		cnt += max((ll)0, (h / asum))*n;
		//cout << cnt << endl;
		cnt += (h%asum) / MAX + ((h%asum) % MAX != 0);
		//cout << cnt << endl;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1792
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int n;
    cin>>n;
    int a[n];

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

    }


    int now = 0, c = 0;

    while(true)
    {
        if(now == 1)
        {
          cout<<c<<"\n";
          break;
        }
        if(c>=n)
        {
          cout<<"-1\n";
          break;
        }
        c++;
        now = a[now];
    }



    































    return 0;
}


Measured memory_bytes: 640
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int h, w;
    cin >> h >> w;
    char grid[h + 1][w + 1];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> grid[i][j];
        }
    }
    bool ok = true;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(grid[i][j] == '#'){
                if(grid[i - 1][j] != '#' && grid[i][j - 1] != '#' && (i + 1 <= h && grid[i + 1][j] != '#') && (j + 1 <= w && grid[i][j + 1] != '#')){
                    ok &= false;
                }
            }
        }
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(){

  int n,m,x;
  cin >> n >> m >> x;

  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=0;j<m;j++) cin >> a[i][j];
  }

  int num = 0b0000'0000'0000;
  int stop = int(pow(2,n));

  int ans=1200008;
  int nowAns=0;
  vector<int> ar(m,0);
  int okCount=0;


  for(int bit=num;bit<stop;bit++){
    //nこの参考書の01の組み合わせで足してい
    okCount=0;
    nowAns=0;
    for(int t=0;t<m;t++) ar[t]=0;
    //cout << "bit:" << bitset<5>(bit) << endl;
    //参考書jのそれぞれの習熟度を足していく
    for(int j=0;j<n;j++){
      if(bit & (1<<j)){
        //cout << bitset<5>(1<<j) << endl;
        //cout << "入った" << endl;
        nowAns+=c[j];
        for(int k=0;k<m;k++){
          ar[k]+=a[j][k];
        }
      }
    }
    for(int f=0;f<m;f++){
      if(ar[f]>=x) okCount++;
      //cout << ar[f] << ",";
    }//cout << endl;
    //cout << "okCount:" << okCount << endl;
    if(okCount==m){
      //cout << "入った01" << endl;
      ans = min(ans,nowAns);
    }
    //cout << "ans:" << ans << endl << endl;
  }

  if(ans==1200008) cout << "-1" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int cnt;
  int ans = 0;
  string s;
  
  cin >> s;
  
  cnt = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
      ans = max(cnt, ans);
      cnt = 0;
    }else{
      cnt ++;
    }
  }
  
  ans = max(cnt, ans);
  cout << ans << endl;
  return 0;
}



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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100010];
int main()
{
	int n;
	scanf("%d", &n);
	int a = sqrt(2*n);
	int upto = 0;
	if (a * (a+1) == 2*n)
	{
		for (int i = 0; i < a+1; i++)
		{
			for (int j = 0; j < i; j++)
			{
				v[i].push_back(v[j][i-1]);
			}
			while (v[i].size() < a) v[i].push_back(++upto);
		}
		printf("Yes\n%d\n", a+1);

		for (int i = 0; i < a+1; i++)
		{
			printf("%lu ", v[i].size());
			for (auto c : v[i]) printf("%d ", c);
			printf("\n");
		}
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 4608
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))


n = readint()
a = readints()

print('YES'if len(set(a))==len(a)else'NO')

Measured memory_bytes: 76292
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int n;
	double ans=0, x;
	string u;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x >> u;
		if (u == "JPY") ans += x;
		else ans += x * 380000;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H, W;
    int N;
    cin >> H >> W >> N;
    vector<vector<int>> ans(H, vector<int>(W));
    vector<int> count(N);
    for(int i = 0; i < N; i++){
        cin >> count[i];
    }
    int x = 0;
    int y = 0;
    bool dir = true;
    for(int i = 0; i < N; i++){
        int val = i+1;
        for(int l = 0; l < count[i]; l++){
            ans[x][y] = val;
            if(dir){
                x++;
            }else{
                x--;
            }
            if(x==H || x==-1){
                if(dir){
                    x = H-1;
                }else{
                    x = 0;
                }
                dir = !dir;
                y++;
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int l = 0; l < W; l++){
            cout << ans[i][l] << " ";
        }
        cout << "\n";
    }
    return 0;
}

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

void dfs(int node, graph& g, vector<bool>& visited, bool& flag) {
  visited[node] = true;

  if (all_of(visited.begin(), visited.end(), [](auto x) { return x; }))
    flag = true;

  for (auto n : g[node])
    if (!visited[n])
      dfs(n, g, visited, flag);
}

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

  vector<int> a(M), b(M);
  rep(i, M) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  int count = 0;
  rep(i, M) {
    graph to(N);
    rep(j, M) {
      if (i == j)
        continue;
      to[a[j]].push_back(b[j]);
      to[b[j]].push_back(a[j]);
    }

    vector<bool> visited(N);
    bool flag = false;
    dfs(0, to, visited, flag);
    if (!flag)
      count++;
  }
  cout << count << endl;
}

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

using namespace std;

int main(){
	char s;
	int a=0,b=0;
	for(int i=0;i<2;i++){
		cin >> s;
		a=a*10+(int)(s-'0');
	}
	for(int i=0;i<2;i++){
		cin >> s;
		b=b*10+(int)(s-'0');
	}
	
	if(0<a&&a<13){
		if(0<b&&b<13)cout << "AMBIGUOUS";
		else cout << "MMYY";
		}
	else{
		if(0<b&&b<13)cout << "YYMM";
		else cout << "NA";
		}
	
}	

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int a, b;
    cin >> a >> b;

    int ans = -1;
    for(int i = 0; i <= 1000; i++){
        if(floor(i*0.08) == a && floor(i*0.1) == b){
            ans = i;
            break;
        }
    }
    OP(ans);
}


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

vector<vector<int>> g, vis;

void dfs(int x, vector<int> &v) {
  v[x] = 1;
  for (auto to : g[x]) {
    if (v[to])  continue;
    dfs(to, v);
  }
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, m, p;
  cin >> n >> m >> p;

  g.resize(n);
  vis.resize(n);

  vector<pair<pair<int, int>, int>> edges;
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    --u; 
    --v;

    g[u].push_back(v);
    edges.push_back({{u, v}, c - p});
  }

  for (int i = 0; i < n; ++i) {
    vis[i].resize(n, 0);
    dfs(i, vis[i]);
  }

  vector<long long> dist(n, INT_MIN);
  dist[0] = 0;

  for (int i = 0; i < n-1; ++i) {
    for (int j = 0; j < m; ++j) {
      int u = edges[j].first.first, v = edges[j].first.second, w = edges[j].second;
      if (dist[u] + w > dist[v]) {
        dist[v] = dist[u] + w;
      }
    }
  }

  bool poss = 1;
  for (int i = 0; i < m; ++i) {
    int u = edges[i].first.first, v = edges[i].first.second, w = edges[i].second;
    if (dist[u] + w > dist[v]) {
      if (vis[0][u] && vis[v][n-1])
        poss = 0;
    }
  }

  poss &= vis[0][n-1];
  if (!poss) cout << -1 << '\n';
  else cout << max(0ll, dist[n-1]) << '\n';

} 

Measured memory_bytes: 25088
while True:
    s = input()
    if s == ".":
        break
    k = []
    for c in s:
        if c == "(":
            k.append(c)
        elif c == "[":
            k.append(c)
        elif c == ")":
            if k != [] and k[-1] == "(":
                k.pop()
            else:
                print("no")
                break
        elif c == "]":
            if k != [] and k[-1] == "[":
                k.pop()
            else:
                print("no")
                break
    else:
        if k == []:
            print("yes")
        else:
            print("no")


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
int k,s;
cin>>k>>s;
int ans=0;
    for (int i = 0; i <=k; ++i) {
        for (int j = 0; j <=k; ++j) {
            int z=s-i-j;
            if(z>=0&&z<=k)ans++;
        }
    }
    cout<<ans<<endl;
}

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

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

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

    sort(A.begin(), A.end(), greater<int>());
    string ans = "Yes";
    for (int i = 0; i < M; i++) {
        int T;
        if (S % (4 * M) == 0) T = S / (4 * M);
        else T = S / (4 * M) + 1;
    	if (A[i] < T) {
          ans = "No";
          break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define test(a) printf("(%3d)", a)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const int MAXN = 2e5 + 10;

int a[MAXN], n, m;
ll ans;

int main (void) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] -= i;
	}
	sort(a+1,a+n+1);
	m = (1+n)>>1;
	for (int i = 1; i <= n; i++) {
		ans += abs(a[i]-a[m]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
X,N=map(int,input().split())
p=list(map(int,input().split()))

if X not in p:
    print(X)
else:
    for i in range(100):
        if X not in p:
            print()
        if X-1-i not in p:
            print(X-1-i)
            break
        elif X+1+i not in p:
            print(X+1+i)
            break
        i+=1

Measured memory_bytes: 9188
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long li;
template<class T>inline void read(T &x) {
  x = 0;
  T tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') tmp = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + c - '0', c = getchar();
  x *= tmp;
}
template<class T>inline void Max(T &x, T y) {
  if (y > x) x = y;
}
template<class T>inline void Min(T &x, T y) {
  if (y < x) x = y;
}

const int N = 1e5 + 10;
int n;
pair<int, int> a[N];
bool b[N];

priority_queue<pair<int, int> >ql, qr;
li Solve(int cur) {
  li res = 0;
  while (!ql.empty()) ql.pop();
  while (!qr.empty()) qr.pop();
  memset(b, 0, sizeof b);
  for (int i = 0; i < n; ++i) {
    ql.push(mp(a[i].first, i));
    qr.push(mp(-a[i].second, i));
  }
  int loc = 0;
  bool flag = 1;
  while (flag) {
    flag = 0;
    if (cur) {
      while (!ql.empty() && b[ql.top().second]) ql.pop();
      if (!ql.empty() && !b[ql.top().second]) {
	flag = 1;
	int now = ql.top().second;
	ql.pop();
	if (a[now].first <= loc) break;
	res += a[now].first - loc;
	b[now] = 1;
	loc = a[now].first;
      }
    } else {
      while (!qr.empty() && b[qr.top().second]) qr.pop();
      if (!qr.empty() && !b[qr.top().second]) {
	flag = 1;
	int now = qr.top().second;
	qr.pop();
	if (loc <= a[now].second) break;
	res += loc - a[now].second;
	b[now] = 1;
	loc = a[now].second;
      }
    }
    cur ^= 1;
  }
  return res + abs(loc);
}

int main(void) {
  read(n);
  for (int i = 0, x, y; i < n; ++i) {
    read(x), read(y);
    a[i] = mp(x, y);
  }
  li ans = max(Solve(0), Solve(1));
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2932
n,m,q = map(int,input().split())

xs = []
for i in range(q):
    a1,b1,c1,d1 = map(int,input().split())
    xs.append([a1,b1,c1,d1])


cnt = 0
for a in range(1,11):
    for b in range(a,11):
        for c in range(b,11):
            for d in range(c,11):
                for e in range(d,11):
                    for f in range(e,11):
                        for g in range(f,11):
                            for h in range(g,11):
                                for i in range(h,11):
                                    for j in range(i,11):
                                        ass = [a,b,c,d,e,f,g,h,i,j]
                                        if ass[n-1] > m:
                                            break
                                        else:
                                            s = 0
                                            for k in range(q):
                                                if ass[xs[k][1] - 1] - ass[xs[k][0] - 1] == xs[k][2]:
                                                    s += xs[k][3]
                                        if s >= cnt:
                                            cnt = s


print(cnt)


Measured memory_bytes: 9292
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

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<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    vector <int> p(n);
    for (int i = 0; i < n; i++) {
        p[a[i] - 1] = i;
    }
    for (int i = 0; i < n; i++) {
        cout << p[i] + 1 << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 3920
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll sum(n+1,0) ;
	for(int i=0;i<n;i++){
		char c ; cin >> c ;
		sum.at(i+1) = sum.at(i) ;
		sum.at(i+1) += (c=='#') ;
	}
	ll ans = n+10 ;
	for(int i=0;i<=n;i++){
		ll w = sum.at(i) ;
		ll b = n-i-(sum.at(n)-sum.at(i)) ;
		ans = min(ans,w+b) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1792
import bisect
n = int(input())
ans = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
for i in range(n):
    ans += bisect.bisect_left(a,b[i]) * (n-bisect.bisect_right(c,b[i]))
print(ans)

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

int main(void) {
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == b) printf("%d\n", c);
	else if(a == c) printf("%d\n", b);
	else printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define cross(a,b) (conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define vec(a,b) b-a
#define Reka ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

ld ans[3005][3005];
int main()
{
    Reka
    int n;
    cin>>n;
    ld prob[n];
    for(int i=1;i<=n;i++)
    {
        cin>>prob[i];
    }

    ans[1][0] = 1-prob[1];
    ans[1][1] = prob[1];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j<=i)
            {
                ans[i][j] = ans[i-1][j]*(1-prob[i]);
                if(j)
                    ans[i][j]+=ans[i-1][j-1]*prob[i];
            }
            else
                ans[i][j] = 0;
        }
    }
    ld s = 0;
    for(int i =ceil((ld)n/2);i<=n;i++)
        s+=ans[n][i];

    cout<<fixed<<setprecision(12)<<s;


    return 0;
}







Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=305,INF=1<<25;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<int> keta(10,1);
    for(int i=1;i<9;i++) keta[i]=keta[i-1]*10;
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        set<int> SE;
        
        vector<string> S(N);
        for(int i=0;i<N;i++){
            cin>>S[i];
            for(char c:S[i]) SE.insert(c-'A');
        }
        
        vector<int> id(10);
        iota(all(id),0);
        
        vector<int> to(26,-1),T(10,0),ng(10,0);
        int cn=0;
        
        for(auto it=SE.begin();it!=SE.end();it++,cn++){
            to[*it]=cn;
        }
        
        for(int i=0;i<N-1;i++){
            for(int j=0;j<S[i].size();j++){
                if(S[i].size()>=2&&j==0) ng[to[S[i][j]-'A']]=1;
                T[to[S[i][j]-'A']]+=keta[S[i].size()-1-j];
            }
        }
        for(int j=0;j<S[N-1].size();j++){
            if(S[N-1].size()>=2&&j==0) ng[to[S[N-1][j]-'A']]=1;
            T[to[S[N-1][j]-'A']]-=keta[S[N-1].size()-1-j];
        }
        
        int ans=0;
        do{
            
            int sum=0;
            bool ok=true;
            for(int i=0;i<10;i++){
                if(ng[i]&&id[i]==0) ok=false;
            }
            for(int i=0;i<10;i++){
                sum+=id[i]*T[i];
            }
            if(ok&&sum==0) ans++;
            
        }while(next_permutation(all(id)));
        
        for(int i=1;i<=10-SE.size();i++) ans/=i;
        
        cout<<ans<<endl;
        //cout<<cnt<<endl;
    }
}





Measured memory_bytes: 3136
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void)
{
  int n,t;
  scanf("%d",&n);
  t=n%10;
  if(t == 3) printf("bon");
  else if((t==0)||(t==1)||(t==6)||(t==8)) printf("pon");
  else printf("hon");
  
  return 0;
}

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

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

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

    nth_element(a.begin(), a.begin() + a.size() / 2, a.end());
    int median = a[a.size()/2];
    long long s = 0;
    for(int x : a)
        s += abs(x - median);
    cout << s << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n;
	cin>>n;
	lvi a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(all(a));
	ll ans=0;
	while(1)
	{
		lvi op(n+2,0);
		ll tt=0;
		for (int i = 0; i < n; ++i)
		{
			if(a[i]<n) continue;
			ll k=a[i]-n+1;
			ll tmp=ceil((ld)k/n);
			a[i]=a[i]-tmp*n;
			tt+=tmp;
			op[i]=tmp;
		}
		if(tt==0) break;
		ans+=tt;
		for(int i=0;i<n;i++)
		{
			a[i]=a[i]+tt-op[i];
		}
		sort(all(a));
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  map<int, int> mp;
  map<int, int> num;
  int n, q; cin >> n >> q;
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    mp[a]++;
  }

  vll su(SZ(mp)+1);
  int pos = 0;
  for(auto &e: mp) {
    num[e.first] = pos+1;
    su[pos+1] = su[pos] + e.second;
    pos++;
  }

  for(int i=0;i<q;++i) {
    int l, r; cin >> l >> r;
    auto it1 = mp.lower_bound(l);
    auto it2 = mp.upper_bound(r);
    //cout << it1->first << ":" << it2->first << endl;
    //cout << num[it1->first] << ":" << num[it2->first] << endl;
    if(it1 != mp.end() && it2 != mp.end()) cout << su[num[it2->first]-1] - su[num[it1->first]-1] << endl;
    else if(it1 != mp.end()) cout << su[SZ(mp)] - su[num[it1->first]-1] << endl;
    else cout << 0 << endl;
  }

}



Measured memory_bytes: 13052