akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

	using i8 = ::std::int_least8_t;
	using i32 = ::std::int_least32_t;
	using i64 = ::std::int_least64_t;
	using u8 = ::std::uint_least8_t;
	using u32 = ::std::uint_least32_t;
	using u64 = ::std::uint_least64_t;
	using isize = ::std::ptrdiff_t;
	using usize = ::std::size_t;

	class rep {
		const usize f, l;

	public:
		class itr {
			friend rep;
			usize i;
			constexpr itr(const usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { ++i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr rep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(f); }
		constexpr itr end() const noexcept { return itr(l); }
	};
	class revrep {
		const usize f, l;

	public:
		class itr {
			friend revrep;
			usize i;
			constexpr itr(usize x) noexcept : i(x) {}

		public:
			void operator++() noexcept { --i; }
			constexpr usize operator*() const noexcept { return i; }
			constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
		};
		constexpr revrep(const usize first, const usize last) noexcept
			: f(first), l(last) {}
		constexpr itr begin() const noexcept { return itr(l - 1); }
		constexpr itr end() const noexcept { return itr(f - 1); }
	};
	template <class T> bool amax(T &a, const T &b) {
		return b < a ? false : (a = b, true);
	}
	template <class T> bool amin(T &a, const T &b) {
		return a < b ? false : (a = b, true);
	}
	template <class T> bool asmax(T &a, const T &b) {
		return a < b ? (a = b, true) : false;
	}
	template <class T> bool asmin(T &a, const T &b) {
		return b < a ? (a = b, true) : false;
	}
	template <class T> using vec_alias = ::std::vector<T>;
	template <class T> auto md_vec(const usize n, const T &value) {
		return ::std::vector<T>(n, value);
	}
	template <class... Args> auto md_vec(const usize n, Args... args) {
		return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
	}
	template <class T> const T &as_const(const T &v) noexcept { return v; }
	template <class T> constexpr T difference(const T &a, const T &b) {
		return a < b ? b - a : a - b;
	}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>
#include <queue>
#include <string>

namespace n91 {

	bool comp(int l, int r) {
		return l < r;
	}

	void main_() {
		std::priority_queue<int, std::vector<int>, bool(*)(int, int)> pq(comp);

		std::string s;
		int k;
		while (std::cin >> s,s[2] != 'd') {
			if (s[0] == 'i') {
				std::cin >> k;
				pq.emplace(k);
			}
			else {
				std::cout << pq.top() << std::endl;
				pq.pop();
			}
		}
		return;
	}

} // namespace n91

int main() {
	n91::main_();
	return 0;
}



Measured memory_bytes: 6876
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,h,w=map(int,input().split())
    cnt=0
    A, B = [0] * n, [0] * n
    for i in range(n):
        a,b=map(int,input().split())
        if a>=h and b>=w:
            cnt+=1
    print(cnt)

    
    

    
resolve()

Measured memory_bytes: 38256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = gcd(sc.nextInt(), sc.nextInt());
		int num = sc.nextInt();
		int ans = a;
		for(int i = 1; i < num; ) {
			ans --;
			if(a % ans == 0) {
				i ++;
			}
		}
		System.out.println(ans);
	}
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}

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

int main() {
  int N,X;
  cin >> N >> X;
  int sum=1;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    X-=a;
    if(X>=0){
      sum++;
    }
    else break;
  }
  cout << sum;
}

Measured memory_bytes: 256
def add_color_array(a)
  if C.empty? then
    C << a
  elsif C[0] >= a then
    C.unshift(a)
  elsif C[-1] < a then
    C[-1] = a
  else
    C[C.bsearch_index{|b| b >= a} - 1] = a
  end
end

C = []
N = gets.to_i
N.times{
  add_color_array(gets.to_i)
}

puts C.size


Measured memory_bytes: 4092
# coding: utf-8

import sys

def digit_check(n):
    digit = 1
    
    while int(n/(10**digit)) != 0:
        digit += 1

    return digit
        
