akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        boolean ok = false;
        for (int i = 0; i <= X; i++) {
            int sum = 2 * i + 4 * (X - i);
            if (sum == Y) {
                ok = true;
                break;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

void solve(){
   string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2)
       cout<<s[i];
}
int main(){
       std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      
       solve(); 
    return 0;
}


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

int main() {
	ll h,w;
	char a[55][55];
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	ll lr[4]={1,-1,0,0},ud[4]={0,0,1,-1};
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]=='.'){
				continue;
			}
			bool flag=false;
			for(int k=0;k<4;k++){
				if(a[i+lr[k]][j+ud[k]]=='#'){
					flag=true;
				}
			}
			if(flag!=true){
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  ll ans=0;
  ll vec[n][2];
  for(int i=n-1;i>=0;i--){
    cin>>vec[i][0]>>vec[i][1];
  }
  ll x;
  for(int i=0;i<n;i++){
    x=(vec[i][1]-(vec[i][0]+ans)%vec[i][1])%vec[i][1];
    ans+=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main(void)
{
	int n,m,a[1001],b[1001],i,j,p,k=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++) scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<m;i++){
		for(j=i+1;j<m;j++){
			if(a[i]<a[j]){
				p=a[i];
				a[i]=a[j];
				a[j]=p;
			}
		}
	}
	for(i=0;i<m-1;i++){
		if(a[i]<n) k+=n-a[i];
	}	
	printf("%d\n",k);
	return 0;
}	

Measured memory_bytes: 2680
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int dist[1 << 15];

void printBit(int cur, int n) {
	for(int i = n - 1; i >= 0; i--)
		printf("%d ", (cur & (1 << i)) > 0 ? 1 : 0);
}

