akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

Int dp[50][2];

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

    Int n,k,L; cin>>n>>k; Int a[n]; 
    fill(dp[0],dp[50],-1); dp[0][0]=0;
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = 0; i < 49; i++){
        Int M=1LL<<(48-i),t=0,f=0;
        for (int k = 0; k < n; k++){
            if(a[k]&M)f++;
            else t++;
        }
        f*=M,t*=M;
        if(dp[i][1]!=-1)chmax(dp[i+1][1],dp[i][1]+max(f,t));
        if(dp[i][0]!=-1){
            if(k&M){
                chmax(dp[i+1][1],dp[i][0]+f);
                chmax(dp[i+1][0],dp[i][0]+t);
            }else chmax(dp[i+1][0],dp[i][0]+f);
        }
    }
    cout<<max(dp[49][0],dp[49][1])<<'\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  cin >> N >> M;
  double oup = 0;
  for(int x = 1; x<=N; x++){
    int c=0;
    int t=x;
    while(t<M){
      c+=1;
      t*=2;
    }
    oup += pow(.5, c);
  }
  cout.precision(12);
  cout << (double)1.0/(double)N*oup << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    fastIO;
    string s;
    bool y = false, m = false;
    cin >> s;
    if((s[0] < '1' || s[1] < '3') && (s[0] != '0' || s[1] != '0')) m = true;
    if((s[2] < '1' || s[3] < '3') && (s[2] != '0' || s[3] != '0')) y = true;

    if(m && y) cout << "AMBIGUOUS" << endl;
    else if(m) cout << "MMYY" << endl;
    else if(y) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>
#include <vector>

using namespace std;

int main()
{
  unsigned N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  unsigned happiness = 0;
  
  for (int n=0; n<N; ++n) {
    if ((n>0 && S[n]=='L' && S[n-1]=='L') ||
	(n<N-1 && S[n]=='R' && S[n+1]=='R'))
      ++happiness;
  }

  cout << min(N-1, happiness+2*K) << endl;
}

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

//   vector<bool> S;
//   S.reserve(N);

//   unsigned different_from_first = 0;
//   bool first_letter;

//   {
//     string SS;
//     cin >> SS;
  
//     for (unsigned n=0; n<N; ++n) {
//       bool s = SS[n]=='L';
//       S.push_back(s);
//       if (n==0)
// 	first_letter = s;
//       else if (different_from_first == 0 && s!=first_letter)
// 	different_from_first = n;
//     }
//   }

//   if (N==1 || different_from_first == 0) {
//     cout << N-1 << endl;
//     return 0;
//   }

//   for (unsigned k=0; k<K; ++k) {
//     unsigned l = different_from_first;
//     unsigned r = l;
//     while (first_letter!=S[r++]) {
//       if (r==N) {
// 	cout << N-1 << endl;
// 	return 0;
//       }
//     }
//     different_from_first = r-1;
//     while (S[different_from_first++]==first_letter) {
//       if (different_from_first==N) {
// 	cout << N-1 << endl;
// 	return 0;
//       }
//     }
//     --different_from_first;

//     cerr << "DFF:" << different_from_first << endl;
//   }

//   unsigned ans = different_from_first-1;
//   for (unsigned ii=different_from_first; ii<N; ++ii) {
//     if ( (S[ii] && S[ii-1]==S[ii]) || (!S[ii] && ii<N-1 && S[ii+1]==S[ii]) )
//       ++ans;
//   }

//   cout << ans << endl;

//   return 0;
// }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 2e5; int n;
lli a[maxN];

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    lli maxA = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
      if (maxA > a[i]) ans += maxA - a[i];
      maxA = max(maxA, a[i]);
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 5396
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n, m;
string s;

int cnt;

