akhauriyash/Code-Regression huggingface dataset:
program fLIP
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,k,i,j,nuru

    read*, n,m,k

    do i=0,n
        do j=0,m
            nuru = i*m + j*n - 2*i*j
            ! print*, i,j,nuru
            if (nuru == k) then
                print'(a)', 'Yes'
                stop
            end if
        end do
    end do

    print'(a)', 'No'
end program fLIP

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ld a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	ll e = 4 * a * b;
	if(d < 0){
		puts("No");
		return 0;
	}
	d = d * d;
	if(e < d) puts("Yes");
	else puts("No");

	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll n, a, b, c;
vll ls;

ll dfs(ll d, ll an, ll bn, ll cn, ll ac, ll bc, ll cc){
  if (d == n) {
    if (ac == 0 || bc == 0 || cc == 0) return INF;
    return abs(a - an) + abs(b - bn) + abs(c - cn) + 10*(ac-1) + 10*(bc-1) + 10*(cc-1);
  }
  ll ans = INF;
  chmin(ans, dfs(d + 1, an + ls[d], bn, cn, ac+1, bc, cc));
  chmin(ans, dfs(d + 1, an, bn + ls[d], cn, ac, bc+1, cc));
  chmin(ans, dfs(d + 1, an, bn, cn + ls[d], ac, bc, cc+1));
  chmin(ans, dfs(d + 1, an, bn, cn, ac, bc, cc));
  return ans;
}

int main() {
  cin >> n >> a >> b >> c;
  ls.resize(n);
  rep(i, n) cin >> ls[i];

  ll ans = dfs(0, 0, 0, 0, 0, 0, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
   
   
   
   int A,B,C,D;
   string s ;
   cin >> s;
   A=s[0]-'0';
   B=s[1]-'0';
   C=s[2]-'0';
   D=s[3]-'0';
   if(1<=C*10+D && C*10+D<=12){
       if(1<=A*10+B && A*10+B<=12){
           cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "YYMM" << endl;
        }
    }

    else{
        if(1<=A*10+B && A*10+B<=12){
            cout << "MMYY" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }    
   
   


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  vector<tuple<string, int, int>> a;
  int n;
  cin >> n;
  rep(i,n)
  {
    string s;
    int p;
    cin >> s >> p;
    a.push_back(make_tuple(s, p, i + 1));
  }
  sort(a.begin(), a.end(),
      []( const auto &x, const auto &y )
      {
        return get<0>( x ) == get<0>( y ) ? get<1>( x ) > get<1>( y ) : get<0>( x ) < get<0>( y );
      });
  rep(i,n)
    cout << get<2>(a[i]) << endl;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-i-1]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


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


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

  int count[N + 10];
  for (int i = 0; i < N+10; i++) {
    count[i] = 0;
  }


  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    count[a]++;
    count[b]++;
  }

  for (int i = 1; i <= N; i++) {
    cout << count[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final UnionFindTree tree = new UnionFindTree(n);
        final int[] langToMan = new int[m + 1];
        Arrays.fill(langToMan, -1);
        for (int man = 1; man <= n; man++) {
            final int k = scanner.nextInt();
            for (int j = 0; j < k; j++) {
                final int lang = scanner.nextInt();
                if (langToMan[lang] == -1) {
                    langToMan[lang] = man;
                } else {
                    tree.unit(man, langToMan[lang]);
                }
            }
        }

        final boolean answer = IntStream.rangeClosed(1, n)
                .mapToObj(tree::getRoot)
                .allMatch(v -> v == 1);

        System.out.println(answer ? "YES" : "NO");
    }

    private static class UnionFindTree {
        private Integer[] nodes;
        private final List<Integer> indices = new ArrayList<>();

        UnionFindTree(final int numOfNodes) {
            this.nodes = init(numOfNodes);
        }

        private Integer[] init(final int numOfNodes) {
            return IntStream.rangeClosed(0, numOfNodes)
                    .boxed()
                    .toArray(Integer[]::new);
        }

        int getRoot(final int nodeNumber) {
            final int rootNode = nodes[nodeNumber];
            if (rootNode == nodeNumber) {
                for (final Integer index : indices) {
                    nodes[index] = rootNode;
                }
                indices.clear();
                return nodeNumber;
            }

            indices.add(nodeNumber);
            return getRoot(rootNode);
        }

        boolean isSame(final int nodeA, final int nodeB) {
            return getRoot(nodeA) == getRoot(nodeB);
        }

        void unit(final int nodeA, final int nodeB) {
            final int rootA = getRoot(nodeA);
            final int rootB = getRoot(nodeB);

            if (rootA == rootB) {
                return;
            }

            nodes[Math.max(rootA, rootB)] = Math.min(rootA, rootB);
        }
    }
}


Measured memory_bytes: 94920
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, cnt = 0;
  cin >> N;
  vector<ll> a(N + 1);
  for(ll i = 1; i <= N; i++) {
    cin >> a.at(i);
    if((a.at(i) % 2 == 1) && (i % 2 == 1)) cnt++;
  }
  cout << cnt << endl;
}

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

