akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    for(int i=0;i<n;i++) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ll k;cin>>k;
    ll a,b;
    UnionFind Friend(n);
    vector<ll> ans(n,0);
    For(i,0,m){
        cin>>a>>b;
        a--;b--;
        Friend.unite(a,b);
        ans[a]--;
        ans[b]--;
    }
    For(i,0,k){
        cin>>a>>b;
        a--;b--;
        if(Friend.same(a,b)){
            ans[a]--;
            ans[b]--;
        }       
    }
    For(i,0,n){
        ans[i]+=Friend.size(i)-1;
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}
int main(){
    Main();
    return 0;
}

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

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

    vector<int> wsums(N+1, 0), esums(N+1, 0);
    rep(i, int(S.size())) {
        if(S[i] == 'W') wsums[i+1] = wsums[i]+1;
        else wsums[i+1] = wsums[i];
        if(S[N-i-1] == 'E') esums[N-i-1] = esums[N-i]+1;
        else esums[N-i-1] = esums[N-i];
    }

    int res = 1e9;
    rep(i, int(S.size())) {
        int temp = wsums[i] + esums[i+1];
        res = min(res, temp); 
    }
    
    cout << res << endl;
    return 0;
}

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

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

    int res = INT_MAX;
    for (int i = 0; i + 2 < (int)S.size(); i++)
    {
        int x = stoi(S.substr(i, 3));
        res = min(res, abs(x - 753));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	cout << 4+(n+min({a,b,c,d,e})-1)/min({a,b,c,d,e}) << endl;
	return 0;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var n = toInt(input[0]);
	var k = toInt(input[1]);
	var ans = 0;
	if(k%2===0){
		var l = Math.floor(n/k);
		var s = Math.floor((n-k/2)/k)+1;
		s = max(s,0);
		console.log(l*l*l + s*s*s);
	}else{
		var l = Math.floor(n/k);
		console.log(l*l*l);
	}

}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    s[3]++;
    cout << s << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prDouble(x) cout<< fixed << setprecision(10) << x
using namespace std;

double dp[3001][3001];
double probability(double* arr,int i,int x){
    if(x==0){
        return 1;
    }
    if(i==0){
        return 0;
    }
    if(dp[i][x]>-0.9){
        return dp[i][x];
    }

    return dp[i][x] = arr[i]*probability(arr,i-1,x-1) + (1 - arr[i])*probability(arr,i-1,x);
}

int main(){
    int n;
    cin>>n;
    double arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    prDouble(probability(arr,n,(n+1)/2));

    return 0;
}

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


const int MAX_N = 2e5 + 10;
int N, Q, D[MAX_N], X[MAX_N];
vector<int> G[MAX_N];

void dfs(int v, int sum){
    sum += X[v];
    D[v] = sum;
    for (auto _v : G[v]){
        if (D[_v] == -1) dfs(_v, sum);
    }
    return;
}

int main(){
    cin >> N >> Q;
    for (int i = 1; i <= N; ++i) X[i] = 0;
    for (int i = 1; i <= N; ++i) D[i] = -1;
    for (int i = 0; i < N-1; ++i){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < Q; ++i){
        int p, x;
        cin >> p >> x;
        X[p] += x;
    }

    dfs(1, 0);

    for (int i = 1; i <= N; ++i){
        cout << D[i] << " ";
    }cout << endl;

    return 0;
}

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

