akhauriyash/Code-Regression huggingface dataset:
N, K = map(eval, input().split())
candy = []

for i in range(K):
    input()
    candy.append(list(map(eval, input().split())))

result = 0

for i in range(1, N+1):
    for j in range(K):
        if i in candy[j]:
            break
    else:
        result += 1

print(result)

Measured memory_bytes: 9104
#include <iostream>
#include<iomanip>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int one_count = 0;
    int nine_count = 0;
    int seven_count = 0;
    int four_count = 0;
    int N[4];
    for(int i = 0; i < 4; i++){
        cin >> N[i];
    }
    for(int i = 0; i < 4; i++){
        if(N[i] == 1){
            one_count ++;
        }
        if(N[i] == 9){
            nine_count++;
        }
        if(N[i] == 7){
            seven_count ++;
        }
        if(N[i] == 4){
            four_count ++;
        }
    }
    if(one_count == 1 && nine_count == 1 && seven_count == 1 && four_count == 1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()

isEasy = True

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            isEasy = False
            break
    else:
        if S[i] == "R":
            isEasy = False
            break
if isEasy:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;
string str;

int main(){
	cin >> n;
    cout << 180*(n-2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll         long long
#define IOS         ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define FOR(i,n)     for(ll i=0;i<n;i++)
#define REP(i,k,n)  for(ll i=k;i<n;i++)
#define nl         "\n"
#define BUFFER         cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define SORT        sort(a,a+n);
#define mod         1000000007
#define pb          push_back

int main()
{
    ll n,cnt=0;
    cin>>n;
    ll a[n];
    FOR(i,n)
    cin>>a[i];
    sort(a,a+n);
    FOR(i,n)
    {
        REP(j,i+1,n)
        {
            for(ll k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k])
                cnt++;
                else
                break;
            }
        }
    }
    cout<<cnt;
return 0;
}


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

#define lint long long


lint MOD = 1000000007;

class Combination_mod{
public:
    Combination_mod(lint mod);
    lint power_mod(lint a, lint p);
    lint div_mod(lint A, lint B);
    lint combi_mod(lint n, lint k);
    
private:
    lint mod;
    vector<lint> power_2; //2の累乗のリスト
};

Combination_mod::Combination_mod(lint MOD){
    mod = MOD; //mod の初期化
}

//a^pを計算する
lint Combination_mod::power_mod(lint a, lint p){
    a %= mod;
    
    if(p == 1){
        return a;
    }
    
    if(p >= mod){
        return 0;
    }
    
    if(p % 2 == 0){
        lint tmp = power_mod(a, p / 2);
        return (tmp * tmp) % mod;
    } else {
        return (power_mod(a, p - 1) * a) % mod;
    }
}

lint Combination_mod::div_mod(lint A, lint B){
    A %= mod; B %= mod;
    lint ans;
    lint inv_B;
    inv_B = power_mod(B, mod - 2);
    ans = (A * inv_B) % mod;
    return ans;
}

lint Combination_mod::combi_mod(lint n, lint k){
    lint ans;
    lint div = 1;
    lint num = 1;
    if(k < 0) return 0;
    if(k == 0) return 1;
    
    for(lint i = 1; i <= k; ++i){
        div = (div * i) % mod;
    }
    
    for(lint i = n - k + 1; i <= n; ++i){
        num = (num * i) % mod;
    }
    
    ans = div_mod(num, div);
    return ans;
}


int main(){
    lint N, K;
    cin >> N >> K;
    

    
    Combination_mod CM(MOD);
    
    for(int i = 1; i <= K; ++i){
        lint Blue;
        Blue = CM.combi_mod(K - 1, i - 1);
        //cout << Blue << " ";
        
        lint Red = 0;
        for(int j = -1; j < 2; ++j){
            Red += CM.combi_mod(N - K - 1, i - j - 1) * (j == 0 ? 2 : 1);
            
            //cout << CM.combi_mod(N - K - 1, i - j - 1) << " ";
            Red %= MOD;
        }
        
        
        cout << ((Blue * Red) % MOD) << endl;
    }

    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int n, m;
	cin >> n >> m;
	priority_queue<ll>a;
	ll temp = 0;
	rep0(i, n) {
		cin >> temp;
		a.push(temp);
	}
	rep0(j, m) {
		temp = a.top();
		temp /= 2;
		a.pop();
		a.push(temp);

	}
	temp = 0;
	while(!a.empty()) {
		temp += a.top();
		a.pop();
	}
	cout << temp << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
//右端が1番左の物を選ぶ区間スケジュール問題
//終了時間が早ければ早いほど、後に選べるロボットの数がおおくなる
int main(){
    cin>>n;
    vector<pair<int,int>> pii(n);
    for(int i = 0;i < n; i++){
        int x;
        cin>>x;
        int ll;
        cin>>ll;
        int l=x-ll,r=x+ll;
        pii[i].first=r;
        pii[i].second=l;
    }
    sort(pii.begin(),pii.end());
    int cnt=0;
    int right=-inf-10;
    //bool first=1;
    for(int i=0;i<n;i++){
        //if(first){
        //    right=u.first;
        //    first=0;
        //}
        //else{
            //cout<<"aaa"<<endl;
            //cout<<"right "<<right<<endl;
            //cout<<u.second<<" "<<u.first<<endl;
            if(pii[i].second>=right){
                cnt++;
                right=pii[i].first;
            } 
        //}
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 10000
#define NIL -1
  
struct node { int p, l, r; };
struct node T[MAX];
int n;
  
void preparse(int u) {
   if (u == NIL) return;
   printf(" %d", u);
   preparse(T[u].l);
   preparse(T[u].r);
}
  
void inparse(int u) {
   if (u == NIL) return;
   inparse(T[u].l);
   printf(" %d", u);
   inparse(T[u].r);
}
  
void postparse(int u) {
   if (u == NIL) return;
   postparse(T[u].l);
   postparse(T[u].r);
   printf(" %d", u);
}
  
int main() {
   int i, v, l, r, root;
  
   scanf("%d", &n);
   for (i = 0; i < n; i++) {
      T[i].p = NIL;
    }
  
   for (i = 0; i < n; i++) {
      scanf("%d %d %d", &v, &l, &r);
  
      T[v].l = l;
      T[v].r = r;
  
      if (l != NIL) T[l].p = v;
      if (r != NIL) T[r].p = v;
   }
  
   for ( i = 0; i < n; i++ )
      if ( T[i].p == NIL ) 
         root = i;
  
   printf("Preorder\n");
   preparse(root);
   printf("\n");
  
   printf("Inorder\n");
   inparse(root);
   printf("\n");
  
   printf("Postorder\n");
   postparse(root);
   printf("\n");
  
   return 0;
}

Measured memory_bytes: 1856
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    LL int a,b,c,ans;

    cin >> a >> b >> c;

    if(((a%2) * (b%2) * (c%2)) % 2 == 0)ans = 0;
    else{
        if(a < b)swap(a,b);
        if(a < c)swap(a,c);
        if(b != 0 && c != 0)ans = b * c;
        else ans = a * b * c;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
  int A,B,K;
  cin>>K>>A>>B;
  bool ans=false;
  for(int i=A;i<=B;i++){
    if(i%K==0){
      ans=true;
    }
  }
  if(ans){
    cout<<"OK";
  }else{
    cout<<"NG";
  }
}

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

long long gcd(long long a, long long b){
	while(a%b>0){
		long long g = a%b;
		a = b;
		b = g;
	}
	return b;
}

int main() {
	int n;
	cin>>n;
	long long num;
	long long multi=1;
	for (int i=0; i<n; i++){
		cin >> num;
		long long g = gcd(multi,num);
		multi = multi/g*num;
	}
	cout << multi << endl;
}


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

int min_cost(int N, vector<int> vec){
  int ans = 9000000;
  sort(vec.begin(), vec.end());
  for(int j = vec.at(0); j <= vec.at(vec.size()-1); j++){
    int cost = 0;
    for(int i = 0; i < N; i++){
      cost += (vec.at(i)-j)*(vec.at(i)-j);
    }
    if(cost < ans) ans = cost;
  }
  return ans;
}
 
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  int ans = min_cost(n, vec);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

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

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    ll g = gcd(n, m);
    string s, t;cin >> s >> t;
    bool ok = true;
    ll sp = 0, tp = 0;
    for(; sp < n; sp += n / g){
        ok &= s[sp] == t[tp];
        tp += m / g;
    }

    if(ok)cout << n * (m / g) << "\n";
    else cout << -1 << "\n";
}

Measured memory_bytes: 3788
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);

    let mut ans_grid = vec![vec![false; 100]; 100];
    for i in 50..100 {
        for j in 0..100 {
            ans_grid[i][j] = true;
        }
    }
    let mut count = 1; // already one connected exists.
    'outer: for i in 0..50 {
        if i % 2 == 1 {
            continue;
        }
        for j in 0..100 {
            if j % 2 == 1 {
                continue;
            }
            if count == b {
                break;
            }
            ans_grid[i][j] = !ans_grid[i][j];
            count += 1;
        }
    }
    let mut count = 1; // already one connected exists.
    'outer: for i in 51..100 {
        if i % 2 == 1 {
            continue;
        }
        for j in 0..100 {
            if j % 2 == 1 {
                continue;
            }
            if count == a {
                break;
            }
            ans_grid[i][j] = !ans_grid[i][j];
            count += 1;
        }
    }
    println!("100 100");
    for ref column in ans_grid.iter() {
        for &mass in column.iter() {
            if mass {
                print!("#");
            } else {
                print!(".");
            }
        }
        println!("");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(){
    int h, w;  cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++) cin >> a[i][j];
    }
    
    for(int i=-1; i<=h; i++){
        if(i==-1 || i == h){
           for(int j=0; j<=w+1; j++) printf("#");
           printf("\n"); 
        }else{
            printf("#");
            rep(j,w) printf("%c",a.at(i).at(j));
            printf("#\n");
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;
	if(s.length()&1)s.POB();
	else {
		s.POB();s.POB();}
	while(s.length()>0) {
		if(s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length()/2)) {
			cout<<s.length();
			return;
		}
		s.POB();s.POB();
	}
	cout<<0;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3656
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;
 

void solveCase() {
   int a, b;
   cin >> a >> b;
   if(a > 0) {
      cout << "Positive" << endl;
   } else if(b < 0) {
      if((b - a + 1) % 2)
         cout << "Negative" << endl;
      else cout << "Positive" << endl;
   } else {
      cout << "Zero" << endl;
   }
}
 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

Measured memory_bytes: 3628
a, b , c, d = list(map(int, input().strip().split()))
lst = []
lstt = []
for i in range(a, b + 1):
    lst.append(i)

for i in range(c, d+1):
    lstt.append(i)

one = set(lst)
two = set(lstt)

inter = one & two
if len(inter)-1 > 0:
    print(len(inter)-1)
else:
    print(0)

Measured memory_bytes: 3064
//
// Created by wulang on 10/10/16.
//

#include <iostream>
#include <algorithm>
using namespace std;

void solve();
int main(int argc, char *argv[]) {
    if (argc == 2) {
        freopen(argv[1], "r", stdin);
    }
    solve();
    return 0;
}

const string s="CODEFESTIVAL2016";
void solve() {
    string ss;
    cin>>ss;

    int ans=0;
    for(int i=0;i<ss.size();i++) {
        ans+=(ss[i]!=s[i]);
    }
    cout<<ans<<endl;
}

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

int main(int argc, char *argv[]) {
  string S;
  cin >> S;
  int countx = 0;
  for (auto s : S) {
    if (s == 'x') {
      countx++;
    }
  }

  if (countx <= 7) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }

  return 0;
}



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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define int ll

