akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,K = MI()
print(N-K+1)


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

int main() {
    long long N;
    cin >> N;
    char a, b;
    string s;
    cin >> s;
    int cW = 0;
    int cR = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (s.at(i) == 'R') {
            cR ++;
        }
        
    }
    for (int i = 0; i < cR; i++) {
        if (s.at(i) == 'W') {
            ans ++;
        }
        
    }
    cout << ans << endl;
 
    
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h,w;
char s[2005][2005];
int ho[2005][2005];
int vi[2005][2005];
int ans;
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                if(j==0){
                    ho[i][j]=1;
                }else{
                    ho[i][j]=ho[i][j-1]+1;
                }
            }else{
                ho[i][j]=0;
            }
        }
        for(int j=w-1;j>=0;j--){
            if(ho[i][j+1]>0&&s[i][j]=='.') ho[i][j]=ho[i][j+1];
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(s[j][i]=='.'){
                if(j==0){
                    vi[j][i]=1;
                }else{
                    vi[j][i]=vi[j-1][i]+1;
                }
            }else{
                vi[j][i]=0;
            }
        }
        for(int j=h-1;j>=0;j--){
            if(vi[j+1][i]>0&&s[j][i]=='.') vi[j][i]=vi[j+1][i];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.') ans=max(ans,ho[i][j]+vi[i][j]-1);
        }
    }
    cout<<ans<<endl;
    
}


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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 1e5+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;

int n, l, a[N];
ll p[N];
int main (){
 ios_base
 cin >> n >> l;
 for(int i = 1; i <= n; i ++){
  cin >> a[i];
  p[i] = a[i] + p[i-1]; 
 }
 int start = 0;
 vector <int> v;
 int c = 0;
 for(int i = 1; i < n; i ++){
  if(a[i] + a[i+1] >= l) c = i;
 }
 if(c == 0) return cout << "Impossible", 0;
 cout << "Possible" << endl;
 for(int i = 1; i < c; i ++){
  cout << i << endl;
 }
 for(int i = n - 1; i > c; i --){
  cout << i << endl;
 }
 cout << c << endl;
 return  0;
}



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

int main() { 
    ios_base::sync_with_stdio(false);
    ll r;
    cin >> r;
    if(r < 1200) {
        cout << "ABC\n";
    } else if (r < 2800) {
        cout << "ARC\n";
    } else {
        cout << "AGC\n";
    }
    return 0; 
}

Measured memory_bytes: 256
s=input()
strdata=list(s)
data=list(map(int,strdata))
FF=10*data[0]+data[1]
LL=10*data[2]+data[3]
if FF==0 and 0<LL and LL<13:
    print("YYMM")
elif LL==0 and 0<FF and FF<13:
    print("MMYY")
elif 12<FF and LL<13 and 0<LL:
    print("YYMM")
elif 12<LL and FF<13 and 0<FF:
    print("MMYY")
elif FF<13 and LL<13 and 0<FF and 0<LL:
    print("AMBIGUOUS")
else:
    print("NA")


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

int main(void){
    stack<int> s[1010];
    int n, q;
    cin >> n >> q;
    for(int i=0; i<q; i++){
        int num, t, x;
        cin >> num;
        if(num==0){
            cin >> t >> x;
            s[t].push(x);
        }
        else if(num==1){
            cin >> t;
            if(s[t].size()>0)
            cout << s[t].top() << "\n";
        }
        else{
            cin >> t;
            if(s[t].size()>0)
            s[t].pop();
        }
    }
    
    return 0;
}



