akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

string s, snew;int n = 0;
vector<pair<int, int> > rng, cnt;

void populate_rng_cnt(int i, int j) {
  if(i > j) return;

  int k = i;
  while(k < j) {
    if(snew[k] == 'A' and snew[k+1] == 'Z') {
      int u = k, v = k+1;
      while(u >= i and snew[u] == 'A') u--;
      while(v <= j and snew[v] == 'Z') v++;
      u++;v--;
      rng.push_back({u, v});
      cnt.push_back({k-u+1, v-k});
      populate_rng_cnt(v+1, j);
      return;
    }
    k++;
  }
}

long long find_answer(int i, int j) {
  long long a = 0, tans = 0;
  for(int k = i;k <= j;k++) {
    a += cnt[k].first;
    tans += a*cnt[k].second;
  }
  return tans;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> s;n = s.size(); // n <= 2 return 0
  for(int i = 0;i < (n-1);) {
    if(s[i] == 'B' and s[i+1] == 'C') {
      snew.push_back('Z');
      i += 2;
    } else {
      snew.push_back(s[i]);
      i += 1;
    }
  }

  populate_rng_cnt(0, n-1);
  if(rng.size() == 0) {
    cout << 0 << endl;
    return 0;
  }

  long long ans = 0;
  int i = 0, j = 1;
  while(j < rng.size()) {
    if((rng[j].first - rng[j-1].second) == 1) {j++;}
    else {
      ans += find_answer(i, j-1);
      i = j;
      j = i+1;
    }
  }
  ans += find_answer(i, j-1);
  cout << ans << endl;
  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
using Graph=vector<vector<Edge>>;
ostream& operator<<(ostream& os,const Edge& e){return os<<'('<<e.src<<"->"<<e.dst<<')';}

int dfs(const Graph& g,int p,int u,int d)
{
	if(d==0) return 1;
	int res=1;
	for(auto e:g[u]) if(e.dst!=p)
		res+=dfs(g,u,e.dst,d-1);
	return res;
}

int main()
{
	for(int n,k;cin>>n>>k && n|k;){
		Graph g(n);
		rep(i,n-1){
			int u,v; cin>>u>>v; u--,v--;
			g[u].emplace_back(u,v);
			g[v].emplace_back(v,u);
		}
		
		int res=INF;
		if(k&1){ // 辺の両端の頂点を中心として深さ(k-1)/2まで残す
			for(auto es:g) for(auto e:es) if(e.src<e.dst){
				int cnt=dfs(g,e.dst,e.src,(k-1)/2)+dfs(g,e.src,e.dst,(k-1)/2);
				res=min(res,n-cnt);
			}
		}
		else{ // ある頂点を中心として深さk/2まで残す
			rep(c,n){
				int cnt=dfs(g,-1,c,k/2);
				res=min(res,n-cnt);
			}
		}
		cout<<res<<endl;
	}
}


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

const double PI=3.14159265358979323846;
// const long long PI = 0x314159265358979323846LL;

int main() {
    int R;
    cin >> R;
    cout << (double)((2 * R) * PI);
    // cout << ((long long)((2 * R) * PI100) / pow(10, 20));
    // cout << ((long long)((2 * R) * PI) / pow(10, 20));
}

// 6.28318530717958623200

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
vector<pair<int, int>> d={{1,0},{0,1}};
vector<vector<char>> Map;

int main() {
    int H, W;
    cin>>H>>W;
    Map.resize(H);
    REP(i,0,H){
        Map[i].resize(W);
    }
    vector<vector<int>> Used(H, vector<int>(W, -1));
    REP(i, 0, H){
        REP(j, 0, W){
            cin >> Map[i][j];
        }
    }
    pair<int, int> cur_point={0,0};
    queue<pair<int, int>> que;
    que.push(cur_point);
    char cur_s = '.';
    int cnt = 0;
    Used[0][0] = 0;
    if(Map[0][0]=='#'){
        Used[0][0] = 1;
    }
    while(!que.empty()){
        cur_point = que.front(); que.pop();
        for(pair<int, int> next : d){
            cnt = Used[cur_point.first][cur_point.second];
            cur_s = Map[cur_point.first][cur_point.second];
            int next_x = cur_point.first + next.first; int next_y = cur_point.second + next.second;
            if(next_x >= H || next_y >= W) continue;
            
            if(Map[next_x][next_y] != cur_s){
                if(cur_s == '#'){
                    cur_s = '.';
                }else{
                    cur_s = '#';
                    cnt++;
                }
            }

            if(Used[next_x][next_y] > cnt || Used[next_x][next_y] == -1){
                Used[next_x][next_y] = cnt;
                que.push(make_pair(next_x, next_y));
            }
        }
    }
    
    cout << Used[H-1][W-1] << endl;
    /*
    REP(i, 0, H){
        REP(j, 0, W){
            cout << Used[i][j];
        }
        cout<<endl;
    }
    */
}

Measured memory_bytes: 256
(* abc138 b problem *)
open Scanf;;
open List;;

let rec list_init n f =
  if n <= 0 then []
  else let x = f () in x :: list_init (n-1) f;;

let () = Scanf.scanf "%d"
           (fun n -> list_init n (fun _ -> Scanf.scanf " %f" (fun v -> v)))
         |> stable_sort Pervasives.compare
         |> (fun arr -> fold_left (fun x y -> (x +. y) /. 2.0) (hd arr) arr)
         |> print_float
         |> print_newline;;

exit 0;;

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int r, p, s;

int solve(string& t) {
	vector<vector<int>> dp(t.size() + 1, vector<int>(3, 0));
	// r:0, s:1, p:2
	rep(i, t.size()) {
		for (auto c : {'r', 's', 'p'}) {
			dp[i + 1][2] =
				max(dp[i + 1][2], max(dp[i][0], dp[i][1]) +
									  (t[i] == 'r' and c == 'p' ? p : 0));
			dp[i + 1][0] =
				max(dp[i + 1][0], max(dp[i][1], dp[i][2]) +
									  (t[i] == 's' and c == 'r' ? r : 0));

			dp[i + 1][1] =
				max(dp[i + 1][1], max(dp[i][0], dp[i][2]) +
									  (t[i] == 'p' and c == 's' ? s : 0));
		}
	}
	return *max_element(all(dp.back()));
}

signed main() {
	int n, k;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	vector<string> vt;
	vector<bool> used(n, false);
	rep(i, n) {
		if (used[i]) continue;
		vt.emplace_back("");
		for (int j = i; j < n; j += k) {
			vt.back() += t[j];
			used[j] = true;
		}
	}

	// cout << vt << endl;

	int sum = 0;
	for (auto& t : vt) { sum += solve(t); }
	cout << sum << endl;
}


Measured memory_bytes: 5888
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        ss: [String;n]
    }
    let mut h = HashSet::new();
    for s in ss {
        h.insert(s);
    }
    println!("{}", h.len());
}