const int N = 100010;
typedef std::pair <int, int> pii;

int a[N];
pii p[N];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
		p[i] = {a[i], i};
	}
	std::sort(p, p + n);
	int ans = 0;
	for (int i = 0; i < n; ++ i){
		ans += (p[i].second & 1) != (i & 1);
	}
	printf("%d\n", ans >> 1);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int n;
    string si;
    int maxvote=-1;
    cin >> n;
    // n = 2;
    vector<string> ss(n+1);
    for (int i=0; i<n; i++) {
        cin >> si;
        ss[i] = si;
    }
    // ss[0] = "xx";
    // ss[1] = "xx";
    ss[n] = "zzzzzzzzzzz";

    vector<string> ans(n);
    string cur = "";
    int curcnt = 0;
    // for (int i=0; i<n; i++) cout << ss[i];
    sort(ss.begin(), ss.end());
    // cout << endl;
    // for (int i=0; i<n; i++) cout << ss[i];

    for (int i=0; i<n; i++){
        if (ss[i] != cur) {
            curcnt = 1;
        } else {
            curcnt++;
        }
        cur =  ss[i];

        if (maxvote < curcnt) {
            maxvote = curcnt;
            ans.clear();
            ans.push_back(cur);
        } else if (maxvote == curcnt){
            ans.push_back(cur);
        }
    }
    // cout << endl << "answer from here" << endl;
    // cout << ans.size();
    for (int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }
    // cout << endl;
    // cout << ans;

}

Measured memory_bytes: 15648
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

bool grid[3][3];
int g[9];

bool is_bingo() {
  for (int i = 0; i < 3; i++) {
    if (grid[i][0] && grid[i][1] && grid[i][2]) {
      return true;
    }
    if (grid[0][i] && grid[1][i] && grid[2][i]) {
      return true;
    }
  }

  if (grid[0][0] && grid[1][1] && grid[2][2]) {
    return true;
  }
  if (grid[0][2] && grid[1][1] && grid[2][0]) {
    return true;
  }
  return false;
}