Measured memory_bytes: 4296
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
	int l, r;
	scanf("%d%d", &l, &r);
	if(r - l <= 5000) {
		long long ans = 1e18;
		for(int i = l; i <= r; i ++) {
			for(int j = i + 1; j <= r; j ++) {
				ans = min(ans, i * 1ll * j % 2019);
			}
		}
		printf("%lld\n", ans);
	} else {
		long long ans = 1e18;
		for(int i = 0; i < 2019; i ++) {
			for(int j = 0; j < 2019; j ++) {
				ans = min(ans, i * 1ll * j % 2019);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

int K, A, B;

bool solve() {
    if (A%K == 0 || B%K == 0) return true;
    if (A/K != B/K) return true;
    return false;
}

int main() {
    cin >> K >> A >> B;
    cout << (solve() ? "OK" : "NG") << endl;
}

Measured memory_bytes: 3580
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

typedef pair<int,int> P;


signed main(void){
  int N,M;
  vector<P> a;
  vector<P> c;
  P buf;
  cin >> N >> M;
  vector<int> count;

  for(int i = 0; i < N; i++){
    cin >> buf.first >> buf.second;
    a.push_back(buf);
  }

  for(int i = 0; i < M; i++){
    cin >> buf.first >> buf.second;
    c.push_back(buf);
    count.push_back(0);
  }

  for(int i = 0; i < N; i++){
    int md = 1000000000;
    int argmin = -1;
    for(int j = 0; j < M; j++){
      int md_ = abs(a[i].first - c[j].first) + abs(a[i].second - c[j].second);
      if( md > md_){
        md = md_;
        argmin = j;
      }
    }
    cout << argmin+1 << "\r\n";
  }


  return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    char b;

    cin >> b;

    if (b == 'A'){
        OUT('T')
    } else if (b == 'T'){
        OUT('A')
    } else if (b == 'G') {
        OUT('C')
    } else {
        OUT('G')
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int v[200010], ap[200010];
int cover[200010];

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n, m;
    scanf ("%d %d", &n, &m);

    for (int i = 1; i <= n; ++i)
    {
        scanf ("%d", &v[i]);
        ++ap[v[i]];
    }

    for (int i = 1; i <= n; ++i)
        for (int j = i - ap[i]; j < i; ++j)
            ++cover[max (0, j)];

    int nr = 0;
    for (int i = 0; i < n; ++i)
        if (!cover[i]) ++nr;

    for (; m; --m)
    {
        int x, y;
        scanf ("%d %d", &x, &y);

        int ex = v[x];
        v[x] = y;

        ++ap[y];
        if ((++cover[max (0, y - ap[y])]) == 1) --nr;
        if ((--cover[max (0, ex - ap[ex])]) == 0) ++nr;
        --ap[ex];

        printf ("%d\n", nr);
    }

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> t(n+1);
	vector<int> x(n+1);
	vector<int> y(n+1);
	rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
	int prex = 0;
	int prey = 0;
	bool ok = false;
	rep(i,n){
		int dist = abs(x[i+1] -x[i]) + abs(y[i+1] - y[i]);
		int deltat = abs(t[i+1] - t[i]);
		if(dist > deltat){
			cout << "No" << endl;
			return 0;
		} 
		else{
			if(dist%2 == 1 && deltat%2 == 1) ok = true;
			// if(dist%2 == 0 && deltat%2 == 0) ok = true;
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 4524
#include <iostream>
#include <string>

using namespace std;

int main() {
    string b;
    cin >> b;
    if (b == "A") cout << "T" << endl;
    if (b == "T") cout << "A" << endl;
    if (b == "C") cout << "G" << endl;
    if (b == "G") cout << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int a_max = 0;
  int a_min = 1000;

  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (a_max < a) a_max = a;
    if (a_min > a) a_min = a;
  }

  cout << a_max - a_min << endl;

  return 0;
}


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


int main(){

    int n,h[100000],i,j=0,max=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",h+i);
    }

    for(i=0;i<n-1;i++){
        if(h[i]<h[i+1]){
            if(max<j){
            max=j;
            }
            j=0;
        }else{
            j++;
        }
    }
    if(max<j){
            max=j;
            }
    printf("%d\n",max);

    return 0;
}

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

typedef long long ll;

int main() {
	vector< ll > a(2),  b(2);
	cin >> a[0] >> a[1] >> b[0] >> b[1];
	ll ans = -2e18 - 100;
	for (int i=0; i<2; i++) {
		for (int j=0; j<2; j++) {
			ans = max(ans, a[i]*b[j]);
			}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

int N,M1,M2;
int as[30],bs[30];
char field[6][6][6];
int main(){
  const int size=5;
  int t=1;
  while(cin>>N&&N){
    if(t!=1)cout<<endl;
    for(int i=0;i<size;i++)
      for(int j=0;j<size;j++)
        for(int k=0;k<size;k++)
          cin>>field[i][j][k];
    cin>>M1;
    for(int i=0;i<M1;i++)cin>>as[i];
    cin>>M2;
    for(int i=0;i<M2;i++)cin>>bs[i];
    vector<int> dy,dx,dz;
    for(int i=-1;i<=1;i++){
      for(int j=-1;j<=1;j++){
        for(int k=-1;k<=1;k++){
          if(!(i==0&&j==0&&k==0)){
            dx.push_back(i);
            dy.push_back(j);
            dz.push_back(k);
          }
        }
      }
    }
    for(int a=0;a<N;a++){
      char nxtField[6][6][6];
      for(int i=0;i<size;i++){
        for(int j=0;j<size;j++){
          for(int k=0;k<size;k++){
            int cnt=0;
            for(int l=0;l<(int)dx.size();l++){
              int nz=dz[l]+i;
              int ny=dy[l]+j;
              int nx=dx[l]+k;
              if(nz>=0&&nx>=0&&ny>=0
                 &&nz<size&&ny<size&&nx<size)
                if(field[nz][ny][nx]=='1')
                  cnt++;
            }
            if(field[i][j][k]=='0'){
              bool ok=false;
              for(int l=0;l<M1;l++){
                if(as[l]==cnt){
                  ok=true;
                  break;
                }
              }
              if(ok)nxtField[i][j][k]='1';
              else nxtField[i][j][k]='0';
            }
            else{
              bool ok=false;
              for(int l=0;l<M2;l++){
                if(bs[l]==cnt){
                  ok=true;
                  break;
                }
              }
              if(ok)nxtField[i][j][k]='1';
              else nxtField[i][j][k]='0';
            }
          }
        }
      }
      for(int i=0;i<size;i++)
        for(int j=0;j<size;j++)
          for(int k=0;k<size;k++)
            field[i][j][k]=nxtField[i][j][k];
    }
    cout<<"Case "<<t++<<":"<<endl;
    for(int i=0;i<size;i++){
      for(int j=0;j<size;j++){
        for(int k=0;k<size;k++){
          cout<<field[i][j][k];
        }
        cout<<endl;
      }
      if(i!=size-1)
        cout<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,a=0;
    string S;
    cin >> N >>S;
    for(int i=0;i<S.size()-2;i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    a++;
                }
            }
        }
    }
    cout << a;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> h(N);
	vector<int> dp(N);//dp[i] を求めるにはdp[i - 1], dp[i - 2]が必要
	for(int i = 0; i < N; i++) cin >> h.at(i);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < N; i++){
		dp[i] = min(dp[i- 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[1005],t[1005];
int main(){
	scanf("%s",s);
	scanf("%s",t);
	int len1=strlen(s),len2=strlen(t),i,j,minn=2147483647;
	for(i=0;i<len1-len2+1;i++){
		int sum=0;
		for(j=0;j<len2;j++){
			if(s[i+j]!=t[j]){
				sum++;
			}
		}
		minn=min(minn,sum);
	}
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    ll n,m;cin>>n>>m;
    ll res=(1900*m)+100*(n-m);
    for(int i=0;i<m;i++) res*=2;
    cout<<res<<endl;
}


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

#define ll long long
#define MAXN (100010)

int N;
ll C;
ll x[MAXN];
ll v[MAXN];
ll suml[MAXN], sumr[MAXN];
ll l[MAXN], r[MAXN];

int main()
{
    scanf("%d%lld", &N, &C);
    for (int i = 1; i <= N; ++ i) {
        scanf("%lld%lld", x + i, v + i);
    }
    ll ans = 0;
    x[0] = 0;
    x[N + 1] = C;
    for (int i = 1; i <= N; ++ i) {
        suml[i] = suml[i - 1] - x[i] + x[i - 1] + v[i];
        ans = std::max(ans, suml[i]);
    }
    suml[0] = INT_MIN;
    for (int i = 1; i <= N; ++ i) {
        suml[i] = std::max(suml[i], suml[i - 1]);
        l[i] = std::max(suml[i] - x[i], l[i - 1]);
    }
    for (int i = N; i; -- i) {
        sumr[i] = sumr[i + 1] - x[i + 1] + x[i] + v[i];
        ans = std::max(ans, sumr[i]);
    }
    sumr[N + 1] = INT_MIN;
    for (int i = N; i; -- i) {
        sumr[i] = std::max(sumr[i], sumr[i + 1]);
        r[i] = std::max(sumr[i] - (C - x[i]), r[i + 1]);
    }
    for (int i = 1; i < N; ++ i) {
        ans = std::max(ans, l[i] + sumr[i + 1]);
    }
    for (int i = N; i > 1; -- i) {
        ans = std::max(ans, r[i] + suml[i - 1]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	vi a(n);
	FOR(i,0,n){in(a[i]);}
	int total = 0;
	FOR(i,0,n-1)FOR(i1,i+1,n)total+=a[i]*a[i1];
	out(total);
	return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int ans = min(B, D) - max(A, C);
    if (ans > 0){
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}

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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    string N;
    int K;
    cin >> N >> K;
    const auto FC = [](int N, int M) {
        if (N < 0 || N > M) return 0ll;
        //assert(0 <= N && N <= M);
        ll rt = fpow(9, N);
        N = min(N, M-N);
        Fr(i, 0, N) rt = rt*(M-i)/(i+1);
        return rt;
    };
    function<ll(string, int)> solve;
    solve = [&](string N, int K) {
        if (N.empty() || K == 0) return 0ll;
        //cerr _ N[0]-'0'-1 _ N.size() _ K _ FC(K-1,N.size()-1) _ FC(K,N.size()-1) _ endl;
        int sz = N.size();
        int j = 1; while (j < sz && N[j] == '0') j++;
        return solve(N.substr(j), K-1) + (N[0]-'1')*FC(K-1,sz-1) + FC(K,sz-1);
    };
    int cnt = 0;
    for(char c: N) cnt += c != '0';
    cout << solve(N, K) + (cnt >= K) << endl;

}


Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  int n = getInt();
  int a = getInt();
  int b = getInt();
  int c = getInt();
  vector<int> v;
  REP(i,n) v.push_back(getInt());
  sort(v.rbegin(), v.rend());

  int ans = c / a;
  REP(i,n){ c += v[i]; ans = max(ans, c / (a + b + i * b)); }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 0
n,m=map(int,input().split())

if n>=2 and m>=2:
    print((n-2)*(m-2))

elif n==1 and m>1:
    print(m-2)

elif m==1 and n>1:
    print(n-2)
    
elif n==1 and m==1:
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;

    string u;
    cin >> u;
    if (u == s) {
        a--;
    } else {
        b--;
    }

    cout << a << " " << b << endl;

    return 0;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int n, m;
  cin >> n >> m;
  vi a(m);
  rep (i, m) {
    cin >> a[i];
  }

  if (m <= 2) {
    vi b = a;
    if (b.size() == 1) b.push_back(0);
    b[0]--; b.back()++;
    if (b[0] == 0) b.erase(b.begin());
    
    rep (i, m) cout << a[i] << " ";
    cout << endl;
    
    cout << b.size() << endl;
    rep (i, b.size()) {
      cout << b[i] << " ";
    }
    cout << endl;
    return 0;
  }
    
    

  int cnt = 0;
  rep (i, m) {
    cnt += a[i] % 2;
  }

  if (cnt > 2) {
    cout << "Impossible" << endl;
    return 0;
  }

  vi b_odd, b_even;
  rep (i, m) {
    if (a[i] % 2) b_odd.push_back(a[i]);
    else b_even.push_back(a[i]);
  }
  
  vi b;
  if (b_odd.size()) {
    b.push_back(b_odd[0]);
    b_odd.erase(b_odd.begin());
  }
  rep (i, b_even.size()) b.push_back(b_even[i]);
  if (b_odd.size()) {
    b.push_back(b_odd[0]);
    b_odd.erase(b_odd.begin());
  }
  
  rep (i, b.size()) {
    cout << b[i] << " ";
  }
  cout << endl;

  b[0]--;
  b.back()++;
  if (b[0] == 0) b.erase(b.begin());
  cout << b.size() << endl;
  rep (i, b.size()) {
    cout << b[i] << " ";
  }
  cout << endl;
    
  
}


Measured memory_bytes: 256
s = input().strip()

start = '0'
ans = 0
for idx, c in enumerate(s):
    if idx % 2 == 0 and c != start:
        ans += 1
    elif idx % 2 != 0 and c == start:
        ans += 1

start = '1'
ans1 = 0
for idx, c in enumerate(s):
    if idx % 2 == 0 and c != start:
        ans1 += 1
    elif idx % 2 != 0 and c == start:
        ans1 += 1
    
print(min(ans, ans1))


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

using namespace std;

int main() {

    int N; cin >> N;
    vector<int> p(N);

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

    sort(p.begin(), p.end());

    int ans = 0;
    for (int j = 0; j < N - 1; ++j) {
        ans += p[j];
    }

    ans += p[N-1] / 2;

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 40408
#include<iostream>
#include<cstdio>
#include<cstring>
#define FIRST 735224;
using namespace std;
bool URUDOSHI[10000001];
void YEAR(){
  for(int i=0;i < 10000001;i++){
    if(i % 400 == 0 || (i % 100 != 0 && i % 4 == 0)){
      URUDOSHI[i] = true;
    } else {
      URUDOSHI[i] = false;
    }
  }
}
int main(){
  YEAR();
  long long a,b,c,d,e,cnt,day;
  char str[111];
  while(1){
    cnt = 0;
    cin >> str;
    if(strcmp(str,"#")==0) break;
    for(int i=0,l=strlen(str);i<l;i++){
      if(str[i] == '.')cnt++;
    }
    if(cnt == 2){
      sscanf(str,"%lld.%lld.%lld",&a,&b,&c);
      day = -FIRST;
      for(int i=0;i<a;i++)
	day += (URUDOSHI[i]==true ? 366 : 365);
      day %= 1872000;
      for(int i=1;i<b;i++){
	if(i==4||i==6||i==9||i==11)day+=30;
	else if(i==2){
	  if(URUDOSHI[a]==true) day+=29;
	  else day+=28;
	}else day+=31;
      }
      day+=c;
      day %= 1872000;
      cout << day/144000 << "." << day%144000/7200 << "." <<
	day%7200/360 << "." << day%360/20 << "." << day%20 << endl; 
    }else{
      sscanf(str,"%lld.%lld.%lld.%lld.%lld",&a,&b,&c,&d,&e);
      day = a * 144000 + b * 7200 + c * 360 + d * 20 + e;
      day += FIRST;
      long long y=0,m=1,dday;
      for(dday=0;dday<day;y++){
	dday += (URUDOSHI[y]==true ? 366 : 365);
      }
      y--;
      day = (URUDOSHI[y]==true ? 366:365) + (day - dday);
      for(dday=0;dday<day;m++){
	if(m==4||m==6||m==9||m==11)dday+=30;
	else if(m==2){
	  if(URUDOSHI[y]==true) dday+=29;
	  else dday+=28;
	}else dday+=31;
      }
      m--;
      day = ((m==4||m==6||m==9||m==11)?30:
	     (m==2?(URUDOSHI[y]==true?29:28):31))+(day-dday);
      cout << y << "." << m << "." << day << endl;
    }
  }
}
    

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

#define SIZE 100

void bubbleSort(int n, int* A){
	bool flag = true;
	int tmp;
	int count = 0;
	
	while(flag){
		flag = false;
		for(int i = n - 1; i > 0; --i){
			if(A[i] < A[i - 1]) {
				tmp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = tmp;
				flag = true;
				++count;
			}
		}
	}
	
	for(int i = 0; i < n; ++i){
		if(i != n - 1)
			cout << A[i] << ' ';
		else
			cout << A[i] << endl;
	}
	cout << count << endl;

}

int main(void){
	int n;
	int A[SIZE];
	
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> A[i];
	
	bubbleSort(n, A);
	
	return 0;
}


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

int main() {
	long long a[5];
	long long i;
	for(i=0; i<5; i++)
	{
		cin >> a[i];
		if(a[i]!=i+1)
		{
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>
#include <iostream>

using namespace std;

constexpr int mod = 998244353;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string dat;
  cin >> dat;
  vector<int> r, g, b;
  for (int i = 0; i < 3 * n; i++) {
    if (dat[i] == 'R') r.push_back(i);
    else if (dat[i] == 'G') g.push_back(i);
    else b.push_back(i);
  }
  vector<int> sign(3*n);
  for (int i = 0; i < n; i++) {
    int left = min(r[i], min(g[i], b[i]));
    int right = max(r[i], max(g[i], b[i]));
    sign[left] = -1;
    sign[right] = 1;
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) ans = (ans*i) % mod;
  int rp = 0, gp = 0, bp = 0;
  int rm = 0, gm = 0, bm = 0;
  for (int i = 0; i < 3*n; i++) {
    if (sign[i] == -1) {
      if (dat[i] == 'R') rp++;
      else if (dat[i] == 'G') gp++;
      else bp++;
    } else if (sign[i] == 1) {
      if (dat[i] == 'R') {
        ans *= gm + bm; ans %= mod;
        if (gm) gm--; else bm--;
      }
      else if (dat[i] == 'G') {
        ans *= rm + bm; ans %= mod;
        if (rm) rm--; else bm--;
      }
      else {
        ans *= rm + gm; ans %= mod;
        if (rm) rm--; else gm--;
      }
    } else {
      if (dat[i] == 'R') {
        ans *= gp + bp; ans %= mod;
        if (gp) gp--; else bp--;
        rm++;
      }
      else if (dat[i] == 'G') {
        ans *= rp + bp; ans %= mod;
        if (rp) rp--; else bp--;
        gm++;
      }
      else {
        ans *= rp + gp; ans %= mod;
        if (rp) rp--; else gp--;
        bm++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


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

long long N, K, Q;
long long point[100005];

int main(){
	cin >> N >> K >> Q;
	for(long long i = 0; i < Q; i++){
		long long win;
		cin >> win;
		win--;
		point[win]++;
	}

	long long num = 0;
	for(long long i = 0; i < N; i++){
		point[i] = K - Q + point[i];
		if(point[i] <= 0){
			cout << "No" << endl;
		}else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

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

    ll a[N];
    REP(i,N){
        cin >> a[i];
    }


    ll ans = 0;
    REP(i,N){
        ans += a[i]-1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
if(w>=(x+r)&&h>=(y+r)&&(x-r)>=0&&(y-r)>=0){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}


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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int ans;
  string s;
  
  cin >> s;
  ans = s.length();
  for (char c='a'; c<='z'; c++){
    int left, len;
    left = -1; len = 0;
    for (int i=0; i<s.length(); i++){
      if (s[i]==c){
        len = MAX(len,i-left-1);
        left = i;
      }
    }
    len = MAX(len,s.length()-left-1);
    ans = MIN(ans, len);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#include<algorithm>
int main()
{
	int n,i,j,k,t[16][17],m;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)for(j=0;j<=n;++j)scanf("%d",&t[i][j]);
		int x[1<<16];
		std::fill(x,x+(1<<16),INT_MAX);
		x[0]=0;
		for(i=1;i<(1<<n);++i)
		{
			for(j=0;j<n;++j)if(i&(1<<j))
			{
				m=t[j][0];
				for(k=0;k<n;++k)if((i^(1<<j))&(1<<k))m=std::min(m,t[j][k+1]);
				x[i]=std::min(x[i],x[i^(1<<j)]+m);
			}
		}
		printf("%d\n",x[(1<<n)-1]);
	}
	return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    cout << "Yes" <<endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 5005
#define ll long long
// #define mod 23333333333333333ll
int n,a[N],num,K;ll f[N];
// bool check(double x,double y){if(abs(x-y)<1e-6)return 1;return 0;}
bool check(int i)
{
	int ret=0;
	for(int j=a[i];j<=K;j++)f[j]=f[j]-f[j-a[i]];
	for(int j=K-1;j>=K-a[i];j--)
		if(f[j])ret=1;
	for(int j=K;j>=a[i];j--)f[j]=f[j]+f[j-a[i]];
	return ret;
}
int main()
{
	// freopen("Num.in","r",stdin);freopen("Num.out","w",stdout);
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);if(a[i]>=K)i--,n--;}
	f[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=K;j>=a[i];j--)
			f[j]=f[j]+f[j-a[i]];
	// printf("%.0f %.0f %.0f\n",f[K],f[K-1],f[K-2]);
	for(int i=1;i<=n;i++)if(!check(i))num++;
	printf("%d\n",num);
}
/*
10 10
1 1 1 1 1 1 1 1 1 1
*/
/*
800 400
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    cout << n*n*n << endl;
}


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

int main()
{
  vector<int> v(3);
  int k;
  for (int i = 0; i < 3; i++)
  {
    cin >> v[i];
  }
  cin >> k;
  sort(v.begin(), v.end());
  for (int i = 0; i < k; i++)
  {
    v[2] *= 2;
  }
  cout << v[0] + v[1] + v[2] << endl;
}


Measured memory_bytes: 3640
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        char[] s = in.ns().toCharArray();
        long ans;
        ArrayDeque<Integer> deq = new ArrayDeque<>();
        for (int i = 0; i < s.length; i++) {
            if(i==n-1) deq.add(1);
            else{
                if(s[i]==s[i+1]){
                    deq.add(2);
                    i++;
                }else{
                    deq.add(1);
                }
            }
        }
        boolean last1;
        if(deq.poll()==1){
            ans = 3;
            last1 = true;
        }else{
            ans = 6;
            last1 = false;
        }
        while(!deq.isEmpty()){
            int x = deq.poll();
            if(last1){
                ans *= 2;
                ans %= mod;
            }else{
                if(x==2){
                    ans *= 3;
                    ans %= mod;
                }
            }
            last1 = x==1;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N,M;cin >> N >> M;
    ll y=0;
    pair<ll,ll> A[100007];
    rep(i,N){
        cin >> A[i].first >> A[i].second;
    }
    psortfirst(A,N)
    rep(i,N){
        if(M>A[i].second){
            y+=A[i].first*A[i].second;
            M-=A[i].second;
        }
        else{
            y+=M*A[i].first;
            cout << y << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    D = {9: 1, 8: 2, 7: 3, 6: 4, 5: 5, 4: 6, 3: 7, 2: 8}
    X = int(input())
    print(D[X//200])


Measured memory_bytes: 9188
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

ab = Is()
if 0 < ab[0] < 10 and 0 < ab[1] < 10:
    print(ab[0] * ab[1])
else:
    print(-1)

Measured memory_bytes: 4584
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
		Scanner in = new java.util.Scanner(System.in);
		String X = in.nextLine();

		if((short)X.charAt(0) >= (short)'a') {
			System.out.println('a');
		}else {
			System.out.println('A');
		}
		in.close();
	}
}


Measured memory_bytes: 35696
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

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

  bool flg = true;
  for(int i=0;i<n/2;i++){
    if(s[i] != s[i+n/2]){
      flg = false;
      break;
    }
  }

  if(n%2==1) cout << "No" << "\n";
  else if(flg==true) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, ans, a[N], p[N];
vector <int> v, b[5];

int main(){
      scanf("%d", &n);

      for(int i = 1; i <= n; i ++){
            scanf("%d", &a[i]);
            v.pb(a[i]);
      }

      sort(v.begin(), v.end());

      for(int i = 1; i <= n; i ++){
            a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
            p[a[i]] = i;
            if(i % 2){
                  if(a[i] % 2) b[1].pb(a[i]);
                  else b[2].pb(a[i]);
            } else {
                  if(a[i] % 2) b[3].pb(a[i]);
                  else b[4].pb(a[i]);
            }
      }

      cout << max(b[2].size(), b[3].size()) << endl;
}


Measured memory_bytes: 2168
N=int(input())
A=list(map(int,input().split()))
#A=int(input().split())
#print(A)
B=[ 0 for _ in range(N)]
#print(B)
ans=""
for i in range(N):
  B[A[i]-1]=i+1
#  ans+=str(A.index(i+1)+1)
#  if i!=N-1:

for i in range(N):
  ans+=str(B[i])
  if i!=N-1:
    ans+=" "
#print(B)
print(ans)

Measured memory_bytes: 14008
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
void f(int rest, string s){
  if(rest==0)cout<<s<<endl;
  else for(char c='a';c<='c';c++) f(rest-1,s+c);
  }
int main(){
  ll n,k;cin >>n>>k;
  if((n-k)%(k-1)==0) cout <<(n-k)/(k-1)+1<<endl;
  else cout<<(n-k)/(k-1)+2<<endl;
}

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

int main(){
int N, T;
int sum = 0;
  cin >> N >> T;
int t[N];
  for(int i = 0;i < N;i++){
  cin >> t[i];
  }
  
  for(int i = 0;i < N;i++){
  if(i == 0){
  if(T <= t[i+1]){
  sum += T;
  }
    else{
    sum += t[i+1];
    }
  }
  else if(t[i] + T <= t[i+1]) {
  sum += T;
  }
  else if(i == N-1){
  sum += T;
  }
  else{
  sum += t[i+1] - t[i];
  }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	N = len(S)
	judge = "Yes"
	s = int((N - 3) // 2)
	t = int((N + 1) // 2)
	for i in range(int((N - 1) // 2)):
		if S[i] != S[s - i]:
			judge = "No"
		if S[t + i] != S[N - 1 - i]:
			judge = "No"

	for i in range(N):
		if S[i] != S[N - 1 - i]:
			judge = "No"

	print(judge)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 3e5 + 5;
int main() {
    abdelrahman010
    int x;
    cin >> x;
    if(x <= 599)
        cout << "8";
    else if(x <= 799)
        cout << "7";
    else if(x <= 999)
        cout << "6";
    else if(x <= 1199)
        cout << "5";
    else if(x <= 1399)
        cout << "4";
    else if(x <= 1599)
        cout << "3";
    else if(x <= 1799)
        cout << "2";
    else if(x <= 1999)
        cout << "1";
    return 0;
}


Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//???????????¨???????????¨??????
public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int dataSet = sc.nextInt(); //??????????????°
		String text = null;

		for(int $ = 0; $ < dataSet; $++) {
			text = sc.next();
			boolean flag = false;
			List<Character> dataList = new ArrayList<Character>();
			char[] word = text.toCharArray();
			char alpha = ' ';
			int n = 0;
			int alphaNum = 0;
			for(int i = 0; i < word.length; i++) {
				if((i % 3) == 0) {
					if(flag) {
						if((n = dataList.indexOf(word[i])) < 0) {
							alphaNum = dataList.indexOf(alpha);
							dataList.add(alphaNum, word[i]);
						}
						alpha = word[i];
					} else {
						if((n = dataList.indexOf(word[i])) < 0 && (alpha == ' ')) {
							dataList.add(word[i]);
						} else if(n < 0) {
							alphaNum = dataList.indexOf(alpha);
							dataList.add(alphaNum + 1, word[i]);
						}
						alpha = word[i];
					}
				} else if(i % 3 == 2) {
					continue;
				} else {
					if(word[i] == '<') {
						flag = true;
					} else {
						flag = false;
					}
				}
			}
			for(int i = 0; i < dataList.size(); i++) {
				System.out.print(dataList.get(i));
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 28148