int main(void){
	int n, m;
	set<string> st;
	cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		st.insert(s);
	}
	cin >> m;
	bool open = false;
	for(int i = 0; i < m; ++i){
		cin >> s;
		if(st.find(s) == st.end()){
			cout << "Unknown ";
		}else{
			if(open){
				cout << "Closed by ";
			}else{
				cout << "Opened by ";
			}
			open = !open;
		}
		cout << s << endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    int a = s[i] - 'A';
    a = (a + n) % 26;
    s[i] = a + 'A';
    cout << s[i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main()
  {
   int n;
   cin>>n;
   int D[n][2];
   for(int i=0;i<n;i++){
       cin>>D[i][0]>>D[i][1];
       }
   
   int f=0;
   
   for(int i=0;i<n-2;i++){
       if((D[i][0]==D[i][1]) && (D[i+1][0]==D[i+1][1]) && (D[i+2][0]==D[i+2][1])){
           f=1;
       }
   }
   
   if(f==1){
       cout<<"Yes";
   }
   
   else{
       cout<<"No";
   }
}



Measured memory_bytes: 3628
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    int n;
    cin >> n;
    vector<string> a(n);
    for (auto &x : a) {
        cin >> x;
    }
    cout << len(set<string>(all(a))) << endl;
}

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll ans = 0;
    priority_queue<PII> que;
    REP(i, n) if(a[i] != b[i]) que.push({b[i], i});
    while(que.size()) {
        ll val, i;
        tie(val, i) = que.top(); que.pop();

        // b[i] - t*num <= t \iff (b[i]-t)/t <= num であるような最大のnum
        // b[i] - t*num <= a[i] \iff (b[i]-a[i])/t <= num であるような最大のnum
        ll t = b[(i+n-1)%n] + b[(i+1)%n];
        ll num = min((b[i]-1)/t, (b[i]-a[i]+t-1)/t);
        dump(b[i], a[i], t, num);
        b[i] -= t * num;
        ans += num;
        dump(b);

        if(num == 0) {
            cout << "-1\n";
            return 0;
        }
        if(b[i] != a[i]) que.push({b[i], i});
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X; cin >> X;
  int ans = X/500 * 1000;
  ans += (X%500)/5 * 5;
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
  
  
  
int main(){
long n,i,N;
double x;
long ans;
 
scanf("%ld",&n);
ans=n;
x=sqrt(n);
  
 
  
i=2;
while(i<=x){
  if(n%i==0){
   while(n%i==0){
    n=n/i;
   }
   ans=ans*(i-1)/i;
  }
 i++;
}
  
if(n!=1)ans=ans*(n-1)/n;
printf("%ld",ans);
printf("\n");
  
return 0;
}


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

int main(){
  int n,q,tmp;
  std::cin>>n;
  std::vector<int> s;
  for(int i=0;i<n;i++){
    std::cin>>tmp;
    s.push_back(tmp);
  }

  std::vector<int> t;
  std::cin>>q;
  for(int i=0;i<q;i++){
    std::cin>>tmp;
    t.push_back(tmp);
  }

  int cnt=0;
  for(int i=0;i<q;i++){
    for(int j=0;j<n;j++){
      if(t[i]==s[j]){
	cnt++;
	break;
      }
    }
  }
  std::cout<<cnt<<'\n';

  return 0;
}
  


Measured memory_bytes: 3212
import sys

a, b, c = list(map(int, input().split()))
j = a + b
k = a + c
l = b + c

if j <= k and j <= l:
  print(j)
  sys.exit()
if k <= j and k <= l:
  print(k)
  sys,exit()
if l <= j and l <= k:
  print(l)
  sys.exit()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
#define pii pair <int,int>
#define pipii pair <int,pair <int,int>>
#define mp make_pair
#define sz(var) (int)var.size()
const int maxinput=100005;
const int inf=1e9+7;
#define vi vector <int>
signed main() 
{
    FAST
    int n,w;cin>>n>>w;
    int a[n+1][2]; //weight,val, 1 based indexing
    for(int i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1];
    //dp[i][j] we are max profit if max weight allowed is j and we have only first i elements
    //dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+val[i])
    //base case: if wt is 0,then we can't take anything so dp[i][0]=0
    //dp[0][j]=0 if no element, then no profit
    int dp[2][w+5];	//optimized O(w) space as dp[i][j] only depends on dp[i-1][*]
    for(int j=0;j<=w;j++)
        dp[0][j]=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(a[i][0]<=j)
                dp[1][j]=max(dp[0][j],dp[0][j-a[i][0]]+a[i][1]);
            else
                dp[1][j]=dp[0][j];
        }
        for(int j=0;j<=w;j++)
            dp[0][j]=dp[1][j];
    }

    cout<<dp[0][w]<<endl;
}

Measured memory_bytes: 1792
k, n = map(int, input().split())
list_a = list(map(int, input().split()))
 
