akhauriyash/Code-Regression huggingface dataset:
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 71 , P = 1e9 + 7 , M = 400;
inline void pp(int &x,int d) {if((x+=d)>=P)x-=P;}
inline int mul(int a,int b) {return ll(a)*b%P;}
int n , K , dp[N][N] , fac[M] , ifac[M];
string s;
inline int comb(int a,int b) {
  return mul(fac[a] , mul(ifac[b] , ifac[a-b]));
}

int main() {
  rep(i,0,M) fac[i] = i ? mul(fac[i - 1] , i) : 1;
  rep(i,0,M) ifac[i] = i >= 2 ? P - mul(P / i , ifac[P % i]) : 1;
  rep(i,1,M) ifac[i] = mul(ifac[i - 1] , ifac[i]);
  cin >> n >> K >> s;
  int ans = 0;
  for(int a = 0;a <= K;++a)
    for(int ab = 0;ab * 2 + a <= K;++ab) {
      if(a == 0 && ab == 0) {
        ans++;
        continue;
      }
      int cnt_a = 0 , cnt_ab = 0;
      vi sum(ab);
      for(auto ch : s) {
        if(ch == 'r') {
          if(cnt_a + cnt_ab < a + ab)
            cnt_a ++;
          else if(cnt_ab)
            sum[ab - cnt_ab]++;
        } else {
          if(cnt_ab < ab && cnt_a)
            cnt_a-- , cnt_ab ++;
          else if(cnt_ab)
            sum[ab - cnt_ab]++;
        }
      }
      if(ab != cnt_ab || a != cnt_a)
        break;
      rep(i,1,sz(sum)) sum[i] += sum[i-1];
      memset(dp , 0 , sizeof(dp));
      dp[0][0] = mul(fac[a + ab] , ifac[a]);
      for(int add = 0;add * 2 < n;++add)
        for(int cnt_ab = ab;cnt_ab >= 0;--cnt_ab)
          for(int used = ab ? sum.back() : 0;used >= 0;--used) if(dp[cnt_ab][used]) {
            for(int add_ab = 1;cnt_ab + add_ab <= ab &&
                used + add * add_ab <= sum[cnt_ab + add_ab - 1];++add_ab) {
              pp(dp[cnt_ab + add_ab][used + add * add_ab] , mul(dp[cnt_ab][used] , ifac[add_ab]));
            }
          }
      rep(used,0,(ab ? sum.back() : 0) + 1) {
        int need = (ab + used * 2 + a) + (ab + a - 1);
        int remain = n - need;
        if(remain < 0)
          continue;
        int position = (ab * 3 + used * 2 + a) + (ab + a + 1);
        pp(ans , mul(dp[ab][used] , comb(remain + position - 1 , remain)));
      }
    }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    vector<int> a(3,0);
    cin >>a[0]>>a[1]>>a[2];
    SORT(a);
    cout <<abs(a[2]-a[0]);
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  int s=0,l=0;
  for (int i=0;i<N;i++){
    l=l+a.at(i);
  }
  
  for (int i=0;i<N;i++){
    s=s+a.at(i);
    l=l-a.at(i);
    if (l-s<=0){
      cout << min(s-l,l-s+2*a.at(i)) << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define DEBUG

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef pair<long,long> pr;
typedef map<double,pr> mp;

short N, A;

int main(void){
	cin >> N >> A;
    if (N % 500 - A <= 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i + 1];
    int cnt = 0;
    int num = 1;
    while(num != 2) {
        if(cnt >= 1000000) {
            cout << -1 << endl;
            return 0;
        }
        num = a[num];
        cnt++;
       //cerr << cnt << " " << num << endl;
    }
    cout << cnt << endl;
    

    return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(),a.end())
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1; while (y > 0){if (y & 1) res = (res*x); y = y>>1;x = (x*x);}return res;}
lli llipowerp(lli x, lli y,lli p){lli res = 1;x = x % p; while (y > 0){if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	}return -1;
}
template <typename T> void printvec(vector<T> inp){for(int i=0;i<inp.size();i++){cout<<inp[i]<<" ";}cout<<endl;}
template <typename T> T ceildiv(T x, T y){return 1 + ((x - 1) / y);}
lli modInverse(lli a, lli m){lli g = gcd(a, m);if (g != 1) return -1;else return llipowerp(a, m-2, m);} 

int main(){

	lli n,m;
    cin>>n>>m;
    lli ans=0;
    ans+=((n*n-n)/2 + (m*m-m)/2);
    cout<<ans<<endl;
    

}
 


Measured memory_bytes: 256
loop {
    tbl = {}
    n = gets.to_i
    break if n == 0

    n.times{
        k,v = gets.split
        tbl[k] = v
    }

    m = gets.to_i
    m.times{
        l = gets.chomp
        print tbl.fetch(l,l)
    }
    puts
}

Measured memory_bytes: 8784
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;

char buf[300005];

int main() {
  int len;
  scanf("%d\n%s", &len, buf);
  int ret = 0;
  int east = 0;
  int west = 0;
  for(int i = 0; i < len; i++) {
    if(buf[i] == 'W') {
      west++;
    }
  }
  for(int i = 0; i < len; i++) {
    if(buf[i] == 'W') {
      west--;
    }
    ret = max(ret, east+west);
    if(buf[i] == 'E') {
      east++;
    }
  }
  printf("%d\n", len-1-ret);
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
int main()
{
	int h,w,n,ans=0,c,i,j,k,l;
	char s[8][8];

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

	for(i=0;i<pow(2,h);i++)
		for(j=0;j<pow(2,w);j++){
			c=0;
			for(k=0;k<h;k++){
				if(i&(1<<k))
					continue;
				for(l=0;l<w;l++){
					if(j&(1<<l))
						continue;
					if(s[k][l]=='#')
						c++;
				}
			}
			if(c==n)
				ans++;
		}

	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b;
            cin>>a>>b;
            cout<<max(0ll,a-2*b)<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
// #include<bits/stdc++.h>
// using namespace std;
 
// typedef vector <int> vi;
// typedef pair< int ,int > pii;
// #define all(v) v.begin(),v.end()
// #define PB push_back
// #define T(val) while(val--)
// #define FIN for(i=0;i<n;i++)
// #define FIS for(i=0;i<s.length();i++)
// #define AIN for(i=0;i<n;i++){cin>>a[i];}
// #define F(i,k,n) for(i=k;i<n;i++)
// #define FG(i,k,n,x) for(i=k;i<n;i+=x)
// #define YES cout<<"YES\n"; 
// #define NO cout<<"NO\n"; 
// #define ll long long
// #define MOD 1000000007
// #define deb(x) cout << #x << "=" << x << endl;
// #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
// #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// //sort(arr, arr+n, greater<int>()); For sorting in reverse order

// int solve(){
//   int i,n,m;
//   cin>>n>>m;
//   vector < int > DG[n],UG[n];
//   int x,y,z;
//   F(i,0,m){
//     cin>>x>>y>>z;
//     if(x==0){
//       UG[x].PB(y);
//       UG[y].PB(x);
//     }
//     if(x==1){
//       DG[x].PB(y);
//     }
//   }
//   iscyclic()
//   return 0;
// }
// int main(){
// fast
//   int t;
//   cin>>t;
//   T(t){
//     solve();
//   }
//   return 0;
// }
// cin>>t;



#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define all(v) v.begin(),v.end()
#define PB push_back
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define MOD 1000000007
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
 
int solve(){
  int n;
  cin>>n;
  int i;
  int h[n];
  FIN{
    cin>>h[i];
  }
  ll dp[n]={0};
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++){
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}

Measured memory_bytes: 4804
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
int main(){
	int n;
	cin >> n;
	int r[n];
	for(int i = 0;i<n;i++) cin >> r[i];//4,3,2

	int ancer = -2000000000;
	int minv = r[0];
	for(int i = 1;i<n;i++){
		ancer = max(ancer,r[i] -minv);
		minv = min(minv,r[i]);
	}

	cout << ancer << endl;

	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	ll ans = 1 ;
	int ul = 0 ;
	for(int i=0;i<n-1;i++){
		if(a.at(i)==a.at(i+1)) continue ;
		if(ul==0){
			if(a.at(i)<a.at(i+1)) ul = 1 ;
			else ul = -1 ;
		}else if(ul==1){
			if(a.at(i)>a.at(i+1)){
				ans++ ;
				ul = 0 ;
			}
		}else{
			if(a.at(i)<a.at(i+1)){
				ans++ ;
				ul = 0 ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1024
class Dice
  def initialize(args)
    @labels = args
  end

  def top
    @labels[0]
  end

  def move(a,b,c,d)
    arr = [@labels[a], @labels[b], @labels[c], @labels[d]]
    t = arr.shift
    arr << t
    @labels[a], @labels[b], @labels[c], @labels[d] = arr
  end

  def move_n
    move(0,1,5,4)
  end

  def move_e
    move(0,3,5,2)
  end

  def move_s
    move(4,5,1,0)
  end

  def move_w
    move(2,5,3,0)
  end

  def move_to_input(ch)
    case ch
    when 'E'
      move_e
    when 'N'
      move_n
    when 'S'
      move_s
    when 'W'
      move_w
    end
  end
end

input = gets.split.map(&:to_i)
dice = Dice.new(input)

gets.chomp.chars.map do |v|
  dice.move_to_input(v)
end

p dice.top

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

#define N 500000

int count = 0;

void marge(int *, int, int ,int);
void margeSort(int *, int, int);

int main() {
    int a;
    cin>>a;
    int A[N];
    for(int i = 0; i < a; i++) cin>>A[i];
    int left = 0;
    int right = a;
    margeSort(A, left, right);
    
    for(int i = 0; i < a-1; i++) cout<<A[i]<<' ';
    cout<<A[a-1]<<endl;
    cout<<count<<endl;

    return 0;
}

void marge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    int i, j;
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(j = 0; j < n2; j++) R[j] = A[mid+j];
    
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    
    i = 0;
    j = 0;
    
    for(int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    count++;
    }
}

void margeSort(int *a, int left, int right) {
    if(left+1 < right) {
        int mid = (left + right) /2;
        margeSort(a, left, mid);
        margeSort(a, mid, right);
        marge(a, left, mid, right);
    }
}




Measured memory_bytes: 6904
#include <stdio.h>

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a == b) printf("%d\n" , c);
  if(b == c) printf("%d\n" , a);
  if(c == a) printf("%d\n" , b);
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int T[N];

    int sum;

    sum=0;
    for(int i=0; i<N; i++){
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    int P[M], X[M];
    for(int i=0; i<M; i++){
        cin >> P[i] >> X[i];
    }

    for(int i=0; i<M; i++){
        cout << sum - T[ P[i]-1 ] + X[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func solve(n int) (ans int) {
	ans = n
	var tmp int
	mp := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		if val, ok := mp[tmp]; ok {
			mp[tmp]++
		} else {
			mp[tmp] = 1
			tmp = val
		}
	}
	cnt := 0
	for key, val := range mp {
		if val%2 == 1 {
			ans -= val - 1
		} else {
			ans -= val - 2
			cnt++
		}
		val = key
	}
	ans -= cnt - cnt%2
	if cnt%2 == 1 {
		ans -= 2
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(solve(n))
}


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

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int t1 = H1*60+M1;
    int t2 = H2*60+M2;
    int ans = (t2-t1)-K;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
(defun App ()
    (let* ((n (read))
        (k (read))
        (di 0)
        (a (make-array n :initial-element nil)))
        (loop for i to (- k 1)
            do (progn
                (setq di (read))
                (dotimes (j di)
                
                    (setf (aref a (- (read) 1)) t)
                    
                )
            )
        )
        (format t "~D~%" (count nil a) 1)
    )
)

(App)

Measured memory_bytes: 29608
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    ABC = [list(iss()) for _ in range(3)]
    key = 'abc'
    s = 'a'

    while True:
        if len(ABC[key.index(s)]) == 0: break
        s = ABC[key.index(s)].pop(0)

    print(s.upper())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	final long MOD = 1_000_000_000 + 7;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();// the number of friends
		int W = sc.nextInt();// the capacity
		int[] w = new int[N];
		for (int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
		}
		Arrays.sort(w);
		/*
		 * dp[k][i][j]????????????k?????????????????????????????§????£???°?????????????????????????°?????????????
		 * ?????????????????????i?????????????£???°???????????????????????°????????¨??????n?????§????????????????????????j??§????????¨????????´????????°???
		 */

		long[][][] dp = new long[2][210][10010];
		dp[0][N][W] = 1;
		for (int k = 0; k < N; k++) {
			int cur = k % 2, next = (k + 1) % 2;
			for (int i = 0; i <= N; i++) {
				for (int j = 0; j <= W; j++) {
					dp[next][i][j] = 0;
				}
			}
			for (int i = 0; i <= N; i++) {
				for (int j = 0; j <= W; j++) {
					if (dp[cur][i][j] == 0)
						continue;
					dp[next][Math.min(i, k)][j] += dp[cur][i][j]%=MOD;
					if (j - w[k] < 0)
						continue;
					dp[next][i][j - w[k]] += dp[cur][i][j]%=MOD ;
				}
			}
		}
		long ret = 0;
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= W; j++) {
				if (i == N || j < w[i]) {
					ret += dp[N % 2][i][j]%=MOD;
				}
			}
		}
		System.out.println(ret % MOD);
	}
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li a,b,c;
    cin>>a>>b>>c;
    if(min(a,b)>c){
        puts("No");
    }else if(max(a,b)<c){
        puts("No");
    }else{
        puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 3616
s = input()
l = len(s)
al = [chr(ord('a') + i) for i in range(26)]
a = 0
ans = "None"
for j in al :
    for i in range(l) :
        if s[i] == j :
            a +=1
    if a == 0 :
        ans = j
        break
    a = 0
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    string S, T;
    cin >> S >> T;
    cout << T << S << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda: list(map(int, input().split()))

ans = 0
def dfs(u, graph, visited, curr_len, req_len):
    global ans
    if visited[u]:
        return
    visited[u] = 1
    if curr_len == req_len:
        ans += 1
        visited[u] = 0
        return
    for kid in graph[u]:
        dfs(kid, graph, visited, curr_len+1, req_len)
    visited[u] = 0

def main():
    global ans
    n, m = M()
    graph = defaultdict(list)
    for _ in range(m):
        u, v = M()
        graph[u].append(v)
        graph[v].append(u)
    visited = [0 for _ in range(n+1)]
    dfs(1, graph, visited, 0, n - 1)
    print(ans)

tc = 1
# tc = I()
for _ in range(tc):
    main()

Measured memory_bytes: 74984
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    long long n;
    int k;
    cin >> n >> k;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    double ans = ceil(log(n) / log(k));
    cout << ans << endl;
}

Measured memory_bytes: 3852
n = int(input())
x = input()
def cal(num):
    A = 1
    while num>0:
        X = bin(num)
        X = str(X)
        Y = X.count("1")
        num = num%Y
        A += 1
    return(A)
y = x.count("1")
if (y==0):
    ans = [1]*n
    print(*ans, sep="\n")
    exit()
elif (y==1):
    w1 = []
    wa = 1
    for i in range(n):
        wa %= y+1
        w1.append(wa)
        wa *= 2
    w1.reverse()
    a1 = 0
    for i in range(n):
        if (x[i]=="1"):
            a1 += w1[i]
    a1 %= y+1
    ans = []
    for i in range(n):
        if (x[i]=="0"):
            tnp = a1
            tnp += w1[i]
            tnp %= y+1
            ans.append(cal(tnp))
        else:
            ans.append(0)
    print(*ans, sep="\n")
    exit()
        
w1 = []
w2 = []
wa = 1
for i in range(n):
    wa %= y+1
    w1.append(wa)
    wa *= 2
wa = 1
for i in range(n):
    wa %= y-1
    w2.append(wa)
    wa *= 2
#print(w1,w2)
w1.reverse()
w2.reverse()
a1 = 0
a2 = 0
for i in range(n):
    if (x[i]=="1"):
        a1 += w1[i]
        a2 += w2[i]
a1 %= y+1
a2 %= y-1
#print(a1,a2)
ans = []
for i in range(n):
    if (x[i]=="0"):
        tnp = a1
        tnp += w1[i]
        tnp %= y+1
        ans.append(cal(tnp))
    else:
        tnp = a2
        tnp -= w2[i]
        tnp %= y-1
        ans.append(cal(tnp))
    #print(tnp)
print(*ans, sep="\n")

    
    

Measured memory_bytes: 30008
#include<iostream>
#include<cmath>
#include<string>

using namespace std;
int main()
{
    int l,a,b,c,d;
    cin >> l >> a >> b >> c >> d;
    int max=0;
    if(a%c==0){
        max=a/c;
    }else{
        max=a/c+1;
    }
    if(b%d==0){
        if(max<(b/d)){
            max=b/d;
        }
    }else{
        if(max<(b/d+1)){
            max=b/d+1;
        }
    }
    
    cout << l-max << endl;
    return 0;
}



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

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

  long sum = 0;
  int mi = 1000000;
  int ma = -1000000;
  int e;
  for (int i = 0; i < n; ++i) {
    cin >> e;
    mi = min(e, mi);
    ma = max(e, ma);
    sum += e;
  }
  cout << mi << " " << ma << " " << sum << endl;

  return 0;
}

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

int main(){
        string N;
        cin >> N;
        int count = 0;
        int len = N.size();
        rep(i,(len / 2)){
                if(N.at(i) != N.at(len - i - 1)) count++;
        }
        cout << count << endl;
}


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn count_digit(x: i64) -> i64 {
    let mut s = x.clone();
    let mut res = 0;
    while s > 0 {
        s /= 10;
        res += 1;
    }
    res
}
use std::cmp::{max, min};
fn main() {
    input! {
        n:i64,
    }
    let mut ans = count_digit(n);
    for j in 1..n {
        if j * j > n {
            break;
        }
        if n % j != 0 {
            continue;
        }
        let div = n / j;
        ans = min(ans, max(count_digit(j), count_digit(div)));
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll k;
   cin>>k;
   ll a,b;
   cin>>a>>b;
       if(((a/k)+1)*k<=b||a%k==0||b%k==0)
        cout<<"OK"<<endl;
       else
        cout<<"NG"<<endl;
}


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

size_t N;

class calculator {
public:
  calculator(void) : zero_found(false), negcnt(0), minabs(LONG_MAX) {}
  void push_num(long num) {
    numseq.push_back(num);
    if (num < 0)
      negcnt++;
    if (num == 0)
      zero_found = true;
    if (!zero_found && minabs > abs(num))
      minabs = abs(num);
  }

  long calc_total(void) {
    long total = 0;

    for (auto num : numseq)
      total += abs(num);

    if (!zero_found && (negcnt % 2) == 1) {
      total -= 2 * minabs;
    }

    return total;
  }

  void dump(void) {
    cout << "negcnt: " << negcnt << endl;
    cout << "minabs: " << minabs << endl;
    cout << "numseq:\n";
    for (auto num : numseq)
      cout << "  " << num << endl;
    cout << "total: " << calc_total() << endl;
  }

  bool zero_found;
  size_t negcnt;
  long minabs;
  vector<long> numseq;
};

int main(void) {
  cin >> N;

  long num;
  vector<calculator *> solver;

  calculator calc;

  for (size_t i = 0; i < N; i++) {
    cin >> num;
    calc.push_num(num);
  }

  cout << calc.calc_total() << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b){
    return *(long*)a-*(long*)b;
}
int main(void){
    long n,i;
    scanf("%ld",&n);
    long a[n];
    for(i=0;i<n;i++) scanf("%ld",&a[i]);
    qsort(a,n,sizeof(long),asc);
    printf("%ld",a[n/2]-a[n/2-1]);
}

Measured memory_bytes: 1788
def solve():
    K = int(input())
    all = []
    for i in range(1,10):
        dfs(1,i,all)
    
    all.sort()
    print(all[K-1])
    
def dfs(d, val, all):
    all.append(val)

    if d == 10:
        return
    
    for j in [-1,0,1]:
        add = val % 10 + j
        if 0 <= add <= 9:
            dfs(d+1, val*10+add, all)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 53872
import java.util.*;
public class Main {
	private static int h[];
	private static int dp[][];

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
        h = new int[n];
        dp = new int[n][k+1];

        for (int i = 0; i < n; i++) {
        	h[i] = sc.nextInt();
        }

		// 40 10 20 70 80 10 20 70 80 60
		dp[0][0] = 0;
		dp[1][0] = Math.abs(h[0] - h[1]);	//30
		dp[1][1] = Math.abs(h[0] - h[1]);	//30
		for (int i=2; i < n; i++) {
			for (int j=1;j <k+1;j++){
				if (i>=j) {
					dp[i][j]=bbbb(i,j);
                    if (j==1){
                      dp[i][0]=dp[i][j];
                    } else {
					dp[i][0]=Math.min(dp[i][0],dp[i][j]);
                    }
				}
			}
		}
		System.out.println(dp[n-1][0]);
	}
	private static int bbbb(int i, int j) {
		int b = Math.abs(h[i] - h[i-j]); //     i-2 j-1
		return dp[i-j][0] + b;
    }
	private static int aaaa(int i, int j) {
		int a = Math.abs(h[i] - h[i-j]); //i = 2  50
		int b = Math.abs(h[i] - h[i-j-1]); //     30
		return Math.min(dp[i-2][0] + b, dp[i-1][0] + a);
	}
}



Measured memory_bytes: 119344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int64_t> vector(87);
  vector.at(0) = 2;
  vector.at(1) = 1; 

  for(int i = 0; i < 85; i++){
      vector.at(i+2) = vector.at(i) + vector.at(i+1);
  } 

  int N;
  cin >> N;

  cout << vector.at(N) << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (N >= 30) {
		cout<<"Yes"<<endl;
	}
	else {
		cout << "No" << endl;
	}




}


Measured memory_bytes: 3640
n = int(input())
house = [[[0 for i in range(10)] for j in range(3)]for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    house[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}', end="")
        print()
    if i != 3:
        print("#"*20)



Measured memory_bytes: 5636
#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>;


vector <ll> Yakusu(ll n){
    vector<ll> res;

    for (ll i = 1; i*i <= n; ++i){
        if (n%i != 0) continue;
        res.push_back(i);
        if (i*i != n) res.push_back(n/i);
    }
    return res;
}

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

    for (ll x: Yakusu(n)){
        if (x == 1) continue;
        ll tmp = n;
        while(tmp % x == 0) tmp /= x; 

        tmp %= x; 
        if (tmp == 1) ++ans;
    }
    ans += Yakusu(n - 1).size() - 1;
   
    cout << ans << endl;
    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        mut s: chars,
    }
    s.sort();
    if s[0] == s[1] && s[2] == s[3] && s[0] != s[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=false;

    ll ans=0,sum=0;

    int m,k;
    cin >>m>>k;

    if(k >= (1<<m)  || (m==1 && k==1)){
        cout << -1 <<endl;
        return 0;
    }else if(m == 0 && k == 0){
        cout << "0 0";
    }else if (m==1 && k==0){
        cout << "0 0 1 1";
    }else{

        for(int i = (1<<m)-1 ; i >= 0 ;--i){
            if(i!=k)cout << i << " ";
        }
        cout << k << " ";

        for(int i = 0; i < (1<<m) ;++i){
            if(i!=k)cout << i << " ";
        }
        cout << k << " ";
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

template <typename T>
void greater_sort(vector<T>& vec) {
	
	sort(all(vec), greater<T>());
	return;
}

int h,w,ans;
int c[444][444];
bool used[444][444];

bool is_in(int i,int j) {
	if(0<=i&&i<h&&0<=j&&j<w) return true;
	return false;
}

bool can(int i,int j,int d) {
	int nx=j+dx[d],ny=i+dy[d];
	if(!is_in(ny,nx)) return false;
	if(c[i][j]==c[ny][nx]) return false;
	return true;
}

signed main() {
	cin>>h>>w;
	rep(i,h) {
		string s;
		cin>>s;
		rep(j,w) {
			c[i][j]=s[j];
		}
	}
	rep(i,h) {
		rep(j,w) {
			if(used[i][j]) continue;
			int b=0,w=0;
			queue<P>que;
			used[i][j]=true;
			que.push(P(i,j));
			while(!que.empty()) {
				P p=que.front(); que.pop();
				int ci=p.first,cj=p.second;
				if(c[ci][cj]=='#') b++;
				else w++;
				rep(d,4) {
					if(!can(ci,cj,d)) continue;
					int ny=ci+dy[d],nx=cj+dx[d];
					if(used[ny][nx]) continue;
					used[ny][nx]=true;
					que.push(P(ny,nx));
				}
			}
			ans+=b*w;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}



void func()
{ 
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  ll red[a],green[b],colorless[c];
  f(i,0,a) cin>>red[i];
  f(i,0,b) cin>>green[i];
  f(i,0,c) cin>>colorless[i];
  sort(red,red+a);
  reverse(red,red+a);
  sort(green,green+b);
  reverse(green,green+b);
  sort(colorless,colorless+c);
  reverse(colorless,colorless+c);

  vll v;
  ll ans=0;
  f(i,0,x) 
  {
    v.pb(red[i]);
    ans+=red[i];
  }
  f(i,0,y) 
  {
    v.pb(green[i]);
    ans+=green[i];
  }
  sort(ALL(v));
  ll sm1=0,sm2=0,mx=ans;
  f(i,0,min(x+y,c))
  {
    sm1+=v[i];
    sm2+=colorless[i];
    mx=max(mx,ans-sm1+sm2);
  }
  cout<<mx<<endl;
} 

int main() 
{
    //fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/
    
    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }
 
    return 0;
}

Measured memory_bytes: 4724
N,M=map(int,input().split())
if (M == 0):
    print(0,0)
    exit()
wacount = [0] * N
account = [0] * N
for idx in range(M):
    p,s=input().split()
    if (s =="WA" and account[int(p) -1] == 0):
        wacount[int(p) -1] += 1
    if (s == 'AC' and account[int(p)-1] == 0):
        account[int(p) -1] += 1

for idx in range(N):
    if (account[idx] == 0):
        wacount[idx] = 0
print(sum(account),sum(wacount))

Measured memory_bytes: 4596
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) cout << "bust\n";
	else cout << "win\n";
	return 0;
}

Measured memory_bytes: 256
N = input()
H_list = [int(i) for i in input().split()]
max_count = 0
count = 0
prev_n = 0
for h in H_list:
    if h > prev_n:
        # stop
        if count > max_count:
            max_count = count
        count = 0
    else:
        count += 1
    prev_n = h
if count > max_count:
    max_count = count
print(max_count)


Measured memory_bytes: 14252
#include <stdio.h>
#include <math.h>
typedef struct team{
    int ban;
    int m1;
    int s1;
    int m2;
    int s2;
    int m3;
    int s3;
    int m4;
    int s4;
}P;
int goukei(int m1,int s1,int m2,int s2,int m3,int s3,int m4,int s4);
int main(){
    int i,n,t;
    int result;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        int skiroku[n+1];
        P data[n+1];
        for(i=0;i<n;i++){
            scanf("%d %d %d %d %d %d %d %d %d",&data[i].ban,&data[i].m1,&data[i].s1,&data[i].m2,&data[i].s2,&data[i].m3,&data[i].s3,&data[i].m4,&data[i].s4);
            result=goukei(data[i].m1,data[i].s1,data[i].m2,data[i].s2,data[i].m3,data[i].s3,data[i].m4,data[i].s4);
            skiroku[i]=result;
        }
        int work;
        for(i=0;i<n;i++){
            for(t=i+1;t<n;t++){
                if(skiroku[i]>skiroku[t]){
                    work=data[i].ban;
                    data[i].ban=data[t].ban;
                    data[t].ban=work;
                    work=skiroku[i];
                    skiroku[i]=skiroku[t];
                    skiroku[t]=work;
                }
            }
        }
        printf("%d\n%d\n%d\n",data[0].ban,data[1].ban,data[n-2].ban);
    }
    return 0;
}
int goukei(int m1,int s1,int m2,int s2,int m3,int s3,int m4,int s4){
    int byou;
    byou=m1*60+s1+m2*60+s2+m3*60+s3+m4*60+s4;
    return byou;
}

Measured memory_bytes: 792