akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, YMD[1003][12][22] = {};
	YMD[1][1][0] = 1;
	for (int i = 1; i <= 1000; i++) {
		for (int j = 1; j <= 10; j++) {
			if (i % 3 == 0||j%2==1) {
				for (int k = 1; k <= 20; k++) {
					YMD[i][j][k] = YMD[i][j][k - 1]+1;
				}

				YMD[i][j + 1][0] = YMD[i][j][20];
				if (j == 10) {

					YMD[i + 1][1][0] = YMD[i][10][20];
				}
			}
			else if (j % 2 == 0) {
				for (int k = 1; k <= 19; k++) {
					YMD[i][j][k] = YMD[i][j][k - 1] + 1;
				}

				YMD[i][j + 1][0] = YMD[i][j][19];
				if (j == 10) {

					YMD[i + 1][1][0] = YMD[i][10][19];
				}
			}

		}

	}
	cin >> n;
	for (int i = 1; i <= n; i++) {
		long long int y, m, d;
		cin >> y >> m >> d;
		cout << YMD[1000][1][1] - YMD[y][m][d] << endl;
	}
}


Measured memory_bytes: 5156
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
using namespace std;

int main(){
    int K;
    string S;
    cin>>K>>S;
    if(S.size()>K){
        for(int i=0;i<K;i++){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
    else{
        cout<<S<<endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	string s,t; cin >> s>> t;
	int ans = 0;
	rep(i,3){
		if(s[i]==t[i])ans++;
	}
	out(ans);
}




Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, ps: [f64; n] };
    let mut dp = vec![vec![0.; n + 1]; n + 1];
    dp[0][0] = 1.;
    for i in 0..n {
        let p = ps[i];
        for j in 0..(i + 1) {
            dp[i + 1][j] += dp[i][j] * (1. - p);
            dp[i + 1][j + 1] += dp[i][j] * p;
        }
    }
    println!("{}", dp[n][(n / 2 + 1)..(n + 1)].iter().sum::<f64>());
}


Measured memory_bytes: 90364
AB, BC, CA = list(map(int, input().split()))
if AB ** 2 + BC ** 2 == CA ** 2:
	print(int(AB * BC / 2))
elif BC ** 2 + CA ** 2 == AB ** 2:
	print(int(BC * CA / 2))
else:
	print(int(CA * AB / 2))

Measured memory_bytes: 3060
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  plus = [0]
  for j in range(n-1):
    if (i >> j) & 1 == 1:
      plus += [j+1]
  plus += [n]
  for j in range(len(plus)-1):
    ans += int(s[plus[j]:plus[j+1]])
print(ans)    

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
int compare(const void*a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int v[n];
    for(int i=0;i<n;i++)
    scanf("%d",&v[i]);
    qsort(v,n,sizeof(int),compare);
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans=(ans+(float)v[i])/2;
    }
    printf("%lf",ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define dump(vec) for(int i = 0; i < (vec).size(); i++){cout << vec.at(i) << ",";}cout << endl

typedef long long ll;

int main(void)
{
    int w,h;
    cin >> h >> w;
    const ll max = (w+h)*80;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(max, false)));
    vector<vector<int>> A(h, vector<int>(w, 0));
    vector<vector<int>> B(h, vector<int>(w, 0));

    rep(i,h){
        rep(j,w){
            int a;
            cin >> a;
            A.at(i).at(j) = a;
        }
    }
    rep(i,h){
        rep(j,w){
            int b;
            cin >> b;
            B.at(i).at(j) = b;
        }
    }

    rep(i,h){
        rep(j,w){
            int diff = abs(A.at(i).at(j)-B.at(i).at(j));
            if (i==0 && j == 0){
                dp.at(0).at(0).at(diff) = true;
            }
            if (i > 0) {
                rep(k,max){
                    if (!dp.at(i-1).at(j).at(k)) continue;
                    dp.at(i).at(j).at(
                            abs(k - diff)
                    ) = true;
                    dp.at(i).at(j).at(
                            abs(k + diff)
                    ) = true;
                }
            }
            if (j > 0) {
                rep(k,max){
                    if (!dp.at(i).at(j-1).at(k)) continue;
                    dp.at(i).at(j).at(
                            abs(k - diff)
                    ) = true;
                    dp.at(i).at(j).at(
                            abs(k + diff)
                    ) = true;
                }
            }

            //cout << "(" << i << "," << j << ")";
            //rep(k,10){
            //    cout  << dp.at(i).at(j).at(k) << ",";
            //}cout << endl;
        }
    }

    rep(k,max){
        if (!dp.at(h-1).at(w-1).at(k)) continue;
        cout << k << endl;
        break;
    }

    return 0;
}