x = 0
longest = 0
for a in list_a:
  if a - x > longest:
    longest = a - x
  x = a
if longest < list_a[0] + (k - list_a[n-1]):
  longest = list_a[0] + (k - list_a[n-1])
print(k-longest)

Measured memory_bytes: 26420
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> w(N);
  for(int i=0;i<N;i++)w[i]=i+1;
  int a=0;
  for(int i=0;i<N;i++)if(v[i]!=w[i])a++;
  if(a<=2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int a[200005],n,b[200005];
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),b[a[i]]=i;
	int now=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i]>b[i-1])
		{
			now++;
		}
		else now=1;
		ans=max(ans,now);
	}
	cout<<n-ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
const int ma=100001;
int main(){
    vector<int>A(ma,0);
    vector<bool>Sig(ma,true);
    int c = floor(pow(ma,0.5));
    Sig[0]=false,Sig[1]=false;
    for(int i=2;i<c;i++){
        for(int j=2;i*j<ma;j++){
            Sig[i*j]=false;
        }
    }
    for(int i=1;i<ma;i++){
        if(Sig[i]&&Sig[(i+1)/2]){
            A[i]=A[i-1]+1;
        }else{
            A[i]=A[i-1];
        }
    }
    int q;cin>>q;
    int l,r;
    fol(i,q){
        cin >> l>>r;
        cout << A[r]-A[l-1]<<endl;
    }
    return 0;
}


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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;
  if(s.back()!='s') s+="s";
  else s+="es";
  cout<<s<<newl;
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
using ll = long long;
ll h[100000];
ll dp[100200];
int main(){
  ll n,k;
  cin>>n>>k;
  rep(i,n){
    cin>>h[i];
    dp[i]=10000000000;
  }
  dp[0]=0;
  rep(i,n){
    rep(j,k){
    dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, d, i, j, k;
	cin >> n >> d;
	ld x[n][d];
	fr(i,0,n)
		fr(j,0,d)
			cin >> x[i][j];
	ll ans = 0;
	fr(i,0,n)
		fr(j, i+1, n)
		{
			ld dis = 0;
			fr(k,0,d)
				dis = dis + (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			dis = sqrt(dis);
			if((dis - (ll)dis) < 0.0000001)
				ans++;
		}
	cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	for(int i=A;i<=B;i++){
        	if(i%K==0){
            	System.out.println("OK");
              	break;
            }
          	if(i==B && i%K!=0){
            	System.out.println("NG");
            }
        }
    }
}

Measured memory_bytes: 35820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int c=0;
  for(int i=a;i<=b;i++){
    int j=i%10;
    int k=(i/10)%10;
    int l=(i/1000)%10;
    int m=i/10000;
    if(j==m && k==l){
      c++;
    }
  }
  cout << c <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main () {
  long long a, b, x;
  scanf ("%lld%lld%lld", &a, &b, &x);
  long long c = b/x - a/x;
  if (a % x == 0) {
    c += 1;
  }
  printf ("%lld\n", c);
  return 0;
}

Measured memory_bytes: 1712
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,k = map(int,input().split())
  LIST = list(map(int,input().split()))
  cnt = 0
  for i in range(n):
    if LIST[i] >= k:
      cnt +=1
  print(cnt)
if __name__ == '__main__':
  main()

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

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

bool check(string a, string b) {

    if (a[0] != b[2]) {
        return false;
    }
    if (a[1] != b[1]) {
        return false;
    }
    if (a[2] != b[0]) {
        return false;
    }
    return true;
}

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

    cout << (check(a, b) ? "YES" : "NO") << endl;

}

Measured memory_bytes: 256
import sys
import numpy as np
n,k,q=map(int,input().split())
list=[]
for i in range(q):
    list.append(int(input()))

point = [k] * n
for i in range(len(list)):
    point[list[i]-1] += 1

for i in range(len(point)):
    if point[i] > q:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 19464
#include<cstdio>
#include<iostream>
const int Maxn=500000+10,Maxm=20000000;
using namespace std;
int ls[Maxm],rs[Maxm],sum[Maxm];
int vis[Maxn];
int root[Maxn],a[Maxn];
int n,m,idcnt;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
inline void push_up(int x)
{
	sum[x]=sum[ls[x]]+sum[rs[x]];
}
void modify(int &x,int y,int l,int r,int pos)
{
	x=++idcnt;
	ls[x]=ls[y];
	rs[x]=rs[y];
	sum[x]=sum[y]+1;
	if(l==r)
	{
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid)modify(ls[x],ls[y],l,mid,pos);
	else modify(rs[x],rs[y],mid+1,r,pos);
}
int query(int x,int y,int l,int r,int u,int v)
{
	if(u<=l && r<=v)return sum[x]-sum[y];
	int mid=(l+r)>>1,ret=0;
	if(u<=mid)ret+=query(ls[x],ls[y],l,mid,u,v);
	if(mid<v)ret+=query(rs[x],rs[y],mid+1,r,u,v);
	return ret;
}
int main()
{
//	freopen("in.txt","r",stdin);
	n=read(),m=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		int tmp=vis[a[i]];
		modify(root[i],root[i-1],0,n,tmp);
		vis[a[i]]=i;
	}
	while(m--)
	{
		int x=read(),y=read();
		printf("%d\n",query(root[y],root[x-1],0,n,0,x-1));
	}
	return 0;
}

