akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define open freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(time(0));

#define int ll

void solve(){
    int n, k, c;
    char ch;
    cin >> n >> k >> c;
    int right[k + 1], left[k + 1], a[n + 1];
    right[0] = n + 1; left[0] = 0;
    for (int i = 1; i <= n; i++){
        cin >> ch;
        if (ch == 'o')
            a[i] = 0;
        else
            a[i] = 1;
    }
    int now = 1;
    for (int i = 1; i <= n; i++){
        if (a[i] == 0 && (now == 1 || i - left[now - 1] - 1 >= c)){
            left[now] = i;
            if (now == k)
                break;
            now++;
        }
    }
    now = 1;
    for (int i = n; i >= 1; i--){
        if (a[i] == 0 && (now == 1 || right[now - 1] - i - 1 >= c)){
            right[now] = i;
            if (now == k)
                break;
            now++;
        }
    }
    for (int i = 1; i <= n; i++) {
        int l = 0;
        int r = k + 2;
        while (r > l + 1) {
            int mid = (r + l) / 2;
            if (left[mid] < i)
                l = mid;
            else
                r = mid;
        }
        int l1 = l;
        l = 0;
        r = k + 2;
        while(r > l + 1){
            int mid = (r + l) / 2;
            if (right[mid] > i){
                l = mid;
            }else{
                r = mid;
            }
        }
        int r1 = l;
        if (l1 + r1 > k || (l1 + r1 == k && (l1 == 0 || r1 == 0 || right[r1] - left[l1] - 1  >= c))){
            continue;
        }else{
            cout << i << endl;
        }
    }
}

