akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

typedef struct DICE{
    int s[6];
}dice;

dice dice_rotate(dice d, char rotate){
    int swap;
    if(rotate == 'E'){
        swap = d.s[2];
        d.s[2] = d.s[0];
        d.s[0] = d.s[3];
        d.s[3] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'N'){
        swap = d.s[4];
        d.s[4] = d.s[0];
        d.s[0] = d.s[1];
        d.s[1] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'S'){
        swap = d.s[1];
        d.s[1] = d.s[0];
        d.s[0] = d.s[4];
        d.s[4] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'W'){
        swap = d.s[3];
        d.s[3] = d.s[0];
        d.s[0] = d.s[2];
        d.s[2] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'R'){
        swap = d.s[1];
        d.s[1] = d.s[2];
        d.s[2] = d.s[4];
        d.s[4] = d.s[3];
        d.s[3] = swap;
    }
    return d;
}

dice dice_jig(dice d, int i){
    if(i%2==0){
        d = dice_rotate(d, 'S');
    }else if(i%2==1){
        d = dice_rotate(d, 'E');
    }
    return d;
}

bool same_judge(dice d1, dice d2){
    int i;
    bool judge=true;
    for(i=0;i<6;i++){
        if(d1.s[i] != d2.s[i]) judge = false;
    }
    return judge;
}

bool two_dice_judge(dice d1, dice d2){
    int i,j;
    bool judge=false;

    for(i=0;i<6;i++){
        if(d1.s[0] == d2.s[0]) break;
        d2 = dice_jig(d2, i);
    }

    for(i=0;i<6;i++){
        for(j=0;j<4;j++){
            if(d1.s[1] == d2.s[1] && d1.s[2] == d2.s[2] && d1.s[4] == d2.s[4] && d1.s[3] == d2.s[3]) break;
            d2 = dice_rotate(d2, 'R');
        }
        if(same_judge(d1,d2)){
            judge = true;
            break;
        }
        d2 = dice_jig(d2, i);
    }

    return judge;
}

