akhauriyash/Code-Regression huggingface dataset:
#include<math.h>
#include<iostream>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
class Point
{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(x * a, y * a);}
    Point operator / (double a) {return Point(x / a, y / a);}

    double abs() {return sqrt(norm());}
    double norm() {return x * x + y * y;}
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
};typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2):p1(p1), p2(p2){}
};typedef Segment Line;

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

Point getCrossPoint(Segment s1, Segment s2){
    Vector base = s2.p2 - s2.p1;
    double d1 = cross(base, s1.p1 - s2.p1) < 0 ? -cross(base, s1.p1 - s2.p1) : cross(base, s1.p1 - s2.p1);
    double d2 = cross(base, s1.p2 - s2.p1) < 0 ? -cross(base, s1.p2 - s2.p1) : cross(base, s1.p2 - s2.p1);
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1)*t;
}
#include<iomanip>
int main(){
    int q; cin >> q;
    int x0, y0, x1, y1, x2, y2, x3, y3;
    Point p0, p1, p2, p3;
    for (int i = 0; i < q; i++)
    {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        p0 = Point(x0, y0);
        p1 = Point(x1, y1);
        p2 = Point(x2, y2);
        p3 = Point(x3, y3);
        Segment s0 = Segment(p0, p1), s1 = Segment(p2, p3);
        cout <<  fixed << setprecision(10) << getCrossPoint(s0, s1).x << " " << getCrossPoint(s0, s1).y << endl;
    }   
}



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

