akhauriyash/Code-Regression huggingface dataset:
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    string s;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;

    cin >> n;

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

        if (s == "AC") {
            a++;
        }
        else if (s == "WA") {
            b++;
        }
        else if (s == "TLE") {
            c++;
        }
        else {
            d++;
        }
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    

    return 0;



}



Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef pair<int, int> PII;
const int MAXN = 200005;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n;
int L[MAXN], R[MAXN], a[MAXN], cnt;
int f[MAXN], sum[MAXN], ans;

PII s[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d %d", &s[i].first, &s[i].second), a[i] = s[i].second;
    sort(a + 1, a + n + 1), cnt = unique(a + 1, a + n + 1) - a - 1;
    for (int i = 1; i <= n; i++)
        s[i].second = lower_bound(a + 1, a + cnt + 1, s[i].second) - a;

    sort(s + 1, s + n + 1), L[n + 1] = INF;
    for (int i = 1; i <= n; i++)
        R[i] = max(R[i - 1], s[i].second);
    for (int i = n; i; i--)
        L[i] = min(L[i + 1], s[i].second);
    for (int i = 1; i <= n; i++)
        s[i] = make_pair(L[i], R[i]);

    sort(s + 1, s + n + 1), f[0] = sum[0] = 1;
    for (int i = 1, j = 0; i <= n; i++) {
        while (s[j].second < s[i].first - 1)
            j++;
        f[i] = (sum[i - 1] - (!j ? 0 : sum[j - 1]) + MOD) % MOD;
        sum[i] = (sum[i - 1] + f[i]) % MOD;
    }
    for (int i = 1; i <= n; i++)
        if (s[i].second == cnt)
            ans = (ans + f[i]) % MOD;
    printf("%d", ans);
    return 0;
}


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

X = 1000000007

flags = [True for _ in range(N+1)]
for i in range(M):
    a = int(input())
    flags[a] = False

counts = [0 for _ in range(N+1)]
counts[0] = 1

for i in range(1, N+1):
    if flags[i] == False:
        continue

    if flags[i-1] == False:
        counts[i] = counts[i-2]
    elif flags[i-2] == False:
        counts[i] = counts[i-1]
    else:
        counts[i] = (counts[i-2] + counts[i-1]) % X

print(counts[N])

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

int main(){
  string s;
  cin>>s;
  int mod=1000000007;
  vector<vector<int>>dp(s.size()+1,vector<int>(13));//i文字までにあまりjの数がいくつあるか
  
  if(s.at(0)=='?'){
    rep(i,10){
      dp[1][i]=1;
    }
  }
  else{
    dp[1][s.at(0)-'0']=1;
  }
  
  rep2(i,2,s.size()+1){
    rep(j,13){
      if(s.at(i-1)=='?'){
        rep(k,10){
          dp[i][(j*10+k)%13]+=dp[i-1][j];
          dp[i][(j*10+k)%13]%=mod;
        }
      }
      else{
        dp[i][(j*10+s.at(i-1)-'0')%13]=dp[i-1][j];
      }
    }
  }
  
  cout<<dp[s.size()][5]<<endl;
}

Measured memory_bytes: 8960
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

int N;

int main(){
    cin>>N;
    out(800*N-200*(N/15));
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
void chmin(T &x, T y) {
    x = min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
    x = max(x, y);
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------



int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    //gen();
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cc(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cc[i] = a[i];
    }
    sort(cc.begin(), cc.end());
    cc.resize(unique(cc.begin(), cc.end()) - cc.begin());
    for (int &x : a) {
        x = lower_bound(cc.begin(), cc.end(), x) - cc.begin();
    }
    ll ans = 0;
    vector<int> u, v;
    for (int i = 0; i < n; i++) {
        if ((a[i] & 1) != (i & 1)) {
            if (i & 1) {
                u.pb(i);
            } else {
                v.pb(i);
            }
        }
    }

    assert(u.size() == v.size());
    cout << u.size() << endl;

    return 0;
}

Measured memory_bytes: 1660
#line 1 "test/algebra/factors.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D&lang=jp"

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

#line 1 "test/algebra/../../library/algebra/factors.cpp"
// list up all factors
template <typename T>
set<T> factors(T a) {
    set<T> facs;
    for (T i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            facs.insert(i);
            facs.insert(a / i);
        }
    }
    return facs;
}
#line 8 "test/algebra/factors.test.cpp"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    auto facs = factors(c);
    int ret   = 0;
    for (auto &f : facs) {
        if (a <= f && f <= b)
            ret++;
    }
    cout << ret << "\n";
    return 0;
}



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