Measured memory_bytes: 24920
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2018

#include <iostream>
using namespace std;

int main() {
  int N, M, P;
  int X;
  while (scanf("%d%d%d", &N, &M, &P) != EOF && N) {
    int sum = 0;
    int win = 0;
    for (int i=1; i<=N; i++) {
      scanf("%d", &X);
      sum += X;
      if (i == M) {
	win = X;
      }
    }
    if (win == 0) {
      printf("%d\n", 0);
    } else {
      printf("%d\n", 100*sum*(100-P)/(100*win));
    }
  }
}

Measured memory_bytes: 1172
n = int(input())
times = [0]
for i in range(n - 1):
    c, s, f = map(int, input().split())
    for j, t in enumerate(times):
        now = max(t, s)
        times[j] = now + (f - now) % f + c
    times.append(0)
for t in times:
    print(t)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a,b,c,i,flag = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(i = 1;i <= 100;i++)
	{
		if((c % b) == (a * i) % b)
		{
			flag = 1;
			break;
		}
	}
	if(flag == 0)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int n, k;
    cin >> n >> k;
    int st = 1, ans = 1;
    while (st * k <= n) {
        st *= k;
        ++ans;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define endl "\n"
typedef long long ll;

const int BIG_NUM = 1e9;

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

    int p, q, r, r1, r2, r3, result;
    cin >> p >> q >> r;
    r1 = p + q;
    r2 = r + p;
    r3 = q + r;
    result = min(r1, r2);
    result = min(result, r3);
    cout << result;
    return 0;
}


Measured memory_bytes: 3604
n, m, k = map(int, input().split())
a_books = [int(i) for i in input().split()]
b_books = [int(i) for i in input().split()]

time = 0
count = 0
for i in range(n):
  time += a_books[i]
  if time > k:
    time -= a_books[i]
    i -= 1
    break
  count += 1
for j in range(m):
  time += b_books[j]
  if time > k:
    time -= b_books[j]
    j -= 1
    break
  count += 1
