akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x1: f64 = read();
    let y1: f64 = read();
    let x2: f64 = read();
    let y2: f64 = read();
    println!("{}", ((x1 - x2).powf(2.0) + (y1 - y2).powf(2.0)).sqrt());
}



Measured memory_bytes: 5072
n,m=map(int,input().split())
l1=[list(input().split()) for i in range(m)]
l2=["WA"]*n
l3=[0]*n
account=0
wacount=0
for i in range(m):
  if l1[i][1]=="WA" and l2[int(l1[i][0])-1]=="WA":
    wacount+=1
    l3[int(l1[i][0])-1]+=1
  if l1[i][1]=="AC":
    l2[int(l1[i][0])-1]="AC"

for i in range(n):
  if l2[i]=="AC":
    account+=1
  else:
    wacount-=l3[i]
print(account,wacount)

Measured memory_bytes: 27468
#include <iostream>

int N, A, B, C, D;
std::string s;

bool approachable(int start, int end) {
    for  (int i=start; i<end; ++i) {
        if (s[i] == '#' && s[i+1] == '#') return false;
    }
    return true;
}

void solve() {
    s = '#' + s + '#';
    bool yesno = true, takeover = false;
    if ( !approachable(A, C) || !approachable(B, D) ) yesno = false;

    if ( C > D ) {
        for (int i=B; i<=D; ++i) {
            if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') takeover = true;
        }
        yesno &= takeover;
    }

    std::cout << (yesno ? "Yes" : "No") << std::endl;

}


int main() {
    std::cin >> N >> A >> B >> C >> D;
    std::cin >> s;

    solve();

    return 0;
}