int digsum(int n) {
  int sum = 0;
  while(n) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int ans = 100000;
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    ans = min(ans, digsum(i) + digsum(n - i));
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char c;
	cin >> c ;
	if (c == 'a'||c == 'i'||c == 'u' ||c == 'e'|| c == 'o')
	{
		cout << "vowel" << endl;
	}else{
		cout << "consonant"  << endl;
	}
}

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

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 X, Y;
  cin >> X >> Y;
  rep(i,0,X + 1) {
    i64 j = X - i;
    if(i * 2 + j * 4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>
#include <utility>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define pb push_back
#define NIL -1
#define MAX 100001

using namespace std;

struct Node{
  int id;
  int parent;
  vector<int> child;
  int depth;
  
  void addChild(int c){
    child.pb(c);
  }
    
 void print(){
    cout << "node " << id << ": ";
    cout << "parent = " << parent << ", ";
    cout << "depth = " << depth << ", ";
    cout << (parent == -1?"root":child.size()==0?"leaf":"internal node") << ", ";
    cout << "[";
    if(child.size() != 0){
      rep(i, child.size()-1){
    cout << child[i] << ", ";
      }
      cout << child[child.size()-1];
    }
      cout << "]" << endl;
 }
};

Node node[MAX];

void init(int n){
  rep(i, n){
    node[i].depth = NIL;
    node[i].parent = NIL;
    node[i].child.clear();    
  }
}

signed main(){
  int n;
  int id, k, c, root;
  cin >> n;
  init(n);
  
  root = NIL;

  rep(i, n){
    cin >> id >> k;
    node[id].id = id;
    rep(j, k){
      cin >> c;
      node[id].addChild(c);
      node[c].parent = id;
      node[c].depth = node[id].depth + 1;
    }
  }

  rep(i, n){
    if(node[i].parent == NIL){
      root = i;
      break;
    }
  }
  
  queue<pair<Node, int> > q;
  q.push(make_pair(node[root], -1));
  while(!(q.empty())){
    pair<Node, int> p = q.front(); q.pop();
    node[p.first.id].depth = p.second + 1;
    rep(i, p.first.child.size()){
      q.push(make_pair(node[p.first.child[i]], p.second + 1));
    }
  }
  
  rep(i, n){
    node[i].print();
  }
}

Measured memory_bytes: 12436
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  const string cor = "CODEFESTIVAL2016";
  string S;
  cin >> S;
  int ans = 0;
  rep(i, S.size()) {
    if (S[i] != cor[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(int argc,char** argv)
{

	int n;
	cin >> n;

	while(1){
		if(n/100==(n/10)%10 && n/100==(n%100)%10){
			cout << n <<endl;
			break;
		}
		n++;
	}

	return 0;

}

Measured memory_bytes: 256
main = interact $ unlines . map (unwords . map show . weight . (read::String->Int)) . lines
weight w = count w [512,256,128,64,32,16,8,4,2,1] []
 where
  count 0 _ acc = acc
  count _ [] _ = []
  count w' (x:xs) acc = count (w'-x) xs (x:acc) ++ count w' xs acc

Measured memory_bytes: 4076
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int dsum(int n){
  if(n == 0)
    return 0;
  else
    return dsum(n/10)+n%10;
}

int main()
{
  int N;
  cin >> N;
  cout << 111*((N+110)/111) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}



Measured memory_bytes: 256
from itertools import product

class BellmanFord:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self, s):
        INF = float('inf')
        self.dist = [INF] * self.N # the distance of each vertex from s
        self.prev = [-1] * self.N # the previous vertex of each vertex on a shortest path from s
        self.dist[s] = 0
        for _ in range(self.N):
            updated = False
            for v in range(self.N):
                d = self.dist[v]
                if d == INF: continue
                for u, c in self.E[v]:
                    temp = d + c
                    if self.dist[u] > temp:
                        updated = True
                        self.dist[u] = temp
                        self.prev[u] = v
            if not updated: break # the minimum costs are already stored in dist
        else: return None # the above loop is not broken if and only if there exists a negative cycle
        return self.dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]

H, W = map(int, input().split())
bf = BellmanFord(H * W)

def vtx(i, j): return i*W + j
def coord(n): return divmod(n, W)

grid = [input() for _ in range(H)] # |string| = W
E = [[] for _ in range(H * W)]
ans = 0 if grid[0][0] == '.' else 1
for i, j in product(range(H), range(W)):
    v = vtx(i, j)
    check = [vtx(i+dx, j+dy) for dx, dy in [(1, 0), (0, 1)] if i+dx <= H-1 and j+dy <= W-1]
    for u in check:
        x, y = coord(u)
        if grid[i][j] == '.' and grid[x][y] == '#':
            bf.add_edge(v, u, 1)
        else:
            bf.add_edge(v, u, 0)
dist = bf.distance(0)
ans += dist[vtx(H-1, W-1)]
print(ans)

Measured memory_bytes: 7284
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    string s; cin >> s;
    if(s == "RRR") pt(3);
    else if(s == "RRS" || s == "SRR") pt(2);
    else if( s == "SSS") pt(0);
    else pt(1);
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main()
{
    int a;
    cin >> a;
    if (a == 1){
        cout << "Hello World" << endl;
    }else{
        int b;
        int c;
        cin >> b >> c;
        cout << b + c << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define MOD     1000000007
#define int     long long int
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI      3.1415926535897932384626
#define pb      push_back
#define clr(x)  memset(x, 0, sizeof(x))
#define MP      make_pair
const int N=1e5+1;
using namespace std;
int gcd(int a,int b){if(a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (max(a,b)/gcd(a,b))*min(a,b);}
int powermodm(int x,int n,int M){int result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
int gcdExtended(int a, int b, int *x, int *y){if (a == 0){*x = 0, *y = 1;return b;}int x1, y1;int gcd = gcdExtended(b % a, a, &x1, &y1);*x = y1 - (b / a) * x1;*y = x1;return gcd;}
int modInverse(int a, int m){int x, y;int g = gcdExtended(a, m, &x, &y);if (g != 1)return -1;else{int res = (x % m + m) % m;return res;}}
bool isPrime(int a){if(a==1) return false;if(a==2) return true;if(a%2==0) return false;int root=sqrt(a);for(int i=3;i<=(int)root;i+=2){if(a%i==0)return false;}return true;}

main()
{
    fastIO;
    int n,m;
    cin >> n >> m;
    char mat[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin >> mat[i][j];
        }
    }
    int dp[n][m];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<n;i++)
    {
        if(mat[i][0]=='#')
        {
            dp[i][0]=0;
        }
        else
        {
            dp[i][0]=dp[i-1][0];
        }
    }
    for(int i=1;i<m;i++)
    {
        if(mat[0][i]=='#')
        {
            dp[0][i]=0;
        }
        else
        {
            dp[0][i]=dp[0][i-1];
        }
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(mat[i][j]=='.')
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
            }
        }
    }
    cout << dp[n-1][m-1];
}


Measured memory_bytes: 12352
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int n;
		n = scan.nextInt();

		System.out.println(n * n * n);
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  priority_queue<pair<ll, ll>> apple;
  rep(i, A){
    cin >> p.at(i);
    apple.push(make_pair(p.at(i), 0));
  }
  rep(i, B){
    cin >> q.at(i);
    apple.push(make_pair(q.at(i), 1));
  }
  rep(i, C){
    cin >> r.at(i);
  }
  sort(all(p));
  sort(all(q));
  sort(all(r));
  reverse(all(p));
  reverse(all(q));
  reverse(all(r));
  vector<ll> sred(A+1, 0);
  vector<ll> sgrn(B+1, 0);
  vector<ll> snon(C+1, 0);
  rep(i, A){
    sred.at(i+1) = sred.at(i) + p.at(i);
  }
  rep(i, B){
    sgrn.at(i+1) = sgrn.at(i) + q.at(i);
  }
  rep(i, C){
    snon.at(i+1) = snon.at(i) + r.at(i);
  }
  ll reat = 0;
  ll geat = 0;
  ll taste = 0;
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> ate;
  rep(i, X){
    ate.push(make_pair(p.at(i), 0));
  }
  rep(i, Y){
    ate.push(make_pair(q.at(i), 1));
  }
  taste = sred.at(X) + sgrn.at(Y);
  rep(i, C){
    ll bad = ate.top().first;
    if(r.at(i) > bad){
      taste += r.at(i) - bad;
      ate.pop();
    }
    else{
      break;
    }
  }
  cout << taste << endl;
}

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

int main(){
  vector<P> mat(9);
  rep(i,9) cin >> mat[i].first;
  rep(i,9) mat[i].second = 0;
  int n;
  cin >> n;
  int num;
  for (int i=0; i < n; ++i){
    cin >> num;
    for (int j=0;j<9;++j) if (num == mat[j].first) mat[j].second = 1;
  }
  if (mat[0].second+mat[1].second+mat[2].second == 3) cout << "Yes" << endl;
  else if (mat[3].second+mat[4].second+mat[5].second == 3) cout << "Yes" << endl;
  else if (mat[6].second+mat[7].second+mat[8].second == 3) cout << "Yes" << endl;
  else if (mat[0].second+mat[3].second+mat[6].second == 3) cout << "Yes" << endl;
  else if (mat[1].second+mat[4].second+mat[7].second == 3) cout << "Yes" << endl;
  else if (mat[2].second+mat[5].second+mat[8].second == 3) cout << "Yes" << endl;
  else if (mat[0].second+mat[4].second+mat[8].second == 3) cout << "Yes" << endl;
  else if (mat[2].second+mat[4].second+mat[6].second == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r,d,x;
  	cin>>r>>d>>x;
  	REP(i,10){
      x=r*x-d;
    	cout<<x<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MX = 1000005;
const int M = 998244353;
int n, b;
ll e[MX], ans, a[MX], c, d, f, g, h;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &b);
		a[b]++;
	}
	for(int i=1; i<MX; i++, c=d=0){
		for(h=1,f=M-2,g=i; f; f/=2,g=g*g%M) if(f%2) (h *= g) %= M;
		for(int j=i; j<MX; j+=i){
			(e[j] += j-i ? M-e[i] : h) %= M;
			(c += (a[j]*(a[j]-1)/2*j+a[j]*d)%M*j) %= M;
			(d += a[j]*j) %= M;
		}
		(ans += c*e[i]) %= M;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
#define FOR(i, m, n) for(int i = m;i < n;i++)
int MAX_N = 100000;
#define REP(i, n) for(int i = 0;i < n;i++)
int MAX_W = 100000;
int chnage(int X){
  if( X == 9){
    return 1;
  }else{
    return 9;
  }
}
int main(){
  int A,B,C;cin >> A>> B>>C;
  cout << min(B / A , C)<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    string s,t;
    cin >> s >> t;

    int ans =0;
    rep(i,3){
        if(s[i] == t[i])++ans;
    }
    cout << ans << endl;




}

Measured memory_bytes: 3616
main(){for(;;){int d[5],s=0,i=0;for(;i<5;i++){int h;scanf("%d",&h);if(!h)exit(0);s|=d[i]=1<<h;}for(i=0;i<5;i++){int k=d[i];printf("%d\n",s==14|s==k?3:(s^k)==k*2|(s^k)==k/4?1:2);}}}

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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<string> disp(h);
  for ( int i=0; i < h; i++){
    cin >> disp[i];
  }
  for ( int i=0; i<(w+2); i++){
    cout << '#';
  }cout << endl;
  for ( int i=0; i < h; i++){
    cout << '#'<< disp[i] << '#'<<endl;
  }
  for ( int i=0; i<(w+2); i++){
    cout << '#';
  }
  
}


Measured memory_bytes: 256
def solve():
    n, k = map(int, input().split())
    ps = 0.0
    for i in range(1, n+1):
        sum = i
        p = 1.0 / n
        while(sum < k):
            p /= 2.0
            sum *= 2
        ps += p
    print(ps)

if __name__ == '__main__':
    solve()

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

using namespace std;

#define int long long
#define double long double
#define mod 1000000007ll
#define INF 1000000000000000000ll

#define MAX_N 200010

int tab[MAX_N];
vector<int> v[MAX_N];

int skok[MAX_N][50];
int dist[MAX_N][50];

bool jest[MAX_N];

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

    int n = 200000, k = 1000000000000ll;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        tab[i] = i;
        cin >> tab[i];
        v[tab[i]].push_back(i);
    }

    for (int i = 0; i < n; i++) {
        int a = tab[i];
        auto it = upper_bound(v[a].begin(), v[a].end(), i);
        if (it == v[a].end()) {
            dist[i][0] = n - i + *v[a].begin() + 1;
        } else {
            dist[i][0] = *it - i + 1;
        }
        //cout << dist[i][0] << " ";
    }
    //cout << endl;

    for (int j = 1; j < 50; j++) {
        for (int i = 0; i < n; i++) {
            int a = dist[i][j - 1], b = dist[(i + dist[i][j - 1]) % n][j - 1];
            dist[i][j] = a;
            if (a + b > a && a + b > b) {
                dist[i][j] = a + b;
            }
        }
    }

    int suma = 0;
    bool czy = true;
    while (czy) {
        czy = false;
        int gdzie = suma % n;
        for (int j = 49; j >= 0; j--) {
            if (suma + dist[gdzie][j] < n * k && suma + dist[gdzie][j] > suma) {
                suma += dist[gdzie][j];
                czy = true;
                break;
            }
        }
    }

    int pocz = suma % n;
    //cout << pocz;

    vector<int> res;
    for (int i = pocz; i < n; i++) {
        if (!jest[tab[i]]) {
            res.push_back(tab[i]);
            jest[tab[i]] = true;
        } else {
            while (jest[tab[i]]) {
                jest[res.back()] = false;
                res.pop_back();
            }
        }
    }
    for (int i : res) {
        cout << i << " ";
    }

    return 0;
}
/*

*/