Measured memory_bytes: 12800
#include<stdio.h>

int main(void){
    unsigned long long int a,b,e,f,g;
    while(scanf("%llu%llu",&a,&b) != EOF){
        if(a >= b){
            e = a;
            f = b;
        }
        else{
            e = b;
            f = a;
        }
        while(e % f){
            g = e % f;
            e = f;
            f = g;
        }
        if(f == 0){
            f = e;
        }
        printf("%llu %llu\n",f,(a * b) / f);
    }
    return 0;
}

Measured memory_bytes: 604
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println(A <= 8 && B <= 8 ? "Yay!" : ":(");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>

auto main() -> int {
  char b;
  std::cin >> b;

  switch (b) {
    case 'A':
      std::cout << 'T';
      break;
    case 'T':
      std::cout << 'A';
      break;
    case 'C':
      std::cout << 'G';
      break;
    case 'G':
      std::cout << 'C';
      break;
  }
  std::cout << std::endl;
}


Measured memory_bytes: 504
class DoubleHelixAnswer
  def self.double_helix(data)
    case data
    when 'A'
      'T'
    when 'T'
      'A'
    when 'C'
      'G'
    when 'G'
      'C'
    end
  end
end

data = STDIN.read.strip
puts DoubleHelixAnswer.double_helix(data)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> b(m,0);
  vector<ll> c(m,0);
  rep(i,m){
    int cnt;
    cin >> c[i] >> cnt; 
    for(int j=0; j<cnt; j++){
      int k; cin >> k; k--;
      b[i]+=(1<<k);
    }
  }
  
  ll sz=1<<n;
  vector<ll> dp(sz,longinf);
  dp[0]=0;
  rep(i,m){rep(j,sz){
    dp[j|b[i]] = min(dp[j|b[i]], dp[j]+c[i]);
  }}

  ll ans=dp[sz-1];
  if(ans==longinf){ans=-1;}
  cout << ans << endl; 
  return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct S{
  int u, cost, change;
  S() {}
  S(int u, int a, int b) : 
    u(u), cost(a), change(b) {}
  bool operator < (const S& s) const {
    if(cost != s.cost) return cost > s.cost;
    return change > s.change;
  }
};
const int MAX_V = 100000;