signed main(){
    ios;
    // open;
    ll t = 1;
    // cin >> t;
    cout.precision(16);
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6272
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w=mp()
n=int(input())
a=lmp()
l=[]
for i in range(n):
    for k in range(a[i]):
        l.append(i+1)


ans=[]
for i in range(h):
    if i%2==0:
        ans.append(l[w*i:w*(i+1)])
    else:
        ans.append(reversed(l[w*i:w*(i+1)]))
for i in range(h):
    print(*ans[i])

Measured memory_bytes: 4296
N,K = [int(i) for i in input().split()]
result = 0
value = 1000000007

def nums_every_k(n,k):
    first_num = (k*(k-1))/2
    last_num = k*(2*n-k+1)/2
    numbers = last_num - first_num + 1
    return numbers
    
for k in range(K,N+2):
    result += nums_every_k(N,k)

result = result%value
print(int(result))

Measured memory_bytes: 9180
n=int(input())
d={}
for x in range(2,n+1):
  while x%2<1:
    x//=2
    d[2]=d.get(2,0)+1
  for i in range(3,int(x**0.5)+1,2):
    while x%i<1:
      x//=i
      d[i]=d.get(i,0)+1
    if x<2: break
  if x>1: d[x]=d.get(x,0)+1
a=1
for v in d.values(): a=a*(v+1)%(10**9+7)
print(a)

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

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

using namespace std;

int main() {
    int a,b;
    cin >>a >>b;
    cout << max(max(a+b, a-b),  a*b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   // #ifndef ONLINE_JUDGE
      // freopen("input.txt", "r", stdin);
      // freopen("output.txt", "w", stdout);
   // #endif
   int a,b;
   cin >> a >> b;
   string s1 = "",s2 = "";
   f(i,0,b){
      s1 += (a+'0');
   }
   f(i,0,a){
      s2 += (b+'0');
   }
   if(s1 < s2){
      cout << s1;
   }else{
      cout << s2;
   }
   return 0;
} 

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

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

  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int tax(int s,int t){
	for(int i = 10;i <= 1009;i++){
                if(int(i*0.08) == s && int(i*0.1) == t){
			return i;
		}
	}
	return -1;
}

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

	cout << tax(a,b) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 1200000;
map < int, int > a;
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        x = x * x % mod;
        y /= 2;
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    vector < int > div;
    for (int i = 1; i * i <= n; i++){
        if (n % i == 0){
            div.pb(i);
            if (i * i != n) div.pb(n / i);
        }
    }
    sort(div.begin(), div.end());
    int ans = 0;
    for (auto i: div){
        int len = (i + 1) / 2;
        int x = binpow(k, len);
        x = (x + a[i]) % mod;
        int z;
        if (i % 2) z = i; else z = len;
        ans = (ans + x * z) % mod;
        for (auto j: div){
            if (j % i == 0){
                a[j] = (a[j] - x + mod) % mod;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 384
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a =	sc.nextInt();
	char op = sc.next().charAt(0);
	int b =	sc.nextInt();
	if(op=='+') System.out.println(a+b);
	else System.out.println(a-b);
    }
}

Measured memory_bytes: 23636
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        b: chars
    }

    let ans = match b[0] {
        'A' => 'T',
        'T' => 'A',
        'G' => 'C',
        'C' => 'G',
        _ => unreachable!(),
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 998244353
#define MN 4000
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int fac[MN+5],pw[MN+5],inv[MN+5];
int n,k,res,num;
inline int qpow(int x,int k){
	int res=1;
	while (k){
		if (k&1) res=(1ll*res*x)%mod;
		x=(1ll*x*x)%mod;k>>=1;
	}return res;
}
inline int C(int x,int y){
	if (x<y||y<0) return 0;
	return (1ll*fac[x]*inv[y]%mod*inv[x-y]%mod);
}
inline int calc(int x,int p,int n){
	int res=0;
	for (int i=0;i<=x;++i)
	res=(1ll*res+(1ll*pw[i]*C(x,i)%mod*C(n+p-1,p+i-1)%mod))%mod;
	return res;
}
int main()
{
	fac[0]=pw[0]=1;
	for (int i=1;i<=MN;++i)
	fac[i]=(1ll*fac[i-1]*i)%mod,pw[i]=(pw[i-1]*2)%mod;
	inv[MN]=qpow(fac[MN],mod-2);
	for (int i=MN-1;i>=0;--i)
	inv[i]=(1ll*inv[i+1]*(i+1))%mod;
	k=in();n=in();
	for (int i=2;i<=(k<<1);++i){
		num=min(i-1,k)-max(i-k-1,0);
		if (i&1) printf("%d\n",calc((num>>1),k-num,n));
		else printf("%d\n",(calc(((num-1)>>1),k-num,n)+calc(((num-1)>>1),k-num,n-1))%mod);
	}return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, total = 0;
    unordered_multiset<ll> ms;
    unordered_map<ll, bool> um;
    cin>>n;
    while(n--) {
        ll tmp;
        cin>>tmp;
        ms.insert(tmp);
    }
    for(auto i=ms.begin(); i != ms.end(); i++) {
        if(um[*i])
            continue;
        ll count = ms.count(*i);
        if(*i > count)
            total += count;
        else if(count > *i)
            total += (count - *i);
        um[*i] = true;
    }
    cout<<total<<'\n';
    return 0;
}

Measured memory_bytes: 8228
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] ships = new int[m][2];
		boolean[][] isExist = new boolean[n][2];
		
		for(int i=0; i<ships.length; i++) {
			ships[i][0] = sc.nextInt();
			ships[i][1] = sc.nextInt();
			
			if(ships[i][0]==1) {
				isExist[ships[i][1]][0] = true;
			}
			
			if(ships[i][1]==n) {
				isExist[ships[i][0]][1] = true;
			}
		}
		sc.close();
		
		boolean ans = false;
		
		for(boolean[] exist: isExist) {
			if(exist[0] && exist[1]) {
				ans = true;
				break;
			}
		}
		
		if(ans) {
			System.out.println("POSSIBLE");
		}else {
			System.out.println("IMPOSSIBLE");
		}
		
		

	}

}

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

#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define pb push_back
#define ar array

typedef long long ll;
typedef long double ld;
//using ll = long long;

typedef vector<int> vi;

const ld EPS = 1e-9, PI = acos(-1.);
const int INF = 0x3f3f3f3f, MOD = 1e9+7;

