akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class Vec;
Vec operator/(const Vec& v, const double& divisor);
Vec operator*(const double& scale, const Vec& v);

class Vec {
  using F = double;
  vector<F> container;

 public:
  Vec(size_t size) : container(size) {}
  Vec(initializer_list<F> elements)
      : container(elements.begin(), elements.end()) {}
  size_t dim() const { return container.size(); }
  F& operator[](const size_t size) { return container.at(size); }
  const F& operator[](const size_t size) const { return container.at(size); }
  Vec operator+(const Vec& other) const {
    Vec ret(*this);
    for (size_t i = 0; i < dim(); i++) ret[i] += other[i];
    return ret;
  }
  Vec operator-(const Vec& other) const { return (*this) + (-other); }
  Vec operator-() const { return -1.0 * (*this); }
  F inner(const Vec& other) const {
    F acc = 0;
    for (size_t i = 0; i < dim(); i++) {
      acc += (*this)[i] * other[i];
    }
    return acc;
  }
  F norm() const { return sqrt(inner(*this)); }
  Vec unit() const { return (*this) / this->norm(); }
  F ccw(const Vec& other) const {
    return (*this)[0] * other[1] - other[0] * (*this)[1];
  }
};
Vec operator/(const Vec& v, const double& divisor) { return 1.0 / divisor * v; }
Vec operator*(const double& scale, const Vec& v) {
  Vec ret(v);
  for (size_t i = 0; i < ret.dim(); i++) ret[i] *= scale;
  return ret;
}

class Segment {
  const Vec m_start;
  const Vec m_end;