int main(){
  int N, T;
  while(cin >> N >> T){
    string ST, GL;
    cin >> ST >> GL;
    map<string, vector<int> > st_ids;
    vector<int> to[MAX_V];
    vector<int> cost[MAX_V];
    string name[MAX_V];
    int V = 0;
    REP(i, N){
      int A;
      cin >> A;
      REP(i, A) cin >> name[V + i];
      REP(i, A) st_ids[name[V + i]].push_back(V + i);
      REP(i, A - 1){
        int t; cin >> t;
        to[V + i].push_back(V + i + 1);
        cost[V + i].push_back(t);
        to[V + i + 1].push_back(V + i);
        cost[V + i + 1].push_back(t);
      }
      V += A;
    }
    priority_queue<S> que;
    set<string> used;
    bool used2[MAX_V] = {};
    used.insert(ST);
    REP(i, st_ids[ST].size()){
      que.push(S(st_ids[ST][i], 0, 0));
    }
    bool ok = false;
    while(!que.empty()){
      S s = que.top(); que.pop();
      //printf("id = %d name = %s cost = %d change = %d\n", s.u, name[s.u].c_str(), s.cost, s.change);
      if(name[s.u] == GL){
        printf("%d %d\n", s.cost, s.change);
        ok = true;
        break;
      }
      if(used2[s.u]) continue;
      used2[s.u] = true;
      if(!used.count(name[s.u])){
        REP(i, st_ids[name[s.u]].size()){
          que.push(S(st_ids[name[s.u]][i], s.cost + T, s.change + 1));
        }
        used.insert(name[s.u]);
      }
      REP(i, to[s.u].size()){
        int v = to[s.u][i];
        int c = cost[s.u][i];
        que.push(S(v, s.cost + c, s.change));
      }
    }
    if(!ok) cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 26524
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define md(a, b)		((a) % b + b) % b
#define mod(a)			md(a, MOD)
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define forn(i, n)			for(int i = 0; i < n; i++)
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
//int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef long double ld;	
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1); 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("qwe.txt", "w", stdout);
	int a, b, c, t;
	cin>>a>>b>>c>>t;
	int x, y, z;
	fore(i, 0, t + 1)
	fore(j, 0, t + 1)
	fore(k, 0, t + 1)
	{
		if(i + j + k == t)
		{
			x = a;
			y = b;
			z = c;
			fore(u, 0, i)
			x *= 2;
			fore(u, 0, j)
			y *= 2;
			fore(u, 0, k)
			z *= 2;
			if(x < y && y < z)
			{
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2			

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
struct STOP{
    clock_t S;
    void ini(){S=clock();}
    bool ok(double Z){return (clock()-S)/(double)CLOCKS_PER_SEC<Z;};
}G;
typedef long double ld;
#define MX 100005
char c;
int sx[]={1,-1,0,0},sy[]={0,0,1,-1},N;
ll X[MX],Y[MX],d[MX];
ld Z=1e18;
ld ok(ld w){
    ld x=1e15,y=1e15,U=-1e15,V=-1e15;
    F(N)x=min(x,X[i]+w*sx[d[i]]),
        y=min(y,Y[i]+w*sy[d[i]]),
        U=max(U,X[i]+w*sx[d[i]]),
        V=max(V,Y[i]+w*sy[d[i]]);
    Z=min(Z,(U-x)*(V-y));
    return (U-x)*(V-y);
}
ld ts(ld B=0,ld E=INF){
    ld T;
    while(G.ok(4.7)){
        T=(E-B)/3;
        if(ok(B+T)>ok(E-T))B+=T;
        else E-=T;
    }
    return ok(B);
}
int main(void){
    scanf("%d",&N),G.ini();
    F(N)scanf("%lld%lld %c",X+i,Y+i,&c),d[i]=c^68?c^'R'?c^'U'?1:2:0:3;
    ts(0,4e8+666);
    printf("%.20lf\n",(double)Z);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string nn;
  cin >> nn;
  vector<int>n(nn.length());
  int i,smaller,j;
  for(i=0;i<nn.length();i++){
    n[i] = (int)(nn[i]-'0');
  }
  int k;
  cin >> k;
  // dp[i][smaller][j];
  vector<vector<vector<long> > >dp(nn.length()+1,vector<vector<long> >(2,vector<long>(5,0)));
  dp[0][0][0] = 1;
  for(i=0;i<nn.length();i++){
    for(smaller=0;smaller<=1;smaller++){
      for(j=0;j<=3;j++){
        if(smaller == 0){
          if(n[i]==0){
            dp[i+1][0][j] += dp[i][0][j];
          }else{
            dp[i+1][0][j+1] += dp[i][0][j];
            dp[i+1][1][j] += dp[i][0][j];
            dp[i+1][1][j+1] += dp[i][0][j] * (n[i]-1);
          }
        }else{
          dp[i+1][1][j] += dp[i][1][j];
          dp[i+1][1][j+1] += dp[i][1][j]*9;
        }
      }
    }
  }
  cout << dp[nn.length()][0][k] + dp[nn.length()][1][k] << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		int n, m;
		std::cin >> n >> m;
		std::vector<int>a(n), b(n), c(m), d(m);
		for (int i = 0;i < n;++i) {
			std::cin >> a[i];
			std::cin >> b[i];
		}
			for (int j = 0;j < m;++j) {
				
				std::cin >> c[j];
				std::cin >> d[j];
			}
		for (int i = 0;i < n;++i) {
			std::vector<int> X(m);
			for (int j = 0;j < m;++j) {
				X[j] = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
			}
			std::cout << std::min_element(X.begin(), X.end()) - X.begin() + 1 << std::endl;
		}
		return 0;
	}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;
const int mod=1e9+7;

int n,m,cnt,top;
int a[N],b[N],S[N];
pair<int,int> p[N];
int f[N];

inline int cmp(pair<int,int> a,pair<int,int> b) {
    if (a.first!=b.first) return a.first<b.first;
    else return a.second>b.second;
}

int c[N];
inline int lowbit(int x) { return x&-x; }
inline int query(int x) { int res=0;
    for (;x;x-=lowbit(x)) res=(res+c[x])%mod;
    return res;
}
inline void add(int x,int y) {
    for (;x<=top;x+=lowbit(x)) c[x]=(c[x]+y)%mod;
}

int main() {
    n=read(),m=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    for (re int i=1;i<=m;++i) b[i]=read();
    for (re int i=1;i<=n;++i) {
        if (a[i]<=b[1]||a[i]>=b[m]) continue;
        int x=lower_bound(b+1,b+m+1,a[i])-b;
        if (b[x]==a[i]) continue;
        p[++cnt]=make_pair(a[i]-b[x-1],b[x]-a[i]);
        S[++top]=b[x]-a[i];
    }
    sort(S+1,S+top+1); top=unique(S+1,S+top+1)-S-1;
    for (re int i=1;i<=cnt;++i)
        p[i].second=lower_bound(S+1,S+top+1,p[i].second)-S;
    sort(p+1,p+cnt+1,cmp); cnt=unique(p+1,p+cnt+1)-p-1;
    f[0]=1;
    for (re int i=1;i<=cnt;++i)
        f[i]=query(p[i].second-1)+1,add(p[i].second,f[i]);
    int ans=0;
    for (re int i=0;i<=cnt;++i) ans=(ans+f[i])%mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int ptr=0;
			int[] prime=new int[500000];
			prime[ptr++]=2;
			prime[ptr++]=3;
			for(int i=5;i<=n;i+=2){
				int j;
				double sqrtn=Math.sqrt(i);
				for(j=1;j<ptr;j++){
					if(i%prime[j]==0||prime[j]>sqrtn){
						break;
					}
				}
				if(prime[j]>sqrtn){
					prime[ptr++]=i;
				}
			}
			if(n<=1){
				System.out.println(0);
			}
			else if(n==2){
				System.out.println(1);
			}else if(n==3){
				System.out.println(2);
			}else{
				System.out.println(ptr);
			}
		}
	}
}

Measured memory_bytes: 53808
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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



int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	double ans = 0;
	if (d == 0) {
		ans =( 1 / double(n))*(m - 1);
	}
	else {
		ans = double((n - d) * 2) / (n*n)*(m - 1);
	}
	cout << setprecision(7)<< ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, K, gcdOfAll;
        int[] A;
        boolean possible = false;

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

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            K = in.nextInt();
            A = in.nextIntArray(N);

            gcdOfAll = A[0];
            for (int a : A) gcdOfAll = gcd(gcdOfAll, a);
            for (int a : A) possible |= a >= K && (a - K) % gcdOfAll == 0;

            out.println(possible ? "POSSIBLE" : "IMPOSSIBLE");
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        int[] nextIntArray(int n) {
        	int[] arr = new int[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextInt();
        	}
        	return arr;
        }

        long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; ++i) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 35260
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N//R + 1):
  s = R * r
  for g in range( (N-s) // G + 1):
    s2 = s + G * g
    if (N-s2) % B == 0:
      ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class LazySegmentTree {
  const int NONE = INT_MAX;
  int N;
  vector<int> lazy, dat;

  void setLazy(int k, int v){
    lazy[k] = v;
    dat[k] = v;
  }

  void push(int k){
    if(lazy[k] == NONE) return;
    setLazy(2*k+1, lazy[k]);
    setLazy(2*k+2, lazy[k]);
    lazy[k] = NONE;
  }
public:
  LazySegmentTree(int n){
    N = 1;
    while(N<n) N *= 2;
    dat.resize(2*N);
    lazy.resize(2*N);
    for(int i=0; i<2*N; i++){
      dat[i] = INT_MIN;
      lazy[i] = NONE;
    }
  }

  void update(int s, int t, int val){ update(s, t, val, 0, 0, N); }
  void update(int s, int t, int val, int k, int l, int r){
    if(r<=s || t<=l) return;
    if(s<=l && r<=t){
      setLazy(k, val);
      return;
    }
    push(k);
    update(s, t, val, 2*k+1, l, (l+r)/2);
    update(s, t, val, 2*k+2, (l+r)/2, r);
    dat[k] = max(dat[2*k+1], dat[2*k+2]);
  }

  int query(int s, int t){ return query(s, t, 0, 0, N); }
  int query(int s, int t, int k, int l, int r){
    if(r<=s || t<=l) return INT_MIN;
    if(s<=l && r<=t) return dat[k];
    push(k);
    int vl = query(s, t, 2*k+1, l, (l+r)/2);
    int vr = query(s, t, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
};

struct ST {
  int s, t, x;
};
bool operator<(const ST& a, const ST& b){
  return a.x > b.x;
}

int main(){
  int N, Q;
  cin >> N >> Q;
  map<int,int> za;
  vector<ST> v;
  rep(i,N){
    int s, t, x;
    cin >> s >> t >> x;
    v.push_back((ST){s,t,x});
    s -= x;
    t -= x;
    s = max(s, 0);
    t = max(t, 0);
    za[s] = 1;
    za[t] = 1;
  }

  map<int,int> rza;
  int id = 0;
  FOR(it,za){
    rza[id] = it->first;
    id++;
  }
  FOR(it,rza){
    za[it->second] = it->first;
  }

  sort(ALLOF(v));
  
  LazySegmentTree lst(id+10);
  rep(i,N){
    int s = v[i].s;
    int t = v[i].t;
    int x = v[i].x;
    s -= x;
    t -= x;
    s = max(s, 0);
    t = max(t, 0);

    int sza = za[s];
    int tza = za[t];
    lst.update(sza, tza, x);
  }

  int pos = 0;
  int posza = rza[pos];
  rep(i,Q){
    int D;
    cin >> D;

    int nextposza = INT_MAX;
    while(1){
      if(rza.count(pos+1) != 0) nextposza = rza[pos+1];
      else nextposza = INT_MAX;
      if(posza <= D && D < nextposza) break;
      pos++;
      posza = rza[pos];
    }

    int val = lst.query(pos, pos+1);
    if(val == INT_MIN) val = -1;
    cout << val << endl;
  }

  
  return 0;
}



Measured memory_bytes: 49328
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    lint ans = 0;
    lint num = 0;
    REP(i, n){
        num += (s[i] == 'I') ? 1 : -1;
        ans = max(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = [1, 3, 5, 7, 8, 10, 12]
d = [4, 6, 9, 11]
e = [2]

if a in c and b in c:
    print("Yes")
elif a in d and b in d:
    print("Yes")
elif a in e and b in e:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
from collections import deque
n = int(input())
G = []
for _ in range(n):
    u, k, *v = map(int, input().split())
    u -= 1
    G.append(v)
q = deque()
seen = [False] * n
dist = [-1] * n

def main():
    q.append(0)
    seen[0] = True
    dist[0] = 0
    while len(q) > 0:
        now_v = q.popleft()
        for new_v in G[now_v]:
            new_v -= 1
            if seen[new_v] is True:
                continue
            seen[new_v] = True
            q.append(new_v)
#             print(now_v, new_v)
            dist[new_v] = dist[now_v] + 1
    
    for i in range(n):
        print(i+1, dist[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 6028
n=int(input())
s=input()
A=[]
for i in range(n):
  A.append(s[i])
W=0
R=A.count('R')
ans=float('inf')
for i in range(n+1):
  if i!=0:
    if A[i-1]=='W':
      W+=1
    else:
      R-=1
  ans=min(max(W,R),ans)
print(ans)

Measured memory_bytes: 93124
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
 
#define For(i,n) for(int i = 0;i < n;i++)
#define Forini(i,s,n) for(int i = s;i < n;i++)
 
#define minusFor(i,n) for(int i = n-1;i >= 0;i--)
#define minusForend(i,n,s) for(int i = n-1;i >= s;i--)
 
const int INF = 10000000000;
 
using namespace std;

bool cell[101][101];
int w,h;

int cast(int x,int y,int s,int t)
{
	int sum = 0;

	for(int i = x;i < x+s && i <= w;i++)
	{
		for(int j = y;j < y+t && j <= h;j++)
		{
			if(cell[i][j])sum++;
		}
	}
	return sum;
}


int main()
{
	
	int n;



	while(cin >> n && n)
	{
		memset(cell,0,sizeof(bool)*101*101);
		int s,t;

		cin >> w >> h;

		for(int i = 0;i < n;i++)
		{
			int tx,ty;
			cin >> tx >> ty;
			cell[tx][ty] = true;
		}

		cin >> s >> t;

		int Max = 0;

		for(int i = 1;i <= w;i++)
		{
			for(int j = 1;j <= h;j++)
			{
				Max = max(Max,cast(i,j,s,t));
			}
		}

		cout << Max << endl;



	}

	return 0;
}
 

Measured memory_bytes: 1176
import sys

n = input()
for i in range(1,n+1) :
	if i%3==0 :
		print(' '),
		sys.stdout.write(str(i))
	else:
		x = i
		while(x>0):
			if(x%10==3):
				print(' '),
				sys.stdout.write(str(i))
				break
			else :
				x/=10
print('')

Measured memory_bytes: 6392
<?php
$input = file_get_contents('php://stdin');
$inarr = explode("\n", $input);

$n = $inarr[0];
$xList = explode(" ", $inarr[1]);
$xList = array_map('intval', $xList);

$min=PHP_INT_MAX;
for($party=min($xList); $party<=max($xList); $party++){
  	$total_hp=0;
    foreach($xList as $x){
        $hp = ($x-$party)*($x-$party);
      	$total_hp = $total_hp + $hp;
    }
    if($total_hp<$min){
        $min=$total_hp;
    }
}
echo $min;

?>

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int H,W,K;cin>>H>>W>>K;
  vector<vector<char>>A(H,vector<char>(W));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>A.at(i).at(j); int ans=0;
  for(int bit=0;bit<(1<<H);bit++){
    vector<vector<char>>B(H,vector<char>(W));
    for(int I=0;I<H;I++)
      for(int J=0;J<W;J++)
        B.at(I).at(J)=A.at(I).at(J);
    for(int i=0;i<H;i++){
    if(bit & (1<<i)){
    for(int j=0;j<W;j++)
      B[i][j]='.';
    }
    }for(int bit1=0;bit1<(1<<W);bit1++){
    vector<vector<char>>C(H,vector<char>(W));
    for(int I=0;I<H;I++)
      for(int J=0;J<W;J++)
        C.at(I).at(J)=B.at(I).at(J);
     for(int j=0;j<W;j++){
    if(bit1 & (1<<j)){
    for(int i=0;i<H;i++)
      C[i][j]='.';
    }
    }int sum=0;for(int i=0;i<H;i++)
       for(int j=0;j<W;j++)
         if(C[i][j]=='#')sum++;
      if(sum==K)ans++;
      
    }
  
  }cout<<ans<<endl;
    
  return 0;
  
}

Measured memory_bytes: 3628
from itertools import*
n,m,r=map(int,input().split())
rc=list(map(int,input().split()))
INF=10**18
d=[[INF]*n for _ in range(n)]
for _ in range(m):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=INF
for i in permutations(rc):
  a=0
  i=list(i)
  for j in range(r-1):
    a+=d[i[j]-1][i[j+1]-1]
  ans=min(a,ans)
print(ans)

Measured memory_bytes: 74556
import java.util.*;
import java.io.*;

public class Main{
	// class node implements Comparator<int[]>{
	// 	public int compare(int[] a, int b){
	// 		double d1 = Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2));
	// 		double d2 = Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2));
	// 		if(d1>d2){
	// 			return 
	// 		}
	// 	}
	// }
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		//int[][] points = new int[n][2];
		int count = 0;
		for(int i=0;i<n;i++){
			st = new StringTokenizer(br.readLine());
			int x = Integer.parseInt(st.nextToken());;
			int y = Integer.parseInt(st.nextToken());;
			double d1 = Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
			if(d1>k){

			}
			else{
				count++;
			}
		}
		// Arrays.sort(points, new Comparator<int[]>{
		// 	public int compare()
		// });
		System.out.println(count);
	}
}

Measured memory_bytes: 53436
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli a, b, c;
int main() {
  cin >> a >> b >> c;
  cout << (a+b>=c ? "Yes" : "No") << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
string S;
int B = 0, W = 0;

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

  cin >> N >> S;
  REP(i,N) {
    if (S[i] == '#') B++;
    else W++;
  }
  int b = 0, w = 0;
  int ans = min(B,W);
  REP(i,N) {
    if (S[i] == '#') b++;
    else w++;
    CHMIN(ans,b+(W-w));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 720
n = int(input())
s = [0 for _ in range(26)]
t = [0 for _ in range(26)]
   
ans = ""

for i in range(n):
    s1 = input()
    if i == 0:
        for j in range(len(s1)):
            s[ord(s1[j]) - ord("a")] += 1
    else:
        for j in range(len(s1)):
            t[ord(s1[j]) - ord("a")] += 1
        for j in range(26):
            s[j] = min(s[j], t[j])
            t[j] = 0
        
for i in range(26):
    ans += chr(ord("a") + i) * s[i]
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
 
enum {
  VTop,
  HLeft,
  VBottom
};
 
struct P {
  int x, y;
  int type;
  int oppo_x;
  bool operator < (P const& p) const {
    if(y != p.y) return y < p.y;
    if(type != p.type) { return type < p.type; }
    return x < p.x;
  }
};
 
struct Line : public vector<P>
{
  Line(P const& a, P const& b) {
    push_back(a), push_back(b);
  }
};
 
void print(vector<P> const& pts) {
  int F[10][10] = {};
  rep(i, pts.size()) {
    if(pts[i].type != HLeft) {
      if(pts[i].type == VTop) {
        REP(j, pts[i].y, 10) { F[j][pts[i].x] = 1; }
      }
      else {
        REP(j, pts[i].y+1, 10) { F[j][pts[i].x] = 0; }
      }
    }
  }
  rep(i, pts.size()) {
    if(pts[i].type == HLeft) {
      REP(j, pts[i].x, pts[i].oppo_x+1) { F[pts[i].y][j] = 1; }
    }
  }
  rep(i, 10) {
    rep(j, 10) {
      cout << (F[i][j] ? "#" : "_");
    }
    cout << endl;
  }
}
 
int main() {
   
  int N; cin >> N;
  vector<P> pts;
  rep(i, N) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    if(x1 > x2) swap(x1, x2);
    if(y1 > y2) swap(y1, y2);
    int type1, type2;
    if(x1 == x2) {
      type1 = VTop, type2 = VBottom;
      pts.push_back((P){x1, y1, type1, -1});
      pts.push_back((P){x2, y2, type2, -1});
    }
    else {
      type1 = HLeft;
      pts.push_back((P){x1, y1, type1, x2});
    }
  }
   
  sort(pts.begin(), pts.end());

  int ret = 0;
  set<int> xtree;
  for(auto p: pts) {
    if(p.type == VTop) {
      xtree.insert(p.x);
    }
    if(p.type == VBottom) {
      xtree.erase(p.x);
    }
    if(p.type == HLeft) {
      int const x1 = p.x, x2 = p.oppo_x;
      auto iter1 = xtree.lower_bound(x1);
      auto iter2 = xtree.upper_bound(x2);

      int cnt = 0;
      while(iter1 != iter2) {
        iter1++; cnt++;
      }
      ret += cnt;
    }
  }
   
  cout << ret << endl;
   
  return 0;
}

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

int main() {
  int A, s1, s2, s3, s4;
  cin >> A >> s1 >> s2 >> s3 >> s4;
  s1 = A % 10;
  s2 = A / 10 % 10;
  s3 = A / 100 % 10;
  s4 = A / 1000 % 10;
  
  if (s1 == s2 && s2 == s3 ) {
    cout << "Yes" << endl;
  }
  else if (s4 == s2 && s2 == s3) {
    cout << "Yes" << endl;
  }
  /*else if (op == "*") {
    cout << A * B << endl;
  }
  else if (op == "?" || op == "=" || op == "!" || op == "=" || B == 0 ) {
    cout << "error" << endl;
  }*/
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	//ll a[200] = {};
	//ll b[200] = {};
	//ll v[3] = {};
	ll *c, *s, *n;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	
	cin >> A >> B >> C >> D;

	

	if (A <= C)
		smax = C;
	else
		smax = A;

	if (B <= D)
		max = B;
	else
		max = D;





	if(max - smax>0)
		cout << max -smax << endl;
	else
	{
		cout << 0 << endl;
	}
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	ll x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return x/b;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////

int main(){
  int N,K;
  cin >> N >> K;
  int ma = (N-1)*(N-2) / 2;//組数（頂点数）計算
  if(ma < K) cout << -1 << endl;
  else {
    vector<pair<int,int>> res;
    for(int i=1;i<=N-1;i++) res.push_back({i,N});
    int rem = ma-K;//余分な辺減らしたい
    int ci = 1,cj=2;
    for(int _=0;_<rem;++_){
      res.push_back({ci,cj});
      ++cj;
      if(cj == N) {
        ci++;
        cj = ci+1;
      }
    }
    cout << res.size() << endl;
    for(auto p:res) cout << p.first << " " << p.second << endl;
  }
}

Measured memory_bytes: 384
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    totalA = sum(A)
    if totalA % (N * (N + 1) // 2) != 0: print("NO")
    else:
        Op = totalA // (N * (N + 1) // 2)
        subA = [A[(i + 1) % N] - A[i] for i in range(N)]
        count = 0
        for i, a in enumerate(subA):
            if (Op - a) % N != 0 or a > Op:
                print("NO")
                break
            else: count += (Op - a) // N
        else: 
            if count == Op: print("YES")
            else: print("NO")
    
    return 0

if __name__ == "__main__":
    solve()



Measured memory_bytes: 15012
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

typedef long long ll;
using namespace std;
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for(int i=0;i<n;i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ll>());

    int max_cnt = 0;
    int cnt_a = 0, idx_a;
    for(int i=0;i<n;i++) {
        if(v[0] == v[i]) max_cnt++;
    }
    for(int i=0;i<n;i++) {
        if(v[i] == v[a-1]) {
            cnt_a++;
            idx_a = i;
        }
    }
    idx_a++;

    ll dp[55][55];
    dp[0][0] = 1;
    ll ans = 0;
    for(int i=1;i<=50;i++) {
        for(int j=0;j<=50;j++) {
            if(i>0 && j>0) 
                dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
            else 
                dp[i][j] = dp[i-1][j];
        }
    }
    if(max_cnt > a) {
        int lim = min(max_cnt, b);
        for(int i=a;i<=lim;i++) {
            ans += dp[max_cnt][i];
        }
    } else {
        int lim = idx_a - cnt_a;
        ans += dp[cnt_a][a-lim];
    }

    double ave = 0;
    for(int i=0;i<a;i++) {
        ave += v[i];
    }

    cout << fixed << setprecision(6) << ave * 1.0 / a << endl;
    cout << ans << endl;

}


Measured memory_bytes: 256
mod = pow(10, 9)+7

n, k = map(int, input().split())
blues = k
reds = n-k

C = [[0]*2001 for i in range(2001)]

def preprocess():
	global C

	for i in range(2001):
		for j in range(i+1):
			if i==j or j==0:
				C[i][j] = 1
			else:
				C[i][j] = (C[i-1][j-1] + C[i-1][j])%mod
preprocess()

for i in range(k):
	slots = reds + 1
	res = (C[slots][i+1]*C[k-1][i])%mod
	print(res)


Measured memory_bytes: 74972
s=gets.chomp
a=s.gsub("b","1").gsub("d","2").gsub("p","3").gsub("q","4")
c=s.reverse.gsub("b","2").gsub("d","1").gsub("p","4").gsub("q","3")
if a==c
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 2812