akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int d[N];
    for (int i = 0; i < N; i++) {
	cin >> d[i];
    }
    sort(d, d + N);
    int c = d[N / 2] - d[N / 2 - 1];
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll x;
    cin>>x;
    for(ll i = -1000; i <= 1000; i++){
        for(ll j = -1000; j <= 1000; j++){
            ll aa = i*i*i*i*i;
            ll bb = j*j*j*j*j;
            if(aa-bb == x){
                print(i<<" "<<j);
                ret;
            }
        }
    }
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cctype>
using namespace std;

int main() {
  char c;
  int a, pass;
  a = 0;
  pass = 0;
  while ((c=getchar())!=EOF) {
    if (isdigit(c)) {
      a *= 10;
      a += c - '0';
    } else if (a) {
      pass += a;
      a = 0;
    }
  } 
  pass += a;
  printf("%d\n", pass);
  return 0;
}

Measured memory_bytes: 932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int d1[200005],d2[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        d1[i]=x+y;
        d2[i]=x-y;
    }
    sort(d1,d1+n);
    sort(d2,d2+n);
    cout<<max(d1[n-1]-d1[0],d2[n-1]-d2[0])<<endl;
    return 0;
}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (upper_bound(ALL(c),x)-lower_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *min_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   int H, W; cin >> H >> W;
   V<V<int>> c(H, V<int>(W));
   REP(i, H) {
      REP(j, W) {
         cin >> c[i][j];
      }
   }

   V<V<int>> h(H, V<int>(W+2));
   REP(i, H) REP(j, W) {
      if (c[i][j] == 1) {
         h[i][j+1] = 0;
      } else {
         h[i][j+1] = 1 + (i == 0 ? 0 : h[i-1][j+1]);
      }
   }
   REP(i, H) h[i][0] = -1;

   int ans = 0;
   REP(i, H) {
      stack<int> st;
      REP(j, W+2) {
         while (!st.empty() && h[i][st.top()] >= h[i][j]) {
            int m = h[i][st.top()]; st.pop();
            chmax(ans, m * (j - st.top() - 1));
         }
         st.push(j);
      }
   }
   cout << ans << endl;

   return 0;
}



Measured memory_bytes: 33644
def ll():
    return list(map(int,input().split()))
def l():
    return int(input())
n = l()
s = ll()
count=0
for i in range(len(s)-2):
    b = [s[i],s[i+1],s[i+2]]
    c = sorted(b)
    if b[1]==c[1]:
        count+=1
print(count)

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

int n, m;
int w[100][100];
int p[50][50];
int b;
bool input() {
  cin >> n >> m;
  if (!n && !m) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> w[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> p[i][j];
    }
  }
  return true;
}

void rotate() {
  int tmp[50][50];
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      tmp[i][j] = p[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      p[i][j] = tmp[m - 1 - j][i];
    }
  }
}

bool check(int r, int c) {
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      if (p[i][j] == -1) {
        continue;
      }
      if (p[i][j] != w[r + i][c + j]) {
        return false;
      }
    }
  }
  return true;
}