int main(void) {
	int n, m, bits = 0, data[15];
	scanf("%d %d", &n, &m);
	if(n == 1) {
		printf("0\n");
		return 0;
	}
	for(int i = 0; i < n; i++) {
		int v;
		scanf("%d", &v);
		bits <<= 1;
		bits += v;
	}
	int goal[2] = {0, 0};
	for(int i = 0; i < m; i++) {
		scanf("%d", data + i);
		for(int j = 0; j < data[i]; j++) {
			goal[i % 2] <<= 1;
			goal[!(i % 2)] = (goal[!(i % 2)] * 2 + 1);
		}
	}

	fill(dist, dist + (1 << n), -1);
	dist[bits] = 0;
	queue<int> q;
	q.push(bits);
	while(!q.empty()) {
		int cur = q.front();
//		printBit(cur, n);
//		printf(", %d\n", dist[cur]);
		q.pop();

		for(int i = 0; i < n - 1; i++) {
			int upper = (((1 << 16) - 1) & cur) >> (i + 2);
			int lower = ((1 << i) - 1) & cur;
			int mid = (cur >> i) & 3;
			if(mid == 1) mid = 2;
			else if(mid == 2) mid = 1;

			int next = (((upper << 2) + mid) << i) + lower;
//			printBit(cur, n);
//			printf("\t");
//			printBit(next, n);
//			printf("\n");
			if(dist[next] == -1) {
				dist[next] = dist[cur] + 1;
				q.push(next);
			}
		}
	}

	int ans = dist[goal[0]];
	if(ans == -1 or (dist[goal[1]] != -1 and ans > dist[goal[1]])) ans = dist[goal[1]];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1168
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

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

char table[501][501];
int main() {
	int N;
	cin >> N;
	int bc=0,wc=0;
	for(int i=0;i<N;i++){
		cin >> table[i];
		for(int j=0;j<N;j++){
			if(table[i][j]=='.'){
				wc++;
			}
			else{
				bc++;
			}
		}
	}
	if(wc==N*N){
		cout << -1 << endl;
		return 0;
	}
	else if(bc==N*N){
		cout << 0 << endl;
		return 0;
	}

	int abc=0;
	for(int j=0;j<N;j++){
		bool ok=true;
		for(int i=0;i<N;i++){
			if(table[i][j]=='.'){
				ok=false;
				break;
			}
		}
		if(ok){
			abc++;
		}
	}
	int ret=1e9;
	for(int p=0;p<N;p++){
		int c=0;
		for(int j=0;j<N;j++){
			if(table[p][j]=='.'){
				c++;
			}
		}
		if(c==0){
			ret=min(ret,N-abc);
			continue;
		}
		bool ok=false;
		for(int i=0;i<N;i++){
			if(table[i][p]=='#'){
				ok=true;
				break;
			}
		}
		if(ok){
			ret=min(ret,N-abc+c);
		}
		else{
			ret=min(ret,N-abc+c+1);
		}
	}
	cout << ret << endl;

	return 0;
}



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

int main() {
	string s;
	cin >> s;
	rep(i,s.size())
		if(s.at(i) == ',')
			cout << " ";
		else
			cout << s.at(i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 998244353;
using mint = Fp<MOD>;

int main(void){
  int N; cin >> N;
  vector<ll> a(N);
  ll S = 0;
  int i;REP(i,N) cin >> a[i], S+=a[i];

  vector<vector<mint> > dp(N+1,vector<mint>(S+1,0));
  dp[0][0] = 1;
  auto dp2 = dp;

  REP(i,N){
    for(int v = 0; v+a[i]<=S; v++){
      //赤に塗る場合の数
      dp[i+1][v+a[i]] += dp[i][v];
      //ア海外に塗るときの場合の数
      dp[i+1][v] += dp[i][v]*2;

      dp2[i+1][v+a[i]] += dp2[i][v];
      dp2[i+1][v] += dp2[i][v];
    }
  }

  mint all = modpow(mint(3),N);
  mint Complement = 0;

  //S/2を超える数を数え上げる
  for(i=S/2+1;i<=S;i++) Complement += dp[N][i]*3;
  if(S%2==0){
    //偶数の時にはS/2もたして，一つが0，二つがS/2になる場合を引く
    Complement += (dp[N][S/2] - dp2[N][S/2])*3; 
  }
  cout << all - Complement << endl;
  return 0;
}


Measured memory_bytes: 423104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
ll sum;
int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    if(k==0)
    {
        printf("%lld\n",n*n);
        return 0;
    }
    for(int i=k+1;i<=n;i++)
    {
        sum+=(n/i)*(i-k);
        if(n%i>=k)
            sum+=(n%i-k+1);
    }
    printf("%lld\n",sum);
    return 0;
}


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

using namespace std;

long long solve(const vector<long long>& a, long long k, int idx, bool k_lt) {
    if (idx < 0) {
        return 0;
    }

    long long cnt_z = 0, cnt_o = 0;
    for (int i = 0; i < static_cast<int>(a.size()); i++) {
        if ((a[i] & (1LL << idx)) == 0) {
            cnt_z++;
        } else {
            cnt_o++;
        }
    }

    if (k_lt) {
        return (1LL << idx) * (cnt_z > cnt_o ? cnt_z : cnt_o) + solve(a, k, idx - 1, true);
    } else if ((k & (1LL << idx)) == 0) {
        return (1LL << idx) * cnt_o + solve(a, k, idx - 1, false);
    } else {
        long long fx_z = (1LL << idx) * cnt_z + solve(a, k, idx - 1, false);
        long long fx_o = (1LL << idx) * cnt_o + solve(a, k, idx - 1, true);
        return (fx_z > fx_o ? fx_z : fx_o);
    }
}

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

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

    cout << solve(a, k, 40, false) << endl;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];

    set<int> s;
    rep(i, k) s.insert(p[i]);

    int ans = 1;
    for(int i = k; i < n; i++) {
        int lo = *s.begin(), hi = *s.rbegin();
        int left = p[i - k], right = p[i];
        // cout << i << " : " << lo << " " << hi << endl;
        if (!(lo == left and hi < right)) {
            ans++;
        }

        s.erase(left);
        s.insert(right);
    }

    int idx = 1, cnt = 1, rem = 0;
    while(idx < n) {
        // cout << idx << " " << cnt << " " << rem << endl;
        if (p[idx - 1] < p[idx]) cnt++;
        else cnt = 1;
        if (cnt == k) rem++;
        idx++;
    }

    if (rem > 0) rem--;
    cout << ans - rem << endl;
    /*
    int ans = n - k;
    int idx = 1; int cnt = 1;
    auto f = [&](){
        while(idx < n) {
            if (cnt == k) break;
            if (p[idx-1] < p[idx]) cnt++;
            else cnt = 0;
            idx++;
        }
    };
    f();
    ans--;

    while(idx < n) {
        if (p[idx - 1] < p[idx]) {
            ans--;
            idx++;
        } else {
            f();
            if(idx <= n) ans--;
        }
    }

    cout << ans  << endl;
    */
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int mod=1000000007;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

int n;
cin>>n;
Vec vec(n);
ll sum=0;
for(int i=0;i<n;i++){
    cin>>vec[i];
    sum+=vec[i];
    sum%=mod;
}
ll ans=0;
for(int i=0;i<n;i++){
    sum-=vec[i];
    if(sum<0){
        sum+=mod;
    }
   ans+=sum*vec[i];
   ans%=mod;
}
cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    int n, a;

    cin >> n;
    cin >> a;

    cout << max(n * n - a, 0) << endl;

    return 0;
}


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