Measured memory_bytes: 772
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, w[101000], P[101000], m, TP[101000], R[101000];
long long K, bb;
void Do(int *a, int *b){
    int i;
    for(i=1;i<=n;i++){
        TP[i] = a[b[i]];
    }
    for(i=1;i<=n;i++)a[i] = TP[i];
}
int main(){
    int i, a;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
    }
    bb = w[1];
    n--;
    for(i=1;i<=n;i++)w[i] = w[i+1]-w[i];
    for(i=1;i<=n;i++)P[i] = R[i] = i;
    scanf("%d%lld",&m,&K);
    while(m--){
        scanf("%d",&a);
        swap(P[a],P[a-1]);
    }
    while(K){
        if(K%2){
            Do(R,P);
        }
        Do(P,P);
        K/=2;
    }
    printf("%lld\n",bb);
    for(i=1;i<=n;i++){
        bb += w[R[i]];
        printf("%lld\n",bb);
    }
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int f(string s, string t) {
    if(s == t) return -1;
    s += t;
    if(count(ALL(s), 'A') == 2) return 0;
    if(count(ALL(s), 'B') == 2) return 1;
    return 2;
}

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

    int n, a[3];
    cin >> n >> a[0] >> a[1] >> a[2];
    string s[100009];
    int nxt[100009]{};
    rep(i, n) cin >> s[i];

    nxt[n - 1] = (s[n - 1][0] != 'A');

    FORR(i, n - 1)
    if(!~(nxt[i] = f(s[i], s[i + 1]))) nxt[i] = nxt[i + 1];

    vector<char> ans;
    rep(i, n) {
        if(s[i] == "AB") {
            int x = 1 - nxt[i];
            if(a[0] + a[1] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(a[x]) {
                a[x]--;
                a[nxt[i]]++;
                ans.push_back(nxt[i] + 'A');
            } else {
                a[nxt[i]]--;
                a[x]++;
                ans.push_back(x + 'A');
            }
        }
        if(s[i] == "AC") {
            int x = 2 - nxt[i];
            if(a[0] + a[2] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(a[x]) {
                a[x]--;
                a[nxt[i]]++;
                ans.push_back(nxt[i] + 'A');
            } else {
                a[nxt[i]]--;
                a[x]++;
                ans.push_back(x + 'A');
            }
        }
        if(s[i] == "BC") {
            int x = 3 - nxt[i];
            if(a[1] + a[2] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(a[x]) {
                a[x]--;
                a[nxt[i]]++;
                ans.push_back(nxt[i] + 'A');
            } else {
                a[nxt[i]]--;
                a[x]++;
                ans.push_back(x + 'A');
            }
        }
    }

    cout << "Yes" << endl;
    for(char c : ans)
        cout << c << endl;

    return 0;
}

Measured memory_bytes: 7308
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int n, pos;
int pre[40], in[40], post[40], pre_to_in[40], in_to_pre[40];
bool pre_used[40];

inline void to_post(int pre_root, int num) {

//    printf("[to_post] pre_root = %d, num = %d\n", pre_root, num);

    int in_root = pre_to_in[pre_root], left_tree_node_num = 0;

    // whether pre_root has a left tree or not. 
    if (in_root - 1 >= 0 && !pre_used[in_to_pre[in_root - 1]]) {
        pre_used[pre_root + 1] = true;
        int i = pre_to_in[pre_root + 1];    // in-left root
        while (--i >= 0 && !pre_used[in_to_pre[i]])
            ++left_tree_node_num;
        i = pre_to_in[pre_root + 1];
        while (++i < n && !pre_used[in_to_pre[i]])
            ++left_tree_node_num;
        ++left_tree_node_num;
        to_post(pre_root + 1, in_to_pre[in_root - 1] - pre_root);
    }

    // whether pre_root has a right tree or not. 
    if (in_root + 1 < n && !pre_used[in_to_pre[in_root + 1]]) {
        int pre_right_root = pre_root + left_tree_node_num + 1;
        pre_used[pre_right_root] = true;
        to_post(pre_right_root, num - left_tree_node_num);
    }

    post[pos++] = pre[pre_root];
}

int main(void) {

    scanf("%d", &n);

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

    for (int i = 0; i < n; ++i) {
        scanf("%d", &in[i]);
        for (int j = 0; j < n; ++j) {
            if (pre[j] == in[i]) {
                pre_to_in[j] = i;
                in_to_pre[i] = j;
            }
        }
    }

    pre_used[0] = true;
    to_post(0, n);

    printf("%d", post[0]);
    for (int i = 1; i < n; ++i) {
        printf(" %d", post[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n, m;
ll lb, ub, aa[100010], bb[100010];
vector<vector<pi>> e;

void dfs(int c, int a, ll b){ // xc = ax0 + b
	aa[c] = a;
	bb[c] = b;
	
	for(pi i : e[c]){
		ll a2 = -a, b2 = i.second - b;
		
		if(a2 > 0){
			lb = max(lb, 1 - b2);
		}
		else{
			ub = min(ub, b2 - 1);
		}
		
		if(!aa[i.first]) dfs(i.first, a2, b2);
		else{
			if(aa[i.first] != a2){
				if(abs(b2 - bb[i.first]) % abs(aa[i.first] - a2)){
					cout << 0 << endl;
					exit(0);
				}
				lb = max(lb, (b2 - bb[i.first]) / (aa[i.first] - a2));
				ub = min(ub, (b2 - bb[i.first]) / (aa[i.first] - a2));
			}
			else{
				if(bb[i.first] != b2) {
					cout << 0 << endl;
					exit(0);
				}
			}
		}
	}
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n >> m;
	e.resize(n);
	rep(i, m){
		int a, b, c; cin >> a >> b >> c; a--; b--;
		e[a].emplace_back(b, c);
		e[b].emplace_back(a, c);
	}
	lb = 1; ub = 1e18;
	dfs(0, 1, 0);
	
	if(lb > ub) cout << 0 << endl;
	else cout << ub - lb + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){

	queue <string> data;
	string str;

	while(cin>>str){
		int i;
		if(str.find("hoge",0)==0){
			break;
		}
		if( (i=str.find("apple",0))>-1){
			str.replace(i,5,"peach");
		}
		else if( (i=str.find("peach",0))>-1){
			str.replace(i,5,"apple");
		}
		
		data.push(str);
		
	}
	int num = data.size();
	for(int i=0;i<num-1;i++){
		cout<<data.front();
		data.pop();
		cout<<" ";
	}
	cout<<data.front()<<endl;

	return 0;

}

/*
Sample Input
the cost of one peach is higher than that of one apple.
Output for the Sample Input
the cost of one apple is higher than that of one peach.
*/

Measured memory_bytes: 1192
R,G,B,n=map(int,input().split())
def cou(R,G,B,n):
    c=0
    for i in range(n+1):
        r=R*i
        if r>n:
            break
        for j in range(n+1):
            g=G*j
            if r+g>n:
                break
            b=n-r-g
            if b%B==0:
                c+=1
    return c
print(cou(R,G,B,n))


Measured memory_bytes: 3060
use std::io::stdin;

fn read_line() -> Vec<String> {
    let mut line = String::new();
    stdin().read_line(&mut line).expect("Failed to read line");
    return line.trim().split_whitespace().map(|s| s.to_string()).collect();
}

struct Reader {
    v: Vec<String>,
    n: usize,
}

impl Reader {
    fn new() -> Reader {
        let v = read_line();
        return Reader { v: v, n: 0 };
    }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() {
            self.v = read_line();
            self.n = 0;
        }
        let x = self.v[self.n].parse().unwrap();
        self.n += 1;
        return x;
    }
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            v.push(self.next());
        }
        return v;
    }
}

fn main() {
    let mut r = Reader::new();
    let n: usize = r.next();
    let k: usize = r.next();
    let q: usize = r.next();
    let a: Vec<i64> = r.nexts(n);

    let mut ai: Vec<(&i64, usize)> = a.iter().enumerate()
        .map(|(i, x)| (x, i)).collect();
    ai.sort();

    let mut ok: Vec<bool> = vec![true; n];
    let mut ans = 1e15_f64 as i64;
    for i in 0..n {
        let mut mins: Vec<i64> = Vec::new();
        let mut ms: Vec<i64> = Vec::new();
        for j in 0..n {
            if !ok[j] {
                if ms.len() >= k {
                    ms.sort();
                    mins.extend_from_slice(&ms[0..ms.len()-k+1]);
                }
                ms.clear();
            } else {
                ms.push(a[j]);
            }
        }
        if ms.len() >= k {
            ms.sort();
            mins.extend_from_slice(&ms[0..ms.len()-k+1]);
        }
        if mins.len() < q {
            break;
        }
        mins.sort();
        ans = std::cmp::min(ans, mins[q-1]-mins[0]);
        ok[ai[i].1] = false;
        //println!("{} {:?} {}", i, mins, ans);
    }

    println!("{:?}", ans);
}


Measured memory_bytes: 4352
/*
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>
*/

#include <iostream>
#include <cmath>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

LL primecheck(LL x) {

	LL ret = 1;

	if (x == 1 || x == 2) {
		return ret;
	}

	for (LL j = 2; j < sqrt(x) + 1; j++) {
		if (x % j == 0) {
			ret = 0;
			break;
		}
	}

	return ret;

}

int main(int argc, const char * argv[]) {

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

	LL X, N, cnt = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> X;
		cnt += primecheck(X);

	}

	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 3168
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

void solve()
{
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

	int z = MAX(x, y);
	int i;
	ll ans = LINF;
	for (i = 0; i <= z; i++) {
		ll tmp = i * 2 * c + a * MAX(0, x - i) + b * MAX(0, y - i);
		ans = MIN(ans, tmp);
	}
	printf("%lld\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF (1LL << 60)

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

	long long n, m, l, i, j, k, a, b, c, s, t, q;
	cin >> n >> m >> l;
	vector<vector<long long>> d(n + 1, vector<long long>(n + 1, INF));
	vector<vector<long long>> dd(n + 1, vector<long long>(n + 1, INF));

	for (i = 0; i < m; i++) {
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}

	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (i == j) dd[i][j] = 0;
			else if (d[i][j] <= l) dd[i][j] = 1;

	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
	}

	cin >> q;
	while (q--) {
		cin >> s >> t;
		if (dd[s][t] == INF) cout << "-1\n";
		else cout << dd[s][t] - 1 << "\n";
	}


	return 0;
}


Measured memory_bytes: 1920
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

template <class T>
struct MP {
  int n;
  vector<int> a;
  T t;

  MP(const T& arr) {
    n = arr.size();
    a = vector<int>(n + 1);
    t = arr;

    a[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
      while (j >= 0 && t[j] != t[i]) j = a[j];
      j++;
      a[i + 1] = j;
    }
  }

  set<int> findAll(const T& s) {

    set<int> res;
    int j = 0;
    for (int i = 0; i < s.size(); i++) {
      while (j >= 0 && t[j] != s[i]) j = a[j];
      j++;
      if (j == n) {
        res.insert(i - j + 1);
        j = a[j];
      }
    }
    return res;
  }
};

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

  string s, t;
  cin >> s >> t;

  // |S| = |s| + |t|

  string S;
  S.reserve(s.size() + t.size());
  while(S.size() < s.size() + t.size()) {
    S += s;
  }

  MP mp(t);
  auto fa = mp.findAll(S);
  //Print(fa);
  int result = 0;
  if (!fa.size()) {
    result = 0;
  }
  else {
    while (fa.size()) {
      int start = *fa.begin(), next, streak = 1;

      if (start >= s.size()) break;

      fa.erase(fa.begin());
      next = start;
      while(true) {
        next += t.size();
        next %= s.size();
        if (next == start) {
          cout << -1;
          return 0;
        }
        if (fa.find(next) == fa.end()) {
          break;
        }
        ++streak;
        fa.erase(next);
      }
      next = start;
      while (true) {
        next -= t.size();
        next = (next + s.size()) % s.size();
        if (fa.find(next) == fa.end()) {
          break;
        }
        ++streak;
        fa.erase(next);
      }

      chmax(result, streak);
    }
  }

  cout << result;
}
#endif


Measured memory_bytes: 54896
import random

class Dice():
    def __init__(self, number):
        self.number = number

    def S(self):
        temp = self.number
        self.number = [temp[4], temp[0], temp[2], temp[3], temp[5], temp[1]]

    def N(self):
        temp = self.number
        self.number = [temp[1], temp[5], temp[2], temp[3], temp[0], temp[4]]

    def E(self):
        temp = self.number
        self.number = [temp[3], temp[1], temp[0], temp[5], temp[4], temp[2]]

    def W(self):
        temp = self.number
        self.number = [temp[2], temp[1], temp[5], temp[0], temp[4], temp[3]]

    def order(self, str):
        for ch in str:
            if ch == "S":
                self.S()
            elif ch == "N":
                self.N()
            elif ch == "E":
                self.E()
            else:
                self.W()

    def query(self, top, front):
        while True:
            drc = random.randint(0, 3)
            self.order("NEWS"[drc])
            if self.number[0] == top and self.number[1] == front:
                break

number1 = list(map(int, input().split()))
number2 = list(map(int, input().split()))

dice1 = Dice(number1)
dice2 = Dice(number2)

dice1.query(dice2.number[0], dice2.number[1])
if dice1.number == dice2.number:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 8188
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split())) 
C = list(map(int,input().split()))
D = []
for i in range(N-1):
  if A[i+1] - A[i] ==1:
    D.append(C[A[i]-1])

