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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    int x[m], y[m], c[m];

    vector<int> st[n], nd[n];

    for(int i = 0; i < m; ++i){
        cin >> x[i] >> y[i] >> c[i];
        --x[i], --y[i];
        st[x[i]].push_back(i);
        nd[y[i]].push_back(i);
    }

    ll best[n];
    memset(best, 0x7f, sizeof best);
    best[0] = 0;

    multiset<ll> ms;

    for(int i = 0; i < n; ++i){

        if (not ms.empty())
            best[i] = *ms.begin();

        for(auto &idx : st[i]){
            ms.insert(best[i] + c[idx]);
        }
        
        for(auto &idx : nd[i]){
            auto it = ms.find(best[x[idx]] + c[idx]);
            //assert(it != ms.end());
            ms.erase(it);
        }
    }

    ll res = best[n - 1];
    if(res >= n * 1LL * 1e9) res = -1; 

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 12928
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<deque<int>> a(n, deque<int>(m, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    int ret = 1000;
    map<int, int> cnt;
    set<int> to_remove;
    for (int i = 0; i < m; ++i) {
        cnt.clear();
        for (int j = 0; j < n; ++j) {
            cnt[a[j].front()]++;
        }
        int maxidx = -1;
        int maxi   = 0;
        for (auto &p : cnt) {
            if (p.second > maxi) {
                maxi   = p.second;
                maxidx = p.first;
            }
        }
        chmin(ret, maxi);
        to_remove.insert(maxidx);
        for (int j = 0; j < n; ++j) {
            while (to_remove.count(a[j].front()) == 1)
                a[j].pop_front();
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		
		
		for(int i = 0; i < str.length(); i++) {
			String s =String.valueOf(str.charAt(i));
			if(!(s.equals(s.toUpperCase()))) {
				System.out.print(s.toUpperCase());
			}else if(!(s.equals(s.toLowerCase()))) {
				System.out.print(s.toLowerCase());
			}else {
				System.out.print(s);
			}
		}
		System.out.println();
	}
}



Measured memory_bytes: 27292
#include <stdio.h>
int main(){
  int n,x,i,j,k,count;
  while(1){
    count=0;
    scanf("%d%d",&n,&x);
  if(n==0 && x==0)break;
  else {
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	if(i>=j)continue;
	for(k=1;k<=n;k++){
	  if(j>=k)continue;
	  if(x==i+j+k)count++;
	}
      }
    }
  }
  printf("%d\n",count);
}


  return 0;
}

Measured memory_bytes: 600
import java.util.*;
// warm-up
// Test case test case.. Look its voldemort.. And he gets a red card.. He has no nose isnt it..
public class Main {

	static class Element implements Comparable<Element> {
		String e = null; int c = 0;
		Element (String a, int ct) {
			a=e; c=ct;
		}
		public int compareTo (Element other) {
			return other.c-c;
		}
	}

	static void solve() {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> m = new HashMap<String, Integer>();
		List<Element> l = new ArrayList<Element>();
		int N = sc.nextInt();
		while (N-->0) {
			String a = sc.next();
			m.put(a, m.get(a)==null ? 1 : m.get(a)+1);
		}
		N = sc.nextInt();
		while (N-->0) {
			String a = sc.next();
			m.put(a, m.get(a)==null ? -1 : m.get(a)-1);
		}
		for (String a : m.keySet()) l.add(new Element(a, m.get(a)));
		Collections.sort(l);
		System.out.println(l.get(0).c<0 ? 0 : l.get(0).c);
		sc.close();		
	}

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

}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  sort(l, l + N);
  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) ans++;
      }
    }
  }

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

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

cout<<(n*(n-1))/2<<endl;

}













Measured memory_bytes: 256
input = gets.chomp.to_i

answer_array = []
temp = input

while (temp > 0) do
    quotient,remainder = temp.divmod(26)
    if remainder == 0
        answer_array.unshift('z')
        quotient -= 1
    else
       answer_array.unshift((remainder+96).chr)
    end
    temp = quotient
end

puts answer_array.join('')

Measured memory_bytes: 14368
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = sorted(a)
#print(b.index(a[0]))
ans = 0
in_ = [0]*n # リスト全体でa[i]より小さい数がいくつあるか
after = [0]*n # リストのa[i]以降の数でa[i]より小さい数がいくつあるか
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            # 転倒数
            in_[i] += 1
            if i < j:
                after[i] += 1