int main(){

  n = in();
  m = in();
  REP( i , n ){
    s = stin();
    YYS( w , s ){
      if( w == '#' ){
        cnt++;
      }
    }
  }

  if( cnt == n + m - 1 ){
    puts( "Possible" );
  } else {
    puts( "Impossible" );
  }
  
  return 0;
}


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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N);
        for(int i=0;i<N;i++){
            int t; cin >> t;
            a[t-1] = i;
        }
        int res = 0;
        for(int i=0;i<N;){
            int cnt = 1;
            while(i+cnt < N && a[i+cnt-1] < a[i+cnt]) ++cnt;
            res = max(res, cnt);
            i += cnt;
        }
        cout << N - res << endl;
    }
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<vector<T>> m) {
    repall (v, m)
        init(v);
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int x;
    cin >> x;
    YN(x == 7 or x == 5 or x == 3);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(i,a,b) for(ll i=a; i<b; i++)
ll gcd(ll ina, ll inb) 
{     
    if (ina == 0) 
       return inb; 
    if (inb == 0) 
       return ina; 
   
    
    if (ina == inb) 
        return ina; 
   
    if (ina > inb) 
        return gcd(ina-inb, inb); 
    return gcd(ina, inb-ina); 
} 
ll lcm(ll in1, ll in2)
{ ll ans=1; ans=(in1*in2)/gcd(in1,in2); 
return ans;
}
int main()
{ ll n,w; cin>>n>>w; ll a[n][w+1]={}; ll b,c; cin>>b>>c; 
f(i7,0,b) { a[0][i7]=0;  } f(i8,b,w+1) {a[0][i8]=c;} 
f(i,1,n) {  cin>>b>>c; f(j,0,w+1) {  if(j<(b)) { a[i][j]=a[i-1][j]; } 
else { a[i][j]=max(a[i-1][j],c+a[i-1][j-b]);  }  } }
cout<<a[n-1][w]<<"\n";
}   






Measured memory_bytes: 81632
import Data.Char as Char

solve :: String -> String
solve = solveInner 0

solveInner :: Int -> String -> String
solveInner idx s
    | idx >= 26 = "None"
    | elem c s = solveInner (idx + 1) s
    | otherwise = [c]
    where
        c = chr (idx + (Char.ord 'a'))

main :: IO ()
main = do
    s <- getLine
    putStrLn $ solve s

Measured memory_bytes: 7164
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, x, sum, minl = INF;
int m[10101];
int main() {
	cin >> n >> x;
	REP(i, n) {
		cin >> m[i];
		sum += m[i];
		minl = min(m[i], minl);
	}
	cout << n + (x - sum) / minl << endl;
}

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

int main()
{
int n,count=0;
double r;
cin>>n;
for(int i=1;i<=n;i++)
{
if(i%2!=0)
count=count+1;
}	
r=1.0*count/n;
cout<<fixed<<setprecision(10)<<r<<endl;	
	
return 0;	
 
}


Measured memory_bytes: 256
"use strict";
const main = arg => {
  let ans = "No";
  let info = arg * 1;
  for(let i = 1; i < 10; i++){
    for(let j = 1; j < 10; j++){
      if( info == i * j ){
      	ans = "Yes";
        break;
      }
  	}
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  rep(i,3){
    string s;cin>>s;
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n + 2];
    long long int ans = 0;
    a[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        ans += abs(a[i] - a[i - 1]);
    }
    ans += abs(a[n]);
    a[n + 1] = 0;
    //cout << ans << endl;
    for(int i = 1; i <= n; i++) {
        int f = abs(a[i] - a[i - 1]);
        int ff = abs(a[i] - a[i + 1]);
        int p = abs(a[i - 1] - a[i + 1]);
        cout << ans + p - ff - f << endl;
    }
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))  # [1, 2, 3, 4] になる
B = list()
judge = 1
for a in A:
    if a%2 == 0:
        B.append(a)

for b in B:
    if b%3==0 or b%5==0:
        continue
    else:
        judge = -1

if judge == 1:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n){
        int x, y;
        cin >> x >> y;
        if(x > y){
            swap(x, y);
        }
        a[i] = {x, y};
    }
    sort(ALL(a));

    int maxi = 0;
    for(int i = 1; i < n; i++){
        if(a[maxi].second <= a[i].second){
            maxi = i;
        }
    }

    int mini = 0;
    rep(i, n){
        if(a[mini].second >= a[i].second){
            mini = i;
        }
    }
    int ans = (a[n-1].first - a[0].first) * (a[maxi].second - a[mini].second);

    maxi = 1;
    for(int i = 1; i < n; i++){
        if(a[maxi].second <= a[i].second){
            maxi = i;
        }
    }

    multiset<int> ms;
    rep(i, n){
        if(i == 0){
            ms.insert(a[0].second);
            continue;
        }
        ms.insert(a[i].first);
    }
    for(int i = 1; i < n; i++){
        if(*ms.begin() < a[i].second){
            ms.erase(ms.find(a[i].first));
            ms.insert(a[i].second);
        }
        int tmp = (a[maxi].second - a[0].first) * (*ms.rbegin() - *ms.begin());
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=1;i<=b;i++){
		for(int j=0;j<a-1;j++){
			if(c[j]%i>c[j+1]%i)swap(c[j],c[j+1]);
		}
	}
	for(int i=0;i<a;i++)printf("%d\n",c[i]);
}