void solve() {
  b = n * n;
  for (int i = 0; i < 4; ++i) {
    bool found = false;
    int dr = -1;
    int dc = -1;
    for (int r = 0; r < m; ++r) {
      for (int c = 0; c < m; ++c) {
        if (p[r][c] != -1) {
          dr = r;
          dc = c;
          found = true;
          break;
        }
      }
      if (found) {
        break;
      }
    }

    found = false;
    for (int r = 0; r <= n - m; ++r) {
      for (int c = 0; c <= n - m; ++c) {
        int bb = (r + dr) * n + c + dc;
        if (check(r, c)) {
          if (b > bb) {
            b = bb;
          }
          found = true;
          break;
        }
      }
      if (found) {
        break;
      }
    }
    rotate();
  }

  if (b == n * n) {
    cout << "NA" << endl;
    return;
  } else {
    cout << b % n + 1 << " " << b / n + 1 << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3156
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.close();
    int nn = 0;
    int ans = 0;
    for(int i=1;i<=n;i++) {
    	for(int j=1;j<=n;j++) {
    		if((i%j==0)&&(i%2==1)) {
    			nn++;
    		}
    	}
    	if(nn == 8) {
    		ans++;
    	}
    	nn = 0;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}


Measured memory_bytes: 3640
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!(
    n: usize,
    m: usize,
    a: [usize; n],
    );
    let s:usize = a.iter().sum();
    let t = a.into_iter().filter(|&x| x * 4 * m >= s).count();
    let ans = if t >= m {"Yes"} else { "No" };
    println!("{}", ans);
}



Measured memory_bytes: 4352
// Date: 2020-03-14

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n;
LL a[N], h[N], c[N], dp[N];

int lowbit(int x) { return x & -x; }

LL ask(int x) {
    LL ans = 0;
    while(x) {
        chkmax(ans, c[x]);
        x -= lowbit(x);
    }
    return ans;
}

void add(int x, LL v) {
    while(x <= n) {
        chkmax(c[x], v);
        x += lowbit(x);
    }
}

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> h[i];
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) {
        dp[i] = ask(h[i]-1) + a[i];
        add(h[i], dp[i]);
    }
    LL ans = 0;
    rep(i, 1, n) chkmax(ans, dp[i]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int a, b, c ,d;
    
    scanf("%d%d%d%d", &a, &b, &c, &d);
    
    while (1) {
        c=c-b;
        a=a-d;
        if (c<=0) {
            printf("Yes");
            break;
        } else if(a<=0){
            printf("No");
            break;
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 1728
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	dp := [3010][3010]int{}
	dp[a][b] = 1
	for i := a; i <= c; i++ {
		for j := b; j <= d; j++ {
			dp[i][j+1] = add(dp[i][j+1], mul(dp[i][j], i))
			dp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], j))
			dp[i+1][j+1] = sub(dp[i+1][j+1], mul(dp[i][j], i*j))
		}
	}
	ans := dp[c][d]
	fmt.Println(ans)
}

const mod int = 998244353

func add(a, b int) int {
	return (a + b) % mod
}

func sub(a, b int) int {
	return (a + mod - b) % mod
}

func mul(a, b int) int {
	return a % mod * b % mod % mod
}


Measured memory_bytes: 74764
#include<stdio.h>
int main(){
  int c;
  int d[]={1,5,10,50,100,500};
  int s,i;
  for(i=s=0;i<6;i++){
    scanf("%d",&c);
    s+=c*d[i];
  }
  if(s<1000)printf("0\n");
  else      printf("1\n");
  return 0;
}

Measured memory_bytes: 584
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] < @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < (@data.size - 1)
  end
end


N, M = gets.chomp.split(' ').map(&:to_i)

AB = []
N.times do |i|
  AB[i] = gets.chomp.split(' ').map(&:to_i)
end

group_by_day = Hash[AB.group_by{|v|v[0]}.sort]

day_fee = Array.new(M){[]}
group_by_day.each do |k,v|
  day_fee[k-1] = v.map{|j| j[1]}
end

# require 'pry'
# binding.pry

ans = 0
pq = PriorityQueue.new
day_fee.each_with_index do |fees, idx|
  break if idx > M - 1
  fees.each do |fee|
    pq.push(fee*(-1))
  end
  ans += pq.pop.to_i
  # p pq
  # p pq.pop*(-1)
end

puts ans*(-1)


Measured memory_bytes: 38284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int s; cin>> s;
    int a = s / 100;
    int b = s - a * 100;
    int ja=0, jb=0;
    if(b >= 13 || b <= 0) jb=1;

    if(a >= 13 || a<=0) ja=1;

    if(jb == 0 && ja == 0) cout<< "AMBIGUOUS" << endl;
    else if(jb == 1 && ja == 0) cout<< "MMYY" << endl;
    else if(jb == 0 && ja == 1) cout<< "YYMM" << endl;
    else cout<< "NA" << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <sstream>

using namespace std;

class c_main
{
private:
    
public:
    c_main();
    void f_input();
};

c_main::c_main()
{

}

