akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;cin>>n;
    int dp[n];int h[n];
    rep(i,n)cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }  
    cout<<dp[n-1];
    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
};
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

void f(vi &v) {
  ll mi=INF;
  for(ll i:v) mi=min(mi,i);
  if(mi>0) return;

  for(ll &i:v) i+=(1-mi);
}

int main() {
  ll N; cin>>N;
  vi p(N); REP(i,N) {cin>>p[i]; p[i]-=1;}
  vi v(N); REP(i,N) v[p[i]]=i;

  vi a(N),b(N);
  a[0]=0; b[0]=v[0];

  REP(i,N-1) {
    b[i+1]=min(v[i+1]-a[i],b[i])-1;
    a[i+1]=v[i+1]-b[i+1];
  }
  f(a);
  f(b);

  REP(i,N) if(i==N-1) cout<<a[i]<<endl; else cout<<a[i]<<' ';
  REP(i,N) if(i==N-1) cout<<b[i]<<endl; else cout<<b[i]<<' ';



}


Measured memory_bytes: 1280
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 05/30/20 16:02:55
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c,d,k; cin>>a>>b>>c>>d>>k;
  int x = a*60+b;
  int y = c*60+d;
  int ans = max(y-k-x, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int n;
  cin >> n;
  set<int> s;
  s.insert(n);
  for (int i = 2; i < 1000001; i++) {
    if (n % 2 == 0) n = n / 2;
    else n = 3 * n + 1;
    auto itr = s.find(n);
    if (itr != s.end()) {
      P(i);
      return 0;
    }
    s.insert(n);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
int a,b,c,d,e,k;
int main()
{
    while(cin>>a>>b>>c>>d>>e>>k)
    {
        if(e-a<=k) cout<<"Yay!\n";
        else cout<<":(\n";
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

int main()
{
	int N;
	cin >> N;
	mint ten = 10;
	mint nine = 9;
	mint eight = 8;
	for(int i = 0; i < N-1; i++){
		ten *= 10;
		nine *= 9;
		eight *= 8;
	}
	
	mint ans = ten - nine * 2 + eight;
	cout << ans.x << endl;
	
	return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  int m = 112345;
  vi b(m, 0);
  rep (i, n) {
    if (a[i] > 0) {
      b[a[i] - 1] += 1;
    }
    b[a[i]] += 1;
    b[a[i] + 1] += 1;
  }
  int ans = 0;
  rep (i, m) {
    ans = max(ans, b[i]);
  }
  printf("%d\n", ans);

  return 0;
}


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

int ar[100001],n,ans,now,br[100001];
 
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>ar[i];
		br[i]=ar[i];
	}
	sort(br+1,br+1+n);
	for (int i=1;i<=n;i++){
		int tmp=distance(ar,lower_bound(br+1,br+n,ar[i]));
		if ((i%2==1 && tmp%2==0) || (i%2==0 && tmp%2==1)) ans++;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 4416
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N ; cin >> N;
    int A[100]={0};
    for(int i=0;i<N;i++) cin >> A[i];
    int max = -1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(max<abs(A[i]-A[j])){
                max = abs(A[i]-A[j]);
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int n = Integer.parseInt(line);
			if(n == 0){
				break;
			}
			int A = 0;
			int B = 0;
			for(int i = 0; i < n; i++){
				String lines = reader.readLine();
				String[] str = lines.split(" ", -1);
				int a = Integer.parseInt(str[0]);
				int b = Integer.parseInt(str[1]);
				if(a > b){
					A += a + b;
				}else if(a < b){
					B += a + b;
				}else{
					A += a;
					B += b;
				}
			}
			System.out.println(A + " " + B);
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,k;
int main()
{
	scanf("%d%d%d",&a,&b,&k);
	if ((2*k) > (b-a))
		for (int i=a;i<=b;i++)
		    printf("%d\n",i);
	else
	{
		for (int i=a;i<=a+k-1;i++)
		    printf("%d\n",i);
		for (int i=b-k+1;i<=b;i++)
		    printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 256
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let mut g = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let (a, b): (usize, usize) = parse!(it, 2);
        g[a - 1].push(b - 1);
        g[b - 1].push(a - 1);
    }
    let mut parents = vec![None; n];
    let mut stack = vec![0];
    parents[0] = Some(n);
    while let Some(u) = stack.pop() {
        for &v in &g[u] {
            if parents[v] == None {
                parents[v] = Some(u);
                stack.push(v);
            }
        }
    }
    let mut path = vec![];
    let mut cur = n - 1;
    while cur != 0 {
        path.push(cur);
        cur = parents[cur].unwrap();
    }
    path.reverse();
    let block = path[(path.len()) / 2];
    let mut count = 0;
    let mut stack = vec![0];
    let mut seen = vec![false; n];
    seen[0] = true;
    seen[block] = true;
    while let Some(u) = stack.pop() {
        count += 1;
        for &v in g[u].iter() {
            if !seen[v] {
                stack.push(v);
                seen[v] = true;
            }
        }
    }
    println!("{}", if 2 * count > n { "Fennec" } else { "Snuke" });
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 16636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			String[] a_op_b = str.split(" ", 0);

			int a = Integer.parseInt(a_op_b[0]);
			String op = a_op_b[1];
			int b = Integer.parseInt(a_op_b[2]);

			if (op.equals("?")) {
				break;
			}
			if (op.equals("+")) {
				System.out.println(a + b);
			}
			if (op.equals("-")) {
				System.out.println(a - b);
			}
			if (op.equals("*")) {
				System.out.println(a * b);
			}
			if (op.equals("/")) {
				System.out.println(a / b);
			}
		}
	}
}

Measured memory_bytes: 24136
#include <iostream>

using namespace std;

#define MAX_N 100
#define MAX_W 10000

void solve();

int N, W;
int v[MAX_N + 1], w[MAX_N + 1];
int dp[MAX_N + 1][MAX_W + 1];

int main() {

    cin >> N >> W;

    //品物0
    v[0] = 0;
    w[0] = 0;

    //品物1~
    for (int i = 1; i <= N; i++) {
        cin >> v[i] >> w[i];
    }

    solve();
    cout << dp[N][W] << endl;

    return 0;
}

void solve(){
    for (int i = 1; i <= N; i++) {          //品物1からスタート
        for (int j = 0; j <= W; j++) {
            /* 漸化式 */
            if(j < w[i]){
              dp[i][j] = dp[i-1][j];
            }else{
              dp[i][j] = max( dp[i-1][j], dp[i-1][j-(w[i])]+v[i]);
            }
        }
    }
}



Measured memory_bytes: 6984
N = int(input())
lst = []
ans = "Yes"

for i in range(N):
  tmp = input()
  lst.append(tmp)

for k in range(N):
  if lst.count(lst[k]) != 1:
    ans = "No"

if ans == "No":
  ans = "No"
else:
  for j in range(N-1):
    left = lst[j]
    right = lst[j+1]
    if left[-1:] == right[:1]:
      continue
    else:
      ans = "No"
      break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<iostream>
#include <ctype.h>
#include <sstream>
using namespace std;
using Graph = vector<vector<int>>;
#define  itn int
using ll=int64_t;
#define rep(i,n) for (int i = 0; i < (int) (n); i++)
using vi = vector<int>;
using vll = vector<ll>;
//GCD
long long gcd(long long a, long long b)
{if(a<b) swap(a,b);
   if (a%b == 0){return(b);}
   else{return(gcd(b, a%b));}
}
//lcm
long long lcm(long long a, long long b)
{return a * b / gcd(a, b);}

long long bikkuri(long long k){
    long long sum = 1;
    for (long long i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int main() {

int x,y;
cin>>x>>y;
if(2*x<=y&&y<=4*x&&y%2==0){cout<<"Yes";}
else cout<<"No";
}


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

ll nc2(ll n){
	ll res = n*(n - 1)/2;
	return res;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
  	cin >> a[i];
  	--a[i];
  }

  vector<int> count(n);
  rep(i,n) ++count[a[i]];
  ll tomakomai = 0;
  rep(i,n){
  	tomakomai += nc2(count[i]);
  }

  ll ans = 0;
  rep(k,n){
  	ll murorann = nc2(count[a[k]] - 1) - nc2(count[a[k]]);
  	ans = tomakomai + murorann;
  	cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
import qualified Data.Set as S
import Data.List
import Data.Maybe

main = do
  n <- readLn
  a <- map read . words <$> getLine
  let xs = reverse $ sort $ zip a [1..]
      f s x (Just i) (Just j) = x*(r-j)*((i+1)-(l+1))
        where
          l = fromMaybe 0 $ S.lookupLT i s
          r = fromMaybe (n+1) $ S.lookupGT j s
      f _ _ _ _ = 0
      g _ [] = 0
      g s ((x,i):xs) = f s x l (Just i) + f s x (Just i) r + g t xs
        where 
          l = S.lookupLT i s
          r = S.lookupGT i s
          t = S.insert i s
  print $ g S.empty xs

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int mp[11];
vector<vector<int>> v(11);
int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

	ll n, m;cin >> n >> m;

	REP(i, m){
		int k;cin >> k;
		vector<int> now;
		REP(j, k){
			int tmp;cin >> tmp;
			tmp--;
			v[tmp].PB(i);
		}
	}

	vector<int> p(m);
	REP(i, m)cin >> p[i];

	ll ans = 0;

	REP(i, (1<<n)){
		REP(j, 11)mp[j] = 0;
		REP(j, n){
			if(i & (1 << j)){
				REP(k, v[j].size())mp[v[j][k]]++;
			}
		}
		bool flag = true;
		REP(j, m){
			if((mp[j] % 2) != p[j])flag = false;
		}
		if(flag)ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum , a , b ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		double ans , r, pi = 3.14159265;
		cin>> r;
		ans = 2*r*pi;
		cout << fixed;
		cout << setprecision(6);
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[200005];
int n;
int dp[100005];
int func(int i)
{
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int ret1 = INT_MAX;
    int ret2 = INT_MAX;

    ret1 = abs(ar[i]-ar[i+1]) + func(i+1);
    if(i+2<n)
        ret2 = abs(ar[i]-ar[i+2]) + func(i+2);
    return dp[i] = min(ret1,ret2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //  mem(dp,-1);
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> ar[i];

   // int ans = func(0);
    for(int i=1;i<n;i++)
    {
        int ret1 = dp[i-1]+abs(ar[i]-ar[i-1]);
        int ret2 = INT_MAX;
        if(i-2>=0)
            ret2 = dp[i-2]+abs(ar[i]-ar[i-2]);
        dp[i] = min(ret1,ret2);
    }

    cout << dp[n-1] << endl;
    return 0;

}


Measured memory_bytes: 4336
#include<iostream>;
#include<vector>;
using namespace std;
int main(){
  vector<int> a={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int K;
  cin>>K;
  cout<<a.at(K-1);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
typedef long long lint;

// ソート済みの配列 vs に対して, from 以上 to 未満の数値の数を求める
int calc(int from, int to, const vector<int>& vs) {
    auto start = lower_bound(vs.begin(), vs.end(), from);
    auto end = lower_bound(vs.begin(), vs.end(), to);
    return end - start;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    int ans = 0;
    for (int k = 0; k < 30; k++) {
        vector<int> as(N), bs(N);
        for (int i = 0; i < N; i++) {
            as[i] = A[i] % (1<<(k+1));
            bs[i] = B[i] % (1<<(k+1));
        }
        sort(bs.begin(), bs.end());
        lint cnt = 0;
        for (int i = 0; i < N; i++) {
            cnt += calc((1<<k) - as[i], 2 * (1<<k) - as[i], bs);
            if (k < 29) cnt += calc(3 * (1<<k) - as[i], 4 * (1<<k) - as[i], bs);
        }
        ans |= (cnt%2)<<k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3428
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a[3];
    while (cin>>a[0]>>a[1]>>a[2]) {
        sort(a,a+3);
        cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    int ans0 = 0, ans1 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S.at(i) == '0') {
                ans1++;
            }
            else {
                ans0++;
            }
            continue;
        }
        if (S.at(i) == '0') {
            ans0++;
        }
        else {
            ans1++;
        }
    }
    int ans = min(ans0, ans1);
    cout << ans << endl;
}

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

int main() {
  int ac =0, wa=0, tle=0, re=0;
  int n;
  cin >>n;
  for (int i=0; i<n ; i++){
    string st;
    cin >> st;
    if(st == "AC") ac++;
    else if(st == "WA") wa++;
    else if(st == "TLE") tle++;
    else if(st == "RE") re++;
  }
  cout << "AC x ";
  cout << ac << endl;
  cout << "WA x ";
  cout << wa << endl;
  cout << "TLE x ";
  cout << tle << endl;
  cout << "RE x ";
  cout << re << endl;
}


Measured memory_bytes: 3632
arr = gets.chomp.split(' ')

class Stack
  attr_accessor :max, :stack, :top

  def initialize(size)
    @max = size
    @stack = Array.new(size)
    @top = 0
  end

  def pop
    @top -= 1
    return @stack[@top + 1]
  end

  def push(x)
    @top += 1
    @stack[@top] = x
  end

  def isEmpty
    return @top == 0
  end

  def isFull
    return @top >= @max - 1
  end
end

s = Stack.new(1000)
arr.each do |obj|
  if obj == '+'
    a = s.pop
    b = s.pop
    s.push(b + a)
  elsif obj == '-'
    a = s.pop
    b = s.pop
    s.push(b - a)
  elsif obj == '*'
    a = s.pop
    b = s.pop
    s.push(b * a)
  else
    s.push(obj.to_i)
  end
end

print "#{s.stack[s.top]}\n"



Measured memory_bytes: 6876
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 300005
#define LL long long
int a[N],b[N],T[N];LL ans[N],sum;
int main()
{
	int n,i,j,t;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	sort(b+1,b+n+1);
	for(t=1,j=1;t<=n;t++){
		while(j<=n&&b[j]<=t){
			sum+=1ll*b[j];
			j++;
		}
		ans[t]=sum+1ll*(n-j+1)*t;
	}
	for(t=1,i=n;i>=1;i--){
		while(t<=n&&ans[t]>=t*i)
			t++;
		T[i]=t-1;
	}
	for(i=1;i<=n;i++)
		printf("%d\n",T[i]);
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
	int a;
	cin>>a;
	string s;
	cin>>s;
	int b=0;
	int c=0;
	int N=s.size();
	for(int i=0; i<N; i++){
		if(s.at(i)=='R'){
			b++;
		}
		else{
			c++;
		}
	}
	
	if(b>c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
        P[i]--;
    }
    vector<int> idx(N);
    rep(i, N) idx[P[i]] = i;

    set<int> s;
    ll ans = 0;
    for(int x = N - 1; x >= 0; x--) {
        int i = idx[x];
        ll c = 0;
        s.insert(i);
        vector<int> l(2, -1);
        { // l
            auto it = s.find(i);
            rep(j, 2) {
                if(it == s.begin()) break;
                it--;
                l[j] = *it;
            }
        }
        vector<int> r(2, N);
        { // r
            auto it = s.find(i);
            rep(j, 2) {
                it++;
                if(it == s.end()) break;
                r[j] = *it;
            }
        }
        vector<int> ls(2);
        ls[0] = i - l[0];
        ls[1] = l[0] - l[1];
        vector<int> rs(2);
        rs[0] = r[0] - i;
        rs[1] = r[1] - r[0];
        c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];

        ans += c * (x + 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1LL << 62;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int> X(N),Y(N);
    for(int i = 0;i < N;i++)cin >> X[i] >> Y[i];
    ll mins = INF;
    for(int i = 0;i < N;i++)for(int j = 0;j < N;j++)for(int k = 0;k < N;k++)for(int l = 0;l < N;l++){
        if(i == j || j == k || k == l || l == i)continue;
        int maxx = max({X[i],X[j],X[k],X[l]}), minx = min({X[i],X[j],X[k],X[l]});
        int maxy = max({Y[i],Y[j],Y[k],Y[l]}), miny = min({Y[i],Y[j],Y[k],Y[l]});
        ll dx = maxx - minx, dy = maxy - miny;
        int cnt = 0;
        for(int m = 0;m < N;m++){
            if((X[m] >= minx) && (X[m] <= maxx) && (Y[m] >= miny) && (Y[m] <= maxy)){
                cnt++;
            }
        }
        if(cnt >= K)mins = min(mins,dx * dy);
    }
    cout << mins << endl;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll k; gi(k);
	__int128_t c = 100; int t = 0;
	while(c < k) {
		c = (c * 101) / 100;
		t++;
	}
	print(t);
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int x[n];
    int firstp = 1000000000;
    for(int i=0;i<n;i++){
        cin >> x[i];
        if(firstp == 1000000000&&x[i]>=0){
            firstp = i;
        }
    }
    if(firstp == 1000000000){
        firstp = n;
    }
    long long ans = 1000000000;
    for(int i=max(firstp-k,0);i<=min(n-k,firstp);i++){
        if(x[i] <0 && x[i+k-1]>0){
            if(abs(x[i])*2+x[i+k-1] <ans){
                ans = abs(x[i])*2+x[i+k-1];
            }
            if(abs(x[i])+x[i+k-1]*2<ans){
                ans = abs(x[i])+x[i+k-1]*2;
            }
        }
        else if(x[i+k-1]<=0){
            if(abs(x[i]) < ans){
                ans = abs(x[i]);
            }
        }
        else{
            if(x[i+k-1] < ans){
                ans = x[i+k-1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int n;
pair<double, double> a[200000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
	double lb = -1, ub = -1;
	sort(a, a + n);
	if(n % 2 == 1) lb = a[n / 2].first;
	else lb = (a[n / 2].first + a[n / 2 - 1].first) / 2;
	for(int i = 0; i < n; i++) a[i].first = a[i].second;
	sort(a, a + n);
	if(n % 2 == 1) ub = a[n / 2].first;
	else ub = (a[n / 2].first + a[n / 2 - 1].first) / 2; 
	if(n % 2 == 1) cout << (long long)(ub - lb + 1) << "\n";
	else cout << (long long)(ub * 2 - lb * 2 + 1) << "\n";
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> p(N + 1);
	vector<int> q(N + 1);
	for (int i = 1; i <= N; ++i)
	{
		cin >> p[i];
		q[i] = p[i];
	}
	std::sort(q.begin(), q.end());
	int counter = 0;
	for (int i = 1; i <= N; ++i)
	{
		if (p[i] == q[i])
		{

		}
		else
		{
			counter += 1;
		}
	}
	if (counter == 2 || counter == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
using System;

public class Hello{
    public static void Main(){
        string[] str =Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        if(a > b){
            Console.WriteLine("a > b");
        }
        if(a < b){
            Console.WriteLine("a < b");
        }
        if(a == b){
            Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 15952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int r[10];
int a[30000];
int b[30000];
int c[30000];

int n;
vector<pair<int,int>> ad[210];
int lis[210][210];

int dij(int i, int j){
    int d[210];
    int prev[210];
    rep(k,210){
        d[k]=INF;
    }
    d[i]=0;
    rep(k,210){
        prev[k] = -1;
    }
    prev[i]=i;
    set<int> st;
    rep(i,n){
        st.insert(i);
    }

    while(!st.empty()){
        int mi = INF;
        int u;
        //stの中でd[u]が最大のuを拾ってくる
        auto itr = st.begin();
        rep(t,st.size()){
            int tmp = *itr;
            if(mi>d[tmp]){
                mi = d[tmp];
                u = tmp;
            }
            itr++;
        }

        st.erase(u);
        auto v=ad[u];
        rep(k,v.size()){
            auto p=v[k];
            int node = p.first;
            int dis = p.second;
            if(d[node]>d[u]+dis){
                d[node]=d[u]+dis;
                prev[node]=u;
            }
        }
    }

    return d[j];

}

void solve(){

    int N,M,R;
    cin >> N >> M >> R;
    n = N;
    rep(i,R){
        int tmp;
        cin >> tmp;
        tmp--;
        r[i]=tmp;
    }
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        ad[a].emplace_back(make_pair(b,c));
        ad[b].emplace_back(make_pair(a,c));
    }
    int ans = INF;

    rep(i,R){
        rep(j,R){
            lis[r[i]][r[j]] = dij(r[i],r[j]);
        }
    }


    vector<int> one_case;
    for (int i = 0; i < R; i++) { // one_case = {0,1,2,3,...n-1} とする
        one_case.emplace_back(i);
    }

    //cout << dij(0,2) << " " << dij(0,1) << endl;
 
    do {
        int tmp = 0;

        /*
        for (auto num : one_case) {
            cout << num << ", ";
        }
        cout << "\n";
        */

        for(int i=0; i<R-1; i++){
            tmp += lis[r[one_case[i]]][r[one_case[i+1]]];
            //cout << dij(one_case[r[i]],one_case[r[i+1]]) << endl;
        }
        ans = min(ans,tmp);
    } while (next_permutation(one_case.begin(), one_case.end()));
    // 順列の最後になるまで one_case を並び替えながらループ

    cout << ans << endl;


}

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


Measured memory_bytes: 768
#include <iostream>
#include <map>

using namespace std;

const char lef[] = {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
const char rig[] = {'y','u','i','o','p','h','j','k','l','n','m'};
const int num_l = 15;
const int num_r = 11;

int main()
{
    string s;

    map<char, bool> qwe;
    for (int i = 0; i < num_l; i++)
        qwe[lef[i]] = true;
    for (int i = 0; i < num_r; i++)
        qwe[rig[i]] = false;

    while (cin >> s, s != "#") {
        int cnt = 0;

        for (int i = 0; i < s.size() - 1; i++) {
            if (qwe[s[i]] ^ qwe[s[i + 1]])
                cnt++;
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
using System;
using System.Linq;
using System.Text;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var output = new StringBuilder();
            for (var input = string.Empty; (input = Console.ReadLine()) != "#";) {
                var lines = input.Split('/');
                var board = Enumerable.Range(0, lines.Length)
                    .Select(i =>
                        string.Join("b",
                            lines[i]
                                .Split('b')
                                .Select(q => new String('.', string.IsNullOrEmpty(q) ? 0 : int.Parse(q)))
                                .ToArray())
                        .ToCharArray())
                    .ToArray();

                var command = Console.ReadLine().Split().Select(q => int.Parse(q) - 1).ToArray();
                board[command[0]][command[1]] = '.';
                board[command[2]][command[3]] = 'b';

                for (int i = 0; i < lines.Length; ++i) {
                    for (int j = 0; j < board[i].Length;) {
                        var block = board[i].Skip(j).TakeWhile(c => c == board[i][j]).ToArray();
                        j += block.Length;
                        output.Append(block.First() == '.' ? block.Length.ToString() : new string(block));
                    }

                    output.Append('/');
                }

                output.Length -= 1;
                output.AppendLine();
            }

            Console.Write(output.ToString());
        }
    }
}



Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
 
char s[200005];
vector<int> ci[26];
bool u[200005];
int n, fw[200005];

void add(int i) {
  u[i++] = true;
  while(i<=n) {
    fw[i]++;
    i += i&-i;
  }
}

int qu(int i) {
  i++;
  int ret = 0;
  while(i) {
    ret += fw[i];
    i -= i&-i;
  }
  return ret;
}
 
int main() {
  scanf("%s",s);
  for(;s[n];n++)
    ci[s[n]-'a'].push_back(n);
  int odd=0;
  for(int i=0;i<26;i++)
    if(ci[i].size()&1) odd++;
  if(odd != (n&1)) {
    puts("-1");
    return 0;
  }
  long long ans = 0;
  int r = n-1, tr = n-1, ct = -1;
 
  for(int i=0;i<=r;i++) {
    if(u[i]) continue;
    u[i] = true;
    int ii = s[i]-'a';
    int j = ci[ii].back();
    ci[ii].pop_back();
    if(i == j) {
      ct = i;
      continue;
    }
    int jj = j-qu(j);
    ans += tr - jj;
    add(j);
    while(u[r]) r--;
    tr--;
    if(j<ct) ans++;
  }
  if(ct>=0) {
    ans += abs(n/2-(ct-qu(ct)));
  }
  printf("%lld\n",ans);
}



Measured memory_bytes: 2168
num = int(input())
guide = [[i for i in input().split()] for j in range(0, num)]
dic = 1
for i in range(0, len(guide)):
    guide[i][1] = int(guide[i][1])
    guide[i].append(dic)
    dic += 1
guide.sort(reverse=True, key=lambda x: x[1])
guide_book = sorted(guide, key=lambda x: x[0])

for i in range(0, len(guide)):
    print(guide_book[i][2])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;

int main() {
  int n,k;cin >> n>>k;
  int cnt = k;
  for(int i=1;i<n;++i) cnt *= k-1;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
s = (stdin.readline().rstrip())
l = 0
r = 1
ans = 0

for i in range(len(s)):

    if l+r > len(s):
        break

    if s[l] == s[-r]:
        l += 1
        r += 1

    elif s[l] == "x" and s[-r] != "x":
        ans += 1
        l += 1

    elif s[l] != "x" and s[-r] == "x":
        ans += 1
        r += 1

    else:
        ans = -1
        break

print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define int long long

const int md = 1000000007;

int n, k;
int a[2010];

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int an = 0;
    for(int i = 0; i < n; i++){
        int cur = 0;
        for(int j = i + 1; j < n; j++){
            if(a[i] > a[j]){
                ++cur;
            }
        }
        an += cur * ((k * (k+1) / 2) % md);
        an %= md;
        cur = 0;
        for(int j = 0; j < i; j++){
            if(a[i] > a[j]){
                ++cur;
            }
        }
        an += cur * (((k-1) * k / 2) % md);
        an %= md;
    }
    cout << an << endl;
    return 0;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint
{
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return 0 - a; }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

// 0: なにもない
// 1: Aの数
// 2: ABの数
// 3: ABCの数
mint dp[4][100005];

void solve()
{
  string s;
  cin >> s;
  int N = s.size();
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 4; j++) {
      if (s[i] == '?') {
        dp[j][i + 1] += dp[j][i] * 3;
      } else {
        dp[j][i + 1] += dp[j][i];
      }
    }
    if (s[i] == 'A' || s[i] == '?') {
      dp[1][i + 1] += dp[0][i];
    }
    if (s[i] == 'B' || s[i] == '?') {
      dp[2][i + 1] += dp[1][i];
    }
    if (s[i] == 'C' || s[i] == '?') {
      dp[3][i + 1] += dp[2][i];
    }
  }
  cout << dp[3][N] << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    vector<int> per(N);
    for (int i = 0; i < N; i++) per[i] = i;
    double sum = 0;

    do {
        for (int i = 0; i < N -1; i++) sum += sqrt((x[per[i]] - x[per[i + 1]]) * (x[per[i]] - x[per[i + 1]]) + (y[per[i]] - y[per[i + 1]]) * (y[per[i]] - y[per[i + 1]]));
    } while (next_permutation(per.begin(), per.end()));

    double prod = 1;
    for (int i = 1; i <= N; i++) {
        prod *= i;
    }
    cout << setprecision(10) << sum / prod << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int t = in.nextInt();
        int s = in.nextInt();
        System.out.println((s*t>=d)?("Yes"):("No"));
       
    }
}


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

using namespace std;

int n, a[100005], ans[100005];

int main () {
  cin >> n;
  for (int i = 1;i <= n;i ++) cin >> a[i];
  for (int i = 1;i <= n;i ++) ans[a[i]] = i;
  for (int i = 1;i <= n;i ++) cout << ans[i] << ' ';
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    double ans = 0;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        double a;
        cin >> a;
        ans += (1.0/a);
    }
    cout << fixed << setprecision(5) << (1.0/ans);
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N, K;
    ll ans = 0;
    cin >> N >> K;
    vector<int> price(N, 0);
    rep(i, N) {
        int p;
        cin >> p;
        price[i] = p;
    }
    sort(price.begin(), price.end());
    rep(i, K) {
        ans += price[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


# BEGIN CUT HERE
MOD = 10**9 + 7


class Modint():
    '''
        自動でMODで割った余りを返してくれる。
    '''

    def __init__(self, n, mod=MOD):
        if n >= 0:
            self.n = n % mod
        else:
            self.n = (mod - (-n) % mod) % mod
        self.mod = mod

    def __eq__(self, other):
        return self.n == int(other)

    def __ne__(self, other):
        return not self == other

    def __neg__(self):
        return Modint(-self.n, self.mod)

    def __str__(self):
        return str(self.n)

    def __int__(self):
        return int(self.n)

    def __iadd__(self, other):
        self.n += int(other)
        self.n %= self.mod
        return self

    def __radd__(self, other):
        self.n += int(other)
        self.n %= self.mod
        return self

    def __isub__(self, other):
        self.n -= int(other)
        self.n %= self.mod
        return self

    def __rsub__(self, other):
        self.n -= int(other)
        self.n %= self.mod
        return self

    def __imul__(self, other):
        self.n = self.n * int(other) % self.mod
        return self

    def __rmul__(self, other):
        self.n = self.n * int(other) % self.mod
        return self

    def inverse(self):
        return self.__class__(pow(self.n, self.mod - 2, self.mod), self.mod)

    def __ifloordiv__(self, other):
        self *= pow(int(other), self.mod - 2, self.mod)
        return self

    def __rfloordiv__(self, other):
        self *= pow(int(other), self.mod - 2, self.mod)
        return self

    def __add__(self, other):
        self += other
        return self

    def __sub__(self, other):
        self -= other
        return self

    def __mul__(self, other):
        self *= other
        return self

    def __floordiv__(self, other):
        self //= other
        return self

    '''コンビネーション絡みの定義
        ･ comb(n,k):特に前処理をせずnCkを求める
    '''

    def comb(self, n, k):
        if n < k or k < 0:
            return Modint(0)
        res = Modint(1)
        for i in range(int(k)):
            res *= Modint(n - i)
            res //= Modint(i + 1)
        return res

    def H(self, n, k):
        if n < 0 or k < 0:
            return Modint(0)
        elif n == 0 and k == 0:
            return Modint(1)
        else:
            return self.comb(n + k - 1, n)


if __name__ == '__main__':
    N, K = mi()
    res = Modint(0)
    for i in range(1, K + 1):
        print(res.comb(K - 1, i - 1) * res.H(N - K - i + 1, i + 1))


Measured memory_bytes: 48488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> people[100010];
vector<int> lang[100010];
bool used[100010];
bool usedlang[100010];
void change(int k) {
  used[k] = 1;
  for (int i = 0; i < people[k].size(); i++) {
    int lg = people[k][i];
    if (usedlang[lg]) continue;
    usedlang[lg] = 1;
    for (int j = 0; j < lang[lg].size(); j++) {
      if (!used[lang[lg][j]]) {
        change(lang[lg][j]);
      }
    }
  }

}
int main(){
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int l;
      cin >> l;
      people[i].push_back(l);
      lang[l].push_back(i);
    }
  }
  change(1);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	std::string s; cin >> s;
	a--; b--;
	
	bool ans = true;
	for(int i = a + 1; i < c - 2; i++) if(s.substr(i, 2) == "##") ans = false;
	for(int i = b + 1; i < d - 2; i++) if(s.substr(i, 2) == "##") ans = false;
	
	if(d < c) {
		bool f = true;
		for(int i = b - 1; i < d - 1; i++) {
			if(s.substr(i, 3) == "...") f = false;
		}
		if(f) ans = false;
	}
	
	if(ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == 'R') r++;
    }
    ll ans = 0;
    for(int i = 0; i < r; i++) {
        if(S[i] != 'R') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780