Measured memory_bytes: 96372
n, k = gets().split().map(&:to_i)
dislike = gets().split().map(&:to_i)

d = Array.new(10){false}
0.upto(k - 1) do |i|
	d[dislike[i]] = true
end

ok = false
s = ""
n.upto(n*10) do |i|
	ok = true
	s = i.to_s
	0.upto(s.length - 1) do |j|
		if d[s[j].to_i]
			ok = false
			break
		end
	end
	break if ok
end

puts s

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	long long  n;
	cin >> n;
	
	long  t = 10;
	long  ans = 0;
	long  res = n/t;
	
	if (n%2 == 0)
	{
	
		while(res!=0)
		{
			res = n/t;
			ans = ans + res;
			t = t * 5;
			
		}
	}
	
	cout <<ans <<endl;
	
	return 0;
}



Measured memory_bytes: 256
h,w,k=map(int,input().split())
p,n=10**9+7,h+w
x=k+k*(k+1)//2+k*(k-1)*(k+1)//3*h*w*pow(n*(n-1),p-2,p)
for i in range(n,n-k,-1):x=x*i%p
print(x)


Measured memory_bytes: 40556
n=int(input())
q=[input().split()+[i] for i in range(n)]
for i in range(n):
  q[i][1]=int(q[i][1])