def main():
    for line in sys.stdin:
        ls = list(map(int, line.split(' ')))
        print(digit_check(ls[0]+ls[1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7596
#include<iostream>
#include<vector>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int n;
vector<int> a[9];
int main(){
    cin >> n;

    REP(i, n){
        int ai;
        cin >> ai;

        REP(j, 8){
            if(400*j<=ai && ai<400*(j+1)){
                a[j].push_back(ai);
            }
        }
        if(ai>=3200){
            a[8].push_back(ai);
        }
    }

    int count = 0;
    REP(i, 8){
        if(a[i].size()>=1){
            count += 1;
        }
    }

    if(count==0){
        if(a[8].size()==0){
            cout << "0 0" << endl;
        } else {
            cout << "1 " << a[8].size() << endl;
        }
    } else {
        int l = count;
        count += a[8].size();
        cout << l << " " << count << endl;
    }
}


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

using namespace std;

int n;

const int p = 1e9 + 7;
int x, sum, ans;
int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%d", &x);
		ans = (ans + 1ll * x * sum) % p;
		sum = (sum + x) % p;
	}
	printf("%d", ans);
}

Measured memory_bytes: 3824
import itertools
n,m,q=map(int,input().split())
abcd=[None]*q
for i in range(q):
    abcd[i]=list(map(int,input().split()))
num=0
for l in list(map(list, itertools.combinations_with_replacement(range(1,m+1), n))):
    num_ = 0
    for x in abcd:
        if l[x[1]-1]-l[x[0]-1] == x[2]:
            num_ += x[3]
    num = max(num ,num_)
print(num)

Measured memory_bytes: 23088
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let (a, b, c, d, e, f) = input!(i64, i64, i64, i64, i64, i64);

    let mut max_density = 0.0;
    let mut max_sugarwater = 0;
    let mut max_sugar = 0;
    for water_a in 0..f {
        for water_b in 0..f {
            let water = 100 * (water_a * a + water_b * b);
            if water > f { break; }
            for sugar_c in 0..f {
                for sugar_d in 0..f {
                    let sugar = c * sugar_c + d * sugar_d;
                    if sugar + water > f  || sugar > e * water / 100 {
                        break;
                    } else {
                        let density = 100.0 * sugar as f64 / (water as f64 + sugar as f64);
                        if density >= max_density {
                            max_density = density;
                            max_sugarwater = sugar + water;
                            max_sugar = sugar;
                        }
                    }
                }
            }
        }
    }
    println!("{} {}", max_sugarwater, max_sugar);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
#include <cassert>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

// enum { kN = 202, kR = 1002, kInf = 1 << 28 };
const int kN = 202, kR = 1002, kInf = 1 << 28;

int N, M, R, rs[kR];
int dl[kN][kN], ds[kN][kN], dp[kR][kN];

int solve() {
  rep(i,N) ds[i][i] = dl[i][i] = 0;
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
        dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
      }
    }
  }
  
  dp[0][ rs[0] ] = 0;
  
  for (int i = 1; i < R; ++i) {
    int from = rs[i-1], to = rs[i];
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        // 海路がひとつ存在する
        dp[i][k] = min(dp[i][k],
                       dp[i-1][j] + dl[from][j] + ds[j][k] + dl[k][to]);
      }
      // 陸路のみ
      dp[i][j] = min(dp[i][j],
                     dp[i-1][j] + dl[from][to]);
    }

    // for (int ii = 0; ii < R; ++ii) {
    //   for (int jj = 0; jj < N; ++jj) {
    //     printf(" %d", dp[ii][jj]);
    //   }
    //   puts("");
    // }
    // puts("");
  }
  
  return *min_element(dp[R-1], dp[R-1] + kN);
}

int main() {
  while (scanf("%d%d", &N, &M) != -1, N | M) {
    rep(i,kR) fill(dp[i], dp[i] + kN, kInf);
    rep(i,kN) {
      fill(dl[i], dl[i] + kN, kInf);
      fill(ds[i], ds[i] + kN, kInf);
    }
    
    int x, y, t; char sl;
    rep(i,M) {
      scanf("%d %d %d %c", &x, &y, &t, &sl);
      --x; --y;
      assert(x >= 0);

      if (sl == 'L')
        dl[y][x] = dl[x][y] = t;
      else
        ds[y][x] = ds[x][y] = t;
    }

    scanf("%d", &R);
    rep(i,R) {
      scanf("%d", &x);
      --x;
      rs[i] = x;
    }
    printf("%d\n", solve());
  }
  return 0;
}

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