void c_main::f_input()
{
    double xp1,yp1,xp2,yp2;
    int q;
    int i;
    double x[1000];
    double y[1000];
    double a;
    double b;
    double x_a;
    double y_a;
    double x_a_a;
    double y_a_a;
    double a_a;
    double b_a;
    int pt1;

    cin >> xp1 >> yp1 >> xp2 >> yp2;
    
    if (xp1 == xp2){
        x_a = xp1;
        y_a = 0;
        pt1 = 0;
    }else if (yp1 == yp2){
        x_a = 0;
        y_a = yp1; 
        pt1 = 1;
    }else{
        //cout << "yp2 = " << yp2 << endl;
        //cout << "yp1 = " << yp1 << endl;
        //cout << "xp2 = " << xp2 << endl;
        //cout << "xp1 = " << xp1 << endl;
        a_a = (yp2-yp1)/(xp2-xp1);
        //cout << "a_a = " << a << endl;
        a = -1 * (1/a_a);
        //cout << "a = " << a << endl;
        b_a = -1 * a_a * xp1+ yp1;
        pt1 = 2;
    }
    
    //cout << x_a << endl;
    //cout << y_a << endl;
    //cout << a << endl;
    
    cin >> q;
    
    for ( i = 0; i < q; ++i){
        cin >> x[i] >> y[i];
        if (pt1 == 0){
            //cout << x_a << " " << y[i] << endl;
            if (x_a < x[i]){
                x_a_a = x_a -(x[i] - x_a);
            }else{
                x_a_a = x_a +(x_a - x[i]);
            }            
            
            printf("%10.10f %10.10f\n", x_a_a,y[i]);
        }else if(pt1 == 1){
            //cout << x[i] << " " << y_a << endl;
            if (y_a < y[i]){
                y_a_a = y_a -(y[i] - y_a);
            }else{
                y_a_a = y_a +(y_a - y[i]);
            }  
            printf("%10.10f %10.10f\n", x[i],y_a_a);
        }else if(pt1 == 2){
            b = -1 * a * x[i] + y[i];
            x_a = (b - b_a)/(a_a - a);
            y_a = a_a * x_a + b_a;
            //cout << x_a << " " << y_a << endl;
            if (x_a < x[i]){
                x_a_a = x_a -(x[i] - x_a);
            }else{
                x_a_a = x_a +(x_a - x[i]);
            }     
            if (y_a < y[i]){
                y_a_a = y_a -(y[i] - y_a);
            }else{
                y_a_a = y_a +(y_a - y[i]);
            }  
            printf("%10.10f %10.10f\n", x_a_a,y_a_a);
        }
    }
}

int main(){
    c_main main01;
    main01.f_input();
    
    return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<long long,long long>
#define read(a) scanf("%d",&a)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define clr(a) memset(a,0,sizeof(a))
#define MOD 10000000000
#define INF 10000000000000;

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ar[n+10];
    ll dp[MAX];
    dp[0]=10000000000,dp[1]=0,ar[0]=10000000;
    for(int i=1;i<=n;i++) scanf("%d",&ar[i]);
    for(int i=2;i<=n;i++){
        ll p = dp[i-1]+abs(ar[i]-ar[i-1]);
        ll q = dp[i-2]+abs(ar[i]-ar[i-2]);
        dp[i]=min(p,q);
        //p3(dp[i],p,q);
    }
    cout<<dp[n]<<endl;


    return 0;
}


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