int main() {
  int n,k; cin >>n >>k;
  vector<int> num(200001), exist(200001);
  // numは整数iが書かれている数
  // existは整数iが書かれていれば1、そうでなければ0
  int buf;
  for (int i=0; i<n; i++){
    cin >>buf; num.at(buf)++; exist.at(buf) = 1;
  }
  int nums = 0; // ボールに書かれた整数の種類
  for (int i=0; i<200001; i++) nums += exist.at(i);
  int rewrite = nums - k; //書き換える整数の種類の数
  sort(num.begin(), num.end());
  int ans = 0;
  
  for (int i=0; i<200001; i++){
    if (rewrite <= 0) break;
    if (num.at(i) != 0){
      ans += num.at(i);
      rewrite--;
    }
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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 ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  vector<int> v(n);
  REP(i,n) cin >> v[i];
  
  vector<int> c(n);
  REP(i,n) cin >> c[i];
  
  int ans = 0;

  REP(i,n){
      if(v[i] - c[i] > 0){
          ans += v[i] - c[i];
      }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N;
	int count=0;
	int eq;
	
	scanf("%d",&N);
	
	char A[N],B[N],C[N];
	
	scanf("%s",&A);
	scanf("%s",&B);
	scanf("%s",&C);
	
	for(int i=0;i<N;i++){
		eq=0;
		if(A[i]==B[i])	eq++;
		if(B[i]==C[i])	eq++;
		if(A[i]==C[i])	eq++;
		
		if(eq==0)	count+=2;
		if(eq==1)	count++;

	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
#define PI 3.14159265
typedef long long ll;
//trading bullish credit spreads on the spy and spx with friday weekly expiration === unlimited quantitative. brrrrrrhhhhhhhhhhh.
// because stonks only gooooooooo up. Diamond hands Babbbbyyyyyy
//Expected profits = [$Win*Win%] - [$Risk*(1-Win%)]
int main(){
	int n; cin>>n;
	map<int,string> m;
	m[2] = "hon";
	m[4] = "hon";
	m[5] = "hon";
	m[7] = "hon";
	m[9] = "hon";
	m[0] = "pon";
	m[1] = "pon";
	m[6] = "pon";
	m[8] = "pon";
	m[3] = "bon";
	cout<<m[n%10]<<"\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int a[300][300];
int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,n) cin >> a[i][j];
  ll ans = 0;
  rep(i,n)rep(j,n){
    if(i>=j)continue;
    int d = 2*1e9;
    rep(k,n){
      if(i==k||j==k) continue;
      if(a[i][j]>a[i][k]+a[k][j]){
        cout << -1 << endl;
        return 0;
      }
      d = min(d,a[i][k]+a[k][j]);
    }
    if(d>a[i][j]) ans += a[i][j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	
	if(a % 3 == 0 || b % 3 ==0 || (a+b) % 3 == 0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#ABC173B.rb
n = gets.to_i

ac = 0
wa = 0
tle = 0
re = 0

(1..n).each do |nn|
  str = gets.chomp
  if str == "AC"
    ac += 1
  elsif str == "WA"
    wa += 1
  elsif str == "TLE"
    tle += 1
  else
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  if (N % 500 <= A)
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}

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;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int Max = a[n-1];
    int Min = a[0];
    vector<int> count(Max + 10,0);
    rep(i,n) count[a[i]]++;

    int ans = 0;
    for(int i = Min; i <= Max; i++){
        int tmp = 0;
        tmp = count[i-1] + count[i] + count[i+1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <utility>
#include <climits>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int cnt = 0;

vector<string> BubbleSort(vector<string> a){
    for(int i=0;i<a.size()-1;i++){
        for(int j=a.size()-1;j>=i+1;j--){
            if(a[j][1]-'0' < a[j-1][1]-'0'){
                swap(a[j],a[j-1]);
            }
        }
    }
    return a;
}
vector<string> SelectionSort(vector<string> a){
    int mini;
    for(int i=0;i<a.size();i++){
        mini = i;
        for(int j=i;j<a.size();j++){
            if(a[j][1]-'0' < a[mini][1]-'0'){
                mini = j;
            }
        }
        swap(a[i],a[mini]);
    }
    return a;
}



int main(void){
    int n;
    cin >> n;
    vector<string>c(n),a,b;
    for(int i=0;i<n;i++)
        cin >> c[i];
    
    b = BubbleSort(c);
    for(int i=0;i<n;i++){
        cout << b[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    cout << "Stable" << endl;
    
    a = SelectionSort(c);
    bool f = false;
    for(int i=0;i<n;i++){
        cout << a[i];
        if(a[i]!=b[i])f=true;
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    if(f)cout << "Not stable" << endl;
    else cout << "Stable" << endl;
    
    
    return 0;
}

Measured memory_bytes: 1216
def main():
    N, K = map(int, input().split())
    A_int_list = list(map(int, input().split()))

    l_int = A_int_list[0]

    for i in range(1, N):
        if l_int < A_int_list[K + i - 1]:
            print("Yes")
        else:
            print("No")

        if K + i == N:
            exit()
        l_int = A_int_list[i]


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) {
    assert(N > 0);
    dat.resize(N, 0);
  }

  void add(int k, T val) {
    assert(0 <= k && k < N);
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    assert(k >= 0);
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) {
    assert(0 <= l && l <= r && r <= N);
    return sum(r) - sum(l);
  }

  T index(int k) {
    assert(0 <= k && k < N);
    return sum(k+1) - sum(k);
  }
};

P idx[200010];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) {
    int a;
    cin >> a;
    idx[i] = P(a, i);
  }
  RangeSumQuery<int> fwt(N);
  REP(i, N) fwt.add(i, 1);
  sort(idx, idx + N);

  ll ans = 0;
  for (P p : idx) {
    ans += (ll)fwt.sum(p.second);
    fwt.add(p.second, -1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3372
N,M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort(key=lambda x:x[1])
# print(ab)

ans = 0
endtime = 0
for ai,bi in ab:
    if endtime <= ai:
        endtime = bi
        ans += 1
print(ans)


Measured memory_bytes: 18244
//Author - Rahil Malhotra
#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 double long double

int arr[300005];
int32_t main()
{
    IOS;
    string s,t;
    cin>>s>>t;
    int ct=0;
    for(int i=0;i<s.length();i++)
        if(s[i]!=t[i])
            ct++;
    cout<<ct;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    int ans=0;
    int maxh=0;
    for(int i=0;i<N;i++){
        int h;cin>>h;
        if(maxh<=h){
            maxh=h;ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
const int N=308;
int n,m,ans,a[N][N][N];
char b[N];
int maxx(int x,int y){if(x>y)y=x;return y;}
int main(void)
{
	int i,j,k;
	scanf("%s%d",b+1,&m);
	n=strlen(b+1);ans=1;
	for(i=1;i<=n;i++)for(j=0;j<=m;j++)a[j][i][i]=1;
	for(k=0;k<=m;k++)
	for(i=n;i>=1;i--)
	for(j=i+1;j<=n;j++)
	{
		if(k){a[k][i][j]=maxx(a[k][i][j],a[k-1][i][j]);}
		if(k){a[k][i][j]=maxx(a[k][i][j],2+a[k-1][i+1][j-1]);}
		a[k][i][j]=maxx(a[k][i][j],maxx(maxx(a[k][i+1][j],a[k][i][j-1]),(b[i]==b[j])*(2+a[k][i+1][j-1])));
	}
	cout<<a[m][1][n];
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;
ll K;

int main(){
    cin >> N;
    map<string, int> m;
    int maxv=0;
    REP(i,N)
    {
        string s;
        cin >> s;
        if(m.find(s)==m.end())
            m[s]=1;
        else
        {
            m[s]++;
        }
        if(maxv<m[s])maxv=m[s];
    }
    vector<string> ans;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if((*it).second==maxv)
        {
            ans.push_back((*it).first);
        }
    }
    sort(ans.begin(),ans.end());
    for(auto it=ans.begin();it!=ans.end();it++)
    {
        cout << (*it) << endl;
    }
    return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

int main() {
    lli n, a;
    cin2(n, a);

    if (n % 500 <= a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int a,b,c;  cin >> a >> b >> c;
  if(a+b+c <= 21){
    cout << "win";
  }else{
    cout << "bust";
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vll P(A), Q(B), R(C);
	for (int i = 0; i < A; i++)
	{
		cin >> P[i];
	}
	for (int i = 0; i < B; i++)
	{
		cin >> Q[i];
	}
	for (int i = 0; i < C; i++)
	{
		cin >> R[i];
	}

	vpll DC(A + B + C);
	for (int i = 0; i < A; i++)
	{
		pair<ll, ll> temp = { P[i], 0 };
		DC.emplace_back(temp);
	}
	for (int i = 0; i < B; i++)
	{
		pair<ll, ll> temp = { Q[i], 1 };
		DC.emplace_back(temp);
	}
	for (int i = 0; i < C; i++)
	{
		pair<ll, ll> temp = { R[i], 2 };
		DC.emplace_back(temp);
	}

	sort(P.begin(), P.end(), greater<ll>());
	sort(Q.begin(), Q.end(), greater<ll>());

	vll used;
	for (int i = 0; i < X; i++)
	{
		used.emplace_back(P[i]);
	}
	for (int i = 0; i < Y; i++)
	{
		used.emplace_back(Q[i]);
	}


	sort(R.begin(), R.end(), greater<ll>());
	sort(used.begin(), used.end(), greater<ll>());

	vll ruiseki_used(X + Y);
	ruiseki_used[0] = used[0];
	for (int i = 1; i < X + Y; i++)
	{
		ruiseki_used[i] = ruiseki_used[i - 1] + used[i];
	}


	vll ruiseki_R(C);
	ruiseki_R[0] = R[0];
	for (int i = 1; i < C; i++)
	{
		ruiseki_R[i] = ruiseki_R[i - 1] + R[i];
	}


	ll ans = ruiseki_used[X + Y - 1];

	for (ll n_R = 1; n_R <=min( X + Y,C); n_R++)
	{
		ll n_used = X + Y - n_R;
		if (n_used <= 0)
		{
			continue;
		}


		ans = max(ans, ruiseki_R[n_R-1] + ruiseki_used[n_used-1]);



	}

	cout << ans;





}



Measured memory_bytes: 16816
n = int(input())
divisors =[]
for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        divisors.append(i)
gojyu=[]
for j in divisors:
    kyori = j + n/j - 2
    gojyu.append(int(kyori))
print(min(gojyu))



Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int i, N, a[51], b[51];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(b[i]));
	for (i = 1; i <= N; i++) if (b[i] != a[i]) break;
	if (i > N) {
		printf("0\n");
		fflush(stdout);
		return 0;
	}
	for (i = 1; i <= N; i++) if (b[i] != a[i] && b[i] * 2 >= a[i]) break;
	if (i <= N) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int j, k, l, adj[51][51] = {};
	long long bit[51], ans;
	for (i = 1, bit[0] = 1; i <= 50; i++) bit[i] = bit[i-1] << 1;
	for (i = 49, ans = bit[50] - 2; i >= 1; i--) {
		ans ^= bit[i];
		for (j = 0; j <= 50; j++) for (k = 0, adj[j][j] = 1; k < j; k++) adj[j][k] = 0;
		for (j = 1; j < 50; j++) {
			if ((ans & bit[j]) == 0) continue;
			for (k = j; k <= 50; k++) adj[k][k%j] = 1;
		}
		for (l = 1; l <= 50; l++) {
			for (j = l; j <= 50; j++) {
				for (k = 0; k <= l; k++) if ((adj[j][l] & adj[l][k]) == 1) adj[j][k] = 1;
			}
		}
		for (j = 1; j <= N; j++) if (adj[a[j]][b[j]] == 0) break;
		if (j <= N) ans ^= bit[i];
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1744
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#define fi first
#define se second
const int INF = 0x7fffffff;
const int maxn = 100000010;

using namespace std;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int maxx = max(a,max(b,c));
    if(maxx==a) cout << b+c << endl;
    else if(maxx==b) cout << a+c << endl;
    else if(maxx==c) cout << a+b << endl;
    return 0;
}


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

ll N;

int main() {
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    // long long limit_ten = N / 10LL;

    long long target = 10;
    long long ans = 0;
    while (N >= target) {
        ans += (N / target);
        // cout << N / target << endl;
        target *= 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)

Ary = readlines.map(&:chomp!)
ans = 0
all = 0
Ary.each do |line|
  all += line.count("#")
end

h = "1" * H
w = "1" * W

(0..(h.to_i(2))).each do |h_choice|
  (0..(w.to_i(2))).each do |w_choice|
    h_string = h_choice.to_s(2)
    w_string = w_choice.to_s(2)
    if h_string.size < H
      h_string = '0' * (H - h_string.size) + h_string
    end

    if w_string.size < W
      w_string = '0' * (W - w_string.size) + w_string
    end

    ary = Ary.dup
    h_kesi = 0
    w_kesi = 0
    h_string.each_char.with_index do |c, i|
      if c == '1'
        h_kesi += ary[i].count("#")
        ary[i] = 'R' * W
      end
    end

    w_string.each_char.with_index do |c, i|
      if c == '1'
        ary.each do |line|
          w_kesi += 1 if line[i] == '#'
        end
      end
    end

    if all - h_kesi - w_kesi == K
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 14308
#include <stdio.h>

int main(int argc, char *argv[])
{
	while (1)
	{
		int x, y;
		int tmp;
		scanf("%d %d\n", &x, &y);
		if (x == 0 && y == 0)
		{
			return 0;
		}
		if (y < x)
		{
			tmp = x;
			x = y;
			y = tmp;
		}
		printf("%d %d\n", x, y);
	}

	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;


int gcd(int a,int b){
    int tmp,r;

    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int gcd2(int a,int b,int c){
    return gcd(gcd(a,b),c);
}

int main(){
    int K;
    cin>>K;
    int count=0;
    FOR(i,1,K+1){
        FOR(j,1,K+1){
            FOR(k,1,K+1){
                count+=gcd2(i,j,k);
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
stack<int> polish;
int main()
{
  string str;
  cin >>str;
  while(cin){
    int x,y,z; 
      switch(str[0]){
      case '+':
	x =polish.top();
	polish.pop();
	y = polish.top();
	polish.pop();
	z = y+x;
	polish.push(z);
	break;
      case '-':
	x =polish.top();
	polish.pop();
	y = polish.top();
	polish.pop();
	z = y-x;
	polish.push(z);
	break;
      case '*':
	x =polish.top();
	polish.pop();
	y = polish.top();
	polish.pop();
	z = y*x;
	polish.push(z);
	break;
      default:
	polish.push(atoi(str.c_str()));
	break;
      }
      cin>>str;
    }
  cout <<polish.top()<<endl;
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

const int N=1e5+10;
int n,m,cnt[N];
struct city{
	int year,bel;
	int id,od;
	inline bool operator < (const city ano) const{
		return year<ano.year;
	}
}ct[N];
int lid[20];

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
inline bool cmp(city a,city b){return a.od<b.od;}
int main(){
	n=readint(),m=readint();
	rep(i,1,m)ct[i].bel=readint(),ct[i].year=readint(),ct[i].od=i;
	sort(ct+1,ct+1+m);
	rep(i,1,m){
		ct[i].id=++cnt[ct[i].bel];
	}
	sort(ct+1,ct+1+m,cmp);
	rep(i,1,m){
		int crt=0;
		memset(lid,0,sizeof lid);
		while(ct[i].id){
			lid[++crt]=ct[i].id%10;
			ct[i].id/=10;
		}
		crt=6;
		while(ct[i].bel){
			lid[++crt]=ct[i].bel%10;
			ct[i].bel/=10;
		}
		for(crt=12;crt>0;--crt)printf("%d",lid[crt]);
		putchar('\n');
	}
	return 0;
}

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

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

int h,w; 
int field[1005][1005];
int mh[1005][1005];
int mw[1005][1005];

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

P search(int a, int b){
	if(mh[a][b] != -1){
		return P(mh[a][b],mw[a][b]);
	}	

	P tmp = P(-1,-1);
	int cnt = 0;
	for (int i = 0;i < 4;i++){
		int na = a+dy[i], nb = b+dx[i];
		if(na<0 || nb<0 || na>=h || nb>= w || field[a][b] < field[na][nb]) continue;
		P tmp2 = search(na,nb);
		if(tmp2 == P(-2,-2)){
			mh[a][b] = -2;
			mw[a][b] = -2;
			return P(-2,-2);
		}
		if(tmp != tmp2) cnt++;
		if(cnt == 2){
			mh[a][b] = -2;
			mw[a][b] = -2;
			return P(-2,-2);
		}
		tmp = tmp2;
	}
	if(tmp == P(-1,-1)){
		mh[a][b] = a;
		mw[a][b] = b;
		return P(a,b);
	}
	mh[a][b] = tmp.first;
   	mw[a][b] = tmp.second;
	return tmp;	
}

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

	cin >> h >> w;

	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			cin >> field[i][j];
		}
	}

	memset(mh,-1,sizeof(mh));
	memset(mw,-1,sizeof(mw));

	int ans = 0;

	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			if(search(i,j) == P(-2,-2)) ans++;
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 69588
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	vmin = min(d*d+w*w, d*d+h*h, w*w+h*h)

	for _ in range(int(input())):
		r = int(input())
		print('OK' if (2*r)**2 > vmin else 'NA')


Measured memory_bytes: 5592
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
using namespace std;

void solve(){
ll n,k;
cin>>n>>k;
ll a[n]={0};
REP(i,k)
{
ll d;
cin>>d;
REP(j,d)
{
    ll x;
    cin>>x;
a[x-1]++;
}
}
ll res=0;
REP(i,n)
if(a[i]==0)
    res++;
cout<<res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin >> t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3656
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int MAX = 1000000;
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int[] pol = new int[200];
			for(int i=1; i<200; i++) {
				pol[i] = (i * (i + 1) * (i + 2)) / 6;
			}
			
			int[] dp = new int[MAX+1];
			int[] dp2 = new int[MAX+1];
			Arrays.fill(dp, Integer.MAX_VALUE);
			Arrays.fill(dp2, Integer.MAX_VALUE);
			dp[0] = 0;
			dp2[0] = 0;
			for(int i=1; i<MAX; i++) {
				for(int j=1; j<200; j++) {
					if(i - pol[j] >= 0) {
						dp[i] = Math.min(dp[i], dp[i-pol[j]]+1);
						if(pol[j] % 2 == 1) {
							dp2[i] = Math.min(dp2[i], dp2[i-pol[j]]+1);
						}
					}
				}
			}
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n == 0) break;
				System.out.println(dp[n] + " " + dp2[n]);
			}
			
		}
	}
}


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

const int N=4005;
const int inf=0x3f3f3f3f;

int n,m,last[N],cnt,a[N],f[N*2][N];
bool vis[N];
struct edge{int to,next;}e[N*2];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dp(int id)
{
	int to=e[id].to;vis[id]=1;
	for (int i=last[to];i;i=e[i].next)
	{
		if (i==(id^1)) continue;
		if (!vis[i]) dp(i);
	}
	int a1=0;
	for (int i=last[to];i;i=e[i].next) if (i!=(id^1)) a[++a1]=i;
	f[id][0]=0;
	for (int i=1;i<=a1;i++) f[id][0]+=f[a[i]][0]+1;
	for (int i=1;i<m;i++)
	{
		f[id][i]=0;
		int j=min(i,m-i),mn=inf;
		for (int k=1;k<=a1;k++) f[id][i]+=f[a[k]][j-1],mn=min(mn,f[a[k]][j-1]-f[a[k]][i-1]);
		f[id][i]+=mn;
		f[id][i]=min(f[id][i],f[id][i-1]);
	}
}

int main()
{
	n=read();m=read();cnt=1;
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
	}
	for (int i=2;i<=cnt;i++)
		if (!vis[i]) dp(i);
	int ans=inf;
	for (int i=2;i<=cnt;i+=2)
		for (int j=0;j<m;j++)
			ans=min(ans,f[i][j]+f[i+1][m-j-1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 63360
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int count[4][3][10]={{{0}}};
int main(void){
    int n,i,j,k;
    int b,f,r,v;
    cin >>n;
    for(i=0;i<n;i++){
        cin >>b>>f>>r>>v;
        count[b-1][f-1][r-1] += v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                cout <<" "<<count[i][j][k];
            }
            cout <<endl;
        }
        if(i<3) {
            cout <<"####################"<<endl;
        }
    }
}


Measured memory_bytes: 3100
def main():
    N, A, B = map(int, input().split())
    count = 0
    for i in range(N):
        n = str(i+1)
        nsum = 0
        for s in n:
            nsum += int(s)
        if A <= nsum <= B:
            count += i+1

    return count

if __name__ == '__main__':
    print(main())



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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b<0) cout << "No" << endl;
  else {
    ll d = (c-a-b)*(c-a-b);
    if(d > 4*a*b) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
string s[N];
int n; 
int dp[N][5][5][5];
int go(int idx, int a, int b, int c){
	if(idx==n){
		return dp[idx][a][b][c] = 1;
	}
	int ret = dp[idx][a][b][c];
	if(ret!=-1)return ret;
	ret = 0;
	if(s[idx]=="AB"){
		if(a)ret = max(ret,go(idx+1,a-1,b+1,c));
		if(b)ret = max(ret,go(idx+1,a+1,b-1,c));
	}
	if(s[idx]=="AC"){
		if(a)ret = max(ret,go(idx+1,a-1,b,c+1));
		if(c)ret = max(ret,go(idx+1,a+1,b,c-1));		
	}
	if(s[idx]=="BC"){
		if(c)ret = max(ret,go(idx+1,a,b+1,c-1));
		if(b)ret = max(ret,go(idx+1,a,b-1,c+1));
	}
///	cout<<idx<<" "<<a<<" "<<b<<" "<<c<<" "<<ret<<endl;
	return dp[idx][a][b][c] = ret;
}
void gogo(int idx, int a, int b, int c){
	if(idx==n)return ;
	if(s[idx]=="AB"){
		if(a and dp[idx][a][b][c] == dp[idx+1][a-1][b+1][c]){
			cout<<"B"<<endl;
			gogo(idx+1,a-1,b+1,c);
			return ;
		}
		if(b and dp[idx][a][b][c] == dp[idx+1][a+1][b-1][c]){
			cout<<"A"<<endl;
			gogo(idx+1,a+1,b-1,c);
			return ;
		}
	}
	if(s[idx]=="AC"){
		if(a and dp[idx][a][b][c] == dp[idx+1][a-1][b][c+1]){
			cout<<"C"<<endl;
			gogo(idx+1,a-1,b,c+1);
			return ;
		}
		if(c and dp[idx][a][b][c] == dp[idx+1][a+1][b][c-1]){
			cout<<"A"<<endl;
			gogo(idx+1,a+1,b,c-1);
			return ;
		}
	}
	if(s[idx]=="BC"){
		if(c and dp[idx][a][b][c] == dp[idx+1][a][b+1][c-1]){
			cout<<"B"<<endl;
			gogo(idx+1,a,b+1,c-1);
			return ;
		}
		if(b and dp[idx][a][b][c] == dp[idx+1][a][b-1][c+1]){
			cout<<"C"<<endl;
			gogo(idx+1,a,b-1,c+1);
			return ;
		}
	}
}
void solve(){
	memset(dp,-1,sizeof dp);
	int a,b,c;
	cin>>n>>a>>b>>c;
	a = min(a,4); 
	b = min(b,4); 
	c = min(c,4); 
	for(int i=0;i<n;i++)cin>>s[i];
	int ans = go(0,a,b,c);
	if(ans==0){
		cout<<"No"<<endl;
		return ;
	}
	cout<<"Yes"<<endl;
	gogo(0,a,b,c);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 115368
from itertools import combinations
from cmath import phase

N = int(input())
xy = [complex(*map(int, input().split())) for _ in range(N)]
xy.sort(key=phase)
xy += xy
ans = 0
for i, j in combinations(range(N*2+1), 2):
    if j-i<=N:
        ans = max(abs(sum(xy[i:j])), ans)
print(ans)


Measured memory_bytes: 41196
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
int n;
int check(const vector<string> &v) {
	int a(0);
	rep(i, 0, n)rep(j, 0, n)if (v[i][j] == '#')a++;
	return a;
}
vector<int> horizontalcnt(const vector<string> &vec) {
	vector<int>w;
	rep(i, 0, n) {
		int c(0);
		rep(j, 0, n)if (vec[i][j] == '#')c++;
		w.push_back(c);
	}
	return w;
}
vector<int> virticalcnt(const vector<string> &vec) {
	vector<int>w;
	rep(i, 0, n) {
		int c(0);
		rep(j, 0, n)if (vec[j][i] == '#')c++;
		w.push_back(c);
	}
	return w;
}

vector<string> next(vector<string>v, int x, int y) {
	string s(v[x]);
	rep(i, 0, n) {
		v[i][y] = s[i];
	}
	return v;
}
int bfs(vector<string>v) {
	queue<pair<vector<string>, int>>q;
	q.push(make_pair(v, 0));
	while (!q.empty()) {
		auto g = q.front(); q.pop();
		if (check(g.first) == n*n)return g.second;
		rep(i, 0, n) {
			rep(j, 0, n) {
				auto h = next(g.first, i, j);
				auto d = check(h);

				if (d < g.second)continue;
				else if (g.second >= 6)continue;
				q.push(make_pair(h, g.second + 1));
			}
		}
	}
	return -1;
}
signed main() {
	vector<string>vec;
	cin >> n;
	vec = vector<string>(n); rep(i, 0, n)cin >> vec[i];
	
	int c(0);
	rep(i, 0, n) {
		bool f(false);
		rep(j, 0, n) {
			if (vec[j][i] == '.')f = true;
		}
		c += f;
	}
	int k(INF);
	rep(i, 0, n) {
		int x = count(all(vec[i]), '.');
		bool f(false);
		rep(j, 0, n) {
			if (vec[j][i] == '#')f = true;
		}
		if (f)k = min(k, x);
		else k = min(k, x + 1);
	}

	int cnt(0);
	rep(i, 0, n)rep(j, 0, n)if (vec[i][j] == '#')cnt++;
	if (cnt == 0)cout << -1 << endl;
	else cout << c + k << endl;




	//if (n == 2) {
	//	if (cnt == 0)cout << -1 << endl;
	//	else if (cnt == 4)cout << 0 << endl;
	//	else if (cnt == 3)cout << 1 << endl;
	//	else if ((vec[0][0] == '#' && (vec[0][1] == '#' || vec[1][0] == '#')) || (vec[1][1] == '#' && (vec[0][1] == '#' || vec[1][0] == '#')))cout << 2 << endl;
	//	else if (vec[0][0] == '#' || vec[1][1] == '#')cout << 3 << endl;
	//}
	//else if (n == 3) {
	//	auto a = horizontalcnt();
	//	auto b = virticalcnt();
	//	if (*max_element(all(a)) == n) {
	//		cout << n - count(all(b), n) << endl;
	//	}
	//	else if (*max_element(all(a)) == 1) {
	//		cout << 5 - count(all(b), n) << endl;
	//	}
	//	else if (*max_element(all(a)) == 2) {
	//		cout << dfs(vec, 0) << endl;
	//	}

	//}
	return 0;
}

Measured memory_bytes: 512
N = int(input())
list = list(map(int,input().split()))
ans = 0
cnt = 0
i = 1
while i < N:
	cnt = 0
	for j in range(i,N):
		if(list[j]<=list[j-1]):
			cnt+=1
		else:
			i+=1
			break
	ans = max(ans,cnt)
	i+=cnt
print(ans)

Measured memory_bytes: 14252
n=int(input())
s=input()

black=s.count("#")
white=s.count(".")
b=0
w=0
ans=float('inf')

for i in range(n):
  if s[i]=="#":
    b+=1
  elif s[i]==".":
    w+=1
  
  right_change=white-w
  now=b+right_change
  # print(now)
  ans=min(ans,now)
  
print(min(ans,black,white))


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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> wa(n, 0), ac(n, 0);
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            if (ac[p] == 0) {
                ac[p] = 1;
            }
        } else {
            if (ac[p] == 0) { // まだ AC していない
                wa[p]++;
            }
        }
    }

    int sol = 0, pen = 0;
    rep(i, n) {
        if (ac[i] == 1) {
            sol++;
            pen += wa[i];
        }
    }

    cout << sol << " " << pen << endl;
}

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




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=55;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,a,b;
    cin>>a>>b>>n;
    ll x=min(n,b-1);
    cout<<(a*x)/b;
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
	std::size_t n;
	std::cin >> n;
	std::vector<long long> a(n), b(n);
	for (std::size_t i = 0; i < n; i++) {
		std::cin >> a[i] >> b[i];
	}
	
	if (a == b) {
		std::cout << 0 << '\n';
	} else {
		long long sum = std::accumulate(a.begin(), a.end(), 0LL);
		long long min = (1LL << 60);
		for (std::size_t i = 0; i < n; i++) {
			if (a[i] > b[i]) min = std::min(min, b[i]);
		}
		std::cout << sum - min << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int ReadValue() {
    int value; 
    scanf("%d",&value);
    return value;
}
int binarySearch(int *Array,int index,int key) {
    int left=0;
    int right=index;
    while (left<right) {
        int mid=(left+right)/2;
        if (key==Array[mid]) {
            return 1;
        }
        if (key>Array[mid]) {
            left=mid+1;
        }
        else if (key<Array[mid]) {
            right = mid;
        }
    }
    return 0;
}
void ReadArray(int *Array,int index) {
    int i;
    for (i=0; i<index; i++) {
        scanf("%d",&Array[i]);
    }
}
int solve(int *Array,int index,int *Array1,int index1) {
    int ans=0;
    for (int i=0; i<index1; i++) {
        if (binarySearch(Array,index,Array1[i])) {
            ans++;
        }
    }
    return ans;
}
void display(int *Array,int index,int *Array1,int index1) {
    printf("%d\n",solve(Array,index,Array1,index1));
}
int main() {
    int n=ReadValue();
    int S[n]; ReadArray(S,n);
    int q=ReadValue();
    int T[q]; ReadArray(T,q);
    display(S,n,T,q);
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.size();
  int k;
  cin >> k;
  vector<string> a;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i + j <= n) {
        a.push_back(s.substr(i, j));
      }
    }
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  cout << a[k - 1] << '\n';
  return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    FOR(i,1,s.size()){
        if(s[i]==s[i-1]){
            cout << "Bad" << endl;
            return 0;
        }

    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] hw = scanner.nextLine().split(" ", 2);
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);

        String[] lines = new String[h];
        for (int i = 0; i < h; i++) {
            lines[i] = scanner.nextLine();
        }

        boolean[] deletedColumns = new boolean[w];
        for (int j = 0; j < w; j++) {
            boolean allDotColumn = true;
            for (int i = 0; i < h; i++) {
                if (lines[i].charAt(j) != '.') {
                    allDotColumn = false;
                    break;
                }
            }
            deletedColumns[j] = allDotColumn;
        }

        for (int i = 0; i < h; i++) {
            String line = lines[i];
            boolean allDotRow = true;
            for (int j = 0; j < w; j++) {
                if (line.charAt(j) != '.') {
                    allDotRow = false;
                    break;
                }
            }
            if (allDotRow) continue;

            for (int j = 0; j < w; j++) {
                if (!deletedColumns[j]) {
                    System.out.print(line.substring(j, j+1));
                }
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 23508
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int max =0;
        int min = 101;
        for(int i=0;i<3;i++){
            int task = scn.nextInt();
            max= Math.max(task,max);
            min=Math.min(task,min);
        }
        System.out.println(max-min);
    }
}


Measured memory_bytes: 22740
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k -a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47440
#include <stdio.h>
#define MAX_NUM (104730)

void enum_prime(char list[]) {
	int i, j;

	list[0] = list[1] = 0;
	for (i = 2; i < MAX_NUM; i++) {
		list[i] = 1;
	}
	for (i = 2; i < MAX_NUM; i++) {
		if (list[i] == 0)
			continue;
		for (j = i + i; j < MAX_NUM; j += i) {
			list[j] = 0;
		}
		if (MAX_NUM < i * i)
			break;
	}
}

int main() {
	int i, n, sum;
	char prime_list[MAX_NUM];

	enum_prime(prime_list);
	while (1) {
		scanf("%d ", &n);
		if (n == 0) {
			break;
		}
		sum = 0;
		for (i = 0; i < MAX_NUM; i++) {
			if (prime_list[i]) {
				sum += i;
				--n;
				if (n == 0) {
					break;
				}
			}
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 704
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 510;
int v[maxn][maxn], n, m, s[maxn][maxn];
void solve() {
	int n = ::n, m = ::m;
	memset(s, 0, sizeof(s));
	DE(n, ' '), DE(m, '\n');
	auto corner = [&](int x, int y) {
		return (x==1&&y==m) || (x==n&&y==1) || (x==n&&y==m);
	};
	int x = 1, y = 1, dx = 1, dy = 0;
	do {
		DE(x, ' '), DE(y, '\n');
		s[x][y] = 1;
		if (corner(x, y) || s[ x+dx*2 ][ y+dy*2 ]) {
			if (dx) swap(dx, dy);
			else swap(dx, dy), dx *= -1;
		}
		//if (x < 0 || y < 0) DE(n, ' '), DE(m, '\n'), exit(0);
		x += dx, y += dy;
		if (s[x][y]) break;
	} while (!s[x+dx][y+dy]);
	for (int i = 2;i < n;++i)
		for (int j = 2;j < m;++j)
			if (s[i][j] == 0) s[i][j] = 2;
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	solve();
	for (int i = 1;i <= n;++i)
		for (int j = 1;j <= m;++j) {
			char a;
			cin >> a;
			if (a == '#') v[i][j] = 0b11;
		}
	auto out = [&](int b) {
		for (int i = 1;i <= n;++i) {
			for (int j = 1;j <= m;++j) 
				putchar((v[i][j]|s[i][j])&b?'#' : '.');
			putchar('\n');
		}
	};
	out(0b01);
	putchar('\n');
	out(0b10);
}


Measured memory_bytes: 5660
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a = ri()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print('red')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOTFREE 1
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool B[N][N];
 
int printBoard(){
  int i,j;
 
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(B[i][j]){
	if(row[i] != j) return 0;
      }
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
int recursive(int i){
  int j;
  
  if(i == N){
    printBoard();
    return 0;
  }
  for(j = 0; j < N; j++){
 
    if(NOTFREE == col[j] || NOTFREE == dpos[i+j] || NOTFREE == dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOTFREE;
 
    recursive(i+1);
 
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){
  int i,j,n,irow,icol;
  
  for(i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
 
  for(i = 0; i < 2*N-1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }  
 
  for(i = 0; i < N; i++)
    for(j = 0; j < N; j++)
      B[i][j] = false;
 
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&irow,&icol);
    B[irow][icol] = true;
  } 
  recursive(0);
 
  return 0;   
}



Measured memory_bytes: 2112