 public:
  Segment(const Vec& start, const Vec& end) : m_start(start), m_end(end) {}
  bool intersect(const Segment& other, const double eps) {
    const Vec u = other.m_start - m_start, w = other.m_end - m_start;
    const Vec v0 = m_end - m_start, v1 = other.m_end - other.m_start;

    const double vn = v0.norm();
    double u_v = v0.inner(u) / vn;
    double w_v = v0.inner(w) / vn;
    if (abs(abs(u_v / u.norm()) - 1) < eps &&
        abs(abs(w_v / w.norm()) - 1) < eps) {
      if (u_v > w_v) {
        swap(u_v, w_v);
      }
      return !(u_v > vn + eps || w_v < -eps);
    }
    bool cond1 =
        v0.ccw(other.m_start - m_start) * v0.ccw(other.m_end - m_start) < eps;
    bool cond2 =
        v1.ccw(m_start - other.m_start) * v1.ccw(m_end - other.m_start) < eps;
    return cond1 && cond2;
  }
};

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

  rep(i, q) {
    double x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    if (Segment(Vec({x0, y0}), Vec({x1, y1}))
            .intersect(Segment(Vec({x2, y2}), Vec({x3, y3})), 1e-9)) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3292
s = gets.chomp.chars
t = gets.chomp.chars
ans = t.length

(s.length - t.length + 1).times {|n|
  sn = s[n .. (n + t.length - 1)]
  sum = 0
  t.length.times {|i|
    sn[i]
    t[i]
    if sn[i] != t[i]
      sum += 1
    else sum += 0
    end
    }
  if ans > sum
    ans = sum
  end
  }
p ans

Measured memory_bytes: 14172
N,M,Q = map(int, input().split())

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

# Aの数列を作る。長さがMAX=Nだからとりあえず全探索

ans = 0

for i1 in range(1, M+1):
    for i2 in range(i1, M+1):
        for i3 in range(i2, M+1):
            for i4 in range(i3, M+1):
                for i5 in range(i4, M+1):
                    for i6 in range(i5, M+1):
                        for i7 in range(i6, M+1):
                            for i8 in range(i7, M+1):
                                for i9 in range(i8, M+1):
                                    for i10 in range(i9, M+1):
                                        tmp = 0
                                        arrs = [0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a, b, c, d in arr:
                                            if arrs[b] - arrs[a] ==c:
                                                tmp += d
                                        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 9184
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
	"math"
)

var INF int32 = math.MaxInt32
var INF64 int64 = math.MaxInt64

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineNum64s(bf *bufio.Reader) []int64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int64{}
	for _, field := range fields {
		num, _ := strconv.ParseInt(field, 10, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	nab := readLineNums(bf)
	N, a, b := nab[0], nab[1], nab[2]

	M := 1000000007

	// 求(2^N)-1, 总的方案数量
	pow := func(b, n int) int {
		n0 := 1
		for n > 0 {
			if n%2 == 1 {
				n0 *= b
				n0 %= M
			}
			b *= b
			b %= M
			n /= 2
		}
		return n0
	}

	n0 := pow(2, N)-1

	// 排除两类方案
	n1 := 1
	for i:=1; i<=a; i++ {
		n1 *= (N-i+1)
		n1 %= M
	}
	for i:=1; i<=a; i++ {
		n1 *= pow(i, M-2)
		n1 %= M
	}

	n2 := 1
	for i:=1; i<=b; i++ {
		n2 *= (N-i+1)
		n2 %= M
	}
	for i:=1; i<=b; i++ {
		n2 *= pow(i, M-2)
		n2 %= M
	}

	ans := (n0+2*M-n1-n2) % M

	fmt.Println(ans)
}


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

#include <queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  int N, D, A;
  cin >> N >> D >> A;

  pii XH[N];
  rep(i, N) {
    int x, h; cin >> x >> h;
    XH[i] = pii(x, h);
  }
  sort(XH, XH+N);

  queue<pii> q;
  ll ans = 0;
  ll damage = 0;
  rep(i, N) {
    while (!q.empty() && q.front().second < XH[i].first) {
      damage -= q.front().first;
      q.pop();
    }
    ll h = XH[i].second;
    ll count = (h - (damage * A) + A - 1) / A;
    if (count > 0) {
      q.emplace(count, XH[i].first + 2 * D);
      damage += count;
      ans += count;
    }
  }


  while (!q.empty()) q.pop();
  ll tmp = 0;
  damage = 0;
  rrep(i, N-1) {
    while (!q.empty() && q.front().second > XH[i].first) {
      damage -= q.front().first;
      q.pop();
    }
    ll h = XH[i].second;
    ll count = (h - (damage * A) + A - 1) / A;
    if (count > 0) {
      q.emplace(count, XH[i].first - 2 * D);
      damage += count;
      tmp += count;
    }
  }
  cout << min(ans, tmp) << endl;

  // なんか、先頭から見ていって、必要回数と爆破の右端を記録。このキューを取る
  return 0;
}


Measured memory_bytes: 2688
//Insert DP
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int mod = 1000000007;
	int N, X;
	cin >> N >> X;
	vector<int> s(N, 0);
	for(int i = 0; i < N; i += 1)
	{
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	vector<vector<long>> dp(N + 1, vector<long>(X + 1, 0)); //dp[N][X] N is order i and X is first number on black board
	for(int x = 0; x <= X; x += 1)
	{
		dp[1][x] = x % s[0];
	}

	for(int i = 1; i < N; i += 1)
	{
		for(int x = 0; x <= X; x += 1)
		{
			dp[i + 1][x] = (dp[i][x % s[i]] + i * dp[i][x]) % mod; //insert in front of array and in mid of array
		}
	}
	cout << dp[N][X] << endl;
	return 0;
}



Measured memory_bytes: 158592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  set<string> st;
  REP(i,n){
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << '\n';
  return 0;
}


Measured memory_bytes: 19248
n = int(input())
A = sorted(map(int, input().split()))
used = set()

U = A[-1]+1
is_prime = [1]*U
cnt = [0]*U
depri = 0
for a in A:
    cnt[a] += 1
    if cnt[a] == 2 and is_prime[a]:
        depri += 1
    if is_prime[a]:
        used.add(a)
        for q in range(2*a, U, a):
            is_prime[q] = 0
print(len(used)-depri)


Measured memory_bytes: 129748
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
const long long INF=1e9+5;
const string alp="abcdefghijklmnopqrstuvwxyz";
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;

int main() {
  string s;
  cin>>s;
  vector<ll> judge(26,0);
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(s[i]==alp[j]){
        judge[j]++;
      }
    }
  }
  bool ans=true;
  for(int i=0;i<26;i++){
    if(judge[i]%2!=0){
      ans=false;
      break;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s,t,u;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	cin>>u;
	if(s==u) cout<<a-1<<" "<<b;
	else cout<<a<<" "<<b-1;
	return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

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

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

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let x: usize = read();

  let ans: usize = (x / 11) * 2 + if x % 11 > 6 { 2 } else if x % 11 > 0 { 1 } else { 0 };
  print!("{}", ans);
}


Measured memory_bytes: 4352
n=int(input())
h=list(map(int,input().split()))
ans=0
def mizu(h_list):
  global ans
  if not h_list:
    return
  if max(h_list)==0:
    return
  m=min(h_list)
  ans+=m
  h_list_=list(map(lambda x :x-m, h_list))
  zero_ind = h_list_.index(0)
  mizu(h_list_[:zero_ind])
  mizu(h_list_[zero_ind+1:])
mizu(h)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s;
	cin >> s;
	if(s[1] == 'B')
		cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}