void solve() {
  vector<int> g(9);

  for (int &i : g) {
    cin >> i;
  }

  int N;
  cin >> N;
  while (N--) {
    int a;
    cin >> a;

    for (int i = 0; i < 9; i++) {
      if (g[i] == a) {
        grid[i / 3][i % 3] = true;
        break;
      }
    }
  }

  if (is_bingo()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


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

int main(){
	std::string s;
	// std::vector<std::string> a("A", "G", "T", "C");
	int len = 0;
	int maxlen = 0;
	std::cin >> s;
	int n = (int)s.size();
	for(int i=0; i<n; i++){
		// std::cout << s[i];
		if(s[i]=='A' or s[i]=='G' or s[i]=='T' or s[i]=='C'){
			len++;
			if(len>maxlen) maxlen = len;
		}else{
			len = 0;
		}
	}
	std::cout << maxlen <<std::endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    readln;
    int[int] as;
    foreach (a; readln.split.to!(int[])) as[a] += 1;
    int r;
    foreach (a, n; as) {
        if (n >= a) {
            r += n - a;
        } else {
            r += n;
        }
    }
    writeln(r);
}

Measured memory_bytes: 9252
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll n,m;
    cin>>n>>m;
	ll ans=(n*m+1)/2;
  	if(m==1||n==1)
      ans=1;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    vector<int> arr = {a / 0.08, b / 0.1, (a + 1) / 0.08, (b + 1) / 0.1};
    for(int i = min(arr[0], arr[1]); i <= max(arr[2], arr[3]); i++) {
        int c = i * 0.08, d = i * 0.1;
        if(c == a && d == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a, p; cin >> a >> p;
    int b = a * 3;
    cout << (b + p) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

char a, b;
bool flag;

int main(){
	scanf("%c %c", &a, &b);
	if(a == b) flag = 1;
	else flag = 0;
	if(flag == 1) printf("H\n");
	else printf("D\n");
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int pos(int n){
	return n+50;
}
void mainmain(){
	int n,r;
	while(cin>>r>>n,n||r){
		double rr=r;
		vint v1(100,0);
		vint v2(100,0);
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			reep(j,a,b+1){
				if(j-a){
					if(v1[pos(j)]==0){
						v1[pos(j)]=c;
					}
					else{
						v1[pos(j)]=max(v1[pos(j)],c);
					}
				}
				if(j-b){
					if(v2[pos(j)]==0){
						v2[pos(j)]=c;
					}
					else{
						v2[pos(j)]=max(v2[pos(j)],c);
					}
				}
			}
		}
		double ans=1e200;
		reep(i,-r,r+1){
			double h=-rr+sqrt(rr*rr-pow(abs(i),2));
			// cout<<i<<" "<<LDcout(h,10)<<endl;
			// cout<<v1[pos(i)]<<" "<<v2[pos(i)]<<endl;
			int mx=1e8;
			if(r+i) mx=min(mx,v1[pos(i)]);
			if(r-i) mx=min(mx,v2[pos(i)]);
			ans=min(ans,mx-h);
		}
		cout<<LDcout(ans,10)<<endl;
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

Measured memory_bytes: 1272
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	ans := 0
	for i := 1; i < n; i++ {
		first := s[:i]
		second := s[i:]

		chars := classifiedChars(first)
		count := 0
		for char := range chars {
			if strings.Contains(second, char) {
				count++
			}
		}
		if ans < count {
			ans = count
		}
	}
	fmt.Println(ans)
}

func classifiedChars(str string) map[string]struct{} {
	table := make(map[string]struct{})
	arr := strings.Split(str, "")
	for _, s := range arr {
		table[s] = struct{}{}
	}
	return table
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e3 + 5;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
pair<int, int> que[maxn * maxn];
string s[maxn];
int n, m;
int vs[maxn][maxn], d[maxn][maxn];

int main() {
    cin >> n >> m;
    
    rep(i, 0, n) {
        cin >> s[i];
    }

    int qsize = 0;
    rep(i, 0, n) {
        rep(j, 0, m) {
            if (s[i][j] == '#') {
                que[qsize++] = mp(i, j);
                vs[i][j] = 1;
                d[i][j] = 0;
            }
        }
    }

    int ans = 0;
    rep(i, 0, qsize) {
        auto cur = que[i];
        rep(j, 0, 4) {
            int x = cur.fi + dx[j];
            int y = cur.se + dy[j];
            if (x < 0 || x >= n || y < 0 || y >= m) continue;
            if (!vs[x][y]) {
                que[qsize++] = mp(x, y);
                vs[x][y] = 1;
                d[x][y] = d[cur.fi][cur.se] + 1;
                ans = max(ans, d[x][y]);
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 17024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

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

    int cnt[30] = {};
    for(int i = 0; i < n; i++){
        cnt[(int)(s[i] - 'a')]++;
    }

    int ans = 1;
    for(int i = 0; i < 30; i++){
        ans *= cnt[i] + 1;
        ans %= MOD;
    }

    cout << (ans + MOD - 1) % MOD << endl;
    return 0;
}

Measured memory_bytes: 512
#=input()
#=int(input())
a,b=map(int,input().split())
#=map(str,input().split())
l=list(map(int,input().split()))
x=0
for i in l:
    x += i
    
y=a-x
if y < 0:
    print(-1)
else:
    print(y)    

Measured memory_bytes: 9856
n,m,x=map(int,input().split())
ca=[]
ans=10**9
for i in range(n):
  tmp=list(map(int,input().split()))
  ca.append(tmp)
for p in range(2**n):
  i_bin = (bin(p)[2:]).zfill(n)
  fl=1
  for i in range(1,m+1):
    ttl=sum([int(i_bin[k])*ca[k][i] for k in range(n)])
    if ttl<x: fl=0
  ansc=sum([int(i_bin[k])*ca[k][0] for k in range(n)])
  if fl and ansc<ans:
    ans=ansc
if ans==10**9: print(-1)
else: print(ans)

Measured memory_bytes: 74808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int d[4]={1,4,-1,-4};
map<vector<int>,int>data;
int main(){
	vector<int> goal(8);
	rep(i,8)goal[i]=i;
	int res=0;
	queue<vector<int> > q;
	q.push(goal);
	while(!q.empty()){
		int pos;
		vector<int> now=q.front();q.pop();
		rep(i,8)if(now[i]==0)pos=i;
		rep(i,4){
			int nn=pos+d[i];
			if(nn>=0&&nn<8&&(pos+nn!=7)){
				vector<int> tmp=now;
				swap(tmp[nn],tmp[pos]);
				if(data.find(tmp)==data.end()){
					q.push(tmp);
					data[tmp]=data[now]+1;
				}
			}
		}
	}
	vector<int> input(8);
	while(cin>>input[0]){
		for(int i=1;i<8;i++)cin>>input[i];
		cout<<data[input]<<endl;
	}
}

Measured memory_bytes: 3764
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int H,W;
	cin>>H>>W;
	char pic[52][52]={};
	for(int i=0;i<=H+1;i++){
		for(int j=0;j<=W+1;j++){
			if(i==0||i==H+1||j==0||j==W+1){
				pic[i][j]='.';
			}else{
				cin>>pic[i][j];
			}
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(pic[i][j]=='#'){
				if(pic[i+1][j]=='.'&&pic[i-1][j]=='.'&&pic[i][j+1]=='.'&&pic[i][j-1]=='.'){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n;
double arr[3002];
bool visited[3002][3002];
double dp[3002][3002];

double solve(int index, int headsSoFar)
{
    if(index == n)
    {
        if(headsSoFar > n / 2)
            return 1;
        return 0;
    }
    if(visited[index][headsSoFar])
        return dp[index][headsSoFar];
    visited[index][headsSoFar] = true;
    double ans = 0;
    ans += arr[index] * solve(index + 1, headsSoFar + 1);
    ans += (1 - arr[index]) * solve(index + 1, headsSoFar);
    return dp[index][headsSoFar] = ans;
}

int main()
{
    IO;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    memset(dp, -1, sizeof dp);
    cout << fixed << setprecision(12) << solve(0, 0);
    return 0;
}


Measured memory_bytes: 79616
#include <iostream>
#include <stdio.h>

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define swap(a,b) {a+=b;b=a-b;a-=b;}
#define ll long long

using namespace std;

main(){
  int N,M;
  scanf("%d %d",&N,&M);
  int A;
  rep(i,0,M){scanf("%d",&A);N-=A;}
  printf("%d",max(-1,N));
}

Measured memory_bytes: 3824
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if(500*a+100*b+50*c == X):
                count += 1

print(count)

Measured memory_bytes: 3060
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


int n, x[505], arr[500*500+5];
ii ordered[505];
vector<int> pos[505];


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

    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>x[i];
    	arr[x[i]] = i;
    	ordered[i] = {x[i], i};
    }
    sort(ordered+1, ordered+n+1);

    vector<int> leftlist, rightlist;
    for(int i=1;i<=n;i++){
    	int temp = ordered[i].ss-1;
    	while(temp--)
    		leftlist.pb(ordered[i].ss);
    	temp = n - ordered[i].ss;
    	while(temp--)
    		rightlist.pb(ordered[i].ss);
    }
    reverse(leftlist.begin(), leftlist.end());
    reverse(rightlist.begin(), rightlist.end());

// cout<<"leftlist: ";for(auto it : leftlist)	cout<<it<<" ";cout<<endl;
// cout<<"rightlist: ";for(auto it : rightlist)	cout<<it<<" ";cout<<endl;

    for(int i=1;i<=n*n;i++){
    	if(arr[i] != 0)	continue;
    	if(!leftlist.empty()){
    		arr[i] = leftlist.back();
    		leftlist.pop_back();
// cout<<"assigned "<<arr[i]<<" to "<<i<<" from leftlist\n";
    		continue;
    	}
    	if(x[rightlist.back()] > i){
    		cout<<"No";
    		return 0;
    	}
    	arr[i] = rightlist.back();
    	rightlist.pop_back();
// cout<<"assigned "<<arr[i]<<" to "<<i<<" from rightlist\n";
    }

    for(int i=1;i<=n*n;i++)
    	pos[arr[i]].pb(i);

    for(int i=1;i<=n;i++)
    	if(pos[i][i-1] != x[i]){
    		cout<<"No";
    		return 0;
    	}

    cout<<"Yes\n";
    for(int i=1;i<=n*n;i++)
    	cout<<arr[i]<<" ";
    return 0;
}


 
 


Measured memory_bytes: 4216
h, w = map(int, input().split())
s = []
bombs= []
for _h in range(h):
    _s = input()
    for _w in range(w):
        if _s[_w] == "#":
            bombs.append((_h, _w))
    s.append(_s)

a = [[0]*(w+1) for _ in range(h+1)]

for _h, _w in bombs:
        a[_h-1][_w-1] += 1
        a[_h-1][_w] += 1
        a[_h-1][_w+1] += 1

        a[_h][_w-1] += 1
        a[_h][_w+1] += 1

        a[_h+1][_w-1] += 1
        a[_h+1][_w] += 1
        a[_h+1][_w+1] += 1

for _h, _w in bombs:
    a[_h][_w] = "#"
a.pop(-1)
for _a in a:
    _a.pop(-1)
    print("".join(map(str, _a)))


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){

    int a,b;
    cin>>a>>b;

    if(a>b){
        cout<<"a > b"<<endl;
    }
    else if (a<b)
    {
        cout<<"a < b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int n;
vector<vector<int>> g(100010);
vector<int> b(100010,-1),w(100010,-1);
vector<int> used(100010,false);

P dfs(int v){
  used[v]=true;
  //cout<<v<<endl;
  if(len(g[v])==1 && v!=1){
    b[v]=1,w[v]=1;
    return P(1,1);
  }
  ll ret1=1,ret2=1;
  for(auto itr:g[v]){
    if(used[itr]) continue;
    P ret=dfs(itr);
    //cout<<v<<' '<<itr<<' '<<ret.fi<<' '<<ret.se<<endl;
    (ret1*=ret.se)%=mod;
    (ret2*=(ret.fi+ret.se))%=mod;
  }
  //cout<<v<<' '<<ret1<<' '<<ret2<<endl;
  b[v]=ret1;
  w[v]=ret2;
  return P(ret1,ret2);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
      int x,y;
      cin>>x>>y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    P ret=dfs(1);
    //FOR(i,1,n+1) cout<<b[i]<<' '<<w[i]<<endl;
    cout<<(ret.fi+ret.se)%mod<<endl;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int n,sum;
map<int,int>mp;
map<int,int>s;
bool pan(int x)
{
	int t=1;
	while (t<=x) t*=2;
	if (mp[t-x]) {
		mp[t-x]--; s[t-x]++; return 1;
	} else return 0;
}
int main()
{
	scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) mp[a[i]]++;
    for (int i=n;i>=1;i--) 
     {
     	if (!s[a[i]]) 
     	{
		 mp[a[i]]--; 
		 if (pan(a[i])) sum++;
	    } 
		 else s[a[i]]--;
     	
	 }
    cout << sum << endl; 
}

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

typedef long long int in;

in dp[3005][3005],cp[3005][3005];

int main() 
{
	in n,l=1000000007,i,j;
	cin>>n;
	
	string s;
	cin>>s;
	
	dp[0][0]=1;
	cp[0][0]=1;
	
	for(i=1;i<3005;++i)
	{
	    cp[0][i]=(cp[0][i]+cp[0][i-1])%l;
	}

	for(i=1;i<n;++i)
	{
	    for(j=0;j<=i;++j)
	    {
	        if(s[i-1]=='>')
	        {
	            if(j==0)
	            dp[i][j]=(cp[i-1][i-1])%l;
	            else
                dp[i][j]=((cp[i-1][i-1]-cp[i-1][j-1])%l+l)%l;
	        }
	        else
	        {
	            if(j==0)
	            dp[i][j]=0;
	            else
	            dp[i][j]=(cp[i-1][j-1])%l;
	        }
	    }
	    
	    for(j=0;j<3005;++j)
	    cp[i][j]=(dp[i][j])%l;
	    
	    for(j=1;j<3005;++j)
	    cp[i][j]=(cp[i][j]+cp[i][j-1])%l;
	    
	}
	
	in ans=0;
	
	for(i=0;i<n;++i)
	ans=(ans+dp[n-1][i])%l;
	
// 	for(i=0;i<n;++i)
// 	{
// 	    for(j=0;j<n;++j)
// 	    cout<<dp[i][j]<<" ";
// 	    cout<<"\n";
// 	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 141184
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  string s;
  int a[2],x[3]={1};
  while(cin >>s){
    for(int i=0; i<2; i++){
      if(s[i*2] == 'A') a[i] = 0;
      if(s[i*2] == 'B') a[i] = 1;
      if(s[i*2] == 'C') a[i] = 2;
    }
    swap(x[a[0]],x[a[1]]);
  }
  if(x[0] == 1) cout <<'A'<<endl;
  if(x[1] == 1) cout <<'B'<<endl;
  if(x[2] == 1) cout <<'C'<<endl;
  return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define R register
typedef long long ll;
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
	return f?-x:x;
}
#define P 1000000007 
inline int plu(int x,int y){return (x+=y)>=P?x-P:x;}
inline int mul(int x,int y){return (ll)x*y%P;}
#define MN 405
int f[MN][MN],g[MN][MN],n,C,A[MN],B[MN];
int main(){
	n=read(),C=read();f[0][0]=1;
	for (R int i=1; i<=n; ++i) A[i]=read();	
	for (R int i=1; i<=n; ++i) B[i]=read();
	for (R int i=1; i<=n; ++i)
		for (R int j=A[i]; j<=B[i]; ++j)
			for (R int k=0,x=1; k<=C; ++k,x=mul(x,j))
				g[i][k]=plu(g[i][k],x);
	for (R int i=1; i<=n; ++i)
		for (R int j=0; j<=C; ++j)
			for (R int k=0; k<=C-j; ++k)
				f[i][k+j]=plu(f[i][k+j],mul(f[i-1][k],g[i][j]));
	printf("%d\n",f[n][C]);return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//変数
ll H, W, h, w;

//解法
void solve() {

	cout << (H - h) * (W - w);

	return;
}

int main() {

	//入力
	cin >> H >> W >> h >> w;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;

ll N, Ma, Mb;
ll a_sum, b_sum;
vector<ll> a, b, c;
ll dp[50][500][500];

void init() {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= a_sum; j++) {
      for (int k = 0; k <= b_sum; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
}

void solve() {
  init();
  for (int i = 0; i < N; i++) {
    for (int ca = 0; ca <= a_sum; ca++) {
      for (int cb = 0; cb <= b_sum; cb++) {
        dp[i + 1][ca][cb] = min(dp[i][ca][cb], dp[i + 1][ca][cb]);
        dp[i + 1][ca + a[i]][cb + b[i]] =
            min(dp[i][ca][cb] + c[i], dp[i + 1][ca + a[i]][cb + b[i]]);
      }
    }
  }

  ll res = INF;
  for (int ca = 0; ca <= a_sum; ca++) {
    for (int cb = 0; cb <= b_sum; cb++) {
      if (Ma * cb == Mb * ca && ca != 0 && cb != 0 && dp[N][ca][cb] != INF) {
        res = min(res, dp[N][ca][cb]);
      }
    }
  }
  if (res == INF) {
    res = -1;
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> Ma >> Mb;
  a.resize(N);
  b.resize(N);
  c.resize(N);
  a_sum = 0;
  b_sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a_sum += a[i];
    b_sum += b[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> x(M), y(M);
    for(int i = 0;i < M;i++)    cin >> x[i] >> y[i];
    vector<int> dp(N+1, 0), bowl(N+1, 1);
    dp[1] = 1;
    for(int i = 0;i < M;i++){
        bowl[x[i]]--;
        bowl[y[i]]++;
        if(dp[x[i]])    dp[y[i]] = 1;
        if(!bowl[x[i]]) dp[x[i]] = 0;
    }
    int ans = 0;
    for(int i = 1;i <= N;i++)    ans += dp[i];
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;
	ll A[200005];

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

	ll sum[200005];
	sum[0] = A[0];

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

	int a = 1;
	int b = 2;
	int c = 3;

	ll ans = LLONG_MAX;

	for (;b < N-1;b++){
		ll sA = sum[a-1];
		ll sB = sum[b-1] - sum[a-1];
		ll sC = sum[c-1] - sum[b-1];
		ll sD = sum[N-1] - sum[c-1];

		while(abs(sA - sB) > abs(sum[a] - (sum[b-1]-sum[a]))){
			a++;
			sA = sum[a-1];
			sB = sum[b-1] - sum[a-1];
		}

		while(abs(sC - sD) > abs((sum[c]-sum[b-1]) - (sum[N-1]-sum[c]))){
			c++;
			sC = sum[c-1] - sum[b-1];
			sD = sum[N-1] - sum[c-1];
		}

		ll MAX = max(sA,max(sB,max(sC,sD)));
		ll MIN = min(sA,min(sB,min(sC,sD)));

		ans = min(MAX-MIN, ans);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <cstdlib>
#include <map>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, x, d;
map<llint, vector<P> > mp;
llint sum[200005];

llint Mod(llint a, llint b)
{
	if(a >= 0) return a%b;
	return (b-abs(a)%b)%b;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x >> d;
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + (i-1);
	
	if(d == 0){
		if(x == 0) cout << 1 << endl;
		else cout << n+1 << endl;
		return 0;
	}
	if(d < 0) d *= -1, x *= -1;
	
	for(llint i = 0; i <= n; i++){
		llint rem = Mod(i * x, d);
		llint l = sum[i], r = sum[n] - sum[n-i];
		l = i*x+l*d, r = i*x+r*d;
		vector<P> &vec = mp[rem];
		vec.push_back(P(l, 0));
		vec.push_back(P(r, 1));
		//cout << i << " " << l << " " << r << endl;
	}
	
	llint ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		vector<P> &vec = it->second;
		sort(vec.begin(), vec.end());
		llint pre = -1, cnt = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i].second == 0){
				if(cnt == 0) pre = vec[i].first;
				cnt++;
			}
			else{
				cnt--;
				if(cnt == 0){
					ans += (vec[i].first - pre) / d + 1;
					//cout << pre << " " << vec[i].first << endl;
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 26880
MOD = 10**9 + 7
p3 = [1]

S = input()
n = len(S)

a = []
c = []
q = []
for i in range(n):
  p3.append(int(p3[i] * 3 % MOD))
  if S[i] == 'A':
    a.append(1)
  else:
    a.append(0)
  if S[i] == 'C':
    c.append(1)
  else:
    c.append(0)
  if S[i] == '?':
    q.append(1)
  else:
    q.append(0)

for i in range(1, n):
  a[i] += a[i - 1]
  c[i] += c[i - 1]
  q[i] += q[i - 1]

count = 0
for i in range(1, n - 1):
  if S[i] == 'B' or S[i] == '?':
    bq = 0 if S[i] == 'B' else 1
    count += a[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - bq]
    count += q[i - 1] * (c[n - 1] - c[i]) * p3[q[n - 1] - 1 - bq]
    count += a[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 1 - bq]
    count += q[i - 1] * (q[n - 1] - q[i]) * p3[q[n - 1] - 2 - bq]

print(int(count % MOD))


Measured memory_bytes: 19112
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream> 
#include <fstream>
using namespace std;
inline bool ChekBit(int mask, int index)
{
	return (bool)((mask >> index) & 1);
}
inline int UpDateMask(int mask, int index)
{
	return mask | (1 << index);
}
inline unsigned int Min(unsigned int a, unsigned int b)
{
	if (a < b&&a != 0)return a;
	else
	{
		return b;
	}
}
int main()
{
	int n;
	int m;
	cin >> n;
	cin >> m;
	vector<vector<pair<int, int> > > map(n);
	vector<int> weightToEnd(n, -1);
	for (int i = 0; i < m; i++)
	{
		int vertuxStart;
		int vertuxEnd;
		int weight;
		cin >> vertuxStart;
		cin >> vertuxEnd;
		cin >> weight;

		map[vertuxStart].push_back(make_pair(vertuxEnd, weight));
		if (vertuxEnd == 0)
		{
			weightToEnd[vertuxStart] = weight;
		}
	}
	int exp = (int)pow(2, n);

	vector<vector<unsigned int> > dState = vector<vector<unsigned int> >(exp, vector<unsigned int>(n, (unsigned int)-1));
	dState[1][0] = 0;
	for (int mask = 1; mask < exp; mask++)
	{
		for (int vertexCurrent = 0; vertexCurrent < n; ++vertexCurrent)
		{
			if (!ChekBit(mask, vertexCurrent))
			{
				continue;
			}
			if (dState[mask][vertexCurrent] == (unsigned int)-1)
			{
				continue;
			}
			for (size_t i = 0; i < map[vertexCurrent].size(); ++i)
			{
				int vertexEnd = map[vertexCurrent][i].first;
				int weight = map[vertexCurrent][i].second;
				if (!ChekBit(mask, vertexEnd))
				{
					int tmpMask = UpDateMask(mask, vertexEnd);
					dState[tmpMask][vertexEnd] = Min(dState[tmpMask][vertexEnd], dState[mask][vertexCurrent] + weight);
				}
			}
		}

	}
	unsigned int answer = (unsigned int)-1;
	for (int i = 0; i < n; i++)
	{
		if (weightToEnd[i] == -1)
		{
			continue;
		}
		if (dState[exp - 1][i] == (unsigned int)-1)
		{
			continue;
		}
		answer = Min(answer, dState[exp - 1][i] + weightToEnd[i]);

	}
	cout << (int)answer << endl;
	return 0;
}

Measured memory_bytes: 4436
import itertools 
n=int(input())
p=tuple(map(int, input().split()))
q=tuple(map(int, input().split()))

cnt=0
for v in itertools.permutations(range(1,n+1), n):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
        int n,w;
        cin>>n>>w;
        int aw[n], av[n];
        for(int i=0; i<n; i++)
        {
                cin>>aw[i]>>av[i];
        }
        int dp[w+1];
        memset(dp,-1,sizeof(dp));
        dp[0] = 0;
        int ans=0;
        for(int i=0; i<n; i++)
        {
                for(int j=w; j>=0; j--)
                {
                        if(dp[j]==-1) continue;
                        if(j+aw[i]<=w)
                        {
                                dp[j+aw[i]] = max(dp[j+aw[i]], dp[j] + av[i]); 
                        }
                }
        }
        for(int i=0; i<=w; i++)
        {
                //cout<<i<<" "<<dp[i]<<endl;
                ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 1024
N=int(input())

#bit探索
start=int((2*N+1)**0.5)

for i in range(3):
    i += start
    if i*(i+1) >= 2*N:
        ret = i
        delete=i*(i+1)/2 - N
        break

for k in range(1,ret+1):
    if k != delete:
        print(k)

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int primeCheck[55560] = {};
vector<int> answer;

void calcPrime() {
  rep(i, 2, 55555) {
    if (primeCheck[i] == 0) {
      primeCheck[i] = 1;
      if (i % 5 == 1) answer.push_back(i);
      rep(j, 2, 55555) {
        if (i * j > 55555) break;
        primeCheck[i * j] = -1;
      }
      if (answer.size() == 55) break;
    }
  }
}

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

  calcPrime();

  cout << answer[0];
  rep(i, 1, N) cout << SP << answer[i];

  return 0;
}

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

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}

void solve()
{
   string s = "ACL";
   string ans ="";
   int k;
   cin>>k;
   while(k--)
   {
   	ans +=s;
   }
   cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3572
/**-------------------------
|--------From A.R.A--------|
-------------------------**/
#include <bits/stdc++.h>

#define ll long long int
#define ull unsigned long long int
#define FOR(i,n) for(ll i=0;i<n;i++)
#define input (a,i,n)for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n)for(ll i=0;i<n;i++){cout<<a[i]<<" ";}
#define pb push_back
#define sz(c) (c).size()
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define sall(c) sort((c).begin(),(c).end())
#define rsall(c) sort((c).rbegin(),(c).rend())
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
int64_t TN=1;
using namespace std;
void  solution(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;

}
int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //cin>>TN;
    while(TN--){
        solution();
    }
    return 0;
}


Measured memory_bytes: 3656
N, M = gets.split.map(&:to_i)

sk = M.times.inject({}) {|acc, i|
  _k, *s = gets.split.map(&:to_i)
  acc[i] = s
  acc
}
cond = gets.split.map(&:to_i)

puts 0.upto(2 ** N - 1).select {|i|
  ok = true
  0.upto(M - 1) do |j|
    on = sk[j].inject(0) {|acc, k|
      acc + ((i & (2 ** (k - 1))) == 0 ? 0 : 1)
    }
    unless on % 2 == cond[j]
      ok = false
      break
    end
  end
  ok
}.size

Measured memory_bytes: 3836
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math as mt

def main():
    A, B, N = map(int, input().split())

    maxn = 0
    
    if N >= B:
        maxn = mt.floor(A*(B-1)/B) - A*mt.floor((B-1)/B)
    else:
        maxn = mt.floor(A*N/B) - A*mt.floor(N/B)
    
    print(maxn)


if __name__ == '__main__':
    main()

Measured memory_bytes: 62212
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(x > a[i]){
                if(i != n-1){
                    ans++;
                    x -= a[i];
                }
            }else if(x == a[i]){
                ans++;
                break;
            }else{
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
N = int(input())
words = []
ans = "Yes"
for i in range(N):
  W = input()
  if(words != []):
    if(W in words):
      ans = "No"
    words.append(W)
    if(W[0] != words[i-1][-1]):
      ans = "No"
  else:
    words.append(W)
print(ans)

Measured memory_bytes: 3060