akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;

const int N=3005;
const int mod=998244353;
const int div2=(mod+1)/2;
int n,s,a[N],dp[N][N],pw[N];

void solve()
{
    cin>>n>>s;
    pw[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pw[i]=pw[i-1]*2%mod;
    }
    dp[0][0]=pw[n];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=a[i]) dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]]*div2%mod)%mod;
        }
    }
    cout<<dp[n][s];
}


main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()
grid=[]
for i in range(H):
    grid.append(list(input()))

L=list2d(H, W, 0)
R=list2d(H, W, 0)
D=list2d(H, W, 0)
U=list2d(H, W, 0)

for i in range(H):
    cnt=0
    for j in range(W):
        if grid[i][j]=='#':
            cnt=0
        else:
            cnt+=1
        L[i][j]=cnt
for i in range(H):
    cnt=0
    for j in range(W-1, -1, -1):
        if grid[i][j]=='#':
            cnt=0
        else:
            cnt+=1
        R[i][j]=cnt
for i in range(W):
    cnt=0
    for j in range(H):
        if grid[j][i]=='#':
            cnt=0
        else:
            cnt+=1
        D[j][i]=cnt
for i in range(W):
    cnt=0
    for j in range(H-1, -1, -1):
        if grid[j][i]=='#':
            cnt=0
        else:
            cnt+=1
        U[j][i]=cnt

ans=0
for i in range(H):
    for j in range(W):
        if grid[i][j]!='#':
            ans=max(ans, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)


Measured memory_bytes: 307464
//089B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    set<char>colors;
    char c;
    int n;
    cin >> n;
    rep(i, n){
        cin >> c;
        colors.insert(c);
    }
    if(colors.size()==4){
        cout << "Four";
    }else{
        cout << "Three";
    }
    
}

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


