akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) //これでiやjを定義しなくていいらしい
using namespace std;

int main(){
  int n;
  cin >> n;
  n %= 10;
  //cout << n;
  if(n==3)
    cout << "bon" << endl;
  else if(n==0 || n==1 || n==6 || n==8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;

  return 0;
}


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

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

    int A[6] = {0};
    
    for(int i=1; i<=3; i++)
    {
        int a, b;
        cin >> a >> b;
        
        A[a]++, A[b]++;
    }
    
    sort(A+1, A+5);
    
    if(A[1] == 1 && A[2] == 1 && A[3] == 2 && A[4] == 2)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define NUM 10000
#define rep(i,a,b) for(i = a; i < b; i++)
using namespace std;

int isPrime(int);

int main(void) {

  int i, n, judge, count = 0;
  int T[NUM] = {};

  cin >> n;

  rep(i,0,n) {

    cin >> T[i];

  }

  rep(i,0,n) {

    judge = isPrime(T[i]);

    if(judge == 1) {

      count++;

    }

  }

  cout << count << endl;

  return 0;

}

int isPrime(int x) {

  int i;

  if(x == 2) {

    return 1;

  } else if(x <= 1 || x % 2 == 0) {

    return 0;

  }

  for(i = 3; i <= sqrt(x); i += 2) {

    if (x % i == 0) {

      return 0;

    }

  }

  return 1;

}

Measured memory_bytes: 1208
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if (n==22) puts("Christmas Eve Eve Eve");
	if (n==23) puts("Christmas Eve Eve");
	if (n==24) puts("Christmas Eve");
	if (n==25) puts("Christmas");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <climits>
#include <complex>
#include <cmath>
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

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

const int maxN = 4e2 + 9, maxV = 5e5, MOD = 1e9 + 7 , lg = 20, LIM = 100;

int n, m;
string mat[maxN];
bool vi[maxN][maxN];

const int dr[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

ll ans, blc, whi;

bool ins(int x, int y){
    return x >= 0 && y >= 0 && x < n && y < m;
}

void dfs(int r, int c){
    vi[r][c] = 1;
    if(mat[r][c] == '.') blc++;
    else whi++;
    for(int i = 0; i < 4; i++){
        int x = r + dr[i][0], y = c + dr[i][1];
        if(ins(x, y) && mat[x][y] != mat[r][c] && !vi[x][y])
            dfs(x, y);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    cin >> n >> m;
    
    for(int i = 0; i < n; i++) cin >> mat[i];
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(!vi[i][j]){
                blc = whi = 0;
                dfs(i, j);
                ans += blc * whi;
            }
        }
    }
    cout << ans << '\n';
    
}

/*
 4
 7 2 3 4
 1
 1 4
 */


Measured memory_bytes: 18048
import math

def f(x, y, z):
  return(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

n = int(input())
fs = [0] * n

lim = math.floor(math.sqrt(n))
rng = range(1, lim)

for x in rng:
  for y in rng:
    for z in rng:
      v = f(x, y, z)
      if v <= n:
      	fs[v - 1] += 1
      
for i in range(n):
  print(fs[i])

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;
#define N 1000001

typedef long long int ll;

ll ans[N];

void pre() {
	ans[1] = 1;

	for (int i = 2; i < N; i++) {
		if (i%3 == 0 || i%5 == 0)
			ans[i] = ans[i-1];
		else
			ans[i] = ans[i-1] + i;
	}

	// for (int i = 0; i < N; i++)
	// 	cout << ans[i] << " ";
	// cout << endl;
}

int main() {

	IOS

	pre();

	int n;
	cin >> n;

	cout << ans[n];

	return 0;
}

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

int main(void) 
{
    int n, k ;
    cin >>n >> k;
    vector<int> snuke(n);
    rep(i,k){
        int d;
        cin >> d;
        vector<int>a(d);
        rep(j,d){
            cin >> a[j];
            snuke[a[j]-1]++;
        }
    }
    int ans =0;
    rep(i,n) if(snuke[i] == 0) ans++;
    cout << ans <<endl;
}

Measured memory_bytes: 3632
n,m=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
li.sort()
i=0
goukei=0
goukeiM=0
while goukei<m:
  if li[i][1]+goukei<=m:
    goukei+=li[i][1]
    goukeiM+=(li[i][1])*(li[i][0])
    i+=1
  else:
    goukeiM+=(m-goukei)*(li[i][0])
    goukei=m
print(goukeiM)

Measured memory_bytes: 27760
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void) {
    string S;
    cin>>S;
    int N;
    N=S.length();
    int A=0;

    for(int i=0;i<N;i++){
        if(i%2==0){
            if(S[i]!='L'){
                A++;
            }
        }
        else{
            if(S[i]!='R'){
                A++;
            }
        }

    }
    if(A==N){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



}


Measured memory_bytes: 256
n,m,c=map(int, input().split())
b=[int(i) for i in input().split()]

count=0
for i in range(n):
    a=[int(i) for i in input().split()]
    sum=c
    for j in range(m):
        sum+=a[j]*b[j]
    
    if sum>0:
        count+=1
        
print(count)


Measured memory_bytes: 9188
#include<stdio.h>
#include<string.h>
int main(){
	int n,m,i,j,ans,x[20];
	int 	a[20],	//a[i]cå«¢û©çiÔÚÜÅðAÉ^Ôñ
		c[20],	//c[i]cå«¢û©çiÔÚÜÅðAÉ^Ôñ
		p[20],	//p[i]cêÔ[ÉæÁ½nÂð½ÎÌêÔ[É^Ô½ßÌñ
		d[3][20],	//úóÔÛ¶p
		b[5];		//eñÉ¢­Â é©
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		memset(d,0,sizeof(d));ans=0;
		for(i=0;i<3;i++){
			scanf("%d",&b[i]);
			for(j=0;j<b[i];j++){
				scanf("%d",&d[i][j]);
				x[d[i][j]]=i;
			}
		}
		
		//êÔ[ÉæÁ½nÂð½ÎÌêÔ[É^Ô½ßÌñ
		p[1]=2;
		for(i=2;i<=15;i++)p[i]=p[i-1]*3+2;
		
		if(x[n]==0)		a[1]=0,c[1]=2;
		else if(x[n]==1)	a[1]=1,c[1]=1;
		else 			a[1]=2,c[1]=0;
		for(i=1;i<n;i++){
			//å«¢û©çi+1ÔÚÌàÌÌêÅêª¯µDP
			if(x[n-i]==0){
				a[i+1]=a[i];
				c[i+1]=c[i]+1+p[i]+1+p[i];
			}else if(x[n-i]==1){
				a[i+1]=c[i]+1+p[i];
				c[i+1]=a[i]+1+p[i];
			}else{
				a[i+1]=a[i]+1+p[i]+1+p[i];
				c[i+1]=c[i];
			}
		}
		//for(i=1;i<=n;i++)printf("%d %d\n",a[i],c[i]);
		ans=(a[n]>c[n])?c[n]:a[n];
		if(ans>m)ans=-1;
		printf("%d\n",ans);
	}
	return 0;
}

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
	for(int i = g; i < n; i++){
		int v = A[i];
		int j = i - g;
		while(j >= 0 && A[j] > v){
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n){
	for(int h = 1; ;){
		if(h > n)break;
		G.push_back(h);
		h = 3*h + 1;
	}
	
	for(int i = G.size()-1; i >= 0; i--){
		insertionSort(A, n, G[i]);
	}
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++)scanf("%d",&A[i]);
	cnt = 0;
	
	shellSort(A, n);
	
	cout << G.size() << endl;
	for(int i = G.size() - 1; i >= 0; i--){
		printf("%d",G[i]);
		if(i)printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
	for(int i = 0; i < n; i++)printf("%d\n",A[i]);
	
	return 0;
}

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

int main(){
  int n;
  vector<int> a;
  while(cin >> n, n){
    a.clear();
    a.resize(n);
    int res = 99999999;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
      if(abs(a[i]-a[i+1])<res){
        res = abs(a[i]-a[i+1]);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int k,x;
    cin>>k>>x;
    if(500*k>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ct = 0;
    for (int i = l; i < r + 1; ++i)
    {
        if (i % d == 0)
        {
            ++ct;
        }
    }
    cout << ct << endl;
}


Measured memory_bytes: 3616
// Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
while(true){
	string S;
	cin >> S;
if(cin.eof())  break;
	int joi = 0;
	int ioi = 0;

	string::size_type I = 0;
	while(true){
		I = S.find("JOI", I);
		if(I==string::npos)
			break;
		joi++;
		I++;
	}

	I = 0;
	while(true){
		I = S.find("IOI", I);
		if(I==string::npos)
			break;
		ioi++;
		I++;
	}

	cout << joi << '\n';
	cout << ioi << '\n';
}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// #define int int64_t
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> l(Q), r(Q);
	for (int i=0; i<Q; i++) {
		cin >> l.at(i) >> r.at(i);
	}
	
	vector<int> chk(N+1);
	chk.at(0) = 0;
	for (int i=0; i<N-1; i++) {
		if (S.at(i) == 'A' && S.at(i+1) == 'C') chk.at(i+1) = chk.at(i) + 1;
		else chk.at(i+1) = chk.at(i);
	}
		
	for (int i=0; i<Q; i++) {
		cout << chk.at(r.at(i)-1) - chk.at(l.at(i)-1) << endl;
	}
		
}


Measured memory_bytes: 2256
N, W = [int(x) for x in input().split()]
items = []
for i in range(N):
    items.append(tuple(int(x) for x in input().split()))


DP = [[0] * (W+1) for _ in range(N+1)]
# DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])
for i in range(N):
    for j in range(W+1):
        v, w = items[i]
        if w <= j:
            DP[i+1][j] = max(DP[i][j], v + DP[i][j-w])
        else:
            DP[i+1][j] = DP[i][j]

print(DP[-1][-1])

Measured memory_bytes: 25500
fn main() {
    let v: Vec<i32> = read_vec();
    if v[0] == v[1] {
        println!("{}", v[2]);
    } else if v[1] == v[2] {
        println!("{}", v[0]);
    } else {
        println!("{}", v[1]);
    }
}

// ######################################################################## //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0;
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
arr = []

for _ in range(m):
    p, s = input().split()
    arr.append((int(p), s))

ans = [[0, 0] for _ in range(n)]
for p, s in arr:
    if s == 'AC':
        ans[p - 1][0] = 1
    else:
        if ans[p - 1][0] == 0:
            ans[p - 1][1] += 1

oks = 0
ngs = 0
for ok, ng in ans:
    if ok == 1:
        oks += 1
        ngs += ng

print(oks, ngs)


Measured memory_bytes: 30988
#include <iostream>
#include <iomanip>
#define ll long long
#define f(i, n) for (int i=1; i <= n; i++)
// sort(bb, bb+n);

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    double n;
    cin >>n;
    cout<< setprecision(12) << fixed << (n/3)*(n/3)*(n/3); 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
        int m,m1;
	cin>>m;
	int sum=1;
	for(int i=1; ;i++)
	{
		if(i*i>m)
		{
		cout<<sum*sum;
		break;
		}
		else
		sum=i;
	}
	return 0;
}

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

int	min(int a, int b)
{
	return ((a < b) ? a : b);
}

int	main(void)
{
	int	N, i, j, res = 0, tmp;
	int	*X;

	scanf("%d", &N);
	X = malloc(sizeof(int) * N);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &X[i]);
		res += X[i] * X[i];
	}
	for (i = 1; i <= 100; i++)
	{
		tmp = 0;
		for (j = 0; j < N; j++)
		{
			tmp += (i - X[j]) * (i - X[j]);
		}
		res = min(res, tmp);
	}
	printf("%d\n", res);
	return (0);
}

Measured memory_bytes: 1732
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(ReadLine());
            int count = 0;
            var b = 0;
            var c = 0;
            var d = 0;
            b = a / 100;
            a = a % 100;
            c = a / 10;
            a = a % 10;
            if (b == 1) {
                count++;
            }
            if (c == 1) {
                count++;
            }
            if (a == 1) {
                count++;
            }
            WriteLine("{0}", count);
            ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n; cin >> n;
    priority_queue<ld, vector<ld>, greater<ld> > pq;
    rep(i,n){
        ld temp;cin >> temp;
        pq.push(temp);
    }
    while(2 <= pq.size()){
        ld a = pq.top();pq.pop();
        ld b = pq.top();pq.pop();
        pq.push((a + b)/2.0);
    }

    ld ans  = pq.top();
    cout << ans << endl;
    // cout << pq.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> read(int n)
{
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d\n", &v[i]);
	sort(v.begin(), v.end());
	return v;
}

int main()
{
	const vector<int> pasta = read(3);
	const vector<int> juice = read(2);
	const int res = pasta[0] + juice[0] - 50;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1044
#include <iostream>
using namespace std;
int main()
{
 	int n;
  	cin >> n;
  	int x;
  	int max = 0;
  	long long int answer = 0;
  	for (int i = 0; i < n; i++)
    {
     	cin >> x;
      	if (x > max)
          max = x;
      	else answer += (max - x);
    }
  	cout << answer;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;
// const ll use =1e18;

ll fun(ll n)
{
	ll l=1,r=100000000;
	ll ans=1;

	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		ll val=mid*(mid+1)/2;

		if(val<=n)
		{
			ans=max(ans,mid);
			l=mid+1;
		}
		else r=mid-1;
	}
	return ans;
}

int main()
{ 

ll n;
cin>>n;
vector<ll> v;

if(n==1)
{
	cout<<0<<endl;
	return 0;
}

vector<ll> prime;
vector<bool> pr(5000000,1);
pr[0]=0;
pr[1]=0;

for(ll i=2;i<5000000;i++)
	if(pr[i])
	for(ll j=i*i;j<5000000;j+=i)
		pr[j]=0;

for(ll j=2;j<5000000;j++)
if(pr[j])prime.pb(j);

for(ll i:prime)
{
	if(n==1)
		break;
	if(n%i==0)
	{
		ll ct=0;
		while(n%i==0)
			n/=i,ct++;
		v.pb(ct);
	}
}

ll ans=0;

if(n!=1)ans++;

if(!v.empty())
for(auto i:v)
ans=ans+fun(i);

cout<<max((ll)1,ans)<<endl;

}


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

int main()
{
  int n;
  cin >> n;
  vector<int> ans(n);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int k = x*x + y*y + z*z + x*y + y*z + z*x;
        if (k <= n) ans[k - 1]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;

ll f(ll x,ll y){
  if(x==-1){
    return 0;
  }
  else{
    return (x/y)+1;
  }
}


int main() {
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans=f(b,x)-f(a-1,x);
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key=lambda x: x[1])
timer = 0

for i in range(N):
  timer += AB[i][0]
  if timer > AB[i][1]:
    print("No")
    exit()
    
print("Yes")

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int h,w,c = 0;
int main() {
    cin >> h >> w;

    char a[h][w];
    rep(i,0,h){
        rep(j,0,w){
            cin >> a[i][j];
            if(a[i][j] == '#') c++;
        }
    }
    if(h+w-1 == c) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}

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

int main() {
  int hmc, hmr;
  cin >> hmc >> hmr;
  
  int num;
  vector<int> cr(hmr * 2);
  for (int i = 0; i < cr.size(); i++) {
    cin >> cr.at(i);
  }
  
  for (int j = 1; j <= hmc; j++) {
    int l = 0;
    for (int k = 0; k < cr.size(); k++) {
      if (cr.at(k) == j) {
        l++;
      }
    }
    cout << l << endl;
  }
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

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

  map<char, int> mp;

  for(int i = 0; i < 10; i++) mp['0' + i] = i;
  for(int i = 0; i < 6; i++) mp['a' + i] = 10 + i;

  int q;
  cin >> q;

  cout << showpoint;
  for(int i = 0; i < q; i++) {
    string s;
    cin >> s;
    signed x = 0;
    int sgn = 1;
    for(int j = 0; j < 8; j++) {
      int v = mp[s[j]];
      if(j == 0 && (v & 8)) {
        v ^= 8;
        sgn = -1;
      }
      x += v << ((7 - j) * 4);
    }
    double ans = sgn * (double(x) / (1 << 7));
    stringstream ss;
    // ss << showpoint;
    ss << fixed << setprecision(10);
    ss << ans;
    string g;
    ss >> g;
    while(g[g.size()-1] == '0' && g[g.size()-2] != '.') g.pop_back();
    cout << g << "\n";
  }

  return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

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

#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	map<ll,ll>ans;
	vll v;
	ll a[n];rep(i,0,n)cin>>a[i],v.pb(a[i]);
	sort(all(v));
	rep(i,0,n){
		if(i<n/2)ans[v[i]]=v[n/2];
		else ans[v[i]]=v[n/2-1];
	}
	rep(i,0,n)cout<<ans[a[i]]<<"\n";
	return 0;
}



Measured memory_bytes: 17520
#include <iostream>
using namespace std;

int main(){
  int N,A,B,div,Now_i = 0,sum = 0,Answer = 0; cin >> N >> A >> B;
  for (int i = 1;i <= N;i++){
    Now_i = i;
    while (Now_i){
      div = Now_i%10 ; sum += div ; Now_i /= 10 ;
    }
    if (A <= sum && sum <= B){
      Answer += i;
    }
    sum = 0;
  }
  cout << Answer <<endl;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

S = input()
w = I()
print(S[::w])

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#define INT long long
#define MOD 1000000007
#define oo 987654321
#define OO 999999987654321ll
using namespace std;

INT x, y, ans;
queue<int> q;
int main()
{
    cin>>x>>y;
    ans = (y-x)>=0?(y-x):OO;
    ans = min(ans, (-y-x)+1>=0?(-y-x)+1:OO);
    ans = min(ans, (y+x)+1>=0?(y+x)+1:OO);
    ans = min(ans, (-y+x)+2>=0?(-y+x)+2:OO);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll dp[110000][13];
string s;
int main() {
	dp[0][0] = 1;
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == '?') {
			REP(j, 10) {
				REP(k, 13) {
					dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
					dp[i + 1][(k * 10 + j) % 13] %= MOD;
				}
			}
		}
		else {
			ll j = s[i] - '0';
			REP(k, 13) {
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
				dp[i + 1][(k * 10 + j) % 13] %= MOD;
			}
		}
	}
	cout << dp[s.size()][5] << endl;
}
	


Measured memory_bytes: 10752
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var dates = new Tuple<int, int>[2];
        for (int i = 0; i < dates.Length; ++i)
        {
            var md = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            dates[i] = Tuple.Create(md[0], md[1]);
        } 

        Console.WriteLine(dates[1].Item1 - dates[0].Item1);
    }
}


Measured memory_bytes: 13396
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var R = int.Parse(buffer[0]);
            var D = int.Parse(buffer[1]);
            var X = int.Parse(buffer[2]);

            var tmp = X;
            for (int i = 0; i < 10; i++)
            {
                tmp = tmp * R - D;
                Console.WriteLine(tmp);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27484
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.next());
        int cake = Integer.parseInt(sc.next());
        int donut = Integer.parseInt(sc.next());
        
        System.out.println((total-cake)%donut);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ba=0,b1=1,x;
	cin>>n>>x;
	for(int t=0;t<n;t++)
	{
		int l; 
		cin>>l;
		ba+=l;
		if(ba<=x)
		{
			b1++; 
		}
	}
	cout<<b1;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string ans="APPROVED";
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if(x%2==0)
    {
      if(x%3 && x%5)
        ans="DENIED";
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	ss := strings.Split(s, "")
	ts := strings.Split(t, "")

	sort.Strings(ss)
	sort.Sort(sort.Reverse(sort.StringSlice(ts)))

	rs := strings.Join(ss, "")
	rt := strings.Join(ts, "")

	if rs < rt {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int n,i,a,b,c,d;

  i = 0;
  while(i < 50){
    int ans = 0;
    scanf("%d", &n);
    if(!(n > 0 && n <= 50)){
      break;
    }
    if(n <= 36){
      for(a = 0;a <= 9;a++){
	for(b = 0;b <= 9;b++){
	  for(c = 0;c <= 9;c++){
	    for(d = 0;d <= 9;d++){
	      if((a+b+c+d) == n){
		ans++;
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n", ans);
    i++;
  }
  return 0;
}

Measured memory_bytes: 2576
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x; cin >> x;
    for(ll i=-1; i<=1000; ++i) {
        for(ll j=i-1000; j<=i; ++j) {
            if (pow(i,5)-pow(j,5)==x) {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int a[512345];
int b[212345];
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>b[i];
	}
	int left =212345,right=left+1;
        for(int i=0;i<N;i++){
			if(i%2==(N-1)%2){
                a[left--]=b[i];
			}
			else{
				a[right++]=b[i];
			}
		}
		
		for(int i=left+1;i<right;i++){
			if(i!=left+1){
				cout<<" ";
			}
			cout<<a[i];
		}
		cout<<endl;
    return 0;
}

Measured memory_bytes: 5164
N = int(input())
s = input()
t = input()
for K in range(N):
    flag = 1
    for i in range(N-K):
        if s[i+K]!=t[i]:
            flag = 0
            break
    if flag == 1:
        print(N+K)
        exit()
print(2*N)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)


int main()
{
	int N;
	vector<int> a;
	cin >> N;
	REP(i, 0, N) {
		int aa;
		cin >> aa;
		a.push_back(aa);
	}
	sort(a.begin(), a.end());

	int ans = 0;
	REP(i, 0, N - 1) ans += (a[i + 1] - a[i]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double n;
    cin >> n;
    double side = n / 3;
    double volume = side * side * side;
    printf("%.12f", volume);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int t = sc.nextInt();

		X = X-t;

		if(X>0){
			System.out.println(X);
		}
		else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 21716
open Scanf
open Printf

let rec for_iter a b f = if a >= b then () else (f a; for_iter (a+1) b f)
let rec for_iterr a b f = if a <= b then () else (f a; for_iter (a-1) b f)
let rec for_iters a b s f = if (a-b >= 0) <> (s >= 0) then () else (f a; for_iter (a+s) b f)

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)
let read_ints_arr n = Array.init n (fun _ -> read_int ())
let read_ints_arr_ref n = Array.init n (fun _ -> ref (read_int ()))

let solve a b c x =
  let rec f u v w acc =
    let acc' = acc + if 500 * u + 100 * v + 50 * w = x then 1 else 0 in
    if w < c then f u v (w+1) acc'
    else if v < b then f u (v+1) 0 acc'
    else if u < a then f (u+1) 0 0 acc'
    else acc'
  in f 0 0 0 0

let () =
  let a = read_int () in
  let b = read_int () in
  let c = read_int () in
  let x = read_int () in
  printf "%d\n" (solve a b c x)


Measured memory_bytes: 384
def z(s):
    n = len(s)
    a = [0]*n
    a[0] = n
    i, j = 1, 0
    while i < n:
        while i+j<n and s[j]==s[i+j]:
            j += 1
        a[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k<n and k+a[k]<j:
            a[i+k] = a[k]
            k += 1
        i += k
        j -= k
    return a
n = int(input())
s = input()
r = 0
for i in range(n):
    a = z(s[i:])
    for j in range(len(a)):
        if a[j] <= j:
            r = max(r, a[j])
print(r)

Measured memory_bytes: 48988
#include<stdio.h>
int main(void)
{
	int n;
	int a, b;

	scanf("%d", &n);
	scanf("%d %d", &a,&b);
	if (n*a > b) {
		printf("%d\n", b);
	}
	else {
		printf("%d\n", a*n);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n, a) for(int i = a; i < n; ++i)
 
int main(void) {
  int n, i, j, st = 0;
  scanf("%d", &n);
  char a[n][5], b[n][5], s[n][5];
  rep(i, n) {
    scanf("%s", a[i]);
    rep(j, 5) b[i][j] = a[i][j], s[i][j] = a[i][j];
  }
  /*bubblesort*/
  int flag = 1;
  rep(i, n) {
    flag = 0;
    for(j = n - 1; j > i; --j) {
      if(b[j][1] < b[j - 1][1]) {
        char t;
        t = b[j][0], b[j][0] = b[j - 1][0], b[j - 1][0] = t;
        t = b[j][1], b[j][1] = b[j - 1][1], b[j - 1][1] = t;
       }
    }
  }
  /*selectionsort*/
  rep(i, n) {
    int minj = i;
    char t;
    repi(j, n, i) if(s[j][1] < s[minj][1]) minj = j;
    t = s[i][0], s[i][0] = s[minj][0], s[minj][0] = t;
    t = s[i][1], s[i][1] = s[minj][1], s[minj][1] = t;
  }
  rep(i, n) {
    if(i) printf(" %s", b[i]);
    else printf("%s", b[i]);
  }
  printf("\nStable\n");
  rep(i, n) {
    if(s[i][0] != b[i][0]) st = 1;
    if(i) printf(" %s", s[i]);
    else printf("%s", s[i]);
  }
  if(st) printf("\nNot stable\n");
  else printf("\nStable\n");
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int judge(string t, string h)
{
	int comp_num;
	int ret_if_draw;
	if (t.size() > h.size())
	{
		comp_num = h.size();
		ret_if_draw = 1;
	}
	else if (t.size() < h.size())
	{
		comp_num = t.size();
		ret_if_draw = -1;
	}
	else
	{
		comp_num = t.size();
		ret_if_draw = 0;
	}
	transform(t.begin(), t.end(), t.begin(), ::tolower);
	transform(h.begin(), h.end(), h.begin(), ::tolower);
	for (int i = 0; i < comp_num; i++)
	{
		if (t[i] != h[i])
		{
			return (int)(t[i] - h[i]);
		}
	}
	return ret_if_draw;
}

int main()
{
	int n;
	cin >> n;
	string hand_t, hand_h;
	int point_t = 0;
	int point_h = 0;
	int res;
	for (int i = 0; i < n; i++)
	{
		cin >> hand_t >> hand_h;
		res = judge(hand_t, hand_h);
		if (res > 0)
		{
			point_t += 3;
		}
		else if (res < 0)
		{
			point_h += 3;
		}
		else
		{
			point_t++;
			point_h++;
		}
	}
	cout << point_t << " " << point_h << endl;
}


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

int mod = 1000000007;

int main()
{
    int64_t A, B, X;
    cin >> A >> B >> X;
    if (A + B <= X)
        cout << "0 0";
    else if (A <= X)
        cout << 0 << " " << B - (X - A);
    else
        cout << A - X << " " << B;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(){}
stack<int>st;
void dfs(int u,vv &graph,vector<bool> &vst)
{
	for(auto it:graph[u])
	{
			if(!vst[it])
			{
				vst[it]=true;
				dfs(it,graph,vst);
			}
	}
	st.push(u);
}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // int tt=1;
    // tc{

    //	cout<<"Case #"<<tt++<<": "<<solve()<<endl;
    //}
	int n,m;cin>>n>>m;
	vv graph(n);
	f(i,m)
	{
		int a,b;cin>>a>>b;a--;b--;
		graph[a].pb(b);
	}
	vector<bool> vst(n,false);
	for(int i=0;i<n;i++)
	{
		if(!vst[i])
		{
			vst[i]=true;
			dfs(i,graph,vst);
		}
	}
	v arr;
	while(!st.empty())
	{
		arr.pb(st.top());
		st.pop();
	}
	v dp(n,0);

	for(int i=n-1;i>=0;i--)
	{
		int ans=0;
		for(auto it:graph[arr[i]])
		{
			ans=max(ans,dp[it]);
		}
		dp[arr[i]]=1+ans;
	}
	int mx=0;
	f(i,n)
	mx=max(mx,dp[i]);
	cout<<mx-1<<endl;
	return 0;
}

Measured memory_bytes: 10916
n = int(input())
d,x = map(int, input().split())
a = [int(input()) for i in range(n)]
sum=x
for j in range(n):
    for i in range(1,d+1):
        if (i-1)*a[j]+1>d:
            break
        else:
            sum+=1
print(sum)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N; cin>>N;
    string s; cin >> s;
    vector<lint> cntb(N+1, 0);
    vector<lint> cntw(N+1, 0);
    REP(i, N){
        if(s[i]=='#') cntb[i+1]=1;
        if(s[i]=='.') cntw[i+1]=1;
    }
    REP(i, N) cntb[i+1] += cntb[i];
    REP(i, N) cntw[i+1] += cntw[i];
    lint res = min(cntb[N], N-cntb[N]);
    //REP(i, N+1) cout<<cntb[i];
    //cout << endl;
    //REP(i, N+1) cout<<cntw[i];
    //cout << endl;
    REP(i, N){
        lint l, r;
        l = cntb[i];
        r = cntw[N] - cntw[i];
        res = min(res, l+r);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

struct unionfind{
    vector<int> par;
    
    unionfind(int N):par(N){
        for(int i=0;i<N;i++) par[i]=i;
    }
    
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        par[rx]=ry;
    }
    
    bool same(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
};

int main(void){
   int N,M;
   cin>>N>>M;
   int p[N];
   for(int i=0;i<N;i++){
       cin>>p[i];
   }
   int x[M],y[M];
   for(int i=0;i<M;i++){
       cin>>x[i]>>y[i];
   }
   unionfind tree(N+1);
   for(int i=0;i<M;i++){
      tree.unite(x[i],y[i]);
   }
   int count=0;
   for(int i=0;i<N;i++){
       if(p[i]==i+1){count++;}
       else if(tree.same(p[i],i+1)){count++;}
   }
   cout<<count;
   return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
N,M=map(int,input().split());S=input()[:-1]
if S.find("1"*M)>0:
  print(-1)
  exit()
k=[N+1]*(N+1)
k[0]=N
c=1
for i in range(N-1,-1,-1):
  if int(S[i])==0:
    if k[c-1]-i <= M:
      k[c]=i
    else:
      c+=1
      k[c]=i

print(*[j-i for i,j in zip(k[c::-1],k[c-1::-1])])

Measured memory_bytes: 9500
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  char ans = 0;
  for(char a = 'a'; a <= 'z'; ++a){
    bool ok = true;
    for(int i = 0; i < s.length(); ++i){
      if(s[i] == a) {
        ok = false;
        break;
      }
    }
    if(ok) {
      ans = a;
      break;
    } 
  }
  if(ans != 0)  cout << ans << endl;
  else cout << "None" << endl;
}


Measured memory_bytes: 512
import heapq
n = int(input())
stw = []
x_list = []
y_list = []
for i in range(n):
  x, y = map(int, input().split())
  x_list += [[x, i]]
  y_list += [[y, i]]

x_list.sort()
y_list.sort()

for i in range(n-1):
  stw += [[x_list[i][1], x_list[i+1][1], abs(x_list[i][0]-x_list[i+1][0])]]
for i in range(n-1):
  stw += [[y_list[i][1], y_list[i+1][1], abs(y_list[i][0]-y_list[i+1][0])]]

stw.sort(key=lambda x:x[2])

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())


def kruskal():
  # stw = [[s0, t0, w0], [s1, t1, w1], ..., [sn, tn, wn]]
  # stw: s: 始点, t: 終点, w: st間の重み
  # stwはwを小さい順にソートされたものとする
  # s, tを入れ替えたものはいれなくていい
  res = 0
  uf = UnionFind(n)
  for i in range(len(stw)):
    s, t, w = stw[i]
    if not uf.isSameGroup(s, t):
      uf.Unite(s, t)
      res += w
  return res

ans = kruskal()
print(ans)

Measured memory_bytes: 63524
import java.util.Scanner;

public class Main{
  static final int INF = Integer.MAX_VALUE / 2;
  static long n;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextLong();

    int min = INF;
    for(long a = 1; a * a <= n; a++){
      if(n % a == 0){
        min = Math.min(min, f(a, n / a));
      }
    }

    System.out.println(min);
  }

  private static int f(long a, long b){
    int ka = 0, kb = 0;
    while(a != 0){
      ka++;
      a /= 10;
    }
    while(b != 0){
      kb++;
      b /= 10;
    }
    return Math.max(ka, kb);
  }
}


Measured memory_bytes: 21972
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int ans = 0;
  int cnt = 0;
  for(int i=0;i<N;i++){
    if(s[i] == 'S') cnt++;
    if(s[i] == 'T' && cnt > 0){
      ans++;
      cnt--;
    }
  }

  cout << N - 2 * ans << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    IN(ll, K);
    ll ans = min(A, K);
    K -= min(A, K);
    K -= min(B, K);
    ans -= min(C, K);
    OUT(ans);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

vector<int>v[100001];
int sum[100001];
int ans[100001];

vector<P>pre;
priority_queue<int,vector<int>,greater<int> >pq;

signed main(){
  int n;
  cin>>n;
  r(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
    pre.push_back(P(a,b));
    sum[a]++;
    sum[b]++;
  }

  queue<int>q;


  r(i,n){
    int x;
    cin>>x;
    pq.push(x);
  }

  r(i,n){
    if(sum[i]==1){
      q.push(i);
      sum[i]--;
      ans[i]=pq.top();pq.pop();
    }
  }

  while(!q.empty()){
    int now=q.front();q.pop();


    r(i,v[now].size()){
      int nex=v[now][i];
      //cout<<nex<<endl;
      if(!sum[nex])continue;
      sum[nex]--;
      if(sum[nex]==1){
        sum[nex]--;
        ans[nex]=pq.top();pq.pop();
        q.push(nex);
      }
    }
  }

  int score=0;

  r(i,n-1){
    score+=min(ans[pre[i].fi],ans[pre[i].se]);
  }

  cout<<score<<endl;
  r(i,n){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+7;
const int mo=1e9+7;
#define ll long long
int a[MAXN],n,m,win;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) if(a[i]%2==1) win=1;
	if(win==1) cout<<"first";
	else cout<<"second";
}


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

int main()
{

	long long int N;
	long long int len = 1000000000000;

	scanf("%lld", &N);

	for (int i = 1; i < sqrt(N)+1; i++)
	{
		if (N%i == 0)
		{
			//printf("%lld %d \n", N/i,i);
			if ((N/i + i-2) < len)
				len = N/i + i-2;
		}
	}

	printf("%lld", len);

	return 0;
}
	

Measured memory_bytes: 128