Measured memory_bytes: 127048
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >



void solve(){
    ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
    cin>>n;
    vl v(n);
    for(auto &i : v) cin>>i;
    rep(i, n){
        ans ^= v[i];
    }
    rep(i, n){
        cout<<(ans ^ v[i])<<" ";
    }
    cout<<"\n";
}

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

    /* ll t;
    cin>>t;
    while(t--){ */
        solve();
    /* } */

}


Measured memory_bytes: 4748
#include <iostream>
#include<bits/stdc++.h>
#include<string>
#include<unordered_set>
#include<vector>
#define ll long long

using namespace std;

int main()
{
    ll n,k;
    cin>>n>>k;
   vector<ll> v(n+1);
   for(ll i=1;i<=n;i++)
     cin>>v[i];
     unordered_set<ll> s;
     vector<ll> vt;
     ll p=v[1];
     s.insert(1);
     vt.push_back(1);
     while(s.find(p)==s.end())
     {
         s.insert(p);
         vt.push_back(p);
         p=v[p];
     }
     if(k<vt.size())
      cout<<vt[k];
      else
      
    {
        ll i=find(vt.begin(),vt.end(),p)-vt.begin();
        k=k-i;
        ll t=vt.size()-i;
        
        cout<<vt[k%t+i]<<endl;
    }
     
  
   //cout<<vt[ps]<<endl;
   
     
    
   
    return 0;
   
   
}

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

int main() {
	int n;
	cin >> n;
	if (n == 100000)cout << 90909 << endl;
	else if (n >= 10000)cout << 9 + 900 + n - 9999 << endl;
	else if (n >= 1000)cout << 909 << endl;
	else if (n >= 100)cout << 9 + n - 99 << endl;
	else if (n >= 10)cout << 9 << endl;
	else if (n >= 1)cout << n << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String T = scan.next();
    int A = scan.nextInt();
    int B = scan.nextInt();
    String U = scan.next();

    if (U.equals(S)) {
      A = A - 1;
    }
    else{
      B = B - 1;
    }
    System.out.println(A+" "+B);    
  }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=998244353;
const ll inf=1e18+7;
int n,h[N],cost[N];
int main()
{
    scanf("%d",&n);
    forn(i,1,n){
        scanf("%d",&h[i]);
        if(i==1)continue;
        if(i==2){
            cost[i]=cost[i-1]+abs(h[i]-h[i-1]);
        }
        else{
            cost[i]=min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]));
        }
       // printf("cost[%d]:%d\n",i,cost[i]);
    }
    printf("%d\n",cost[n]);
    return 0;
}

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

