akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue> 
using namespace std;
#define INF 0x3f3f3f3f
char p[110];
int a[26];
int n,m,k;
int main()
{
	while(~scanf("%s",p))
	{
		memset(a,0,sizeof(a));
		int len=strlen(p);
		int flag=0;
		for(int i=0;i<len;i++)
		{
			if(a[p[i]-'0']) flag=1;
			else a[p[i]-'0']++;
		}
		if(flag)cout<<"no"<<endl;
		else cout<<"yes"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  cin >> N >> K;
  vector<long> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  sort(data.begin(), data.end());
  long ng = 0, ok = data.at(N - 1), mid;
  long count = 0;
  while(abs(ok - ng) > 1){
    mid = (ok + ng) / 2;
    count = 0;
    for(int i = 0; i < N; i++){
      if(data.at(i) % mid == 0){
        count += data.at(i) / mid - 1;
      } else {
        count += data.at(i) / mid;
      }
    }
    if(count <= K)ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 4720
import math
n,k = map(int,input().split())

def f(i,k,n):
     if i<k:
          m = math.ceil(math.log2(k/i))
          return ((1/2)**m)/n
     else:
          return 1/n

ans = 0
for i in range(1,n+1):
     ans += f(i,k,n)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=200005;
int A[MAX_N];
bool B[MAX_N];
int n;
int val(int pos)
{
	if(B[pos]!=B[pos+1])return n;
	return min(abs(pos-n),abs(pos+1-n));
}
bool check(int m)
{
//	cout<<"check:"<<m<<endl;
	memset(B,false,sizeof(B));
	for(int i=1;i<2*n;i++)if(A[i]>=m)B[i]=true;
	int pos=0,mi=n;
	for(int i=1;i<2*n-1;i++)
	{
		if(val(i)<mi)
		{
			mi=val(i);
			pos=i;
		}
	}
/*	for(int i=1;i<2*n;i++)cout<<B[i]<<" ";
	cout<<endl;*/
	if(pos==0)return n%2?B[n]:!B[n];
	else return B[pos];
}
int main()
{
	cin>>n;
	for(int i=1;i<2*n;i++)cin>>A[i];
	int lb=0,ub=2*n-1;
	while(ub-lb>1)
	{
		int mid=(lb+ub)/2;
		if(check(mid))lb=mid;
		else ub=mid;
	}
	cout<<lb<<endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int T_MAX = 11;

int tb[][3][3] = {
	{{9,1,9},
	 {1,0,1},
	 {9,9,9}},

	{{9,1,9},
	 {9,0,1},
	 {9,1,9}},

	{{9,0,9},
	 {1,0,1},
	 {9,1,9}},

	{{9,1,9},
	 {1,0,9},
	 {9,1,9}},
	// +
	{{9,1,9},
	 {1,0,1},
	 {9,1,9}},
};

int cur[9][9],W,H,sx,sy;
int dx[] = {-1,0,0,1} , dy[] = {0,-1,1,0};

bool done[9][9];
int dfs(int x,int y){
	if(done[y][x]) return 0 ;
	else done[y][x] = true;
	if(y == sy && x == sx) return 1;
	if(cur[y][x] != 0) return 0;
	int ans = 1;
	rep(i,4) ans += dfs(x+dx[i],y+dy[i]);
	return ans;
}
void output(){
	rep(i,H+2){
		rep(j,W+2)cout << cur[i][j];
		cout << endl;
	}
}	
bool isTaboo(int c,int x,int y){
	int ans = 0;
	rep(i,9) rep(j,9) done[i][j] = 0;
	rep(i,4) ans+=dfs(x+dx[i],y+dy[i]);
	return c != ans;
}

bool badFlag;
int nest[50] = {0};
int bt(int c,int x,int y){
	if(nest[c]++ > 25000) { badFlag = true;return true;}
	if(c == 0) return (x == sx && y == sy);
	if(cur[y][x] != 0)return false;
	cur[y][x] = 2;
	if(isTaboo(c,x,y)){cur[y][x] = 0;return false;}
	rep(i,4) if( bt(c-1,x+dx[i],y+dy[i]) ) return true;
	cur[y][x] = 0;
	return false;
}
int main(){
	while(cin >> W >> H && W){
		int eCount = 0;
		rep(i,9)rep(j,9) cur[i][j] = 1;
		rep(i,H)rep(j,W) cin >> cur[i+1][j+1] , eCount += !cur[i+1][j+1];
		rep(i,H+2)rep(j,W+2) if(cur[i][j] == 0) sx = j , sy = i;
		rep(i,50)nest[i] = 0;
		badFlag = 0;
		cout << (eCount > 3 && bt(eCount,sx,sy) && !badFlag ? "Yes" : "No") << endl;
	}
}

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

int main(){
    int x;
    cin >> x;

    int a=x%7;

    if(a==1) cout << "fri" << endl;
    else if(a==2) cout << "sat" << endl;
    else if(a==3) cout << "sun" << endl;
    else if(a==4) cout << "mon" << endl;
    else if(a==5) cout << "tue" << endl;
    else if(a==6) cout << "wed" << endl;
    else if(a==0) cout << "thu" << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll, ll>
#define pb push_back
#define rep0(i, n) for(ll i = 0;i<n;i++)
#define rep1(i, n) for(ll i = 1;i<n;i++)
#define all(v) v.begin(),v.end()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const int N = 1e6 + 5;

vector<bool> arr(N, false);

bool factorise(int a){
    bool flag = true;
    for(int i=2; i*i<=a; i++){
        if(a%i == 0){
            if(arr[i] || arr[a/i]){
                arr[i] = true;
                arr[a/i] = true;
                flag = false;
                return flag;
            }
            else{
                arr[i] = true;
                arr[a/i] = true;
            }
        }
    }
    return flag;
}

void solve(){
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(ll i=0; i<n; i++){
        cin >> v[i];
        arr[v[i]] = true;
    }
    bool ok = 1;
    ll a = v[0];
    for(ll i=1; i<n; i++){
        a = __gcd(a, v[i]);
    }
    for(ll i=0; i<n; i++){
        if(!factorise(v[i])){
            ok = 0;
            break;
        }
    }
    if(ok){
        cout << "pairwise coprime";
    }
    else if(a == 1){
        cout << "setwise coprime";
    }
    else{
        cout << "not coprime";
    }
}
 
int main()
{
    fast;
    solve();
    // int t;
    // cin >> t;
    // while(t--){
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 11024
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,i,j;
    string str;
    cin >> n;
    getline(cin,str);
    for(i=0;i<n;i++){
        getline(cin,str);
        for(j=0;j<str.size();j++){
            if(j+6 > str.size()) break;
            if(str[j] == 'H' && str[j+1] == 'o' && str[j+2] == 's' && str[j+3] == 'h' && str[j+4] == 'i' && str[j+5] =='n' && str[j+6] == 'o'){
                str[j+6] = 'a';
            }
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

const int N = 2e3 + 20;
int n, m, T, a[N], x, y, dis[N], num, inqueue[N], flag;

queue<int> q;
int ans[N];

int main()
{
#ifdef ONLINE_JUDGE
#else
    // freopen("r.txt", "r", stdin);
    // freopen("w.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);

    cin >> n >> x >> y;

    // cout << n << " " << x << " " << y << endl;

    for (int i = 1; i <= n; i++) {
        q.push(i);
        memset(dis, 0x7f, sizeof(dis));
        dis[i] = 0;
        inqueue[i] = true;
        while (!q.empty()) {
            int u = q.front();
            q.pop();

            int v = u + 1;
            if (v > 0 and v <= n and dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                if (!inqueue[v])
                    q.push(v);
            }

            v = u - 1;
            if (v > 0 and v <= n and dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                if (!inqueue[v])
                    q.push(v);
            }

            if (u == x or u == y) {
                if (u == x)
                    v = y;
                else
                    v = x;
                if (v > 0 and v <= n and dis[v] > dis[u] + 1) {
                    dis[v] = dis[u] + 1;
                    if (!inqueue[v])
                        q.push(v);
                }
            }
            inqueue[u] = false;
        }

        for (int j = 1; j <= n; j++)
            ans[dis[j]]++;
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] / 2 << endl;
}

Measured memory_bytes: 256
main = do
    large_n_ <- readLn::IO Integer
    let
	hstart = min (3*large_n_`quot`4) 3500

	ans = [ (h,n,w) |
		h<-[hstart,hstart-1..1]				   ,
		n<-[h..min 3500 ((2*large_n_*h)`quot`(4*h-large_n_))],
		(w,r) <-[(h*n*large_n_)`quotRem`(4*h*n-large_n_*(n+h))],
		 r==0&&w>0		]

	print' (a,b,c) = putStr $
			    (show a)++" "++(show b)++" "++(show c)
    case large_n_ of
	2   -> putStr "1 2 2"
	_   -> print' $ head ans


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

int main(void){

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

    int sum = 0;
    int a[n];
    a[0] = W[0];

    for(i=0;i<n;i++){
        sum += W[i];
        if(i>0) a[i] = a[i-1]+W[i];
    }

    int min = 100000;

    for(i=0;i<n;i++){
        if(abs((sum - a[i])-a[i]) < min) min = abs((sum - a[i])-a[i]);
    }

    printf("%d\n",min);


    
}

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

using namespace std;

int main() {
	int a, b, h, m;
	double angle, c;
	cin >> a >> b >> h >> m;
	
	double ah = h * 30 + m * .5;
	int am = m * 6;
	angle = abs(ah - am);
	if (angle > 180) {
		angle = 360 - angle;
	}
	angle = angle / 180.0 * M_PI;
	c = sqrt(a * a + b * b - 2 * a * b * cos(angle));
	
	printf("%.20lf", c);
	
	return 0;
}


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

int H;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void maxHeapify(vector<int> &A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= H and A.at(l) > A.at(i)) largest = l;
    else largest = i;
    if (r <= H and A.at(r) > A.at(largest)) largest = r;

    if (largest != i) {
        swap(A.at(i), A.at(largest));
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<int> &A) {
    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(A, i);
    }
}

int main() {
    cin >> H;
    vector<int> A(H+1);
    for (int i = 1; i <= H; i++) {
        cin >> A.at(i);
    }

    buildMaxHeap(A);
    for (int i = 1; i <= H; i++) {
        cout << " ";
        cout << A.at(i);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4620
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%lf\n",d);
    return 0;
}


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <climits>
#include <cstdio>
#include <vector>

using namespace std;

const int NMAX = 200;

const int CMAX = 100001 * 200;

array<array<int, NMAX>, NMAX> d;

int getDist(const vector<int> &r)
{
    int bk = -1;
    int dist = 0;
    for (auto x : r)
    {
        if (bk < 0)
        {
            bk = x;
            continue;
        }

        dist += d[bk - 1][x - 1];

        bk = x;
    }
    return dist;
}

int main()
{
    int N, M, R;
    if (scanf("%d%d%d", &N, &M, &R) < 3) return 0;

    vector<int> r;
    for (int i = 0; i < R; i++)
    {
        int tmp;
        if (scanf("%d", &tmp) < 1) return 0;
        r.push_back(tmp);
    }

    for (int i = 0; i < NMAX; i++)
    {
        d[i].fill(CMAX);
    }

    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        if (scanf("%d%d%d", &a, &b, &c) < 3) return 0;

        // 0-indexed
        a--;
        b--;

        d[a][b] = d[b][a] = c;
    }

    // Warshall–Floyd
    // kは中継点
    for (int k = 0; k < N; k++)
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    int mintotal = INT_MAX;

    sort(r.begin(), r.end());

    while (next_permutation(r.begin(), r.end()))
    {
        int dist = getDist(r);
        mintotal = min(mintotal, dist);
    }

    printf("%d\n", mintotal);
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (10 ** 6 + 1)
a.sort()
ans = 0


for i in a:
    cnt[i] += 1

a = set(a)

for k in a:
    for l in range(k * 2, (10 ** 6 + 1), k):
        cnt[l] += 1

for m in a:
    if cnt[m] == 1:
        ans += 1
    


print(ans)

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

#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e16;
const int N = 3e3 + 5;

LL a[ N ];
LL dp[ N ][ N ];

LL solve(int l, int r) {
  if (l > r) return 0;
  if (dp[l][r] != -INF) return dp[l][r];
  LL ret = -INF;
  ret = max(ret, a[l] - solve(l + 1, r));
  ret = max(ret, a[r] - solve(l, r - 1));
  return dp[l][r] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = -INF;
    }
  }
  cout << solve(1, n) << endl;
  return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  ll H, W;
  cin >> H >> W;

  if (H % 3 == 0 || W % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = min(H, W);
  repp(a, H / 3, H / 3 + 1) {
    repp(b, W / 2, W / 2 + 1) {
      ll A = a * W;
      ll B = (H - a) * b;
      ll C = (H - a) * (W - b);

      ll S = max({A, B, C}) - min({A, B, C});

      chmin(ans, S);
    }
  }
  swap(H, W);
  repp(a, H / 3, H / 3 + 1) {
    repp(b, W / 2, W / 2 + 1) {
      ll A = a * W;
      ll B = (H - a) * b;
      ll C = (H - a) * (W - b);

      ll S = max({A, B, C}) - min({A, B, C});

      chmin(ans, S);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  A, B, C, X, Y = map(int, input().split())
  print(min([C*max(X, Y)*2, A*X + B*Y, 2*C*Y+A*(max(0, X-Y)), 2*C*X + B*(max(0, Y-X))]))
if __name__ == "__main__":
  main()

Measured memory_bytes: 3060
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  string S;
  cin >> S;

  int n = S.size() - 1;
  int m = 1;
  rep(i, n) { m *= 2; }

  ll Ans = 0;
  rep(i, m) {
    ll num = S[0] - '0';
    rep(j, n) {
      if (i & (1 << j)) {
        Ans += num;
        num = S[j + 1] - '0';
      } else {
        num = num * 10 + (S[j + 1] - '0');
      }
    }
    Ans += num;
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 384
a,b,c,x = 4.times.map{gets.to_i}

cnt = 0

(0..a).each do |i|
  (0..b).each do |m|
    (0..c).each do |n|
      cnt += 1 if 500 * i + 100 * m + 50 * n == x
    end
  end
end

print cnt

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N, X, T := nextInt(), nextInt(), nextInt()
	fmt.Fprintf(out, "%d\n", T*((N-1)/X+1))
}


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

string str;
int p;

int Num();
vector<int> SS();
int S();

int Num() {
//  cout << "NUM:" << str.substr(p) << endl;
  int ans = 0;
  while (isdigit(str[p])) {
    int c = str[p] - '0';
    ans = ans * 10 + c;
    p++;
  }
  return ans;
}

vector<int> SS() {
//  cout << "SS:" << str.substr(p) << endl;
  vector<int> ans;
  while (str[p] == '[') {
    int s = S();
    ans.push_back(s);
  }
  return ans;
}

int S() {
 // cout << "S:" << str.substr(p) << endl;
  p++; // read [
  if (isdigit(str[p])) {
    int s = Num();
    p++; // read ]
    return s / 2 + 1;
  } else {
    vector<int> ss = SS();
    sort(ss.begin(), ss.end());
    int ans = 0;
    for (int i = 0, len = ss.size(); i < len / 2 + 1; i++) {
      ans += ss[i];
    }
    p++; //read ]
/*    cout << ans << "=[";
    for (int s : ss) {
      cout << s << ",";
    }
    cout << "]"<< endl;*/
    return ans;
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str;
    p = 0;
    cout << S() << endl;
  }
  return 0;
  
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc161/abc161_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int K;
  cin >> K;

  queue<ll> que;
  repi(i, 1, 10) { que.push(i); }
  rep(i, K - 1) {
    ll s = que.front();
    que.pop();
    for (int j = -1; j <= 1; j++) {
      int add = (s % 10) + j;
      if (add >= 0 && add <= 9) que.push(s * 10 + add);
    }
  }

  cout << que.front() << endl;
}

Measured memory_bytes: 1792
import collections
N = int(input())
S_list = []
for i in range(N):
  S = str(input())
  S_list.append(S)

c = collections.Counter(S_list)

C_0 = c['AC']
C_1 = c['WA']
C_2 = c['TLE']
C_3 = c['RE']

print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))

Measured memory_bytes: 16588
#include<iostream>
#include<vector>
using namespace std;
const int MOD=1000000007;
int N,M;
vector<bool>issafe;

int main(){
    cin>>N>>M;
    issafe.assign(N+1,true);
    for(int i=0;i<M;i++){
        int a;cin>>a;
        issafe[a]=false;
    }

    vector<int>dp(N+1,0);

    dp[0]=1;
    if(issafe[1])dp[1]=1;

    for(int n=2;n<=N;n++){
        if(issafe[n-1])dp[n]+=dp[n-1];
        if(issafe[n-2])dp[n]+=dp[n-2];
        dp[n]%=MOD;
    }
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 640
////////////////////////    W H I T E C L O U D    ////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main()
{
    FAST();
    string str;
    cin>>str;
    if(str[str.size()-1]=='s')str+="es";
    else str+='s';
    cout<<str<<endl;



    return 0;
}







Measured memory_bytes: 3664
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		int K = sc.nextInt();
		int S = sc.nextInt();
		for(int x = 0; x <= K; x++) {
			for(int y = 0; y <= K; y++) {
				if((S - x - y >= 0 )&&(S - x - y <= K)) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
double pi = 3.14159265359;
int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if(x >= a * a * b / 2)
    {
        ans = atan(2*(a*a*b-x) / (a*a*a)) * 180 / pi;
    }
    else
    {
        double z = 2 * x / (b * a);
        ans = atan(b/z) * 180 / pi;
    }
    cout << fixed << setprecision(10) << ans << endl;
}



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

int main() 
{ 
string s,t;
cin>>s>>t;

int n = s.length(), m = t.length(); 
int ans = INT_MAX; 


for (int i = 0; i < n - m + 1; i++) { 
        int mini = 0; 

        for (int j = 0; j < m; j++) { 
            if (t[j] != s[i + j]) { 
                mini++; 
            } 
        } 
  
        ans = min(mini, ans); 
    } 
   
    cout<<ans; 

} 


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

map<LL,int> prime_factor(LL n){
  map<LL,int> ret;
  for(LL i = 2; i * i <= n; i++){
    while(n % i == 0){
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(){
    LL N;cin >> N;
    map<LL,int> memo;
    rep(i,N)memo[i+1] = 0;  // map初期化
    map<LL,int> tmp;
    rep(i,N){
        if(i == 0)continue;
        tmp = prime_factor(i+1);
        for(auto itr = tmp.begin();itr != tmp.end();itr++){
            LL a = itr->F;
            int b = itr->S;
            memo[a] += b;
        }
    }
    LL ans = 1;
    for(auto itr = memo.begin();itr != memo.end();itr++){
        int c = itr->S;
        ans *= (c+1);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n;
  cin >> n;
  ll ans = n;
  for (ll i = 1; i * i <= n; i++) {
    ll a = n / i;
    if (i * a != n) continue;
    ans = min(ans, i-1+a-1);
  }
  cout << ans << endl;
}

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

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

int main(){
	long long n,a,b;
	cin>>n>>a>>b;
	if(a>b)return 0*printf("0");
	if(n==1)return 0*printf("%d",a==b?1:0);
	cout<<(n-2)*(b-a)+1;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int x[] = new int[m];
    long s[] = new long[n];
    int ng[] = new int[n];
    int ans = 0;
    int t = 0;
    
    for (int i=0; i<m; i++){
      x[i] = Integer.parseInt(sc.next());
    }
    
    int j = 0;
    for(int i=0; i<n; i++){
      ng[i] = 0;
      if(m > 0 &&i == x[j]-1){
        ng[i] = 1;
        if(j != m-1){ 
          j++;
        }
      }
    }
    
    if(n==1){
      System.out.println("1");
      return;
    }
    
    if(n==2){
      if(m==1){
        System.out.println("1");
        return;
      } else {
      	System.out.println("2");
        return;
      }
    }
    
    if(ng[0]==1){
	  s[0] = 0;
      if(ng[1] == 1) {
        s[1] = 0;
      } else {
        s[1] = 1;
      }
    } else {
      s[0] = 1;
      if(ng[1] == 1){
        s[1] = 0;
      } else {
        s[1] = 2;
      }
    }
    
    for(int i=2; i<n; i++){
      if(ng[i] == 0){
        s[i] = (s[i-1]%1000000007 + s[i-2]%1000000007)%1000000007;
      } else {
        s[i] = 0;
      }
    }
    
    System.out.println(s[n-1]%1000000007);
  }
}


Measured memory_bytes: 48716
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define pp pair<ll, ll>
#define mp make_pair
#define PI acos(-1.0)
#define all(v) v.begin(), v.end()
#define pb push_back
#define foo(n) for (int i = 0; i <n; i++)
#define FREV(i, a, b) for (i = a; i >= b; i--)
#define READ(a, i, n) \
	FOR(i, 0, n) { a[i] = read_ll(); }
#define DEBUG(x) cerr << "In file " << __FILE__ << " at line " << __LINE__ << " :: " << #x << " = " << x << endl
#define S(n) scanf("%lld", &n)
#define INF 1e18
#define MOD 1000000007

// #ifndef ONLINE_JUDGE
// #define gc getchar
// #define pc putchar
// #else
// #define gc getchar_unlocked
// #define pc putchar_unlocked
// #endif




using namespace std;
int main()
{

	int c;
	cin>>c;
	if(c>=30)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

// D, R, U, L
const int DY[] = {-1,0,1,0};
const int DX[] = {0,1,0,-1};

const string DIR = "DRUL";

struct P {
    int x, y, hist, dist;
};

bool visited[2099][2099], used[2099][2099];
int SX, SY, TX, TY, C = 1050, history[2099][2099];

string mini(int sx, int sy, int tx, int ty) {
    MEM(visited, 0);
    MEM(history, -1);

    used[sx][sy] = used[tx][ty] = 0;

    queue<P> Q;
    Q.push(P{sx, sy, 0, 0});

    while(sz(Q)) {
        P p = Q.front(); Q.pop();
        if(visited[p.x][p.y])continue;
        visited[p.x][p.y] = 1;
        history[p.x][p.y] = p.hist;

        if(p.x == tx&&p.y == ty)break;

        rep(i, 4) {
            int nx = p.x + DX[i], ny = p.y + DY[i];
            if(nx >= 0 && ny >= 0 && nx < 2099 && ny < 2099 && !visited[nx][ny] && !used[nx][ny]) {
                Q.push(P{nx,ny,i,p.dist + 1});
            }
        }
    }

    string res;

    int x = tx, y = ty;
    while(x != sx || y != sy) {
        used[x][y] = 1;
        int h = history[x][y];
        res += DIR[h];
        int revH = (h + 2) % 4;
        x += DX[revH];
        y += DY[revH];
    }
    reverse(all(res));

    return res;
}

void solve() {
    SX += C; SY += C; TX += C; TY += C;
    string ans;

    ans += mini(SX, SY, TX, TY);
    ans += mini(TX, TY, SX, SY);
    ans += mini(SX, SY, TX, TY);
    ans += mini(TX, TY, SX, SY);
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> SX >> SY >> TX >> TY) {
        MEM(used, 0);
        solve();
    }
}


Measured memory_bytes: 26240
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	string s;
	cin>>s;
	int n=sz(s);
	stack<char>g;
	g.push(s[0]);
	rep(i,1,n){
		if(g.empty()||s[i]=='S')g.push(s[i]);
		else if(g.top()=='S')g.pop();
		else g.push(s[i]);
	}
	cout<<sz(g);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,sum;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c&&a%2==0)
        printf("-1\n");
    else
    {
        sum=0;
        while(a%2==0&&b%2==0&&c%2==0)
        {
            sum++;
            int a1=a;
            int b1=b;
            int c1=c;
            a=(b1+c1)/2;
            b=(a1+c1)/2;
            c=(a1+b1)/2;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BPickingUp {
public:
        int N;
        pii P[55];
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N;
    map<pii, int> M;
    _for(i,N){
        cin >> P[i].first >> P[i].second;
    }
    sort(P, P+N);
    _for(i,N)rep(j,i+1,N)M[{P[i].first - P[j].first, P[i].second - P[j].second}]++;
    int mx = 0;
    for(auto p : M)mx = max(mx, p.second);
    cout << N - mx << endl;
}
};


#undef int
int main() {
	BPickingUp solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c-max({a,b,c});
	return 0;
}


Measured memory_bytes: 256
while True:
    cnt = 0
    scores = list(map(int, input().split()))
    m = scores[0]
    f = scores[1]
    r = scores[2]
    if m == f == r == -1:
        break
    else:
        if (m == -1) or (f == -1):
            print("F")
        elif m + f >= 80:
            print("A")
        elif 65 <= (m + f) < 80:
            print("B")
        elif 50 <= (m + f) < 65:
            print("C")
        elif 30 <= (m + f) < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        else:
            print("F")





Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define int long long
#define endl '\n'
#define pi 3.14159265
#define double long double
ll p(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b%2!=0)
            res*=a;
        a*=a;
        b/=2;
    }
    return res;
}
int32_t main()
{           
    IOS;
    ll a,b,k;
    cin>>a>>b>>k;
    ll  count=0;
    for(ll i=1000;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
            count++;
        //trace2(i,count);
        if(count==k)
        {
            cout<<i;
            return 0;
        }
    }
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[345678], cnt[345678], visit[345678];
const int INF = 10000000000000;
signed main() {
	int n, m, q; cin >> n >> m >> q;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	for (int h = 0; h < m; h++) {
		cin >> cnt[h];
	}
	for (int h = 0; h < q; h++) {
		cin >> visit[h];
		int b = lower_bound(test, test + n, visit[h]) - test - 1;
		int c = lower_bound(test, test + n, visit[h]) - test;
		if (test[c] == 0) { b = abs(test[b] - visit[h]); c = INF; }
		else if (test[b] == 0) { b = INF; c = abs(test[c] - visit[h]); }
		else { b = abs(test[b] - visit[h]); c = abs(test[c] - visit[h]); }
		int e = lower_bound(cnt, cnt + m, visit[h]) - cnt - 1;
		int f = lower_bound(cnt, cnt + m, visit[h]) - cnt;
		if (cnt[f] == 0) { e = abs(cnt[e] - visit[h]); f = INF; }
		else if (cnt[e] == 0) { e = INF; f = abs(cnt[f] - visit[h]); }
		else { e = abs(cnt[e] - visit[h]); f = abs(cnt[f] - visit[h]); }
		int a = min(min(b, f) + min(b, f) + max(b, f), min(c, e) + min(c, e) + max(c, e));
		int d = min(max(b, e), max(c, f));
		cout << min(a, d) << endl;
	}

}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

int main()
{
    string s;
    cin >> s;

    if(s.size()==2){
        cout << s << endl;
    }else{
        REP(i,s.size()){
            cout << s[s.size()-i-1];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define P(x) cout<<x<<endl  //変数xを改行付きで出力
#define INF 1000000007  //最大値兼MOD
typedef long long ll;
using namespace std;
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; }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
./a.exe
*/
int a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
int temp = min(x,y);
int ans = temp*min(a+b,c*2);
if(x < y){
	ans += abs(x-y) * min(b,c * 2);
}
else{
	ans += abs(x-y) * min(a,c*2);
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n, m int
  fmt.Scan(&n, &m)
  ks := make([]int, n)
  ass := make([][]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&ks[i])
    ass[i] = make([]int, ks[i])
    for j := 0; j < ks[i]; j++ {
      fmt.Scan(&ass[i][j])
    }
  }
  
  counter := make(map[int]int)
  for _, as := range ass {
    for _, a := range as {
   	  counter[a]++ 
    }
  }
  
  result := 0
  for _, num := range counter {
    if num == n {
      result++
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 640
n,m = $stdin.gets.split.map(&:to_i)
a = $stdin.gets.split.map(&:to_i)
a.sort!
ary = []
m.times do |i|
  ary[i]=$stdin.gets.split.map(&:to_i)
end
ary.sort!{|a,b| a[1] <=> b[1]}.reverse!

result = 0
j=0
n.times do |i|
  if !ary[j].nil?&&a[i]<ary[j][1]
    a[i]=ary[j][1]
    ary[j][0]-=1
    if ary[j][0]==0
      j += 1
    end
  end

  result += a[i]
end

puts result

Measured memory_bytes: 18944
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  std::string s,t;
  std::cin>>s>>t;

  i64 ans=1e9;

  i64 n=s.size();
  i64 m=t.size();

  rep(i,0,n-m+1){
    i64 val=0;
    rep(j,0,m){
      if(t[j]!=s[i+j])val++;
    }

    chmin(ans,val);
  }

  std::cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 3644
import math
a, b, h, m = map(int, input().split())
def ret(hour, minute):
    ans = abs((hour * 30 + minute * 0.5) - (minute * 6))
    x = min(360-ans,ans)
    return (x * math.pi) / 180.0

c = ret(h, m)
print(math.sqrt(a ** 2 + b ** 2 - (2 * a * b * (math.cos(c)))))

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

using namespace std;

long long int modinv(long long int a, long long int m) {
    long long int b = m, u = 1, v = 0;
    while (b) {
        long long int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
  long long max = 1000000000 + 7;
  int x,y;
  cin>>x>>y;

  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }

  long long int N = (x+y)/3;
  long long int M = min(y-N,x-N);
  if(M<0){
    cout<<0<<endl;
    return 0;
  }

  long long int result = 1;
  if(M==0){
    cout<<1<<endl;
    return 0;
  }
  for(long long int i=1;i<=M;i++){
    result *= (N-i+1);
    long long int u = modinv(i,max);
    result %=max;
    result = (result * (u % max))%max;
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    B = [A[0]]
    prev = A[0]
    for a in A:
        if prev != a:
            B.append(a)
            prev = a
    count = 1
    up = False
    down = False
    for i in range(1, len(B)):
        if not up and not down:
            if B[i-1] < B[i]:
                up = True
            else:
                down = True
        elif up and B[i-1] > B[i]:
            up = False
            count += 1
        elif down and B[i-1] < B[i]:
            down = False
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 14480
n,m=map(int,input().split(' '))
piece=[0]*m
for i in range(m):
    piece[i]=tuple(map(int,input().split(' ')))

node=[0]+[float('inf')]*(n-1)

for v in range(n-1):
    for e in range(m):
        a,b,c=piece[e]
        if node[b-1] > node[a-1]-c:
            node[b-1] = node[a-1]-c
ans=node[n-1]
for e in range(m):
    a,b,c=piece[e]
    if node[b-1] > node[a-1] - c:
        node[b-1] = node[a-1] -c

if ans != node[n-1]:
    print('inf')
else:
    print(-ans)

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

typedef long long lli;
typedef vector<vector<int> > Graph;

const int MAXN = 50;

int N;
map<string,int> id;
Graph g;
int B[MAXN];

lli adj[MAXN];
int sum[MAXN];
int ans;

inline int getId(const string &s) {
  if(!id.count(s)) id[s] = id.size()-1;
  return id[s];
}

inline void addEdge(int src, int dst, Graph &g) {
  g[src].push_back(dst);
}

void rec(int k, lli bit, int now) {
  ans = max(ans, now);
  if(now + sum[k] <= ans) return;
  if(k == N) return;
  rec(k+1, bit, now);
  if(!(bit & (1LL<<k))) rec(k+1, bit|adj[k], now+B[k]);
}

int main() {
  while(cin >> N && N) {
    id.clear();
    g = Graph(N);
    for(int i = 0; i < N; ++i) {
      string src;
      int C;
      cin >> src;
      cin >> B[getId(src)] >> C;
      while(C--) {
        string dst;
        cin >> dst;
        addEdge(getId(src), getId(dst), g);
      }
    }

    for(int v = 0; v < N; ++v) {
      adj[v] = 0;//1LL<<v;
      for(int i = 0; i < g[v].size(); ++i) {
        int nv = g[v][i];
        adj[v] |= 1LL<<nv;
      }
    }

    sum[N] = 0;
    for(int v = N-1; v >= 0; --v) sum[v] = sum[v+1] + B[v];

    ans = 0;
    rec(1, adj[0], B[0]);
    cout << ans << endl;
  }
  return 0;
}

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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<double> p(n);
    cin >> p;
    vector<vector<double>> dp(n + 1, vector<double> (n + 1));
    // dp[i][j] -> making j heads using i coins
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i][j] = (j == 0 ? 0 : (dp[i-1][j-1])*(p[i-1])) + (dp[i - 1][j])*(1 - p[i -1]);
        }
    }
    double ans = 0;
    for(int i = 0; i <= n; ++i){
        if(i > n - i){
            ans += dp[n][i];
        }
    }

    cout << fixed << setprecision(10) << ans ;
 }

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

long long c[10][10];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        int e = i;
        int d = i % 10;
        while (e > 9) { e /= 10; }
        c[e][d]++;
    }
    long long ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            if (i == j) {
                ans += c[i][j] * c[j][i];
            } else {
                ans += c[i][j] * c[j][i] * 2;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long[] input0 = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long N = input0[0];
            long x = input0[1];
            long[] a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long count =0;
            if(a[0]>x){
                count += a[0]-x;
                a[0] = x;
            }
            for(var i=0;i<N-1;i++){
                if(a[i]+a[i+1]>x){
                    count += a[i+1] + a[i] -x;
                    a[i+1] = x-a[i]; 
                }
            }
            Console.WriteLine(count);
        }
    } 
}

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

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

  int n;
  cin >> n;

  vector<ll> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> v.at(i);
    if (v.at(i) == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = v.at(0);
  ll limit = 1000000000000000000;

  for (ll i = 1; i < n; i++)
  {
    if ((limit + ans -1) / ans < v.at(i))
    {
      cout << -1 << endl;
      return 0;
    }
    ans = ans * v.at(i);
  }
  if (ans > limit)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3988
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
loop_flag = True
while loop_flag:
    loop_flag = False

    for i in range(h):
        f = True
        for j in range(w):
            if a[i][j] != ".":
                f = False
                break
                print(i, "breaked")
        if f:
            loop_flag = True
            a.pop(i)
            h -= 1
            break
            
    #print(a, h, w)

    for j in range(w):
        f = True 
        for i in range(h):
            # print(i, j, a[i][j])
            if a[i][j] != ".":
                f = False
                break
        if f:
            loop_flag = True
            for i in range(h):
                a[i].pop(j)
            w -= 1
            break
        
for i in range(h):
    print("".join(a[i]))



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

using namespace std;

int maxi, N, dp[200009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
{
    int x;
    scanf ("%d", &x);
    dp[x] = dp[x - 1] + 1;
    if (dp[x] > maxi)
        maxi = dp[x];
}
printf ("%d\n", N - maxi);

return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main() {
  string s;
  cin >> s;
  bool ans = true;
  rep(i,s.size()){
    if(i%2 == 0 && s.at(i) == 'L' || i%2 != 0 && s.at(i) == 'R') ans = false;
  }
  puts(ans ? "Yes":"No");
  }


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

int main() {
    int n, a;
    cin >> n;
    set<int> s;
    for (auto i = 0; i < n; i++) {
        cin >> a;
        s.insert(a);
    }
    cout << ((s.size() % 2 == 0) ? s.size() - 1 : s.size())
         << endl;
    return 0;
}

Measured memory_bytes: 8168