p=sorted(sorted(q,key=lambda x:x[1],reverse=True),key=lambda x:x[0])
for s,i,r in p:
  print(r+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int a;
    int  ar[110][110];
    for(int i=1; i<=3; i++)
    {
        for(int j=1; j<=3; j++)
        {
            cin>>a;
            ar[i][j]=a;
        }

    }
    vector<pair<int,int>>v;
    int b;
    cin>>b;
    for(int c=0; c<b; c++)
    {
        int x1;
        cin>>x1;
        for(int i=1; i<=3; i++)
        {
            for(int j=1; j<=3; j++)
            {
                if(x1==ar[i][j])
                {
                    v.push_back(make_pair(i,j));
                }
            }

        }

    }

    int row1=0,row2=0,row3=0,col1=0,col2=0,col3=0,dia1=0,dia2=0;
    for(int i=0; i<v.size(); i++)
    {
        if(v[i].first==1)
            row1++;
        if(v[i].first==2)
            row2++;
        if(v[i].first==3)
            row3++;
        if(v[i].second==1)
            col1++;
        if(v[i].second==2)
            col2++;
        if(v[i].second==3)
            col3++;
            if(v[i].first==v[i].second)
                dia1++;
            if(v[i].first==3&&v[i].second==1)
                dia2++;
            if(v[i].first==2&&v[i].second==2)
                dia2++;
                if(v[i].first==1&&v[i].second==3)
                dia2++;

    }

if(row1==3||row2==3||row3==3||col1==3||col2==3||col3==3||dia1==3||dia2==3)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

    return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  char s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (i != k - 1) {
      cout << s[i];
    }
    else {
      cout << tolower(s[i], locale::classic());
    }
  }

  return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