print(sum(B)+sum(D))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
//#define int long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
  	string str;
  cin >> str;
  if(str=="SAT") cout << 1;
  if(str=="SUN") cout << 7;
  if(str=="MON") cout << 6;
  if(str=="TUE") cout << 5;
  if(str=="WED") cout << 4;
    if(str=="THU") cout << 3;
  if(str=="FRI") cout << 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x/11 * 2;
  x %= 11;
  if(x == 0){
  }else if(x <= 6){
    ans++;
  }else{
    ans += 2;
  }
  cout << ans << endl;
  return 0;
}

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

const int maxn = 505;
int qs[maxn][maxn];

int n, m;
int main()
{
	int q; 
	scanf("%d %d %d", &n, &m, &q);
	while(m--)
	{
		int u, v; scanf("%d %d", &u, &v);
		qs[u][v]++;
	}
	for(int i = n; i>= 1; i--)
	{
		for(int j = 1; j<= n; j++)
		{
			qs[i][j] += qs[i+1][j];
			qs[i][j] += qs[i][j-1];
			qs[i][j] -= qs[i+1][j-1];
		}
	}
	while(q--)
	{
		int u, v; scanf("%d %d", &u, &v);
		printf("%d\n", qs[u][v]);
	}
}

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

using LL = long long int;

