akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")

// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62592
def main():
    while True:
        n = int(input())
        if n == 0:
            break

        cost = []
        for i in range(n):
            cost.append(int(input()))

        cost.sort()
        wait = 0
        for i in range(n):
            wait += sum(cost[:i])

        print(wait)


if __name__ == "__main__":
    main()




Measured memory_bytes: 5724
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,x; cin>>n>>x;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin>>l[i];
    int t[n+1]; t[0]=0;
    for(int i=1;i<n+1;i++){
        t[i]=t[i-1]+l[i-1];
    }
    int ans=0;
    //for(int i=0;i<n+1;i++) cout<<t[i]<<endl;
    for(int i=0;i<n+1;i++){
        if(t[i]<=x) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
 
int Partition(int A[] ,int ,int );
int A[MAX];
 
int main(){
 
  int n,c,i,j;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&A[i]);
 
  c = Partition(A,0,n-1);
 
  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    if(i==c) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  
  printf("\n");
 
  return 0;
}
int Partition(int A[] ,int p,int r){
 
  int c,tmp,i,j;
 
  c = A[r];
  i = p-1;
 
  for(j=p; j<r; j++){
    if(A[j] <= c){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp; 
    }
  }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
 
    return i+1;
}

Measured memory_bytes: 992
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int p[100100];
int r[100100];

void init(int n){
  REP(i, n){
    p[i] = i;
    r[i] = 0;
  }
}

int find(int n) {return (p[n] == n ? n : p[n] = find(p[n]));}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(r[x] < r[y]) p[x] = y;
  else{
    p[y] = x;
    if(r[x] == r[y]) r[x]++;
  }
}

bool same(int x, int y){
  return (find(x) == find(y));
}