max_count = count
#print(max_count, time)
while j < m and i >= 0:
  time -= a_books[i]
  i -= 1
  count -= 1
  j += 1
  while j < m:
    time += b_books[j]
    if time > k:
      time -= b_books[j]
      j -= 1
      break
    count += 1
    j += 1
  if count > max_count:
    max_count = count
  #print(count, time)
  #print(max_count)
print(max_count)

Measured memory_bytes: 40900
#include <iostream>

using namespace std;

int main() {
  int count = 0;
  int a, b, c;
  cin >> a >> b >> c;

  for (int i = a; i <= b; i++) {
    if (int(c / i) * i == c)
      count++;
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3096
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.NoSuchElementException;

	
public class Main{
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long A=sc.nextLong();
		long B=(long)Math.round(sc.nextDouble()*100);
		System.out.println(A*B/100);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main()
{
	ll n,k,r,s,p;
	cin>>n>>k>>r>>s>>p;
	string t;
	cin>>t;

	
	ll sum = 0;
	for(ll i=0;i<n;i++)
	{
		if(i>=k && t[i]==t[i-k])
		{
			t[i] = ' ';
			continue;
		}
		else if(t[i]=='p')
		{
			sum += s;
		}
		else if(t[i]=='s')
		{
			sum += r;
		}
		else if(t[i]=='r')
		{
			sum += p;
		}
	}
	
	
	cout<<sum;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N=300010;

int f[3010][3010][2][2];
int n,l,t[N],x[N],a[N],b[N];

int main(){
	scanf("%d%d",&n,&l); ll ans=2*l;
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&t[i]);
		ans+=1LL*((t[i]+2LL*l-1)/(2*l))*2*l;
		t[i]%=2*l;
		if(t[i]>0 && t[i]<=2LL*(l-x[i])) a[i]=1;
		if(t[i]>0 && t[i]<=2LL*x[i]) b[i]=1;
	}
	int cur=0,bt=0;
	for(int i=1;i<n;i++){
		if(a[i]){
			if(cur){
				if(b[i]) bt++;
				cur--; ans-=2*l;
			}
			else if(bt && !b[i]){
				bt--; cur++;
			}
			else if(b[i]) cur++;
		}
		else if(b[i]) cur++;
	}
	if(a[n]) ans-=2*l;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	vector<ll> sum(N);  //sum[i] : i番目までの合計

	long a;  cin >> a;  sum[0] = a;
	for(int i = 1 ; i < N ; i++){
	 cin >> a;
	 sum[i] = sum[i - 1] + a;
	}

	long long ans = 1000000000000000000LL;;
	for(int i = 0 ; i < N - 1 ; i++)
	 ans = min(ans, abs(2 * sum[i] - sum[N - 1]));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
/*
[arc103] D - Robot Arms
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1000;

int N;
ll X[MAX_N], Y[MAX_N];

void solve() {
    char op[4] = {'L', 'D', 'U', 'R'};
    int M = 31;
    int odd = (X[0] + Y[0] + (1LL << M)) % 2;
    string w[MAX_N];

    for (int n = 0; n < N; n++) {
        if ((X[n] + Y[n] + (1LL << M)) % 2 != odd) {
            cout << -1 << endl;
            return;
        }

        ll u = X[n] + Y[n] + (1 - odd);
        ll v = X[n] - Y[n] + (1 - odd);
        ll ub = (u + (1LL << M) - 1) / 2;
        ll vb = (v + (1LL << M) - 1) / 2;

        w[n].resize(M + (1 - odd));
        for (int i = 0; i < M; i++) {
            int pat = ((ub >> i) & 1) * 2 + ((vb >> i) & 1);
            w[n][i] = op[pat];
        }
        if (odd == 0) {
            w[n][M] = 'L';
        }
    }

    cout << M + (1 - odd) << endl;
    ll p = 1;
    for (int i = 0; i < M; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << p;
        p <<= 1;
    }
    if (odd == 0) {
        cout << " " << 1 << endl;
    } else {
        cout << endl;
    }
    for (int i = 0; i < N; i++) {
        cout << w[i] << endl;
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }

    solve();

    return 0;
}


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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (b-a==c-b){ cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}


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

int main(void){
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int rex = x1-x2;
    int rey = y1-y2;
    int x3, y3, x4, y4;
    int ans[4];
    ans[0] = x2 + rey;
    ans[1] = y2 - rex;
    ans[2] = x1 + rey;
    ans[3] = y1 - rex;

    char kuuhaku = ' '; 

    for(int i = 0; i < 4; i++){
        cout << ans[i];
        cout << kuuhaku;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    # define LL long long
    # define int long long
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    # define mo 998244353
    # define pi acos(-1)
    //vector<pair<int,int>> v;
    //int x0=INT_MAX,y0=INT_MAX;
    /*int crossprod(pair<int,int> a,pair<int,int> b,pair<int,int> c)
    {
        int x1 = a.first-b.first;
        int x2 = a.first-c.first;
        int y1 = a.second-b.second;
        int y2 = a.second-c.second;
        return x1*y2 - y1*x2;
    }
    int direction(pair<int,int> a,pair<int,int> b,pair<int,int> c) {
       int val = (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
       if (val == 0)
          return 0;     //colinear
       else if(val < 0)
          return 2;    //anti-clockwise direction
          return 1;    //clockwise direction
    }*/
   vector<int> v[102];
    signed main(){
        gok

     int n;
     cin>>n;
     double ss = n/3.0;

  cout<<fixed<<setprecision(10)<<(ss*ss*ss);





        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a>=b && a>=c)
        ans=a*10+b+c;
    else if(b>=a && b>=c)
        ans=b*10+a+c;
    else
        ans=c*10+b+a;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h> 
int main()
{
	char a[10];
	scanf("%s",a);
	if(strcmp(a,"SUN")==0)
	printf("7\n");
	else if(strcmp(a,"MON")==0)
	printf("6\n");
	else if(strcmp(a,"TUE")==0)
	printf("5\n");
	else if(strcmp(a,"WED")==0)
	printf("4\n");
	else if(strcmp(a,"THU")==0)
	printf("3\n");
	else if(strcmp(a,"FRI")==0)
	printf("2\n");
	else if(strcmp(a,"SAT")==0)
	printf("1\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=2e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
	G;while(*ip<'-')G;
	R x=*ip&15;G;
	while(*ip>'-'){x*=10;x+=*ip&15;G;}
	return x;
}
int n,rt,p,a[N],f[N],he[N],ne[M],to[M],w[M],s[N],mx[N]={N};
LL d[N];bool vis[N];
struct Edge{
	int u,v;LL w;
	inline bool operator<(const Edge&x)const{
		return w<x.w;
	}
}e[50*N];
inline void Cmx(R&x,R y){
	if(x<y)x=y;
}
void Getrt(R x){
	vis[x]=1;s[x]=1;mx[x]=0;
	for(R y,i=he[x];i;i=ne[i])
		if(!vis[y=to[i]])
			Getrt(y),s[x]+=s[y],Cmx(mx[x],s[y]);
	Cmx(mx[x],n-s[x]);
	if(mx[rt]>mx[x])rt=x;
	vis[x]=0;
}
void Dfs1(R x){
	vis[x]=1;
	if(d[rt]>d[x])rt=x;
	for(R y,i=he[x];i;i=ne[i])
		if(!vis[y=to[i]])
			d[y]=d[x]-a[x]+a[y]+w[i],Dfs1(y);
	vis[x]=0;
}
void Dfs2(R x){
	vis[x]=1;
	e[++p]=(Edge){x,rt,d[rt]+d[x]};
	for(R y,i=he[x];i;i=ne[i])
		if(!vis[y=to[i]])Dfs2(y);
	vis[x]=0;
}
void Solve(R x){
	rt=0;Getrt(x);x=rt;
	d[x]=a[x];Dfs1(x);Dfs2(x);
	vis[x]=1;
	for(R t=n,y,i=he[x];i;i=ne[i])
		if(!vis[y=to[i]])
			n=s[y]<s[x]?s[y]:t-s[x],Solve(y);
}
int Getf(R x){
	return x==f[x]?x:f[x]=Getf(f[x]);
}
int main(){
	R n=::n=in();
	for(R i=1;i<=n;++i)a[i]=in(),f[i]=i;
	for(R i=1,p=0;i<n;++i){
		R x=in(),y=in();
		ne[++p]=he[x];to[he[x]=p]=y;
		ne[++p]=he[y];to[he[y]=p]=x;
		w[p]=w[p-1]=in();
	}
	Solve(1);
	sort(e+1,e+p+1);
	LL ans=0;
	for(R i=1;i<=p;++i){
		R x=Getf(e[i].u),y=Getf(e[i].v);
		if(x!=y)f[x]=y,ans+=e[i].w;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 74368
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    double m;
    cin >> n >> m;
    vector<int> arr(n);
    int tot=0;
    F0R(i,n) {
        cin >> arr[i];
        tot+=arr[i];
    }
    double val=tot*(1.0/(4*m));
    int cnt=0;
    F0R(i,n) {
        if(arr[i]>=val)
            cnt++;
    }
    if(cnt>=m)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


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


class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] lo =reader.readLine().split(" ");
        int N=Integer.parseInt(lo[0]);
        int K = Integer.parseInt(lo[1]);
        String[] lop = reader.readLine().split(" ");
        int[] arr = new int[N];
        for (int i = 0; i <N ; i++) {
            arr[i] = Integer.parseInt(lop[i]);
        }
        int[] dp = new int[N];
        dp[0] = 0;
        for (int i = 1; i <N ; i++) {
            int min = Integer.MAX_VALUE;
            int j = 1;
            while(j<=K && i-j>=0){
                min = Math.min(min,dp[i-j]+Math.abs(arr[i]-arr[i-j]));
                j++;
            }
            dp[i] = min;
        }
        System.out.println(dp[N-1]);
    }
}


Measured memory_bytes: 33884
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    string s;cin >> s;
    int n=s.length();
    vector<int> ans(n,0);
    int a=0,b=0,c=0;
    for (int i = 0; i < n; i++) {
        if(s[i]=='R'){
            if((i-c)%2==0){
                a++;
            }
            else b++;
        }
        else{
            if((i-c)%2==0){
                ans[i]+=a;
                if(i) ans[i-1]+=b;
            }
            else{
                ans[i]+=b;
                if(i) ans[i-1]+=a;
            }
            a=0,b=0;
            c=i+1;
        }
    }
    a=0,b=0,c=n-1;
    for (int i = n-1; i >= 0; i--) {
        if(s[i]=='L'){
            if((c-i)%2==0){
                a++;
            }
            else b++;
        }
        else{
            if((c-i)%2==0){
                ans[i]+=a;
                if(i<n-1) ans[i+1]+=b;
            }
            else{
                ans[i]+=b;
                if(i<n-1) ans[i+1]+=a;
            }
            a=0,b=0;
            c=i-1;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << (i==n-1?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)


bool used[100001]; //! used color

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

    int N;
    cin >> N;

    vector<vector<pair<int, int>>> to(N);   //! edges from i-th node. edge = pair<next node, edge-index>
    vector<int> ans(N-1);

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back({b, i});
        to[b].push_back({a, i});
    }

    int K = 0;
    rep(i, N) {
        K = max(K, (int) to[i].size());
    }

    queue<int> q;
    rep(i, N) {
        if (to[i].size() == K) {
            q.push(i);
            break;
        }
    }

    vector<bool> visited(N);
    while (!q.empty()) {
        int a = q.front(); q.pop();
        if (visited[a]) continue;
        // cout << "a = " << a << endl;
        memset(used, 0, sizeof(used));
        visited[a] = true;
        for (auto e: to[a]) {
            q.push(e.first);
            int c = ans[e.second];
            if (c) {
                used[c] = true;
            }
        }
        int cc = 1;
        for (auto e: to[a]) {
            if (!ans[e.second]) {
                while (used[cc]) ++cc;
                ans[e.second] = cc;
                used[cc] = true;
                K = max(K, cc);
                ++cc;
            }
        }
    }

    cout << K << '\n';
    for (int c: ans) {
        cout << c << '\n';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	ios::sync_with_stdio(0);
	cin>>n;
	int f=0,o=0,two=0;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		if(t%2==1)o++; 	
		else if(t%4==0)f++;
		else if(t%2==0)two++;
	}
	if(two!=0){
		if(o+1<=f+1)puts("Yes");
		else puts("No");
	}
	else {
		if(o<=f+1)puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	
	std::cin >> n;
	
	int i = 1;
	while( i <= n )
	{
		int x = i;
		
		if( x % 3 == 0 ) 
			std::cout << " " << i;
		
		else 
		{
			while(x)
			{				
				if( x % 10 == 3 )
				{
					std::cout << " " << i;
					break;
				}
				
				x /= 10;
			}
		}
		
		i++;
	}
	
	std::cout << std::endl;
	
	return 0;
}


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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}cout << endl;
		}cout << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<ll> A(N), B(N);
	for (int i = 0; i < N; i++)
		cin >> A[i] >> B[i];

	ll cnt = 0;
	for (int i = N - 1; i >= 0; i--) {
		if ((A[i]+cnt) % B[i] != 0) {
			cnt += B[i] - (A[i] + cnt) % B[i];
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 4852
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w;
	list *adj[100001] = {}, e[400001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int prev[200001] = {}, q[200001], head, tail;
	list *p;
	q[0] = 1;
	prev[1] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (prev[w] == 0) {
				prev[w] = u;
				q[tail++] = w;
			}
		}
	}

	if (head == N) {
		printf("Yes\n");
		for (i = 2; i <= N; i++) printf("%d\n", prev[i]);
	} else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 9928
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next()),b=Integer.parseInt(sc.next());
        if(a!=1&&b!=1){
            System.out.println(1);
        }else if(a!=2&&b!=2){
            System.out.println(2);
}else if(a!=3&&b!=3){
    System.out.println(3);
}
    }
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  string ans = "NG";
  for (int i=a;i<=b;i++) {
    if (i%n==0) {
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
      
}
    

Measured memory_bytes: 3620
#include<bits/stdc++.h>
const int N=200007,inf=0x3f3f3f3f,P=1e9+7;
int n,x,y,mn=inf,mn2=inf,mw=0,mw2=0,ans=1;
int f[N],fac[N],fiv[N],sz[N],val[N];
std::vector<int>cs[N];
int gf(int x){
	while(x!=f[x])x=f[x]=f[f[x]];
	return x;
}
int pw(int a,int n){
	int v=1;
	for(;n;n>>=1,a=1ll*a*a%P)if(n&1)v=1ll*v*a%P;
	return v;
}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	for(int i=fac[0]=1;i<=n;++i)fac[i]=1ll*i*fac[i-1]%P;
	fiv[n]=pw(fac[n],P-2);
	for(int i=n;i;--i)fiv[i-1]=1ll*i*fiv[i]%P;
	for(int i=1,c,w;i<=n;++i){
		f[i]=i;
		val[i]=1;
		scanf("%d%d",&c,&w);
		cs[c].push_back(w);
	}
	for(int i=1;i<=n;++i)if(cs[i].size()){
		std::sort(cs[i].begin(),cs[i].end());
		int v=cs[i][0];
		if(v<=mn)mn2=mn,mw2=mw,mn=v,mw=i;
		else if(v<mn2)mn2=v,mw2=i;
	}
	for(int i=1;i<=n;++i)if(cs[i].size()){
		int w=mw==i?mw2:mw,v=cs[w].size()?y-cs[w][0]:0;
		while(cs[i].size()){
			if(cs[i].size()>1&&cs[i].back()+cs[i].front()<=x)break;
			if(cs[i].back()<=v)break;
			cs[i].pop_back();
		}
		if(cs[i].size()&&w&&cs[i][0]<=v)f[gf(i)]=gf(w);
	}
	for(int i=1;i<=n;++i)if(cs[i].size()){
		int a=gf(i),b=cs[i].size();
		sz[a]+=b;
		val[a]=1ll*val[a]*fiv[b]%P;
	}
	for(int i=1;i<=n;++i)if(f[i]==i)ans=1ll*ans*val[i]%P*fac[sz[i]]%P;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 13184
N = int(input())
A_list = list(map(int, input().split()))

dif = []
for idx, v in enumerate(A_list, 1):
    dif.append(v - idx)

dif.sort()
if len(dif) % 2 == 1:
    b = dif[len(dif) // 2]
    print(sum(map(abs, (map(lambda x: x - b, dif)))))
else:
    b1 = dif[len(dif) // 2 - 1]
    b2 = dif[len(dif) // 2]
    print(min(sum(map(abs, (map(lambda x: x - b1, dif)))),
              sum(map(abs, (map(lambda x: x - b2, dif))))))


Measured memory_bytes: 26180
using System;
class Program
{
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    bool result = true;
    for (int i = 0; i < s.Length; i++)
    {
      if (i % 2 == 0 && s[i] == 'L')
      {
        result = false;
      }
      if (i % 2 == 1 && s[i] == 'R')
      {
        result = false;
      }
    }
    Console.WriteLine(result ? "Yes" : "No");
  }
}


Measured memory_bytes: 13140
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var ans = Math.round((180-(360/N))*N);

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M ,X = mi()
CA = [li() for _ in range(N)]

B = 2**N
ans = float('inf')
for i in range(B):
    cnt = [0]*M
    flag = 1
    kane = 0
    for j in range(N):
        if i & 1 << j:
            kane += CA[j][0]
            for k in range(M):
                cnt[k] += CA[j][k+1]
    #print(i, cnt)
    for k in range(M):
        if cnt[k] < X:
            flag = 0
            break
    if flag:
        ans = min(ans, kane)
if ans == float('inf'):
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 9128
#include <stdio.h>

#define min(x, y)   ((x) < (y) ? (x) : (y))

int main(void) {
    int n, m;
    int dp[50001];
    int coin[20];
    int i, j;

    scanf("%d %d", &n, &m);
    for( i = 0; i < m; i++ ) {
        scanf("%d", coin + i);
    }
    dp[0] = 0;
    for( i = 1; i <= 50000; i++ ) {
        dp[i] = 1 << 20;
    }

    for( i = 0; i < n; i++ ) {
        for( j = 0; j < m; j++ ) {
            if( i + coin[j] <= n ) {
                dp[i + coin[j]] = min(dp[i + coin[j]], dp[i] + 1);
            }
        }
    }

    printf("%d\n", dp[n]);

    return 0;
}

Measured memory_bytes: 792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }
        Scanner cin;

        int A,B;
        void solve() {
            cin = new Scanner();

            A = cin.nextInt();
            B = cin.nextInt();

            if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
                Console.WriteLine("Possible");
            } else {
                Console.WriteLine("Impossible");
            }
        }
    }

    class Scanner {
        string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
        public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
        public string next() {
            if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            BufferCnt = 0;
            return nextBuffer[BufferCnt++];
        }
        public int nextInt() { return int.Parse(next()); }
        public long nextLong() { return long.Parse(next()); }
        public double nextDouble() { return double.Parse(next()); }
    }
}

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