class Solution {
private:
    bool checkVanishable(int N, LL A, LL B, const vector<LL> &hs, int K) {
        LL C = A - B;
        LL sum = 0;
        for(auto h : hs) {
            LL hi = h - K * B;
            if(hi > 0) {
                sum += hi / C;
                sum += hi % C > 0;
            }
        }
        return sum <= K;
    }
public:
    LL solve(int N, LL A, LL B, const vector<LL> &hs) {
        LL low = 0, high = numeric_limits<int>::max();
        while (low < high) {
            LL mid = (low + high) / 2;
            if(checkVanishable(N, A, B, hs, mid)) {
                high = mid;
            }
            else {
                low = mid + 1;
            }
        }
        return high;
    }
};

int main() {
    Solution s;
    int N;
    LL A, B;
    cin >> N >> A >> B;
    vector<LL> hs(N);
    for(auto &h : hs) {
        cin >> h;
    }
    cout << s.solve(N, A, B, hs) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<stack>
using namespace std;
struct data{
    int color,cnt;
    data(int a,int b){
        color=a;cnt=b;
    }
    data(){}
};
int main(){
    int n;
    while(cin>>n,n){
        int a;
        cin>>a;
        int lc=a,cnt=1;
        stack<data>S;
        for(int i=1;i<n;i++){
            cin>>a;
            if(lc==a){
                cnt++;
            }
            else{
                if(i&1){
                    if(!S.size()){
                        cnt++;
                    }
                    else{
                        data d=S.top();S.pop();
                        cnt+=d.cnt;
                        cnt++;
                    }
                }

                else{
                    S.push(data(lc,cnt));
                    cnt=1;
                }
                lc=a;
            }
            //cout<<i<<":"<<lc<<" "<<cnt<<endl;
        }
        S.push(data(lc,cnt));
        int sum=0;
        while(S.size()){
            data d=S.top();S.pop();
            //cout<<d.color<<" "<<d.cnt<<endl;
            if(d.color==0)sum+=d.cnt;
        }
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 1200
n, k = map(int, input().split())
a = list(map(int, input().split()))
right = 0
left = 0

for i in range(n):
    cnt_left = 0
    cnt_right = 0
    for j in range(n):
        if a[i] > a[j]:
            if i < j:
                cnt_right += 1
            elif i > j:
                cnt_left += 1
    right += cnt_right % (10 ** 9 + 7)
    left += cnt_left % (10 ** 9 + 7)
    cnt_right = 0
    cnt_left = 0

ans = ((right * k) % (10 ** 9 + 7)) + (right + left) * ((k * (k - 1) // 2) % (10 ** 9 + 7))
ans = ans  % (10 ** 9 + 7)

print(ans)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, K, S;

int main() {
	cin >> N >> K >> S;
	for (int i = 0; i < K; i++) {
		cout << S << sp;
	}
	for (int i = K; i < N; i++) {
		if (S == 1000000000) {
			cout << 1;
		}
		else {
			cout << 1000000000;
		}
		if (i != N - 1)cout << sp;
	}
	cout << endl;
}

Measured memory_bytes: 1280
def main():

    N  = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if (i+1) % 2 == 1 and a[i] % 2 == 1:
            ans += 1
    return ans

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 61932
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
const int mod=1e9+7;
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chadd(T1 &x,T2 b) {x+=b;if(x>=mod) x-=mod;};
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}

int main()
{
//	freopen("input.txt","r",stdin);
	char c;
	cin>>c;
	if(isupper(c)) cout<<"A"<<endl;
	else cout<<"a"<<endl;
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(c, b/a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0.0,double y = 0.0): x(x),y(y) {}
	Point operator + (Point p){
		return Point(x + p.x,y + p.y);
	}
	Point operator - (Point p){
		return Point(x - p.x,y - p.y);
	}
	Point operator * (double lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point &p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point &p)const
	{
		if(abs(x - p.x) < EPS) return y < p.y;
		else return x < p.x;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(Point p1 = Point(),Point p2 = Point()): p1(p1),p2(p2) {}
};
typedef Segment Line;
struct Circle{
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0): c(c),r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector a,Vector b){
	return a.x * b.x + a.y * b.y;
}
double det(Vector a,Vector b){
	return a.x * b.y - b.x * a.y;
}
bool vertical(Line l1,Line l2){
	return abs(dot(l1.p2 - l1.p1,l2.p2 - l2.p1)) < EPS;
}
bool parallel(Line l1,Line l2){
	return abs(det(l1.p2 - l1.p1,l2.p2 - l2.p1)) < EPS;
}
Point proj(Point p,Line l){
	Vector a = l.p2 - l.p1;
	double r = dot(a,p - l.p1) / a.norm();
	return l.p1 + a * r;
}
Point ref(Point p,Line l){
	Point A = proj(p,l);
	return A + (A - p);
}
int ccw(Segment/*Directed Segment*/ s,Point p){//
	Vector a = s.p2 - s.p1,b = p - s.p1;
	if(det(a,b) > EPS) return 1;
	else if(det(a,b) < -EPS) return -1;
	else if(dot(a,b) < -EPS) return 2;
	else if(a.norm() < b.norm() - EPS) return -2;
	else return 0;
}
bool intersect(Segment s1,Segment s2){
	return ccw(s1,s2.p1) * ccw(s1,s2.p2) <= 0 && ccw(s2,s1.p1) * ccw(s2,s1.p2) <= 0;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		Segment s1,s2;
		scanf("%lf%lf%lf%lf",&s1.p1.x,&s1.p1.y,&s1.p2.x,&s1.p2.y);
		scanf("%lf%lf%lf%lf",&s2.p1.x,&s2.p1.y,&s2.p2.x,&s2.p2.y);
		printf("%d\n",(int)intersect(s1,s2));
	}
	return 0;
}



Measured memory_bytes: 3252
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int n;
  cin >> n;
  
  map<int,int>mp;
  int a;
  REP(_,n){
    cin >> a;
    if(a > n-1){
      cout << "No" << endl;
      return 0;
    }
    mp[a]++;
  }
  
  if(mp.size() == 1){
    if(a <= n/2 || a == n-1) cout << "Yes" << endl;
    else		 cout << "No"  << endl;
    return 0;
  }
    
  
  auto itr = mp.begin();
  a = itr->fst;
  int num = itr->sec;
  itr++;
  
  if(mp.size() > 2 || itr->fst != a+1){
    cout << "No" << endl;
    return 0;
  }
  
  if(num <= a && a+1 <= num + itr->sec/2){
    cout << "Yes" << endl;
  }
  
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 6528
/// Zhamshitov
/// Rinat
/// Rahatovich
/// 8 "A";
///
#include <bits/stdc++.h>

using namespace std;


int main()

{
    int n, m, a;
    cin >> n >> m >> a;
    if(( m * 10 + a) % 4  == 0 )
        cout << "YES";
    else
        cout << "NO";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,d1,d2,n1,n2;
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	while(d1%(1<<(n1+1))==0)
  		n1++;
  	while(d2%(1<<(n2+1))==0)
	  	n2++;
  	int c=0;
 	for(int i=0;i<2*n&&c<n*n;i++){
    	for(int j=0;j<2*n&&c<n*n;j++){
      		if((n1%2==0?(i>>(n1/2))%2==(j>>(n1/2))%2:(i>>(n1/2))%2==0)
	 		   &&(n2%2==0?(i>>(n2/2))%2==(j>>(n2/2))%2:(i>>(n2/2))%2==0)){
				printf("%d %d\n",i,j);
				c++;
      		}
    	}
  	}
  	return 0;
}

Measured memory_bytes: 896
import numpy as np

def resolve():
    N, M = map(int, input().split())
    ACs = np.zeros(N)
    WAs = np.zeros(N)
    
    c_ac = 0
    c_wa = 0

    for i in range(M):
        p, s = input().split()
        if s == "WA":
            if ACs[int(p) - 1] == 0:
                WAs[int(p) - 1] += 1
        if s == "AC":
            ACs[int(p) - 1] += 1
            if ACs[int(p) - 1] == 1:
                c_ac += 1
                c_wa += WAs[int(p) - 1]

    print(int(c_ac), int(c_wa))
    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 21488
N = int(input())
A = input()
B = input()
C = input()
if A == B == C:
    print(0)
else:
    count = 0
    for a, b, c in zip(A,B,C):
        if a == b == c:
            pass
        elif a == b and not a==c:
            count += 1
        elif a ==c and not a == b:
            count += 1
        elif b == c and not a == b:
            count += 1
        else:
            count += 2
    print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		long h = sc.nextLong();
		long count=0;
		long r = 0;
		ArrayList<Long> b1=new ArrayList<Long>();
		for(int i = 0; i<n; i++){
			long a = sc.nextLong();
			long b = sc.nextLong();
			r=Math.max(r,a);
			b1.add(b);
		}
		Collections.sort(b1);
		for(int i=b1.size()-1; i>=0; i--){
			if(b1.get(i)<=r){
					break;
			}
			count++;
			h-=b1.get(i);
			if(h<=0){
				System.out.println(count);
				return;
			}
		}
			if(h%r==0){
				System.out.println(count+h/r);
			}else{
				System.out.println(count+h/r+1);
			}
	}
}

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

public class Main {
	public static void main(String[] args)throws IOException {
		int x,cal;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		x = Integer.parseInt(br.readLine());
		cal = x*x*x;

		System.out.println(cal);
	}
}

Measured memory_bytes: 24156
#include "bits/stdc++.h"
using namespace std;

int main(){
    long long N, bit[64] = {}, DP[65][6] = {}, ANS = 0, MOD = 1000000007;
    cin >> N;
    for (int i = 0; i < 64; i++) {
        bit[i] = N % 2;
        N /= 2;
    }
    DP[0][0] = 1;
    for (int i = 0; i < 64; i++) {
        long long Zero = (DP[i][0] + DP[i][1] + DP[i][2]) % MOD, One = (DP[i][3] + DP[i][4] + DP[i][5]) % MOD;
        for (int j = 0; j < 6; j++) {
            if (j % 2 == 0) DP[i + 1][j] = Zero;
            else DP[i + 1][j] = One;
        }
        if (bit[i] == 0) {
            DP[i + 1][1] = DP[i + 1][2] = DP[i + 1][5] = 0;
        }
        if (bit[i] == 1) {
            DP[i + 1][0] = DP[i + 1][3] = DP[i + 1][4] = 0;
        }
    }
    ANS += DP[64][0];
    for (int i = 0; i < 64; i++) {
        if (bit[i] == 0) {
            continue;
        }
        long long Now[64] = {};
        for (int j = 0; j <= 64; j++) {
            for (int k = 0; k < 6; k++) DP[j][k] = 0;
        }
        DP[0][0] = 1; 
        for (int j = 0; j < 64; j++) {
            if (j < i) Now[j] = 2;
            else if (j == i) Now[j] = 0;
            else Now[j] = bit[j];
        }
        for (int j = 0; j < 64; j++) {
            long long Zero = (DP[j][0] + DP[j][1] + DP[j][2]) % MOD, One = (DP[j][3] + DP[j][4] + DP[j][5]) % MOD;
            for (int k = 0; k < 6; k++) {
                if (k % 2 == 0) DP[j + 1][k] = Zero;
                else DP[j + 1][k] = One;
            }
            if (Now[j] == 0) {
                DP[j + 1][1] = DP[j + 1][2] = DP[j + 1][5] = 0;
            }
            if (Now[j] == 1) {
                DP[j + 1][0] = DP[j + 1][3] = DP[j + 1][4] = 0;
            }
        }
        ANS += DP[64][0];
        ANS %= MOD;
    }
    cout << ANS << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<Integer> L = new ArrayList<>(); 
        for(int i=0; i<N; i++){
            L.add(scanner.nextInt());
        }
        Collections.sort(L);
        //System.out.println(L);
        int count = 0;
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                int a = L.get(i);
                int b = L.get(j);
                int res = find(L, j+1, a+b);
                //System.out.println(String.format("%d", res));
                count = count + res;
            }
        }
        System.out.println(count);
    }

    public static int find(List<Integer> li, int from, int target){
        int low = from;
        int upp = li.size() - 1;
        int mid = (upp-low+1)%2==0 ? (low+upp)/2+1 : (low+upp)/2 ;
        //System.out.println(String.format("%d, %d, %d", low, upp, target));
        if(upp-low < 0){
            return 0;
        }else if(li.get(from) >= target){
            return 0;
        }else if(li.get(upp) < target){
            return upp - low + 1;
        }
        while(upp - low > 1){ 
            //System.out.println(li.get(mid));
            if(li.get(mid) >= target){
                upp = mid;
            }else{
                low = mid;
            }
            mid = (upp-low+1)%2==0 ? (low+upp)/2+1 : (low+upp)/2 ;
        }
        return low - from + 1;
    }
}