int main(){
  int n, m;
  cin >> n >> m;
  init(n);
  int p[n];
  REP(i, n) cin >> p[i];
  REP(i, m){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    unite(x, y);
  }
  int ans = 0;
  REP(i, n){
    if(same(i, p[i]-1)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=998244353;
const long double Pi=acos(-1);
ll pow2(ll a,ll b){
  ll ans=1;
  while(b>=1){
    ans*=a;
    ans%=MOD;
    b--;
  }
  return ans;
}
int main(){
  ll N,S;
  cin>>N>>S;
  vector<ll> A(0);
  for(ll i=0;i<N;i++){
    ll a;
    cin>>a;
    //if(a==1){cout<<1<<endl;}
    //if(a==2){cout<<2<<endl;}
    if(a<=S){A.push_back(a);}//Sより大きいのをそもそも除外(部分集合に入るわけないから)
  }
  //cout<<mini<<endl;
  ll dp[3020][3020];//何乗？
  sort(A.begin(),A.end());//何となくソート(特に意味ないけど自分に分かりやすくするため)
  if(A.size()==0){cout<<0<<endl;return 0;}//そもそも要素が空だったら0を出力(条件を満たすことは不可能だから)
  dp[1][A.at(0)]=1;
  for(ll i=1;i<N;i++){
    dp[i][0]=pow2(2,i);//定数項は2の指数乗に
  }
  //以下、積のシグマ(2+x^(A.at(i)))を計算していき、x^sの項の係数(答え)を求める
  for(ll i=2;i<=N;i++){
    for(ll j=0;j<=S;j++){
      if(i-1<(ll)A.size()){
        if(j-A.at(i-1)>=0){
          if(dp[i-1][j-A.at(i-1)]>0){
            dp[i][j]+=dp[i-1][j-A.at(i-1)];
            dp[i][j]%=MOD;
          }
        }
      }
      if(j>0){
        dp[i][j]+=dp[i-1][j];
        dp[i][j]%=MOD;
        dp[i][j]+=dp[i-1][j];
        dp[i][j]%=MOD;
      }
    }
  }
  cout<<dp[N][S]%MOD<<endl;
}

Measured memory_bytes: 74408
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        k: usize1,
    }
    let mod_num = 1e9 as i64 + 7;
    let mut pattern = vec![vec![0i64; w]; h];
    for i in (0..h).rev() {
        for j in 0..w {
            if i == h - 1 {
                if j == k {
                    pattern[i][j] = num_pattern(w as i32, j as i32, None);
                } else if (j as i32 - k as i32).abs() == 1 {
                    pattern[i][j] = num_pattern(w as i32, j as i32, Some(k as i32));
                }
            } else {
                pattern[i][j] = num_pattern(w as i32, j as i32, None) * pattern[i + 1][j];
                if j != 0 {
                    pattern[i][j] +=
                        num_pattern(w as i32, j as i32, Some(j as i32 - 1)) * pattern[i + 1][j - 1];
                }
                if j != w - 1 {
                    pattern[i][j] +=
                        num_pattern(w as i32, j as i32, Some(j as i32 + 1)) * pattern[i + 1][j + 1];
                }
            }
            pattern[i][j] %= mod_num;
        }
    }
    if pattern[0][0] == 0 {
        println!("1");
    } else {
        println!("{}", pattern[0][0]);
    }
}

fn num_pattern(w: i32, a: i32, b: Option<i32>) -> i64 {
    if let Some(b) = b {
        count(cmp::min(a, b)) * count(w - cmp::max(a, b) - 1)
    } else {
        count(a) * count(w - a - 1)
    }
}

fn count(num: i32) -> i64 {
    fibonacci(num + 1)
}

fn fibonacci(n: i32) -> i64 {
    if n <= 0 {
        panic!("invalid argument");
    }
    match n {
        1 | 2 => 1,
        3 => 2,
        _ => fibonacci(n - 1) + fibonacci(n - 2),
    }
}


Measured memory_bytes: 4352
n = gets.to_i

taro_score = 0
hanako_score = 0

n.times do
  taro, hanako = gets.split

  if taro > hanako
    taro_score += 3
  elsif taro < hanako
    hanako_score += 3
  else
    taro_score += 1
    hanako_score += 1
  end
end

puts "#{taro_score} #{hanako_score}"



Measured memory_bytes: 6856
#include<iostream>
 
int main(){
  int A,B,C;
  
  std::cin >> A >> B >> C;
  int five = 0;
  int seven = 0;
  
  if(A==5)five++;
  if(B==5)five++;
  if(C==5)five++;
 
  if(A==7)seven++;
  if(B==7)seven++;
  if(C==7)seven++;
  
  if(five==2 && seven==1)std::cout << "YES";
  else std::cout << "NO";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=51;
const ll INF=1LL<<55;

int main(){
    
    int N;cin>>N;
    vector<pair<ll,int>> L(N),R(N);
    vector<int> used(N);
    for(int i=0;i<N;i++){
        cin>>L[i].first>>R[i].first;
        L[i].second=i;
        R[i].second=i;
    }
    
    sort(all(L));
    sort(all(R));
    reverse(all(L));
    
    ll left=0,right=0,sum1=0,sum2=0,now=0;
    
    for(int k=0;k<N;k++){
        while(left<N&&used[L[left].second]){
            left++;
        }
        if(left==N) break;
        if(L[left].first-now<=0) break;
        sum1+=(L[left].first-now);
        now=L[left].first;
        used[L[left].second]=1;
        
        while(right<N&&used[R[right].second]){
            right++;
        }
        if(right==N) break;
        if(now-R[right].first<=0) break;
        sum1+=(now-R[right].first);
        now=R[right].first;
        used[R[right].second]=1;
    }
    
    sum1+=abs(now);
    
    left=0;right=0;now=0;
    
    for(int i=0;i<N;i++){
        used[i]=0;
    }
    
    for(int k=0;k<N;k++){
        while(right<N&&used[R[right].second]){
            right++;
        }
        if(right==N) break;
        if(now-R[right].first<=0) break;
        sum2+=(now-R[right].first);
        now=R[right].first;
        used[R[right].second]=1;
        
        while(left<N&&used[L[left].second]){
            left++;
        }
        if(left==N) break;
        if(L[left].first-now<=0) break;
        sum2+=(L[left].first-now);
        now=L[left].first;
        used[L[left].second]=1;
    }
    
    sum2+=abs(now);
    
    //cout<<sum1<<" "<<sum2<<endl;
    cout<<max(sum1,sum2)<<endl;
    
}



Measured memory_bytes: 3712
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dfs(string s) {
  //cout << s << endl;
  if(s[0] == '[') s = s.substr(1, s.size()-2);
  if(isdigit(s[0])) {
    int ret = 0;
    REP(i, s.size()) {
      ret *= 10;
      ret += s[i] -'0';
    }
    return ret/2+1;
  }

  VI v;
  int idx = 0, a = 0;
  REP(i, s.size()) {
    if(s[i] == '[') a++;
    else if(s[i] == ']') a--;
    if(a == 0) {
      //cout << s.substr(idx, i-idx+1) << endl;
      v.PB(dfs(s.substr(idx, i-idx+1))), idx = i+1;
    }
  }
  sort(ALL(v));
  int ret = 0;
  REP(i, v.size()/2+1) ret += v[i];
  return ret;
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    string s;
    cin >> s;
    cout << dfs(s) << endl;
  }

  return 0;
}

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

int main() {
	int n, A[100];
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> A[i];

	}

	for (int i = n - 1; i >= 0; i--) {
		if (i != n - 1)cout << " ";
		cout << A[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
#define N 3
#define MAX 1000
#define INF -1



typedef struct {
  int ban[N*N], sp, MD, p[N][N];  
}Record;



void IDA(Record); 
int Manhat(Record);
int dfs(int, int);





int cnt = 0, ans[N][N], size, limit, stack[N], time, path[100];
int dx[4] = {0, -1, 0, 1}; //四方向
int dy[4] = {1, 0, -1, 0}; //四方向
int MDT[N*N][N*N];
char dir[4] = {'r','u','l','d'}; //右、上、左、下
char an[100];
Record data, in;


int main () {
  int i, j, k = 0, m = 0, l = 0;


  for(i = 0 ; i < N*N ; i++) {
    for(j = 0 ; j < N*N ; j++) {
      m = i / N - j / N;
      l = i % N - j % N;

      if(m < 0) m = -1 * m;
      if(l < 0) l = -1 * l;
      MDT[i][j] = m + l;
    }
  }



  for(i = 0 ; i < N*N ; i++) {
      scanf("%d",&in.ban[i]);

      if(in.ban[i] == 0) {
	in.ban[i] = N*N;
	in.sp = i;
      }
    
      //if(i * j != (N-1)*(N-1)) ans[i][j] = ++k;
  }

  IDA(in);
 

  printf("%d\n",strlen(an));

  return 0;
}



int Manhat(Record A) {
  int d = 0, i;
  
  for(i = 0 ; i < N * N ; i++) {
    if(A.ban[i] == N*N) continue;
    d += MDT[i][A.ban[i]-1];
  }

  return d;
}






int dfs(int def, int prev) {
  int sx = 0, sy = 0, i, j, tx = 0, ty = 0, max = 0, min = 0, t1;
  Record tmp;

  //printf("test\n");
  if(data.MD == 0) return 1;

  if(def + data.MD > limit) return -1;

  sx = data.sp / N;
  sy = data.sp % N;

  for(i = 0 ; i < 4 ; i++) {
    tx = sx + dx[i];
    ty = sy + dy[i];

    if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;

    if(prev > i) {
      max = prev;
      min = i;
    }

    else {
      max = i;
      min = prev;
    }

    if(max - min == 2) continue;

    tmp = data;
    data.MD -= MDT[tx * N + ty][data.ban[tx * N + ty]-1]; //正解に近づいているか
    data.MD += MDT[sx * N + sy][data.ban[tx * N + ty]-1];
    t1 = data.ban[tx * N + ty];
    data.ban[tx * N + ty] = data.ban[sx * N + sy];
    data.ban[sx * N + sy] = t1;

    data.sp = tx * N + ty;

    if(dfs(def + 1, i) == 1) {
      path[def] = i;
      return 1;
    }

    data = tmp;
  }
  

  return -1;
}


void IDA(Record A) {
  int i, cnt = 0, j = 0;
  
  in.MD = Manhat(in);

  for(limit = in.MD ; limit <= 100 ; limit++) {
    data = in;

    if(dfs(0, -100) == 1) {
      for(i = 0 ; i < limit ; i++) {
   
	an[j] = dir[path[i]];
	j++;
      }
      //printf("test\n");
      an[j] = '\0';
      return;
    }

  }
  
}







Measured memory_bytes: 2108
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    drinks = [list(map(int, input().split())) for i in range(m)]

    for p, x in drinks:
        print(sum(t) - t[p - 1] + x)

    # p = [0 for i in range(m)]
    # x = [0 for i in range(m)]
    # 
    # for i in range(m):
    #     p[i], x[i] = map(int, input().split())
    # 
    # for i in range(m):
    #     print(sum(t) - t[p[i] - 1] + x[i])


if __name__ == "__main__":

    main()


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}



template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int k, s;
    cin >> k >> s;

    int cnt=0;
    rep(z,k+1){
        rep(y,k+1){
            if(s-z-y <= k && s-z-y >= 0)
                cnt++;

        }
    }

    ppp(cnt);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

vector<PII> G[100010];
pair<ll, int> d[100010];
int main(void){
	int N, M ,C;
	ll total = 0;
	ll res = INF_LL;
	cin >> N >> M >> C;
	REP(i, N){
		d[i] = {INF_LL, i};
	}
	REP(i, M){
		int a, b, d;
		cin >> a >> b >> d; a--; b--;
		G[a].push_back({d, b});
		G[b].push_back({d, a});
		total += d;
	}
	d[0] = {0, 0};
	priority_queue<PLL, vector<PLL>, greater<PLL> > pq;
	pq.push({0, 0});
	while(pq.size()){
		PLL p = pq.top(); pq.pop();
		int v = p.second;
		if(p.first > d[p.second].first) continue;
		REP(i, G[v].size()){
			if(d[G[v][i].second].first > d[v].first + G[v][i].first){
				d[G[v][i].second].first = d[v].first + G[v][i].first;
				pq.push({d[G[v][i].second].first, G[v][i].second});
			}
		}
	}
	sort(d, d+N);
	bool used[100010] = {};
	REP(i, N){
		used[d[i].second] = true;
		REP(j, G[d[i].second].size()){
			if(used[G[d[i].second][j].second])
				total -= G[d[i].second][j].first;
		}
		res = min(res, total + C*d[i].first);
	}
	cout << res << endl;
}

Measured memory_bytes: 13944
#include <cstdio>
const int MOD = 998244353;
const int MAXN = 10000000;
int sub(int x, int y) {return x - y < 0 ? x - y + MOD : x - y;}
int pow_mod(int b, int p) {
	int ret = 1;
	while( p ) {
		if( p & 1 ) ret = 1LL*ret*b%MOD;
		b = 1LL*b*b%MOD;
		p >>= 1;
	}
	return ret;
}
int pw2[MAXN + 5], fct[MAXN + 5], ifct[MAXN + 5];
void init() {
	pw2[0] = 1;
	for(int i=1;i<=MAXN;i++)
		pw2[i] = 2LL*pw2[i-1]%MOD;
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXN] = pow_mod(fct[MAXN], MOD-2);
	for(int i=MAXN-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}
int comb(int n, int m) {
	return 1LL*fct[n]*ifct[m]%MOD*ifct[n-m]%MOD;
}
int main() {
	init();	int N;
	scanf("%d", &N);
	int ans = pow_mod(3, N);
	for(int i=N/2+1;i<=N;i++)
		ans = sub(ans, 2LL*comb(N, i)*pw2[N-i]%MOD);
	printf("%d\n", ans);
}

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

vector<int> to_xor(vector<int> x)
{
    int n = x.size();
    vector<int> ret(n);
    for (int i = 0; i < n; i++)
    {
        ret[i] = x[i] ^ x[(i + 1) % n];
    }
    return ret;
}

template <typename T>
class MP
{
    long long n;
    T query;
    vector<long long> table;

public:
    MP(const T &str)
    {
        this->query = T(str);
        this->n = this->query.size();
        this->table = vector<long long>(this->n + 1, -1);
        long long j = -1;
        for (long long i = 0; i < this->n; i++)
        {
            while (j != -1 && this->query[j] != this->query[i])
            {
                j = this->table[j];
            }
            j++;
            this->table[i + 1] = j;
        }
    }

    int operator[](const int i)
    {
        return this->table[i];
    }

    vector<long long> find_from(const T &document)
    {
        vector<long long> res;
        long long j = 0;
        for (long long i = 0; i < document.size(); i++)
        {
            while (j != -1 && this->query[j] != document[i])
            {
                j = this->table[j];
            }
            j++;
            if (j == this->n)
            {
                res.push_back(i - j + 1);
                j = this->table[j];
            }
        }
        return res;
    }
};

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

    vector<int> a(N);
    for (int &aa : a)
    {
        cin >> aa;
    }
    vector<int> axor = to_xor(a);
    axor.insert(axor.end(), axor.begin(), axor.end());

    vector<int> b(N);
    for (int &bb : b)
    {
        cin >> bb;
    }
    vector<int> bxor = to_xor(b);

    MP<vector<int>> mp(bxor);
    for (int i : mp.find_from(axor))
    {
        if (i >= N)
        {
            continue;
        }
        cout << i << " " << (a[i] ^ b.front()) << endl;
    }
}


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

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

    for(int cx=0; cx<=100; cx++){
        for(int cy=0; cy<=100; cy++){
            bool flag = true;
            int maxH = 2000000000;
            int H = -1;
            for(int i=0; i<N; i++){
                int tmp = abs(x[i]-cx) + abs(y[i]-cy);
                if(h[i] == 0){
                    maxH = min(maxH, tmp);
                }else{
                    if(H == -1) H = tmp + h[i];
                    else if(H != tmp + h[i]){
                        flag = false;
                        break;
                    }
                }
            }
            if(flag && H <= maxH && H >= 1){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>

using namespace std;

typedef vector<string> V;
typedef queue<string> Q;

bool is_used(string &s, int n, char c) {
    for (int i=0; i<n; i++) {
        if (s[i] == c) {
            return true;
        }
    }
    return false;
}

V enumerate(string cipher) {
    V candidates;
    Q q;
    q.push("");
    while (!q.empty()) {
        string substr = q.front();
        unsigned int n = substr.length();
        q.pop();
        if (n == cipher.length()) {
            candidates.push_back(substr);
            continue;
        }
        if (cipher[n] == 'a') {
            q.push(substr+'a');
            if (!is_used(substr, n, 'b')) {
                q.push(substr+'b');
            }
        }
        else if (cipher[n] < 'z') {
            char c = cipher[n];
            if (is_used(substr, n, c)) {
                q.push(substr+c);
            }
            if (!is_used(substr, n, c+1)) {
                q.push(substr+(char)(c+1));
            }
        }
        else {
            if (is_used(substr, n, 'z')) {
                q.push(substr+'z');
            }
        }
    }
    return candidates;
}

int main() {
    int n;
    string cipher;
    V candidates;
    while (true) {
        cin >> cipher;
        if (cipher == "#") {
            return 0;
        }
        candidates = enumerate(cipher);
        n = candidates.size();
        cout << n << endl;
        for (int i=0; i<min(5, n); i++) {
            cout << candidates[i] << endl;
        }
        for (int i=max(n-5, 5); i<n; i++) {
            cout << candidates[i] << endl;
        }
    }
}

Measured memory_bytes: 3044
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int[] A = new int[M];
		for (int i = 0; i < N; i++) {
			int K = in.nextInt();
			for (int j = 0; j < K; j++) {
				int index = in.nextInt();
				A[index-1]++;
			}
		}
		int count = 0;
		for (int a : A) {
			if (a == N) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23124
#include<iostream>
using namespace std;string s;int main(){for(;getline(cin,s),s!="END OF INPUT";){int j,i,m=int(s.size());for(j=i=0;i<m;i++){if(s[i]==' '){cout<<i-j;j=i+1;}}cout<<m-j<<endl;}}

Measured memory_bytes: 1180
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
    ll  X,Y,A,B,C,sum=0;
	cin>>X>>Y>>A>>B>>C;
	vector<ll>p(A);
	vector<ll>q(B);
	vector<ll>r(C);
	vector<ll>ans;
	for(ll i=0;i<A;i++)cin>>p[i];
	for(ll i=0;i<B;i++)cin>>q[i];
	for(ll i=0;i<C;i++){cin>>r[i];ans.push_back(r[i]);}
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	sort(r.rbegin(),r.rend());
	for(ll i=0;i<X;i++){ans.push_back(p[i]);}
	for(ll i=0;i<Y;i++){ans.push_back(q[i]);}
	sort(ans.rbegin(),ans.rend());
	for(int i=0;i<X+Y;i++)
	{
		sum+=ans[i];
	}
	cout<<sum;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string s,t;

int main(){
	cin>>s>>t;
  int n=s.size();
  int m=t.size();
  string res="~";
  rep(i,n-m+1){
    bool ok=true;
    rep(j,m){
      if(s[i+j]!=t[j]&&s[i+j]!='?')ok=false;
    }
    if(!ok)continue;
    string tmp;
    rep(j,n){
      if(j>=i&&j<i+m)tmp+=t[j-i];
      else if(s[j]=='?')tmp+="a";
      else tmp+=s[j];
    }
    minch(res,tmp);
  }
  if(res=="~")cout<<"UNRESTORABLE"<<endl;
  else  cout<<res<<endl;
	return 0;
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, int> smap;
    svec ans;
    int m=0;
    for (size_t i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(!smap.count(s)) smap[s] = 1;
        else smap[s]++;
    }
    for( auto i = smap.begin(); i != smap.end() ; ++i ) m = max(i->second, m);
    for( auto i = smap.begin(); i != smap.end() ; ++i ) {
        if(i->second == m) ans.push_back(i->first);
    }
    sort(ans.begin(), ans.end());
    for (auto &a : ans) cout << a << endl;
    return 0;

}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000007;

int N, M;

int main(){
    cin >> N >> M;
    vector<int> a(M), b(M);

    a[0] = 1;
    for(int i = 1; i < M; i++){
        a[i] = a[i-1] + 1;
    }
    b[0] = N;
    for(int i = 1; i < M; i++){
        b[i] = b[i-1] - 1;
    }

    if(N%2 == 0){
        for(int i = N/4; i < M; i++){
            b[i]--;
        }
    }

    rep(i,M){
        cout << a[i] << " " << b[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3860
//https://atcoder.jp/contests/abc137/tasks/abc137_a

#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stderr, stdin, BufRead, Write};

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn main() {
    let (a,b) = read!(i64, i64);

    let mut ans = max(a+b, a-b);
    ans = max(ans, a*b);

    println!("{}", ans)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;

    int ans=0;
    if(2*C>A+B) ans=A*X+B*Y;
    else{
        ans=2*C*min(X,Y);
        if(X>Y) ans+=min(2*C,A)*(X-Y);
        else ans+=min(2*C,B)*(Y-X);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll A , B;
ll fnd()
{
        ll K = A*B;
        ll hi = 1e9+7;
        ll lo = 0;
        while(hi > lo)
        {
                ll md = lo + (hi - lo + 1) / 2;
                if(md*md < K) lo = md;
                else hi = md-1;
        }
        return hi;
}
int main()
{
        ll Q;
        cin >> Q;
        while(Q--)
        {
                cin >> A >> B;
                if(A == B) {
                        cout << A + A - 2 << "\n"; continue;
                }
                ll C = fnd();
                if(C*(C+1) >= A*B) cout << C + C - 2 << "\n";
                else cout << C + C - 1 << "\n";
        }
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    lld d,t,s;   cin>>d>>t>>s;
    lld time=d/s;
    if(time<=t){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}

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

using namespace std;

typedef long long int ll;
#define pb push_back


vector< vector<int> > gr;


int dp[1000005];
int vis[1000005];
int timeIn[1000005];
int timeOut[1000005];
int time_=0;


int n,m;


int find(int u)
{
	if(dp[u]!=-1) return dp[u];

	int mx=0;

	for(int i=0;i<gr[u].size();i++)
	{
		mx=max(1+find(gr[u][i]),mx);
	}
	return dp[u]=mx;
}

void DFS(int u)
{
	vis[u]=1;
	timeIn[u]=++time_;

	for(int i=0;i<gr[u].size();i++)
	{
		if(vis[gr[u][i]]==0)
		{
			vis[gr[u][i]]=1;
			DFS(gr[u][i]);
		}
	}
	timeOut[u]=++time_;

}

bool isCyclic()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<gr[i].size();j++)
		{
			if(timeOut[gr[i][j]]>=timeOut[i]) return 1;
		}
	}
	return 0;
}




int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);

	
	memset(dp,-1,sizeof(dp));

	cin>>n;

	for(int i=0;i<=n*n;i++)
	{
		vector<int> v;
		gr.pb(v);
	}

	int l,r,now,l1,r1;


	for(int i=0;i<n;i++)
	{
		cin>>r;
		l=i;
		r--;
		l1=min(l,r);
		r1=max(l,r);
		now=n*l1+r1;
		for(int j=1;j<n-1;j++)
		{
			cin>>r;
			l=i;r--;
			l1=min(l,r);
			r1=max(l,r);
			gr[now].pb(n*l1+r1);
			now=n*l1+r1;
		}
	}

	n*=n;

	memset(vis,0,sizeof(vis));
	memset(timeIn,0,sizeof(timeIn));
	memset(timeOut,0,sizeof(timeOut));

	for(int i=0;i<n;i++)
	{
		if(!vis[i]) DFS(i);
	}


	if(isCyclic())
	{
		cout<<-1<<'\n';
		return 0;
	}


	
	for(int i=1;i<=n;i++)
	{
		int tt=find(i);
	}
	
	int mx=0;

	for(int i=1;i<=n;i++) mx=max(mx,dp[i]);

	cout<<mx+1<<'\n';
	return 0; 
}











Measured memory_bytes: 55908
import heapq
def main():
    N, M = map(int, input().split())
    a = list(map(lambda x: -int(x), input().split()))

    heapq.heapify(a)
    for i in range(M):
        temp = heapq.heappop(a)
        heapq.heappush(a, -(-temp//2))
    print(-sum(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14180
#include<stdio.h>

int main(void){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(x >= r && y>= r && (H - r) >= y && (W - r) >= x){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>

int main(void) {
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    char s[n];
    scanf("%s",s);
    
    int A=0,B=0;/*通過した人数*/
    int i;
    for(i=0;i<=n-1;i++){
        if(s[i]=='c'){
            printf("No\n");
        }else if(s[i]=='a'){
            if(A+B<a+b){
                printf("Yes\n");
                A+=1;
            }else{
                printf("No\n");
            }
        }else if(s[i]=='b'){
            if(A+B<a+b && B<b){
                printf("Yes\n");
                B+=1;
            }else{
                printf("No\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++)
	{	//cout<<"Case #"<<i<<": ";
		solve();

	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{
	string s;
	cin >> s;
	ll sum = 0;
	for (int i = 0; i < s.size(); i++)
	{
		sum += (int)s[i];
	}
	if (sum % 3 == 0)
	{
		cout << "Yes";
	}
	else
		cout << "No";
}



Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>c>>a>>b;
    cout<<(a-b>=0?"delicious":(c-b+a<0?"dangerous":"safe"))<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int max(int a, int b) {
	return a > b ? a : b;
}

void swap(int *a, int *b) {
	int temp = *a;
	*a = *b;
	*b = temp;
/*
	*a ^= *b;
	*b ^= *c;
	*a ^= *b;
*/
}

int main() {
	int a, b, c, m, i, n, f;

	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d%d%d", &a, &b, &c);

/*
		// バブルソート
		if (b < c) swap(&b, &c);
		if (a < b) swap(&a, &b);
		if (b < c) swap(&b, &c);

		// a > b > c が保証される
		if (a * a == b * b + c * c)
			printf("YES");
		else
			printf("NO");
*/

		m = max(max(a, b), c);

		if (m*m == a*a + b*b + c*c - m*m)
			printf("YES");
		else
			printf("NO");

		puts("");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e9
#define MOD 1e9 + 7
using namespace std;
const double EPS = 1e-9;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

struct Point3D {
  double x, y, z;
  Point3D() : x(0), y(0), z(0) {}
  Point3D(double x, double y, double z) : x(x), y(y), z(z) {}
  Point3D operator+(const Point3D &o) const { return Point3D(x + o.x, y + o.y, z + o.z); }
  Point3D operator-(const Point3D &o) const { return Point3D(x - o.x, y - o.y, z - o.z); }
  Point3D operator*(const double m) const { return Point3D(x * m, y * m, z * m); }
  Point3D operator/(const double d) const { return Point3D(x / d, y / d, z / d); }

  bool operator==(const Point3D &o) const { return fabs(x - o.x) < EPS && fabs(y - o.y) < EPS; }
};

double dot(Point3D a, Point3D b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
Point3D cross(Point3D a, Point3D b) { return Point3D(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); }
double norm(Point3D p) { return dot(p, p); }
double abs(Point3D p) { return sqrt(norm(p)); }

struct Line {
  Point3D a, b;
  Line() : a(Point3D(0, 0, 0)), b(Point3D(0, 0, 0)) {}
  Line(Point3D a, Point3D b) : a(a), b(b) {}
};

Point3D projection(Line l, Point3D p) {
  Point3D base = l.b - l.a;
  double t = dot(base, p - l.a) / dot(base, base);
  return l.a + base * t;
}

struct Ball {
  Point3D p;
  double r;
  Ball() : p(Point3D(0, 0, 0)), r(0.0) {}
  Ball(Point3D p, double r) : p(p), r(r) {}
};

signed main() {
  int N, Q;
  cin >> N >> Q;
  vector<Ball> b(N);
  vector<int> cost(N);
  rep(i, N) cin >> b[i].p.x >> b[i].p.y >> b[i].p.z >> b[i].r >> cost[i];

  rep(i, Q) {
    int ans = 0;
    Point3D s, d;
    cin >> s.x >> s.y >> s.z >> d.x >> d.y >> d.z;
    Line line(s, d);

    rep(j, N) {
      Point3D proj = projection(line, b[j].p);
      if (abs(line.b - line.a) >= abs(proj - line.a) && abs(line.a - line.b) >= abs(proj - line.b)) {
        if (abs(proj - b[j].p) < b[j].r + EPS) {
          ans += cost[j];
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3228
#include<stdio.h>

int main(void)
{
	
	int a, b;
	
    scanf("%d %d",&a, &b);
    
    if(a > b){
    	printf("a > b\n");
    }
    else if(a < b){
    	printf("a < b\n");
    	}
    else{
    	printf("a == b\n");
    };
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cnt++;
    if (i < N - 1 ) {
      while(d.at(i) == d.at(i+1)) {
        i++;
        if (i == N - 1) break;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int n;
	cin>>n;
	int x=n,y=0;
	y+=n/15;
	cout<<x*800-y*200<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
 
const int N=1e6+5,MOD=1e9;
 
const int dx[]={0,1,-1,0},
          dy[]={1,0,0,-1};
 
typedef long long ll;
 
int n,m,k,a[N],b[N],q,u,x,y,tc,c,ans;
 
char s[N],s2[N];
 
vector<int> v;

int main() {
   
    bool ok=true;
    scanf("%s",s);
    for(int i=0;s[i];i++){
        if (i%2==0 && s[i]=='L'){
            ok=false;
        }
        else if (i%2==1 && s[i]=='R'){
            ok=false;
        }
    }
    if (ok)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;
const int MAXN=1e5+5;
long long sum,ans;
int n,m,flag,vis[MAXN],cnt[2];
vector<int> v[MAXN];
inline int read()
{
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x;
}
void dfs(int x)
{
	cnt[vis[x]-2]++;
	for(int i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]])
		{
			if(vis[v[x][i]]==vis[x]) flag=1;
			continue;
		}
		vis[v[x][i]]=vis[x]^1;
		dfs(v[x][i]);
	}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			vis[i]=2,dfs(i),sum=cnt[0]+cnt[1];
			ans+=flag?sum*(sum-1)/2:1ll*cnt[0]*cnt[1];
			sum=cnt[0]=cnt[1]=flag=0;
		}
	printf("%lld\n",ans-m);
	return 0;
}

Measured memory_bytes: 10252
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var t = "abc";

        var all = true;
        for (int i = 0; i < 3; i++)
        {
            var any = false;
            for (int j = 0; j < 3; j++)
            {
                if (t[i] == s[j])
                {
                    any |= true;
                }
            }
            all &= any;
        }

        Console.WriteLine(all ? "Yes" : "No");
    }
}


Measured memory_bytes: 13140
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)



Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		string t="."+sc.S;
		string ans="Yes";
		if(s[1]>s[3]||s[2]>s[4]){ans="No";}
		for(int i = 1;i<=s[0];i++) {
			if(t[i]=='#'&&t[i-1]=='#'){
				if(s[1]<i&&i<s[3]){ans="No";}
				if(s[2]<i&&i<s[4]){ans="No";}
			}
		}
		if(ans=="No"){
			Console.WriteLine("{0}",ans);
			return;
		}
		if(s[1]<s[2]&&s[3]>s[4]){
			ans="No";
			int q=0;
			for(int i = s[2]-1;i<=s[4]+1;i++) {
				if(t[i]=='.'){q++;}
				else{q=0;}
				if(q>=3){ans="Yes";break;}
			}
		}
		if(s[1]>s[2]&&s[3]<s[4]){
			ans="No";
			int q=0;
			for(int i = s[1]-1;i<=s[3]+1;i++) {
				if(t[i]=='.'){q++;}
				else{q=0;}
				if(q>=3){ans="Yes";break;}
			}
		}

		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return (Console.ReadLine()+" 0").Split();}}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 12896
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

a,b=map(int,input().split())
cnt=0
n=1
while n<b:
    n=(n-1)+a
    cnt+=1
print(cnt)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
	ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0){
    cout<<0<<endl;
    return 0;
  }else{
    cout<<min(min(a*b,b*c),c*a)<<endl;
    return 0;
  }
}

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

using namespace std;

#define int long long
#define MP make_pair
#define F first
#define S second
#define pi pair<int,int> 
#define sz(s) ((int)s.size())
#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)

const unsigned mod = 1e9 + 7;
const unsigned N = 5e5 + 4;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  const int mx = sqrt(n);
  set<int> st;
  rep(i,2,mx) {
  	if (n % i == 0) {
  		st.insert(i);
  		st.insert(n/i);
  	}
  }
  int ans = 1;
  for (int x: st) {
  	int tmp = n;
  	while (tmp % x == 0)
  		tmp /= x;
  	ans += (tmp % x == 1);
  }
  const int mx2 = sqrt(n-1);
  --n;
  rep(i,1,mx2) {
  	if (n % i == 0) {
  		if (i > 1)
  		ans += !st.count(i);
  		if (i != n/i) {
  			ans += !st.count(n/i);
  		}
  	}
  }
  cout << ans << '\n';




  
  assert(numeric_limits<int>::max() >= 1e18);
  return 0;
}

Measured memory_bytes: 512