int main(){
  int N,M,X,Y;
  cin >>N>>M>>X>>Y;
  int x[N];
  int y[M];

  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  for(int i = 0;i<M;i++){
    cin >> y[i];
  }

  sort(x,x+N);
  sort(y,y+M);
  if(x[N-1]<y[0] && X<y[0] && Y>x[N-1]){
    cout<< "No War";
  }
  else{
    cout << "War";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, N, M);
	in(string, S, T);
	ll nmg = my_gcd(N, M);
	ll nm = (N / nmg) * M;
	bool ans = true;
	ll Ns = N / nmg, Ms = M / nmg;
	loop(i, nmg) {
		if (S[Ns * i] != T[Ms * i])
			ans = false;
	}
	if (ans)
		cout << nm << endl;
	else
		cout << -1 << endl;
	return 0;
}


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

#define int long long
const int N = 1005;

int n,m,a[N],s;

signed main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i], s+=a[i];
    int c=0;
    for(int i=1;i<=n;i++) if(a[i]*4*m>=s) ++c;
    cout<<(c>=m?"Yes":"No");
}

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

int main(){
  int n,m;
  cin >> n >> m ;
  
  vector<vector<long long>> vec(3,vector<long long>(n));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> vec[j][i];
    }
  }

  long long ans=0;
  for (int i = 0; i < 8; i++)
  {
        vector<long long> anslist(n);
        for (int j = 0; j < n; j++)
        {
          long long sum=0;
          for (int k = 0; k < 3; k++)
          {
            if((i/(1<<k))%2==0){
              sum += vec[k][j];
            }
            else{
              sum -= vec[k][j];
            }
          }
          anslist[j]=sum;
        }
        sort(anslist.begin(),anslist.end(),greater<long long>());
        long long res=0;
        for (int v = 0; v < m; v++)
        {
          res+=anslist[v];
        }
        ans=max(res,ans);
  }
  cout << ans << endl;  
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

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

  while(Q--) {
    ll ans = LLONG_MAX;
    ll p;
    cin >> p;
    int ai = lower_bound(alist.begin(), alist.end(), p) - alist.begin();
    for (int i = max(0, ai - 1); i < min(A, ai + 1); i++) {
      ll tmp = abs(alist[i] - p);
      int bi = lower_bound(blist.begin(), blist.end(), alist[i]) - blist.begin();
      for (int j = max(0, bi - 1); j < min(B, bi + 1); j++) {        
        ans = min(ans, tmp + abs(blist[j] - alist[i]));
      }
    }

    int bi = lower_bound(blist.begin(), blist.end(), p) - blist.begin();
    for (int i = max(0, bi - 1); i < min(B, bi + 1); i++) {
      ll tmp = abs(blist[i] - p);
      int ai = lower_bound(alist.begin(), alist.end(), blist[i]) - alist.begin();
      for (int j = max(0, ai - 1); j < min(A, ai + 1); j++) {        
        ans = min(ans, tmp + abs(alist[j] - blist[i]));
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
LL n , t , a[ N ];
void init(){
  n = getint();
  t = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
}
void solve(){
  LL mn = mod7 , bst = 0;
  for( int i = 0 ; i < n ; i ++ ){
    if( a[ i ] > mn )
      bst = max( bst , a[ i ] - mn );
    mn = min( mn , a[ i ] );
  }
  LL cnt = 0; mn = mod7;
  for( int i = 0 ; i < n ; i ++ ){
    if( a[ i ] - mn == bst )
      cnt ++;
    mn = min( mn , a[ i ] );
  }
  printf( "%lld\n" , cnt );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
#include<stdio.h>

 int main(){
      int i,j,k,n,x,t,count;
      for(t=0;;t++){
           scanf("%d%d",&n,&x);
           if(n+x==0)break; 
           count=0;
           for(i=1;i<=n-2;i++){
              for(j=i+1;j<=n-1;j++){
                    for(k=j+1;k<=n;k++){
                           if(i+j+k==x)count++;
                           }
                    }
              }
            printf("%d\n",count);
            }
       return 0;
       }


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

int main() {
    int n, c, k; cin >> n >> c >> k;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    sort(t.begin(),t.end());

    int i = 0,ans = 0;
    while(i < n){
        bool ok = true;
        for(int j = i+1; j < i+c && j < n;j++){
            if(t[i]+k >= t[j]) continue;
            else {
                i = j;
                ok = false;
                ans++;
                break;
            }
        }
        if(ok) {
            ans++;
            i += c;
        }
    }
    cout << ans << endl;
}




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

using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	
	int ans = -1;
	for(int i=0; i<n; i++) {
		string a=s.substr(0, i), b=s.substr(i, n-i);
		sort(a.begin(), a.end());
		sort(b.begin(), b.end());
		a.erase(unique(a.begin(), a.end()), a.end());
		b.erase(unique(b.begin(), b.end()), b.end());
		
		multiset<char> result;
		set_intersection(a.begin(), a.end(), b.begin(), b.end(),
		                 inserter(result, result.end()));
		ans = max(ans, (int)result.size());
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}

// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  bool first = false;
  rep(i,n){
    if(a[i]%2)first = true;
  }
  if(first)print("first");
  else print("second");
  return 0;
}

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

using namespace std;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  if(n%2==0)
  {
      cout<<n/2<<endl;
  }
  else
  {
      cout<<(n/2)+1<<endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>

using namespace std;

// 厚さ
vector<long long> b(51, 0);
// パティの枚数
vector<long long> p(51, 0);

long long barger(int k){
    if(k == 0){
        b[0] = 1;
        return 1;
    }
    else {
        b[k] = 3 + 2 * barger(k-1);
        return b[k];
    }
}

long long patti(int k){
    if(k == 0){
        p[0] = 1;
        return 1;
    }
    else {
        p[k] = 1 + 2 * patti(k-1);
        return p[k];
    }
}

int main()
{
    long long n, x, key;
    cin >> n >> x;
    key = x - 1;
    long long max = barger(n);
    long long ans = patti(n);
    long long mid = 0;
    long long left = 0;
    long long right = max - 1;
    ans = p[n];
    /* debug
    for (int i=0; i<=4; ++i){
        cout << i << ": patty:" << p[i] << " @ barger:" << b[i] << endl;
    }
    */
    // find
    // cout << "key -> " << key << endl;
    for (int i=n; i>=0; --i){
        mid = (left + right) / 2;
        // cout << i << ":[" << left << ", " << mid << ", " << right << ")" << " ans -> " << ans << " ";
        if(key == mid){
            // cout << "mid" << endl;
            ans -= (i > 0) ? p[i-1] : 0;
            break;
        }
        else if(key < mid){
            // cout << "down" << endl;
            left++;
            right = mid - 1;
            ans -= (i > 0) ? (p[i-1] + 1) : 1;
        }
        else {
            // cout << "up" << endl;
            left = mid + 1;
            right--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
#include <algorithm>

using namespace std;
const static int L_MAX = 7;

string rmn_toString( int n, int l ) {
  ostringstream oss;
  oss << n;
  string s = oss.str();
  for( int i = s.size(); i < l; i++ ) {
    s = "0" + s; 
  }
  return s;
}

int rmn_parseInt( string s ) {
  int len = s.size();
  int i;
  for( i = 0; i < len; i++ ) {
    if( s[ i ] != 0 ) { break; }
  }
  if( i == len ) { return 0; }

  int r;
  sscanf( s.substr( i ).c_str(), "%d", &r );

  return r;
}

int main() {
  while( 1 ) {
    int ai, l;
    int i = 0, j;
    map<int, int> dict;
    cin >> ai >> l;
    if( !ai && !l ) { return EXIT_SUCCESS; }

    dict[ ai ] = i;
    while( 1 ) {
      string as;
      as = rmn_toString( ai, l );
      sort( as.begin(), as.end() );

      string asi = as;
      reverse( asi.begin(), asi.end() );

      ai = rmn_parseInt( asi ) - rmn_parseInt( as );
      i++;
      if( dict.find( ai ) != dict.end() ) { break; }
      dict[ ai ] = i; 
    }
    
    cout << dict[ ai ] << " " << ai << " " << ( i - dict[ ai ] ) << endl;
  }
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, a, b; cin >> n >> a >> b;
	if ((b - a) % 2) {
		if (b - 1 < n - a)
			cout << (a - 1) + (b - a + 1) / 2;
		else
			cout << (n - b) + (b - a + 1) / 2;
	}
	else
		cout << (ll)((b - a) / 2);
	return 0;
}

Measured memory_bytes: 256
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int long long
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout<<fixed<<setprecision(20)
#define ff first
#define ss second
#define T int t;cin>>t;rep(mmm,0,t)
#define uniq(v) v.resize(distance(v.begin(),unique(all(v))))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

const int INF=1e9+5;
const int N=100001;
int mod=1000000007;
//mod=998244353;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sub(int a,int b){return (((a-b)%mod)+mod)%mod;}

void solve()
{
	int nee;
	cin>>nee;
	vi dp(3);
	vi c(3);
	while(nee--)
	{
		vi n(3,0);
		rep(i,0,3)
		cin>>c[i];
		rep(i,0,3)
		{
			rep(j,0,3)
			{
				if(i!=j)
				{
					n[j]=max(n[j],dp[i]+c[j]);
				}
			}
		}
		dp=n;
	}
	cout<<max(dp[0],max(dp[1],dp[2]));
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,a,b,c;cin>>N;
  map<int,int> mp;
  REP(i,0,N){
    cin>>a;
    mp[a]++;
  }
  int M;cin>>M;
  REP(i,0,M){
    cin>>a;
    if(!mp[a]||mp[a]==0){
      print("NO");
      re 0;
    }
    mp[a]--;
  }
  print("YES");

}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<int> ans;
    for(int i = 1; i*i <= m; i++){
        if(m%i == 0){
            ans.push_back(i);
            ans.push_back(m/i);
        }
    }
    sort(ans.rbegin(),ans.rend());
    for(int i = 0; i < ans.size(); i++){
        if(n*ans[i] <= m){
            cout << ans[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()

#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define trav(a, x) for(auto& a : x)

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define shandom_ruffle random_shuffle
#define funoredered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using funordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

constexpr int INF = 0x3f3f3f3f;
constexpr int NINF = 0xc0c0c0c0;
constexpr double EPS = 1e-8;
constexpr ll MOD = 1000000007LL;

template <typename T>
using ordered_set = 
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll modPow( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

inline int cmp_double( double x, double y, double tol = EPS) {
    return (x <= y + tol) ? ( x + tol < y) ? -1 : 0 : 1;
}

constexpr int ms = 1010;

char mat[ms][ms];
ll   dp[ms][ms];
int main()
{
	ios::sync_with_stdio(0); cin.tie(NULL);
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < n; ++i) 
        for(int j = 0; j < m; ++j) 
            cin >> mat[i][j];
    
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if( i == 1 && j == 1) dp[i][j] = 1;
            else if( mat[i - 1][j - 1] == '#') dp[i][j] = 0;
            else dp[i][j] = ( dp[i - 1][j] + dp[i][j - 1] ) % MOD;
        }
    }
    cout << dp[n][m] << endl;
}



Measured memory_bytes: 9216
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;
const ll MAX_N = 100000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, dp[MAX_N+10]; cin >> N;
    FILL(dp, INF);
    dp[0] = 0;
    for(int i=1;i<=N;i++){
        dp[i] = dp[i-1]+1;
        for(int j=6;j<=i;j*=6){
            chmin(dp[i], dp[i-j]+1);
        }
        for(int j=9;j<=i;j*=9){
            chmin(dp[i], dp[i-j]+1);
        }
    }
    cout << dp[N];
    cout << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#define HEN 1
#define kuro 2
#define siro 0
#define gre 1
int A[100][100];
int n,z,iro[100],dd[100],ff[100];

void saikiDFS(int x){
  int a;
  iro[x]=gre;
  
  dd[x]=++z;

  for(a=0; a < n;a++){
    
    if(A[x][a]==0){
      continue;
    }

    if(iro[a]== siro){
      saikiDFS(a);
    }

  }
  iro[x]=kuro;
  ff[x]=++z;
  
}

void firstDFS(){
  int b;

  for(b=0; b < n; b++){
    iro[b]=siro;
  }
  z=0;//syokika

  for(b=0; b < n;b++){

    if(iro[b]==siro){
      saikiDFS(b);
    }
    
  }

  for(b=0; b< n;b++){

    printf("%d %d %d",b+1,dd[b],ff[b]);
    printf("\n");
  }

}


int main(){
  int i,j,k,l,m,c,d;
  
  scanf("%d",&n);

  for(i=0;i < n;i++){
    for(j=0;j < n; j++){
       A[i][j]=0;
    }
}
  
      for(i=0; i < n;i++){

    scanf("%d %d",&c,&d);
    c=c-1;

    for(j=0; j < d; j++){

      scanf("%d",&k);
      k=k-1;
      A[c][k]=HEN;
    }
  }

      firstDFS();
      return 0;

}



Measured memory_bytes: 2060
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> A;

	for (ll i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;
		A.push_back(temp);
	}

	ll half;
	ll m = 0;

	while(m < M)
	{
		if (A.size() > 0)
		{
			sort(A.begin(), A.end(), greater<int>());

			half = A[0] / 2;
			ll size = A.size();
			ll j = 0;

			while (j < A.size())
			{
				if (half < A[j])
				{
					if (m < M)
					{
						A[j] /= 2;
						if (A[j] <= 0)
						{
							A.erase(A.begin() + j);
						}
						m++;
					}
				}
				j++;
			}
		}
		else
		{
			break;
		}
		
	}

	ll cnt = 0;
	for (ll i = 0; i < A.size(); i++)
	{
		cnt += A[i];
	}

	cout << cnt << endl;


	return 0;

}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

 
int main() {
  double T, X, ans;
  cin >> T >> X;
  ans = T/X;
  cout << fixed << setprecision(5) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
x,y,a,b,c = gets.chomp.split.map(&:to_i)
o = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_i)
r = gets.chomp.split.map(&:to_i)

o.sort!.reverse!
q.sort!.reverse!
r.sort! # 1,2,3

a = o.slice(0,x) + q.slice(0,y) + r
a.sort!.reverse! # 3,2, 1

puts a.slice(0,x+y).inject(:+)


Measured memory_bytes: 33632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   ll a,b,c=0,d=0,e=0,f=0,g=0,h=0;
   cin>>a>>b>>c;
       d=b+c;
       e=a/d;
       f=a%d;
    g=e*b;
    if(f>=b){g=g+b;}
    else{g=g+f;}
    cout<<g;
}

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

int main() {
    int a, b;
    while (scanf("%d %d",&a,&b)!=EOF) {
        a+=b;
        int ans=0;
        while (a>0) {
            a/=10;
            ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

void fnInput(int& rnMaxNum)
{
  cin >> rnMaxNum;
}

bool fnDgt753_Check(int64_t nRecNum)
{
  int nDgt3 = 0, nDgt5 = 0, nDgt7 = 0;

  while (nRecNum)
  {
    int n1stDgt = nRecNum % 10;

    if      (n1stDgt == 3) nDgt3++;
    else if (n1stDgt == 5) nDgt5++;
    else if (n1stDgt == 7) nDgt7++;

    nRecNum /= 10;
  }

  if (nDgt3 && nDgt5 && nDgt7)
    return true;
  else
    return false;
}

void fnDFS_Main(int nMaxNum, int64_t nRecNum)
{
  static int stn753DgtCnt = 0;

  if (nRecNum > nMaxNum) return;
  if (fnDgt753_Check(nRecNum)) stn753DgtCnt++;

  fnDFS_Main(nMaxNum, 10 * nRecNum + 3);
  fnDFS_Main(nMaxNum, 10 * nRecNum + 5);
  fnDFS_Main(nMaxNum, 10 * nRecNum + 7);

  if (!nRecNum) cout << stn753DgtCnt << endl;
}

int main()
{
  int nMaxNum;

  fnInput(nMaxNum);
  fnDFS_Main(nMaxNum, 0);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
#define bi(x) (1<<(x-1))
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=20,mod=1e9+7;
int n,m,ans,k,i,cur,nxt,j,p,a,b,c,sn,lock[N+1][N+1];
int x,y,f[2][N+1][1<<N];
void updata(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
int main()
{
//	freopen("zigzag.in","r",stdin);
//	freopen("zigzag.out","w",stdout);
	scanf("%d%d%d",&n,&m,&k);
	rep(i,1,k) {scanf("%d%d%d",&a,&b,&c); lock[a][b]=c+1; }
	f[0][0][0]=1;
	sn=(1<<n-1)-1;
	x=1; y=0;
	rep(i,1,m)
	{
		x^=1; y^=1;
		rep(j,0,n-1)
			rep(cur,0,sn) f[y][j][cur]=0;
		rep(j,0,n-1)
			rep(cur,0,sn)
			if (f[x][j][cur])
			{
				if (j==n-1) {
					if (i<m) updata(f[y][0][cur],f[x][j][cur]);
					else updata(ans,f[x][j][cur]);
				}
				if (lock[i][j+1]!=2 && !( cur&bi(j+1) )) 
					updata(f[x][j+1][cur],f[x][j][cur]);
				if (lock[i][j+1]!=1)
				{
					nxt=cur;
					if (!( cur&bi(j+1) )) {
						rep(p,j+2,n-1) if (cur&bi(p)) break;
						if (p<n) nxt^=bi(p);
						nxt|=bi(j+1);
					}
					updata(f[x][j+1][nxt],f[x][j][cur]);
				}
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 172288
solve :: Int -> Int
solve x
  | a == 0 = 0 + n * 2
  | a <= 6 = 1 + n * 2
  | otherwise = 2 + n * 2
    where (n, a) = x `divMod` 11

main :: IO ()
main = do
  x <- readLn
  print $ solve x

Measured memory_bytes: 508
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  string s;
  cin >> s;
  ll r_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') r_cnt++;
  }
  ll ch_cnt = 0;
  for (int i = 0; i < r_cnt; i++) {
    if (s[i] == 'R') ch_cnt++;
  }
  cout << r_cnt - ch_cnt << endl;
  return 0;
}

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

int main(){
  while(true){
    string s;
    string bottom;
    string top;
    int m;
    int h;
    cin >> s;
    if(s=="-")break;
    cin >> m;
    for(int i=0; i<m; i++){
      cin >> h;
      bottom = s.substr(0, h);
      top = s.substr(h, s.length()-h);
      for(int i=0; i<s.length()-h;i++){
        s[i] = top[i];
      }
      for(int i=0; i<h; i++){
        s[i+s.length()-h]=bottom[i];
      }
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3220
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (!(i & 1))continue;
		int num = i;
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (num % j == 0)cnt++;
		}
		if (cnt == 8)ans++;
	}
	cout << ans;
}

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

vector<int> fonk(vector<vector<int>> vec, int from, int to){
	vector<int> res;
	queue<pair<int, vector<int>>> q;
	q.push({from, {from}});
	while(!q.empty()){
		int i = q.front().first;
		vector<int> path = q.front().second;
		q.pop();
		if(i == to){
			if(res.size() > path.size()){
				res = path;
			}
			continue;
		}
		for(auto x: vec[i]){
			if(x != i){
				path.push_back(x);
				q.push({x, path});
			}
		}
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	char c; cin>>c;
	printf("%c", c+1);
	return 0;
}


Measured memory_bytes: 256
x = list(map(int,input().split()))
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for l in range(x[0])]

count = 0
for i in range(x[0]):
  t = x[2]
  for j in range(x[1]):
    t += a[i][j] * b[j]
  if t > 0:
    count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>

using i64 = long long;

const int N = 300000 + 7;

int n;
i64 a[N], b[N], s[2];
i64 l, r, m, p;

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

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", a + i),
		b[i] = b[i - 1] + (i & 1 ? 1 : -1) * a[i],
		s[i & 1] += a[i];
	if (n % 2 == 0) return printf("%lld %lld", std::max(s[0], s[1]), std::min(s[0], s[1])), 0;

	r = s[0] + s[1];
	while (l < r) {
		m = l + r + 1 >> 1, p = 0;
		for (int i = 1; i < n; i += 2)
			if (b[i] + p >= m) p = std::max(p, a[i + 1] - b[i]);
		b[n] + p >= m ? (l = m) : (r = m - 1);
	}
	m = std::max(s[0] + l, s[1]);
	return printf("%lld %lld", m, s[0] + s[1] - m), 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

char solve(string& a, string& b, string& c, char turn){
	if(turn=='a'){
		if(a.length()){
			char t = a.back();
			a.pop_back();
			return solve(a,b,c,t);
		}
		else {
			return 'A';
		}
	}
	if(turn=='b'){	
		if(b.length()){
			char t = b.back();
			b.pop_back();
			return solve(a,b,c,t);
		}
		else {
			return 'B';
		}
	}
	if(turn=='c'){	
		if(c.length()){
			char t = c.back();
			c.pop_back();
			return solve(a,b,c,t);
		}
		else {
			return 'C';
		}
	}
}

int32_t main(){
	string a,b,c;
	cin>>a>>b>>c;
	reverse(all(a));
	reverse(all(b));
	reverse(all(c));
	char t = a.back();
	a.pop_back();
	cout<<solve(a,b,c,t);
}


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

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

	int count[4][3][10] = {};
	for( int i = 0; i < n; ++i ) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		count[b-1][f-1][r-1] += v;
	}

	for( int i = 0; i < 4; ++i ) {
		for( int j = 0; j < 3; ++j ) {
			for( int k = 0; k < 10; ++k ) {
				cout << ' ' << count[i][j][k];
			}

			cout << endl;
		}

		if( i < 3 ) {
			cout << "####################" << endl;
		}
	}
}



Measured memory_bytes: 3092
from bisect import bisect_right
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
B1 = []
for i in range(N):
    ind = bisect_right(C,B[i])
    B1.append(ind)
B2 = [0 for _ in range(N+1)]
for i in range(N-1,-1,-1):
    B2[i] = B2[i+1]+N-B1[i]
cnt = 0
for i in range(N):
    ind = bisect_right(B,A[i])
    cnt += B2[ind]
print(cnt)

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

int main() {

    ll x, y;
    cin >> x >> y;

    if(x % y == 0){
        cout << -1 << endl;
        return 0;
    }

    for(ll i=1; x <= 1e18; ++i){
        ll z = x * i;
        if(z % y != 0){
            cout << z << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using vi = deque<int>;
using db = double;
#define pb push_back
#define pf push_front

ll n;

vi a, b;
int t;

void cal(ll n) {
	if (n == 0)
		return;
	if (n % 2 == 1) {
		cal(n / 2);
		++t;
		a.pb(t);
		b.pb(t);
	} else {
		cal(n - 1);
		++t;
		a.pf(t);
		b.pb(t);
	}
}

int main() {
	cin >> n;
	
	cal(n);
	
	vi s = a;
	for (auto i : b) s.pb(i);
	
	cout << s.size() << endl;
	for (auto i : s)
		cout << i << ' ';
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
        sc := bufio.NewScanner(os.Stdin)
        bufsize := 100 * 1024 * 1024
        sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)

        var n int
        if sc.Scan() {
                n, _ = strconv.Atoi(sc.Text())
        }

        as := make([]int, n)
        if sc.Scan() {
                for i, v := range strings.Split(sc.Text(), " ") {
                        as[i], _ = strconv.Atoi(v)
                }
        }

        var count int
        target := 1
        for i := 0; i < n; i++ {
                if as[i] == target {
                        target++
                } else {
                        count++
                }
        }
        //for _, a := range as {
        //      if a == target {
        //              target++
        //      } else {
        //              count++
        //      }
        //}

        if n == count {
                fmt.Println(-1)
        } else {
                fmt.Println(count)
        }
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
vector <long long> a(200000);
long long fun(long long b, int n) {
  long long f = 0;
  for (int i = 0; i < n; i++) {
	  f += abs(a[i] - b - i - 1);
	}
  return f;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
	  cin >> a[i];
	}
  long long x0 = -2 * 1e9;
  long long x3 = 2 * 1e9;
  long long x1, x2;
  do {
	  x1 = (x0 * 2 + x3) / 3;
	  x2 = (x0 + x3 * 2) / 3;
	  if (fun(x1, n) < fun(x2, n)) {
		  x3 = x2;
		} else {
		  x0 = x1;
		}
	} while (x1 + 1 < x2);
  cout << min(fun(x1, n), fun(x2, n)) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#define NMAX 10000
#define NMIN 1
#define MAX 100000000
#define MIN 2
int main(){
  int i,n,j,num[NMAX],count=0;
  scanf("%d",&n);
  if(n>NMAX||n<NMIN) return 0;
  for(i=n;i>0;i--){
    scanf("%d",&num[i]);
    if(num[i]>=MIN&&num[i]<=MAX){
      if(num[i]!=2&&num[i]%2==0) count++;
      else{
	for(j=3;j<=sqrt(num[i]);j+=2){
	  if(num[i]%j==0){
	    count++;
	    break;
	  }
	}
      }
    }
    else break;
  }
  printf("%d\n",n-count);
  return 0;
}



Measured memory_bytes: 2056