Measured memory_bytes: 27592
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
	string S;
	cin >> S;
	int len=S.size();
	int score=753;
	rep(i,len-2){
		int temp=stoi(S.substr(i,3));
		int score_temp=max(temp-753,753-temp);
		if(score_temp<score){
			score=score_temp;
		}
	}
	output(score,0);

    return 0;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b||a==c||b==c)&&(!(a==b&&b==c))){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
sb=[0]*(n+1)
db=[0]*(n+1)
for _ in range(m):
    s,d=map(int,input().split())
    if s==1:
        sb[d]=1
    if d==n:
        db[s]=1

for i in range(n):
    if sb[i]==1 and db[i]==1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Measured memory_bytes: 6132
#include<cstdio>
int numcheck[10000]={0};
using namespace std;
int main(){
    int num;
    double kg,m;
    int x = 0;
    while(scanf("%d,%lf,%lf",&num,&kg,&m)!=EOF){
        if(kg /(m*m) >= 25.0){
            numcheck[x] = num;
            x++;
        }
    }
    for(int i = 0;i < x; i++)printf("%d\n",numcheck[i]);
    return 0;
}

Measured memory_bytes: 1056
#include<iostream>
#include<string>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main(void) {
	char x; cin >> x;
	if (x == 'a' || x == 'i' || x == 'e' || x == 'u' || x == 'o')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

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

public class Main {

	static void sortBy(int a[], int n, int v[]) {
		if (n == 0) {
			return;
		}
		for (int i = 1; i < n; i++) {
			int j = i;
			int ca = a[i];
			int cv = v[ca];
			do {
				int nj = (j - 1) >> 1;
				int na = a[nj];
				if (cv <= v[na]) {
					break;
				}
				a[j] = na;
				j = nj;
			} while (j != 0);
			a[j] = ca;
		}
		int ca = a[0];
		for (int i = n - 1; i > 0; i--) {
			int j = 0;
			while ((j << 1) + 2 + Integer.MIN_VALUE < i + Integer.MIN_VALUE) {
				j <<= 1;
				j += (v[a[j + 2]] > v[a[j + 1]]) ? 2 : 1;
			}
			if ((j << 1) + 2 == i) {
				j = (j << 1) + 1;
			}
			int na = a[i];
			a[i] = ca;
			ca = na;
			int cv = v[ca];
			while (j != 0 && v[a[j]] < cv) {
				j = (j - 1) >> 1;
			}
			while (j != 0) {
				na = a[j];
				a[j] = ca;
				ca = na;
				j = (j - 1) >> 1;
			}
		}
		a[0] = ca;
	}

	static void solve() throws Exception {
		int n = scanInt();
		int l[] = new int[n], r[] = new int[n], idx[] = new int[n];
		int maxLen = 0, maxL = Integer.MIN_VALUE, minR = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			l[i] = scanInt();
			r[i] = scanInt();
			maxLen = max(maxLen, r[i] - l[i] + 1);
			maxL = max(maxL, l[i]);
			minR = min(minR, r[i]);
			idx[i] = i;
		}
		int ans = maxLen + max(minR - maxL + 1, 0);
		sortBy(idx, n, l);
		int r2 = Integer.MAX_VALUE;
		for (int i = n - 1; i > 0; i--) {
			r2 = min(r2, r[idx[i]]);
			int l2 = l[idx[i - 1]];
			if (l2 <= minR && maxL <= r2) {
				ans = max(ans, minR + r2 - maxL - l2 + 2);
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 43796
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
using pair = std::pair<std::pair<std::string, int>, int>;

int main(){
  int n;
  std::cin >> n;
  std::vector<pair> p;
  std::string stemp;
  int itemp;
  for(int i=0; i<n; ++i){
    std::cin >> stemp >> itemp;
    p.push_back(std::make_pair(std::make_pair(stemp, -itemp), i));
  }
  std::sort(p.begin(), p.end());
  for(auto i : p)
    std::cout << i.second+1 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import bisect

def main():
    N= int(input())
    red = [list(map(int,input().split())) for _ in range(N)]
    blue = [list(map(int,input().split())) for _ in range(N)]
    red.sort(key= lambda x:(x[0],x[1]))
    red_x = [r[0] for r in red]
    blue.sort(key= lambda x:x[0])
    answer = 0
    for i  in range(N):
        b = blue[i][0]
        max_x_index = bisect.bisect_left(red_x,b)
        search_target_red = red[:max_x_index]
        max_y = 0 
        max_index = -1

        for j,r in enumerate(search_target_red):
            if blue[i][1]>r[1]>=max_y:
                max_y = r[1]
                max_index=j
 
        if max_index!=-1:
            answer+=1
            red.pop(max_index)
            red_x.pop(max_index)
    
    print(answer)










if __name__ == '__main__':
    main()


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

int main(){

    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll sum = 0;

    if(A > K) sum += 1*K;
    else sum += 1*A;

    if(K-A-B > 0){
        sum += -1*(K-A-B);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
def main():
  n, a = map(int, input().split())
  xlst = list(map(int, input().split()))
  #xlst.insert(0, 0)

  """
  dp[i][j][k] ... iまででj個使ってkを作る
  dp[i][j][k] += dp[i - 1][j - 1][k - x]
  """
  
  """
  dp =  [[[0] * (50 * n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
  for i in range(n + 1):
    dp[i][0][0] = 1
  
  
  for i in range(1, n + 1):
    x = xlst[i]
    dpi = dp[i]
    dpi_1 = dp[i - 1]
    for j in range(1, n + 1):
      dpij = dpi[j]
      dpi_1j = dpi_1[j]
      dpi_1j_1 = dpi_1[j - 1]
      for k in range(1, n * 50 + 1):
        if k >= x:
          #dp[i][j][k] += dp[i - 1][j - 1][k - x] + dp[i - 1][j][k]
          dpij[k] += dpi_1j_1[k - x] + dpi_1j[k]
        else:
          #dp[i][j][k] += dp[i - 1][j][k]
          dpij[k] += dpi_1j[k]

  ans = 0
  for j in range(1, n + 1):
    ans += dp[n][j][j * a]
  
  print(ans)

  """

  ans = 0
  dp = [[0] * (n * 50 + 1) for _ in range(n + 1)]
  dp[0][0] = 1
  for x in xlst:
    for j in range(n, 0, -1):
      for k in range(n * 50, x - 1, -1):
        dp[j][k] += dp[j - 1][k - x]
  for j in range(1, n + 1):
    ans += dp[j][j * a]
  print(ans)
main()

Measured memory_bytes: 4596
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import math
import itertools

n = int(input())

x = []
y = []
l = []

for i in range(n):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)
    l.append(i)    

sum_distance = 0
c = 0

for p in itertools.permutations(l):
    for i in range(n-1):
        sum_distance += ((x[p[i]]-x[p[i+1]])**2 + (y[p[i]]-y[p[i+1]])**2)**0.5

print(sum_distance/math.factorial(n))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,m;
  cin >> n >> m;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  mint ans = 1;
  rep(i,n) ans *= i+1;
  rep(i,m) ans *= i+1;
  if(n==m) ans *= 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			long aPos = sc.nextLong();
			long aSpeed = sc.nextLong();

			long bPos = sc.nextLong();
			long bSpeed = sc.nextLong();

			long time = sc.nextLong();

			if(bSpeed - aSpeed >=0) {
				System.out.println("NO");
				return;
			}

			if(Math.abs(bPos-aPos)/ (double)(aSpeed-bSpeed) <= time) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}



		}catch(Exception e) {
			e.printStackTrace();
		}

	}
}



Measured memory_bytes: 35768
#include <iostream>
#include <stdio.h>
#define MAX 101
using namespace std;

int main(int argc, char *argv[])
{
    int table[MAX][MAX] = {0};
    int r, c, temp;
    scanf("%d %d", &r, &c);
    for (int i = 0; i < r; i++)
    {
        int rowNum = 0;
        for (int j = 0; j < c; j++)
        {
            scanf("%d", &temp);
            table[i][j] = temp;
            rowNum += temp;
        }
        table[i][c] = rowNum;
    }

    for (int j = 0; j <= c; j++)
    {
        int colNum = 0;
        for (int i = 0; i < r; i++)
        {
            colNum += table[i][j];
        }
        table[r][j] = colNum;
    }

    for (int i = 0; i <= r; i++)
    {
        printf("%d", table[i][0]);
        for (int j = 1; j <= c; j++)
        {
            printf(" %d", table[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3248