int main(){
    ll a;
    cin >> a;
    if(a < 600) cout << 8 << endl;
    else if(a < 800) cout << 7 << endl;
    else if(a < 1000) cout << 6 << endl;
    else if(a < 1200) cout << 5 << endl;
    else if(a < 1400) cout << 4 << endl;
    else if(a < 1600) cout << 3 << endl;
    else if(a < 1800) cout << 2 << endl;
    else if(a < 2000) cout << 1 << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
ll a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a+b<c)
	{
		cout<<b+a+b+1<<"\n";
	}
	else 
	{
		cout<<b+c<<"\n"; 
	} 
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000000
int memo[50010];
int c[20];
int n,m;
int f(int a){
    if(a==0)return 0;
    if(memo[a]!=0)return memo[a];
    int min=MAX;
    int i;
    for(i=0;i<m;i++){
        if(a-c[i]>=0&&c[i]>0){
        int b=f(a-c[i]);
        if(min>b)min=b;
        }
    }
    return memo[a]=min+1;
}
 int main(void){
    int i;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&c[i]);
    }
    printf("%d\n",f(n));
    return 0;
}

Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

ll _nCr[300][300];
ll nCr(int n,int r){
  if(_nCr[n][r] != -1) return _nCr[n][r];
  return (r==0 || n==r) ? 1 : (_nCr[n][r] = nCr(n-1,r) + nCr(n-1,r-1));
}