int main(){
    int n,i,j;
    bool judge;

    cin >> n;
    dice d[n];

    for(i=0;i<n;i++){
        for(j=0;j<6;j++) cin >> d[i].s[j];
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            judge = two_dice_judge(d[i], d[j]);
            if(judge) break;
        }
        if(judge) break;
    }

    if(!judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		while (sc.hasNext()) {
			int n = sc.nextInt();
			int res = 0;
			for (int i1 = 0; i1 < 10; i1++)
				for (int i2 = 0; i2 < 10; i2++)
					for (int i3 = 0; i3 < 10; i3++)
						for (int i4 = 0; i4 < 10; i4++)
							if (i1+i2+i3+i4 == n)
								res++;
			out.println(res);
				
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 18864
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 1000005, mod = 1000000007;
int n;
ll f[N], k;
int main()
{
	scanf ("%d", &n);
	f[0] = 1, f[1] = n;
	Rep(i, 2, n) {
		if (i >= 3) k += f[i - 3];
		f[i] = (f[i - 1] + (ll)(n - 1) * (n - 1) + (n - i + 1) + k) % mod;
	}
	printf("%lld\n", f[n]);

	return 0;
}

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

int main(){
	int N,D;
	cin >> N >> D;
	int X[N][D];
	for(int i(0);i<N;++i){
		for(int j(0);j<D;++j){
			cin >> X[i][j];
		}
	}
	int ans(0);
	for(int i(0);i<N-1;++i){
		for(int j(i+1);j<N;++j){
			ll sum(0);
			for(int k(0);k<D;++k){
				sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			}
			float dist = sqrt(sum);
			if(ceil(dist) == floor(dist))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  char b;
  cin >> b;
  
  if(b == 'a' || b == 'b' || b == 'c' || b == 'd' || b == 'e' || b == 'f' || b == 'g' || b == 'h' || b == 'i' || b == 'j' || b == 'k' || b == 'l' || b == 'm' || b == 'n' || b == 'o' || b == 'p' || b == 'q' || b == 'r' || b == 's' || b == 't' || b == 'u' || b == 'v' || b == 'w' || b == 'x' || b == 'y' || b == 'z')
	cout << 'a' << endl;
  else
    cout << 'A' << endl;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	int m, k;
	scanf("%d %d", &m, &k);
	int n = 1;
	int i;
	for (i = 0; i < m; i++)
		n *= 2;
	if (k >= n)
	{
		printf("-1\n");
		return 0;
	}
	if (m == 1)
	{
		if (k == 1)
		{
			printf("-1\n");
			return 0;
		}
		else
		{
			printf("0 0 1 1\n");
			return 0;
		}
	}
	for (i = n - 1; i >= 0; i--)
		if (i != k)
			printf("%d ", i);
	printf("%d ", k);
	for (i = 0; i < n; i++)
		if (i != k)
			printf("%d ", i);
	printf("%d\n", k);
	return 0;
}

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


int main() {
  int i;
  cin >> i;
  int64_t sum = 0;
  
  for (int j = 1; j < i+1; j++){
    if (j % 3 != 0 && j % 5 != 0){
      sum += j;
    }
  }
  
  cout << sum << endl;
}




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

dist = []
for i in range(n-1):
    dist.append(a[i+1] - a[i])
dist.append(k - a[n-1] + a[0])

sorted_dist = sorted(dist)
print(sum(sorted_dist[:n-1]))

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll find_power(ll x){
	ll res = 1;
	while(1){
		if(res>x) break;
		res*=2;
	}
	return res - x;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(all(a));
	reverse(all(a));

	map<ll,ll> s;
	for(int i = 0; i < n; i++){
		s[a[i]]++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(s.find(a[i]) == s.end()) continue;
		ll x = find_power(a[i]);
		if(s.find(x) != s.end()){
			if(a[i] == x){
				if(s[x]>=2){
					ans++;
					s[x] -= 2;
				}
				if(s[a[i]] == 0) s.erase(a[i]);
			}else{
				ans++;
				s[a[i]]--;
				s[x]--;
				if(s[a[i]] == 0) s.erase(a[i]);
				if(s[x] == 0) s.erase(x);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int N;
	
	cin >> N;
	vector<int>a(N);
	int top = 0;
	rep(i, N) {
		cin >> a[i];
		a[i] = a[i] / 400;
		if (a[i] >= 8)a[i] = 8;
		if (a[i] == 8)top++;
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	int minN, maxN;
	if (a[0] == 8) {
		maxN = top;
		minN = 1;
	}
	else if (top != 0) {
		maxN = a.size() - 1 + top;
		minN = a.size() - 1;
	}
	else {
		maxN = a.size();
		minN = a.size();
	}
	cout << minN <<" "<< maxN << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
comp :: [Int] -> [Int] -> Ordering
comp (x:xs) (y:ys) = if x < y then LT else if x > y then GT else EQ
check :: [Int] -> [[Int]] -> Int
check s x = if null x /= True then check (intersect s (head x)) (tail x) else length s 
main :: IO()
main=do
 t<-map read.words<$>getLine
 a<-map (map read.words)<$>replicateM (head t) getLine
 let s=sortBy comp a
 print$check (tail (head s)) (map tail(tail s))

Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>

int partition (int A[], int p, int r) {
    int x, t, i, j;

    x = A[r];
    i = p-1;
    for (j = p ; j < r ; j ++ ) {
        if (A[j] <= x) {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }

    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    return i+1;
}

int main (void) {
    int n, i , q , A[100010];

    scanf("%d", &n);

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

    q = partition(A, 0, n-1);

    for (i = 0 ; i < n ; i++) {
        if (i) printf(" ");

        if(i == q) printf("[");
        printf("%d", A[i]);
        if(i == q) printf("]");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL ar[100];
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>a;
        p=0;
        q=0;
        for(i=0; a[i]; i++)
        {
            if(a[i]=='W')
            {
                p++;
            }
            else
            {
                q++;
            }
        }
        k=0;
        if(p==q)
        {
            for(i=0; i<n; i++)
            {
                if(i<n/2 && a[i]=='W')
                {
                    k++;
                }
            }
        }
        else if(p>q)
        {
            for(i=0; i<q; i++)
            {
                if(a[i]=='W')
                {
                    k++;
                }
            }
        }
        else
        {
            for(i=0; i<p; i++)
            {
                if(a[i]=='W')
                {
                    k++;
                }
            }
            for(i=p; i<q; i++)
            {
                if(a[i]=='W')
                {
                    k++;
                }
            }
        }
        cout<<k<<endl;

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3764
package main

import "fmt"

func floor(x float64) int { return int(x) }

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= 50000; i++ {
		fi := float64(i)
		if floor(fi*1.08) == n {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(":(")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int d; cin>>d;
  ll g; cin>>g;
  vector<int> p(d);
  vector<int> c(d);
  rep(i,d) cin>>p[i]>>c[i];

  int ans=INF;
  for(int bit=0;bit<(1<<d);bit++){
    ll sum=0;
    int count=0;
    rep(i,d){
      if(((1<<i)&bit)!=0){
        sum+=(i+1)*100*p[i]+c[i];
        count+=p[i];
      }
    }
    if(sum>=g) ans=min(ans,count);
    else{
      bool f=0;
      rep(i,d){
        if(((1<<d-i-1)&bit)==0){
          rep(j,p[d-i-1]){
            sum+=(d-i)*100;
            count++;
            if(sum>=g){
              ans=min(ans,count);
              f=1;
              break;
            }
          }
        }
        if(f) break;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	cin >> N >> Q;

	// t = x - D_i と x = X_j (S_j <= t <= T_j) が交わるD_iの範囲を計算しておく
	vector <pair<pair<int, int>, int>> stx(N);
	for (int i = 0; i < N; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		stx[i] = { { max(0, s - x), t - x }, x };
	}
	sort(stx.begin(), stx.end());

	set<pair<int,int>> st;
	vector<int> ans(Q, INF);
	auto first = stx.begin();
	auto last = stx.end();
	for (int i = 0; i < Q; i++) {

		int d;
		cin >> d;

		// add
		last = upper_bound(stx.begin(), stx.end(), make_pair(make_pair(d, INF), INF));
		for (auto itr = first; itr != last; itr++) st.emplace(itr->second, itr->first.second);
		first = last;
		DMP(first - stx.begin());

		DMP(st);
		//erase
		vector<pair<int, int>> memo;
		for (const auto &e : st) {
			if (d < e.second) {
				chmin(ans[i], e.first);
				break;
			}
			else memo.emplace_back(e);
		}
		DMP(memo);
		for (const auto e : memo) st.erase(e);
		DMP(st);

	}

	for (const auto &e : ans) cout << (e == INF ? - 1 : e) << "\n";

	return 0;
}

Measured memory_bytes: 15000
#include<stdio.h>
#include<vector>
using namespace std;
const int N=100010;
vector<int>graph[N];
int dep[N],p[20][N];
void go(int now){
	for(int i=0;i<graph[now].size();i++){
		dep[graph[now][i]]=dep[now]+1;
		p[0][graph[now][i]]=now;
		go(graph[now][i]);
	}
	return;
}
int LCA(int l,int r){
	if(dep[l]<dep[r])swap(l,r);
	for(int i=19;i>=0;i--){
		if(dep[p[i][l]]>=dep[r]){
			l=p[i][l];
		}
	}
	for(int i=19;i>=0;i--){
		if(p[i][l]!=p[i][r]){
			l=p[i][l];
			r=p[i][r];
		}
	}
	if(l!=r)return p[0][l];
	else return l;
}
int main(){
	int n,k,temp,q,l,r;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&k);
		for (int j=0;j<k;j++){
			scanf("%d",&temp);
			graph[i].push_back(temp);
		}
	}
	go(0);
	for(int i=1;i<20;i++){
		for(int j=0;j<n;j++){
			p[i][j]=p[i-1][p[i-1][j]];
		}
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d%d",&l,&r);
		printf("%d\n",LCA(l,r));
	}	
}


Measured memory_bytes: 20960
/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        long n = Long.parseLong(br.readLine());

        HashMap<Long, Long> dp = new HashMap<>();

        dp.put(1l, 1l);

        long ans = getAns(dp, n);

        pw.println(ans);

        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }

    static long getAns(HashMap<Long, Long> dp, long n) {
        if(dp.containsKey(n)) {
            return dp.get(n);
        }
        long ans = getAns(dp, n/2);
        ans += ans;
        ans++;
        return ans;
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        std::cout << T << std::endl;
    }else{
        std::cout << F << std::endl;
    }
}

int judge(ull left, ull right){
    if(left < right){
        return 1;
    }else if(left > right){
        return -1;
    }else{
        return 0;
    }
}
int main(){
    int n; std::cin >> n;
    std::vector<ull> a;
    ull temp;
    int ans = 1;
    int i = 0;
    int mode = 0;
    REP(i, n){
        std::cin >> temp;
        a.push_back(temp);
    }

    while(i < n - 2){
        if(judge(a[i], a[i + 1]) != 0){
            mode = judge(a[i], a[i + 1]);
        }
        if(mode == -1 && judge(a[i + 1], a[i + 2]) == 1){
            ans++;
            i++;
            mode = 0;
        }else if(mode == 1 && judge(a[i + 1], a[i + 2]) == -1){
            ans++;
            i++;
            mode = 0;
        }
        i++;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
typedef pair<int, int> P;

int main(){
    string s; cin >> s;
    bool flag = true;
    rep(i, s.size()){
        if(i%2==1){
            if(s[i]=='L'||s[i]=='U'||s[i]=='D');
            else flag=false;
        }
        if(i%2!=1){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D');
            else flag = false;
        }
    }
    if(flag==true) out("Yes");
    else out("No");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#define MAX 2000001
#define VMAX 10000

int A[MAX],B[MAX];
int C[VMAX+1];

int main(void){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i+1]);
		C[A[i+1]]++;
	}
	for(int i=1;i<=VMAX;i++){
		C[i]=C[i]+C[i-1];
	}
	for(int j=1;j<=n;j++){
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	for(int i=1;i<=n;i++){
		printf("%d%c",B[i],i==n?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 16692
#include <stdio.h>

int main(){
	int j,s_length = 0;
	char s[101],p[101];
	scanf("%s",s);
	scanf("%s",p);

	for(int i = 0; s[i] != '\0';i++) s_length++;

	for(int left = 0;s[left] != '\0';left++){
		for(j = 0;p[j] != '\0' && p[j] == s[(left+j)%s_length];j++);
		if(p[j] == '\0'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 2692
N = int(input())
S = input()

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append("{}{}{}".format(i, j, k))

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)


Measured memory_bytes: 40940
import sys
x, y= map(int, input().split())
a=[300000,200000,100000]

ans = 0
if x==1 and y==1:
    print(1000000)
    sys.exit()
if x<=3:
    ans += a[x-1]
if y<=3:
    ans += a[y-1]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<vector>
#include<climits>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
  int n, ans = 0;
  cin>>n;
  for(int i=0; i<n; i++) {
    int s;
    cin>>s;
    bool flag = false;
    for(int x=1; x*x<=s && flag==false; x++) {
      if((s-x)%(2*x+1) == 0) {
	flag = true;
      }
    }
    if(flag == false) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

pair<int,int> to(string a){
	if(a == "AB") return make_pair(0,1);
	if(a == "BC") return make_pair(1,2);
	if(a == "AC") return make_pair(0,2);
}

string tos(int x){
	return {(char)('A'+x), '\n'};
}

string ans = "Yes\n";
void step(string s, ll *abc){
	auto [i,j] = to(s);
	if(abc[i] < abc[j]){
		abc[i]++;
		abc[j]--;
		ans += tos(i);
	}else{
		abc[j]++;
		abc[i]--;
		ans += tos(j);
	}
	if(abc[i] < 0 || abc[j] < 0){
		cout << "No" << endl;
		exit(0);
	}
}

pair<int,int> con(pair<int,int> x, pair<int,int> y){
	if(x.fs == y.fs || x.fs == y.sc) return x;
	else return make_pair(x.sc, x.fs);
}

bool operator==(pair<int,int> x, pair<int,int> y){
	return (x.fs == y.fs) && (x.sc == y.sc);
}


int main(void){
	int n;
	ll a,b,c;
	cin >> n >> a >> b >> c;
	ll abc[3] = {a,b,c};
	ll d = a + b + c;
	if(d == 0){
		cout << "No\n";
	}else if(d != 2){
		string s;
		Rep(n){
			cin >> s;
			step(s, abc);
		}
		cout << ans;
	}else{
		vector<pair<int,int>> cmd;
		Rep(n){
			string s;
			cin >> s;
			cmd.push_back(to(s));
		}
		rep(i, n-1){
			auto [x,y] = cmd[i];
			if(abc[x] < abc[y]){
				abc[x]++; abc[y]--;
				ans += tos(x);
			}else if(abc[x] > abc[y]){
				abc[y]++; abc[x]--;
				ans += tos(y);
			}else{
				auto [x,y] =  con(cmd[i], cmd[i+1]);
				abc[x]++; abc[y]--;
				ans += tos(x);
			}
			if(abc[x] < 0 || abc[y] < 0){
				cout << "No\n";
				return 0;
			}
		}
		cout << ans;
		auto [x,y] = cmd[n-1];
		if(abc[x]) cout << tos(y);
		else cout << tos(x);
	}
}

Measured memory_bytes: 4408
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
Node * find(Node *u, int k) {
	while (u != NIL && k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL) root = z;
	else {
		if (z->key < y->key)y->left = z;
		else y->right = z;
	}
}
void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL)printf("yes\n");
			else printf("no\n");
		}
		else if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 22064
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
  for j in range(N-i-2):        
    ans+=min(N-i-j-2,N-bisect.bisect_left(L,L[-j-1]-L[i]+1)-j-1)
print(ans)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[110][100010],sum[100010];
const int MAXN=1e9+7;
int n,k,a[100010];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		dp[i][0]=1;
	}
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k+1;++j){
			sum[j]=sum[j-1]+dp[i-1][j-1];
			sum[j]%=MAXN;
		}
		for(int j=1;j<=k;++j){
			dp[i][j]=sum[j+1]-sum[max(0,j-a[i])]+MAXN;
			dp[i][j]%=MAXN;
		}
	}
	/*for(int i=1;i<=n;++i){
		for(int j=0;j<=k;++j){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	cout<<dp[n][k]%MAXN<<endl;
	return 0;
}


Measured memory_bytes: 81024
import math
a, b, x = map(int, input().split())

# 水が多いか少ないかで作図が変わってくる

# 半分以上水が入っている場合
if x >= a**2 * b / 2:
    # 限界の時、a**2 * b - 0.5 * a**2 * tanθ * a = x
    tan = 2 * (a**2 * b - x) / a**3
    ans = math.degrees(math.atan(tan))
    print(ans)

# 半分以下の場合
else:
    # 限界の時、0.5 * b**2 * tan(90 - θ) * a = x
    # tan(90 - θ) = 1/tanθ
    tan = (a * b**2) / (2 * x)
    ans = math.degrees(math.atan(tan))
    print(ans)


Measured memory_bytes: 9208
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String S = in.readLine();
		String T = in.readLine();
		int count = 0;
		for (int i = 0; i < S.length(); ++i) {
			if (S.charAt(i) == T.charAt(i)) {
				++count;
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 22612
# NG 15-

N = int(input())

R = []
for i in range(N):
    x, y = list(map(int, input().split()))
    R.append((x, y))

B = []
for i in range(N):
    x, y = list(map(int, input().split()))
    B.append((x, y))

R.sort(key=lambda a:a[1], reverse=True)
B.sort(key=lambda a:a[0], reverse=False)

ans = 0
for pos in B:
    x, y = pos
    for pos2 in R:
        x2, y2 = pos2
        if x2<x and y2<y:
            R.remove(pos2)
            ans += 1
            break

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int N= sc.nextInt();
        int[] arr= new int[N];
        for (int x=0; x<N; x++){
            arr[x]= sc.nextInt();
        }
        int[] dp= new int[N];
        dp[1]= Math.abs(arr[0]-arr[1]);
        for (int x=2; x<N; x++){
            int val= arr[x];
            int last1= arr[x-1];
            int last2= arr[x-2];
            dp[x]= Math.min(dp[x-1] + Math.abs(last1-val), dp[x-2]+ Math.abs(last2-val));
        }
        System.out.println(dp[N-1]);
    }
}


Measured memory_bytes: 50628
S = str(input())
T = str(input())
mini = []

if len(S) != len(T):
    for i in range(len(S) - len(T)):
        count = 0
        for j in range(len(T)):
            if T[j] == S[j+i]:        
                count+=1
        mini.append(len(T) - count)
    print(min(mini))
else:
    count = 0
    for i in range(len(S)):
       if T[i] == S[i]:
           count+=1
    print(len(T) - count)
            

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    unsigned int n[5];
    cin >> n[0] >> n[1];
    
    // AND
    n[2] = n[0] & n[1];
    // OR
    n[3] = n[0] | n[1];
    // XOR
    n[4] = n[0] ^ n[1];
    
    for(int i = 2;i < 5;++i){
        cout << bitset<32>(n[i]) << endl;
    }
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e3 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    string str ; cin >> str;  
    int x = 0 ; 
    for(char c : str)  x += c - '0' ;
    if(x%9 == 0) cout << "Yes" ; 
    else cout << "No" ;
}


Measured memory_bytes: 3748
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*全然わからんから答え見てしまった*/

int top, S[1000];

/*topを加算してその位置に値を挿入*/
void push(int x)
{
	S[++top] = x;
}

/*topの値を取り出す*/
int pop(void)
{
	top--;
	return S[top + 1];
}

int main(void)
{
	int a, b;
	top = 0;
	char s[100];

	while ( scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}else if( s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}else if ( s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}else {
			push(atoi (s));
		}
	}
	printf("%d\n", pop());

	return 0;
}



Measured memory_bytes: 2096
N ,K = map(int, input().split())
MOD = 10**9 + 7
ans = 0

S = [0]*(2*10**5+1)
S[1] = 1
for i in range(2, 2*10**5+1):
    S[i] = S[MOD%i]*(MOD-int(MOD/i))%MOD

if N-1 <= K:
    ans = 1
    num = 2*N - 1
    for i in range(N-1):
        ans *= (num-i)*S[i+1]
        ans %= MOD
    print(ans%MOD)
else:
    S1 = [1]*N
    S2 = [1]*N
    for i in range(1, N):
        S1[i] = (S1[i-1]*(N+1-i)*S[i])%MOD
        S2[i] = (S2[i-1]*(N-i)*S[i])%MOD
    ans = 0
    for i in range(K+1):
        ans += S1[i]*S2[N-1-i]
        ans %= MOD
    print(ans)


# nCm * n-mHm
# nCm * n-1Cn-m-1

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

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

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long ans = 0;
		for (long i = 0; i < 60; i++) {
			long zero = 0;
			for (int j = 0; j < n; j++) {
				if ((a[j] & (1L << i)) == 0) {
					zero++;
				}
			}
			ans += ((zero * (n - zero)) % MOD) * ((1L << i) % MOD);
			ans %= MOD;
		}
		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 31812
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
  int n,m,a,b,c;
  scanf("%d %d %d",&n,&m,&a);
  c=a;
  while(--n){
    scanf("%d",&b);
    a=gcd(a,b);
    if(c<b)c=b;
  }
  printf("%s\n",m%a||m>c?"IMPOSSIBLE":"POSSIBLE");
  return 0;
}


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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int n, m; cin >> n >> m;

    vector<int> total(n, 1), red(n, 0);
    red[0] = 1;

    for (int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;

        u--; v--;

        total[u]--;
        total[v]++;

        if (red[u]) red[v] = true;
        if (!total[u]) red[u] = false;
    }

    int x = 0;
    for (auto v : red)
        x += v;

    cout << x << endl;

    return 0;
}

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

int main() {
  string a,b,c;
  char a_,b_,c_;
  cin>>a>>b>>c;
  a_=a[0];
  b_=b[0];
  c_=c[0];
  char x,y,z;
  x='A'+(a_-'a');
  y='A'+(b_-'a');
  z='A'+(c_-'a');
  cout<<x<<y<<z<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int main () {

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

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,l,a=0;
  cin>>n;
  l=n;
  
  for(int i=8;i>0;i--){
    int m=1;
    for(int j=0;j<i;j++){      
      m*=10;
    }
    int b=n/m;
    a+=b;
    n-=(b*m);
  }  
  a+=n;
  
  if(l%a==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }  
}

Measured memory_bytes: 3584
#include <iostream>
#include<string.h>
using namespace std;

int main() {
	string A;
	string S[8];
	S[6] = "MON";
	S[5] = "TUE";
	S[4] = "WED";
	S[3] = "THU";
	S[2] = "FRI";
	S[1] = "SAT";
	S[7] = "SUN";

	cin >> A;

	for (int i = 0; i < 8; i++) {
		if (S[i] == A) {
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
l = []
for i in range(N):
    s = str(input())
    l.append(s)
    
res = ['AC','WA','TLE','RE']
num = [0,0,0,0]
for i in range (N):
    for j in range(4):
        if res[j] == l[i]:
            num[j] += 1

for i in range(4):
    print(res[i] + ' x',num[i])

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

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

  long long int ans = k;
  for(int i = 1; i < n; ++i){
    ans *= (k - 1);
  }

  cout << ans << endl;

  return 0;
  
}


Measured memory_bytes: 256
#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() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> v(n+1);
    rep(i,n-1){
        string ss=s.substr(i,2);
        if(ss=="AC") v[i+1]++;
    }
    rep(i,n){
        v[i+1]+=v[i];
    }
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << v[y]-v[x] << endl;
    }
}


Measured memory_bytes: 3812
n = int(input())
s = [int(input())for _ in range(n)]
s.sort(reverse = True)
ans = sum(s)
if ans%10 == 0:
    no = True
    for i  in range(n-1,-1,-1):
        if s[i]%10 !=0:
            ans-=s[i]
            no = False
            break
            
    if no:
        ans = 0
    
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N, M;
    cin >> N;
    if(N%2 == 0){
        M = (N-2)*N/2;
        cout << M << endl;
        rep2(i, 1, N+1){
            rep2(j, i+1, N+1){
                if(i+j != N+1){
                    cout << i << ' ' << j << endl;
                }
            }
        }
    }
    else{
        M = (N-3)*(N-1)/2 + N-1;
        cout << M << endl;
        rep2(i, 1, N){
            rep2(j, i+1, N+1){
                if(i+j != N){
                    cout << i << ' ' << j << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int N;
    cin >> N;
    cout.precision(10);
    cout << (double)(N - N / 2) / (double)N << endl;
}

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

int main()
{
    int a,b,t;
    cin>>a>>b;
    if(a<6)
    {
        cout<<"0";
    }
    else{
    if(a<13)
    {
        t=b/2;
        cout<<t;
    }
    else{
        cout<<b;
    }
    }
    return 0;
}


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

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    printf("%d\n", min(p + q, min(p + r, r + q)));
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        long n = in.longNext();
        long k = in.longNext();
        out.println(solve(n, k));

        out.close();
    }

    static long solve(long n, long k) throws IOException {
        if (k >= n) return 0;
        long[] monsterHealths = in.nextLongArray((int) n);
        Arrays.sort(monsterHealths);
        long total = 0;
        for (int i = 0; i < (n - k); i++) {
            total += monsterHealths[i];
        }
        return total;
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 55664
A, B, M = map(int,input().split())
aArray = list(map(int,input().split()))
bArray = list(map(int,input().split()))
cArray = [[]] * M
for i in range(M):
    cArray[i] = (list(map(int,input().split())))
minV = min(aArray) + min(bArray)
for c in cArray:
    minV = min([minV, (aArray[c[0] - 1] + bArray[c[1] - 1] - c[2])])
print(minV)

Measured memory_bytes: 76908
# input
n, k = map(int, input().split())
A = list(map(int, input().split()))

ones = [0] * 40 # 各桁で1が立っている数
for a in A:
    for i in range(40):
        if a & (1 << i):
            ones[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << i) > k:
        continue
    if ones[i] < n - ones[i]: # 1が立っている数 < 0が立っている数 -> 1を立てる
        x += (1 << i)

ans = 0
for a in A:
    ans += x ^ a

print(ans)

Measured memory_bytes: 14620
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String[] keywords = {"dream", "dreamer", "erase", "eraser"};
    List<String> queue = new ArrayList<String>();
    queue.add(s);
    while (queue.size() > 0) {
      s = queue.remove(queue.size() - 1);
      if (s.isEmpty()) {
        System.out.println("YES");
        return;
      }
      for (int i = 0; i < 4; i++) {
        String keyword = keywords[i];
        String ts = s.replaceAll(keyword, "");
        if (s.length() > ts.length()) queue.add(ts);
      }
    }
    System.out.println("NO");
  }
}

Measured memory_bytes: 46920
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100
string s[N],ans;
ll n,l;

int main(){
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	ans=s[0];
	for (int i = 1; i < n; ++i){
		ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1000000007;
	//constexpr ll P = 998244353;

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

	vector<ll> cnta(n + 1, 0), cntb(n + 1, 0);
	for (ll i = 0; i < n; i++) {
		cnta[a[i]]++;
		cntb[b[i]]++;
	}

	for (ll i = 1; i <= n; i++) {
		if (cnta[i] + cntb[i] > n) {
			No();
			return 0;
		}
	}

	ll diff = 0;
	for (ll i = 1; i <= n; i++) {
		auto itr1 = upper_bound(ALL(a), i);
		auto itr2 = lower_bound(ALL(b), i);
		if (itr1 == a.begin()) continue;
		if (*(--itr1) != i) continue;
		if (itr2 == b.end()) continue;
		if (*itr2 != i) continue;
		diff = max(diff, (ll)((itr1 - a.begin()) - (itr2 - b.begin())) + 1);
	}

	for (ll i = diff; ; i++) {
		bool flag = false;
		for (ll j = 0; j < n; j++) {
			if (a[j] == b[(j + i) % n]) break;
			if (j == n - 1) flag = true;
		}
		if (flag) {
          Yes();
			for (ll j = 0; j < n - 1; j++) cout << b[(j + i) % n] << ' ';
			cout << b[(n - 1 + i) % n] << endl;
			break;
		}
	}
}

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

int main(){
	double p = 3.141592653589793238;
	double r;
	cin >> r;
	std::cout << std::fixed;
	std::cout << std::setprecision(6) << r*r*p << ' ' << 2*r*p << "\n";
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>;
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop();
          for(int k=0;k<4;k++){
            int nh=p.first+dh[k];
            int nw=p.second+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first).at(p.second)+1;
            An=d.at(nh).at(nw);
            que.push(make_pair(nh,nw));
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = [input() for i in range(n)]
cnt = 0
a = 0
b = 0
ba = 0
for i in s:
    if i[0] == 'B' and i[-1] == 'A':
        ba += 1
    elif i[0] == 'B':
        b += 1
    elif i[-1] == 'A':
        a += 1
    for j in range(len(i)-1):
        if i[j] == 'A' and i[j+1] == 'B':
            cnt += 1
if a == b == ba == 0:
    print(cnt)
elif a == b == 0:
    print(cnt + ba-1)
else:
    print(cnt + min(a,b) + ba)




Measured memory_bytes: 47700