Measured memory_bytes: 2756
def pos(a, b, seq):
	st = set([a])
	for k in seq:
		new_st = set(st)
		for v in st:
			new_st.add(v%k)
		st = new_st
	return b in st
	
def main():
	n = input()
	aa = map(int, raw_input().split())
	bb = map(int, raw_input().split())
	def ok(seq):
		for a,b in zip(aa,bb):
			if not pos(a,b,seq):
				return False
		return True
	u = []
	for j in xrange(60,0,-1):
		if not ok(u + range(j-1,0,-1)):
			u.append(j)
	#print u
	if 59 in u:
		print -1
		return
	else:
		print sum(2**k for k in u)

main()


Measured memory_bytes: 2692
#include <iostream>

using namespace std;

int map[10][10]= {};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, -2, 0, 0}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1, 0, 0, 2, -2};
  
void drop_ink(int x, int y, int size)
{
  map[x][y]++;
  for(int i = 0; i < 4 * size; i++)
    if(x+dx[i] < 10 && x+dx[i] >= 0 && y+dy[i] < 10 && y+dy[i] >= 0)
      map[x+dx[i]][y+dy[i]]++;
}

int main()
{
  int x, y, s, ans1, ans2 = 0;
  char c;
  while(cin >> x >> c >> y >> c >> s){
    drop_ink(x, y, s);
    ans1 = 0;
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
	if(map[i][j] == 0)
	  ans1++;
	ans2 = (map[i][j] > ans2) ? map[i][j] : ans2;        
      }
    }
  }
  cout << ans1 << endl << ans2 << endl;
}

Measured memory_bytes: 1160
import Data.Array.IO
import Data.Int
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Mutable as VM
import Data.Maybe
import Control.Monad

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

bsToNum :: Integral a => BS.ByteString -> a
bsToNum = fromIntegral . fst . fromJust . BS.readInt

main = do
  n <- readLn :: IO Int
  tree <- VM.new n :: IO (VM.IOVector [(Int,Int64)])
  forM_ [0..n-1] $ \i -> VM.write tree i []

  replicateM (n-1) $ do
    (a,b,c) <- BS.getLine >>= return . (\(a:b:c:_) -> (bsToNum a, bsToNum b, bsToNum c)) . BS.words :: IO (Int,Int,Int64)
    VM.read tree (a-1) >>= \x -> VM.write tree (a-1) ((b,c):x)
    VM.read tree (b-1) >>= \x -> VM.write tree (b-1) ((a,c):x)    

  (q:k:_) <- getLine >>= return . map read . words :: IO [Int]

  dist <- VM.new n :: IO (VM.IOVector Int64)
  forM_ [0..n-1] $ \i -> VM.write dist i (-1)

  let
    calc :: Int -> Int -> Int64 -> IO ()
    calc i p d = do
      nodes <- VM.read tree (i-1)
      forM_ nodes $ \(next, c) -> do
        when (next /= p) $ do
          VM.write dist (next-1) (d+c)
          calc next i (d+c)

  VM.write dist (k-1) 0
  calc k (-1) 0

  replicateM q $ do
    (x:y:_) <- BS.getLine >>= return . map bsToNum . BS.words :: IO [Int]
    mapM (VM.read dist) [x-1,y-1] >>= print . sum


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

const int MAX = 1e7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    COMinit();
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep (i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll mx = 0, mi = 0;
    rep (i, n) {
        if (i < k - 1) continue;
        ll tmp = COM(i, k - 1);
        mx += (a[i] * tmp) % MOD;
        mx %= MOD;
    }
    reverse(a.begin(), a.end());
    rep (i, n) {
        if (i < k - 1) continue;
        ll tmp = COM(i, k - 1);
        mi += (a[i] * tmp) % MOD;
        mi %= MOD;
    }
    ll res = mx - mi;
    if (res < 0) res += MOD;
    res %= MOD;

    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 235392
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  string S;
  cin >> S;
  char old = 'o';
  int ans = 0;
  REP(i,n){
      if (old == S[i]){
          ans += 1;
      }
      old = S[i];
  }
  ans = min(n-1,ans + 2*k);
  cout << ans << endl;

}