int main(){
  string s;
  cin>>s;
  ll ans=0;
  for(int bits=0; bits<(1<<(s.size()-1)); bits++){
    ll a=s[0]-'0';
    rep(i,s.size()-1){
      if((bits>>i)&1){
	ans+=a;
	a=s[i+1]-'0';
      }
      else{
	a=a*10+s[i+1]-'0';
      }
    }
    ans+=a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,k,a,b,c,p[100000],pl[100001],su[100001],g;
	int x,y;
	long long sum,xx,yy,mn;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d",&p[i]);
	for(i=1;i<=n;i++)	{
		pl[i]=0;	su[i]=0;
	}
	for(i=1;i<m;i++)	{
		x=p[i-1];	y=p[i];
		if(x>y)	swap(x,y);
		pl[x]++;	pl[y]--;
	}
	su[0]=0;
	for(i=1;i<=n;i++)	{
		su[i]=su[i-1]+pl[i];
	}
	sum=0;
	for(i=1;i<n;i++)	{
		scanf("%d %d %d",&a,&b,&c);
		xx=(long long)a*su[i];
		yy=(long long)b*su[i]+c;
		mn=min(xx,yy);
		sum+=mn;
	}
	printf("%lld\n",sum);
	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    int H,W; cin >> H >> W;
    VI use(26,0);
    REP(i,H*W){
        char c; cin >> c;
        use[c-'a']++;
    }

    int n = 0;
    REP(i,26){
        if(n < (H/2)*(W/2) && use[i]>=4){
            int tmp = min((H/2)*(W/2)-n, use[i]/4);
            n += tmp;
            use[i] -= tmp*4;
        }
    }
    if(n < (H/2)*(W/2)){
        cout << "No" << endl;
        return 0;
    }
    if(H%2){
        n = 0;
        REP(i,26){
            if(n < W/2 && use[i]>=2){
                int tmp = min(W/2-n, use[i]/2);
                n += tmp;
                use[i] -= tmp*2;
            }
        }
        if(n < W/2){
            cout << "No" << endl;
            return 0;
        }
    }
    if(W%2){
        n = 0;
        REP(i,26){
            if(n < H/2 && use[i]>=2){
                int tmp = min(H/2-n, use[i]/2);
                n += tmp;
                use[i] -= tmp*2;
            }
        }
        if(n < H/2){
            cout << "No" << endl;
            return 0;
        }
    }
    if(H%2 && W%2){
        n = 0;
        REP(i,26){
            if(use[i]%2){
                use[i] -= 1;
                n = 1;
                break;
            }
        }
        if(n < 1){
            cout << "No" << endl;
            return 0;
        }
    }
    int sum = 0;
    REP(i,26) sum += use[i];
    cout << (sum==0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mxn 100010
using namespace std;

ll a[mxn],stk[mxn];int tp,n,q;
ll cnt[mxn],add[mxn],mul[mxn];

int erf(int l,int r,ll x)
{
	int pos=r;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(stk[mid] <= x)	pos=mid,l=mid+1;
		else	r=mid-1; 
	}
	return pos;
}

void work(ll l,ll k,int x)
{
	if(!k)	return;
	if(k<=stk[1])
	{
		add[1] += l;
		add[k+1] -= l;
		return;
	}
	int pos=erf(1,x,k);
	ll tmp = k / stk[pos];
	mul[pos] += tmp*l;
	work(l,k%stk[pos],pos-1);
}

int main()
{
	scanf("%d%d",&n,&q);
	stk[++tp] = n;
	for(int i=1;i<=q;i++)
	{
		scanf("%lld",&a[i]);
		while(tp && stk[tp] >= a[i])	tp--;
		stk[++tp] = a[i];
	}
	mul[tp] = 1;
	for(int i=tp;i>=2;i--)
	{
		ll tmp = stk[i]/stk[i-1];
		ll fin = stk[i]%stk[i-1];
		mul[i-1] += mul[i]*tmp;
		work(mul[i],fin,i-1);
	}
	for(int i=1;i<=stk[1];i++)
	{
		add[i] += add[i-1];
		printf("%lld\n",mul[1]+add[i]);
	}
	for(int i=stk[1]+1;i<=n;i++)
		printf("0\n");
	return 0;
}

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

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

    vector<long long int> f(n+1,0);

    f[0] = 2;
    f[1] = 1;
    for(int i=2; i<n+1; i++){
        if(f[i] == 0){
            f[i] = f[i-1] + f[i-2];
        }
    }
    cout << f[n] << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.readline

n: int = int(input())
a = list(map(int, input().split()))
minus = Counter([i-a[i] for i in range(n)])
plus = Counter([i+a[i] for i in range(n)])

cnt: int = 0
i: int
for i in minus:
    if i in plus:
        cnt += minus[i] * plus[i]
print(cnt)


Measured memory_bytes: 61324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

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

    float t,x;
    cin>>t>>x;
    cout<<t/x<<endl;

    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,k,c,cnt1[maxn],cnt2[maxn];
string str;
bool b1[maxn]={false},b2[maxn]={false};
vector<int> vec1,vec2;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k >> c >> str;
	rep(n) if(str[i]=='o'){
		if(vec1.empty()) vec1.pb(i);
		else if(i-vec1.back()>c) vec1.pb(i);
	}
	rep3(i,n-1,0) if(str[i]=='o'){
		if(vec2.empty()) vec2.pb(i);
		else if(vec2.back()-i>c) vec2.pb(i);
	}
	rep(sz(vec1)) b1[vec1[i]]=true;
	rep(sz(vec2)) b2[vec2[i]]=true;
	cnt1[0]=0;
	rep(n) cnt1[i+1]=cnt1[i]+b1[i];
	cnt2[0]=0;
	rep(n) cnt2[i+1]=cnt2[i]+b2[n-1-i];
	rep(n) if(cnt1[i]+cnt2[n-1-i]<k) print1(i+1);
	return 0;
}

Measured memory_bytes: 8456
A,B,C,K =map(int,input().split())

if A >= K:
    print(K)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = A + c
    print(cc)
    


Measured memory_bytes: 9168
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;

const double PI = acos(-1.0);
typedef long long LL;
typedef complex<double> Complex;

void FFT(Complex* P, int n, int op) {
	for(int i = 1, j = 0; i < n - 1; i++) {
		for(int s = n; j ^= s >>= 1, ~j&s; );
		if(i < j) swap(P[i], P[j]);
	}
	int log = 0;
	while((1 << log) < n) log++;
	for(int s = 0; s < log; s++) {
		int m = 1 << s;
		int m2 = m << 1;
		Complex wm(cos(PI / m), sin(PI / m) * op);
		for(int i = 0; i < n; i += m2) {
			Complex w(1, 0);
			for(int j = 0; j < m; j++, w *= wm) {
				Complex u = P[i + j];
				Complex t = P[i + j + m] * w;
				P[i + j] = u + t;
				P[i + j + m] = u - t;
			}
		}
	}
	if(op == -1) for(int i = 0; i < n; i++) P[i].real(P[i].real() / n);
}

Complex P[2][1 << 22];

int n;

LL cnt[2100000];

double dist(double x, double y) {
	return sqrt(x * x + y * y);
}

int main()
{
	scanf("%d", &n);
	int sum = 0;
	int offset = (n - 1) * (n * 2 + 1);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			int x; scanf("%d", &x);
			sum += x;
			cnt[0] += (x - 1) * x / 2;
			int id = i * 2 * n + j;
			P[0][id] = x;
			P[1][offset-id] = x;
		}
	}

	int s = 1;
	while(s < offset * 2 + 1) s <<= 1;
	FFT(P[0], s, 1); FFT(P[1], s, 1);
	for(int i = 0; i < s; i++) P[0][i] *= P[1][i];
	FFT(P[0], s, -1);
	
	double ans = 0;
	for(int i = 1; i <= offset; i++) {
		LL t = (LL)(P[0][offset + i].real() + 0.5);
		if(!t) continue;
		int dx = ((i / n) + 1) >> 1;
		int dy = abs(i - dx * n * 2);
		ans += dist(dx, dy) * t;
		cnt[dx*dx+dy*dy] += t;
	}

	ans /= (double)sum * (sum - 1) / 2;
	printf("%.10f\n", ans);

	int num = 0;

	int top = (n - 1) * (n - 1) * 2;
	for(int i = 0; i <= top && num < 10000; i++) if(cnt[i]) {
		printf("%d %lld\n", i, cnt[i]);
		num++;
	}

	return 0;
}

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