#print(in_)
#print(after)
for i in range(n):
    ans += after[i]*k + (k*(k-1)//2) * in_[i]
ans %= 1000000007
print(int(ans))


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    vector <int> cand;
    x=0;
    i=1;
    int N;
    cin>>N;
    while(true){
        x=(i+1)*i/2;
        if(x<=100000){
            cand.push_back(x);
        }else{
            break;
        }
        i++;
    }
    //cout<<cand.size()<<endl; 446
    if(find(ALL(cand),N)==cand.end()){
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    k=sqrt(N*2)+1;//N=kC2
    cout<<k<<endl;
    int table[k][k];
    FOR(i,k){
        FOR(j,k){
            table[i][j]=-1;
        }
    }
    int cnt=1;
    FOR(i,k){
        FOR(j,i){
            table[i][j]=cnt;
            table[j][i]=cnt;
            cnt++;
        }
    }
    FOR(i,k){
        string ret="";
        ret += to_string(k-1);
        FOR(j,k){
            if(i==j) continue;
            ret += " ";
            ret += to_string(table[i][j]);
        }
        cout<<ret<<endl;
    }
    /*cin>>N;
    vector<ll> V((N+1)*(N+1));
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 2176
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[100][100];
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> s[i][j];
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') continue;
      int ok = 0;
      rep(k, 4) {
        int ny = i + dy[k], nx = j + dx[k];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
        if (s[ny][nx] == '#') ok = 1;
      }
      if (!ok) {
        Cout("No");
        return 0;
      }
    }
  }
  Cout("Yes");
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; i++){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  
  if (N==1){
    cout << 1 << endl;
  }
  else{
    int ans=1;
    for (int i=1; i<N; i++){
      int k=0;
      string Si=S.at(i);
      if(S.at(i) == S.at(i-1)){
        k++;
      }
      if (k == 0){
        ans++;
      }
    }
  cout << ans << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    v.push_back (x);
  }
  
  sort(v.begin(), v.end());
  const int INF = 10000;
  v.push_back (INF);
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int lb = j, ub = N;
      
      while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (v.at(i) + v.at(j) <= v.at(mid)) {ub = mid;}
        else {lb = mid;}
      }
      
      ans += (lb - j);
      
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N, K;
ll A[100010];
ll B[100010];

int main () {
  cin >> N >> K;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }
  if (K == 0) {
    ll ans = 0;
    for (auto i = 0; i < N; ++i) {
      if (A[i] == 0) ans += B[i];
    }
    cout << ans << endl;
    return 0;
  }
  ll ans = 0;
  ll t = 0;
  int mb = 0;
  for (auto i = 0; i < 40; ++i) {
    ll x = (K >> i);
    if (x == 1) {
      mb = i;
      break;
    }
  }
  ll sup = ((ll)1 << mb) - 1;
  for (auto i = 0; i < N; ++i) {
    if (A[i] <= sup) t += B[i];
    // cerr << "t = " << t << endl;
  }
  ans = max(ans, t);
  for (auto k = 0; k < 40; ++k) {
    sup = 0;
    for (auto j = k; j < 40; ++j) {
      sup += ((ll)1 << j);
    }
    sup = (K & sup);
    if (sup == 0) continue;
    sup -= 1;
    cerr << "sup = " << sup << endl;
    t = 0;
    for (auto i = 0; i < N; ++i) {
      bool ok = true;
      for (auto j = 0; j < 40; ++j) {
        if ((((sup >> j) & 1) == 0)
            && (((A[i] >> j) & 1) == 1)) {
          ok = false;
          break;
        }
      }
      if (ok) {
        t += B[i];
      }
    }
    ans = max(ans, t);
  }
  sup = K;
  cerr << "sup = " << sup << endl;
  t = 0;
  for (auto i = 0; i < N; ++i) {
    bool ok = true;
    for (auto j = 0; j < 40; ++j) {
      if ((((sup >> j) & 1) == 0)
          && (((A[i] >> j) & 1) == 1)) {
        ok = false;
        break;
      }
    }
    if (ok) {
      t += B[i];
    }
  }
  ans = max(ans, t);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int x;cin>>x;
    yesno(x>=30);

    return 0;
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }

bool comp(const std::string& lh, const std::string& rh) {
     // 文字列lhの長さが文字列rhより短かったらtrueを返す
	 if (lh.length() == rh.length())
	 	return lh > rh;
 else     return lh.length() > rh.length();
}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N, M; cin >> N >> M;
	vector<ll> p(N); REP(i, N) cin >> p[i];
	UnionFind uf(N+1);
	REP(i, M) {
		int l,r; cin >> l >> r;
		uf.unionSet(l, r);
	}
	ll ans = 0;
	REP(i, N)  {
		if (uf.findSet(i + 1, p[i])) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pill pair<ll,ll>
#define s second
#define f first
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const ll N = 1e3 + 1 , M = 1e9 + 7;
ll n,m;
ll dp[N][N];
int main() {
	speed;
	cin >> n >> m;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			char x;
			cin >> x;
			dp[i][j] = (x == '#' ? -1 : 0);
		}	
	}
	dp[0][0] = 1;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			if(dp[i][j] == -1)continue;	
			if(i > 0)
				dp[i][j] += dp[i - 1][j] + (dp[i - 1][j] == -1);
			if(j > 0)
				dp[i][j] += dp[i][j - 1] + (dp[i][j - 1] == -1);
			dp[i][j] %= M;
		}
	}
	cout << dp[n - 1][m - 1] % M;
}
/*
Timus : 288471KD
Atcoder : Zhabka
Codeforces : Zhabka
mail : dzhon.snoudin@mail.ru
*/



Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int h,a;
    cin >> h >> a;
    int ans = 0;
    while(h > 0){
      h -= a;
      ans++;
    }
    print(ans);
}


Measured memory_bytes: 256
m[8][8];main(i,j){
	for(i=0;i<8;getchar(),i++)for(j=0;j<8;j++)m[i][j]=getchar();
	for(puts("90"),i=0;i<8;putchar('\n'),i++)for(j=7;j>=0;j--)putchar(m[j][i]);
	for(puts("180"),i=7;i>=0;putchar('\n'),i--)for(j=7;j>=0;j--)putchar(m[i][j]);
	for(puts("270"),i=7;i>=0;putchar('\n'),i--)for(j=0;j<8;j++)putchar(m[j][i]);
	exit(0);
}

Measured memory_bytes: 0
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int R,C,K; cin>>R>>C>>K;
   char g[R][C];
   for(int i=0; i<R; i++) for(int j=0; j<C; j++) cin>>g[i][j];

	int res=0;
	for(int i=0; i<(1<<R); i++) for(int j=0; j<(1<<C); j++){
      char gg[R][C];
      for(int i=0; i<R; i++) for(int j=0; j<C; j++) gg[i][j]=g[i][j];

      for(int k=0; k<R; k++) if( ((i)&(1<<(k))) ) for(int l=0; l<C; l++) gg[k][l]='R';
      for(int k=0; k<C; k++) if( ((j)&(1<<(k))) ) {for(int l=0; l<R; l++) gg[l][k]='R';}

      int s=0;
      for(int k=0; k<R; k++) for(int l=0; l<C; l++) if(gg[k][l]=='#') s++;
      if(s==K) res++;
	}
	cout << res << endl;


   return 0;
}



