akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;

int main(){
    int r,g,b;
    cin>>r>>g>>b;
    if((r*100+g*10+b)%4==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  int cnt = 0;
  rep(i, n) {
    string s; cin >> s;
    if (s == "A") cnt++;
    else cnt--;
    if (cnt < 0) no();
  }
  if (cnt != 0) no();
  yes();
}



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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
	int n; scanf("%d", &n);
	int p4 = 0, p2 = 0, p0 = 0;
	for(int i = 1; i <= n; ++i){
		int x; scanf("%d", &x);
		if(x % 4 == 0) ++p4;
		else if(x % 2 == 0) ++p2;
		else ++p0;
	}
	(p0 <= p4 || (p0 == p4 + 1 && p2 == 0)) ? puts("Yes") : puts("No");
	
}



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

int main() {
  
  int A,B,C,D;
    cin >> A >> B >> C >> D ;
  
  if ( A + B > C + D ) {
    cout << "Left" << endl;
  }
  
  else if ( A + B == C + D ) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
  
}

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

using namespace std;

int main() {
  int n, l;
  cin >> n >> l;
  int sum = 0;
  int diff = 500;
  int tmp;
  for (int i = 1;i<=n;i++){
    sum += l + i -1;
    if(diff > abs(l + i -1)){
      diff = abs(l+i-1);
      tmp = l + i -1;
    }
  }
  cout<<sum-tmp<<endl;
  return 0;
}

Measured memory_bytes: 384
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        c: usize,
        s: chars,
    }
    let mut diff = c;
    let mut r = Vec::new();
    for (index, ch) in s.iter().enumerate() {
        if *ch == 'o' && diff >= c {
            diff = 0;
            r.push(index);
            if r.len() == k {
                break;
            }
        } else {
            diff += 1;
        }
    }

    let mut diff = c;
    let mut l = Vec::new();
    for (index, ch) in s.iter().enumerate().rev() {
        if *ch == 'o' && diff >= c {
            diff = 0;
            l.push(index);
            if l.len() == k {
                break;
            }
        } else {
            diff += 1;
        }
    }

    let ans = r.iter().zip(l.iter().rev()).filter(|(x, y)| x == y).map(|(x, _)| *x);

    for day in ans {
        println!("{}", day + 1);
    }
}


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

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

    long long n;
    cin >> n;

    set<long long> D;
    for(int i = 1; i <= (int)sqrt(n); i++){
        if(n % i == 0){
            D.insert(i);
            D.insert(n / i);
        }
    }

    long long ans = 0;
    for(auto d: D){
        if(n % d) continue;
        long long m = n / d - 1;
        if(m == 0) continue;
        if(n / m == n % m) ans += m;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
 
int main(void) {
    int n = 0;
    int num[2001] = {};     //????????????????????????°????????????°1.
    int a = 0;                  //????????\??????????????´?.
    int q = 0;
 
    int i = 0;
    int j = 0;
 
    scanf("%d", &n);
 
    //??????§????????????°????????´?.
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
 
        num[0] = 1;
 
        for (j = 2000; j >= 0; j--) {
            if (num[j] && j + a < 2001)
                num[j + a] = 1;
        }
    }
 
    //??????.
    scanf("%d", &q);
 
    for (i = 0; i < q; i++) {
        scanf("%d", &a);
 
        if (num[a])
            printf("yes\n");
        else
            printf("no\n");
    }
 
    return 0;
}

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