const int M = 2e5 + 5;
int a[M];
bool vis[M];
ll k, n, t, b=1, bb;
ll read(){
	char c = getchar();
	ll x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}

int main() {
	n = read(); k = read();
	for (ll i = 1; i <= n; ++i)
		a[i] = read();
	t = 1;
	if (n >= k) {
		while (k--)
			t = a[t];
		printf("%lld\n", t);
	}
	else {
		vis[a[1]] = 1;
		for (ll i = 1; i <= n; ++i) {
			t = a[t];
			if (vis[a[t]])
				break;
			else
				vis[a[t]] = 1;
		}
		for (ll i = a[t]; i != t; i = a[i])
			b++;
		for (ll i = 1; i != t; i = a[i])
			bb++;
		k = (k - bb) % b;
		while (k--)
			t = a[t];
		printf("%lld\n", t);
	}
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if(n/100 == 7 or n % 10 == 7 or (n / 10)%10 == 7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define MOD 1000000007
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  if(k==0){
    ll c=0;
    for(int i=0;i<n;i++) c+=a[i];
    cout<<c;
    return 0;
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll x=max(a[0],k);
  ll c=0;
  while(x!=0){
    x/=2;
    c++;
  }
  vector<ll> d(c,0);
  for(int i=0;i<n;i++){
    for(int j=0;j<c;j++){
      if(b[i]%2==1) d[j]++;
      b[i]/=2;
    }
  }
  x=k;
  ll cnt=0;
  while(x!=0){
    x/=2;
    cnt++;
  }
  x=a[0];
  ll cn=0;
  while(x!=0){
    x/=2;
    cn++;
  }
  vector<ll> f(c);
  x=k;
  for(int i=0;i<c;i++){
    f[i]=x%2;
    x/=2;
  }
  ll me=0;
  x=1;
  for(int i=0;i<c;i++){
    if(i<cnt-1){
      me+=max(d[i],n-d[i])*x;
      x*=2;
    }else{
      me+=d[i]*x;
      x*=2;
    }
  }
  ll mem=0;
  x/=2;
  bool bo=false;
  for(int i=c-1;i>=0;i--){
    if(bo){
      mem+=max(d[i],n-d[i])*x;
      x/=2;
    }else{
      if(f[i]==0){
        mem+=d[i]*x;
        x/=2;
      }else{
        if(d[i]<n-d[i]){
          mem+=(n-d[i])*x;
          x/=2;
        }else{
          mem+=max(d[i],n-d[i])*x;
          x/=2;
          bo=true;
        }
      }
    }
  }
  cout<<mem;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1000000007;
#define MAX 10000

int N;

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

    cin >> N;

    LL A[N+10];
    LL T[N+10];

    for (int i = 0; i < N; i++){
        cin >> T[i];
    }
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    LL ans = 0;

    if (T[N-1] == A[0] && T[0] <= A[0]) {
      ans = 1;
      for (int i = 1; i < N -1; i++) {
        if (T[i-1] < T[i]) {
          if (A[i] < T[i]) {
            ans = 0;
            break;
          }
        } else if (A[i] > A[i+1]) {
          if (T[i] < A[i]) {
            ans = 0;
            break;
          }
        } else {
          ans *= min(T[i], A[i]);
          ans %= mod;
        }
      }
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            res += d[i] * d[j];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		 Scanner scan = new Scanner(System.in);
	     int r  = scan.nextInt();
	     ArrayList<Integer> list = new ArrayList<Integer>();
	     for(int i=0;i<r;i++) {
	    	 list.add(scan.nextInt());
	     }

	     @SuppressWarnings("unchecked")
		ArrayList<Integer> sorted =(ArrayList<Integer>) list.clone();
	     Collections.sort(sorted);
	     for(int i=0;i<list.size()-1;i++) {
	    	 for(int j=i+1;j<list.size();j++) {
	    		 @SuppressWarnings("unchecked")
				ArrayList<Integer> tmp =(ArrayList<Integer>) list.clone();
	    		 tmp.set(i, list.get(j));
	    		 tmp.set(j, list.get(i));
	    		 if(sorted.equals(tmp) || sorted.equals(list)) {
	    			 System.out.println("YES");
	    			 return ;
	    		 }

	    	 }

	     }
		 System.out.println("NO");
	}

}


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

#define ll long long 

int main(){
	int n, k;
	cin>>n>>k;
	int arr[n];
	for(int i = 0; i<n; i++)
		cin>>arr[i];
	ll dp[n+1]={};
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i<n; i++)
		dp[i] = INT_MAX;
	for(int i = 2; i<n; i++){
		for(int j = 1; j<=k && i-j >= 0; j++)
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
		}
		
	cout<<dp[n-1]<<endl;
	return 0;
	}


Measured memory_bytes: 1408
#include <stdio.h>
 #define N 100
int main(){
   
  int i,j,min,n;
int mi,count = 0;
int array[N][N],farray[N],num[N];
 
  scanf("%d",&n);
   
   
  for(i = 0;i < n;i++){

    for(j = 0;j < n;j++){

      scanf("%d",&array[i][j]);
    }
  }

  for(i = 0;i < n;i++){
    farray[i] = 0;
    num[i] = 2000;
  }

  num[0] = 0; 
 
  for(i = 0;i < n-1;i++){
    min = 2000;
    for(j = 0;j < n;j++){
      if(num[j] < min && farray[j] == 0){
    min = num[j];
    mi = j;
      }
    }
    farray[mi] = 1;
   
    for(j = 0;j < n;j++){
      if(array[mi][j] != -1 && array[mi][j] < num[j] && farray[j] == 0){
    num[j] = array[mi][j];
      }
    }
  }
   
  for(i = 0;i < n;i++){
    count += num[i];
  }

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

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define ps pair<string,string>

using namespace std;

int n;
long long res;
string s;
map<ps, int> been;

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    cin>>s;
    for (int tt=0;tt<(1<<n);tt++) {
        string s1="",s0="";
        for (int i=0;i<n;i++)
            if ( ((tt>>i)&1)==1) s1+=s[i];
        for (int i=n-1;i>=0;i--)
            if ( ((tt>>i)&1)==0) s0+=s[i];
       // cout<<tt<<" "<<s1<<" "<<s0<<endl;
        been[ps(s1,s0)]++;
    }
     for (int tt=0;tt<(1<<n);tt++) {
        string s1="",s0="";
        for (int i=0;i<n;i++)
            if ( ((tt>>i)&1)==1) s1+=s[n+i];
        for (int i=n-1;i>=0;i--)
            if ( ((tt>>i)&1)==0) s0+=s[n+i];
        res+=been[ps(s0,s1)];
    }
    cout<<res<<endl;
}



Measured memory_bytes: 91904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  int tmp;
  cin >> N >> A;
  tmp = N % 500;
  if (tmp > A) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define MOD 1000000007

ll digits(ll n)
{
    ll ctr=0;
    while(n>0)
    {
        ++ctr;
        n/=10;
    }
    return ctr;
}
int main()
{
    speed;
    ll t;
    cin>>t;
    ll ans=0;
    for(ll i=1;i<=t;++i)
    {
        if(digits(i)%2!=0)
            ++ans;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
import heapq


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign


x, y, a, b, c = map(int, input().split())

red = [int(i) for i in input().split()]
green = [int(i) for i in input().split()]
clear = [int(i) for i in input().split()]

red = Heapq(red, True)
green = Heapq(green, True)
clear = Heapq(clear, True)

ans = []
for i in range(x):
    clear.push(red.pop())
for j in range(y):
    clear.push(green.pop())
ans = 0
for k in range(x + y):
    ans += clear.pop()
print(ans)


Measured memory_bytes: 23216
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin>>n>>h>>w;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    int ans=0;
    rep(i,n){
        if(a[i]>=h&&b[i]>=w)ans++;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N; cin >> N;
    vector<ll> num(N+1);
    for(ll i = 1; i <= N; ++i){
        for(int j = i; j <= N; j += i){
            ++num[j];
        }
    }
    ll ans = 0;
    for(ll i = 0; i <= N; ++i){
        ans += i * num[i];
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 81340
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  cin>>s>>s;
  cout<<'A'<<s[0]<<'C'<<endl;

  return 0;
}







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


int main() {
  int N;
  cin >> N;
  vector<int>Vec(N);
  for(int i=0; i<N; i++){
    Vec.at(i)=0;
   }
  
  for(int i=1; i<100; i++){
   	for(int j=1; j<100; j++){
   	  for(int k=1; k<100; k++){
        if(i*(i+j+k)+j*(j+k)+k*k<=N){
          Vec.at(i*(i+j+k)+j*(j+k)+k*k-1)++;
        }
        
  }
  }
  }
  
  for(int k=0; k<N-1; k++){
      cout << Vec.at(k) << endl;  
  }
  cout << Vec.at(N-1);

}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  int K;
  cin>>s>>K;
  set<string>S;
  int N=s.size();
  for(int i=0;i<N;i++){
    for(int j=1;j<=5&&i+j<=N;j++){
      S.insert(s.substr(i,j));
    }
  }
  vector<string>SS;
  for(auto it:S)SS.push_back(it);
  sort(rng(SS));
  cout<<SS[K-1]<<endl;
  return 0;
}


Measured memory_bytes: 1920
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int r=sc.nextInt();
		int d=sc.nextInt();
		int x=sc.nextInt();
		for(int i=0;i<10;i++){
			x=r*x-d;
			System.out.println(x);
		}
	}
}

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

int main(){
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << "7" << endl;
  }
  else if(s == "MON"){
    cout << "6" << endl;
  }
  else if(s == "TUE"){
    cout << "5" << endl;
  }
  else if(s == "WED"){
    cout << "4" << endl;
  }
  else if(s == "THU"){
    cout << "3" << endl;
  }
  else if(s == "FRI"){
    cout << "2" << endl;
  }
  else if(s == "SAT"){
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vi a(n);

	rep(i, n){
		cin>>a[i];
		a[i]--;
	}

	int i=0, count=0;
	bool flag=false;
	while(1){
		i=a[i]; count++;
		if(i==1){
			flag=true; break;
		}
		if(count>n) break;
	}
	if(flag){
		cout<<count<<endl;
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
double dp[305][305][305];
int c[4];
int main(){
    fast;

    int n,ele;
    cin>>n;

    for(int k=0;k<=n;k++){
        for(int j=0;(k+j)<=n;j++){
            for(int i=0;(i+j+k)<=n;i++){

                if(i==0 && j==0 && k==0)
                    continue;

                double pwait = 1.0*n/(i+j+k);
                double pi = 1.0*i/(i+j+k);
                double pj = 1.0*j/(i+j+k);
                double pk = 1.0*k/(i+j+k);

                if(i)
                    dp[i][j][k] += pi*dp[i-1][j][k];
                if(j)
                    dp[i][j][k] += pj*dp[i+1][j-1][k];
                if(k)
                    dp[i][j][k] += pk*dp[i][j+1][k-1];

                dp[i][j][k] += pwait;
            }
        }
    }

    f(i,0,n){
        cin>>ele;
        c[ele]++;
    }

    printf("%.10lf",dp[c[1]][c[2]][c[3]]);

}

Measured memory_bytes: 219392
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,q,s,t,leng[100000],par[100000],i,j;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)	{
		leng[i]=1;	par[i]=i;
	}
	for(i=0;i<m;i++)	{
		scanf("%d %d",&s,&t);
		while(par[s]!=s)	s=par[s];
		while(par[t]!=t)	t=par[t];
		if(s!=t)	{
			if(leng[s]>leng[t])	par[t]=s;
			else if(leng[s]<leng[t])	par[s]=t;
			else {
				par[s]=t;	leng[t]++;
			}
		}
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)	{
		scanf("%d %d",&s,&t);
		while(par[s]!=s)	s=par[s];
		while(par[t]!=t)	t=par[t];
		if(s==t)	printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


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

int main ()
{
  int N,K;
  cin >> N;
  cin >> K;
  int a = 1;
  
  while(N > 0){
   	if(a * 2 <= a + K){
      a *= 2;
    }else{
      a += K;
    }
    
    N--;
  }
  
  cout << a << endl;
}

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

int main(){
    int n;
    int isopen[110][2][5];
    cin >> n;
    REP(i, n){
        REP(j, 2){
            REP(k, 5){
                cin >> isopen[i][j][k];
            }
        }
    }
    int profit[110][12];
    REP(i, n){
        REP(j, 11){
            cin >> profit[i][j];
        }
    }
    int answer = -1000000010;
    REP(a, 2){
        REP(b, 2){
            REP(c, 2){
                REP(d, 2){
                    REP(e, 2){
                        REP(v, 2){
                            REP(w, 2){
                                REP(x, 2){
                                    REP(y, 2){
                                        REP(z, 2){
                                            int pro = 0;
                                            if(a + b + c + d + e + v + w + x + y + z == 0){
                                                continue;
                                            }
                                            REP(i, n){
                                                int cnt = 0;
                                                if(a && isopen[i][0][0]) cnt++;
                                                if(b && isopen[i][0][1]) cnt++;
                                                if(c && isopen[i][0][2]) cnt++;
                                                if(d && isopen[i][0][3]) cnt++;
                                                if(e && isopen[i][0][4]) cnt++;
                                                if(v && isopen[i][1][0]) cnt++;
                                                if(w && isopen[i][1][1]) cnt++;
                                                if(x && isopen[i][1][2]) cnt++;
                                                if(y && isopen[i][1][3]) cnt++;
                                                if(z && isopen[i][1][4]) cnt++;
                                                pro += profit[i][cnt];
                                            }
                                            answer = max(answer, pro);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
<?php

// 捨て
fgets(STDIN);

$numList = [];
while (!empty($line = fgets(STDIN))) {
	$numList[] = (int) $line;
}

$THRESHOLD = 10000;
$max = min($THRESHOLD, max($numList));

// 特定数値以下の素数を求める
$primaryNumList = array_fill(2, $THRESHOLD - 1, true);
for ($i = 2; $i ** 2 <= $max; $i++) {
	if (!isset($primaryNumList[$i])) {
		continue;
	}

	for ($j = 2; $i * $j <= $max; $j++) {
		$primaryNumList[$i * $j] = null;
	}
}

$count = 0;
foreach ($numList as $num) {
	if ($num <= $THRESHOLD) {
		if (isset($primaryNumList[$num])) {
			$count++;
		}
		continue;
	}

	if ($num % 2 === 0) {
		continue;
	}

	for ($i = 3; $i ** 2 <= $num; $i += 2) {
		if ($num % $i === 0) {
			continue 2;
		}
	}

	$count++;
}

echo "$count\n";



Measured memory_bytes: 12028
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0; i<n1; i++) L[i] = A[left + i];
	for(int i=0; i<n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i=0, j=0;
	for(int k=left; k<right; k++){
		cnt++;
		if(L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
		}
	}
}


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


int main(void)
{
	int A[MAX], n, i;
	cnt = 0;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	mergeSort(A,n,0,n);
	
	for(i=0; i<n; i++){
		if(i != 0)
		{
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", cnt);
	
	return 0;
}



Measured memory_bytes: 5648
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	vector<int> t(1000001, -1);
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		if (t[a[i]] == -1)t[a[i]] = 1;
		else {
			t[a[i]] = 0; continue;
		}
		for (int k = a[i] * 2; k <= 1000000; k += a[i]) {
			t[k] = 0;
		}
	}
	rep(i, 0, 1000001)ans += t[i] == 1;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
int main() {
  int max_in_dice, required_score;
  cin >> max_in_dice >> required_score;
  double probability = 0;

  // calculate probability for each roll
  for(int roll = 1; roll <= max_in_dice; ++roll) {
    int current_score = roll;
    double tmp_probability = 1.0 / max_in_dice; // probability of a roll
    // need to see heads every time until the current score reaches/exceeds the specific score.
    while(current_score < required_score) {
      current_score *= 2;
      tmp_probability /= 2;
    }
    probability += tmp_probability;
  }
  cout << setprecision(15) << probability;
  cout << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   	public String lcs(String a, String b) {
        int n = a.length();
        int m = b.length();
        int[][] dp = new int[n + 1][m + 1];
        for (int[] row: dp) {
            Arrays.fill(row, -1);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m ;j++) {
                if (a.charAt(i - 1) == b.charAt(j - 1)) {
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        reconstructSolution(a, b, dp, sb, n, m);
        return sb.reverse().toString();
    }
    private void reconstructSolution(String a, String b, int[][] memo, StringBuilder sb, int i, int j) {
        if (i <= 0 || j <= 0) {
            return;
        }
        if (a.charAt(i - 1) == b.charAt(j - 1)){
            sb.append(a.charAt(i - 1));
            reconstructSolution(a, b, memo, sb, i - 1, j - 1);
        } else if (memo[i - 1][j] > memo[i][j - 1]) {
           reconstructSolution(a, b, memo, sb, i - 1, j); 
        } else {
           reconstructSolution(a, b, memo, sb, i, j - 1); 
        }
    }
    private int lcs(String a, int i, String b, int j, int[][] memo) {
       if (i <= 0 || j <= 0) {
           return 0;
       }
       if (memo[i][j] != -1) {
           return memo[i][j];
       }
       if (a.charAt(i - 1) == b.charAt(j - 1)) {
           return memo[i][j] = 1 + lcs(a, i - 1, b, j - 1, memo);
       } else {
           int x = lcs(a, i - 1, b, j, memo);
           int y = lcs(a, i, b, j - 1, memo);
           return memo[i][j] = Math.max(x, y);
       }
    }
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String a = br.readLine();
            String b = br.readLine();
          	Main app = new Main();
            String result = app.lcs(a, b);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 83028
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
h,w,k=n1()
s=s4(h)
H=list(itertools.product([0,1],repeat=h))
W=list(itertools.product([0,1],repeat=w))

ans=0
for tate in H:
    for yoko in W:
        c=0
        for i in range(h):
            for j in range(w):
                if tate[i] == 1 or yoko[j] == 1:
                    pass
                elif s[i][j]=="#":
                    c+=1
        if c==k:
            ans+=1
print(ans)

Measured memory_bytes: 9288
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ld,ld>
#define maxn 100005
using namespace std;
ll n, a[100],cn;
ld sum;
vector<pii> v;
void genper(ll siz)
{
	if(siz==1)
	{
		for(ll i=0;i<n-1;i++)
		{
			sum += sqrt((v[a[i]].fi - v[a[i+1]].fi)*(v[a[i]].fi - v[a[i+1]].fi) + (v[a[i]].se - v[a[i+1]].se)*(v[a[i]].se - v[a[i+1]].se));	
		}
		cn++;
		return;
	}
	for(ll i =0;i<siz;i++)
	{
		genper(siz-1);
		if(siz&1)
		{
			swap(a[0],a[siz-1]);
		}
		else
		{
			swap(a[i] , a[siz-1]);
		}
	}
}
signed main()
{
    fast;
   
    ll i;
    cin>>n;
    for(i=0;i<n;i++) a[i] = i;
    for(i=0;i<n;i++)
    {
    	ld x,y;
    	cin>>x>>y;
    	v.pb({x,y});
    }
    genper(n);
    sum /= (ld)cn;
    cout<<fixed<<setprecision(10)<<sum;

}

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

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tk = new StringTokenizer(br.readLine());

		int num = Integer.parseInt(tk.nextToken());
		int num2 = Integer.parseInt(tk.nextToken());
		int num3 = Integer.parseInt(tk.nextToken());

		A AAA = (int a, int b, int c) -> {
			if( a<b && b<c ) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			};
		};

		AAA.Judgment(num, num2, num3);
	}
}

interface A{
	void Judgment(int a,int b,int c);
}


Measured memory_bytes: 30224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int a,b;
  cin >> a >> b;
  if(a%2==1) {
    rep(i,b) {
        cout << i+1 << " " << 2*b-i << endl;
    }
  }
  else {
      if(a/4>=b) {
          rep(i,b) {
            cout << i+1 << " " << 2*b-i << endl;
          }
      }
      else {
          rep(i,a/4) {
              cout << i+1 << " " << a/4*2-i << endl;
          }
          rep(i,b-a/4) {
              cout << a/4*2+1+i << " " << a-1-i << endl;
          }
      }
  }
  return 0;
}

Measured memory_bytes: 3640
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)

s = IS()
if 0 < int(s[0:2]) <= 12 and 0 < int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 0 <= int(s[0:2]) <= 99 and 0 < int(s[2:4]) <= 12:
    print('YYMM')
elif 0 < int(s[0:2]) <= 12 and 0 <= int(s[2:4]) <= 99:
    print('MMYY')
else:
    print('NA')


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

int main() {

    int a, b;

    std::cin >> a >> b;

    if ( a < b )  std::cout <<  "a < b" << std::endl;
    if ( a > b )  std::cout <<  "a > b" << std::endl;
    if ( a == b ) std::cout << "a == b" << std::endl;

    return 0;
}



Measured memory_bytes: 3104
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    Integer[] a = new Integer[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }

    sc.close();

    // color[0]:灰 [1]:茶 [2]:緑 [3]:水 [4]:青 [5]:黄 [6]:オレンジ [7]:赤 [8]:自由      
    int[] color = new int[9];

    for (int i = 0; i < N; i++) {
      if (a[i] < 400) {
        color[0]++;
      } else if (a[i] < 800) {
        color[1]++;
      } else if (a[i] < 1200) {
        color[2]++;
      } else if (a[i] < 1600) {
        color[3]++;
      } else if (a[i] < 2000) {
        color[4]++;
      } else if (a[i] < 2400) {
        color[5]++;
      } else if (a[i] < 2800) {
        color[6]++;
      } else if (a[i] < 3200) {
        color[7]++;
      } else {
        color[8]++;
      }
    }

    int min = 0;
    int max = 0;

    for (int i = 0; i < 8; i++) {
      if (color[i] != 0) {
        min++;
      }
    }
    
    max = min + color[8];

    if (min == 0){
      min = 1;
    }

    System.out.println(min + " " + max);

  }

}


Measured memory_bytes: 21844
n,k=map(int,input().split())
AB=sorted([list(map(int,input().split())) for i in range(n)])
dic={}
C=[0]
for i in range(n):
    C.append(C[-1]+AB[i][1])
for i in range(n):
    if C[i]<k<=C[i+1]:
        print(AB[i][0])
        exit()

Measured memory_bytes: 32588
import itertools
n = int(input())
s = ""
for i in range(n):
  s += str(i+1)
l = list(itertools.permutations(s, n))
p = tuple(input().split())
q = tuple(input().split())
a = l.index(p)
b = l.index(q)
print(abs(a-b))

Measured memory_bytes: 13780
#include<stdio.h>

int main(void)
{
	int i,t=0,a,min=10;
	
	for(i=0;i<5;i++){
		scanf("%d",&a);
	
		if(a%10==0)
			t+=a;
		else{
			t+=a-a%10+10;
			if(a%10<min)
				min=a%10;
		}
	}
	printf("%d",t+min-10);
	return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <math.h>

using namespace std;

int main()
{
    int a,b,c[105][105],d,e,f,g,i;
    char s[105];
    scanf("%d%d",&a,&b);
    for(i=0;i<a;i++)
    {
            scanf("%s",s);
            printf("%s\n",s);
            printf("%s\n",s);
    }
    return 0;
}


Measured memory_bytes: 3120