int main()
{
    long long N;
    long long A, B, tmp;
    int cur, a, b;
    int ans;

    cin >> N;
    tmp = N;
    for(ans = 1; ans <= 11; ans++) {
        tmp /= 10;
        if(tmp == 0) {
            break;
        }
    }
    for(A = 1; A <= N; A++) {
        if(A*A > N) {
            break;
        }
        if(N%A != 0) {
            continue;
        }
        B = N/A;

        tmp = A;
        for(a = 1; a <= 11; a++) {
            tmp /= 10;
            if(tmp == 0) {
                break;
            }
        }
        tmp = B;
        for(b = 1; b <= 11; b++) {
            tmp /= 10;
            if(tmp == 0) {
                break;
            }
        }
        //cout << a << ", " << b << endl;
        cur = max(a, b);

        //cout << a << ", " << b << ", [" << A << ", " << B << "]" << endl;
        if(ans > cur) {
            ans = cur;
        }
    }
    //cout << ans << endl;
    cout << ans << endl;;

    return 0;
}

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

int main(){
  int w,h,n,px,py,qx,qy,dx,dy,r;
  cin>>w>>h>>n;
  r=0;
  cin>>px>>py;
  for(int i=1;i<n;i++){
    cin>>qx>>qy;
    dx=qx-px;dy=qy-py;
    if(dx*dy>=0){
      r+=max(abs(dx),abs(dy));
    }else{
      r+=abs(dx)+abs(dy);
    }
    px=qx;py=qy;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3088
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){
    string s,ans="keyence?";
    cin>>s;
    int n=(int)s.size();
    s.push_back('?');
    bool flag=false;
    for(int i=0;i<=7;i++){
        if(s.substr(0,i)==ans.substr(0,i)  &&  s.substr(n-(7-i),7-i) == ans.substr(i,7-i)  ) flag=true;
    }
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll mod=1000000007;
ll K(ll x){
  ll i,res=1;REP(i,x){res*=i+1;res%=mod;}
  return res;
}
ll G(ll x){
  ll res=1,j=mod-2,n=x;
  while(j){
    if(j%2)res*=n;n*=n;j/=2;res%=mod;n%=mod;
  }
  return res;
}
ll COM(ll x,ll y){
  if(x<y)return 0;
  return K(x)*G(K(y)*K(x-y)%mod)%mod;
}
signed main(){
  ll N,K,i;cin>>N>>K;FOR(i,1,K+1)cout<<COM(K-1,i-1)*COM(N-K+1,i)%mod<<endl;
  return 0;
}

Measured memory_bytes: 3544
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
double a[1005];
int main(){
	memset(a,0,sizeof(a));
	int n,t,aa;
	cin>>n;
	cin>>t>>aa;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	double minn=1e6;
	int flag;
	for(int i=1;i<=n;i++){
		
		a[i]=abs((double)(t-a[i]*0.006-aa));
		if(a[i]<minn){
			minn=min(minn,a[i]);
			flag=i;
		}
	}
	printf("%d",flag);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
//C++14 (GCC 5.4.1)
int main() {
    string S,Ss;
    cin >> S;
    //-----------------------------------
    int Ans=0,point=S.size();
    bool is=true,rooper=true;
    do{
        point-=5;
        if(point==-5){
            rooper=false;
        }else if(point<0){
            is=false;
            rooper=false;
        }else{
            Ss=S.substr(point,5);
            if(Ss!="dream"&&Ss!="erase"){
                if(Ss=="eamer"){
                    point-=2;
                    Ss=S.substr(point,2);
                    if(Ss!="dr"){
                        is=false;
                        rooper=false;
                    }
                }else if(Ss=="raser"){
                    point-=1;
                    if(S[point]!='e'){
                        is=false;
                        rooper=false;
                    }
                }else{
                    is=false;
                    rooper=false;
                }
            }
        }
    }while(rooper);
    

    cout << ((is) ? "YES" : "NO") <<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
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; }

const ll mod = 1e9+7;
ll n , m;

int main() {
    cin >> n >> m;
    ll ans = 1;
    for(int i = 1; i <= n; ++i) {
        ans *= i;
        ans %= mod;
    }
    for(int i = 1; i <= m; ++i) {
        ans *= i;
        ans %= mod;
    }
    if(n == m) {
        ans *= 2;
        ans %= mod;
    }else if(abs(n-m) == 1) {

    }else {
        ans = 0;
    }
    cout << ans << endl;
}

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

int main()
{
    int h, w;
    for (;;) {
	cin >> h >> w;
	if (h == 0 && w == 0)
	    return 0;
	for (int c1 = 0; c1 < h; c1++) {
	    for (int c2 = 0; c2 < w; c2++)
		cout << "#";
	    cout << endl;

	}
	cout << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>
long gcm(long a,long b){
    if (b==0) return a;
    return gcm(b,a%b);
}
 
int main(void){
    long a,b,x;
    while (std::cin>>a>>b){
        x=gcm(a,b);
        std::cout<<x<<" "<<a/x*b<<"\n";
    }
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    vector<Int> p(N);
    rep(i, 0, N) cin >> p[i];

    Int res = 0;
    rep(i, 1, N-1) {
        vector<Int> np(3);
        np[0] = p[i-1];
        np[1] = p[i];
        np[2] = p[i+1];
        sort(np.begin(), np.end());
        if (np[1] == p[i]) ++res;
    }

    cout << res << endl;
}


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

int main() {
   int N, K;
   cin >> N >> K;
   vector<int> d(K);
   vector<bool> sunuke(N, false);
   rep(i, K) {
      cin >> d[i];
      vector<int> A(d[i]);
      rep(j, d[i]){
         cin >> A[j];
         sunuke[A[j] - 1] = true;
      }
   }
   int ans = 0;
   rep(i, N) {
      if(sunuke[i] == false) {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s,t,u;
	int a,b; cin>>s>>t>>a>>b>>u;
	if(s==u)cout<<--a<<' '<<b<<endl;
	else cout<<a<<' '<<--b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
using namespace std;
#pragma warning(disable:4996)
long long n, x;

long long sum(long long G, long long H) {
	long long cnt = G + H;
	while (G >= 1 && H >= 1) {
		if (G == H) { cnt += G; G = 0; H = 0; }
		else if (G > H) {
			cnt += H*(G / H) * 2; G %= H;
		}
		else {
			cnt += G*(H / G) * 2; H %= G;
		}
	}
	cnt -= G; cnt -= H;
	return cnt;
}
int main() {
	cin >> n >> x;
	long long B = x, C = n - x;
	cout << sum(B, C) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define sum(v) accumulate(ALL(v),0)

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);
    rep(i,n){
        cin>>v[i];
    }
    double ans=0;
    sort(ALL(v));
    rep(i,n){
        if(i==0){
            ans += v[i]/pow(2,n-1);
        }else{
            ans += v[i]/pow(2,n-i);
        }
    }
    cout<<std::setprecision(10) << ans <<endl;
    return  0;
}


Measured memory_bytes: 256
S = list(input())
len = len(S)
flag = 1
s = S[0]


for i in range(0, len, 2):
    if len%2 == 1:
        flag = 0
        break

    if S[i] != 'h' or S[i+1] != 'i':
            flag = 0

    """""
    if s == 'h':
        if S[i] == 'i':
            flag = 1
    if s == 'i':
        if S[i] == 'h':
            flag = 1
    s = S[i]
    """

if flag == 1:
    print('Yes')
else:
    print('No')


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

using namespace std;

int dp[1001][1001];
string s;

int main(){
    int N, M;
    cin >> N >> M;
    dp[1][0] = 1;
    for(int i = 1; i<=N; i++){
        cin >> s;
        for(int j = 1; j<=M; j++){
            if(s[j-1] == '.'){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%1000000007;
            }
            else{
                dp[i][j] = 0;
            }
        }
    }
    cout << dp[N][M] << endl;
}


Measured memory_bytes: 4224
// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#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 SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)
#define INF 1000000000
#define mod 1000000007

int main() {
	int n, m;
	sc("%d%d", &n, &m);

	vector<vector<int>> g(n + 1, vector<int>());

	int a, b;
	for (int i = 1; i <= m; i++) {
		sc("%d%d", &a, &b);

		g[a].pb(b);
		g[b].pb(a);
	}

	queue<ii> q;
	q.push({1, 0});

	vector<bool> bor(n + 1, 0);
	int qy[n + 1];
	memset(qy, -1, sizeof(qy));
	bor[1] = true;
	while (!q.empty()) {
		int u = q.front().F;
		int ay = q.front().S;
		q.pop();
		for (int i = 0; i < g[u].size(); i++) {
			if (!bor[g[u][i]]) {
				q.push({g[u][i], u});
				qy[g[u][i]] = u;
				bor[g[u][i]] = true;
			}
		}

		// qy[u] = u;
	}

	for (int i = 2; i <= n; i++)
		if (qy[i] == -1) {
			cout << "No" << endl;
			return 0;
		}

	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++)
		pr("%d\n", qy[i]);

	return 0;
}


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

typedef long long ll;

int main(void){
    ll n, p; cin >> n >> p;
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    
    ll ans = 1;
    for (int i = 2; i <= sqrt(p); i += (i == 2 ? 1 : 2)) {
        int cnt = 0;
        while (p % i == 0) {
            p /= i;
            cnt++;
        }
        if (cnt >= n) {
            ll t = cnt / n;
            ans *= pow(i, t);
        }
    }
    cout << ans << endl;
    return 0;
}


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

double dist(int x,int y, int xi, int yi){
	return pow(pow(x-xi,2)+pow(y-yi,2),0.5);
}


int main() {
	cout<<setprecision(14);
	int N;
	cin >> N;
	vector<pair<int,int>> xy(N);
	vector <int> num(N);
	
	for(int i=0;i<N;i++){
		cin>>xy.at(i).first;
		cin>>xy.at(i).second;
		num.at(i)=i+1;
	}
	
	int p=1;
	for(int i=1;i<=N;i++){
		p=p*i;
	}
	double ans =0;
	// cout<<p<<endl;
	do{
		for(int j=0;j<N-1;j++){
			ans+=dist(xy.at(num.at(j)-1).first,xy.at(num.at(j)-1).second,xy.at(num.at(j+1)-1).first,xy.at(num.at(j+1)-1).second);
		}
	}while(next_permutation(num.begin(),num.end()));
	
	cout<<ans/p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,K,check=0;
  	cin>>N>>K;
    int ans=N;
  vector<int>D(K);
  vector<vector<int>> A(K, vector<int>(100));
  for(int i=0;i<K;i++){
    	cin>>D.at(i);
    	for(int j=0;j<D.at(i);j++){
        	cin>>A.at(i).at(j);
        }
    }//入力
  for(int i=1;i<=N;i++){
  	for(int j=0;j<K;j++){
    	for(int k=0;k<D.at(j);k++){
        	if(i==A.at(j).at(k)){
             check=1;
              break;
            }
        }
    }
    ans-=check;
    check=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3668
import numpy as np

H, W, K = map(int, input().split())
c = [[] for _ in range(H)]
for i in range(H):
    s = input()
    for j in s:
        if j == '.':
            c[i].append(0)
        else:
            c[i].append(1)

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        # print(bin(bit), i, bit>>i, bit>>i == 1, i<H, i-H)
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    # print(bin(bit))
    # print(red_array)
    for y in range(H):
        for x in range(W):
            # print(bit, y, x, c[y][x], red_array[y,x],c[y][x] == 1 and not red_array[y, x])
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    # print(cnt)
    if cnt == K:
        ans += 1
print(ans)

Measured memory_bytes: 27136
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

bool solve(string& S, string& T, int dist, int M, char to, char rev)
{
    int d = dist;
    for(int i=0; i<S.size(); i++){
        if(S[i] == to){
            d--;
            if(d <= 0) return false;
        }
        if(T[i] == rev) d = min(d+1, M);
    }
    return true;
}

int main()
{
    int H, W, N, sr, sc;
    cin >> H >> W >> N >> sr >> sc;
    string S, T;
    cin >> S >> T;

    bool ans = true;
    ans &= solve(S, T, sr, H, 'U', 'D');
    ans &= solve(S, T, H-sr+1, H, 'D', 'U');
    ans &= solve(S, T, sc, W, 'L', 'R');
    ans &= solve(S, T, W-sc+1, W, 'R', 'L');

    if(ans) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 776
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std; 
int main(int argc,char const* argv[])
{
  int n,k,ans=1,i;
  cin >> n;
  cin >> k;
  for(i=0;i<n;i++)
    {
      ans=min(ans*2,ans+k);
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local sum = {}
local cursum = 0

local function addsub(curval, i)
  for j = 1, i - 1 do
    curval = curval - a[j]
    table.insert(sum, curval)
  end
end

for i = 1, n do
  cursum = cursum + a[i]
  table.insert(sum, cursum)
  addsub(cursum, i)
end
local mfl = math.floor
local function challenge(tbl, div)
  local cnt = 0
  local tn = #tbl
  for i = 1, tn do
    local v = mfl(tbl[i] / div)
    if v % 2 == 1 then
      cnt = cnt + 1
    end
  end
  if cnt < k then
    return false, tbl
  else
    local newtbl = {}
    for i = 1, tn do
      local v = mfl(tbl[i] / div)
      if v % 2 == 1 then
        table.insert(newtbl, tbl[i])
      end
    end
    return true, newtbl
  end
end

local mul = 2^40
local result = 0
for i = 0, 40 do
  ret, sum = challenge(sum, mul)
  if ret then
    result = result + mul
  end
  mul = mul / 2
end
print(result)


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

typedef long long ll;
const ll INF = 1LL << 60;

ll N, K;
vector<ll> A;

int main() {
    cin >> N >> K;
    A.resize(N);

    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    ll l = -INF, r = INF;
    while (r - l > 1) {
        ll x = (l + r) / 2;
        bool ok = [&] {
            ll total = 0;
            rep(i, N) {
                if (A[i] < 0) {
                    int l = -1, r = N;
                    while (r - l > 1) {
                        int c = (l + r) / 2;
                        if (A[c] * A[i] < x) r = c; else l = c;
                    }
                    total += N - r;
                } else {
                    int l = -1, r = N;
                    while (r - l > 1) {
                        int c = (l + r) / 2;
                        if (A[c] * A[i] < x) l = c; else r = c;
                    }
                    total += r;
                }
                if (A[i] * A[i] < x) total--;
            }
            total /= 2;
            return total < K;
        }();

        if (ok) l = x; else r = x; 
    }

    cout << l << endl;
}

Measured memory_bytes: 1792
loop do
  l = gets.to_i
  break if l.zero?
  sum=0
  1.upto(12) do |i|
    m,n = gets.split.map(&:to_i)
    sum+=m-n
    if sum>=l
      puts i
      (12-i).times{gets}
      break
    end
    puts :NA if i==12
  end
end

Measured memory_bytes: 2788
#include  <bits/stdc++.h> 
using namespace std;
 
#define ll long long
#define ar array
#define pii pair<int,int>
#define mp make_pair
 
const int INF = INT_MAX;
const int mod = 1000000007;



void solve(){
	int x;cin>>x;
    if(x>=30){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	// int t;
	// cin>>t;
	// while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
 
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int SIZE = 31;
const int INF = 1<<27;
 
int G[SIZE][SIZE], C[4];
int H, W;
 
struct State {
  int x, y, d, cost;
  State() {}
  State(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
  bool operator<(const State &s) const {
    return cost>s.cost;
  }
};
 
int solve() {
  int cost[4][SIZE][SIZE];
  priority_queue<State> pq;
  pq.push(State(0,0,0,0));
  fill(cost[0][0], cost[4][0], INF);
  cost[0][0][0] = 0;
  while(!pq.empty()) {
    const State s = pq.top(); pq.pop();
    if(cost[s.d][s.y][s.x] < s.cost) continue;
    if(s.x == W-1 && s.y == H-1) return s.cost;
    for(int i=0; i<4; i++) {
      State t = s;
      t.cost += ( G[s.y][s.x] == i ? 0 : C[i] );
      t.d = (s.d + i) % 4;
      t.x += dx[t.d], t.y += dy[t.d];
      if(0 <= t.x && t.x < W 
     && 0 <= t.y && t.y < H 
     && cost[t.d][t.y][t.x] > t.cost) {
    pq.push(t);
    cost[t.d][t.y][t.x] = t.cost;
      }
    }
  }
   
  return INF;
}
 
int main() {
  while(cin >> W >> H, W+H) {
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
    cin >> G[i][j];
     
    for(int i=0; i<4; i++) cin >> C[i];
     
    cout << solve() << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1328