public class Main {
    static int n = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += array[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 39264
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef vector<long> vi;
typedef vector<vi> vvi;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

const long inf = 1e15;

struct edge {
    long to,cost;
};
struct state {
    long v, cost;
    bool operator<(const state& r) const {
        return cost>r.cost;
    }
};

int dijk(const vector<vector<edge>> & G){
    vi dis(G.size(),inf);
    priority_queue<state> q;
    dis[0]=0;
    q.push({0,0});

    while(q.size()){
        state sta=q.top();
        q.pop();

        if(dis[sta.v] > sta.cost) continue;

        const vector<edge>& es=G[sta.v];
        rep(i, es.size()){
            if(dis[es[i].to] <= dis[sta.v] + es[i].cost) continue;
            dis[es[i].to] = dis[sta.v] + es[i].cost;
            q.push({es[i].to, dis[es[i].to]});
        }
    }

    return dis[G.size()-1];
}

int main(){
    int L,n;
    while(cin>>L>>n){
        map<long,int> m;
        vector<long> s(n), g(n), t(n);
        rep(i,n){
            int pp,dd,tt;
            cin>>pp>>dd>>tt;
            s[i]=pp, g[i]=pp+dd, t[i]=tt;
            m[pp]=m[pp+dd]=0;
        }
        if(n==0){
            cout << L << endl;
        } else {
            m[0]=m[L]=0;
            int i=0;
            for(auto & p:m){
                p.second = i++;
            }

            vector<vector<edge>> G(m.size());
            rep(i,n){
                if(t[i] < g[i] - s[i]){
                    G[m[s[i]]].push_back({m[g[i]], min(t[i], g[i]-s[i])});
                }
            }
            auto it=m.begin();
            it++;
            auto jt=it;
            it--;
            while(jt!=m.end()){
                G[it->second].push_back({jt->second, jt->first-it->first});
                it++;
                jt++;
            }
            cout << dijk(G) << endl;
        }
    }
}


Measured memory_bytes: 1516
#include <iostream>

using namespace std;

int main()
{
	int H, N, A = 0, tmp;
	cin >> H >> N;
	for (int count = 0; count < N; count++)
	{
		cin >> tmp;
		A += tmp;
	}
	if (A >= H)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

int main(){
	int N,l;
  string s;
  cin >> N >> s;
  l = s.size();
	if(l <= N){
      cout << s << endl;
    }else{
      for(int i = 0;i < N;i++){
        cout << s.at(i);
      }
      cout << "..." << endl;
    }
return 0;
}

Measured memory_bytes: 3632
n = int(input())
count = []
for i in range(1,10):
    if n%i == 0:
        a = n//i
        count.append(a)

ans = 0
for j in range(len(count)):
    if count[j] <= 9:
        ans += 1

if ans == 0:
    print("No")
else:  
    print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    string S;
    ll cnt = 0;
    cin >> S;
    rep(i, 3) if (S[i] == 'o') cnt ++;
    cout << 700 + cnt * 100 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3616
import fractions
A, B, K = map(int, input().split())
gcd = fractions.gcd(A, B)

cnt = 0
for i in range(gcd,0,-1):
#  print (i, gcd % i, cnt)
  if gcd % i == 0:
    cnt += 1
    if cnt == K:
      print (i)
      break

Measured memory_bytes: 5048
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>

int n, k;
long double f[3000010];

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n >> k;
    for (int i = k / 2 + k % 2; i < k; ++i)
        f[i] = 0.5;
    for (int i = k; i <= n; ++i)
        f[i] = 1;
    for (int i = k / 2 + k % 2 - 1; i; --i)
    {
        f[i] = 0.5 * f[i * 2];
    }
    long double ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += f[i];
    printf("%.12Lf\n", ans / (long double)n);
    return 0;
}

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


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

int X;
int main(){
     cin >> X;
     int n = 0;
     while((n+1)*n/2 < X){
     	n++;
     }
   cout << n << endl;
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	ll res = 0;
	for (ll k = 1; k <= n; k++)
	{
		for (ll j = k; j <= n; j += k)
		{
			res += j;
		}
	}
	cout << res << "\n";
	return 0;
}

int main0()  // original answer
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	ll res = 1;  // for k=1
	for (int k = 2; k <= n; k++)
	{
		res += 2 * (ll)k;  // for two divisors of 1 and k
	}
	for (int k = 2; k * 2 <= n; k++)
	{
		for (int j = k * 2; j <= n; j += k)
		{
			res += j;  // for the divisors other than 1 and k
		}
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll MOD = ll(1e9+7);
constexpr int INF = 1<<30;

int main(){
    int a[3], ma = 0, idx = 0;
    for(int i=0;i<3;i++){
        cin >> a[i];
        if(a[i] > ma){
            ma = a[i];
            idx = i;
        }
    }
    int k;
    cin >> k;
    a[idx] <<= k;
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}

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

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;

    rep(a, K + 1) {
        rep(b, K + 1) {
            int c = S - a - b;
            if (c >= 0 && c<=K) ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

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

    const int total_len = accumulate(a.begin(), a.end(), 0LL);
    int min_cost = total_len;
    int left_len = 0;
    for (auto &&ai : a)
    {
        left_len += ai;
        const int right_len = total_len - left_len;
        min_cost = min(abs(left_len - right_len), min_cost);
    }
    cout << min_cost << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
map<int,int>mp;
int n,m;
int main()
{
	//file();
	int x;
	read(n);
	For(i,1,n)read(x),mp[x]++;
	read(m);
	For(i,1,m)
	{
		read(x);
		if(!mp[x])
		{
			puts("NO");
			return 0;
		}
		mp[x]--;
	}
	puts("YES");
	return 0;
}


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

using namespace std;

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

int N = 1300000;
bool is_prime[1300000];

void set_prime() {
    memset(is_prime, true, N);
    is_prime[0] = is_prime[1] = false;
    REP(i, 2, sqrt(N)) {
        if(is_prime[i]) {
            for(int j=0; i*(j+2)<N; j++) {
                is_prime[i*(j+2)] = false;
            }
        }
    }
}

int main() {
    set_prime();
    int k;
    while(1) {
        cin >> k;
        if(k == 0) break;
        if(is_prime[k]) {cout << 0 << endl; continue;}
        int l, r;
        for(l=k-1; !is_prime[l]; l--);
        for(r=k+1; !is_prime[r]; r++);
        cout << r - l << endl;
    }
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	
	int n, w;
	cin >> n >> w;
	vector<vector<int>> a(4);
	int sw;
	for(int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if(i == 0) sw = x;
		a[x -sw].push_back(y);
	}
	for(int i = 0; i < 4; i++) {
		sort(a[i].rbegin(), a[i].rend());
	}
	long long ans = 0;
	for(int i = 0; i <= a[0].size(); i++) {
		for(int j = 0; j <= a[1].size(); j++) {
			for(int k = 0; k <= a[2].size(); k++) {
				for(int l = 0; l <= a[3].size(); l++) {
					long long val = 0;
					long long ww = 1LL * i * sw + 1LL * j * (sw + 1) + 1LL * k * (sw + 2) + 1LL * l * (sw + 3);
					if(ww > w) continue;
					for(int m = 0; m < i; m++) {
						val += a[0][m];
					}
					for(int m = 0; m < j; m++) {
						val += a[1][m];
					}
					for(int m = 0; m < k; m++) {
						val += a[2][m];
					}
					for(int m = 0; m < l; m++) {
						val += a[3][m];
					}
					ans = max(val, ans);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;
	
int main() {
	fastio;
	ll n;
	string a;
	cin>>n;
	set<string> s;
	while(n--){
		cin>>a;
		s.insert(a);
	}
	cout<<sz(s)<<endl;
	return 0;
	}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define N 200005
#define inf 0x3f3f3f3f
using namespace std;
int n,x,y;
int c[N],w[N],jie[N],ni[N];
int cnt[N],sm,b[N],d[N],m[N];
const int p = 1000000007;
int main()
{
	scanf("%d%d%d",&n,&x,&y);
    jie[0]=ni[0]=ni[1]=1;
    for(int i=1;i<=n;i++)jie[i]=1LL*jie[i-1]*i%p;
    for(int i=2;i<=n;i++)ni[i]=1LL*ni[p%i]*(p-p/i)%p;
    for(int i=2;i<=n;i++)ni[i]=1LL*ni[i-1]*ni[i]%p;
    int mn=inf,mnn=inf,c1=0,c2=0;
	memset(m,0x3f,sizeof(m));
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&c[i],&w[i]);
        if(w[i]<mn)
        {
            if(c1!=c[i])c2=c1,mnn=mn;
            mn=w[i];c1=c[i];
        }
        else if(w[i]<mnn&&c1!=c[i])
        {
            c2=c[i];mnn=w[i];
        }
        m[c[i]]=min(m[c[i]],w[i]);
	}
	for(int i=1;i<=n;i++)
    {
        if(c[i]==c1)
        {
            if(w[i]+mnn<=y||w[i]+mn<=x)d[i]=1;
            if(w[i]==mn)d[i]=1;
        }
        else
        {
            if(w[i]+mn<=y)b[c[i]]=1,d[i]=1;
            if(w[i]+m[c[i]]<=x)d[i]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if((c[i]==c1&&d[i])||(b[c[i]]&&d[i]))sm++,cnt[c[i]]++;
    }
    int ans=jie[sm];
    for(int i=1;i<=n;i++)ans=1LL*ans*ni[cnt[i]]%p;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

def lcm(a,b):
  return a * b / gcd(a,b)

n,m = [int(x) for x in input().split()]
s = input()
t = input()
l = lcm(n,m)
d = {}
for i in range(n):
  d[i * l / n] = s[i]
for i in range(m):
  if i in d and d[i * l / m] != t[i]:
    l = -1
    break

print(int(l))

Measured memory_bytes: 14628
#include <bits/stdc++.h>
#define lli long long int

using namespace std;
vector<pair<int,int > >adj[100010];
bool visit[100010];
int  dis[100010];
bool dfs(int v)
{
    visit[v]=1;
    bool ret=1;
    for(int i=0;i<adj[v].size();i++)
    {
        int u=adj[v][i].first;
        if(!visit[u])
        {
            dis[u]=dis[v]+adj[v][i].second;
            ret&=dfs(u);
            if(!ret)
                return 0;
        }
        else
            if(dis[u]!=dis[v]+adj[v][i].second)
            return 0;
    }
    return ret;
}

int main()
{

 int a,b;
 cin >>a>>b;
 if((a*b)%2)
    cout <<"Odd";
 else 
    cout <<"Even";
}



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

int main() {
  ios::sync_with_stdio(false);
  int N, W;
  cin >> N >> W;

  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) cin >> w.at(i) >> v.at(i);

  vector<vector<long long>> DP(N + 1, vector<long long>(W + 1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (w.at(i) <= j) DP.at(i + 1).at(j) = max(DP.at(i + 1).at(j), DP.at(i).at(j - w.at(i)) + v.at(i));
      DP.at(i + 1).at(j) = max(DP.at(i + 1).at(j), DP.at(i).at(j));
    }
  }

  cout << DP.at(N).at(W) << "\n";
}

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

int main(){
  long long k;
  cin >> k;
  long long x = 0;
  for(int i=0;i<k;i++){
    x = (x*10+7)%k;
    if(x==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

int main() {
	string s1("");
	int l, i, out, ans = 0;
	while (cin >> s1) {
		out = 0;
		l = s1.size();
		for (i = 0; i < l / 2; i++) {
			if (s1.at(i) != s1.at(l - i - 1)) {
				out = 1;
				break;
			}
		}
		if (out == 0) {
			ans = ans + 1;
		}
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, i;
	cin >> n;
	ll h[n];
	fr(i,0,n)
		cin >> h[i];
	fr(i,0,n)
	{
		if(i == 0)
			h[i]--;
		else
		{
			if(h[i] - 1 >= h[i-1])
				h[i]--;
		}
	}
	fr(i,1,n)
	{
		if(h[i] < h[i-1])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 1024
n, w = map(int, input().split())
weights, values = zip(*[tuple(map(int, input().split())) for _ in range(n)])
UV = 10**5
INF = 10**10
dp = [[INF]*(UV+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
    
for i in range(1, n+1):
    for j in range(1, UV+1):
        dp[i][j] = dp[i-1][j]
        if 0 <= j-values[i-1]:
            dp[i][j] = min(dp[i][j], dp[i-1][j-values[i-1]]+weights[i-1])

ans = 0
for i in reversed(range(UV+1)):
    if dp[-1][i] <= w:
        ans = i
        break
print(ans)

Measured memory_bytes: 120044
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = Console.ReadLine().Trim();
        var b = Console.ReadLine().Trim();
        var c = Console.ReadLine().Trim();
        Console.WriteLine(getAns(a, b, c, n));
    }
    static int getAns(string a, string b, string c, int n)
    {
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            var ai = a[i]; var bi = b[i]; var ci = c[i];
            if (ai == bi && bi == ci) continue;
            else if (ai == bi | bi == ci | ci == ai) count++;
            else count += 2;
        }
        return count;
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>

namespace HaoKaiXinA_WoXiangDaoZenMeZuoLe___OiO
{
	const int N=410,M=201000;
	int begin[N],next[M],to[M],w[M];
	int n,m,e;
	void add(int x,int y,int z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}
	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1,u,v;i<=m;i++)
			scanf("%d%d",&u,&v),add(u,v,i);
	}

	bool available[N];
	int f[N][N];

	bool dfs(int p,int *g)
	{
		for(int i=begin[p],q,k;i;i=next[i])
		{
			q=to[i],k=w[i];
			if(k>=g[p])continue;

			if(g[q]>=0)
			{
				if(g[q]!=k)return 0;
				continue;
			}

			g[q]=k;
			if(!dfs(q,g))return 0;
		}
		return 1;
	}

	void calc(int p)
	{
		memset(f[p],-1,sizeof(f[p]));
		f[p][p]=m+1;
		if(!dfs(p,f[p]))available[p]=0;
		else available[p]=1;
	}

	bool judge(int p,int q)
	{
		if(!available[p] || !available[q])return 0;
		for(int i=1;i<=n;i++)
			if(f[p][i]>=0 && f[q][i]>=0 && f[p][i]!=f[q][i])
				return 0;
		return 1;
	}
	
	void solve()
	{
		initialize();
		for(int i=1;i<=n;i++)
			calc(i);
		int ans=0;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				ans+=judge(i,j);
		printf("%d\n",ans);
	}
}

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


Measured memory_bytes: 3200
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		int u[]=new int[1000005];
		int f[]=new int[1000005];
		for(int p:a) {
			if(u[p]==0) {
				u[p]=1;
				for(int j=p*2;j<1000005;j+=p) {
					f[j]=-1;
				}
			}else {
				f[p]=-1;
			}
		}
		int ans=0;
		for(int p:a) {
			if(f[p]!=-1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
	
	

}

Measured memory_bytes: 53844
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, T;
  cin >> N >> T;
  ll c, t, min_c = INF;
  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if (t <= T && c < min_c) {
      min_c = c;
    }
  }
  if (min_c == INF) {
    cout << "TLE" << endl;
  } else {
    cout << min_c << endl;
  }
  return 0;
}

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

int main(int argc, const char * argv[]) {
    int c[3][3];
    int x;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> x;
            c[i][j] = x;
        }
    }
    
    bool flag;
    int a[3], b[3];
    for (int i = 0; i <= 100; i++) {
        flag = true;
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        
        
        
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (c[j][k] != a[j] + b[k]) {
                    flag = false;
                    break;
                }
            }
        }
        if (flag) {
            break;
        }
    }
    
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 20:52:24 +0900
# LastModified: 2020-09-26 21:19:33 +0900
#


import os
import sys
sys.setrecursionlimit(2000000)
# import numpy as np
# import pandas as pd


def BFS(cnt, color, path, u):
    color[u] = cnt
    for v in path[u]:
        if color[v] == -1:
            BFS(cnt, color, path, v)


def main():
    N, M = map(int, input().split())
    path = [[] for _ in range(N+1)]
    for _ in range(M):
        A, B = map(int, input().split())
        path[A].append(B)
        path[B].append(A)
    color = [-1] * (N+1)
    cnt = 0
    for i in range(1, N+1):
        if color[i] == -1:
            BFS(cnt, color, path, i)
            cnt += 1
    print(max(color))


if __name__ == "__main__":
    main()


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


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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s){
        cout << a-1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b-1 << endl;
    }
    
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

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

  unsigned k;
  cin >> k;

  ll sum = 0;
  rep(a, k) rep(b, k) rep(c, k) {
    sum += gcd(a + 1, gcd(b + 1, c + 1)); 
  }
  cout << sum << endl;
}

Measured memory_bytes: 3652
N = int(input())
edge = []
# bとして振られる番号
d_col = [0] * N
# b先に振り分ける番号
e_col = [1] * N
for i in range(N-1):
    a, b = map(int, input().split())
    edge.append([a, b, i, 0])
edge = sorted(edge)
for j, e in enumerate(edge):
    a, b, i, ans = e
    if d_col[a-1] == e_col[a-1]:
        edge[j][3] = e_col[a-1] + 1
        e_col[a-1] += 1
    else:
        edge[j][3] = e_col[a-1]
    d_col[b-1] = e_col[a-1]
    e_col[a-1] += 1
edge = sorted(edge, key=lambda x: x[2])
col = []
for e in edge:
    col.append(e[3])
print(max(col))
for i in col:
    print(i)


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

int T[100010];
int X[100010];
int Y[100010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> T[i] >> X[i] >> Y[i];
	}

	for(int i = 0; i < N; i++){
		int dt = abs(T[i] - T[i + 1]);
		int dx = abs(X[i] - X[i + 1]);
		int dy = abs(Y[i] - Y[i + 1]);
		if(dx + dy > dt || (dx + dy) % 2 != dt % 2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  if(a >= b)
  {
    cout << "delicious" << endl;
  }
  else if(a < b && b - a <= x)
  {
    cout << "safe" << endl;
  }
  else
  {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string A, B;
    cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    for (int i = 0; i < A.size(); i++) {
        if (A.at(i) > B.at(i)) {
            cout << "GREATER" << endl;
            return 0;
        }
        if (A.at(i) < B.at(i)) {
            cout << "LESS" << endl;
            return 0;
        }
        if (i == A.size() - 1) {
            cout << "EQUAL" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]=='S'){
        cout << "Cloudy"<<endl;
    }
    else if(s[0]=='C'){
        cout << "Rainy"<<endl;
    }
    else{
        cout << "Sunny"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int h[100001],dp[100001];
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		int mn=0x3f3f3f3f;
		for(int j=1;j<=min(k,i-1);j++)
			mn=min(mn,int(dp[i-j]+abs(h[i-j]-h[i])));
		dp[i]=mn;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4356
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void solv() {

	ll n;
	cin >> n;
	string s;
	cin >> s;
	int st = 0;
	int end = n - 1;
	while (s[st] == '.') st++;
	while (s[end] == '#') end--;

	int wc = 0;
	int ra = end - st + 1;
	for (int i = st; i <= end; i++)
		if (s[i] == '.') wc++;

	int best = wc;
	int bc = 0;

	for (int i = st; i <= end; i++)
	{
		if (s[i] == '#') bc++;
		if (s[i] == '.') wc--;
		best = min(best, bc + wc);
	}
	cout << best << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.ReadLineInt32();
            var s = consoleReader.ReadLine();

            return s.Count(c => c == 'R') > N / 2 ? "Yes" : "No";
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<long> RepeatReadLinesInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt64();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static V GetOrDefault<K, V>(this Dictionary<K, V> dic, K key, V defaultValue = default(V))
        {
            V val;
            return dic.TryGetValue(key, out val) ? val : defaultValue;
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int m = int.Parse(s[1]);
        long l = 1;
        long r = n;
        for (int i = 0;i < m; i++)
        {
            s = Console.ReadLine().Split();
            int li = int.Parse(s[0]);
            int ri = int.Parse(s[1]);
            if (l <= li) l = li;
            if (r >= ri) r = ri;
            if (l > r)
            {
                Console.WriteLine(0);
                return;
            }
        }
        Console.WriteLine(r - l + 1);
    }
}

Measured memory_bytes: 17348
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K, N = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_diff = []
    for i in range(len(A_arr[1:])):
        A_arr_diff.append(A_arr[i+1]-A_arr[i])
    A_arr_diff.append(K-A_arr[-1]+A_arr[0])
    cnt = K - max(A_arr_diff)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 84956
import numpy as np
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    s1=[]
    for j in range(W):
        if s[j]=='.':
            s1+=[1]
        else:
            s1+=[0]
    S+=[s1]
S=np.array(S)

Tl=np.zeros((H,W),dtype=np.int)
Tr=np.zeros((H,W),dtype=np.int)

Tu=np.zeros((H,W),dtype=np.int)
Td=np.zeros((H,W),dtype=np.int)
for i in range(1,W):
    Tl[:,i]+=(Tl[:,i-1]+1)*S[:,i-1]

for i in range(W-2,-1,-1):
    Tr[:,i]+=(Tr[:,i+1]+1)*S[:,i+1]

for i in range(1,H):
    Tu[i,:]+=(Tu[i-1,:]+1)*S[i-1,:]

for i in range(H-2,-1,-1):
    Td[i,:]+=(Td[i+1,:]+1)*S[i+1,:]

print(((Tl+Tr+Tu+Td)*S).max()+1)

Measured memory_bytes: 263480
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <list>

using namespace std;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  list<int>::iterator it;
  int i;

  for ( ; ; )
  {
    list<int> h, v;
    int n;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;
    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( "%d", &d );
      h.push_back ( d );
    }
    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( "%d", &d );
      v.push_back ( d );
    }

    for ( ; ; )
    {
      it = find ( h.begin ( ), h.end ( ), 0 );
      if ( it != h.end ( ) )
      {
        h.erase ( it );
        continue ;
      }
      it = find ( v.begin ( ), v.end ( ), 0 );
      if ( it != v.end ( ) )
      {
        v.erase ( it );
        continue ;
      }

      it = find ( h.begin ( ), h.end ( ), v.size ( ) );
      if ( it != h.end ( ) )
      {
        h.erase ( it );
        for ( it = v.begin ( ); it != v.end ( ); ++it )
        {
          *it -= 1;
        }
        continue ;
      }
      it = find ( v.begin ( ), v.end ( ), h.size ( ) );
      if ( it != v.end ( ) )
      {
        v.erase ( it );
        for ( it = h.begin ( ); it != h.end ( ); ++it )
        {
          *it -= 1;
        }
        continue ;
      }

      break ;
    }
    
    puts ( ( h.size ( ) == 0 && v.size ( ) == 0 )
         ? "Yes" : "No" );
  }

  return ( EXIT_SUCCESS );
}

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

using namespace std;
using ll = long long;

constexpr int MAXN = 17;

int n;
ll A[MAXN][MAXN];

ll profits[1 << MAXN];
ll dp[1 << MAXN];

ll profit(int mask) {
  ll res = 0;
  for (int i = 0; i < n; i++) {
    if (!(mask & (1 << i))) { continue; }
    for (int j = i + 1; j < n; j++) {
      if (!(mask & (1 << j))) { continue; }
      res += A[i][j];
    }
  }
  return res;
}

ll solve(int mask) {
  if (mask == 0) { return 0LL; }
  ll& res = dp[mask];
  if (res != -1LL) { return res; }
  res = numeric_limits<ll>::min();
  for (int submask = mask; submask > 0; submask = (submask - 1) & mask) {
     res = max(res, profits[submask] + solve(mask ^ submask));
  }
  return res;
}

int main() {
  fill(dp, dp + (1 << MAXN), -1LL);
  cin >> n;
  for(int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < (1 << n); i++) {
    profits[i] = profit(i);
  }
  cout << solve((1 << MAXN) - 1) << '\n';
  return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    int dig = 0;
    while (n /= k)
        dig++;

    cout << dig + 1;

    return 0;
}


Measured memory_bytes: 256