akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> sc;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    sc.emplace_back(s, c);
  }
  for (int i = 0; i < 1000; i++) {
    if (n == 1) {
      if (i == 0 || i < 10) {
        bool b = true;
        rep(j, m) {
          int s, c;
          tie(s, c) = sc[j];
          int k = i / exp(10, n - s) % 10;
          if (c != k) b = false;
        }
        if (b) {
          cout << i << endl;
          return;
        }
      }
    } else {
      int keta = 0;
      int ii = i;
      while (ii) ii /= 10, keta++;
      if (n != keta) continue;
      bool b = true;
      rep(j, m) {
        int s, c;
        tie(s, c) = sc[j];
        int k = i / exp(10, n - s) % 10;
        if (c != k) b = false;
      }
      if (b) {
        cout << i << endl;
        return;
      }
    }
  }
  cout << -1 << endl;
}


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

ll g(ll a,ll b){
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

int main(){
  int i,j,cnt=0;
  ll a,b;
  cin>>a>>b;
  ll p=g(a,b);
  if(p==1){
    cout<<1;
    return 0;
  }
  ll c[50];
  for(i=2;i<=(int)round(sqrt(p));i++){
    if(p%i==0){
      c[cnt++]=i;
      p/=i;
      i=1;
    }
  }
  c[cnt++]=p;
  sort(c,c+cnt);
  int n=cnt;cnt=2;
  for(i=1;i<n;i++){
    if(c[i]!=c[i-1])cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long t,n,count=0,x,y;
cin>>t>>n;
for(int i=0;i<t;i++){
   cin>>x>>y;
   double d=sqrt(x*x+y*y);
   if(d<=n)
    count++;
}
cout<<count;


    return 0;
}


Measured memory_bytes: 3616
n,k=map(int,input().split())
a=list(map(int,input().split()))

lst=[0]*50


for i in a:
  for j in range(50):
    if (i>>j)%2==1:
      lst[j]+=1

k=bin(k)[2:]

dp=[[0]*2 for i in range(len(k)+1)]


for i in range(len(k)):
  if k[i]=='1':
    dp[i+1][0]=dp[i][0]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1))
    dp[i+1][1]=dp[i][0]
  else:
    dp[i+1][0]=dp[i][0]

  if i==0:
      continue
  
  dp[i+1][1]=max(dp[i+1][1],dp[i][1],dp[i][1]+(n-lst[len(k)-i-1]*2)*(2**(len(k)-i-1)))


print(sum(a)+max(dp[-1][0],dp[-1][1]))

Measured memory_bytes: 87476
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

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

    vector<int> x, y;
    REP(i, N) {
        int xi, yi;
        cin >> xi >> yi;
        x.push_back(xi);
        y.push_back(yi);
    }

    vector<int> X = x;
    vector<int> Y = y;

    sort(ALL(X));
    sort(ALL(Y));

    int countMap[50][50];

    REP(i, X.size()) REP(j, Y.size()) {
        int count = 0;
        REP(k, N)
            if (x[k] <= X[i] && y[k] <= Y[j])
                count++;

        countMap[i][j] = count;
    }

    long long m = LLONG_MAX;

    for (size_t i = 0; i < X.size() - 1; i++) {
        for (size_t j = 0; j < Y.size() - 1; j++) {
            for (size_t k = 1; k < X.size(); k++) {
                for (size_t l = 1; l < Y.size(); l++) {
                   int count = countMap[k][l];
                    if (i > 0 && j == 0)
                        count -= countMap[i - 1][l];
                    else if (j > 0 && i == 0)
                        count -= countMap[k][j - 1];
                    else if (i > 0 && j > 0)
                        count -= countMap[i - 1][l] + countMap[k][j - 1] - countMap[i - 1][j - 1];
                    
                    if (count >= K)
                        m = min(m, 1ll * (X[k] - X[i]) * (Y[l] - Y[j]));
                }
            }
        }
    }

    cout << m << endl;
 
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"Yes"<<nl
#define no cout<<"No"<<nl

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void solve()
{
  int n,x,y;
  cin>>n;
  int a[n+1]={0};
  for(int i=0;i<n;i++)
  {
    cin>>x>>y;
    if(x==y)
    {
      a[i]=1;
    }
  }
  for(int i=0;i<n-2;i++)
  {
    if(a[i]==1&&a[i+1]==1&&a[i+2]==1)
    {
      yes;
      return;
    }
  }
  no;
}

