akhauriyash/Code-Regression huggingface dataset:
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = 1e18;
	ans = -1 * ans;
	ans = max(ans, a*c);
	ans = max(ans, a*d);
	ans = max(ans, b*c);
	ans = max(ans, b*d);
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
double PI = 3.14159;
int main(){

	cin >> n;
	printf("%0.9f\n",2*PI*n );

	
	return 0;
}

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

using namespace std;

typedef long long ll;

ll mdif(ll a, ll b, ll c, ll d) {
    ll ma = max(max(a, b), max(c, d));
    ll mi = min(min(a, b), min(c, d));
    return ma - mi;
}

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

    int j = 0, k = 1;
    ll s1 = a[0], s2 = 0, s3 = a[1], s4 = 0;
    for (int i = 2; i < n; i++) {
        s4 += a[i];
    }
    long long ans = mdif(s1, s2, s3, s4);
    for (int i = 1; i < n - 2; i++) {
        s2 += a[i];
        s3 -= a[i];
        while (j < i - 1 && s1 < s2) {
            j++;
            s1 += a[j];
            s2 -= a[j];
        }
        while (k < n - 1 && s3 < s4) {
            k++;
            s3 += a[k];
            s4 -= a[k];
        }

        ans = min(ans, mdif(s1, s2, s3, s4));
        if (j > 0) {
            ans = min(ans, mdif(s1 - a[j], s2 + a[j], s3, s4));
        }
        if (k > i + 1) {
            ans = min(ans, mdif(s1, s2, s3 - a[k], s4 + a[k]));
        }
        if (j > 0 && k > i + 1) {
            ans = min(ans, mdif(s1 - a[j], s2 + a[j], s3 - a[k], s4 + a[k]));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#define DIV 1000000007

int main(){
  char S[100002],tmp[100002];
  int N;
  int cnt[2][13];
  int mod;
  
  scanf( "%s", tmp);
  N = strlen(tmp);
  for(int i=0;i<N;i++)
    S[i] = tmp[N-1-i];
  
  for(int i=0;i<13;i++)
    cnt[1][i] = 0;
  mod = 1;
  cnt[1][0] = 1;
  
  for( int i=0; i<N; i++){
    if ( S[i] == '?' ){
      for( int j=0; j<13; j++)
	cnt[i%2][j] = 0;
      for( int n=0; n<10; n++)
	for( int j=0; j<13; j++)
	  cnt[i%2][(j+n*mod)%13] = (cnt[i%2][(j+n*mod)%13]+cnt[(i+1)%2][j]) % DIV;
    }else
      for( int j=0; j<13; j++)
	cnt[i%2][(j+(S[i]-'0')*mod)%13] = cnt[(i+1)%2][j];

    mod = (mod*10)%13;
  }  
    
  printf("%d\n",cnt[(N-1)%2][5]);
  
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  // cout << A << "," << B << "," << C << endl;

  int ans = 0;
  if(A % 2 == B % 2 && A % 2 != C % 2) {
    // cout << A << "," << B << "->" << A + 1 << "," << B + 1 << endl;
    A++;
    B++;
    ans++;
  } else if(B % 2 == C % 2 && B % 2 != A % 2) {
    // cout << B << "," << C << "->" << B + 1 << "," << C + 1 << endl;
    B++;
    C++;
    ans++;
  } else if(C % 2 == A % 2 && C % 2 != B % 2) {
    // cout << C << "," << A << "->" << C + 1 << "," << A + 1 << endl;
    C++;
    A++;
    ans++;
  }
  vector<int> vs(3);
  vs[0] = A;
  vs[1] = B;
  vs[2] = C;
  sort(vs.begin(), vs.end());
  // cout << vs[0] << "," << vs[1] << "," << vs[2] << endl;

  ans += (vs[2] - vs[0]) / 2;
  ans += (vs[2] - vs[1]) / 2;
  cout << ans << endl;
  return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    int ret = 0;
    for (int i=0; i<n; i++) {
        bool ok = true;
        for (int j=1; j*j<=a[i]; j++)
            if (a[i] % j == 0)
                for (int x : {j, a[i] / j})
                    if ((x == a[i] && mp[x] > 1) || (x != a[i] && mp[x] > 0)) {
                        ok = false;
                        break;
                    }
        if (ok)
            ret++;
    }

    cout << ret << "\n";

    return 0;
}


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

int main()
{
	int y, s, i;
	int c[] = {10, 50, 100, 500};
	int m[4];
	bool f = false;
	
	while (cin >> y, s = -y) {
		if (f) cout << endl;
		else f = true;
		
		for (i = 0; i < 4; i++) {
			cin >> m[i];
			s += c[i] * m[i];
		}
		for (i = 3; i >= 0; i--) {
			while (s >= c[i]) {
				s -= c[i];
				m[i]--;
			}
		}
		for (i = 0; i < 4; i++) {
			if (m[i] > 0) {
				cout << c[i] << " " << m[i] << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int n;
    ll ans = 1;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;++i)    cin >> d[i];

    if(d[0] != 0){
        cout << "0" << endl;
    }else{
        //sort(d.begin(), d.end());
        vector<int> value(n, 0);
        for(int i = 0;i < n;++i){
            value[d[i]]++;
        }

        if(value[0] > 1){
            cout << "0" << endl;
        }else{
            int flag = 0;
            for(int i = n-1;i > 0;--i){
                if(value[i] != 0){
                    flag = 1;
                }
                if(flag){
                    for(int j = 0;j < value[i];++j){
                        ans *= (ll)((ll)value[i-1] % 998244353);
                        ans = ans % 998244353;
                    }
                    ans = ans % 998244353;
                    //cout << ans << "*=" << value[i] << " * " << value[i-1] << endl; 
                }
            }
            cout << ans << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
typedef long long ll;

typedef enum {
	A = 1,
	C = 2, 
	G = 3,
	T = 4
} ACGT;

const ll mod = (long long)(1e9) + 7ll;

ll n;
//ll dp[now][s1][s2][s3][s4];
ll dp[105][5][5][5][5];

ll dfs(int now, int s1, int s2, int s3, int s4)
{
	if (dp[now][s1][s2][s3][s4] != -1) {
		return dp[now][s1][s2][s3][s4];
	}

	if ((s2 == A && s3 == G && s4 == C) ||
		(s2 == A && s3 == C && s4 == G) ||
		(s2 == G && s3 == A && s4 == C) ||
		(s1 == A && s2 == G && s4 == C) ||
		(s1 == A && s3 == G && s4 == C)) {
		return 0;
	}

	if (now == n) {
		return 1;
	}

	dp[now][s1][s2][s3][s4] = 0;
	for (ACGT i = A; i <= T; i++) {
		dp[now][s1][s2][s3][s4] += dfs(now + 1, s2, s3, s4, i);
		dp[now][s1][s2][s3][s4] %= mod;
	}

	return dp[now][s1][s2][s3][s4];
}


int main()
{
	scanf("%lld", &n);

	memset(dp, -1, sizeof(dp));

	printf("%lld\n", dfs(0, 0, 0, 0, 0));

	return 0;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a+b;
  ll ans = a * (n/c);
  ans += min(n%c, a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static long inv(long a, long mod) {
		if(extGCD(a, mod, 0) != 1) return -1; // there is no inverse
		x = 0; y = 0;
		extGCD(a, mod, 0);
		return (x + mod) % mod;
	}
	static long x = 0, y = 0;
	static long extGCD(long a, long b, int c) {
		long d = a;
		if(b != 0) {
			d = extGCD(b, a % b, (c + 1) % 2);
			if(c == 0) y -= (a / b) * x;
			else x -= (a / b) * y;
		}else {
			x = (c == 0) ? 1 : 0;
			y = (c == 0) ? 0 : 1;
		}
		return d;
	}
	static long mod = 1000000000 + 7;
	static long Choose(long n, long k) {
		if(n < k) return 0;
		else if (n == k) return 1;
		long res = fact[(int)n];
		res *= inv_fact[(int)k]; res %= mod;
		res *= inv_fact[(int)(n - k)]; res %= mod;
		return res;
	}
	static long[] fact, inv_fact;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		fact = new long[3000];
		inv_fact = new long[3000];
		fact[0] = 1; inv_fact[0] = 1;
		fact[1] = 1; inv_fact[1] = 1;
		for(int i = 2; i < 3000; i++) {
			fact[i] = fact[i - 1] * (long)i; fact[i] %= mod;
			inv_fact[i] = inv(fact[i], mod);
		}
		int N = sc.nextInt(), K = sc.nextInt();
		long[][] comb = new long[3000][3000];
		for(long i = 0; i <= 2000; i++) {
			for(int j = 0; j <= 2000; j++) comb[(int)i][(int)j] = Choose(i, j);
		}
		for(int i = 1; i <= K; i++) {
			long ans = (comb[N - K + 1][i] * comb[K - 1][i - 1]);
			ans %= mod;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 129620
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int i=0; i < N; i++){
        cin >> vec.at(i);
    }

    int64_t count = 0;
    for (int i=0; i < N; i++) {
        int index = i + 1;
        if (vec[i] == index) {
            if (index == N) {
                int64_t tmp = vec[i];
                vec[i] = vec[i - 1];
                vec[i - 1] = tmp;
            }
            else
            {
                int64_t tmp = vec[i];
                vec[i] = vec[i + 1];
                vec[i + 1] = tmp;
            }
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = [0 for _ in range(N)]

now = 0
l[now] = 1
count = 0
loop = [0]

while count < K:
    count += 1
    now = A[now]-1
    loop.append(now)
    if l[now] == 1:
        loop = loop[loop.index(now):-1]
        break
    else:
        l[now] = 1

if count == K:
    print(now + 1)
else:
    ans = loop[(K-count) % len(loop)]
    print(ans + 1)


Measured memory_bytes: 32368
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt,type=-1;
char a[55][55],b[55][55];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",a[i-1]);
	}
	for(int i=1;i<=m;i++){
		scanf("%s",b[i-1]);
	}
	for(int i=1;i<=n-m+1;i++){
		for(int j=1;j<=n-m+1;j++){
			cnt=0;
			for(int k=i;k<=i+m-1;k++){
				for(int l=j;l<=j+m-1;l++){
					if(a[k-1][l-1]==b[k-i][l-j]){
						++cnt;
					}
				}
			}
			if(cnt==m*m){
				type=0;
				break;
			}
		}
	}
	if(type==0){
		printf("Yes");
	}else printf("No");
}

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 n; cin >> n;
  vector<char>s(n);
  vector<char>t(n);
  rep(i,n) cin >> s[i];
  rep(i,n) cin >> t[i];
  rep(i,n) cout << s[i] << t[i];
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35604
#!/usr/bin/python3

(k, n) = map(int, input().split())
a = list(map(int, input().split()))

maxd = 0

for i in range(len(a)):
    if i == 0:
        maxd = a[0] + (k - a[len(a) - 1])
    else:
        maxd = max(a[i] - a[i - 1], maxd)


print(k - maxd)

Measured memory_bytes: 26420
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){

	int h;
	int w;
	int d[100][100]={};
	int flg=-1;


	cin>>h>>w;
	string str1;
	for(int j=0; j<h; j++){
		cin>>str1;
		flg=-1;
		for(int i=0; i<w; i++){
			if(str1[i]=='c'){
				d[i][j]=0;
					flg=1;
			}else if(str1[i]=='.'&&flg>0){
				d[i][j]=flg;
				flg++;
			}else if(str1[i]=='.'&&flg==-1){
				d[i][j]=-1;
			}
		}

	}
		for(int j=0; j<h; j++){
			for(int i=0; i<w-1; i++){
			cout<<d[i][j]<<" ";
			}
		cout<<d[w-1][j]<<endl;



	}


}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[1005][200005];
ll I[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    memset(I, 0, sizeof(I));
    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll t, x;
            cin >> t >> x;
            S[t][I[t]++] = x;
        }
        else if (q == 1) {
            ll t;
            cin >> t;
            if (I[t] == 0)
                continue;
            cout << S[t][I[t] - 1] << endl;
        }
        else {
            ll t;
            cin >> t;
            if (I[t] == 0)
                continue;
            I[t]--;
        }
    }
    return 0;
}


Measured memory_bytes: 7868
# -*- coding: utf-8 -*-

x,y = map(int, raw_input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if(x in a and y in a):
    print('Yes')
elif(x in b and y in b):
    print('Yes')
elif(x in c and y in c):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 705;
bool g[N][N], dp[N][N];
int col[N], ct[2];
int n, m;

bool dfs(int node, int c) {
    col[node] = c;
    ct[c - 1]++;

    for (int i = 0; i < n; i++) {
        if (g[node][i]) {
            if (!col[i]) {
                if (dfs(i, 3 - c))
                    return true;
            }
            else if (col[i] == col[node]) {
                return true;
            }
        }
    }

    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x][y] = g[y][x] = true;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j)
                g[i][j] = !g[i][j];
        }
    }

    dp[0][0] = true;

    for (int i = 0; i < n; i++) {
        ct[0] = ct[1] = 0;

        if (!col[i]) {
            if (dfs(i, 1)) {
                cout << -1;
                return 0;
            }
        }

        for (int j = 0; j <= n; j++) {
            if (dp[i][j]) {
                for (int k = 0; k < 2; k++) {
                    dp[i + 1][j + ct[k]] = true;
                }
            }
        }
    }

    int ans = m;

    for (int i = 1; i <= n; i++) {
        if (dp[n][i]) {
            ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }

    cout << ans;

    return 0;   
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int D, N;
  cin >> D >> N;
  if (N != 100) {
   cout << r(100, D) * N <<endl;
  }
  else {
    cout << r(100, D) * 101 <<endl;
  }
} 

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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	vector<int> a(n);
	
	rep(i, n) cin >> p.at(i);
	rep(i, n) cin >> q.at(i);
	rep(i, n) a.at(i) = i+1;

	map<vector<int>, int> mp;
	do{
		mp[a] = mp.size();
	}while(next_permutation(a.begin(), a.end()));

	int ans = abs(mp[q] - mp[p]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#define MAX 100
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra()
{
  int minv;
  int d[MAX],color[MAX];
  int i,v;

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      color[i]=WHITE;
    }
  d[0]=0;
  color[0]=GRAY;

  while(1)
    {
      minv=INFTY;
      int u=-1;
      for(i=0;i<n;i++)
	{
	  if(minv>d[i] && color[i] != BLACK)
	    {
	      u=i;
	      minv=d[i];
	    }
	}

      if(u==-1) break;
      color[u]=BLACK;
      for(v=0;v<n;v++)
	{
	  if(color[v]!=BLACK && M[u][v]!=INFTY)
	    {
	      if(d[v]>d[u]+M[u][v])
		{
		  d[v]=d[u]+M[u][v];
		  color[v]=GRAY;
		}
	    }
	}
    }

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


int main()
{
  int i,j,k,c,u,v;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=INFTY;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d%d",&v,&c);
	  M[u][v]=c;
	}
    }

  dijkstra();

  return 0;
}



Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int m, n, flag = 0;
	scanf("%d %d", &m, &n);
	for (int i = 0; i <= m ; i++)
	{
		int a, b, c;
		a = (m - i) * 2;
		b = i * 4;
		c = a + b;
		if (c == n)
		{
			flag = 1;
			printf("Yes");
			break;

		}
	}
	if (!flag)
	{
		printf("No");
	}
}

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

int main() {
	// your code goes here
	
	int i,n;
	cin>>n;
	int h[n],dp[n];
	for(i=0;i<n;i++)
	{
	    cin>>h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	
	for(i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()

    kuro_num = 0
    siro_num = 0
    for moji in S:
        if moji == "#":
            kuro_num += 1
        else:
            siro_num += 1

    if siro_num == N:
        print(0)
        exit()

    # ..........############ のパターン
    right_kuro_num = kuro_num
    right_siro_num = siro_num
    ans = siro_num
    for moji in S:
        if moji == "#":
            right_kuro_num -= 1
        else:
            right_siro_num -= 1
        num = right_siro_num + (kuro_num - right_kuro_num)
        ans = min(ans, num)

    print(ans)

"""
26
...##..##...##.....#..#..#
"""
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3500
k, n = map(int, input().split())
a = list(map(int, input().split()))
d_max = 0

for i in range(n - 1):
    d = a[i + 1] - a[i]
    d_max = max(d_max, d)

d = (k - a[-1]) + a[0]
d_max = max(d_max, d)

print(k - d_max)


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

Measured memory_bytes: 580
import collections

N, K = map(int, input().split())
A = list(map(int, input().split()))

AC = collections.Counter(A)

if K >= len(AC):
    print(0)
    exit(0)

delete_item_num = len(AC)-K
ans = 0
cnt = 0
for k, v in sorted(AC.items(), key=lambda x: x[1]):
    cnt += 1
    ans += v
    if cnt >= delete_item_num:
        print(ans)
        exit(0)


Measured memory_bytes: 39344
from itertools import permutations


class Solution:
    def CountOrder(self, sequence1, sequence2):
        l = list(permutations(range(1, n + 1)))
        index1 = l.index(sequence1)
        index2 = l.index(sequence2)
        return abs(index1 - index2)


if __name__ == "__main__":
    n = int(input())
    sequence1 = tuple(map(int, input().split()))
    sequence2 = tuple(map(int, input().split()))
    solution = Solution()
    print(solution.CountOrder(sequence1, sequence2))



Measured memory_bytes: 8052
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
fun main() {
    val builder = StringBuilder()

    val (_, k) = readInputLine().split(" ").map { it.toInt() }
    val pArr = readInputLine().split(" ").map { it.toInt() }.sorted().toIntArray()

    var ans = 0

    for (i in 0 until k) {
        ans += pArr[i]
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 40536
package main

import "fmt"

func main() {
	var h, w, n, sr, sc int
	fmt.Scan(&h, &w, &n, &sr, &sc)
	var s, t string
	fmt.Scan(&s, &t)

	up := sr
	for i := 0; i < n; i++ {
		if s[i] == 'U' {
			up--
		}
		if up == 0 {
			fmt.Println("NO")
			return
		}
		if t[i] == 'D' {
			if up != h {
				up++
			}
		}
	}
	up = sr
	for i := 0; i < n; i++ {
		if s[i] == 'D' {
			up++
		}
		if up == h+1 {
			fmt.Println("NO")
			return
		}
		if t[i] == 'U' {
			if up != 1 {
				up--
			}
		}
	}
	le := sc
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			le--
		}
		if le == 0 {
			fmt.Println("NO")
			return
		}
		if t[i] == 'R' {
			if le != w {
				le++
			}
		}
	}
	le = sc
	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			le++
		}
		if le == w+1 {
			fmt.Println("NO")
			return
		}
		if t[i] == 'L' {
			if le != 1 {
				le--
			}
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (c*2 >= a+b) {
        cout << x*a + y*b << endl;
    } else {
        int m = min(x, y);
        int cost = c*2*m;
        x -= m; y -= m;
        if (x > 0)
            cost += x * min(a, c*2);
        if (y > 0)
            cost += y * min(b, c*2);
        cout << cost << endl;
    }
    return 0;
}



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

int count(int n, int x){
    int time = 0;
    for(int i = 1; i <= n - 2; i++){
        for(int j = i + 1; j <= n - 1; j++){
            for(int k = j + 1; k <= n; k++){
                if(i + j + k == x) time++;
            }
        }
    }
    return time;
}
int main(){
    int n,x;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        cout << count(n,x) << endl;
    }
   return 0;
}


Measured memory_bytes: 3092
N=int(input())  
x = []
u = []
price=[]
for i in range(N):
    x1,y1=[i for i in input().split()]
    x.append(float(x1))
    u.append(y1)

for j in range(N):
    if u[j]=='BTC':
        price.append(x[j]*380000.0)
    else:
        price.append(x[j])

print(sum(price))


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

char str[1001];
bool field[1001][1001];
pair<int,int> point[10];
int bfs[1001][1001];

int main(){
	int a, b, N;
	int ret = 0;
	scanf("%d%d%d", &a, &b, &N);
	for(int i=0;i<a;i++){
		scanf("%s", str);
		for(int j=0;j<b;j++){
			if(str[j]=='X')
				field[i][j] = false;
			else
				field[i][j] = true;
			switch(str[j]){
				case 'S':
					point[0] = make_pair(i,j);
					break;
				case '1':
					point[1] = make_pair(i,j);
					break;
				case '2':
					point[2] = make_pair(i,j);
					break;
				case '3':
					point[3] = make_pair(i,j);
					break;
				case '4':
					point[4] = make_pair(i,j);
					break;
				case '5':
					point[5] = make_pair(i,j);
					break;
				case '6':
					point[6] = make_pair(i,j);
					break;
				case '7':
					point[7] = make_pair(i,j);
					break;
				case '8':
					point[8] = make_pair(i,j);
					break;
				case '9':
					point[9] = make_pair(i,j);
					break;				
			}
		}
	}
	
	queue<pair<int,int> > Q;
	for(int i=0;i<N;i++){
		for(int m=0;m<a;m++){
			for(int n=0;n<b;n++){
				bfs[m][n] = -1;
			}
		}
		int first = point[i].first;
		int second = point[i].second;
		bfs[first][second] = 0;
		Q.push(point[i]);
		while(Q.size()){
			int row = Q.front().first;
			int col = Q.front().second;
			if(row>0&&field[row-1][col]&&bfs[row-1][col]==-1){
				bfs[row-1][col] = bfs[row][col] + 1;
				Q.push(make_pair(row-1,col));
			}
			if(row<a-1&&field[row+1][col]&&bfs[row+1][col]==-1){
				bfs[row+1][col] = bfs[row][col] + 1;
				Q.push(make_pair(row+1,col));
			}
			if(col>0&&field[row][col-1]&&bfs[row][col-1]==-1){
				bfs[row][col-1] = bfs[row][col] + 1;
				Q.push(make_pair(row,col-1));
			}
			if(col<b-1&&field[row][col+1]&&bfs[row][col+1]==-1){
				bfs[row][col+1] = bfs[row][col] + 1;
				Q.push(make_pair(row,col+1));
			}
			Q.pop();
		}
		ret += bfs[point[i+1].first][point[i+1].second];
	}
	cout << ret << endl;
}


Measured memory_bytes: 8100
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];

int main() {
	double n, k;
	cin >> n >> k;
	double ans = 0;
	for (double i = 1;i <= n;++i) {
		double target = i;
		double pro = 1 / n;
		while (target < k) {
			target *= 2;
			pro /= 2;
		}
		ans += pro;
	}
	printf("%.12f\n", ans);
}


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
		string s;
		cin >> s;
		int n = s.length();
		while(n--)
		cout << 'x';
		cout << endl;
		return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int n,t[4],ans,able[3010][4];
bool dfs(int total,int id)
{
	if(able[total][id]==1)
	{
		ans++;
		return true;
	}
	if(total==n)
	{
		ans++;
		return true;
	}
	if(id>3||total+t[id]>n)
		return false;
	int flag=0;
	for(int i=0;(i+1);i++)
	{
		if(t[id]*i+total<=n)
		{
			if(dfs(t[id]*i+total,id+1))
			{
				flag=1;
				able[total][id]=1;
			}
		}else
			break;
	}
	if(flag)
		return true;
	else
		return false;
}
int main()
{
	cin>>t[1]>>t[2]>>t[3]>>n;
	sort(t+1,t+4);
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
///Nahid Hasan Raju
#include <bits/stdc++.h>
#define ll long long
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
using namespace std;

#define P1(XX) cerr<<"db1: "<<XX<<endl
#define P2(XX,YY) cerr<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cerr<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007ll
#define MX 2000006  ///200005


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll m, n;
ll a[MX], b[MX];
string s,s1;
map<ll,int>mp;

void precalc(ll p)
{

}

///cerr<<   how to use it?
int main()
{
    #ifndef ONLINE_JUDGE
    Fin;
    #endif
    int test=1, tc=0, i, j;
    ll k, ans;
    ll c,p;
    //scanf("%d", &test);
    //precalc(1);
    while(test--)
    {
        ans=0;
        ll pp;
        cin>>n>>pp;
        k=pp*pp;
        for(i=0 ; i<n ; i++){
            cin>>c>>p;
            if(((c*c)+(p*p))<=k)ans++;
        }
        printf("%lld\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

void a(int A[], int N) {
	for (int k = 0; k < N; k++) {
		cout << A[k];
		if (k != N - 1)cout << " ";
	}
	cout << endl;
}

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

int main() {
	int N;	cin >> N;
	int A[1000];
	for (int i = 0; i < N; i++)
		cin >> A[i];
	insertionSort(A, N);
	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
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; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, X;
int M[102];

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

  cin >> N >> X;
  int sm = 0;
  int a = 0;
  int min_d = 1000;
  rep(i, N){
    cin >> a;
    sm += a;
    M[i] = a;
    min_d = min(min_d, a);
  }

  X-= sm;
  int ans = N;
  ans += X/min_d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(s):
    # implement process
    len_s = len(s)
    a,b = -1,-1
    for i in range(len_s):
        if len_s - i > 1 and s[i]==s[i+1]:
            a,b = i+1,i+2
            break
        if len_s - i > 2 and s[i]==s[i+2]:
            a,b = i+1,i+3
            break
    return f"{a} {b}"

def main():
    # input
    s = input()
    # process
    ans = str( solve(s) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
aba
"""
_EXPECTED = """\
2 5
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 9148
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  Vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  Vout(a);
  return 0;
}



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

bool solve(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(b > d or b > a) return false;
    if(c >= b) return true;
    int x = __gcd(b,d);
    return b - x + a%x <= c;
}

signed main(){
    int t; cin >> t;
    REP(i,t) cout << ( solve() ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 500000

int H, T[MAX + 1];

void maxHeapify(int A[], int i) {
	int l = 2 * i, r = 2 * i + 1;
	int maxi = 0;
	if (l <= H && A[l] > A[i]) maxi = l;
	else maxi = i;
	if (r <= H && A[r] > A[maxi]) maxi = r;
	if (maxi != i) {
		swap(A[i], A[maxi]);
		maxHeapify(A, maxi);
	}
}

void buildMaxHeap(int A[]) {
	for (int i = H / 2; i > 0; --i) maxHeapify(A, i);
}

int main() {
	cin >> H;
	for (int i = 1; i <= H; ++i) {
		int key; cin >> key;
		T[i] = key;
	}
	buildMaxHeap(T);
	for (int i = 1; i <= H; ++i) {
		cout << " " << T[i];
	}
	cout << endl;

	return 0;
}


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

int main() {
  string S, a, b, c, temp;
  cin >> S;
  int i = 0;
  i = S.size()-3 + 1;
  int diff = 0;
  int ans = 0;

  for(int count = 0; count < i; count++){
    a = S[count+0];
    b = S[count+1];
    c = S[count+2];
    temp = a + b + c;
    diff = abs(753 - atoi(temp.c_str()));
    if(count == 0){
        ans = diff;
    }
    if(diff < ans){
        ans = diff;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string s;cin>>s;
  for(int i = 0; i < s.size() -1; i++){
    if(s[i] == s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
      }
    }
  cout<<"Good"<<endl;
  
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    int t[N+1],x[N+1],y[N+1];
    t[0] = 0,x[0] = 0,y[0] = 0;
    
    for(int i=1;i<=N;i++){
        cin >> t[i] >> x[i] >> y[i];
        if(t[i]-t[i-1] < abs((x[i]+y[i])-(x[i-1]+y[i-1]))){
            cout << "No" << endl;
            return 0;
        }else if((t[i]-t[i-1])%2 != abs((x[i]+y[i])-(x[i-1]+y[i-1]))%2){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    
    return 0;
}


Measured memory_bytes: 2560
import Control.Applicative
import Text.Printf

main = do
  x <- getLine
  xs <- map read . words <$> getLine
  putStrLn . toString . solve $ xs

solve :: [Int] -> (Int,Int,Int)
solve xs = (minimum xs, maximum xs, sum xs)

toString :: (Int,Int,Int) -> String
toString (x,y,z) = printf "%d %d %d" x y z

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    vector<ll>c(n+2,0);
    for (int i = 0; i < m; ++i) {
        ll a;cin >>a;
        c[a]++;
    }
    vector<ll>f(n+2,0);
    f[0]=1;
    for (int i = 0; i < n; ++i){
        if(c[i+1]==0)f[i+1]+=f[i];
        f[i+1]%=mod;
        if(c[i+2]==0)f[i+2]+=f[i];
        f[i+2]%=mod;
    }
    cout <<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  ll ans = 0;
  REP(i, s.size()){
    if(s[i] == '1') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();++i)
    {
        if(s[i]+n>90)
        {
            cout<<char(64+(s[i]+n)%90);
        }
        else cout<<char(s[i]+n);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  int B;
 cin >>A >>B;
  string S;
  cin >>S;
  
  int count=0;
  int x=S.size();
  
  if (S.at(A) != '-') {
    cout << "No"<< endl;
  }
  else if (S.at(A) == '-') {
    for(int i=0; i<x; i++) {
   if (S.at(i) == '-') {
     count ++;
   }
    }
  if (count ==1) {
    cout << "Yes" << endl;
  }
    else {
      cout <<"No" << endl;
    }
  }
  
}   
    
   


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	double a,b,h,m;
	cin >> a>>b>>h>>m;
	double theta = 0;
	double ans = 0;
	double pi = 3.14159265358979323846;

	double hour = (h / 12.0) * 2 * pi + (m / 60.0) * pi/6.0;
	double min = (m / 60.0) * 2 * pi;
	theta=abs(hour - min);
	if (theta > pi)	theta = 2*pi - theta;

	
	ans = sqrt(a*a + b*b - (double)2 * a*b*cos(theta));
	printf("%.15f", ans);



}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<string, int> u;
  bool ans = true; int prev = -1;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    if (u[s] != 0) ans = false;
    if (prev != -1 && prev != s[0]) ans = false;
    u[s]++; prev = s[s.size()-1];
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

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

    if(a >= 13){
        cout << b << endl;
    }else if(6 <= a && a <= 12){
        cout << b / 2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if(a >= 13) ans = b;
  else if(6 <= a && a <= 12) ans = b/2;
  else if(a <= 5) ans = 0;
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

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

fastio();

    ll x,k,d;
    cin>>x>>k>>d;

    ll q=abs(x)/d;

    if (q>=k)
    {
        cout<<abs(x)-k*d;

    } else {

        if (x<=0)
        {
            ll x1=x+q*d;
            ll x2=x+(q+1)*d;
            k-=q;

            if (k&1)
                cout<<abs(x2);
            else
                cout<<abs(x1);

        } else {
            ll x1=x-q*d;
            ll x2=x-(q+1)*d;
            k-=q;

            if (k&1)
                cout<<abs(x2);
            else
                cout<<abs(x1);
        }
    }

return 0;
}

Measured memory_bytes: 3560
N, M = map(int, input().split())
A = list(set(map(lambda x : int(x)//2, input().split())))

def _gcd(a, b):
    return a if b == 0 else _gcd(b, a%b)

def _lcm(a,b):
    return (a*b) // _gcd(a,b)

lcm = A[0] 
for ai in A[1:]:
    lcm = _lcm(lcm, ai)

ret = (M//lcm + 1)//2

for ai in A[1:]:
    if (lcm // ai) % 2 == 0:
        ret = 0
        break
print(ret)


Measured memory_bytes: 64112
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>();
    for ch in s.chars() {
        match ch {
            '1' => print!("9"),
            _ => print!("1"),
        }
    }
    println!("");
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
n = gets.to_i
a = Array.new(n)

n.times do |i|
  a[i] = gets.to_i
end

i = 1
count = 0
 
while i != 2 do
  if count > n
    puts -1
    exit 0
  else
    i = a[i-1]
    count += 1
  end
end

puts count


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double det = a*e - b*d;
    double y = (-d*c+a*f)/det;
    double x = (c-b*y)/a;

    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, T = lr()
CT = np.array([lr() for _ in range(N)])
CT = CT[CT[:, 1] <= T]
time = CT[:, 0]
if len(time) == 0:
    print('TLE')
else:
    answer = time.min()
    print(answer)


Measured memory_bytes: 12436
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int N=500015;
const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef vector<int> VI;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

char s[N];
int Len,f[N][27],g[N][21],l,r,Q;

int main() {
	scanf("%s",s+1);
	Len=strlen(s+1);
	Dep (i,Len,1) {
		f[i][s[i]-97]=i+1;
		For (j,s[i]-97+1,26) f[i][j]=f[f[i][j-1]][j-1];
		For (j,0,s[i]-97-1)	 f[i][j]=f[f[i][ 26]][j];
	}
	Dep (i,Len,1) {
		g[i][0]=f[i][26];
		For (j,1,20) g[i][j]=g[g[i][j-1]][j-1];
	}
	Q=rd();
	while (Q--) {
		l=rd(),r=rd()+1;
		Dep (i,20,0) if (g[l][i] && g[l][i]<=r) l=g[l][i];
		puts(l==r?"Yes":"No");
	}
	return 0;
}






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

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int k=0;
  long sum=A[0];
  for(int i=1; i<N; i++){
    if(2*sum<A[i]){
      k=i;
    }
    sum+=A[i];
  }
  cout << N-k << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

typedef long long ll;
typedef pair<ll,ll> P;

#define MOD 1000000007

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

ll dp[1111111];
ll fact[1111111];
ll factAcc[1111111];

void calFact(){
	fact[0] = 1;
	REP(i, 1111110) {
		fact[i+1] = fact[i] * (i+1) % MOD;
		factAcc[i+1] = (factAcc[i] + fact[i+1]) % MOD;
	}
}

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

	calFact();
	ll n, d, h;cin >> n >> h >> d;
	dp[0] = mod_div(1, factAcc[n]);
	ll sum = 0;
	ll l = 0;

	REP(i, h){
		sum = (sum + dp[i] * factAcc[n] % MOD) % MOD;
		while(l < i && i - l >= d){
			sum = (sum + MOD - dp[l] * factAcc[n] % MOD) % MOD;
			l++;
		}
		dp[i+1] = sum;
	}

	cout << dp[h] * fact[n] % MOD << endl;
	return 0;
}


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

int main(){
	int n, k, s;
	cin >> n >> k >> s;
	if(s != 1000000000){
		rep(i, k) cout << s << ' ';
		rep(i, n-k) cout << 1000000000 << ' ';
	}else{
		rep(i, k) cout << s << ' ';
		rep(i, n-k) cout << 999999999 << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280