// global to problem

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	vector<int> v(m);
	for(int i=0; i<m; i++){
		cin >> v[i];
	}
	
	int sum = accumulate(v.begin(), v.end(), 0);
	
	n<sum ? cout<<"-1\n" : cout << (n-sum) << "\n";  

}


Measured memory_bytes: 3692
#include<stdio.h>

int suitnum(char);
char rsuitnum(int);

int main(){
  int n,i,j,c[4][13]={};
  int rank;
  char s;

  scanf("%d\n", &n);
  for(i=0;i<n;i++){
    scanf("%c %d\n",&s,&rank);
    c[suitnum(s)][rank-1] = 1;
  }
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if (c[i][j]==0){
        printf("%c %d\n",rsuitnum(i),j+1);
      }
    }
  }

  return 0;
}

int suitnum(char suit){
  if (suit=='S'){
    return 0;
  }
  else if (suit=='H'){
    return 1;
  }
  else if (suit=='C'){
    return 2;
  }
  else if (suit=='D'){
    return 3;
  }
  return -1;
}

char rsuitnum(int num){
  if (num==0){
    return 'S';
  }
  else if (num==1){
    return 'H';
  }
  else if (num==2){
    return 'C';
  }
  else if (num==3){
    return 'D';
  }
  return 'a';
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int n;
  cin >> n;
  int N = n;
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  if(N%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
int  u[200];
ll mod = 1000000007;
P p[200005];
ll i, b, c, k,j, n, m, z = 0,mi=10,q;
char g;
string ss;
ll nn[100008] = {};
vector<ll> v;
int main() {
	cin >> n >> k >> q;
	rep(i, q) {
		cin >> b;
		nn[b]++;

	}

	for (i = 1; i < n + 1; i++) {
		if (nn[i] + k > q)cout << "Yes" << "\n";
		else cout << "No" << "\n";
	}
	return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    map<ll, int> m; rep(i,n) m[-a[i]]++;
    ll a1 = 0LL,a2 = 0LL;
    for(auto i: m){
        if(i.second >= 2){
            if(a1 == 0){
                a1 = -(i.first);
                m[i.first]-=2;
                break;
            }
        }
    }
    for(auto i: m){
        if(i.second >= 2){
            if(a2 == 0){
                a2 = -(i.first);
                break;
            }
        }
    }
    cout << a1*a2 << endl;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> k(M);
  vector<vector<int>> sw(M,vector<int>(10));
  vector<int> p(M);
  
  for(int i=0;i<M;++i){
    for(int j=0;j<=k.at(i);++j){
      if(j==0){
        cin>>k.at(i);
      }
      else{
        cin>>sw.at(i).at(j-1);
        sw.at(i).at(j-1)=sw.at(i).at(j-1)-1;
      }
    }
  }
  
  for(int i=0;i<M;++i){
    cin>>p.at(i);
  }

  int count=0;
  for(int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> s(tmp);
    int subcount=0;
    
    for(int i=0;i<M;++i){
      int subsubcount=0;
      for(int j=0;j<k.at(i);++j){
        if(s.test(sw.at(i).at(j))){
          ++subsubcount;
        }
      }
      if(subsubcount%2==p.at(i)){
        ++subcount;
      }
  }

  if(subcount==M){
    ++count;
  }
}


  cout<<count/pow(2,10-N)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll total = 0;
    for (ll i = 1; i <= n; i++) {
        ll y = n / i;
        total += (i * y * (y + 1)) / 2;
    }
    cout << total << endl;
}

Measured memory_bytes: 3592
n,m,q = map(int,input().split())
a,b,c,d=[0]*q,[0]*q,[0]*q,[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())

ans =0

from itertools import combinations_with_replacement

for i in combinations_with_replacement(range(1,m+1), n):
    tmp=0
    for j in range(q):
        if c[j] == i[b[j]-1] - i[a[j]-1]:
            tmp += d[j]
    ans = max( ans, tmp)

print(ans)

Measured memory_bytes: 68120
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
VI e[SIZE];
int dfs(int x,int lt){
    int v=0;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(y==lt)continue;
        v+=dfs(y,x);
    }
    if(!v)return 1;
    if(v==1)return 0;
    puts("First");
    exit(0);
}
int main(){
    DRI(n);
    REPP(i,1,n){
        DRII(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    if(n%2==1)return 0*puts("First");
    if(dfs(1,1))puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 26880
#include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <vector>
    #include <set>
    #include <queue>
    #include <deque>
    #include <map>
    #include <string.h>
     
    using namespace std;
     
    using ll = long long;
     
    int N, A[200005], S[200005];
    int main() {
      scanf("%d", &N);
      for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
      }
      int res = 0;
      for (int i = 1; i <= N; i++) {
        if (S[A[i] - 1]) {
          S[A[i]] = S[A[i] - 1] + 1;
        } else {
          S[A[i]] = 1;
        }
        res = max(res, S[A[i]]);
      }
      printf("%d\n", N - res);
      return 0;
    }

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

int main(){
    int a=0,b=0,c=0,d=0;
    cin >> a >> b >> c >> d;
    if(a+b>c+d)cout << "Left" << endl;
    else if(a+b==c+d)cout << "Balanced" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int a[4005][4005];
int s[4005][4005];
int n, k;

int f(int i, int j) {
  return s[i+k][j+k] - s[i+k][j] - s[i][j+k] + s[i][j];
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  cin >> n >> k;
  vi x(n), y(n), c(n, 1);
  int cntw = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> x[i] >> y[i] >> s;
    if (s[0] == 'W') {
      c[i] = -1;
      ++cntw;
    }
    x[i] %= 2 * k;
    y[i] %= 2 * k;
    a[x[i]][y[i]] += c[i];
    a[x[i]][y[i] + 2 * k] += c[i];
    a[x[i] + 2 * k][y[i]] += c[i];
    a[x[i] + 2 * k][y[i] + 2 * k] += c[i];
  }
  for (int i = 0; i < 4 * k; ++i) for (int j = 0; j < 4 * k; ++j) {
    s[i+1][j+1] = a[i][j] + s[i][j+1] + s[i+1][j] - s[i][j];
  }
  int res = 0;
  for (int i = 0; i < 2*k; ++i) for (int j = 0; j < 2*k; ++j) {
//    if (i == 0 && j == 1) cerr << cntw << ' ' << f(i, j) << ' ' << f(i + k, j + k) << ' ' << a[i+k][j+k] << endl;
    res = max(res, cntw + f(i, j) + f(i + k, j + k));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 126720
n = int(input())
res = float('inf')
for a in range(n+1):
    # 6の累乗としてa円引き出す
    rest = n - a
    cnt = 0
    for i in range(6,-1,-1):
        if a // (6**i) != 0:
            cnt += a // (6**i)
            a %= 6 ** i
    for i in range(5,-1,-1):
        if rest // (9**i) != 0:
            cnt += rest // (9**i)
            rest %= 9 ** i
    res = min(res, cnt)
print(res)


Measured memory_bytes: 3060
# K, N = map(int, input().split())
# a = list(map(int, input().split()))

# N = int(input())

n = int(input())
ans = 0
for i in range(1, n+1):
    if (i%3 != 0) and (i%5 != 0):
        ans += i
print(ans)

Measured memory_bytes: 9164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long count = 0;
        Integer[] H = new Integer[N];
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }
        Arrays.sort(H, Collections.reverseOrder());
        for (int i = 0; i < N; i++) {
            if (K == 0) {
                count += H[i];
            } else {
                K--;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 94300
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int u[MAXN],v[MAXN],deg[MAXN];
int val[MAXN];
bool valid[MAXN];
char str[MAXN];
vector<int> G[MAXN];
int dp[MAXN];
int ans,tot;
void add_edge(int u,int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
    deg[u]++;deg[v]++;
}
void dfs(int v,int p)
{
    dp[v]=0;
    int m1=-1,m2=-1;
    for(auto to:G[v])
    {
        if(to==p) continue;
        tot++;
        dfs(to,v);
        dp[v]=max(dp[v],val[v]+dp[to]);
        if(dp[to]>m1)
        {
            m2=m1;
            m1=dp[to];
        }
        else if(dp[to]>m2) m2=dp[to];
    }
    if(m2!=-1) ans=max(ans,m1+m2+val[v]);
    if(m1!=-1) ans=max(ans,m1+val[v]);
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n-1;i++) 
    {
        scanf("%d%d",&u[i],&v[i]);
        add_edge(u[i],v[i]);
    }
    scanf("%s",str+1);
    int cnt=0;
    for(int i=1;i<=n;i++) if(str[i]=='W') cnt++;
    if(cnt==0) {puts("0"); return 0;}
    else if(cnt==1) {puts("1"); return 0;}
    memset(valid,true,sizeof(valid));
    queue<int> que;
    for(int i=1;i<=n;i++) if(deg[i]==1&&str[i]=='B') que.push(i);
    while(que.size())
    {
        int p=que.front();que.pop();
        valid[p]=false;
        for(auto to:G[p])
        {
            deg[to]--;
            if(deg[to]==1&&str[to]=='B') que.push(to);
        }
    }
    for(int i=1;i<=n;i++) G[i].clear();
    memset(deg,0,sizeof(deg));
    for(int i=0;i<n-1;i++)
    {
        if(valid[u[i]]&&valid[v[i]]) add_edge(u[i],v[i]);
    }
    cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(valid[i])
        {
            if(str[i]=='B') val[i]=(deg[i]&1?2:0);
            else val[i]=(deg[i]&1?0:2);
            if(val[i]==2) cnt++; 
        }
    }
    ans=0;tot=0;
    for(int i=1;i<=n;i++) 
    {
        if(valid[i])
        {
            dfs(i,0);
            break;
        }
    }
    //printf("%d %d %d\n",tot,ans,cnt);
    if(cnt==0) ans=2*tot; else ans=2*tot+cnt-ans;
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 14848
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    
    vector<pii> vec;
    rep(i,N){
        ll A,B;
        cin>>A>>B;
        vec.push_back({A,B});
    }
    
    sort(all(vec));
    
    ll ans=0, m=M;
    rep(i,N){
        int x = min(m,vec[i].second);
        m-=x;
        ans += x*vec[i].first;
        if(m<=0) break;
    }
    
    cout1(ans)
}

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

#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define UNIQUE(x)       x.erase(unique(all(x)), x.end())

#define fs              first
#define sc              second
#define pb              push_back

#define sz(x)           (int)x.size()
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define ms(a,b)         memset(a, b, sizeof(a))
#define valid(x,y,n, m)      x>=0 && y>=0 && x<n && y<m

#define input           freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output          freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)

#define endl            '\n'
#define eps             1e-5
#define yes             printf("Yes\n")
#define no              printf("No\n")

inline void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}

#define int long long

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(10, 20)(rng);

int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
inline int Set(int n,int pos) { return n = n | (1 << pos); }
inline int Reset(int n,int pos) { return n = n & ~(1 << pos); }
inline bool Check(int n,int pos) { return (bool)(n & (1 << pos)); }
inline int Count(int n) {
    int res = 0;
    while(n){
        if(n & 1) res++;
        n >>= 1;
    }
    return res;
}


int const N = 3e5 + 5;
int const MOD = 1e9 + 7;




void solve(){
    int n;
    cin >> n;
    
    int s = 0;
    int last = 1e9;

    for(int i = 0; i < n - 1; i++){
        int a; cin >> a;
        s += min(last, a);
        last = a;
    }
    s += last;
    cout << s << endl;
    
}


int32_t main(){
    fast();
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	int ans=0;
	cin >>n>>m;
	int a,b;
	int mack=0;
	int c;
	VPi data(m);
	VVi dp(m+1,Vi(1<<n,INF));
	dp[0][0]=0;
	/*
dp: [at][state]=yen
intit : INF , [0][0]=0;
find [m][2^n-1]
	*/
	rep(i,m){
		mack=0;
		cin>>a>>b;
		rep(i,b){
			cin>>c;
			c--;
			mack|=(1<<c);
		}
		data[i]=mp(a,mack);
	}
	rep(i,m){
		rep(j,1<<n){
			chmin(dp[i+1][j],dp[i][j]);
			chmin(dp[i+1][j|data[i].S],dp[i][j]+data[i].F);
		}
	}
	if(dp[m][(1<<n )-1]==INF){
		cout<<-1<<endl;
	}else{
		cout<<dp[m][(1<<n)-1]<<endl;
	}
	//cout<<ans<<endl;
}

Measured memory_bytes: 19272
#include <iostream>
#include <string>
#include <set>

using namespace std;

#define rall(c) (c).rbegin(), (c).rend()

int main(){
    int m;
    cin >> m;
    while(m--){
        string tr;
        cin >> tr;
        set<string> org;
        for(int i=1; i<(int)tr.size(); ++i){
            string s = tr.substr(0, i), t = tr.substr(i);
            org.insert(s + t);
            org.insert(t + s);
            org.insert(string(rall(s)) + t);
            org.insert(t + string(rall(s)));
            org.insert(s + string(rall(t)));
            org.insert(string(rall(t)) + s);
            org.insert(string(rall(s)) + string(rall(t)));
            org.insert(string(rall(t)) + string(rall(s)));
        }
        cout << org.size() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll x;cin>>x;
  cout<<360/gcd(360,x)<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

int main() {
	string s;
	cin >> s;
	vector<int> cnt(26);
	long long ans = 0;
	for (char c : s) {
		for (int i = 0; i < 26; ++i) {
			if (c != 'a' + i) {
				ans += cnt[i];
			}
		}
		cnt[c - 'a'] += 1;
	}

	cout << ans + 1 << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n, n )
	{
		map<char, char> t;

		for (int i = 0; i < n; ++i)
		{
			char a, b;
			cin >> a >> b;
			t[a] = b;
		}

		int m;
		cin >> m;

		string out = "";

		for (int i = 0; i < m; ++i)
		{
			char c;
			cin >> c;
			if ( t.count(c) )
				out += t[c];
			else
				out += c;
		}
		cout << out << endl;
	}

	return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  string s[n];
  int t[n];
  REP(i,n){
    cin>>s[i]>>t[i];
  }
  string x;
  cin>>x;
  bool flag = false;
  int ans = 0;
  REP(i,n){
    if(flag){
      ans += t[i];
    }
    if(s[i] == x){
      flag = true;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	private static final String RIGHT_TRIANGLE = "YES";
	private static final String NOT_RIGHT_TRIANGLE = "NO";

	/**
	 * <p>
	 * 与えられた三辺で直角三角形が作れるかを判定する。
	 * </p>
	 *
	 * @param args
	 *            利用しない。
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineCount = Integer.parseInt(br.readLine());
		for (int i = 0; i < lineCount; i++) {

			String[] input = br.readLine().split(" ");
			int[] side = {Integer.parseInt(input[0]),
					Integer.parseInt(input[1]), Integer.parseInt(input[2])};
			Arrays.sort(side);

			if (side[2] * side[2] == side[0] * side[0] + side[1] * side[1]) {
				System.out.println(RIGHT_TRIANGLE);
			} else {
				System.out.println(NOT_RIGHT_TRIANGLE);
			}
		}
	}
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }
  else if(a == c){
    cout << b << endl;
  }
  else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
s = input()
c = 0
for i in range(len(s)):
    if s[i].isupper() == True:
        c += 1
if s[0] != "A":
    print("WA")
    exit()
if s[2:-1].count("C") != 1:
    print("WA")
    exit()
if  c != 2:
    print("WA")
    exit()
print("AC")


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

int main(){
	while(1){
		int h, w;
		char f[102][102];
		
		scanf(" %d %d", &h, &w);
		if(h==0) break;
		
		for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
		scanf(" %c", &f[i][j]);
		
		int x=0, y=0;
		bool loop=false;
		while(!loop && f[y][x]!='.'){
			//printf("%c\n", f[y][x]);
			if(f[y][x]=='a') loop=true;
			else{
				int tx=x, ty=y;
				
				if(f[y][x]=='>') ++x;
				else if(f[y][x]=='<') --x;
				else if(f[y][x]=='^') --y;
				else if(f[y][x]=='v') ++y;			
				
				f[ty][tx]='a';
			}
			
			//printf("%d %d\n", x, y);
		}
		
		if(loop) printf("LOOP\n");
		else printf("%d %d\n", x, y);
	}
}

Measured memory_bytes: 1208
from __future__ import division
while True:
	try:
		a, b, c, d, e, f = map(int, raw_input().split())
		D = a*e - b*d
		Dx = c*e - b*f
		Dy = a*f - c*d
		print("%.3f %.3f" % (Dx/D + 0, Dy/D + 0))
	except EOFError:
		break

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

using namespace std;


int main() {
  int h = 0, w = 0;
  cin >> h >> w;

  vector<int> col(w, 0);
  vector<string> grid(h, "");
  
  for (int i = 0; i < h; i++) {
    cin >> grid.at(i);
    if (grid.at(i).find('#') == string::npos) {
      grid.at(i) = "";
      continue;
    }
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') col.at(j)++;
    }
  }
  
  for (int i = 0; i < h; i++) {
    if(grid.at(i).empty()) continue;
    for(int j = 0; j < w; j++) {
      if (col.at(j) == 0) grid.at(i).at(j) = ' ';
    }
    grid.at(i).erase(remove(grid.at(i).begin(),
                            grid.at(i).end(), ' '),
                     grid.at(i).end());
    grid.at(i).push_back('\n');
  }

  for (int i = 0; i < h; i++) {
    cout << grid.at(i);
  }

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919810893;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll N;
    cin >> N;
    vector<P>v;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        v.push_back(P(a + b, a - b));
    }
    sort(v.begin(), v.end());
    ll lst = v[0].second - 10;
    ll ans = 0;
    rep(i, N){
        ll a = v[i].second;
        ll b = v[i].first;
        if(a < lst)continue;
        chmax(lst, b);
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2420
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')



n = I()
XY = LIR(n)
D = [[0]*n for _ in range(n)]
for i, j in combinations(range(n), 2):
    x1 = XY[i][0]
    y1 = XY[i][1]
    x2 = XY[j][0]
    y2 = XY[j][1]
    D[i][j] = sqrt((x1-x2)**2+(y1-y2)**2)

tmp = 0
for Z in permutations(range(n), n):
    a = 0
    for i in range(n-1):
        b = min(Z[i], Z[i+1])
        c = max(Z[i], Z[i+1])
        a += D[b][c]
    tmp += a
print(tmp/factorial(n))


Measured memory_bytes: 41580
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int mod = 1e9 + 7;

int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;

  vector<int> broken(n + 1);  // zero初期化
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

  vector<int> dp(n + 2);
  dp[n] = 1;  // goal
  for (int i = n - 1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
  }
  cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s,t;
   cin >> s >> t;
   t = t.erase(t.size()-1);
   if (s == t) cout << "Yes" << endl;
   else cout << "No" << endl;   
   return 0;

}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String X = sc.next();
		sc.close();
		int l = X.length();
		int cnt = 0;
		int t = 0;
		for(int i = 0; i < l; i++) {
			char c = X.charAt(i);
			if(c == 'S') {
				t++;
			}else {
				if(t > 0) {
					t--;
					cnt += 2;
				}
			}
		}
		System.out.println(l - cnt);
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI h(n);
	rep(i,n) cin >>h[i];
	
	vector<ll> dp(n+4, 1LL<<50); dp[0]=0;
	rep(i, n) rep2(j,1,k+1){
		if(i+j <= n)
		dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] -h[i+j]));
	}
	//for(auto x :dp) printf("%lld, ",x); puts("");
	cout << dp[n-1] <<"\n";
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

const long long MOD = 1000000007;

long long cnt[64][2];

void solve(long long N, std::vector<long long> A) {
    for (int i = 0; i < 64; i++) {
        for (auto x : A) {
            cnt[i][x >> i & 1]++;
        }
    }
    long long ans = 0;
    for (int i = 0; i < 64; i++) {
        ans += (1ll << i) % MOD * cnt[i][0] % MOD * cnt[i][1] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
// last edited at 224/8/2015 by charis

#include<iostream>
using namespace std;

class Dice{
public:
	int f[6];
	Dice(){}
	
	void roll(int x, int y, int z, int w){
		int c=f[x]; f[x]=f[y]; f[y]=f[z]; f[z]=f[w]; f[w]=c;
	}
	void rollE(){roll(0,3,5,2);}
	void rollS(){roll(0,4,5,1);}
	void rooll(){roll(1,2,4,3);}
};

int check(Dice d1, Dice d2){
	for (int i=0; i<4; i++){
		for (int j=0; j<4; j++){
			for (int k=0; k<4; k++){
				if (d1.f[0]==d2.f[0] && d1.f[1]==d2.f[1] && d1.f[2]==d2.f[2] && d1.f[3]==d2.f[3] && d1.f[4]==d2.f[4] && d1.f[5]==d2.f[5]){
					return 1;				
				}
				d2.rooll();
			}
			d2.rollS();
		}
		d2.rollE();
	}
	return -1;
}

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

	Dice d[n];
	for(int i=0; i<n; i++){
		for (int j=0; j<6; j++){
			cin >> d[i].f[j];
		}		
	}
	int x=0;
	for(int i=0; i<n-1; i++){
		for(int j=1; j<n; j++){
			if(i!=j){
			int t=check(d[i], d[j]);
			if(t==1) x=1;
			}
		}
	}

	if(x==1) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	auto sv = v;
	sort(sv.begin(), sv.end(),greater<>());
	for (int i = 0; i < N; i++) {
		cout << (v[i] == sv[0] ? sv[1] : sv[0]) << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,a,b; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int main() {
	cin >> n; int sum = 0;
	int m = n;
	for (int i = 0; n >= 1; i++) {
		sum += n % 10;
		n /= 10;
	}
	if (m % sum==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial = 0))
csum_of_positives = list(accumulate([max(A, 0) for A in As], initial = 0))

#[i, i+K) will be all white/black.
max_score = 0
for i in range(N-K+1):
    score = 0
    all_black = csum[i+K] - csum[i]
    if all_black > 0: # if [i, i+K) is worth painting with black 
        score += all_black
    score += csum_of_positives[i] #[0, i)
    score += csum_of_positives[N] - csum_of_positives[i+K] #[i+K, N)    
    max_score = max(max_score, score)

print(max_score)


Measured memory_bytes: 25184
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e5+50;
const ll mod=1e9+7;
using namespace std;
int n,i,j,nr[100];
ll a[nmax],rs;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		for(j=0;j<60;j++)if(a[i]&(1LL<<j))nr[j]++;
	}
	for(i=1;i<n;i++)
	{
		for(j=0;j<60;j++)
		{
			if(a[i]&(1LL<<j))nr[j]--;
			if(a[i]&(1LL<<j))
			{
				rs+=(1LL<<j)%mod*1LL*(n-i-nr[j])%mod;
				rs%=mod;
			}
			else
			{
				rs+=(1LL<<j)%mod*1LL*nr[j]%mod;
				rs%=mod;
			}
		}
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl; 
#define MOD llong(1e9 +7)

int main(){
    int n;
    cin >> n;
    llong ans=1;
    FOR(i,1,n+1){
        ans *= llong(i);
        ans %=MOD;
    }
    print(ans);
}

Measured memory_bytes: 384
a, b = map(int, input().split())

m = -((-a*25)//2)
M = -(-(a+1)*25)//2


def check(x, b):
    ans = True
    if x < 10*b or 10*(b+1) <= x:
        ans = False
    return ans


ans = -1
for x in range(m, M):
    if(check(x, b)):
        ans = x
        break

print(ans)


Measured memory_bytes: 3060