int main()
{
    fio;
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
string s;
bool flag1,flag2;
int main(){
	cin>>s;
	for(int i=0;i<=s.size();i++){
		if(s[i]=='C') flag1=1;
		if(s[i]=='F'&&flag1){
			cout<<"Yes"<<endl;
			flag2=1;
			break;
		}
	}
	if(!flag2) cout<<"No"<<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>
#include<ext/pb_ds/tag_and_trait.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) std::cin>>(P)
#define IN2(P1,P2) std::cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUT(P) std::cout<<P<<std::endl
#define OUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define ALL(C) (C).begin(),(C).end()
using namespace std;
using namespace __gnu_pbds;
typedef unsigned long ul;
ul N,i,j;
double p[3000],dp[3001][3001],ans;
inline void solve(){
  IN(N);
  INS(i,N,p);
  dp[0][0]=1.0;
  REP(i,N){
    UP(j,0,i){
      dp[i+1][j+1]+=dp[i][j]*p[i];
      dp[i+1][j]+=dp[i][j]*(1-p[i]);
    }
  }
  UP(j,(N+1)/2,N)ans+=dp[N][j];
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) 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; }
using namespace std;

struct RollingHash{ //ローリングハッシュ法
private:
    static const int_fast32_t mod1 = 1031326447, mod2 = 993766717;
    static const int_fast32_t base1 = 281, base2 = 383;
    vector<int_fast64_t> hash1, hash2, pow1, pow2;
public:
    string str;
    RollingHash(const string& s) : str(s) { //初期化
        int_fast32_t sz = (int_fast32_t)s.size();
        hash1.assign(sz + 1, 0); hash2.assign(sz + 1, 0);
        pow1.assign(sz + 1, 1); pow2.assign(sz + 1, 1);
        for(int_fast32_t i = 0; i < sz; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline pair<int_fast64_t, int_fast64_t> get(int_fast32_t l, int_fast32_t r){ //[l, r)
        int_fast64_t res1 = (hash1[r] - hash1[l] * pow1[r - l]) % mod1;
        int_fast64_t res2 = (hash2[r] - hash2[l] * pow2[r - l]) % mod2;
        if(res1 < 0)res1 += mod1; if(res2 < 0)res2 += mod2;
        return { res1, res2 };
    }
    inline int_fast32_t getLCP(int_fast32_t x, int_fast32_t y){ //LCP S[a:], S[b:]
        int_fast32_t len = min((int_fast32_t)size() - x, (int_fast32_t)size() - y) + 1;
        int_fast32_t l = 0, r = len;
        while(r - l > 1){
            int_fast32_t m = (l + r) >> 1;
            if(get(x, x + m) != get(y, y + m))r = m;
            else l = m;
        }
        return l;
    }
    inline void add_str(const string& s){ //string型を連結
        int_fast32_t ns = (int_fast32_t)str.size(), ms = (int_fast32_t)s.size();
        str += s;
        hash1.resize(ns + ms + 1); hash2.resize(ns + ms + 1);
        pow1.resize(ns + ms + 1); pow2.resize(ns + ms + 1);
        for(int_fast32_t i = ns; i < ns + ms; i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i - ns]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i - ns]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    inline void add_char(const char& c){ //char型を連結
        str += c;
        hash1.push_back((hash1.back() * base1 + c) % mod1);
        hash2.push_back((hash2.back() * base2 + c) % mod2);
        pow1.push_back((pow1.back() * base1) % mod1);
        pow2.push_back((pow2.back() * base2) % mod2);
    }
    inline void add_rh(const RollingHash& rh){ //rhを連結
        add_str(rh.str);
    }
    inline size_t size(){ //strのsizeを返す
        return str.size();
    }
};

int main(){

    int N;
    cin >> N;

    string S;
    cin >> S;
    RollingHash rh(S);

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            int lcp = rh.getLCP(i, j);
            chmin(lcp, i - j);
            chmax(ans, lcp);
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 512
N = gets.chop.to_i
A = gets.chop.split.map(&:to_i)

def uniq?(array)
  uniq_check = {}
  array.each do |v|
    return false if uniq_check.key? v
    uniq_check[v] = true
  end
  return true
end

if uniq?(A)
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 30852
#include<iostream>
using namespace std;
int main(){
  int A=0,B=0,K=0,count=0,i=0;
  cin >> A >> B >> K;
  if (A >= B){
    for(i=B;i>0;i--){
      //      cout << i <<" "<<A%i << " "<<B%i << endl;
      if(A%i == 0 && B%i == 0){
	count = count + 1;
	if(count == K){
	  cout << i << endl;
	}else{
	  //do nothing
	}	  
	}else {
      //do nothing  
    }
    }
  }else if(A<B){
    for(i=A;i>0;i--){
      //      cout << i <<" "<<A%i<<" "<< B%i <<endl;
      if(A%i==0 && B%i==0){
	count = count + 1;
	if(count == K){
	  cout << i << endl;
	}else{
	  //do nothing
	}
      }else{
	//do nothing
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<std::string> s(n);
    for (int i = 0; i < n; i++) std::cin >> s[i];
    std::vector<std::pair<int, int>> l, r;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int mi = 0, last = 0;
        for (char c : s[i]) {
            last += c == '(' ? 1 : -1;
            mi = std::min(mi, last);
        }
        sum += last;
        if (last >= 0) l.emplace_back(mi, last);
        else r.emplace_back(mi - last, -last);
    }
    std::sort(l.rbegin(), l.rend());
    std::sort(r.rbegin(), r.rend());
    auto check = [&](const auto &v) {
        int pos = 0;
        for (const auto &p : v) {
            if (pos + p.first < 0) return false;
            pos += p.second;
        }
        return true;
    };
    if (sum == 0 && check(l) && check(r)) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 42596
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a,b,k;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> k >> a >> b ;
}

int solve(){
    string ans = "NG";
    for (int i = a; i <= b; i++)
    {
        if(i%k==0) ans = "OK";
    }
    cout << ans << endl;
    
    return 0;
}   

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


Measured memory_bytes: 3660
import sys
def input() -> str:
    return sys.stdin.readline()
m = int(input())
n, s = 0, 0
for i in range(m):
  d, c = [int(i) for i in input().split()]
  n += c
  s += d * c
print(n + (s - 1) // 9 - 1)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main() {
  while (true) {
    uint32_t e;
    cin >> e;

    if (e == 0)
      break;

    uint32_t m = UINT32_MAX;
    for (uint32_t a = 0; a * a * a <= e; a++) {
      for (uint32_t b = 0; b * b <= e - a * a * a; b++) {
        uint32_t c = e - a * a * a - b * b;
        m = min(m, a + b + c);
      }
    }

    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

using Graph=vector<vector<int>>;;
Graph G;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    G.assign(n,vector<int>());
    for (int i = 0; i < n-1; i++)
    {
        int u,v;
        cin>>u>>v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans=0;
    for (int i = 0; i < n; i++)
    {
        ans+=(n-i)*(i+1);
        for(auto & u : G[i]){
            if(u<i){
                continue;
            }
            else {
                ans-=(i+1) * (n-u);
            }
        }

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

Measured memory_bytes: 15828
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();

        int max = 0;
        int cur = 0;
        boolean last = true;
        for (char c : s.toCharArray()) {
            if (c == 'R') {
                if (last) cur++;
                else {
                    last = true;
                    cur = 1;
                }
            } else {
                last = false;
                max = Math.max(max, cur);
            }
        }
        max = Math.max(max, cur);
        out.println(max);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 25440
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {


    string t; cin >> t;
    int n = t.size();

    rep(i,n) {
        if (t[i] == '?') {
            cout << 'D';
        }
        else {
            cout << t[i];
        }
    }
    cout << endl;





    return 0;
}









Measured memory_bytes: 3724
N=int(input())
A=list(map(int,input().split()))
s=0
t=0
a=0
b=0
for i in range(N):
    s+=A[i]
    if i%2==0:
        if s>=0:
            a+=s+1
            s=-1
    if i%2!=0:
        if s<=0:
            a+=-s+1
            s=1
for j in range(N):
    t+=A[j]
    if j%2!=0:
        if t>=0:
            b+=t+1
            t=-1
    if j%2==0:
        if t<=0:
            b+=-t+1
            t=1
print(min(a,b))

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

divisor = []
c = 1
while c <= M**0.5:
    if M % c == 0:
        divisor.append(c)
    c += 1
divisor2 = []
for i in range(len(divisor)):
    divisor2.append(M//divisor[i])
    
divisor = divisor + divisor2
divisor.sort(reverse=True)

for j in range(len(divisor)):
    if M//divisor[j] >= N:
        ans = divisor[j]
        break
        
print(ans)

Measured memory_bytes: 3188
/*
ソートするためにswap関数を作る
*/
/*
#include<iostream>
using namespace std;

int swap(int *a, int *b){
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a >= b){
		swap(&a, &b);
	}
	else if(b >= c){
		swap(&b, &c);
	}
	else if(a >= c){
		swap(&a, &c);
	}

	cout << a << " " << b << " " << c << endl;
	return 0;
}
*/

#include<iostream>
using namespace std;
 
int swap(int *a, int *b) {
  int tmp;
  tmp = *b;
  *b = *a;
  *a = tmp;
}
 
int main () {
  int a, b, c, tmp = 0;
  cin >> a >> b >> c;
  if (a >= b) {
    swap(&a, &b);
  }
  if (a >= c) {
    swap(&a, &c);
  }
  if (b >= c) {
    swap(&b, &c);
  }
   
  cout << a << " " << b << " " << c << "\n";
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#define MAX 500001


void swap(int A[],int x,int y){
int temp;
temp=A[x];
A[x]=A[y];
A[y]=temp;
return;
}


void maxHeapify(int A[],int i,int n){
int l,r;
int largest;
l=2*i;
r=2*i+1;


if(l<=n&&A[l]>A[i]){largest=l;}
else{largest=i;}
if(r<=n&&A[r]>A[largest]){largest=r;}

if(largest!=i){swap(A,i,largest);maxHeapify(A,largest,n);}

return;
}





void buildMaxHeap(int A[],int n){
int i;

for(i=n/2;i>=1;i--){maxHeapify(A,i,n);}

return;
}





int main(){
int n,i;
int A[MAX];
for(i=1;i<MAX;i++){A[i]=-2000000001;}
scanf("%d",&n);
for(i=1;i<=n;i++){scanf("%d",&A[i]);}

buildMaxHeap(A,n);

for(i=1;i<=n;i++){printf(" %d",A[i]);}
printf("\n");

return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n;
	cin>>n;
	ll ans=0;
	fo(i,1,n+1) if(i%3!=0&&i%5!=0)ans+=i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        //FastScanner fs = new FastScanner();
        double d = sc.nextDouble();
        int t = sc.nextInt();
        double s = sc.nextDouble();
        System.out.println((d / s) > t ? "No" : "Yes");
    }
//==============================================//
//==============================================//

    static void sort(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a) {
            l.add(i);
        }
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) {
            a[i] = l.get(i);

        }
    }

    static class FastScanner {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 37244
k = int(input())
n = min(50,k)
if n == k:
    if k >= 2:
        l = [n-1 for i in range(n)]
        l[0] = n
    elif k == 1:
        n = 2
        l = [0,2]
    else:
        n = 2
        l = [0,0]
else:
    a = k//n
    b = k%n
    l = []
    for i in range(n):
        l.append(n-i)
    #print(l)
    for i in range(n):
        l[i] += a-1
    for i in range(b):
        l[i] += 1
print(n)
for i in l:
    print(i,end=" ")

Measured memory_bytes: 3064
#include<stdio.h>


int compare_int(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}


int main(void){
    long sumA=0,sumB=0,sumcom=0;
    int N=0,ans=0;
    scanf("%d",&N);
    int A[N],B[N],C[N],com[N];
    
    for(int i = 0; i < N; i++){
        A[i]=0;
        scanf("%d ",&A[i]);
        sumA+=A[i];
    }
    for(int i = 0; i < N; i++){
        B[i]=0;
        com[i]=0;
        scanf("%d ",&B[i]);
        sumB+=B[i];
        com[i]=A[i]-B[i];
    }

    //printf("%ld,%ld",sumA,sumB);
    

    if (sumA<sumB) {
        printf("-1");
        return 0;
    }
    
    qsort(com,N,sizeof(int),compare_int);
    
    for(int i = 0; i < N; i++)
    {
        
        if (com[i]<0) {
            sumcom+=com[i];
            ans++;
        }
    }
    
    for(int i=N-1;sumcom<0;i--){
        sumcom+=com[i];
        ans++;
        
        
    }
    
    printf("%d",ans);
    

    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s.emplace(a);
    }
    for (int i = 0; i < 100; ++i) {
        if(!s.count(x-i)) {
            cout << x-i << "\n";
            return 0;
        }
        if(!s.count(x+i)){
            cout << x+i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3612
// E - Almost Everywhere Zero
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string N;
int K;
int lt = 0, eq = 1;//lt: <, eq: =
int dp[101][2][4];// digit DP, [|N|+1: 1 origin][lt|eq][k:0~3]

int main(){
	cin>>N>>K;
	int dn = N.size();
	dp[0][eq][0] = 1;
	rp(i,0,dn){
		int di = N[i] - '0';
		rp(k,0,K+1){
			rp(dk,0,2){
				dp[i+1][lt][k] += dp[i][lt][k-dk] * (dk? (k?9:0): 1);
				dp[i+1][lt][k] += dp[i][eq][k-dk] * (dk? (k?max(0,di-1):0): (di?1:0));
			}
			if(dp[i][eq][k] && k+(di>0)<4) dp[i+1][eq][k+(di>0)] = 1;
		}
	}
	cout<< dp[dn][lt][K] + dp[dn][eq][K] <<endl;
}

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

using namespace std;
#define ll long long int


int main()
{
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> ans;
    vector<int> dpl(n),dpr(n),cand;
    int last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[i - 1] == 'x') dpl[i] = dpl[i - 1];
        else if (last + c < i) {
            last = i;
            dpl[i] = dpl[i - 1] + 1;
        }
        else dpl[i] = dpl[i - 1];
    }
    last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[n - i] == 'x') dpr[i] = dpr[i - 1];
        else if (last + c < i) {
            last = i;
            dpr[i] = dpr[i - 1] + 1;
        }
        else dpr[i] = dpr[i - 1];
    }
    for(int i=0;i<n;i++){
        int l = i;
        int r = n-i-1;
        if(s[i]=='o' && dpl[l]+dpr[r]<k &&  dpl[l]+dpr[r]+1>=k) cout << (i+1) << endl;
    }
}


Measured memory_bytes: 3332
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    cout<<n*n<<endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
count = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] < L[j] + L[k] and L[i] != L[j] and L[j] != L[k]:
                count += 1

print(count)


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

int main()
{
  int array[] = {
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  };
  int K;
  cin >> K;
  cout << array[K - 1] << endl;
}

Measured memory_bytes: 256
n = int(input())
p_list = list(map(int, input().split()))

ans = 0
now_min = p_list[0]
for i in range(n):
    if now_min > p_list[i]:
        now_min = p_list[i]
    if p_list[i] <= now_min:
        ans += 1
print(ans)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct Maze {
  int id[2];
  int cost;
};
int H, W;

queue< Maze > q;
vec< vec< bool > > flg;
int bfs() {
  Maze start = {{0, 0}, 0};
  flg[0][0] = true;
  q.push(start);
  while (!q.empty()) {
    Maze now = q.front();
    q.pop();
    if (now.id[0] == H - 1 && now.id[1] == W - 1) {
      return now.cost + 1;
    }
    REP(i, 4) {
      Maze next = {{now.id[0] + dx[i], now.id[1] + dy[i]}, now.cost + 1};
      if (next.id[0] < 0 || next.id[0] >= H || next.id[1] < 0 ||
          next.id[1] >= W)
        continue;
      else if (!flg[next.id[0]][next.id[1]]) {
        flg[next.id[0]][next.id[1]] = true;
        q.push(next);
      }
    }
  }
  return -1;
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> H >> W;
  vec< vec< int > > T(H, vec< int >(W));
  vec< vec< int > > dp(H, vec< int >(W, INF));
  int cntX = 0;
  flg.assign(H, vec< bool >(W, false));
  REP(i, H) {
    REP(j, W) {
      char p;
      cin >> p;
      T[i][j] = (p == '.') ? 0 : 1;
      if (T[i][j]) {
        cntX++;
        flg[i][j] = true;
      }
    }
  }

  int ans = bfs();
  if (ans == -1) {
    print(ans);
  } else {
    print(H * W - ans - cntX);
  }
}

Measured memory_bytes: 384
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    int MAX(int a,int b){
      if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
      }
      int r = a%b;
      while(!r){
        a = b;
        b = r;
        r = a%b;
      }
      return r;
    }

    int main(){
      int n;
      string s;
      cin>>n>>s;
      int res = 0;
      rep(i,n){
        if(s[i] != s[i+1])res++;
      }
      cout<<res<<endl;
    }


Measured memory_bytes: 512
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    READV(M);
    multiset<ll,greater<ll>> A;
    FORI(i,0,N)
    {
        READV(x);
        A.insert(x);
    }
    while(M--)
    {
        ll x=*A.begin();
        A.erase(A.begin());
        A.insert(x/2);
    }
    ll ans=0;
    while(sz(A))
    {
        ans+=(*A.begin());
        A.erase(A.begin());
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <bitset>

constexpr int MAX_D = 31;
std::bitset<MAX_D> Exist;

int main(void){
    unsigned int n; scanf("%u", &n);
    unsigned int s = 0, t;
    for(unsigned int i = 0; i < n; ++i){
        unsigned int a; scanf("%u", &a);
        unsigned int cnt = 0;
        s ^= a; t = (a - 1) ^ a; 
        while(t) t >>= 1, cnt++;
        Exist[cnt] = true; // 2^cnt - 1
    }
    unsigned int res = 0;
    for(int t = MAX_D - 1; t >= 0; --t) if((s >> t) & 1U) {
        if(Exist[t + 1]){ s ^= (1 << (t + 1)) - 1; res++;}
        else{ puts("-1"); return 0; }
    }
    printf("%u\n", res);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace AtTest.ABC_105
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            if (n == 0)
            {
                Console.WriteLine(0);
            }

            //指数が小さいほうからスタートするのがポイント
            var haveIndexList = new List<bool>();
            long checkIndex = 1;
            while (n != 0)
            {
                if (Math.Abs(n) % Math.Pow(2,checkIndex) != 0)
                {
                    haveIndexList.Add(true);
                    long val = (long)Math.Pow(2, checkIndex - 1);
                    if ((checkIndex - 1) % 2 == 1) val *= -1;
                    n -= val;
                }
                else
                {
                    haveIndexList.Add(false);
                }
                checkIndex++;
            }

            string result = "";
            for (int i = haveIndexList.Count - 1; i >= 0; i--)
            {
                result += haveIndexList[i] ? '1' : '0';
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int cR = 0, cB = 0;
  REP(i, N) {
    if(S[i] == 'R') {
      cR++;
    } else {
      cB++;
    }
  }
  cout << (cR > cB ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int mod=1e9+7;

int32_t main() {

    fast

    int n;
    cin>>n;

    vector<int>arr(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
        sum%=mod;
    }
    int curr;
    int ans=0;
    int currSum=0;
    for(int i=0;i<n;i++){
        currSum+=arr[i];
        currSum%=mod;
        curr=(sum-currSum+mod)%mod;
        int toadd=(curr*arr[i])%mod;
        ans+=toadd;
        ans%=mod;
    }
    cout<<ans;


    return 0;
}



Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,m;
    cin >> n >> m;
    int ans[n+1] = {0};
    int a,b;
    rep(i,m){
        cin >> a >> b;
        ans[a]++;
        ans[b]++;
    }
    rep(i,n){
        cout << ans[i+1] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define abs(x) ((x)>0?(x):(-(x)))
using namespace std;
const int maxn=19;

int n;
struct Point{
	int x,y,z;
	void input(){
		scanf("%d%d%d",&x,&y,&z);
	}
}p[maxn];

long long ans[maxn];

int count(int s){
	int ret=0;
	while(s){
		ret+=s&1;s>>=1;
	}
	return ret;
}

int q[maxn][2];

int d0[maxn][1<<15];
int d1[maxn][1<<15];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)p[i].input();
	for(int i=1;i<=n;++i){
		d0[i][0]=abs(p[i].y);
		d1[i][0]=abs(p[i].x);
	}
	for(int s=0;s<(1<<n);++s){
		for(int i=1;i<=n;++i){
			d0[i][s]=abs(p[i].y);
			for(int j=1;j<=n;++j){
				if((s>>(j-1))&1){
					d0[i][s]=min(d0[i][s],abs(p[i].y-p[j].y));
				}
			}
			d1[i][s]=abs(p[i].x);
			for(int j=1;j<=n;++j){
				if((s>>(j-1))&1){
					d1[i][s]=min(d1[i][s],abs(p[i].x-p[j].x));
				}
			}
		}
	}
	for(int i=0;i<=n;++i)ans[i]=1e15;
	for(int s=0;s<(1<<n);++s){
		for(int t=s;;t=(t-1)&s){
			long long tmp=0;//int nn=0;
//			for(int i=1;i<=n;++i){
//				if((s>>(i-1))&1){
//					if((t>>(i-1))&1){
//						q[++nn][0]=p[i].x;
//						q[nn][1]=1;
//					}else{
//						q[++nn][0]=p[i].y;
//						q[nn][1]=0;
//					}
//				}
//			}
			for(int i=1;i<=n;++i){
				int d=min(d0[i][s^t],d1[i][t]);
//				for(int j=1;j<=nn;++j){
//					if(q[j][1]==0)d=min(d,abs(p[i].y-q[j][0]));
//					else d=min(d,abs(p[i].x-q[j][0]));
//				}
				tmp+=1LL*d*p[i].z;
			}
			int cnt=count(s);
			ans[cnt]=min(ans[cnt],tmp);
			if(t==0)break;
		}
	}
	for(int i=0;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 7608
#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
typedef  long long ll;
const int  maxn = 2110;
const int mod = 1000000007;
using namespace std;
ll n, m;

int main()
{
	cin >> n >> m;
	printf("%lld", max(n + m, max(n - m, n * m)));
}


Measured memory_bytes: 256
S=input()
DP=[0]*len(S)

now=0
for i in range(len(S)-1,-1,-1):
    now=(now+pow(10,len(S)-1-i,2019)*int(S[i]))%2019
    DP[i]=now
    
DP.append(0)

from collections import Counter
C=Counter(DP)

ANS=0
for c in C.values():
    ANS+=c*(c-1)//2

print(ANS)

Measured memory_bytes: 16724
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int N, V[1005];
int SMAX;

int bin_search2(int x) {
    int pw = 1;

    while(pw <= N) {
        pw <<= 1;
    }

    pw >>= 1;

    int pos = 0;

    while(pw) {
        if(pos + pw <= N) {
            if(V[pos + pw] <= x) {
                pos += pw;
            }
        }

        pw >>= 1;
    }

    return pos;
}

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    #endif // ONLINE_JUDGE

    scanf("%d %d\n", &N, &SMAX);

    while(N + SMAX > 0) {
        for(int i = 1; i <= N; ++i) {
            scanf("%d", &V[i]);
        }

        sort(V + 1, V + 1 + N);

        int mx = 0;
        for(int i = 1; i <= N && V[i] < SMAX; ++i) {
            int dif = SMAX - V[i];
            int pos = bin_search2(dif);
            if(pos != i) {
                if(V[i] + V[pos] <= SMAX && pos > 0) {
                    if(V[i] + V[pos] > mx) {
                        mx = V[i] + V[pos];
                    }
                }
            }
        }

        if(mx == 0) {
            cout << "NONE\n";
        }
        else {
            cout << mx << '\n';
        }

        cin >> N >> SMAX;
    }

    return 0;
}



Measured memory_bytes: 3204
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

vector<vector<char>>grid(1001,vector<char>(1001));

vector<vector<int>>dp(1001,vector<int>(1001));

int fun(int i, int j, int h, int w){

	if(i == h-1 and j == w-1){
		return 1;
	}
	
	if(i==h || j == w) return 0; // Not a Safe place to visit...

	if(dp[i][j] != -1){
		return dp[i][j];
	}

	if(grid[i][j] == '#'){
		return 0;
	}

	return dp[i][j] = (fun(i+1,j,h,w)%mod + fun(i,j+1,h,w)%mod)%mod;

}

signed main(){

    fastio;

    int h,w;
    cin>>h>>w;

    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		dp[i][j] = -1;
    	}
    }

    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		cin>>grid[i][j];
    	}
    }

    cout<<fun(0,0,h,w);


    return 0;
}

Measured memory_bytes: 5376