int32_t main(){
    FAST
    int a, b; cin >> a >> b;
    map<int, bool> has;
    for(int i = 2; i*i <= a; i++){
        if(a%i == 0)has[i] = 1;
        while(a%i == 0){
            a /= i;
        }
    }
    if(a != 1){
        has[a] = 1;
    }
    int ans = 1;
    for(int i = 2; i*i <= b; i++){
        if(b%i == 0){
            if(has[i])ans++;
        }
        while(b%i == 0){
            b /= i;
        }
    }
    if(b != 1){
        if(has[b])ans++;
    }
    cout << ans;
    return 0;
}


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

void printvec(vector<int> A)
{
  for(int i = 0; i < A.size() - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[A.size() - 1] << endl;
}

void BubbleSort(vector<int> A){
  int count = 0;
  int flag = 1;
  while(flag){
    flag = 0;
    for(int j = A.size() - 1; j >= 1; j--){
      if(A[j] < A[j - 1]){count++; swap(A[j], A[j - 1]); flag = 1;}
    }
  }
  printvec(A);
  cout << count << endl;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  BubbleSort(A);
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>

using namespace std;

const double EPS = 1e-7;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }
};
double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
double norm(const Point& a) { return sqrt(dot(a, a)); }
Point rot90(const Point& p) { return Point(p.y, -p.x); } // 時計回りに90度回転 
ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;
    if (cross(b, c) > EPS) return +1;      // a,b,cの順に反時計周り
    if (cross(b, c) < -EPS) return -1;     // a,b,cの順に時計周り
    if (dot(b, c) < 0) return +2;          // c--a--b 直線
    if (norm(b) < norm(c)) return -2;      // a--b--c 直線
    return 0;                              // a--c--b 直線
}