int main()
{

int m,n,s=1100,sum=0,dif,total;
cin>>m>>n;
int a[m];
for(int i=0;i<m;i++)
{

    cin>>a[i];
    sum=sum+a[i];
    if(s>a[i])
        s=a[i];
}
dif=n-sum;
total=dif/s;
total=total+m;
cout<<total<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 1e5+1;
bool visited[N];
vector<ll>v[N];
vector<ll>p;
ll dis[N];

void dfs(ll vertex)
{
    visited[vertex] = true;
    p.push_back(vertex);
    for(ll i = 0 ;i < v[vertex].size() ; i++)
    {
        //cout << vertex << " " << v[vertex][i] << endl;
        
       
        //cout << dis[vertex] << " " << dis[v[vertex][i]] << endl;
        if(!visited[v[vertex][i]])
        {
            dfs(v[vertex][i]);
        }

         dis[vertex] = max(dis[v[vertex][i]]+1 , dis[vertex]);
        
    }
}


int main()
{
    ll N, M;
    cin >> N >> M;

    for(ll i = 0 ; i < M ; i++)
    {
        ll X , Y;
        cin >> X >> Y;
        v[X].push_back(Y);
    }

    for(ll i = 1 ; i <= N ; i++)
    {
        if(!visited[i])
        {
            dfs(i);
        }
    }


    ll maxi = 0 ;
    for(ll i = 1 ; i <= N ; i++)
    maxi = max(maxi , dis[i]);

    cout << maxi;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

vector<vector<int>> m;
vector<int> ansv;
vector<bool> used;
void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
  ll ans=accumulate(c.begin(),c.end(),0)-*max_element(c.begin(),c.end());
  m.resize(N);
  ansv.resize(N);
  used.resize(N);
  fill(used.begin(),used.end(),false);
  REP(N-1){
    a[i]--;
    b[i]--;
    m[a[i]].push_back(b[i]);
    m[b[i]].push_back(a[i]);
  }
  sort(c.begin(),c.end(),greater<int>());
  deque<int> q;
  ansv[0]=c[0];
  q.push_back(0);
  used[0]=true;
  int i=1;
  ll ansc=0;
  while(!q.empty()){
    int tmp=q.front();q.pop_front();
    for (auto &&j : m[tmp])
    {
      if(used[j])continue;
      used[j]=true;
      ansv[j]=c[i++];
      assert(ansv[j]<=ansv[tmp]);
      ansc+=min(ansv[j],ansv[tmp]);
      q.push_back(j);
    }
    
  }

  cout<<ans<<endl;
  REP(N){
    cout<<ansv[i]<<" ";
  }
  cout<<endl;  dump(ansc);
  dump(ans);
  assert(ans==ansc);
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 1152
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd); FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    cout << (s.find("YAKI") == 0 ? "Yes" : "No") << '\n';
}


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

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n){
        cin >> h[i];
    }
    int cnt=1;
    for(int i=1;i<n;i++){
        bool f=true;
        for(int j=0;j<i;j++){
            if(h[j]>h[i]){
                // cout << i << " " << j << endl;
                f = false;
            }
        }
        if(f){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll=long long;
const ll mod=1000000007;
int main(){

  ll N;
  cin>>N;
  ll power=1;
  for(int i=1;i<=N;i++){
  
    power*=i;
    power%=mod;
  }
  cout<<power;
  return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();
    if(a+b>=c) {
    	System.out.println(b+c);
    }else {
    	System.out.println(a+b+1+b);
    }
  }
}


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

#define int long long

signed main() {
  int N;
  while ( cin >> N, N ) {
    int W, H;
    cin >> W >> H;

    //1-indexed
    vector<vector<int> > cum(H+1, vector<int>(W+1, 0));
    for ( int i = 0; i < N; i++ ) {
      int x, y;
      cin >> x >> y;
      cum[y][x]++;
    }
    for ( int i = 1; i <= H; i++ ) {
      for ( int j = 1; j <= W; j++ ) {
	cum[i][j] += cum[i][j-1]+cum[i-1][j]-cum[i-1][j-1];
      }
    }

    int S, T;
    int ans = 0;
    cin >> S >> T;
    for ( int i = 1; i <= H-T+1; i++ ) {
      for ( int j = 1; j <= W-S+1; j++ ) {
	ans = max(ans, cum[i+T-1][j+S-1]-cum[i-1][j+S-1]-
		  cum[i+T-1][j-1]+cum[i-1][j-1]);
      }
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;
int main()
{
    long long w, h, x, y;
    cin >> w >> h >> x >> y;

    bool f = (x * 2) == w && (y * 2) == h;
    cout << fixed << setprecision(5);
    cout << (static_cast<double>(w * h) / 2.0) << " " << (f ? 1 : 0) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll func(ll K, ll N){
    if(K > N)
        return N;
    else if(N % K == 0)
        return func(K, N/K);
    else
        return func(K, N-K);
}

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main(){
    ll N;
    cin >> N;

    //REPi(i,2,N+1){
    //    ll x = func(i, N);
    //    if(x == 1){
    //        printf("%d\n", i);
    //    }
    //}

    ll ans = 0;
    auto divY = divisor(N-1);
    ans += divY.size() - 1;
    //cout << ans << endl;

    auto divX = divisor(N);
    for(auto&& x : divX){
        if(x == 1) continue;
        //if((N/x) % x == 1)
        //    ans++;
        ll n = N;
        while(n%x == 0) n /= x;
        if(n % x == 1)
            ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long
#define int long long 
#define INF 1e18
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}

int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,MOD-2,MOD);

}

int32_t main()
{
 c_p_c();
 int k;
 cin>>k;
if(k%2 == 0 || k%5 == 0){
    cout<<"-1\n";
  }
  else{
    ll p = 7%k;
    int cnt = 1;
    while(p != 0){
      p = (p*10+7)%k;
      ++cnt;
    }
 
    cout<<cnt<<"\n";
  }




return 0;

}








   



   








Measured memory_bytes: 3660
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0LL;
	ll up = 0LL;
	cin >>n;
	V a(n);
	input(a);
	rep(i, n) { ans += max(0LL, up - a[i]);
		chmax(up, a[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4788
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int a,b,c,d,k;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b>>c>>d>>k;
    cout<<max(0,c*60+d-k-(a*60+b))<<endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
 
int n, S[50000000],L[5000000],R[5000000];
int MAX = 1000000001;
int count = 0;

void merge(int S[], int left, int mid, int right) {
	int i = 0;
	int j = 0;
	int k = 0;
	int n1 = mid - left;
	int n2 = right - mid;

	for (i = 0;i < n1 ;i++) {
		L[i] = S[left + i];
		
	}
	for (i = 0;i < n2 ;i++) {
		R[i] = S[mid + i];

	}
	L[n1] = MAX;
	R[n2] = MAX;

	i = 0;
	j = 0;
	
	for (k = left;k < right;k++) {
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
			count++;
		}
		else {
			S[k] = R[j];
			j++;
			count++;
		}

	}
}

void mergesort(int S[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergesort(S, left, mid);
		mergesort(S, mid, right);
		merge(S, left, mid, right);
	}
}


int main(void)
{
	int q, m[5000000];
	int i, j, k, l = 0;

	scanf("%d", &n);

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

	mergesort(S, 0, n);

	for (i = 0;i < n;i++) {
		printf("%d", S[i]);
		if (i < n - 1) {
			printf(" ");
		}
	}
	printf("\n%d\n", count);

	return 0;
}
 



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
	bool arr[30]={};
	int n;
	for(int i=0;i<28;i++){
		cin>>n;
		arr[--n]=1;
	}
	for(int i=0;i<30;i++)
		if(!arr[i])
			cout<<i+1<<endl;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> v(n),b(q);
  for(int i=0;i<n;i++) v[i]=k;
  for(int i=0;i<q;i++) cin>>b[i];
  for(int i=0;i<q;i++){
    v[b[i]-1]+=1;
  }
  
  for(int i=0;i<n;i++){
    if(v[i]<=q){
      cout<<"No"<<endl;
    }else{
      cout<<"Yes"<<endl;
    }
  }
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define long long long
const int MAXN = 1e6 + 7;
const long MOD = 1e9 + 7;
const long INF = 1e15 + 7;


main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int i, j, k;

    int N; cin >> N;
    int c = 0;
    for (i = 1; i <= N; ++i) {
        int E; cin >> E;
        if (E != i) ++c;
    }

    cout << (c <= 2 ? "YES" : "NO");
}

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

int arr[100005][3];
int val[100005][3];

int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	val[0][0] = arr[0][0];
	val[0][1] = arr[0][1];
	val[0][2] = arr[0][2];
	for (int i = 1; i < n; ++i)
	{
		int* curr = val[i];
		int* temp = val[i - 1];
		curr[0] = std::max(temp[1], temp[2]) + arr[i][0];
		curr[1] = std::max(temp[0], temp[2]) + arr[i][1];
		curr[2] = std::max(temp[0], temp[1]) + arr[i][2];
	}
	std::cout << std::max({ val[n - 1][0], val[n - 1][1], val[n - 1][2] }) << '\n';
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    const long MOD = 1000000007;
    static int N = int.Parse(Console.ReadLine());
    static int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    static void Main()
    {
        if (N % 2 == 1)
        {
            int[] cnt = new int[N / 2 + 1];
            for(int i = 0; i < N; i++)
            {
                cnt[A[i] / 2]++;
            }
            if (cnt[0] != 1)
            {
                Console.WriteLine(0);
                return;
            }
            for(int i = 1; i <= N / 2; i++)
            {
                if (cnt[i] != 2)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            Console.WriteLine(myPow(2,N/2));
        }
        else
        {
            int[] cnt = new int[N / 2];
            for(int i = 0; i < N; i++)
            {
                cnt[A[i] / 2]++;
            }
            if (cnt.Count(a => a != 2) > 0)
            {
                Console.WriteLine(0);
                return;
            }
            Console.WriteLine(myPow(2, N / 2));
        }
    }
    static long myPow(long a,long b)
    {
        long ans = 1;
        while (b > 0)
        {
            if (b % 2 == 0)
            {
                a = (a * a) % MOD;
                b /= 2;
            }
            else
            {
                ans = (ans * a) % MOD;
                b--;
            }
        }
        return ans;
    }
}


Measured memory_bytes: 11224
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
const int MAX_N=100010;
bool is_prime[MAX_N];

int sieve(int n){
    
    ll p=0;
    for(ll i=0;i<=n;i++) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(ll i=2;i<=n;i++){
        if(is_prime[i]){
            //prime[p++]=i;
            p++;
            for(ll j=i*2;j<=n;j+=i){
                is_prime[j]=false;
            }
        }
    }
    return p;
}


int main(){
  sieve(100000);
  int res[100010];
  for(int i=0;i<MAX_N;i++){
    if(is_prime[i] and is_prime[((i+1)/2)])res[i]=res[i-1]+1;
    else res[i]=res[i-1];
  }
  int x;
  cin>>x;
  
  for(int i=0;i<x;i++){
    int l,r;
    cin>>l>>r;
    cout<<res[r+1]-res[l-1]<<endl;
  }
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    
    if(n==1)cout <<"Hello World"<<endl;
    else{
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import sys

sys.setrecursionlimit(10 ** 7)
# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W, K = map(int, input().split())
    C = [[] for _ in range(H)]
    for i in range(H):
        C[i] = list(input())
    ccc =[0]*37
    ans = 0

    for h in itertools.product("01", repeat=H):
        for w in itertools.product("01", repeat=W):
            count = 0

            for i in range(H):
                for j in range(W):
                    if h[i] == "1" and w[j] == "1" and C[i][j] == "#":
                        count += 1
            ccc[count] +=1

    print(ccc[K])


if __name__ == "__main__":
    main()


Measured memory_bytes: 68508
s=input()
right=1

import collections
def isOK(target):
  counter=collections.Counter(list(target))
  if max(counter.values())>len(target)//2:
    return True
  return False
  
for left in range(len(s)-1):
  cur=s[left:right+1]
  while right+1<len(s) and s[right+1] in cur:
    cur+=s[right+1]
    right+=1
    if isOK(cur):
      break
    
  if isOK(cur):
    print(left+1,right+1)
    break
    
  if left+1==right:
    right+=1
else:
  print(-1,-1)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int a[26];
int b[26];
int main()
{
    int i;
    string s;
    cin>>s;
    int n=s.size();

    for(i=0;i<n;i++)
        a[s[i]-'a']=1;

    if(n<26)
    {

        string d=s;

        int f;
        for(i=0;i<26;i++)
            if(a[i]==0)
        {f=i;
        break;
        }
        d.push_back((char)('a'+f));
        cout<<d<<endl;


    }
    else{

        int h=0;
        int in=-1;
        int te=0;
        for(i=n-1;i>=0;i--)
        {
            int u=s[i]-'a';
            if(u>=h)
            {
                b[u]=1;
                h=u;


            }
            else{

                in=i;
                te=s[i]-'a';
break;



            }


        }
        int y;
        if(in!=-1)
        {

            for(i=te+1;i<26;i++)
                if(b[i])
            {
                y=i;
                break;
            }


        for(i=0;i<in;i++)
            cout<<s[i];
        cout<<(char)('a'+y)<<endl;
        }
        else
            cout<<-1<<endl;




    }

    return 0;
}


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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if ( a == 5 && b == 5 && c == 7){
      cout << "YES" << endl;
  }
    
  else if (a == 5 && b == 7 && c == 5){
    cout << "YES" << endl;
  }
  
  else if (a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}

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

int main(){
	string s;
  	cin >> s;
  	int zero = 0, ichi = 0;
  	for(auto c:s){
    	if(c == '0')++zero;
      	else ichi++;
    }
  	cout << min(zero,ichi)*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;

int main(){
  int n;
  cin>>n;
  int a=n%100;
  a+=4; a/=5;
  if(n/100>=a) co(1);
  else co(0);
  
  
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>

using namespace std;

int main(){
    
    int n, k, aux, tot = 0;

    cin >> n >> k;
    
    for(int i = 0; i < n; i++){
        cin >> aux;

        if(aux >= k)
            tot++;
    }   

    cout << tot << endl;

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int count = 0;
    int prei = a[0];
    for(int i=1;i<N;i++){
        if(prei == a[i]){
            if(prei == a[i+1]) i++;
            count++;
        }
        prei = a[i];
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

typedef long long ll;
typedef pair<int, int> pii;
struct Node {
    int a, b;
    bool operator < (const Node& x) const { return a < x.a; }
};

const int INF = 0x7fffffff;
const int maxn = 1e5 + 10;
int n;
ll k;
Node node[maxn];

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d %lld", &n, &k);
    REP(i, n) { scanf("%d %d", &node[i].a, &node[i].b); }
    sort(node, node + n);
    for (int i = 0; i < n; ++i) {
        k -= node[i].b;
        if (k <= 0) { printf("%d\n", node[i].a); break; }
    }
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
inline bool is_year(ll i) {
    return i > 12 || i == 0;
}

// 処理内容
int main() {
    
    string s; cin >> s;

    ll si = 10LL * (s[0] - '0') + s[1] - '0';
    ll sj = 10LL * (s[2] - '0') + s[3] - '0';

    if (is_year(si) && is_year(sj)) {
        cout << "NA" << endl;
    } else if (is_year(si)) {
        cout << "YYMM" << endl;
    } else if (is_year(sj)) {
        cout << "MMYY" << endl;
    } else {
        cout << "AMBIGUOUS" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;
  int a = x/1000;
  x -= a*1000;
  int b = x/100;
  x -= b*100;
  int c = x/10;
  int d = x%10;
  if((b==c) && (a==b||c==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}
int main(void){
	int n=nextint();
	int k=nextint();
	int d=nextint();
	int ans=0;
	for(int i=n; i<=k; i++){
		if(i%d==0) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define maxn 100
#define maxk 100001
using namespace std;

int n,k;
int ar[maxn];
bool dp[maxk];

int main() {
	scanf("%d%d",&n,&k);
	for( int i = 0 ; i < n ; i++ )
		scanf("%d",&ar[i]);
	for( int i = 1 ; i <= k ; i++ )
		for( int j = 0 ; j < n && ar[j] <= i ; j++ )
			if( !dp[i-ar[j]] ) {
				dp[i] = true;
				break;
			}
	if(dp[k])
		puts("First");
	else
		puts("Second");
	return 0;
}


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

template <class T>
inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; }
template <class T>
inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; }

const int nax = 2010;

long long dp[nax][nax];
long long A[nax];
int N;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
	vector<long long> order(N);
	iota(order.begin(), order.end(), 0);
	sort(order.begin(), order.end(), [&](const long long& i, const long long& j) { return A[i] > A[j]; });

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j + i < N; ++j) {
			int pos = order[i + j];
			uax(dp[i + 1][j], dp[i][j] + A[pos] * abs(pos - i));
			uax(dp[i][j + 1], dp[i][j] + A[pos] * abs(pos - (N - 1 - j)));
		}
	}

	long long ans = 0;
	for (int i = 0; i < N; ++i) uax(ans, dp[i][N - i]);
	cout << ans << '\n';
}

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

const ll INF = 1LL << 60;

ll A, B, C, D;
int main() {
    cin >> A >> B >> C >> D;
    if (B < C || D < A) {
        cout << 0 << endl;
        return 0;
    }
    
    if (A <= C) {
        cout << min(abs(C - B), abs(D - C)) << endl;
    } else {
        cout << min(abs(A - D), abs(A - B)) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
long long ans;
int main(){
	long n;
	long long a[1000];
	long long b[1000];
	long long c[1000];
	long long d[1000];
	scanf("%li",&n);
	for (int i=1;i<=n;i++){
		scanf("%lli %lli %lli %lli",&a[i],&b[i],&c[i],&d[i]);	
		
	}
	for (int i=1;i<=n;i++){
		gcd(b[i],d[i]);
		long long g=ans;
		if (d[i]<b[i]||a[i]<b[i])printf("No\n");
		else
		if ((b[i]-g+a[i]%g)>c[i])printf("No\n");
		else printf("Yes\n");
	}
}
int gcd(long long x,long long y){
	if (x<y) return(gcd(y,x));
	if (x%y==0){
		ans=y;
		return(1);
	}
	return(gcd(y,x%y));
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    --p[i];
  }

  vector<int> a(n);
  vector<int> b(n);

  b[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    b[i] = b[i + 1] + 2 * n + 1;
  }

  CHECK(b[0] <= 1000 * 1000 * 1000 - 2 * n);

  a[0] = 1;
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1] + 2 * n + 1;
  }
  CHECK(a[n - 1] <= 1000 * 1000 * 1000 - 2 * n);

  for (int i = 1; i < n; i++) {
    int prev = a[p[i - 1]] + b[p[i - 1]];
    int cur = a[p[i]] + b[p[i]];
    int delta = max(0, prev + 1 - cur);
    CHECK(delta <= 2 * n);
    a[p[i]] += delta;
  }

  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
  for (int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  int count=0;
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  for(int i=0;i<n;i++){
    if(d[i]==d[i+1])continue;
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        string S = NextString(), T = NextString();
        int N = S.Length;
        Dictionary<char, char> c1 = new Dictionary<char, char>();
        Dictionary<char, char> c2 = new Dictionary<char, char>();
        for (int i = 0; i < N; i++)
        {
            if (c1.ContainsKey(S[i]) && c1[S[i]] != T[i])
            {
                Console.WriteLine("No");
                return;
            }
            if (c2.ContainsKey(T[i]) && c2[T[i]] != S[i])
            {
                Console.WriteLine("No");
                return;
            }
            c1[S[i]] = T[i];
            c2[T[i]] = S[i];
        }
        Console.WriteLine("Yes");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
    public static long nHr(long n, long r)
    {
        n = n + r - 1;
        long a = 1;
        for (long x = 0; x < r; x++) { a *= (n - x); a %= MOD; }
        long b = 1;
        for (long x = 2; x <= r; x++) { b *= x; b %= MOD; }
        b = RepPow(b, MOD - 2) % MOD;
        return a * b % MOD;

    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

using ll=int64_t;
//#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	#ifdef int
	scanf("%" SCNd64,&i);
	#else
	scanf("%d",&i);
	#endif
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	#ifdef int
	printf("%" PRId64,x);
	#else
	printf("%d",x);
	#endif
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

#ifdef int
const int inf=LLONG_MAX/3;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=310;
int dp[Nmax][Nmax][Nmax];

signed main(){
	string s=readString();
	int n=s.size(),k=read();
	REP(i,n)dp[i][i+1][0]=1;
	FOR(len,2,n+1)REP(b,n-len+1){
		int e=b+len;
		REP(x,k+1)dp[b][e][x]=max(dp[b+1][e][x],dp[b][e-1][x]);
		if(s[b]==s[e-1]){
			REP(x,k+1)chmax(dp[b][e][x],dp[b+1][e-1][x]+2);
		}else{
			FOR(x,1,k+1)chmax(dp[b][e][x],dp[b+1][e-1][x-1]+2);
		}
	}
	int ans=0;
	REP(x,k+1)chmax(ans,dp[0][n][x]);
	cout<<ans<<endl;
}


Measured memory_bytes: 114816
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=998244353;

void solve(){
	ld a,b;
	cin>>a>>b;
	ld h,m;
	cin>>h>>m;
	
	ld hour=(h*60+m)*2*M_PI/(60.0*12.0);
	ld mini=m*2*M_PI/(60.0);	

	ld X=a*cos(hour), Y=a*sin(hour);
	ld x=b*cos(mini), y=b*sin(mini);

	ld ans=sqrtl((X-x)*(X-x)+(Y-y)*(Y-y));

	cout<<setprecision(15)<<ans<<endl;
}


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


Measured memory_bytes: 4172
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){
	
	int a,b,c;
	bool f=false;
	cin>>a>>b>>c;
	
	if(a==1){
		if(b==1)
			f=true;
	}
	else{
		if(c==1)
			f=true;
	}

	if(f)
		cout<<"Open"<<endl;
	else
		cout<<"Close"<<endl;


}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b;
	cin >> a >> b;
	for (int n = 1; n < 10000; n++) {
		if (n * 8 / 100 == a && n / 10 == b) {
			cout << n << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 100005
using namespace std;

int main(){
    int a,b,w;
    cin>>w>>a>>b;
    if(a+w<b)cout<<b-a-w<<endl;
    else if(b+w<a)cout<<a-b-w<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';

const main = (input) => {
    const lines = input.split('\n');
    const data = lines[0].split(' ');
    const N = parseInt(data[0], 10);
    const i = parseInt(data[1], 10);
    const r = N - i + 1;
    console.log(r);
};

const isTest = false;

if (isTest) {
    main('4 2');
    main('1 1');
    main('15 11');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

Measured memory_bytes: 7500
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

int main(){
  int a, b;
  cin >> a >> b;
  bool ans = a % 2 && b % 2;
  puts(ans ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>

using namespace std;

int main()
{
    int k,a,b,n,ans;
    cin>>k>>a>>b;
    for(int i = a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

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

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull MOD = 1000'000'007;

const ll HMAX = 80 + 1;
const ll WMAX = 80 + 1;
const ll XMAX = 160 * 80 + 10;

bool dp[HMAX][WMAX][XMAX] = {};
ll A[HMAX][WMAX] = {};
ll B[HMAX][WMAX] = {};

int main(){
    auto H = read<ll>();
    auto W = read<ll>();
    REP(h, H) REP(w, W) A[h][w] = read<ll>(); 
    REP(h, H) REP(w, W) B[h][w] = read<ll>(); 

    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    REP(h, H){
        REP(w, W){
            REP(x, XMAX){
                if(dp[h][w][x]){
                    auto h1 = abs(A[h+1][w] - B[h+1][w]);
                    auto w1 = abs(A[h][w+1] - B[h][w+1]);
                    dp[h + 1][w][x + h1] = 
                    dp[h + 1][w][abs(x - h1) ] =
                    dp[h][w + 1][x + w1] =
                    dp[h][w + 1][abs(x - w1)] = true;
                }
            }

        }
    }
    REP(x, XMAX) if(dp[H-1][W-1][x]){ write(x); break; }

}



Measured memory_bytes: 81536
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ").map(_.toInt)
      while( n(0) != 0 || n(1) != 0) {
        println("#"*n(1))

        (2 to n(0)-1).foreach(s=> { print("#");print("."*(n(1)-2));print("#\n") })

        if(n(0)>1) {
          println("#"*n(1))
        }
        println("")
        n = readLine.split(" ").map(_.toInt)
      }
  }
}

Measured memory_bytes: 45020
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  var data = input.split("\n");
  while(data[0] != 0){
    var unit = data.splice(0,5);
    var result, te = [];
    unit.forEach(function (v) {
      if(te.indexOf(v) < 0) te.push(v);
    });
    if(te.length == 3 || te.length == 1){
      result = [3,3,3];
    } else{
      if(te.indexOf("1") < 0)      result = [0,1,2]
      else if(te.indexOf("2") < 0) result = [2,0,1]
      else if(te.indexOf("3") < 0) result = [1,2,0]
    }
    unit.forEach(function (v) {
      console.log(result[v-1]);
    })
  }
});

Measured memory_bytes: 17484