Measured memory_bytes: 3620
// きりみんちゃんの配信からきました
// こういう問題苦手（実装がめんどくさい）
// だるいので愚直でいいや
package main

import "fmt"

var n int
var s string

func main() {
	alphabets := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	fmt.Scan(&n, &s)
	ans := 0
	// 区切る場所で区切って左右のアルファベットの登場するか否かを数えて比較して両方にあったらインクリメントしてansと比較
	// あーだるい。。
	for i := 1; i < n-1; i++ {
		pre, epi := make(map[string]bool), make(map[string]bool)

		for j := 0; j < i; j++ {
			t := string([]rune(s)[j])
			if _, ok := pre[t]; !ok {
				pre[t] = true
			}
		}
		for j := i; j < n; j++ {
			t := string([]rune(s)[j])
			if _, ok := epi[t]; !ok {
				epi[t] = true
			}
		}
		tmp := 0
		for _, a := range alphabets {
			if pre[a] && epi[a] {
				tmp += 1
			}
		}
		ans = max(ans, tmp)
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 4864
import java.util.*;

class Main{
  static int r,c,a;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int c = sc.nextInt();
    int[][] matrix = new int[r+1][c+1];
    for (int i= 0; i<r; i++) {
      for (int j= 0; j<c; j++) {
        a = sc.nextInt();
        matrix[i][j] = a;
        matrix[r][j] += a;
        matrix[i][c] += a;
        matrix[r][c] += a;
      }
    }
    for (int i= 0; i<r+1; i++) {
      for (int j= 0; j<c+1; j++) {
        if (j != c) {
        System.out.print(matrix[i][j] + " ");
        } else {
          System.out.println(matrix[i][j]);
        }
      }
    }
  }
}


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


int main() {
	int n;
	cin >> n;
	switch(n%10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon" << "\n";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon" << "\n";
			break;
		case 3:
			cout << "bon" << "\n";
			break;
	}
	return 0;
}


Measured memory_bytes: 3616
A,B = (int(a) for a in input().split())
if A+B<=A*B:
    if A-B<=A*B:
        print(A*B)
    else:
        print(A-B)
else:
    if A-B<=A+B:
        print(A+B)
    else:
        print(A-B)

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> loads(N, 0);
  
  for (int i=0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    
    loads.at(a-1) += 1;
    loads.at(b-1) += 1;
  }
  
  for (int i=0; i < N; i++) {
    cout << loads.at(i) << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

void Main() {
  // code
  pair<int, int> s, t;
  cin >> s.first >> s.second;
  cin >> t.first >> t.second;

  for (int i = s.first; i < t.first; ++i) cout << "R";
  for (int j = s.second; j < t.second; ++j) cout << "U";
  for (int i = s.first; i < t.first; ++i) cout << "L";
  for (int j = s.second; j < t.second; ++j) cout << "D";

  cout<<"D";
  for (int i = s.first; i < t.first+1; ++i) cout << "R";
  for (int j = s.second-1; j < t.second; ++j) cout << "U";
  cout<<"L";

  cout<<"U";
  for (int i = s.first; i < t.first+1; ++i) cout << "L";
  for (int j = s.second-1; j < t.second; ++j) cout << "D";
  cout<<"R";
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using pll = pair<long long, long long>;
pll sub(long long h, long long w) {
    if (h % 2 == 0 || w % 2 == 0) return {h*w/2, h*w/2};
    if (h > w) swap(h, w);
    return {h * (w+1)/2, h * (w-1)/2};
}


int main() {
    long long H, W;
    cin >> H >> W;
    long long res = H * W;

    for (long long h = 1; h < H; ++h) {
        vector<long long> a(3);
        a[0] = h * W;
        auto p = sub(H-h, W);
        a[1] = p.first, a[2] = p.second;
        sort(a.begin(), a.end());
        chmin(res, a.back() - a[0]);
    }
    for (long long w = 1; w < W; ++w) {
        vector<long long> a(3);
        a[0] = H * w;
        auto p = sub(H, W-w);
        a[1] = p.first, a[2] = p.second;
        sort(a.begin(), a.end());
        chmin(res, a.back() - a[0]);
    }
    cout << res << endl;
}


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

int main() {
  int N, K, V, A = 0;
  cin >> N >> K;
  V = K / 2;
  
  for (int i = 0; i < N; i++) {
    int X;
    cin >> X;
    if (X > V)
      A += (K - X) * 2;
    else
      A += X * 2;
  }
  
  cout << A;
}

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

int main() {
	string S; cin >> S;
	map<char, int> mp;
	mp['N']=mp['E']=mp['W']=mp['S']=0;
	for(int i=0; i<S.size(); ++i) if(!mp[S[i]]) ++mp[S[i]];
	if((mp['N']^mp['S']) || (mp['E']^mp['W'])) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int M, mi, ma;
  while (M = in(), mi = in(), ma = in(), M || mi || ma) {
    auto P = in(M);
    int gap = 0;
    int ans = 0;
    for (int border : P) {
      int lo = inf, hi = -inf;
      int pass = 0;
      for (int p : P) {
        if (border <= p) {
          pass++;
          chmin(lo, p);
        } else {
          chmax(hi, p);
        }
      }
      int g = lo - hi;
      if (mi <= pass && pass <= ma) {
        if (chmax(gap, g) || g == gap) chmax(ans, pass);
      }
    }
    pr(ans);
  }

  return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int[] array = { a, b, c };

        for (int i : array) {
            if (i < 1 || i > 10000) {
                System.exit(0);
            }
        }

        int stock = 0;

        if (array[0] > array[1]) {
            stock = array[0];
            array[0] = array[1];
            array[1] = stock;
        }

        if (array[1] > array[2]) {
            stock = array[1];
            array[1] = array[2];
            array[2] = stock;
        }

        if (array[0] > array[1]) {
            stock = array[0];
            array[0] = array[1];
            array[1] = stock;
        }

        print(array[0], array[1], array[2]);

        scan.close();
    }

    public static void print(int one, int tow, int three) {
        System.out.printf("%d %d %d\n", one, tow, three);
    }

}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  VI dp(n, -1);
  map<char, int> mp;
  mp['r'] = p; mp['s'] = r; mp['p'] = s;
  for(int i = 0; i < n; ++i) {
    if(dp[i] >= 0) continue;
    else {
      if(i + k < n && t[i] == t[i + k]) dp[i + k] = 0;
      dp[i] = mp[t[i]];
    }
  }
  ll ans = 0;
  rep(i, n) ans += dp[i];
  out(ans);
  return 0;
}


Measured memory_bytes: 848
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MAX_N = 50;
const int MAX_M = (MAX_N + 1) * (MAX_N);
int N, M, a[MAX_M], b[MAX_M];
bool used[MAX_N + 1];       // used[i]: iがすでに使われたかどうか.
bool G[MAX_N + 1][MAX_N + 1];

void solve() {
    int ans = 0;
    queue<int> que;
    rep(i, M) {
        fill(used, used + (N + 1), false);
        bool g[N + 1][N + 1];
        fill(g[0], g[N + 1], false);
        rep(n, M) g[a[n]][b[n]] = G[a[n]][b[n]], g[b[n]][a[n]] = G[b[n]][a[n]];

        g[a[i]][b[i]] = false, g[b[i]][a[i]] = false;
        que.push(1);
        int count = 0;
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            if (!used[v]) count++;
            used[v] = true;
            repone(j, N) {
                if (g[v][j]) {
                    que.push(j);
                    g[v][j] = false, g[j][v] = false;
                }
            }
        }
        if (count != N) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#define reg register
using namespace std;
const int MaxN=200005;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[MaxN];
bool prayforkyoani[MaxN];
signed main(void)
{
	reg int n,cnt=0;
	rd(n);
	for(reg int i=1;i<=n;++i)
		rd(a[i]);
	for(reg int i=n;i;--i)
	{
		reg int sum=0;
		for(reg int j=i<<1;j<=n;j+=i)
			sum+=prayforkyoani[j];
		if((sum&1)!=a[i])
			prayforkyoani[i]=1,++cnt;
	}
	printf("%d\n",cnt);
	for(reg int i=1;i<=n;++i)
		if(prayforkyoani[i])
			printf("%d ",i);
	return 0;
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 30;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll sum = 0;
    int n = 0;
    cin>>n;

    ll maxVal;
    cin>>maxVal;

    for(int i=1; i<n;i++)
    {
        ll a;
        cin>>a;
        if(a < maxVal)
            sum += (maxVal - a);
        else
            maxVal =a;
    }

    cout<< sum<<endl;

    return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i=1; i<=n; i++) {
    int t = (i/10000) % 10;
    int k = (i/1000) % 10;
    int c = (i/100) % 10;
    int d = (i/10) % 10;
    int m = i % 10;
    int temp = t+k+c+d+m;
    if(temp >= a && temp <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
	int h,w;
	cin>>h>>w;
	if(h == 1 || w == 1){
		cout<<1;
		return 0;
	}
	int baseceil = ceil(w/2.0);
	int basefloor = w/2;
	long long ans = ((1LL*(ceil(h/2.0)))*baseceil + (1LL*(h/2))*basefloor);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 088 _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

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

int H, W;
// Board[H][W];
string B[50];
int vx[] = {1,-1,0,0};
int vy[] = {0,0,1,-1};

vector<vector<int>> memo(50,vector<int>(50,0));
bool state[50][50] = {false};

int solve()
{
  // queueXとqueueYのpair
  queue<pair<int,int>> q;
  q.push({0,0});
  state[0][0] = true;
  //memo[0][0] = 0;
  
  while (!q.empty()) {
    auto tmp = q.front();
    q.pop();
    int x,y;
    tie(x,y) = tmp;
    if (x == W-1 && y == H-1) return memo[y][x];
    REP(i,4) {
      int nextX = x + vx[i];
      int nextY = y + vy[i];
      
      if (0 <= nextX && nextX < W
      &&  0 <= nextY && nextY < H
      //&& memo[nextY][nextX] == -1
      &&  state[nextY][nextX] == false
      &&  B[nextY][nextX] == '.') {
        state[nextY][nextX] = true;
        memo[nextY][nextX] = memo[y][x] + 1;
        q.push({nextX,nextY});
      }
    }
  }
  return 0;
}


int main()
{
  int cnt = 0;
  cin >> H >> W;
  REP(hi,H) {
    cin >> B[hi];
    REP(si,B[hi].size()) if (B[hi][si] == '#') ++cnt;
  }
  
  int ans, res = solve();
  if (res == 0) {
    ans = -1;
  } else {
    //ans = H*W - (#の数) - (すぬけ君が通るマスの数);
    ans = H*W - cnt - res - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import math

def solve(x):
  if x == 1:
    return x

  ans = 1
  for i in range(2, math.ceil(x ** 0.5)+1):
    j = 2
    while(i**j <= x):
      ans = max(ans, i**j)
      j += 1
  return ans

X = int(input())
print(solve(X))


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	a := make([]int, n)
	allXOR := 0
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
		allXOR ^= a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Print(allXOR ^ a[i])
		if i < n-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 7244
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();

        if(N%500==0||N-(N/500)*500<A){
        System.out.println("Yes");
    }else {
        System.out.println("No");
    } 
		
    }
}



Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)

a,b = map(int, input().split())

print((a-1)*(b-1))


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main() {
    int ans;
    string hoge;
    int k = 0;
    int num = -48;
    int abc[100];
    cin >> hoge >> k;
    for (int i = 0; i < hoge.size(); ++i) {
        num = num + hoge[i];
        abc[i] = num;
        num = -48;
    }
    for (int j = 0; j <k; ++j) {
        if (abc[j] != 1){
            ans = abc[j];
            break;
        } else {
            ans = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
using namespace std;
 
int const MAX_N = 128 * 1024;
 
int s[2][MAX_N], dp[2][MAX_N];

int main() {
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    
	int n;
	cin>>n;
	for (int i=0; i<2; i++)
		for (int j=0; j<n; j++) {
			cin>>s[i][j];
			dp[i][j] = -1;
			dp[i][j+1] = -1;
		}
	dp[0][0] = s[0][0];
	for (int j=0; j<n; j++) {
		dp[1][j] = max(dp[1][j], dp[0][j] + s[1][j]);
		if (j+1<n)
			for (int i=0; i<2; i++)
				dp[i][j+1] = max(dp[i][j+1], dp[i][j] + s[i][j+1]);
	}

	cout<<dp[1][n-1];
    return 0;
}  


Measured memory_bytes: 256
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
const int N= int(2e5)+10;
int f[N],a[N];
vector<pair<int,int> >v[N];


void update(pair<int,int> p)
{
    int l=p.F;
    int r=p.S+1;
    for(;l<N;l+=(l)&(-l))
        a[l]++;
    for(;r<N;r+=(r)&(-r))
        a[r]--;
}
int get(int l)
{
    int ans=0;
    for(;l>0;l-=(l)&(-l))
        ans+=a[l];
    return ans;
}
int main()
{
	//fr;fw;
	fast_io;
    int n,m;
    cin>>n>>m;
    REP(i,0,n)
    {
        int l,r;
        cin>>l>>r;
        f[r-l+1]++;
        v[r-l+1].PB({l,r});
    }
    for(int i=N-2;i>=0;i--)
    {
        f[i]+=f[i+1];
    }
    REP(i,1,m+1)
    {
        int ans=f[i];
        for(int j=i;j<=m;j+=i)
        {
            ans+=get(j);
        }
        for(auto w:v[i])
        {
            update(w);
        }
        cout<<ans<<endl;
    }



	return 0;
}






Measured memory_bytes: 11136
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n,c[maxn],num[maxn],fl;
bool vis[maxn];
char s[maxn];
int v[30][maxn];
inline int lowbit(int x){return x&(-x);}
void modify(int x,int k){for(int i=x;i<=n;i+=lowbit(i))c[i]+=k;}
int query(int x){int ans=0;for(int i=x;i>=1;i-=lowbit(i))ans+=c[i];return ans;}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) v[s[i]-'a'][++num[s[i]-'a']]=i;
    for(int i=0;i<26;i++){
        if(num[i]&1) fl++;
    }
    if(fl>1) {
		puts("-1");
		return 0;
	}
    for(int i=1;i<=n+1;i++)
		modify(i,1);
    long long ans=0;
    for(int i=1;i<=n;i++)if(!vis[i]){
        int c=s[i]-'a';
        int x=v[c][num[c]];
        if (i==x) ans+=(query(n)-query(i))>>1;
        else ans+=(query(n)-query(x));   
        modify(i,-1);
		if (i!=x) modify(x,-1);
        vis[i]=vis[x]=1;
        num[c]--;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 5820
#include<stdio.h>

#define MAX 300

int main() {
    //変数の宣言
    int h[MAX], w[MAX];
    int i = 0, j, a, b; //処理用
    
    //入力
    while(1) {
        scanf("%d %d", &h[i], &w[i]);
        if (h[i] == 0 && w[i] == 0) { //どちらも0の時
            break; //このループを終了
        }
        i++; //カウンター回しておく
    }
    
    for (j=0; j<i; j++) {
        for (a=0; a<h[j]; a++) {
            for (b=0; b<w[j]; b++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    //printf("確認");
    
    return 0;
}



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

using namespace std;

int main() {
  uint64_t X;
  cin >> X;
  int x = 0;
  uint64_t m = 100;
  do {
    m = (uint64_t)((double)m * 1.01);
    x++;
  } while (m < X);
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    vec A(N); cin >> A;
    Sort(A);
    int B, C;
    pairs p(M);
    REP(i, M){
        cin >> B >> C;
        p[i] = Pii(C, B);
    }
    Sort(p); Reverse(p);
    int i0 = 0;
    REP(i, M){
        bool f = false;
        REP(j, p[i].s){
            if(i0 == N || A[i0] >= p[i].f){
                f = true;
                break;
            }else A[i0++] = p[i].f;
        }
        if(f) break;
    }
    int ans = 0;
    REP(i, N) ans += A[i];
    Out(ans);

    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        String op;
        Scanner scan = new Scanner(System.in);
        while(true){
            int a = scan.nextInt();
            op = scan.next();
            int b = scan.nextInt();
            if(op.equals("+")){
                System.out.println(a+b);
            }
            if(op.equals("-")){
                System.out.println(a-b);
            }
            if(op.equals("*")){
                System.out.println(a*b);
            }
            if(op.equals("/")){
                System.out.println(a/b);
            }
             
            if(op.equals("?")){
                break;
            }
 
        }
    }
 
}

Measured memory_bytes: 26108
import sys
n, m = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
li2 = ['a']*n
for _ in range(m):
  i, k = map(int, sys.stdin.readline().split())
  k -= 1
  i -= 1
  if li[k] - li[i] > 0:
    li2[i] = 'F'
    if li2[k] == 'a':
      li2[k] = 'T'
  elif li[k] == li[i]:
    li2[i] = 'F'
    li2[k] = 'F'
  else:
    li2[k] = 'F'
    if li2[i] == 'a':
      li2[i] = 'T'
print(n-li2.count('F'))

Measured memory_bytes: 20340
#include <cstdio>

typedef long long ll;

ll tree[202020];

ll mod = 1e9 + 7;

void add(int idx, int diff)
{
    while (idx < 202020)
    {
        tree[idx] += diff;
        tree[idx] %= mod;
        idx += (idx) & (-idx);
    }
}

ll sum(int idx)
{
    ll ret = 0;
    while (idx > 0)
    {
        ret += tree[idx];
        ret %= mod;
        idx -= (idx) & (-idx);
    }
    return ret;
}

int main(void)
{
    ll N, x;
    ll A[202020];
    scanf("%lld", &N);

    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", &x);
        add(i, x);
        A[i] = x;
    }

    ll ans = 0;

    for (int i = 1; i <= N; i++)
    {
        ans += ((sum(N) - sum(i)+ mod) * A[i])%mod;
        ans %= mod;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4872
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> n>>m;
 	priority_queue<ll> x;
 	for (int i = 0; i < n; i++){
 		ll y;
 		cin >> y;
 		x.push(y);
 	}
 	for (int i = 0; i < m; i++){
 		ll y=x.top()>>1;
 		x.pop();
 		x.push(y);
 	}
 	ll ans=0;
 	for (int i = 0; i < n; i++){
 		ans+=x.top();
 		x.pop();
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s; cin>>s;
	int n=s.size();
	ll a[500050]={};
	ll b[500050]={};
	for(int i=0; i<n; i++){
		if(s[i]=='<'){
			a[i+1]=a[i]+1;
		}
	}
	for(int i=n-1; i>=0; i--){
		if(s[i]=='>'){
			b[i]=b[i+1]+1;
		}
	}
	ll ans=0;
	for(int i=0; i<=n; i++) ans+=max(a[i], b[i]);
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  int N, x; cin >> N >> x;
  int a[N]; rep(i, N) cin >> a[i];
  sort(a, a+N);
  int ans = 0;
  rep(i,N){
    if(x >= a[i])
    {
      ans++;
      x -= a[i];
      if(i == N-1 && x > 0)
      {
        ans--;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定

int main () {

    int n;cin>>n;

    vector<vector<P>> vec(n,vector<P>());

    rep(i,n) {
        int a;cin>>a;
        rep(j,a) {
            int x,y;cin>>x>>y;
            vec[i].push_back(P(x,y));
        }
    }
    
    int ans=0;
    for (int bit=0;bit<(1<<n);bit++) {
        int cnt=0;
        bool end=false;
        for (int i=0;i<n;i++) {
            if (bit & (1<<i)) {
                cnt++;
                rep(j,vec[i].size()) {
                    if (((bit & (1<<(vec[i][j].first-1)))==0 && vec[i][j].second==1) | ((bit & (1<<(vec[i][j].first-1)))!=0 && vec[i][j].second==0)) {
                        end=true;
                        break;
                    }
                }
                if (end) break;
            }
        }
        if (!end) {
            ans=max(ans,cnt);
            // if (ans==2) cout<< bit <<endl;
        }
    }

    cout<<ans<<endl;

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, bool> P;

const ll MOD = 1000000007;

int N;
P ab[100000 * 2];

int main() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		ab[i].first = a, ab[i].second = true;
	}
	for (int i = 0; i < N; i++) {
		ll b;
		cin >> b;
		ab[i + N].first = b, ab[i + N].second = false;
	}

	sort(ab, ab + 2 * N);

	ll ans = 1;
	ll cnt = 1;
	bool base = ab[0].second;
	for (int i = 1; i < 2 * N; i++) {
		if (cnt == 0) {
			cnt = 1;
			if (ab[i].second != base)base = !base;
		}else if (base != ab[i].second) {
			ans *= cnt;
			ans %= MOD;
			cnt--;
		}
		else {
			cnt++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[5][5],b[15];
bool m[5][5];
int main(){
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		for(int j=1;j<=3;j++)
			for(int k=1;k<=3;k++)
				if(b[i]==a[j][k])
					m[j][k]=true;
	}
	if(m[1][1]&&m[2][2]&&m[3][3])
		cout<<"Yes";
	else if(m[1][3]&&m[2][2]&&m[3][1])
		cout<<"Yes";
	else if(m[1][1]&&m[1][2]&&m[1][3])
		cout<<"Yes";
	else if(m[2][1]&&m[2][2]&&m[2][3])
		cout<<"Yes";
	else if(m[3][1]&&m[3][2]&&m[3][3])
		cout<<"Yes";
	else if(m[1][1]&&m[2][1]&&m[3][1])
		cout<<"Yes";
	else if(m[1][2]&&m[2][2]&&m[3][2])
		cout<<"Yes";
	else if(m[1][3]&&m[2][3]&&m[3][3])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
a, b = map(int, input().split())

# a*bが偶数の場合は条件を満たすcは存在しない
# a*bが奇数の場合はc=1, 3の時条件を満たす

if (a * b) % 2 == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940