ll _fact[300];

ll fact(ll n)
{
  if(_fact[n] != -1) return _fact[n];
  return (n <= 1 ? 1 : (_fact[n] = n * fact(n-1)));
}

struct Comparer {
  bool operator() (const bitset<71> &b1, const bitset<71> &b2) const {
    return b1.to_ulong() < b2.to_ulong();
  }
};

ll dp[101][10][2][2];
ll seats;

ll dfs(int pos,int used,bool here,bool opposite){
  if(used >= 8) return 1;
  if(pos >= seats/2) return 0;
  if(dp[pos][used][here][opposite] != -1) return dp[pos][used][here][opposite];
  if(pos + 1 == seats/2) here = false;

  ll res = 0;
  res += dfs(pos+1,used,true,true);
  if(here) res += dfs(pos+1,used + 1,false,true);
  if(opposite) res += dfs(pos+1,used + 1,true,false);

  return (dp[pos][used][here][opposite] = res);
}

int main(){

  memset(_nCr,-1,sizeof(_nCr));
  memset(_fact,-1,sizeof(_fact));
  while(~scanf("%lld",&seats)){
    if(seats == 0) break;

    if(seats <= 16){
      printf("%d\n",0);
    }
    else if(seats % 2 != 0){
      printf("%lld\n",seats * nCr(seats - 9,7) * fact(7));
    }
    else{
      memset(dp,-1,sizeof(dp));
      printf("%lld\n",seats * dfs(1,1,false,true) * fact(7));
    }
  }
}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int i,n,x,y;
    vector<long long>v1,v2;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> x >> y;
        v1.emplace_back(x+y);
        v2.emplace_back(x-y);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout << max(v1.back()-v1[0],v2.back()-v2[0]);
    return 0;
}


Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {

	vector<int> V;
	for(int i=0;i<3;i++){
		int v;
		cin>>v;
		V.pb(v);
	}
	sort(V.begin(),V.end());
	cout<<V[2]-V[1]+V[1]-V[0]<<endl;

	return 0;
}

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

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

  int n;
  cin >> n;

  vector<int> b(n);
  rep(i, n){
    cin >> b[i];
    rep(j, 3){
      rep(k, 3){
        if(a[j][k]==b[i]){
          a[j][k]=0;
        }
      }
    }
  }

  bool ans=false;

  rep(i, 3){
    if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
      ans=true;
    }
    if(a[0][i]==a[1][i]&&a[1][i]==a[2][i]){
      ans=true;
    }
  }

  if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
    ans=true;
  }
  if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]){
    ans=true;
  }

  if(ans==true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct team {
	int id;
	int solve;
	int score;
	bool operator< (const team&t) {
		return solve == t.solve?score == t.score ?id>t.id:score>t.score: solve < t.solve;
	}
};

int main() {
	while(1) {
		int T, P, R; cin >> T >> P >> R;
		vector<vector<int>>miss(T, vector<int>(P));
		vector<vector<int>>scores(T, vector<int>(P));
		if (!T)break;
		for (int i = 0; i < R; ++i) {
			int tid, pid, time;string mes; cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT") {
				if (!scores[tid][pid])
					scores[tid][pid] = 1200 * miss[tid][pid] + time;

			}
			else {
				miss[tid][pid]++;
			}
		}
		vector<team>performs(T);

		for (int i = 0; i < T; ++i) {
			performs[i].id = i + 1;
			for (int j = 0; j < P; ++j) {
				if (scores[i][j]) {
					performs[i].solve++;
					performs[i].score += scores[i][j];
				}
			}
		}
		sort(performs.begin(), performs.end());
		reverse(performs.begin(), performs.end());
		for (int i = 0; i < T; ++i) {
			cout << performs[i].id << " " << performs[i].solve << " "<<performs[i].score << endl;
		}
	}

	
	return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n;
VI a;
int minButtons()
{
	VB used(n + 1, false);
	int start = 1, ret = 1;
	while(used[start] == false)
	{
		used[start] = true;	
		start = a[start];
		if(start == 2)
			return ret;
		++ret;
	}
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	a = VI(n + 1);
	REP(i, 1, n + 1) cin >> a[i];

	cout << minButtons() << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;
#define INF 1000000007

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

    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        string tmp;
        for (int j = i; j < s.length(); j++){
            if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') break;
            tmp += s[j];
            ans = max(ans, (int)tmp.length());
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(void){
	ll x,n,i,ans=0,m=0;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++){
		ans+=a[i]-1;
	}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N % 2 == 1)
  {
    N = N / 2 + 1;
  }
  else
  {
    N /= 2;
  }
  cout << N << endl;
}

Measured memory_bytes: 3488
N, M, Q = map(int, input().split())
import numpy as np
LR = [[0]*(N+1) for _ in range(N+1)]

for i in range(1, M+1):
    l, r = map(int, input().split())
    LR[l][r] += 1
cLR = np.cumsum(np.cumsum(LR, axis=0), axis=1)

for _ in range(Q):
    p, q = map(int, input().split())
    ans = cLR[N][q] - cLR[p-1][q]
    print(ans)

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

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans1 = (double)w * h / 2;
	int ans2 = 0;
	if (w == 2 * x && h == 2 * y) {
		ans2 = 1;
	}
	cout << fixed << setprecision(10) << ans1 << " " << ans2 << endl;
}


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

int main() {
	int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	if (Q * 2 < H) H = Q * 2;
	if (H * 2 < S) S = H * 2;
	if (S * 2 < D) D = S * 2;
	cout << (int64_t)N / 2 * D + N % 2 * S;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
string a,b,c;
int main()
{ 
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){printf("YES");
                                                }else{printf("NO");
                                                     }
}

Measured memory_bytes: 256