struct Line {
    Point a, b;
    Line() {}
    Line(const Point& a, const Point& b) : a(a), b(b) {}
};
bool contains(const Line& l, const Point& p) { return ccw(l.a, l.b, p) % 2 == 0; }
bool parallel(const Line& s, const Line& t) { return abs(cross(s.b - s.a, t.b - t.a)) < EPS; }
bool orthogonal(const Line& s, const Line& t) { return abs(dot(s.b - s.a, t.b - t.a)) < EPS; }
bool equals(const Line& s, const Line& t) { return parallel(s, t) && contains(s, t.a); }
istream& operator>>(istream& is, Line& l) { return is >> l.a >> l.b; }

Point projection(const Line& l, const Point& p) {
    Point u = (p - l.a), v = (l.b - l.a);
    return l.a + (v / norm(v)) * (dot(u, v) / norm(v));
}

struct Segment {
    Point a, b;
    Segment() {}
    Segment(const Point& a, const Point& b) : a(a), b(b) {}
};
istream& operator>>(istream& is, Segment& l) { return is >> l.a >> l.b; }
bool intersects(const Segment& s, const Segment& t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
double dist(const Segment& s, const Point& p) {
    Point q = projection(Line(s.a, s.b), p);
    Segment t(p, q);
    if (intersects(s, t)) return norm(t.b - t.a);
    return min(norm(s.a - p), norm(s.b - p));
}
double dist(const Segment& s, const Segment& t) {
    if (intersects(s, t)) return 0;
    return min( min(dist(s, t.a), dist(s, t.b)),
                min(dist(t, s.a), dist(t, s.b)) );
}

int main() {
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        Segment s, t; cin >> s >> t;
        cout << fixed << setprecision(12) << dist(s, t) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int a, b;

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> a >> b;
    if (a <= b) {
        cout << a << endl;
    } else {
        cout << a-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> V(N);
    rep(i,N) cin >> V[i];
    int M = min(N,K);
    long long res = 0;
    rep(i,M+1){
        rep(j,M+1){
            //cout << i << " " << j << " ";
            long long sum = 0;
            vector<int> Z;
            if(i+j > M) continue;
            for(int k = 0;k<i;k++){
                sum+=V[k]; 
                if(V[k] < 0) Z.emplace_back(V[k]);
            }
            //cout << sum << " ";
            for(int k = N-1;N-1-j<k;k--){
                sum+=V[k];
                if(V[k] < 0) Z.emplace_back(V[k]);
            }
            //cout << sum << " ";
            if(K-i-j > 0){
                sort(Z.begin(),Z.end());
                rep(k,min(K-i-j,(int)Z.size())){
                    sum -= Z[k];
                }
            }
            //cout << sum << endl;
            res = max(res,sum);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli n,m;
bool ok;
string s;
bool vis[100100];

void func(lli now){
	if(DEBUG)cout<<"now="<<now<<endl;
	if(now>n)return;
	if(now==n){
		ok=true;
		return;
	}
	if(s.at(now)=='1')return;
	if(vis[now])return;
	vis[now]=true;

	for(lli i=m;i>0;i--){
		func(now+i);
		if(ok){
			cout<<i<<" ";
			return;
		}
	}
}

signed main(){

	cin>>n>>m;
	cin>>s;

	reverse(s.begin(),s.end());

	func(0);
	if(!ok){
		cout<<-1<<endl;
		return 0 ;
	}

	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
int v,n;
int freq[2][N] = {0}, maxm[2][2], maxi[2][2];

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    FOR(i, 0, n) {
    	cin>>v;
    	freq[i%2][v]++;
    }
    memset(maxm, -1, sizeof(maxm));
    memset(maxi, -1, sizeof(maxi));
	FOR(i, 0, 2) {
		FOR(j, 0, N) {
			if(freq[i][j] > maxm[i][0]) {
				maxm[i][1] = maxm[i][0];
				maxi[i][1] = maxi[i][0];
				maxm[i][0] = freq[i][j];
				maxi[i][0] = j;
			} else if(freq[i][j] > maxm[i][1]) {
				maxm[i][1] = freq[i][j];
				maxi[i][1] = j;
			}
		}
	}

	int ans = 2*N;
	if(maxi[0][0] != maxi[1][0]) {
		ans = n - maxm[0][0] - maxm[1][0];
	} else {
		ans = min(n - maxm[0][0] - maxm[1][1], n - maxm[0][1] - maxm[1][0]);
	}
	cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
# include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int findGCD(int arr[], int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;cin >> a;
    int arr[3];
    int sum = 0;
    for(int i = 1;i <= a;i++)
    {
        arr[0] = i;
        for(int j = 1;j <= a;j++)
        {
            arr[1] = j;
            for(int k = 1;k <= a;k++)
            {
                arr[2] = k;
                sum += findGCD(arr,3);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3616
import sys

sys.setrecursionlimit(200000)
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

def tdfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        distt[to] = distt[x] + 1
        tdfs(to, x)

def adfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        dista[to] = dista[x] + 1
        adfs(to, x)

tdfs(u)
adfs(v)
ans = 0

for i in range(1, n+1):
    if distt[i] >= dista[i]:continue
    l = distt[i]
    k = dista[i] - distt[i]
    ans = max(ans, k - 1 + l)

print(ans)

Measured memory_bytes: 117040
#include <bits/stdc++.h>
using namespace std;
 
#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll sum[N];
ll mod = 1e9 + 7;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n, k;
        cin >> n >> k;
        for (int i = 1; i <= (n + 1); i++){
                sum[i] = (sum[i - 1] + (i - 1)) % mod;
        }
        ll ans = 0;
        for (int i = k; i <= (n + 1); i++){
                ans += (sum[n + 1] - sum[n + 1 - i]) - (sum[i] - 1) + mod * mod;
                ans %= mod;
        }
        cout << ans;
}

Measured memory_bytes: 5196
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    map<int,int> count;
    for(int i = A; i <= B; i++) count[i]++;
    for(int j = C; j <= D; j++) count[j]++;
    int m = 0;
    for(auto p : count){
        if(p.se == 2) m++;
    }
    cout << max(m - 1, 0) << endl;
}


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

int main() {
	long long int n;
	cin>>n;
	long long int a;
	if(n%2!=0){
	    a=2*n;
	    cout<<a;
	}
	else{
	    cout<<n;
	}
}

Measured memory_bytes: 256
from collections import deque

S = deque(input())
Q = int(input())
N = len(S)

flag = 0
for i in range(Q):
	q = list(map(str, input().split()))
	if q[0] == '1':
		flag = 1 - flag
	else:
		if (q[1] == '1' and flag == 1) or (q[1] == '2' and flag == 0):
			S.append(q[2])
		else:
			S.appendleft(q[2])
if flag == 1:
	S.reverse()
ans = ''.join(S)
print(ans)

Measured memory_bytes: 75480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define MOD ll(1e9+7)

int main() {
    int n;
    cin >> n;
    string s1,s2;
    cin >> s1;
    cin >> s2;
    vector<int> dir;
    dir.push_back(0);
    for(int i = 0; i < s1.size()-1; i++){
        if(s1[i]==s2[i]){dir.push_back(1);}
        else{
            dir.push_back(2);
            i++;
        }
    }
    if(s1[s1.size()-1]==s2[s1.size()-1]){dir.push_back(1);}
    ll ans = 1;
    for(int i = 0; i < dir.size()-1; i++){
        if(dir[i] == 0 && dir[i+1] == 1)        {ans = ans * 3LL % MOD;}
        else if(dir[i] == 0 && dir[i+1] == 2)   {ans = ans * 6LL % MOD;}
        else if(dir[i] == 1)                    {ans = ans * 2LL % MOD;}
        else if(dir[i] == 2 && dir[i+1] == 1)   {ans = ans * 1LL % MOD;}
        else if(dir[i] == 2 && dir[i+1] == 2)   {ans = ans * 3LL % MOD;}
    }
    cout << ans << endl;

    return 0;
}


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

int s[1010];

int main(){
	int n;
	while(true) {
		int ave = 0;
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			ave += s[i];
		}
		double m = (double)ave / n;
		double ss = 0;
		for(int i = 0; i < n; i++)
			ss += (s[i] - m) * (s[i] - m);
		printf("%.12lf\n", sqrt(ss / n));
	}
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

ll countdigits(ll n){
  ll cnt=0;
  while(n){
    n=n/10;
    cnt++;
  }
  return cnt;
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,ans=0;
  cin>>n;
  forn(i,1,n+1){
    ll a=countdigits(i);
    if(a%2==1) ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a[][]=new int[3][3];
boolean v[][]=new boolean[3][3];
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
a[i][j]=sc.nextInt();
}
}
int t =sc.nextInt();
while(t-->0)
{
int n =sc.nextInt();
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(a[i][j]==n)
v[i][j]=true;
}
} 
}
if((v[0][0] && v[0][1] && v[0][2]) || (v[1][0] && v[1][1] && v[1][2]) || (v[2][0] && v[2][1] && v[2][2]) || (v[0][0] && v[1][0] && v[2][0]) || (v[0][1] && v[1][1] && v[2][1]) || (v[0][2] && v[1][2] && v[2][2]) || (v[0][0] && v[1][1] && v[2][2]) || (v[0][2] && v[1][1] && v[2][0]))
System.out.println("Yes");
else
System.out.println("No");
}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
const ll INF = 1LL<<60;

int main()
{
  ll a,b;cin>>a>>b;
  if(a>b){
    ll tmp=a;a=b;b=tmp;
  }
  string ans="";
  ostringstream oss;
  oss<<a;
  for(ll i=0;i<b;i++)ans+=oss.str();
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll N;
    cin>>N;
    vector<ll> v(N);
    ll sum=0;
    for(ll i=0;i<N;i++){
        cin>>v[i];
    }
    sum+=abs(v[0]-0);
    for(ll i=0;i<N;i++){
        if(i==N-1){
            sum+=abs(v[i]-0);
        }else{
            sum+=abs(v[i]-v[i+1]);
        }
    }
 
    for(ll i=0;i<N;i++){
        ll ba,fo;
        if(i==0){
            ba=0;
            fo=v[i+1];
        }else if(i==N-1){
            ba=v[i-1];
            fo=0;
        }else{
            ba=v[i-1];
            fo=v[i+1];
        }
        if((v[i]-ba>=0 && fo-v[i]>=0)||(ba-v[i]>=0 && v[i]-fo>=0)){
            cout<<sum<<endl;
        }else{
            ll tmp=abs(v[i]-fo)+abs(v[i]-ba);
            ll tmp2=abs(fo-ba);
            cout<<sum-(tmp-tmp2)<<endl;
        }
    }
        
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int sum = 0;
  rep(i,n)rep(j,n){
    if(i==j)continue;
    sum += a[i]*a[j];
  }
  cout << sum/2 << endl;
  
         
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, b, c;
  int kawaisou = 0;
  
  scanf("%d %d %d", &a, &b, &c);
  
  if(a == b && b != c) {
    kawaisou = 1;
  }else if(b == c && a != b) {
    kawaisou = 1;
  }else if(a == c && a != b) {
    kawaisou = 1;
  }
  if(kawaisou == 1) {
    printf("Yes");
  }else{
    printf("No");
  }
   return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Control.Applicative
import Data.List

-- String, Int, Char, IO

-- e.g.
-- 1
-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'


getPair :: IO (Int, Int)
getPair = do
  [a, b] <- map read . words <$> getLine
  return (a, b)


main :: IO()
main = do
  n <- readLn :: IO Int
  lst <- replicateM n getPair
  print $ foldl (\n -> \(a, b) -> b-a+1 + n) 0 lst

  


Measured memory_bytes: 1404
s = input()
t = input()

maxLength = [[0 for i in range(len(s)+2)] for j in range(len(t)+2)] # index_s, index_t

for i_t in range(1,len(t)+1) :
	for i_s in range(1,len(s)+1) :
		if s[i_s-1] == t[i_t-1] :
			maxLength[i_t][i_s] = max(maxLength[i_t-1][i_s-1] + 1, maxLength[i_t][i_s])
		maxLength[i_t+1][i_s] = max(maxLength[i_t+1][i_s], maxLength[i_t][i_s])
		maxLength[i_t][i_s+1] = max(maxLength[i_t][i_s+1],maxLength[i_t][i_s])

str = ''
i, j = len(t), len(s)

while( i > 0 and j > 0) :
	if maxLength[i][j] == maxLength[i-1][j] :
		i -= 1

	elif maxLength[i][j] == maxLength[i][j-1] :
		j -= 1

	else :
		str = s[j-1] + str # (j + 1)文字目
		i -= 1
		j -= 1

print(str)

Measured memory_bytes: 120136
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main( ) {
	// your code goes here
     ll t,i,j,n,m,k=0;
      
     	cin>>n;
     	if(n>=400 && n<=599)cout<<8;
     	else if(n>=600 && n<=799) cout<<7;
     	else if(n>=800 && n<=999) cout<<6;
     	else if(n>=1000 && n<=1199) cout<<5;
     	else if(n>=1200 && n<=1399)cout<<4;
     	else if(n>=1400 && n<=1599) cout<<3;
     	else if(n>=1600 && n<=1799)cout<<2;
     	else if(n>=1800 && n<=1999) cout<<1;
	  
	return 0;
}



Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<sstream>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#include<stdlib.h>
#include<time.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
vector<long long> Prime;
void SieveOfEratosthenes(long long e) //setup vector<long long>Prime(~x)
{
	bool *x=new bool[e];
	for (long long i = 0; i <= e; i++)x[i] = false;
	for (long long i = 2; i <= e; i++)
	{
		if (x[i]);
		else
		{
			Prime.push_back(i);
			for (long long l = i; l <= e; l += i)x[l] = true;
		}
	}
	return;
}
int StringToInt(string a)
{
	stringstream ss;
	int x;
	ss << a;
	ss >> x;
	return x;
}
string IntToString(int a)
{
	stringstream ss;
	string x;
	ss << a;
	ss >> x;
	return x;
}
int GetRandom(int MIN, int MAX)
{
	static int flag=0;
	if (flag == 0)
	{
		srand((unsigned int)time(NULL));
		flag = 1;
	}
	return MIN + (int)(rand()*(MAX - MIN + 1.0) / (1.0 + RAND_MAX));
}
int in()
{
	int x;
	cin >> x;
	return x;
}
void outl(string a)
{
	cout << a << endl;
	return;
}
void outl(int a)
{
	cout << a << endl;
	return;
}
void out(string a)
{
	cout << a;
	return;
}
void out(int a)
{
	cout << a;
	return;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
 (char)A=(int)65
 (char)a=(int)97
*/
////////////////////////////////////////////////////
vector<char> al;

int main()
{
	
	rep(i, 26)
	{
		al.push_back(i + 97);
	}
	rep(i, 26)
	{
		al.push_back(i + 65);
	}
	while(al.size()<1000)rep(i, 52)al.push_back(al[i]);
	int n;
	while (cin >> n&&n)
	{
		int r, l;
		vector<int> a;
		string b;
		rep(i,n)a.push_back(in());
		while(a.size()<150)rep(i, n)a.push_back(a[i]);
		cin >> b;
		b += "a";
		
		for (int i = 0; i < b.size()-1; i++)
		{
			for (r = 0;; r++)if (al[r] == b[i])break;
			cout << al[r - a[i] + 312];
		}
		
		cout << endl;

	
		
	}


}

Measured memory_bytes: 1228
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#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 <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

int main() {
  double L;
  cin >> L;
  cout << fixed << setprecision(15) << L*L*L/27;
}

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

int main(){
	string s,t;
	cin >> s >> t;
       if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
        	cout << "YES" << endl;
 	else
        	 cout << "NO" << endl;	
  return 0;

}





Measured memory_bytes: 256
import std.algorithm, std.array, std.conv, std.exception, std.stdio, std.string;
void main()
{
    auto cond = readln.chomp.split.map!(to!int);
    immutable n = cond[0], h = cond[1];
    int[] a, b;
    foreach (i; 0..n)
    {
        auto buf = readln.chomp.split.map!(to!int);
        a ~= buf[0];
        b ~= buf[1];
    }
    solve(h, a, b).writeln;
}
auto solve(int h, int[] _as, int[] _bs)
{
    auto a = _as.reduce!max;
    int answer;
    foreach (b; _bs.sort!((x, y) => x > y).filter!(b => a < b))
    {
        h -= b;
        answer += 1;
        if (h <= 0)
            return answer;
    }
    return answer + h.divceil(a);
}
auto divceil(int numerator, int denominator)
{
    return numerator / denominator + !!(numerator % denominator);
}


Measured memory_bytes: 4476
A, B = map(int, input().split())

def check_ans(num):
  first = [i for i in str(num)]
  if first[4] == 0:
  	return 0
  elif first[0] == first[4] and first[1] == first[3]:
    return 1
  else:
    return 0

count = 0
for i in range(A, B+1):
  count += check_ans(i)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) {
    cin >> A[i];
  }
  i64 S =0 ;
  rep(i,0,N) {
    S ^= A[i];
  }
  rep(i,0,N) {
    cout <<  (S ^ A[i]) << " \n"[i + 1 == N];
  }
}



Measured memory_bytes: 4832
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

def P(n, r):
	return math.factorial(n)//math.factorial(n-r)

def C(n, r):
	return P(n, r)//math.factorial(r)

N,A,B = inpl()
vv = inpl()
vv.sort()

ave = sum(vv[N-A:])/A
print(ave)

MIN = vv[N-A]
SUM = vv.count(MIN)
used = vv[N-A:].count(MIN)

if vv[-1] != vv[N-A]:
	used = vv[N-A:].count(MIN)
	print(C(SUM,used))
else:
	ans = 0
	for i in range(A,min(SUM,B)+1):
		ans += C(SUM,i)
	print(ans)


Measured memory_bytes: 4204
def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0138.txt")
  end

  rec=[]
  while fh.gets do
    f = $_.chomp.split
    id=f[0].to_i
    tm=f[1].to_f
    rec.push([id, tm])
  end
  ans=[]
  g1=rec[0..7].sort{|a,b| a[1]<=>b[1]}
  g2=rec[8..15].sort{|a,b| a[1]<=>b[1]}
  g3=rec[16..23].sort{|a,b| a[1]<=>b[1]}
  ans = g1.take(2) + g2.take(2) + g3.take(2) + (g1.drop(2) + g2.drop(2) + g3.drop(2)).sort{|a,b| a[1]<=>b[1]}.take(2)
  ans.each{|id,tm| printf("%d %.2f\n", id, tm)}

end

if $0==__FILE__ then
  main
end

Measured memory_bytes: 8692
n = int(input())
arr = list(map(int, input().split()))
res, i, j = 0, 0, 0
while j < n-1:
    i = j
    while i < n-1 and arr[i] >= arr[i+1]:
        i += 1
    res = max(res, i-j)
    j = i+1
print(res)


Measured memory_bytes: 63984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main(){
   int k,s;scanf("%d %d",&k,&s);
   int x,y,z;
   int ans=0;
   for(int i = 0;i < k+1;i++){
      for(int j = 0;j < k+1;j++){
         x = i;
         y = j;
         z = s-i-j;
         if(0 <= z && z <= k){
            ans++;
            //printf("%d %d %d\n",x,y,z);
         }
      }
   }
   printf("%d",ans);
}

Measured memory_bytes: 128
from collections import Counter

N = int(input())

A = [int(x) for x in input().split()]
T = sum(A)
Z = Counter(A)

Q = int(input())

for _ in range(Q):
  B,C = map(int,input().split())
  x = Z[B]
  y = Z[C]
  Z.pop(B,0)
  Z[C] = x+y
  T = T-(B*x)+(C*x)
  print(T)

  

Measured memory_bytes: 23988
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      char c=s[i];
      for(int j=0;j<s.size();j++){
        if(j<i){
          if(t[i]==s[j]){
            cout<<"No";
            return 0;
          }
        }
        if(s[j]==c){
          s[j]=t[i];
        }else if(s[j]==t[i]){
          s[j]=c;
        }
      }
    }
  }
  cout<<(s==t?"Yes":"No");
}

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

int main(){
    int k,n;
    cin>>n>>k;
    long long t[n],d[n];
    vector<pair<long long,long long>> v;
    for(int i=0;i<n;i++){
        cin>>t[i]>>d[i];
        t[i]--;
        v.push_back(make_pair(d[i],t[i]));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    long long ans=0,kind=0,cnt[n]={};
    vector<int> p;
    int ccc=0;

    for(int i=0;i<k;i++){
        ans+=v[i].first;
        if(cnt[v[i].second]==0) kind++;
        else {
            p.push_back(i);
        }
        cnt[v[i].second]++;
    }

    reverse(p.begin(),p.end());
    ans+=kind*kind;

    long long res=ans;
    int c=0;
    for(auto i:v){
        if(cnt[i.second]==0){
            res+=i.first - v[p[c]].first;
            res+=(kind+1)*(kind+1) - kind*kind;
            kind++;
            c++;
            cnt[i.second]++;
            ans=max(ans,res);
        }
        if(kind==k) break;
    }

    cout<<ans;

}

Measured memory_bytes: 4592