Measured memory_bytes: 512
#include <stdio.h>

int n;
int in[100000][3];
int dp[100000][3];

int max(int a, int b)
{
	if (a > b)
		return a;
	return b;
}
int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	int i = 0;
	while (i < n){
		scanf("%d %d %d", &in[i][0], &in[i][1], &in[i][2]); 
		i++;
	}
	i = 0;
	while (i < n)
	{
		int j = 0;
		while (j < 3)
		{
			int k = 0;
			while (k < 3)
			{
				if(j != k) dp[i+1][j] = max(in[i][j] + dp[i][k++], dp[i+1][j]);
				else k++;
			}
			j++;
		}
		i++;
	}
	int ans = 0;
	i = 0;
	while (i < 3)
		ans = max(ans, dp[n][i++]);
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int N;
int main(){
	cin>>N;
	int ans=0;
	REP(i,N){
		int a;
		cin>>a;
		ans=gcd(ans,a);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	long long int  a, x, b = 0, c = 0, count = 0, ans = 0, n = 0, h = 0, l = 0, d = 0, e = 0, f = 0, g = 0, m, v, p, k;
	string s, t;
	cin >> x;
	while (1) {
		if (x == 2 || x == 3) {
			cout << x << endl;
			break;
		}
		if (x == 1) {
			cout << "2" << endl;
		}
		count = x;
		if (x % 2 == 0) {
			x++;
			continue;
		}
		for (int i = 3; i < x; i = i + 2) {
			if (x % i == 0) {
				x++;
				break;
			}
		}
		if (count == x) {
			cout << x << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicReferenceArray;

public class Main {


  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N+100];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    int[] dp = new int[N+100];

//    dp[0] = 0;
//    for (int i = 1; i <N ; i++) {
//      //morau dp
//      dp[i] = Integer.MAX_VALUE;
//
//      for (int j =i-K ; j <i ; j++) {
//        if(j >=0) {
//          dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i]-h[j]));
//        }
//      }
//
//    }

    Arrays.fill(dp,Integer.MAX_VALUE);
    dp[0]=0;

    for (int i = 0; i < N; i++) {
      for (int j = i+1; j <=i+K ; j++) {
        dp[j] = Math.min(dp[j],dp[i] + Math.abs(h[i]-h[j]));
      }
    }

    System.out.println(dp[N-1]);


  }


}


Measured memory_bytes: 51004
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

int N, M, A, B;
std::string s;

void solve() {

}

int main() {
    std::cin >> s;
    if (s.length() == 2) {
        std::cout << s << std::endl;
    } else {
        for (int i=s.length()-1; i>=0; i--) {
            std::cout << s[i];
        }
        std::cout << std::endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  vector<int> v;
  int n,result;
  for(int i=0;i<5;i++){
    int tmp;
  	cin >> tmp;
    v.push_back(tmp);
  }

  cin >> n;
                                                     
  if(*max_element(v.begin(),v.end())-*min_element(v.begin(),v.end())<=n){
  	cout << "Yay!";
  }else{
  	cout << ":(";
  }
  return 0;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int N, M;
    std::cin >> N >> M;
    std::vector<std::pair<int64_t, int>> shops(N);
    for (auto& i : shops)std::cin >> i.first >> i.second;
    std::sort(shops.begin(), shops.end());
    int sum = 0;
    int64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += shops[i].first * std::min(M, shops[i].second);
        M = std::max(M - shops[i].second, 0);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#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 all(x) (x).begin(),().end()
#define SZ(x) ((int)(x).size())
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        string s;
        string t;
        cin>>s>>t;

        cout<<t<<s<<endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
main(){
  int l[10];
  int v[2];
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
    double h;
    double k;
    int res;
    for(int i=0;i<10;i++){
      int j;
      k=0;
      for(j=0;j<=i;j++){
	k+=(double)l[j];
      }
      h=k/(double)v[0];
      k=h*v[1];
      double tk=0;
      for(j=9;j>=0;j--){
	tk+=(double)l[j];
	if(tk >= k) break;
      }
      //printf("%lf %lf   %d : %d\n",h,k,i,j);
      if(i > j){
	double th;
	tk=0;
	for(j=9;j>=i;j--){
	  tk+=(double)l[j];
	}
	k=0;
	for(j=0;j<i;j++)
	  k+=(double)l[j];
	h=k/(double)v[0];
	th=tk/(double)v[1];
	//	printf("%lf->%lf <> %lf->%lf : %d\n",k,h,tk,th,i);
	if(th > h) res=i+1;
	else
	  res=i;
	break;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
//#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(20)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class Modint {
public:
	ll val;
	Modint(ll a) {
		val = a % mod;
	}
	Modint operator+(const Modint& r) {
		return Modint((this->val + r.val) % mod);
	}
	Modint operator-(const Modint& r) {
		return Modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	Modint operator*(const Modint& r) {
		return Modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	Modint operator/(const Modint& r) {
		return Modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	Modint& operator+=(const Modint& r) {
		*this = *this + r;
		return *this;
	}
	Modint& operator-=(const Modint& r) {
		*this = *this - r;
		return *this;
	}
	Modint& operator*=(const Modint& r) {
		*this = *this * r;
		return *this;
	}
	Modint& operator/=(const Modint& r) {
		*this = *this / r;
		return *this;
	}

};

//dp[i][j]
int main() {
	string S;
	cin >> S;
	vector<vector<Modint<MOD>>> dp(S.size() + 1, vector<Modint<MOD>>(13, 0));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 13; j++) {
			if (S[i] == '?') {
				for (int k = 0; k < 10; k++) {
					dp[i + 1][(j*10 + k) % 13] += dp[i][j];
				}
			}
			else {
				dp[i + 1][(j*10 + (S[i] - '0')) % 13] += dp[i][j];
			}
		}
	}
	cout << dp[S.size()][5].val << endl;
}

Measured memory_bytes: 16660
#include <stdio.h>

int search(int A[], int n, int key){
  int i=0;
  A[n]=key;
  while(A[i] !=key) i++;
  return i !=n;
}

int main(){
  int i, n, A[10000+1], q, key, sum=0;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2756
import java.util.Scanner;
import java.util.Stack;

/**
 * https://abc064.contest.atcoder.jp/tasks/abc064_d
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();
		
		Stack<String> stack = new Stack<>();
		for(int i=N-1; i>=0; i--){
			stack.push(Character.toString(s[i]));
		}
		
		StringBuilder sb = new StringBuilder();
		int current = 0;
		while(!stack.isEmpty()){
			String c = stack.pop();
			if(c.equals("(")){
				current++;
				sb.append(c);
			}else{
				if(current>0){
					sb.append(c);
					current--;
				}else{
					sb = new StringBuilder("("+ sb.toString()+")");
				}
			}
		}
		for(int i=0; i<current; i++){
			sb.append(")");
		}
		
		System.out.println(sb);

	}

}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < N; i++) {
			int h = sc.nextInt();
			if(h>=K) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 45132
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        int N = sn.nextInt();
        if(N % 10 == 7){
            System.out.println("Yes");
        }else{
            N = N/10;
            if(N % 10 == 7){
                System.out.println("Yes");
            }else{
                N = N/10;
                if(N % 10 == 7){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }
        }

    }
}

Measured memory_bytes: 35656
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
double dp[305][305][305];
int N;
int a[305];
double rec(int x,int y,int z){
 if(dp[x][y][z]!=-1.0)return dp[x][y][z];
 double p = (double)(N-x-y-z)/(double)N;
 auto& t = dp[x][y][z];
 t = 1.0;
 if(x>0)t += rec(x-1,y,z)*(double)x/(double)N;
 if(y>0)t += rec(x+1,y-1,z)*(double)y/(double)N;
 if(z>0)t += rec(x,y+1,z-1)*(double)z/(double)N;
 t /= (1.0-p);
 return t;
}
int main(){
  fastio();
  cin >> N;
  int x=0,y=0,z=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]==1)x++;
    if(a[i]==2)y++;
    if(a[i]==3)z++;
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      for(int k=0;k<=N;k++){
        dp[i][j][k] = -1.0;
      }
    }
  }
  dp[0][0][0] = 0.0;
  cout << rec(x,y,z) << endl;
  return 0;
}


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

#define N 131075
#define int long long
#define INF 0x7fffffffffffffff

using namespace std;

struct edge
{
	int a,b;
};

bool operator < (edge a,edge b)
{
	if(a.a==b.a)return a.b<b.b;
	return a.a<b.a;
}

int n,sum;
int cnt,head[N],to[N<<1],w[N<<1],nxt[N<<1];
int ch[N][2],pre[N],size[N];

vector<edge>g[N],o;

void adde(int u,int v,int wi)
{
	to[++cnt]=v;
	w[cnt]=wi;
	nxt[cnt]=head[u];
	head[u]=cnt;
}

void dfs(int u,int fa)
{
	int tot=0;
	size[u]=1;
	for(int i=head[u];i;i=nxt[i])
	{
		if(to[i]!=fa)
		{
			ch[u][tot++]=to[i];
			pre[to[i]]=w[i];
			dfs(to[i],u);
			size[u]+=size[to[i]];
		}
	}
}

bool get(int a,int b,int x,int b1,int &a2,int &b2)
{
	int l=0,r=g[b].size()-1;
	while(l<r-1)
	{
		int mid=(l+r)>>1;
		a2=g[b][mid].a,b2=g[b][mid].b;
		if(b1+pre[a]+pre[b]+a2<=x)l=mid;
		else r=mid;
	}
	a2=g[b][r].a,b2=g[b][r].b;
	if(b1+pre[a]+pre[b]+a2<=x)return true;
	a2=g[b][l].a,b2=g[b][l].b;
	if(b1+pre[a]+pre[b]+a2<=x)return true;
	return false;
}

void merge(int u,int x)
{
	if(ch[u][0]) 
	{
		int a=ch[u][0],b=ch[u][1];
		merge(a,x),merge(b,x);
		o.clear();
		if(size[a]>size[b])swap(a,b);
		if(!g[a].size()||!g[b].size())
			return;
		for(int i=0;i<g[a].size();i++)
		{
			int a1=g[a][i].a,b1=g[a][i].b,a2,b2;
			if(!get(a,b,x,b1,a2,b2))
				continue;
			o.push_back((edge){a1+pre[a],b2+pre[b]});
			o.push_back((edge){b2+pre[b],a1+pre[a]});
		}
		sort(o.begin(),o.end());
		int minn=INF;
		for(int i=0;i<o.size();i++)
		{
			if(o[i].b<minn)
			{
				minn=o[i].b;
				g[u].push_back(o[i]);
			}
		}
	}
	else g[u].push_back((edge){0,0});
}

bool check(int x)
{
	for(int i=1;i<=n;i++)
		g[i].clear();
	merge(1,x);
	return g[1].size()>0;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<n;i++)
	{
		int a,v;
		scanf("%lld%lld",&a,&v);
		adde(i+1,a,v),adde(a,i+1,v);
		sum+=v;
	}
	dfs(1,0);
	int l=0,r=sum,ans;
	while(l<r-1)
	{
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	if(check(l)) ans=l;
	else ans=r;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 39284
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>

#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 400000 + 10;

int N;
int A[MAXN];

void Work()
{
	scanf("%d", &N);
	int x = 1, y = 1;
	for (int i = 0; i < N; i ++)
	{
		scanf("%d", &A[i]);
		x *= 3;
		if (A[i] % 2 == 1)
			y *= 1;
		else
			y *= 2;
	}
	printf("%d\n", x - y);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
struct Edge{
	long long to,cost,dis;//used in state is cur_v,cur_money,distance with node 1
};
vector<Edge> g[55];
long long c[55],d[55],dp[55][2550],maxv=2500;
struct cmp{
	bool operator()(const Edge a,const Edge b)const{
		return a.dis>b.dis;
	}
};
priority_queue<Edge,vector<Edge>,cmp> pq;
int main(){
	long long i,j,n,m,s,u,v,a,b;
	scanf("%lld%lld%lld",&n,&m,&s);
	for(i=0;i<m;i++){
		scanf("%lld%lld%lld%lld",&u,&v,&a,&b);
		g[u].emplace_back((Edge){v,a,b});
		g[v].emplace_back((Edge){u,a,b});
	}
	for(i=1;i<=n;i++)	
		scanf("%lld%lld",&c[i],&d[i]);
	for(i=0;i<55;i++)
		for(j=0;j<2550;j++)
			dp[i][j]=100000000000000000;
	s=min(s,maxv);
	pq.push({1,s,0});
	dp[1][s]=0;
	while(pq.size()){
		auto x=pq.top();
		pq.pop();
		if(dp[x.to][min(x.cost+c[x.to],maxv)]>x.dis+d[x.to]){
			dp[x.to][min(x.cost+c[x.to],maxv)]=x.dis+d[x.to];
			pq.push({x.to,min(x.cost+c[x.to],maxv),dp[x.to][min(x.cost+c[x.to],maxv)]});
		}
		for(auto y:g[x.to]){
			if(x.cost<y.cost)
				continue;
			if(dp[y.to][x.cost-y.cost]>x.dis+y.dis){
				dp[y.to][x.cost-y.cost]=x.dis+y.dis;
				pq.push({y.to,x.cost-y.cost,dp[y.to][x.cost-y.cost]});
			}
		}
	}
	for(i=2;i<=n;i++)
		printf("%lld\n",*min_element(dp[i],dp[i]+maxv));
}

Measured memory_bytes: 6964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i;
    cin>>n;
    ll sum=0;
    for(i=1; i<=n; i++)
    {
        if(i%3==0|| i%5==0) continue;
        else sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
 using  namespace std;
 int main()
 {
 int a,b,c;
cin>>a>>b>>c;
set<int > se;
se.insert(a);se.insert(b);se.insert(c);
if(se.size()==2)
 cout<<"Yes"<<endl;
else cout<<"No"<<endl;
  return 0;
 } 

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

long long pow_mod(int a, long x) {
  long long ret = a;
  for (long i = x; i > 1; i--) {
    ret = ret*a % 1000000007;
  }
  return ret;
}

int main() {
  long n;
  cin >> n;
  
  if (n == 1) {
    cout << 0;
    return 0;
  }
  
  cout << ((pow_mod(10, n) + pow_mod(8, n) - 2*pow_mod(9, n)) % 1000000007 + 1000000007) % 1000000007;
  
  return 0;
}

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

int main() {
  // input hight and width
  int H, W;
  cin >> H >> W;
 
  // input table
  vector<vector<char>> table(H, vector<char>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> table.at(i).at(j);
    }
  }
  
  // check white('.') line
  vector<int> cnt_w(H,0),cnt_h(W,0);
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(table.at(i).at(j)=='.')
        cnt_w.at(i)++;
    } 
  }
 
  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      if(table.at(j).at(i)=='.')
        cnt_h.at(i)++;
    } 
  }


  // display result table
   for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(cnt_w.at(i)!=W && cnt_h.at(j)!=H)// not white line
        cout << table.at(i).at(j);
      if(cnt_w.at(i)!=W && j==W-1)
        cout << endl;
    }
  } 
  
}


Measured memory_bytes: 256
//Kriti Verma
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         1000000007
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     lcm(a,b)    (a*b)/__gcd(a,b)
#define     MAX         100002 
#define     ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    ll n,check=0;;
    cin >> n;
    ll a[n][2];
    for(ll i=0;i<n;i++)
        for(ll j=0;j<2;j++)
            cin >> a[i][j];
    for(ll i=0;i<n;i++){
            if(a[i][0]==a[i][1])check++;
            else check=0;
            if(check==3){
                cout <<"Yes\n";
                return 0;
            }    
    }  
    cout <<"No\n";  
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    char b;
    cin >> b;

    char ans;
    switch(b){
        case 'A':
            ans = 'T';
            break;
        case 'C':
            ans = 'G';
            break;
        case 'G':
            ans = 'C';
            break;
        case 'T':
            ans = 'A';
            break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3032
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    int i,j,k,p=1,q=1;
    long n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    int strr[200005];
    cin>>i>>j;
    if(i>=10||j>=10)cout<<-1<<endl;
    else cout<<i*j<<endl;

    return 0;
}

Measured memory_bytes: 1792
s=input()
d='BDEFGHIJKLMNOPQRSTUVWXYZ'
if s[0]=='A' and s.count('A')==1 and s.count('C')==1 and s[2:-1].count('C')==1:
    for t in d:
        if t in s:
            break
    else:
        print('AC')
        exit()
print('WA')

Measured memory_bytes: 38416
#include <bits/stdc++.h>
using namespace std;
int main(){
    char C;
    cin >> C;
    vector<char> vec(26);
    vec = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
           'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    for(int i=0; i<26; i++){
        if(vec[i] == C){
            cout << vec[i+1];
        }
    }
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
  string w;
  cin>>w;
  int len=w.length();
  map<char,int>mp;
  for(int i=0;i<len;i++){
	  mp[w[i]]++;
  }
  bool check=true;
  for(auto it:mp){
	  if(it.S % 2!=0)check=false;
  }
  if(check)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
arr_n = [(i+1) * 2 for i in range(N)]
arr_m = [i+1 for i in range(0, M*2, 2)]

count = 0
for i in range(len(arr_n)):
    count += len(arr_n[i + 1:])
for j in range(len(arr_m)):
    count += len(arr_m[j + 1:])

print(count)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    long long a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    long long sum=0;
    if ((a+b) <=(c*2))
    {
        sum=a*x+b*y;
    }
    else if ((a+b)>(c*2))
    {
        long long d=(x>=y)?y:x;
        sum=c*2*d;
        if (d==y)
        {
            x=x-d;
            if (a<=c*2)
                sum=sum+a*x;
            else
                sum=sum+x*c*2;
        }
        else
        {
            y=y-d;
            if (b<=c*2)
                sum=sum+b*y;
            else
                sum=sum+y*c*2;
        }
    }
    cout<<sum<<endl;
    return 0;
}



/*
  int N,X,cnt=0,sum=0;
  int a[105],b[105];
  cin>>N>>X;
  for (int i = 0; i < N; i++)
      cin>>a[i];
  int t;
  for (int j = 0,r=0; j<N; j++)
  {
      if (a[j]!=0)
      {
          b[r++]=a[j];
          for (int i = j+1; i<N ; i++)
          {
              if (a[i]==a[j])
                  a[i]=0;
          }
      }
      t=r;
  }
  for (int i=0;i<t;i++)
      cout<<b[i]<<endl;
  int mins=b[0];
  for (int r=0; r<t; r++)
      if (b[r]<mins)
          mins=b[r];
  for (int r=0; r<t; r++)
  {
      sum+=b[r];
      cnt++;
  }
  cnt=cnt+(X-sum)/mins;
  cout<<cnt<<endl;

  */


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;
int inf=1<<29;
long long llinf=1ll<<60;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct
int f[10001][2000];

int main(void){
    int N,M,r,t,n,m,s,q,ts,te,i,j,ans;
    while(1){
        N=in();
        M=in();
        if(!N)break;
        MEMSET(f);
        r=in();
        rep(i,r){
            t=in();
            n=in();
            m=in();
            s=in();
            if(s)
                f[m][t]++;
            else
                f[m][t]--;
        }
        for(i=1;i<=M;i++){
            rep(j,2000){
                if(j)f[i][j]+=f[i][j-1];
            }
        }
        q=in();
        rep(j,q){
            ts=in();
            te=in();
            m=in();
            ans=0;
            for(i=ts;i<te;i++){
                ans+=!!f[m][i];
            }
            print(ans);
        }
    }
    return 0;
}


Measured memory_bytes: 79816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e18;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
 
ll N, tot,p;
ll A[(1<<18)];
pi memo[(1<<18)];

ll ck(ll a){
  if (a == -1)return 0;
  return A[a];
}

pi merge(pi a, pi b){
  if (a.f == b.f){
    if (a.s == b.s)return a;
    if (a.s > b.s)return a;
    else return mp(a.f, b.s);
  }
  if (ck(a.f)>ck(b.f)){
    if (ck(a.s) > ck(b.f))return mp(a.f, a.s);
    return mp(a.f, b.f);
  }else {
    if (ck(a.f) > ck(b.s))return mp(b.f,a.f);
    return mp(b.f,b.s);
  }
}
 
pi dp(ll x){
  if (memo[x].f != -1)return memo[x];
  pi res = mp(x, -1);
  for (int i=0;i<=18;++i){
    if ((1<<i) & x){
      pi t = dp(x - (1 << i));
      res = merge(res, t);
    }
  }
  return memo[x] = res;
}
 
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>N;
  N = (1<<N);
  for (int i=0;i<N;++i)cin>>A[i];
  memo[0] = mp(0, -1);
  dp(N-1);
  ll p = 0;
  //for (int i=1;i<N;++i)cout<<memo[i].f<<' '<<memo[i].s<<'\n';
  for (int i=1;i<N;++i){
    p = max(p, A[memo[i].f]+A[memo[i].s]);
    cout<<p<<'\n';
  }
}

Measured memory_bytes: 9216