int main() {
    int h; cin >> h;
    int n; cin >> n;
    int sum = 0;
    rep(i,n) {
        int a; cin >> a;
        sum += a;
    }
    if (h <= sum) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define whole(xs) xs.begin(), xs.end()

int n, w, d;

bool input() {
    cin >> n >> w >> d;
    if (n == 0 && w == 0 && d == 0) return false;
    return true;
}

struct S {
    int y, x;
    S(int y, int x) {
        this->y = y;
        this->x = x;
    }
    const int area() const {
        return y * x;
    }
    const int length() const {
        return 2 * (y + x);
    }
};
ostream& operator<<(ostream& os, S s) {
    os << "S(" << s.y << " " << s.x << ")";
    return os;
}
bool compare_area(const S& a, const S& b) {
    return a.area() < b.area();
}

void step(vector<S>& cakes, int index, int s) {
    S cake = cakes[index];
    s %= cake.length();
    vector<S> add;
    int y = cake.y, x = cake.x;
    if (0 <= s && s < x) {
        add.push_back(S(y, s));
        add.push_back(S(y, x - s));
    } else if (x <= s && s < x + y) {
        s = s - x;
        add.push_back(S(s, x));
        add.push_back(S(y - s, x));
    } else if (x + y <= s && s < x * 2 + y) {
        s = s - (x + y);
        add.push_back(S(y, s));
        add.push_back(S(y, x - s));
    } else {
        s = s - (x * 2 + y);
        add.push_back(S(y - s, x));
        add.push_back(S(s, x));
    }
    sort(whole(add), compare_area);
    cakes.insert(cakes.end(), whole(add));
    cakes.erase(cakes.begin() + index);
}

int main() {
    while (input()) {
        vector<S> cakes;
        cakes.push_back(S(d, w));
        for (int i = 0; i < n; i++) {
            int index, s;
            cin >> index >> s;
            index--;
            step(cakes, index, s);
        }
        sort(whole(cakes), compare_area);
        cout << cakes[0].area();
        for (int i = 1; i < cakes.size(); i++) {
            cout << " " << cakes[i].area();
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<cstdlib>
#define  ll int
using namespace std;
string s;
ll ans;
int main()
{
	cin>>s;
	for(ll i=0;i<s.size();++i)
	{
		if(s[i]!=s[s.size()-i-1]) ++ans;
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
d=dict()

for _ in range(n):
    a,b=map(int,input().split())
    if a in d:
        d[a]+=b
    else:
        d[a]=b
d=sorted(d.items() ,key=lambda x:x[0])

for kk,v in d:
    k-=v
    if k<=0:
        print(kk)
        exit()


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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: "List[int]", B: "List[int]"):
    AB = [[a,b] for a,b in zip(A, B)]
    AB = sorted(AB, key = lambda x: x[1], reverse = True)

    tail = 100000000000
    for a, b in AB:
        tail = min(tail - a, b - a)
        if tail < 0:
            print('No')
            exit()
    else:
        print('Yes')
    
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43032
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b = s_map()

    print('H' if a == b else 'D')

if __name__ == '__main__':
    main()


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

int main() {
    long k,n,sum1=0,sum2=0;
    cin>>k>>n;
    long ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
     long mx=k-ar[n-1]+ar[0];
    for(int i=0;i<n-1;i++)
    {
        sum1+=ar[i+1]-ar[i];
        mx=max(mx,ar[i+1]-ar[i]);
    }
    sum1+=ar[0]+k-ar[n-1];
    cout<<sum1-mx<<endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << (n%2==0?n:n*2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,j,s;
		for(i=1;i<=9;i++){
			for(j=1;j<=9;j++){
			s=i * j;
			printf("%dx%d=%d\n",i,j,s);
		}
	}
	 return 0;
}

Measured memory_bytes: 524
import bisect,collections,copy,heapq,itertools,math,numpy,string,decimal
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C,K = II()

ans = 0

if K <= A:
  ans = K
elif K > A:
  ans += A
  if K - A > B:
    ans -= K - A - B
print(ans)
  
  

Measured memory_bytes: 27232
n,k = map(int,input().split())
d = []
a = []

for i in range(k):
  d.extend(input())
  a.extend(input().split())

d1 = list(map(int,d))
a1 = list(map(int,a))

ct = 0

for j in range(1,n+1):
  if a1.count(j)==0:
    ct +=1
print(ct)

Measured memory_bytes: 9516
#include <cstdio>
#include <vector>

typedef struct Node {
    int id;
    int c[2];
    int parent;
    Node(){id = 0; c[0] = -1; c[1] = -1; parent = -1;};
    ~Node(){};
} Node;

void preorder_iter(std::vector<Node> &nodes, int id){
    if(id == -1) return;
    std::printf(" %d", id);
    preorder_iter(nodes, nodes[id].c[0]);
    preorder_iter(nodes, nodes[id].c[1]);
}

void inorder_iter(std::vector<Node> &nodes, int id){
    if(id == -1) return;
    inorder_iter(nodes, nodes[id].c[0]);
    std::printf(" %d", id);
    inorder_iter(nodes, nodes[id].c[1]);
}

void postorder_iter(std::vector<Node> &nodes, int id){
    if(id == -1) return;
    postorder_iter(nodes, nodes[id].c[0]);
    postorder_iter(nodes, nodes[id].c[1]);
    std::printf(" %d", id);
}

void solve(std::vector<Node> &nodes){
    int rootId = 0;
    for(auto &x: nodes){
        if(x.parent == -1){
            rootId = x.id;
        }
    }
    std::printf("Preorder\n");
    preorder_iter(nodes, rootId);
    std::printf("\n");
    std::printf("Inorder\n");
    inorder_iter(nodes, rootId);
    std::printf("\n");
    std::printf("Postorder\n");
    postorder_iter(nodes, rootId);
    std::printf("\n");
}

int main(){
    int n;
    std::scanf("%d", &n);
    std::vector<Node> nodes(n);
    for(int i = 0; i < n; ++i){
        int id;
        std::scanf("%d", &id);
        nodes[id].id = id;
	std::scanf("%d", &nodes[id].c[0]);
        std::scanf("%d", &nodes[id].c[1]);
        if(nodes[id].c[0] != -1) nodes[nodes[id].c[0]].parent = id;
        if(nodes[id].c[1] != -1) nodes[nodes[id].c[1]].parent = id;
    }
    solve(nodes);
    return 0;
}



Measured memory_bytes: 2760
n, m = map(int, input().split())

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

p = list(map(int, input().split()))

cnt = 0

for i in range(2 ** n):
    bin_i = '{:010b}'.format(i)[::-1]

    for i in range(m):
        ks = kss[i]
        k = ks[0]
        s = ks[1:]

        sum_s = 0

        for j in range(k):
            sum_s += int(bin_i[s[j]-1])

        if sum_s % 2 != p[i]:
            break
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="?":
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else :
        print(a//b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007


int main (){
  string S;
  cin>>S;
  if(S=="ABC") cout<<"ARC";
  else cout<<"ABC";
    
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() 
{
  ll n; cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  //ソートして真ん中のindexを調べて、その間のかずじゃん
  //真ん中2つが同じだったらぜろジャン
  sort(d.begin(), d.end());
  int middle1 = n / 2 - 1;
  int middle2 = n / 2;
  int ans;

  if (d[middle1] == d[middle2]){
    ans = 0;
  }else{
    ans = d[middle2] - d[middle1];
  }

  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103;
const ll INF=1LL<<60;

int main(){
    
    int N,K;cin>>N>>K;
    vector<ll> S(N),T(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
        if(i<K) T[i]=1;
        else T[i]=0;
    }
    
    sort(all(T));
    
    ll ans=INF;
    
    do{
        ll sum=0;
        ll M=0;
        for(int i=0;i<N;i++){
            if(T[i]){
                if(S[i]>M){
                    M=S[i];
                }else{
                    sum+=(M+1-S[i]);
                    M++;
                }
            }else M=max(M,S[i]);
        }
        //cout<<sum<<endl;
        ans=min(ans,sum);
    }while(next_permutation(all(T)));
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std; 
typedef long long ll; 
int arr[55], cnt; 
pair<int, int> ans[105]; 
int main()
{
	// freopen("ARC086-D.in", "r", stdin); 
	int n, mx = 0, mn = 0; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		if (arr[i] > arr[mx])
			mx = i; 
		if (arr[i] < arr[mn])
			mn = i; 
	}
	if (arr[mx] > 0 && arr[mn] < 0)
	{
		if (arr[mx] > -arr[mn])
		{
			for (int i = 0; i < n; i++)
			{
				if (arr[i] < 0)
				{
					ans[cnt++] = mp(mx, i); 
					arr[i] += arr[mx]; 
				}
			}
		}
		else
		{
			for (int i = 0; i < n; i++)
			{
				if (arr[i] > 0)
				{
					ans[cnt++] = mp(mn, i); 
					arr[i] += arr[mn]; 
				}
			}
		}
	}
	if (arr[0] > 0)
	{
		for (int i = 1; i < n; i++)
		{
			if (arr[i - 1] > arr[i])
			{
				ans[cnt++] = mp(i - 1, i); 
				arr[i] += arr[i - 1]; 
			}
		}
	}
	else
	{
		for (int i = n - 1; i > 0; i--)
		{
			if (arr[i] < arr[i - 1])
			{
				ans[cnt++] = mp(i, i - 1); 
				arr[i - 1] += arr[i]; 
			}
		}
	}
	printf("%d\n", cnt);
	for (int i = 0; i < cnt; i++)
		printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int a,b;
int main(){
  cin >> a >> b;
  cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
from itertools import permutations
import sys

N = int(sys.stdin.readline().rstrip())
P = [int(x) for x in sys.stdin.readline().rstrip().split()]
Q = [int(x) for x in sys.stdin.readline().rstrip().split()]


def nanba(N, P):
    P = tuple(P)
    for i, p in enumerate(permutations(range(1, N + 1), N)):
        # print(p)
        if P == p:
            return i
    return 0

a = nanba(N, P)
b = nanba(N, Q)

print(abs(a - b))


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
long long n,a[300001],p,ans;
int main()
{
	cin>>n;
	p=n*3;
	for(int i=1;i<=p;i++) cin>>a[i];
	sort(a+1,a+p+1);
	for(int i=p-1;i>=n+1;i-=2) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


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

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define pb push_back
#define ar array

typedef long long ll;
typedef long double ld;
//using ll = long long;

typedef vector<int> vi;

const ld EPS = 1e-9;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;

const double PI  =3.141592653589793238463;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r;
	cin >> r;
	double circumference = 2*PI*r;
	cout << circumference << endl;

}


Measured memory_bytes: 3800
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = 0 +: Vector.fill(n)(sc.nextInt()) :+ 0

  def cost(x: Int, y: Int): Int = (x - y).abs

  val sum = a.sliding(2).map{case Vector(x, y) => cost(x, y)}.sum

  val pw = new java.io.PrintWriter(Console.out)
  a.sliding(3).foreach{case Vector(x, y, z) =>
    println(sum - cost(x, y) - cost(y, z) + cost(x, z))
  }
  pw.flush()
}


Measured memory_bytes: 65656
n, k = map(int, input().split())
mod = 1000000007

b = mod-2
blis = []
c = 0
while b >0:
  if b & 1 == 1:
    blis.append(c)
  c += 1
  b >>= 1

def modinv(a):
  if a == 1:
    return 1
  else:
    res = 1
    li = []
    for _ in range(c):
      li.append(a%mod)
      a = a*a%mod
    for item in blis:
      res = res *li[item] %mod
    return res

if k >=n:
  L = 2*n-1
  ansbunsi =1
  for j in range(n-1):
    ansbunsi = ansbunsi*L%mod
    L -= 1
  ansbunbo = 1
  L = n - 1
  for j in range(n-1):
    ansbunbo = ansbunbo*L%mod
    L -= 1
  ansbunbo = modinv(ansbunbo)
  print(ansbunsi*ansbunbo%mod)

else:
  kaijou = [1, 1]
  for j in range(2, n+1):
    kaijou.append(kaijou[-1]*j%mod)
  
  ans = 0

  for m in range(k+1):
    ansbunsi = kaijou[n]*kaijou[n-1]%mod
    ansbunbo = kaijou[m]*kaijou[n-m]%mod
    ansbunbo = ansbunbo*kaijou[n-m-1]%mod
    ansbunbo = ansbunbo*kaijou[m]%mod
    ansbunbo = modinv(ansbunbo)
    ans += ansbunbo*ansbunsi
    ans %= mod
  
  print(ans)

Measured memory_bytes: 16780
#include<stdio.h>

int points[101];

int main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0;i < n * (n - 1) / 2;i++){
    int ai, bi, ci, di;
    scanf("%d%d%d%d", &ai, &bi, &ci, &di);
    if(ci == di){
      points[ai]++;
      points[bi]++;
    }
    else if(ci > di){
      points[ai] += 3;
    }
    else{
      points[bi] += 3;
    }
  }
  for(i = 1;i <= n;i++){
    int res = 1;
    for(j = 1;j <= n;j++){
      if(points[j] > points[i])res++;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 600
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(1, n - 1):
    per = [p[i - 1], p[i], p[i + 1]]
    per.sort()
    
    if per[1] == p[i]:
        ans += 1

print(ans)

Measured memory_bytes: 38256