Measured memory_bytes: 3652
S = input()
acgt = ["A", "C", "G", "T"]
ans = 0

for i in range(len(S)):
    if S[i] in acgt:
        j = i
        while True:
            if j < len(S) - 1 and S[j + 1] in acgt:
                j += 1
            else:
                break
        ans = max(j - i + 1, ans)

print(ans)


Measured memory_bytes: 2940
n = int(input())
AC=0
WA=0
TLE=0
RE=0
list1 = []
for _ in range(n):
    s = input()
    list1.append(s)

for i in list1:
    if(i=='AC'):    AC+=1
    elif(i=='WA'):  WA+=1
    elif(i=="TLE"): TLE+=1
    else:
        RE+=1

print("AC x",AC )
print("WA x",WA )
print("TLE x",TLE )
print("RE x",RE )

Measured memory_bytes: 16328
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int cou[28]={0};
    string S;
    cin>>S;
    for(int i=0;i<S.size();i++){
        cou[S[i]-'a']++;
    }
    int flg=1;
    for(int i=0;i<28;i++){
        if(cou[i]%2==1)flg=0;
    }
    if(flg)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1;i <= 9; i++)
        if(n % i == 0)
          if(n / i <= 9)
            {cout << "Yes";
            return 0;
            }

            cout << "No";
    return 0;
}


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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n;
    cin >> n;
    map<int,int>mp;
    rep(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans=0;
    for(auto p:mp){
        if(p.second%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const int N = 3e3+9, M = 1e5+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
int n;
LL arr[N],memo[N][N][2];
LL solve(int i=0,int j=n-1,int player=0)
{
  if(i>j) return 0;

  LL &ret = memo[i][j][player];
  if(~ret) return ret;
  if(!player) ret = max(arr[i]-solve(i+1,j),arr[j]-solve(i,j-1));
  else  ret = min(solve(i+1,j)-arr[i],solve(i,j-1)-arr[j]); // X-Y
  
  return ret;

}

int main()
{
  memset(memo,-1,sizeof memo);

  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%lld",arr+i);
  printf("%lld",solve());

  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

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

int main(){
  int a,b,c;
cin>>a>>b;
  vector<int>A(b),B(b-1);
  if(a>=b){
    cout<<0<<endl;
  }
  else{
    c=0;
  for(int i=0;i<b;i++){
    cin>>A[i];
  }
sort(A.begin(),A.end());
  for(int i=0;i<b-1;i++){
  B[i]=abs(A[i]-A[i+1]);
  }
    sort(B.begin(),B.end());
   for(int i=0;i<b-a;i++){
     c+=B[i];
   }
  

    cout<<c<<endl;

  }
}


Measured memory_bytes: 1024
import math

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

ansp=1
ansq=1

for i in range(n):
    count=0
    for j in range(i+1,n):
        if p[i]>p[j]:
            count+=1
    ansp+=count*math.factorial(n-i-1)

for i in range(n):
    count=0
    for j in range(i+1,n):
        if q[i]>q[j]:
            count+=1
    ansq+=count*math.factorial(n-i-1)
print(abs(ansp-ansq))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
//ll a,b;
//ld ;
string s;
 
int main() {
  cin >> s;
  for(ll i=0;i<s.length();i++){
    cout << 'x';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n
  integer(4) :: k, i

  read *, n, k
  i = 1
  do
    if ( n/k > 0 ) then
      n = n/k
      i = i + 1
    else
      print *, i
      exit
    end if
  end do

end program main


Measured memory_bytes: 256
lst_blue = []
lst_red = []
dic = {}

N = int(input())
for i in range(0,N):
  lst_blue.append(input())
M = int(input())
for i in range(0,M):
  lst_red.append(input())

for i in list(set(lst_blue)):
  dic[i] = int(lst_blue.count(i))

for i in lst_red:
  if i in dic:
    dic[i] -= 1
    
print(max(0,max(dic.values())))

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

using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int ans = 0;
    sort(a.begin(), a.end());
    int i = 0;
    while(i < n) {
        int cc = a[i];
        int cnt = 0;
        while (i < n && a[i] == cc) {
            i++;
            cnt++;
        }
        ans += cnt % 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i, n) cin>>p[i];
    int min=2e5+1;
    int ans=0;
    rep(i, n){
        if(min>p[i]){
            min=p[i];
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}

fn main() {
    input! {
        l: f64
    }

    let t = l / 3.;
    println!("{}", t * t * t);
}


Measured memory_bytes: 4352
import itertools
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
s = [IS()[0] for _ in range(n)]
m = s.count('M');
a = s.count('A');
r = s.count('R');
c = s.count('C');
h = s.count('H');

march = ['M','A','R','C','H']
ans = 0
for combination in list(itertools.combinations(march, 3)):
    count = 1
    for char in combination:
        if char == 'M':
            count *= m
        elif char == 'A':
            count *= a
        elif char == 'R':
            count *= r
        elif char == 'C':
            count *= c
        else:  # char == 'h'
            count *= h
    ans += count
print(ans)


Measured memory_bytes: 4012
import Control.Applicative

inputs = fmap (read :: String -> Int) . words <$> getLine

ruu lst = [n | n <- [0..c*w] ,  (r*(n-1) + r0) < c*w]
    where
        r0 = lst !! 0
        w  = lst !! 1
        c  = lst !! 2
        r  = lst !! 3

solve lst = maximum $ 0 : lst
main = inputs >>= \x -> if (x !! 2) /= 0 then (print $ solve $ ruu x) >> main else do return ()

Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
	ll H,W,h,w;
  in(H>>W>>h>>w);
  ll a = H*W;
  a -= (h*W+H*w-h*w);
    out(a);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main (){
    int a, b, c;
    cin >> a >> b;
    c = a % b;
    double d =(double) a/ (double)b;
    cout << a / b <<" "<< c <<" "<<fixed<<setprecision(10)<<  d << endl;


}


Measured memory_bytes: 3284
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> d = new TreeSet<>();
        for(int i = 0;i < n;i++){
            d.add(sc.nextInt());
        }
        int min = -1;
        int ans = 0;
        for(Integer it : d){
            if(it <= min){
                break;
            }
            else{
                min = it;
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

using namespace std;

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

    vector<int> dp(3, 0), ndp(3, 0);
    for (int i = 0; i < n; ++i) {
        vector<int> a(3);
        cin >> a[0] >> a[1] >> a[2];
        fill(ndp.begin(), ndp.end(), 0);
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i == j) continue;
                ndp[j] = max(ndp[j], dp[i] + a[j]);
            }    
        }
        swap(dp, ndp);
    }

    cout << max(max(dp[0], dp[1]), dp[2]) << endl;


    return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if (a==b && b==c)
    cout << "No\n";
  else if(a==b || b==c || c== a)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 888
a=[]
n, k, q = map(int, input().split())
for _ in range(q):
    ss = input().split()
    a.append(int(ss[0]))
ans = [k-q] * n
for i in a:
    ans[i-1] = ans[i-1] + 1

for i in ans:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10488
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll i, j, k, l, m, n;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++) cin>>a[i];
	
	ll sum = 0;
	for(i=0;i<=60;i++)
	{
	    ll one = 1;
	    ll bit = one<<i;
	    ll count1=  0, count0 = 0;
	    for(j=0;j<n;j++)
	    {
	        if(a[j]&bit)
	        {
	           // if(i==32)
	           // cout<<"a:"<<a[j]<<" bit:"<<bit;
	            count1++;
	        }
	        else
	        {
	           // if(i==32)
	           // cout<<"a:"<<a[j]<<" bit:"<<bit;
	            count0++;
	        }
	        
	    }
	    bit = bit%mod;
	    ll bitsum = (count0*count1)%mod;
	    bitsum = (bitsum*bit)%mod;
	    sum = (sum + bitsum)%mod;
	    //cout<<"\ni:"<<i<<" sum:"<<sum<<" bitsum:"<<bitsum;
	}
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 5940
#include <iostream>
using namespace std;
int SelectSort(int A[],int N){
    int i,j,t,sw=0,minj;
    for ( i = 0; i < N-1; ++i) {
       minj=i;
        for ( j = i; j < N; ++j)
            if(A[j]<A[minj]) minj=j;
        t=A[i],A[i]=A[minj],A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}
int main() {
    int n,i,a[110],sw;
    cin>>n;
    for (i = 0; i < n; ++i) cin>>a[i];
    sw=SelectSort(a,n);
    for ( i = 0; i < n; ++i) {
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

int s(int x, int y, int z) {
	return abs(y - x) + abs(z - y);
}

int main(void) {
	int A1, A2, A3;
	int c[6];
	int i, min;
	if (scanf("%d%d%d", &A1, &A2, &A3) != 3) return 1;

	c[0] = s(A1, A2, A3);
	c[1] = s(A1, A3, A2);
	c[2] = s(A2, A1, A3);
	c[3] = s(A2, A3, A1);
	c[4] = s(A3, A1, A2);
	c[5] = s(A3, A2, A1);

	min = c[0];
	for (i = 1; i < 6; i++) {
		if (c[i] < min) min = c[i];
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define INF 10000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
int n,k,a[111111],bit[50],dp[50][2],b[50];
signed main(){
	cin>>n>>k;
	b[0]=1;
	for(int i=1;i<=50;i++)b[i]=b[i-1]*2;
	rep(i,n){
		cin>>a[i];
		rep(j,45){
			if((a[i]>>j)&(ll)1)bit[j]++;
		}
	}
	rep(i,46)dp[i][0]=-INF;
	for(int i=45;i>=0;i--){
		if(k<b[i]){
			dp[i][1]=dp[i+1][1]+b[i]*bit[i];
			continue;
		}
		dp[i][0]=dp[i+1][0];
		dp[i][1]=dp[i+1][1];
		if(n-bit[i]>=bit[i]){
			if((k>>i)&(ll)1){
				dp[i][1]=max(dp[i][1],dp[i+1][1]+(n-bit[i])*b[i]);
				dp[i][0]=max(dp[i][0],dp[i+1][1]+b[i]*bit[i]);
			}
			else dp[i][1]=max(dp[i][1],dp[i+1][1]+b[i]*bit[i]);
			dp[i][0]=max(dp[i][0],dp[i+1][0]+b[i]*(n-bit[i]));
		}
		else{
			if((k>>i)&(ll)1){
				dp[i][0]=max(dp[i+1][0],dp[i+1][1]+b[i]*bit[i]);
			}
			else{
				dp[i][1]=dp[i+1][1]+b[i]*bit[i];
				dp[i][0]=dp[i+1][0]+b[i]*bit[i];
			}
		}
		dp[i][1]=max(dp[i][1],dp[i][0]);
	}
	cout<<dp[0][1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
ll sum[N],ls[N];
ll lsree[N];
int n,k,nn,c;
void add(int x)
{
	while(x<=nn)//nn为上限，要大于离散化后的最大的数字
	{
		lsree[x]++;
		x+=x&-x;   //向上更新
	}
}
ll query(int x)
{
	ll s=0;
	while(x)
	{
		s+=lsree[x];
		x-=x&-x;   //向下求和
	}
	return s;
}
int main()
{
	scanf("%d %d",&n,&k);
	nn=n+5;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		ls[i]=sum[i]=sum[i-1]+a-k;   //预处理出sum[i]数组
	}
	sort(ls,ls+1+n);   //排序，排n+1个数字的序（包括了sum[0]）
	c=unique(ls,ls+1+n)-ls;   //去重
	for(int i=0;i<=n;i++)
	sum[i]=lower_bound(ls,ls+1+c,sum[i])-ls+1;  //离散化 
	
	ll s=0;
	for(int i=0;i<=n;i++)
	{
		s+=query(sum[i]);  //查询有多少个小于sum[i]的数字
		add(sum[i]);   //更新 
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()


using namespace std;
 
int main(void)
{   
    string s,t;
    cin >> s >> t;
    
    sort(all(s));
    sort(all(t),greater<int>());

    bool f = true;
    REP(i, min(s.size(),t.size())){
        if(s[i] < t[i]){
            break;
        }
        else if(s[i] > t[i]){
            f = false;
        }
        else if(i == s.size() -1 && s.size() == t.size() && s[i] == t[i]){
            f = false;
        }
        else if(i == t.size() -1 && s[i] == t[i] && s.size() > t.size()){
            f = false;
        }
        else continue;
    }
    
    if(f) yOUT;
    else nOUT;
}

Measured memory_bytes: 256
import sys
for i in sys.stdin.readlines():
        a,b = i.strip().split()
        if a == "0" and b == "0":
                break

        if int(a) < int(b):
                print("{0} {1}".format(a,b))
        else:
                print("{1} {0}".format(a,b))
        

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;

  for (int c = 1; c < n; c++){
    int num = n-c;
    int l = sqrt(num);
    for( int i=1; i<=l; ++i ){
      if( num%i == 0 )
        if( num/i == i ) {
          ans++;
        } else {
          ans += 2;
        }
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3680
#include <stdio.h>
#define FOR(x,n) for(int i=(x);i<(n);i++)
int main(void){
    int hp,var,buf=0;
    int power=0;
    scanf("%i %i\n",&hp,&var);
    FOR(0,var){
        scanf("%i",&buf);
        power+=buf;
    }
    if(hp<=power){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 128
h,w=map(int, input().split())
maps=[[0]*w for i in range(h)]
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            maps[i][j]=-1
    
maps_l=[[0]*w for i in range(h)]
maps_r=[[0]*w for i in range(h)]
maps_u=[[0]*w for i in range(h)]
maps_d=[[0]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if maps[i][j]==-1:
            maps_l[i][j]=0
        elif j==0:
            maps_l[i][j]=1
        else:
            maps_l[i][j]=maps_l[i][j-1]+1

for i in range(h):
    for j in range(w-1,-1,-1):
        if maps[i][j]==-1:
            maps_r[i][j]=0
        elif j==w-1:
            maps_r[i][j]=1
        else:
            maps_r[i][j]=maps_r[i][j+1]+1

for j in range(w):
    for i in range(h):
        if maps[i][j]==-1:
            maps_d[i][j]=0
        elif i==0:
            maps_d[i][j]=1
        else:
            maps_d[i][j]=maps_d[i-1][j]+1

for j in range(w):
    for i in range(h-1,-1,-1):
        if maps[i][j]==-1:
            maps_u[i][j]=0
        elif i==h-1:
            maps_u[i][j]=1
        else:
            maps_u[i][j]=maps_u[i+1][j]+1
ans=0
for i in range(h):
    for j in range(w):
        if maps[i][j]!=-1:
            ans=max(ans,maps_u[i][j]+maps_d[i][j]+maps_r[i][j]+maps_l[i][j]-3)

print(ans)

Measured memory_bytes: 232908
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//アルファベットのデータセットn

		//String nsh = "";

		//ループ
		while (true) {
			String n = sc.next();
			//区切り部分

			//-が来たら終了する
			if (n.equals("-")) {
				break;
			}

			//シャッフル回数m
			int m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				//hが数字かそうでないかで判定
				//				try {
				//					Integer.parseInt(h);
				//				} catch (NumberFormatException e) {
				//					System.out.println(n);
				//					n = h;
				//					continue;
				//				}

				//カット位置h
				String h = sc.next();

				//残す部分nFront
				String nf = n.substring(Integer.parseInt(h));

				//hまでを抜き出して後ろに接続するnRear
				String nr = n.substring(0, Integer.parseInt(h));

				//シャッフル後nShuffle
				n = nf + nr;
				//System.out.println(n);
			}

			System.out.println(n);
		}
		sc.close();
	}

}


Measured memory_bytes: 26460
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/7/ALDS1_7_A
# 図参照
# 配列を3つ用意してもよいがここではクラスを定義する。
# 本ではNILを-1としていたがここではNoneとして実装する（どっちのほうがいいんだろう）

import sys
sys.setrecursionlimit(2**20)  # 再帰回数上限の向上


class Node:
    def __init__(self,
                 parent,
                 left,
                 right):
        self.parent = parent
        self.left = left  # 一番左の**子**ノードということに注意
        self.right = right


def get_depth(T: dict, u: int):
    '''
    Tは木の構造と見立てたdict
    uはTのノード
    '''
    d = 0
    while T[u].parent is not None:
        u = T[u].parent
        d += 1  # 親をたどりながらdを増やしていく。


D = {}  # 深さを保存しておく用のdict


def get_all_depth(T: dict, u: int, p: int):
    '''
    一度にすべてのノードの深さを取得する関数(再帰的に処理を行う)。
    一気に全体の深さを求めるならばこちらの方がオーダーが小さい。
    pは現在扱う深さ
    '''
    D[u] = p
    # ココらへんの動きは図を参照、ふさごとに深さ優先探索している感じ
    if T[u].right is not None:
        # 右の兄弟ノード(深さは同じ)から入れていく
        get_all_depth(T, T[u].right, p)
    if T[u].left is not None:
        # 兄弟を入れ終わったら次は下のふさへ
        get_all_depth(T, T[u].left, p+1)


def ret_children(T, u):
    chilren = []
    c = T[u].left
    while c is not None:
        chilren.append(c)
        c = T[c].right
    return chilren

# 答え出力用


def print_for_a_node(T: dict, node: int, D: dict):
    node_type = 'internal node' if T[node].left is not None else 'leaf'
    if T[node].parent is None:
        parent = -1
        node_type = 'root'
    else:
        parent = T[node].parent
    children = ret_children(T, node)

    print(
        f'node {node}: parent = {parent}, depth = {D[node]}, {node_type}, {children}')


# この問題は入力をNoneに適する形に整形するのも少し難しい
n = int(input())

T = {k: Node(None, None, None) for k in range(n)}  # pythonぽくないけど初期化
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] == 0:  # もし子ノードがなければ次へ
        continue
    T[tmp[0]].left = tmp[2]  # 一番左の子ノードは即座にわかる
    T[tmp[2]].parent = tmp[0]  # 子の親ノードも即座に与えられる
    prev_sibling = tmp[2]  # 前のノード番号を覚えておく用
    for sib in tmp[3:]:
        T[prev_sibling].right = sib
        T[sib].parent = tmp[0]  # 子から親を与えている
        prev_sibling = sib

for node in range(n):
    if T[node].parent is None:
        get_all_depth(T, node, 0)  # rootを入れなければいけないことに注意
        # Dに深さが入った
        break

# print(n)
# print(T)
# print(D)

for node in range(n):
    print_for_a_node(T, node, D)



Measured memory_bytes: 142156