L=[[] for i in range(H)]
for i in range(H):
  L1=list(input())
  L[i]=L1
L=[["$"]+i+["$"] for i in L]
L=[["$" for i in range(W+2)]]+L+[["$" for i in range(W+2)]]
for i in range(1,H+1):
  for j in range(1,W+1):
    if L[i][j]==".":
      L[i][j]=str([L[i][j+1],L[i-1][j+1],L[i+1][j+1],L[i-1][j-1],L[i+1][j],L[i-1][j],L[i][j-1],L[i+1][j-1]].count("#"))
for i in range(1,H+1):
  print("".join(L[i][1:-1]))

Measured memory_bytes: 68584
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> as(n); cin >> as;
    vector<ll> accs(n + 1), accs2(n + 1);
    for(int i = n - 1; i >= 0; i--){
        accs[i] = accs[i + 1] + as[i];
    }
    for(int i = 0; i < n; i++){
        accs2[i] = (i >= 2 ? accs2[i - 2] : 0) + as[i];
    }
    printde(as, accs, accs2);
    for(int i = 0; i < q; i++){
        int x; cin >> x;
        int tin = 1, tout = n - 1;
        ll ans = 0;
        auto proc = [&](int& tin, int& tout){ 
            int num = (tin + tout) / 2;
            int diff = as[n - num - 1] - x;
            int diff2 = as[n - num] - x;
            auto idx = lower_bound(as.begin(), as.end(), x - diff) - as.begin();
            auto idx2 = lower_bound(as.begin(), as.end(), x - diff2) - as.begin();
            // ---- idx2 ---- idx ---
            int numa = max(0l, n - num - 1 - idx + 1);
            int numb = max(0l, n - num - 1 - idx2 + 1);
            printde(num, idx, idx2, numa, numb);
            if(num < numa){
                tin = num;
            }else if(num > numb + 1){
                tout = num;
            }else{
                int idx = n - num - num - 1;
                ll cand = accs[n - num] + (idx >= 0 ? accs2[idx] : 0);
                printde(num, cand, accs[n - num], (idx >= 0 ? accs2[idx] : 0), ans);
                ans = max(ans, cand);
                tin = max(1, num - 10);
                tout = min(n - 1, num + 10);
            }
        };
        while(tin + 20 < tout){
            proc(tin, tout);
        }
        for(int i = tin; i <= tout; i++){
            int tin = i, tout = i;
            proc(tin, tout);
        }
        // if(ans == 0){
        //     exit(1);
        // }
        cout << ans << '\n';
    }
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if(abs(a - c) <= d){
    cout << "Yes" << endl;
  }else if(abs(a - b) <= d && abs(b - c) <= d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    double a;
    int x = 1;
    cin >> a;
    for(int i=2; i <= sqrt(a); i++){
        int y = 1;
        while(y <= a){
            y *= i;
        }
        if(y != 1){
            y /= i;
        }
        if(x <= y){
            x = y;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public final static double MAX_T = 1000000;
	public final static double MIN_T = 0;
	public static int s = 0;
 
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
 
	static class TaskC {
 
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			out.println((n - 1) * (m - 1));	
		}
 
	}
 
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
		public long nextLong() {
			return Long.parseLong(next());
		}
 
		public double nextFloat() {
			return Double.parseDouble(next());
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
	}
}


Measured memory_bytes: 21460
import heapq as hq
n, q = map(int, input().split())
queues = [[] for i in range(n)]
while q:
    q -= 1
    s = [*map(int, input().split())]
    if s[0] == 0:
        hq.heappush(queues[s[1]], -s[2])
    elif s[0] == 1 and queues[s[1]]:
        print(-queues[s[1]][0])
    elif queues[s[1]]:
        hq.heappop(queues[s[1]])


Measured memory_bytes: 13172
from collections import deque
from sys import stdin

n = int(input())

q = deque()

for _ in range(n):
	cmd = stdin.readline().strip().split()
	if cmd[0] == "insert":
		q.appendleft(cmd[1])
	elif cmd[0] == "deleteFirst":
		q.popleft()
	elif cmd[0] == "deleteLast":
		q.pop()
	elif cmd[0] == "delete":
		try:
			q.remove(cmd[1])
		except:
			pass

print(*q)



Measured memory_bytes: 69736
str = input()
ma = {}
cnt = 0
for i in str :
    if i not in ma.keys() :
        ma[i] = 1
    else :
        ma[i] += 1
for i in ma :
    if ma[i] == 2 :
        cnt += 1
if cnt == 2 :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
int main()
{
	char s[20];
	cin >> s;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == '7')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

enum occupant
{
build, floor, room, number
}

class Program
 {



    static void Main(string[] args)
    {
        String nyuryoku;
        string[] data = new string[2];
        string[] data1;
        int row, column, temp;
        int[,] matrix;

        nyuryoku = Console.ReadLine();
        data = nyuryoku.Split(' ');
        row = int.Parse(data[0]);
        column = int.Parse(data[1]);

        matrix = new int[row + 1, column + 1];
        data1 = new string[column];
        for (int i = 0; i < row; i++)
        {
            nyuryoku = Console.ReadLine();
            data1 = nyuryoku.Split(' ');
            temp = 0;
            for (int j = 0; j < column; j++)
            {

                matrix[i, j] = int.Parse(data1[j]);
                temp += matrix[i, j];
                matrix[row, j] = matrix[row, j] + matrix[i, j];
            }
            matrix[i, column] = temp;
            matrix[row, column] = matrix[row, column] + matrix[i, column];
        }
        for (int i = 0; i <= row; i++)
        {
            for (int J = 0; J <= column; J++)
            {
                Console.Write("{0}", matrix[i, J]);
                if (J < column)
                    Console.Write(" ");
                else
                    Console.Write("\n");
            }
        }





    }

 }



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

using graph = vector<vector<int>>;


void dfs(int v, const graph& G, vector<int>& res, vector<int>& used) {
	used[v] = 1;
	for (auto to : G[v]) if (used[to] == 0) {
		dfs(to, G, res, used);
	}
	res.push_back(v);
}

vector<int> topo_sort(const graph& G) {
	int V = G.size();
	vector<int> ide(V);
	for (int i = 0; i < V; i++) {
		for (auto to : G[i]) {
			ide[to]++;
		}
	}
	vector<int> res;
	vector<int> used(V);
	for (int i = V - 1; i >= 0; i--) {
		if (ide[i] == 0) {
			dfs(i, G, res, used);
		}
	}
	reverse(res.begin(), res.end());
	return res;
}

int main()
{
	int V, E;
	cin >> V >> E;
	graph G(V);
	for (int i = 0, s, t; i < E; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}
	auto res = topo_sort(G);
	for (int i = 0; i < V; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m,dt;
	while(1){
		cin>>n>>m;
		if(!(n&&m))break;
		priority_queue<int> que;
		rep(i,n){cin>>dt;que.push(dt);}
		int cnt=0,sum=0;
		while(!que.empty()){
			cnt++;
			if(cnt!=m)sum+=que.top();
			else cnt=0;
			que.pop();
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

using namespace std;

const int mod = 998244353;
const int INF = 1e6;
vector<vector<int>> graph(1e5 + 1, vector<int>(0));
vector<int> used(1e5 + 1);

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long potolok(long long a, long long b){   // округление вверх для целых
    return (a + b - 1) / b;
}


long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

bool cmpr(int x, int y){            // сортировка по абсолютной величине
    if(abs(x) < abs(y)) return true;
    else{
        return false;
    }
}

bool comp(pair<int, int> x, pair<int, int> y){  // сортировка по первой компоненте
    if(x.first < y.first)return true;
    else if(x.first == y.first){
        if(x.second < y.second)return true;
        else return false;
    }
    else{
        return false;
    }
}

int cnt(string &s, string &p, int m, int n){
    if((m == 0 && n == 0) || n == 0){
        return 1;
    }
    if(m == 0){
        return 0;
    }
    if(s[m - 1] == p[n - 1]){
        return cnt(s, p, m - 1, n - 1) + cnt(s, p, m - 1, n);
    }
    else{
        return cnt(s, p, m - 1, n);
    }
}

int div(int n){
    int ans = 0;
    vector<int> used(n + 1, 0);
    for(int i = 1;i <= sqrt(n);i++){
        if(n % i == 0 && (!used[i] && !used[n / i])){
            if(i * i == n){
                ans++;
            }
            else{
                ans += 2;
            }
        }
    }
    return ans;
}

void dfs(int node){
    if(used[node]){
        return;
    }
    used[node] = 1;
    for(auto i : graph[node]){
        dfs(i);
    }
}

void solve(){
    int n, m;
    cin >> n >> m;

    for(int i = 0;i < m;i++){
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(!used[i]){
            dfs(i);
            ans++;
        }
    }
    cout << ans - 1 << endl;
}

int main(){
    int t = 1;
    while(t--){
        solve();
    }
 }


Measured memory_bytes: 9560
#include <iostream>
using namespace std;
int main() {
 int  a, b, c;
 int d = 0;
 int f = 0;
 int bb[20];
 cin >>a>>b>>c;
 for (int j = 0; j <b; j++) {
  cin >> bb[j];
 }
   int am[20][20];
   for (int i = 0; i < a; i++) {
    for (int j = 0; j < b; j++) {
     cin >> am[i][j];
     d += am[i][j] * bb[j];
    }
           if(d+c> 0) {
      f += 1;
     }
     d = 0;
    
   }
  cout << f << endl;
     return 0;
   }

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)
#define PI 3.14159265358979323846264338327950L

// -----

int main()
// {
//     ll n;
//     cin >> n;
//     ll ans = 1;
//     rep(i, n)
//     {
//         ll temp;
//         cin >> temp;
//         ans *= temp;
//     }
//     if(ans > 1000000000000000000L)
//     {
//         ans = -1;
//     }
//     pl(ans);
// }
{
    ll a;
    long double b;
    cin >> a >> b;
    pl((ll)(a * b));
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

ll f(pair<string,ll>&x ,pair<string,ll>&y) 
{
	if(x.first == y.first) 
	{
		return x.second>y.second;
	}
	else 
	{
		return x.first<y.first;
	}
}
 
void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n+1),pre(n+2),suf(n+2);
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		pre[i]=gcd(pre[i-1],a[i]);
	}
	ll ans=1;
	for(ll i=n;i>=1;i--)
	{
		suf[i]=gcd(suf[i+1],a[i]);
	}
	for(ll i=0;i<=n+1;i++)
	{
		ans=max(ans,gcd(pre[i-1],suf[i+1]));
	}
	cout<<ans;
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 5576
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    a = LI()
    print("YES" if len(a) == len(set(a)) else "NO")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 93624