akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    switch (a)
    {
    case 1:
        switch (b)
        {
        case 2:
            cout << 3;
            break;
        case 3:
            cout << 2;
            break;
        }
        break;
    case 2:
        switch (b)
        {
        case 1:
            cout << 3;
            break;
        case 3:
            cout << 1;
            break;
        }
        break;
    case 3:
        switch (b)
        {
        case 1:
            cout << 2;
            break;
        case 2:
            cout << 1;
            break;
        }
        break;
    }
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(ll i=(ll)(m) - 1;i>=(ll)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int d;
  ci(d);
  ve<int> C(26);
  ve<ve<int>> S(d, ve<int>(26));
  ve<int> T(d);
  rep(i, 26){
    ci(C.at(i));
  }
  rep(i, d){
    rep(j, 26){
      ci(S.at(i).at(j));
    }
  }
  rep(i, d){
    ci(T.at(i));
  }
  ve<int> L(26, 0);
  ll ans = 0;
  rep(i, d){
    ans += S.at(i).at(T.at(i) - 1);
    L.at(T.at(i) - 1) = i + 1;
    rep(j, 26){
      ans -= C.at(j) * (i + 1 - L.at(j));
    }
    co(ans);
  }
}


Measured memory_bytes: 3648
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int h,w;
string s[10];
int nd=0;
void rec(int x,int y,int cnt)
{
      if(x<0 || y<0 || x>=h || y>=w)return ;
      if(x==h-1 && y==w-1)
      {
          if(s[x][y]=='#')cnt++;
          if(nd==cnt)
          {
              cout<<"Possible"<<endl;
              exit(0);
          }
          return ;
      }
      if(s[x][y]=='#')cnt++;
      rec(x+1,y,cnt);
      rec(x,y+1,cnt);
}
 main()

{
    fast
    cin>>h>>w;
    f(i,0,h-1)cin>>s[i];
    f(i,0,h-1)
    {
        f(j,0,w-1)
        {
            if(s[i][j]=='#')nd++;
        }
    }
    rec(0,0,0);
    cout<<"Impossible"<<endl;
    return 0;

}





































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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int res, ip;
	for (int i = 0; i < 5; i++) {
		cin >> ip;
		if (ip == 0)
			res = i+1;
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	char a,b,c;
	int s=0;
	cin>>a>>b>>c;
	if(a=='A'||b=='A'||c=='A')s++;
	if(a=='B'||b=='B'||c=='B')s++;
	if(s<2)cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

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

int n;
double a[60];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 2; i <= n; i++)
    {
        a[i] = (a[i] + a[i-1]) / 2.0;
    }
    cout << a[n] << endl;
    return 0;
}

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

using namespace std;

const int N=1005;

string gr[N];
int dis[N][N];
int n,m,a,b,x,y;

int main()
{
	scanf("%d %d",&n,&m);
	scanf("%d %d %d %d",&a,&b,&x,&y);
	a--; b--; x--; y--;
	for(int i=0;i<n;i++)
	{
		cin >> gr[i];
	}
	deque<pair<int,int> > q;
	q.push_front({a,b});
	memset(dis,-1,sizeof dis);
	dis[a][b]=0;
	while(q.size())
	{
		int cx=q.front().first,cy=q.front().second;
		q.pop_front();
		for(int dx=-1;dx<=1;dx++)
		{
			for(int dy=-1;dy<=1;dy++)
			{
				int nx=cx+dx,ny=cy+dy;
				if(abs(dx)+abs(dy)!=1) continue;
				if(nx<0||ny<0||nx>=n||ny>=m||gr[nx][ny]=='#') continue;
				if(dis[nx][ny]==-1||dis[cx][cy]<dis[nx][ny])
				{
					dis[nx][ny]=dis[cx][cy];
					q.push_front({nx,ny});
				}
			}
		}
		for(int dx=-2;dx<=2;dx++)
		{
			for(int dy=-2;dy<=2;dy++)
			{
				int nx=cx+dx,ny=cy+dy;
				if(nx<0||ny<0||nx>=n||ny>=m||gr[nx][ny]=='#') continue;
				if(dis[nx][ny]==-1||dis[cx][cy]+1<dis[nx][ny])
				{
					dis[nx][ny]=1+dis[cx][cy];
					q.push_back({nx,ny});
				}
			}
		}
	}
	cout << dis[x][y] << endl;
}

Measured memory_bytes: 9524
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();

    //start with plus
    let mut cnt1: i64 = 0;
    let mut sum = a[0];
    if sum <= 0 {
        cnt1 += 1 - sum;
        sum = 1;
    }
    for i in 1..n {
        if sum > 0 {
            if a[i] + sum < 0 {
                sum += a[i];
            } else {
                cnt1 += a[i] + sum + 1;
                sum = -1;
            }
        } else {
            if a[i] + sum > 0 {
                sum += a[i];
            } else {
                cnt1 += 1 - sum - a[i];
                sum = 1;
            }
        }
    }

    //start with minus
    let mut cnt2: i64 = 0;
    let mut sum = a[0];
    if sum >= 0 {
        cnt2 += 1 + sum;
        sum = -1;
    }
    for i in 1..n {
        if sum > 0 {
            if a[i] + sum < 0 {
                sum += a[i];
            } else {
                cnt2 += a[i] + sum + 1;
                sum = -1;
            }
        } else {
            if a[i] + sum > 0 {
                sum += a[i];
            } else {
                cnt2 += 1 - sum - a[i];
                sum = 1;
            }
        }
    }

    println!("{}", min(cnt1, cnt2));
}


Measured memory_bytes: 8444
#include<stdio.h>

int main(){

    unsigned long ulW_D_inact[100][100];    /* 行列Ａの格納用変数 */

    unsigned long ulW_D_act[100];           /* 行列Ｂの格納用変数 */

    unsigned long ulW_D_ans[100];           /* 積の格納用変数 */

    unsigned short usW_D_row, usW_D_col;          /* 行列の要素数の格納用変数 */

    unsigned short usW_C_i, usW_C_j;              /* ループ変数 */

    /* 配列の初期化 */

    for(usW_C_i = 0;usW_C_i < 100;usW_C_i++){

        for(usW_C_j = 0;usW_C_j < 100;usW_C_j++){

            ulW_D_inact[usW_C_i][usW_C_j] = 0;

        }

        ulW_D_act[usW_C_i] = 0;

        ulW_D_ans[usW_C_i] = 0;

    }

    /* 行列の要素数の入力 */

    scanf("%d %d", &usW_D_row, &usW_D_col);

    /* 行列Ａの入力 */

    for(usW_C_i = 0;usW_C_i < usW_D_row;usW_C_i++){

        for(usW_C_j = 0;usW_C_j < usW_D_col;usW_C_j++){

            scanf("%d", &ulW_D_inact[usW_C_i][usW_C_j]);

        }

    }

    /* 行列Ｂの入力 */

    for(usW_C_i = 0;usW_C_i < usW_D_col;usW_C_i++){

        scanf("%d", &ulW_D_act[usW_C_i]);

    }

    /* ＡとＢの積の計算 */

    for(usW_C_i = 0;usW_C_i < usW_D_row;usW_C_i++){

        for(usW_C_j = 0;usW_C_j < usW_D_col;usW_C_j++){

            /* i番目の積の計算 */

            ulW_D_ans[usW_C_i] += ulW_D_inact[usW_C_i][usW_C_j] * ulW_D_act[usW_C_j];

        }

    }

    /* 積の出力 */

    for(usW_C_i = 0;usW_C_i < usW_D_row;usW_C_i++){

        /* i番目の積の出力 */

        printf("%d\n", ulW_D_ans[usW_C_i]);

    }

    return 0;

}




Measured memory_bytes: 2116
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int [] array = new int[3];
		for (int i = 0;i< array.length;i++) {
			array[i] = sc.nextInt();}
		Arrays.sort(array);
		
		if (array[0] + array[1] == array[2]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35608
#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;
  ll d;
  cin >> n >> d;

  int ans = 0;
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    //距離の計算により、D以上をカウントする
    if (x*x+y*y <= d*d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
def pro(x):
    ret = 1
    for i in range(x):
        ret *= i+1
    return ret


def cal(n, da):
    ju = [False for i in range(n+1)]
    ret = 1
    for i in range(n):
        now, co = 1, 0
        while(now != da[i]):
            if not ju[now]:
                co += 1
            now += 1
        #print(pro(n-1-i),co)
        ret += pro(n-1-i) * co
        ju[da[i]] = True
    #print(ret)
    return ret

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

print(abs(cal(n,p)-cal(n,q)))


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

using namespace std;

int main(void) {
	long long int N, M;

	cin >> N >> M;

	if (2 * N >= M) cout << M / 2 << endl;
	else cout << (2 * N + M) / 4 << endl;
	
	system("pause");

	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  if(s[0]==s[1] && s[1]==s[2])cout<<"Yes"<<endl;
  else if(s[1]==s[2] && s[2]==s[3])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int r, g;
   cin >> r >> g;
   cout << 2 * g - r << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dd double
using namespace std;
const ll MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  dd d,t,s;
  cin>>d>>t>>s;
  dd check=d/s;
  if(check<=t){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }


  return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>
#include<algorithm>
#include<cstdlib>
using namespace std;
struct point{
    int ck, x;
    bool operator<(const point &p)const{
        return x<p.x;
    }
}w[201000];
int n, s;
long long res = 1;
int main(){
    int i, j;
    scanf("%d",&n);
    for(i=0;i<2*n;i++){
        scanf("%d",&w[i].x);
        w[i].ck = i/n;
    }
    sort(w,w+2*n);
    for(i=0;i<2*n;i++){
        int t1 = abs(s), t2;
        s += w[i].ck*2-1;
        t2 = abs(s);
        if(t2 < t1){
            res = res*t1%1000000007;
        }
    }
    printf("%lld\n",res);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

int main() {
	//
	int K, S;
	cin >> K >> S;

	long long ret = 0;
	rep(x, K+1){
		rep(y, K + 1)
		{
			int z = S - x - y;
			if (z >= 0 && z <= K) ret++;
		}
	}

	cout << ret << endl;
}

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

typedef long long ll;

#define rep(var,n) for(int var=0;var<(n);++var)

int main(){
  int n,k;
  cin >> n >> k;
  bool d[10];
  rep(i,10) d[i] = false;
  rep(i,k){
    int buf; cin >> buf;
    d[buf] = true;
  }
  int ans=0;
  for(int i=n;i<100*n;i++){
    string s = to_string(i);
    bool f = true;
    rep(j,s.size()){
      if(d[s[j]-'0']){
        f = false;
        break;
      }
    }
    if(f){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[2] == s[3] && s[2] != s[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

ll n, m;

int main() {
    cin >> n >> m;
    vector<ll> A(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i);
    }

    vector<ll> sumA(n+1, 0);
    for(int i = 0; i < n; ++i) {
        sumA.at(i+1) += sumA.at(i) + A.at(i);
    }
    map<ll, ll> cnt;
    for(int i = 0; i <= n; ++i) {
        ll ch = sumA.at(i) % m;
        cnt[ch]++;
    }

    ll ans = 0;
    for(auto mp : cnt) {
        ll cc = mp.second;
        ans += cc*(cc-1)/2;
    }
    cout << ans << endl;
}

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

int main() {
    int x, y, a, b, c;
    long long ans = 0;
    cin >> x >> y >> a >> b >> c;
    int p[a], q[b], r;
    for(int i = 0; i < a; ++i) cin >> p[i];
    for(int i = 0; i < b; ++i) cin >> q[i];
    vector<int> v;
    for(int i = 0; i < c; ++i) {
        cin >> r;
        v.push_back(r);
    }
    sort(p, p+a);
    sort(q, q+b);
    for(int i = 0; i < x; ++i) v.push_back(p[a-i-1]);
    for(int i = 0; i < y; ++i) v.push_back(q[b-i-1]);
    sort(v.begin(), v.end());
    for(int i = 0; i < x + y; ++i) ans += v[v.size()-i-1];

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;
vector<ll>a;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n;
  a=vector<ll>(n);
  rep(i,n) cin >> a[i];
  
  
  ll right=0 ,ans=0;
  ll s=0;
  rep(left,n){
    while(right<n && (s^a[right])==(s+a[right])){
      s+=a[right];
      right++;
    }
    ans+=(right-left);
    if(right==left)right++;
    else{
      s-=a[left];
    }
  }
  cout << ans << endl;
  return 0;     
}


Measured memory_bytes: 1792
#include <climits>
#include <iostream>
using namespace std;
const int MAX_N = 500000;
int n;
int A[MAX_N];
int count;

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

void mergeSort(int left, int right){
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(mid, right);
		merge(left, mid, right);
	}
}

int main () {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	mergeSort(0, n);
	int i = 0; goto FIRST;
	for (; i < n; i++) {
		cout << ' ';
FIRST:
		cout << A[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}

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

int main(){
  int n,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
  	int a,b;
    cin>>a>>b;
    if(a==b){
    	cnt++;
        if(cnt==3){
        cout<<"Yes";
		return 0;
        }
    }else{
    	cnt=0;
    }
  }
	cout<<"No";
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

const lli mod = 1'000'000'007;
// n^x
lli pw(int n, int x) {
    if (x == 0) return 1LL;
    else if(x % 2) return (n * pw(n, x - 1)) % mod;
    else {
        lli t = pw(n, x / 2);
        return (t * t) % mod;
    }
}

int main() {
    lli H, W, A, B;
    cin >> H >> W >> A >> B;
    const int N = 200020;
    vector<lli> v(N, 1);
    vector<lli> inv(N);
    REP (i, 1, N) v[i] = (i * v[i - 1]) % mod;
    REP (i, 0, N) inv[i] = pw(v[i], mod - 2);
    auto nCr = [&](int n, int r) -> lli {
        return (((v[n] * inv[r]) % mod) * inv[n - r]) % mod;
    };
    vector<lli> mid(H - A, 0);
    REP (i, 0, mid.size()) {
        mid[i] = nCr(B + i, B);
//        dump(mid[i]);
    }
    lli ans = 0;
    lli bef = 0;
    REP (i, 0, mid.size()) {
        ans = (ans + (((mid[i] - bef + mod) % mod) * nCr(H - i + W - B - 2, W - B - 1)) % mod) % mod;
//        dump(ans);
        bef = mid[i];
    }
    cout << ans << endl;
    return 0;
}

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

struct abc{
  ll a,b,c;
  bool operator<(const abc& right ) const {
    return c>right.c;
  }
};

int main(){
  ll n,A,B,C,ans[2]={};
  abc t[100010];
  cin>>n;
  fr(i,n){
    cin>>A>>B;
    t[i]=(abc){A,B,A+B};
  }
  sort(t,t+n);
  fr(i,n){
    if(i%2<1) ans[0]+=t[i].a;
    else ans[1]+=t[i].b;
  }
  cout<<ans[0]-ans[1]<<endl;
}

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

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<int> b(n);
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	int cnt = 0;

	set<pair<int, int> > s = { { 0, -1 } };
	for(int i = 0; i < n; ++i) {
		s.emplace(b[i], i);
	}

	long long ans = 0;

	while(s.size() > 1) {
		auto o = *s.rbegin();
		s.erase(o);
		int p = o.second;
		int nxt = s.rbegin() -> first;
		int m = b[(p - 1 + n) % n] + b[(p + 1) % n];
		int delta = (o.first - a[p]) / m;
		if(o.first == a[p]) {
			continue;
		}
		if(delta == 0 || o.first < a[p]) {
			cout << -1 << '\n';
			exit(0);
		}
		ans += delta;
		o.first -= m * delta;
		b[p] = o.first;
		s.insert(o);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 13312
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int t[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &t[i]);
    }
    int m;
    scanf("%d", &m);
    int p[m], x[m];
    for (int i = 0; i < m; i++){
        scanf("%d%d", &p[i], &x[i]);
    }

    int ans;
    for (int i = 0; i < m; i++){
        ans = 0;
        for (int j = 0; j < n; j++){
            ans += t[j];
        }
        ans -= t[p[i] - 1] - x[i];
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static class Bottle {
		int size;
		int price;
		public Bottle(int size, int price) {
			this.size = size;
			this.price = price;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Bottle[] b = new Bottle[4];
		for(int i=0; i<4; i++)
			b[i] = new Bottle(1<<i, sc.nextInt());
		long N = sc.nextLong()*4;
		
		Arrays.sort(b, new Comparator<Bottle>() {
			public int compare(Bottle b1, Bottle b2) {
				return b1.price*b2.size - b2.price*b1.size;
			}
		});
		
		long ans = 0;
		for(int i=0; i<4; i++) {
			long buy = N/b[i].size;
			ans += buy*b[i].price;
			N -= buy*b[i].size;
		}

		System.out.println(ans);
		sc.close();
	}
	
	static int gcd(int a, int b) {
		return a==0 ? b : gcd(b%a, a);
	}
}


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

#include <math.h>
#include <stdlib.h>


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

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



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int x, y; cin >> x >> y;

    bool ans = false;
    for(int i = 0; i <= x; i++){
        int f = i * 2 + (x-i) * 4;
        if(f == y) ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <array>

using namespace std;

int main() {
	
	// 変数宣言
	int A, B;
	int ans = 0;
	
	// 入力
	scanf("%d", &A);
	scanf("%d", &B);
	
	for(int i=0; i<2; i++){
		if(A > B){
			ans += A;
			A--;
		}else{
			ans += B;
			B--;
		}
	}
	
	// 出力
	printf("%d\n", ans);
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG


int main() {
  ll N, P, ans;
  double P_f, sum;
  cin >> N;
  
  vector<ll> X(N);
  //vector<vector<int>> data(3, vector<int>(4));
  sum = 0.0;
  
  for(ll i=0; i< N; i++){
    cin >> X.at(i);
    sum += X.at(i);
  }
  
  P_f = sum / (float)N;
  P = round(P_f);

  ans = 0;
  for(ll i=0; i< N; i++){
    ans += (X.at(i) - P) * (X.at(i) - P);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,m,l;
  cin >> n >> m >> l;
  mat dis(n,vec(n,inf));
  for(ll i=0;i<n;i++) dis[i][i]=0;
  for(ll i=0;i<m;i++) {
    ll a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    if(c<=l) dis[a][b]=dis[b][a]=c;
  }
  for(ll k=0;k<n;k++) {
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<n;j++) {
        dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
      }
    }
  }
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      if(dis[i][j]<=l) dis[i][j]=min(1LL,dis[i][j]);
    }
  }
  for(ll k=0;k<n;k++) {
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<n;j++) {
        dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
      }
    }
  }
  ll q;
  cin >> q;
  while(q--) {
    ll s,t;
    cin >> s >> t;
    s--;
    t--;
    if(dis[s][t]==inf) cout << -1 << endl;
    else cout << dis[s][t]-1 << endl;
  }
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll ans = 0LL, suml[200011], sumr[200011], k;
int main() {
  ll n;
  cin >> n >> k;
  suml[1] = 0LL;
  sumr[1] = n;
  for (ll i = 1; i <= n; i++) {
    suml[i + 1LL] = suml[i] + i;
    suml[i + 1LL] %= MOD;
  }
  for (ll i = 1; i <= n; i++) {
    sumr[i + 1LL] = sumr[i] + (n - i);
    sumr[i + 1LL] %= MOD;
  }
  for (ll i = k; i <= n + 1; i++) {
    ans += MOD - suml[i] + sumr[i] + 1LL;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    bool flag = true;
    int a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 0){
            if (!(a % 3 == 0 || a % 5 == 0)){
                flag = false;
            }
        }
    }
    cout << (flag ? "APPROVED" : "DENIED") << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(2*M);
  for (int i = 0; i < 2*M; i++)
   cin >> road.at(i);
  for (int i = 0; i < N; i++){
    int count = 0;
    for (int j = 0; j < 2*M; j++){
     if (road.at(j) == i+1) count ++;
    }
    cout << count << endl;
  }
}

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

int main(){
	int i,j,n,m;
	int a[100][100]={0};
	int b[100]={0};
	int c[100]={0};

	cin>>n>>m;
	for(i=0;i<n;i++){
		for (j = 0; j < m; j++){
			cin>>a[i][j];
	
		}
	}
	for(i=0;i<m;i++)
		cin>>b[i];

	for (i = 0; i < n; i++){
		for (j = 0; j < m; j++)
			c[i]+=a[i][j]*b[j];	
		
		cout<<c[i]<<endl;
	}

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
typedef pair<int,int> P;

const int INF = 1001001001;

const int MAXE = 100010;
int dist[MAXE][3];

signed main()
{
  int n,m,s,t;
  cin>>n>>m;
  vector<vector<int>> to(n);
  rep(i,m) {
    int a,b; cin>>a>>b;
    --a; --b;
    to[a].push_back(b);
    
  }
  cin>>s>>t;
  --s; --t;
  rep(i,n)rep(j,3) dist[i][j]=INF;
  queue<P> q;
  q.push(P(s,0));
  dist[s][0]=0;
  while(!q.empty()){
    int v=q.front().first;
    int l=q.front().second;
    q.pop();
    int nl=(l+1)%3;
    for(int u: to[v]){
      if(dist[u][nl] != INF) continue;
      dist[u][nl]=dist[v][l]+1;
      q.push(P(u,nl));
    }
  }
  printf("%d\n",dist[t][0]==INF?-1:dist[t][0]/3);
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int A,B,C,X,Y;
  int ans;
  cin>>A>>B>>C>>X>>Y;

    if(X>Y){
      ans = min(X,Y)*2*C+(X-Y)*A;
    }else{
      ans = min(X,Y)*2*C+(Y-X)*B;
    }
    ans = min(ans,X*A+Y*B);
    ans = min(ans,2*C*max(X,Y));

  cout<<ans<<endl;
}


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

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

  int n = 0;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if((500*i+100*j+50*k) == X){
          n++;
        }
      }
    }
  }

  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
memo = [0]*(N+1)
memo[0] = 0

for i in range(1,N+1):
	memo[i] = memo[i-1]+1
	j = 1
	while pow(6,j) <= i:  
		memo[i] = min(memo[i],memo[i-pow(6,j)]+1)
		j += 1
	j = 1
	while pow(9,j) <= i:
		memo[i] = min(memo[i],memo[i-pow(9,j)]+1)
		j += 1

print(memo[-1])


Measured memory_bytes: 3828
def calc(x):
    if x%10!=0:
        y=x+(10-x%10)
    else:
        y=x
    return y

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

a_ = calc(a)
b_ = calc(b)
c_ = calc(c)
d_ = calc(d)
e_ = calc(e)

# print(a_,b_,c_,d_,e_)

l=[a+b_+c_+d_+e_, a_+b+c_+d_+e_, a_+b_+c+d_+e_, a_+b_+c_+d+e_, a_+b_+c_+d_+e]
print(min(l))

Measured memory_bytes: 38384
#include <stdio.h>
int main(){
	int h,w,i,j,detect;
	scanf("%d%d",&h,&w);
	char cam[51][51];
	for(i=0;i<h;i++){
		scanf("%s",cam[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(cam[i][j] == '#'){
				detect = 1;
				if(i>0 && cam[i-1][j] == '#') detect = 0;
				if(i<h-1 && cam[i+1][j] == '#') detect = 0;
				if(j>0 && cam[i][j-1] == '#') detect = 0;
				if(j<w-1 && cam[i][j+1] == '#') detect = 0;
				if(detect == 1) break;
			}
		}
		if(detect == 1) break;
	}
	if(detect == 1) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) {
    cin>>A[i];
  }
  int index = 0;
  ll maxa = abs(A[0]);
  for(int i=0;i<N;++i) {
    if(maxa<abs(A[i])) {
      index = i;
      maxa = abs(A[i]);
    }
  }
  vector<pair<int, int> > ans;
  for(int i=0;i<N;++i) {
    if(i==index) continue;
    ans.push_back(mp(index+1, i+1));
  }
  if(A[index]>=0) {
    for(int i=0;i<N-1;++i) {
      ans.push_back(mp(i+1, i+2));
    }
  }
  else {
    for(int i=N-1;i>0;--i) {
      ans.push_back(mp(i+1, i));
    }
  }
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();++i) cout<<ans[i].fi<<" "<<ans[i].se<<endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n;
    cin >> n;
    vll a(n+1); 
    rep(i, n) cin >> a[i];
    a[n] = -1;
    
    int flag_buy = 0;
    ll buy, sell;
    ll now = 1000;
    
    rep(i, n){
        if(!flag_buy && a[i] < a[i+1]){
            flag_buy = 1;
            buy = a[i];
            sell = a[i+1];
            // cout << buy << " " << sell << endl;
        }
        else if(flag_buy){
            if(a[i] < a[i+1]){
                sell = a[i+1];
            }
            else{
                ll cnt = now / buy;
                now += cnt * (sell - buy);
                // cout << now << endl;
                flag_buy = 0;
            }
        }
    }
    
    cout << now << endl;
	return;
}

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

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;

int main(){
  int N,a,min,ans;
  ans = -(1<<30);
  min = 0;
  scanf("%d\n",&N);
  for(int i=0;i<N;i++){
    scanf("%d\n",&a);
    if(i==0) min=a;
    else{
      if(a-min>ans) ans=a-min;
      if(min>a) min=a;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long>a(n);
  for(long long i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  long long wa=0;
  for(long long i=0;i<k-1;i++){
    wa+=a[i+1]-a[i];
  }
  long long kotae=wa;
  for(int i=1;i<n-k+1;i++){
    wa=wa-(a[i]-a[i-1])+(a[i+k-1]-a[i+k-2]);
    //cout<<wa<<" ";
    kotae=min(kotae,wa);
  }
  cout<<kotae<<endl;
  return 0;
}


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

vector<string> field;

int dist[2010][2010][2];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int H, W;

void dfs(int _cx, int _cy, int _p, int &_sum){
  _sum += 1;
  int nx = _cx + dx[_p];
  int ny = _cy + dy[_p];

  if(nx < 0 || nx  >= W || ny < 0 || ny >= H) return;
  if(field[ny][nx] == '#') return;
  dfs(nx, ny, _p, _sum);

}

void searchY(int _x, int _y){
  int sum = 0;
  dfs(_x, _y, 1, sum);
  dfs(_x, _y, 3, sum);
  sum -= 1;
  dist[_y][_x][0] = sum;
}

void searchX(int _x, int _y){
  int sum = 0;
  dfs(_x, _y, 0, sum);
  dfs(_x, _y, 2, sum);
  sum -= 1;
  dist[_y][_x][1] = sum;
}


int main(){

  cin >> H >> W;

  field.resize(H);
  rep(i,H) cin >> field[i];

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      dist[i][j][0] = -1;   // height方向
      dist[i][j][1] = -1;   // width方向
    }
  }


  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(ans == H+W-1) continue;
      if(field[i][j] == '#') continue;
      if(i == 0) searchY(j, i);
      else if(dist[i-1][j][0]!= -1 && field[i-1][j] == '.') dist[i][j][0] = dist[i-1][j][0];
      else searchY(j, i);

      if(j == 0) searchX(j,i);
      else if(dist[i][j-1][0]!= -1  && field[i][j-1] == '.') dist[i][j][1] = dist[i][j-1][1];
      else searchX(j, i);

      int total = dist[i][j][0] + dist[i][j][1] -1;
      if(total > ans) ans = total;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 35712
#include <stdio.h>
int main(){
    int a[4];
    int b[2];
    for(int i=0;i<4;i++){
        scanf("%d", &a[i]);
    }
    for(int i=0;i<2;i++){
        scanf("%d", &b[i]);
    }
    
    int min = 100;
    int x = 0;
    for(int i=0;i<4;i++){
        if(min > a[i]){
            min = a[i];
            x = i;
        }
    }
    
    
    int sum = 0;
    for(int i=0;i<4;i++){
        if(i == x)continue;
        sum += a[i];
    }
    
    if(b[0] < b[1]){
        sum += b[1];
    }else{
        sum += b[0];
    }
    
    printf("%d\n", sum);
    
    return 0;
}



Measured memory_bytes: 2128
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline void Add(int &x, const int &y) { (x += y) >= MOD ? (x -= MOD) : 0; }
int arr[200005], dp[200005];
int main()
{
	// freopen("AGC031-B.in", "r", stdin);
	int n, sum = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	for (int i = 0; i < n; i++)
	{
		if (i && arr[i] != arr[i - 1])
			Add(sum, dp[arr[i]]);
		if (i + 1 != n && arr[i] != arr[i + 1])
			dp[arr[i]] = sum;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();
            Console.WriteLine($"{a[0]}{b[1]}{c[2]}");

            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c;
	int sum;
	cin>>a>>b>>c;
	for(int i=1;i<=10;i++){
		sum=a*c-b;
		c=sum;
		cout<<sum<<endl;
	}
	return 0;
}

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

long int n, a[20], i;

int main()
{
    cin >> n;
    for (i = 0; i < 20; i++) {
        n = n - 1;
        a[i] = n % 26;
        n /= 26;
        if (n == 0) break;
    }
    for (; i >= 0; i--) {
        char c = a[i] + 'a';
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3648
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    dp = [INF]*(n+1)
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))

Measured memory_bytes: 224952
a = list(input())
i = 0
while True:
    odd = a[i]
    if odd == 'L':
        print('No')
        break
    i += 1
    if i == len(a):
        print('Yes')
        break
    even = a[i]
    if even == 'R':
        print('No')
        break
    i += 1
    if i == len(a):
        print('Yes')
        break


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int n,d,x;scanf("%d%d%d",&n,&d,&x);
   int a[101];
   int ans=0;
   for(int i = 0;i < n;i++)scanf("%d",&a[i]);
   for(int i = 0;i < n;i++){
      ans += (((d%a[i]==0)?0:1) + d/a[i]);
   }
   printf("%d",ans+x);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
int f[10],zz,z,aa[10],a[10],tempp,temp,bat,batt;
bool cek[10],cekk[10];
int n;
void fact(int x){
	f[0]=1;
	f[1]=1;
	
	for(int i=2;i<=9;i++){
		f[i]=i*f[i-1];
	}
}

int main(){
	
	fact(8);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	bat=n-1;
	temp=1+(a[1]-1)*f[n-1];
	cek[a[1]]=1;
	for(int j=2;j<=n;j++){
		for(int k=1;k<=a[j];k++){
			if(!cek[k]){
				z++;
			}
		}
		
		cek[a[j]]=1;
		temp+=(z-1)*f[bat-1];
		z=0;
		bat--;
	}
	
	for(int i=1;i<=n;i++){
		cin>>aa[i];
	}
	
	batt=n-1;
	tempp=1+(aa[1]-1)*f[n-1];
	cekk[aa[1]]=1;
	for(int jj=2;jj<=n;jj++){
		for(int kk=1;kk<=aa[jj];kk++){
			if(!cekk[kk]){
				zz++;
			}
		}
		
		cekk[aa[jj]]=1;
		tempp+=(zz-1)*f[batt-1];
		zz=0;
		batt--;
	}
	
	cout<<abs(temp-tempp)<<endl;
}

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

vector<int> CM(pow(2, 12), -1);

int	CMin(int AllOP, int OP, int BoxN, vector<int> &a, vector<int> &cb, vector<vector<int>> &bk) {
	if (CM.at(OP)>=0)
		return CM.at(OP);
	if (AllOP==OP)
		return 0;
	if (BoxN==bk.size())
		return 1000000001;
	if (0==bk.at(BoxN).size())
		return 1000000001;
	int PP=pow(2, BoxN);
	if (PP==(OP&PP))
		CM.at(OP)=CMin(AllOP, OP, BoxN+1, a, cb, bk);
	else {
		int CC=1000000001;
		for (int i=0; i<bk.at(BoxN).size(); i++) {
			int KN=bk.at(BoxN).at(i);
			CC=min(CC, a.at(KN)+CMin(AllOP, (OP|cb.at(KN)), BoxN+1, a, cb, bk));
		}
		CM.at(OP)=CC;
	}
	return CM.at(OP);
}

int	main() {
	int N, M;
	cin >>N >>M;
	vector<vector<int>> bk(N);
	vector<int> a(M);
	vector<vector<int>> c(M, vector<int> (0));
	vector<int> cb(M, 0);
	for (int i=0; i<M; i++) {
		int b;
		cin >>a.at(i) >>b;
		for (int j=0; j<b; j++) {
			int C;
			cin >>C;
			c.at(i).push_back(C);
			cb.at(i) = (cb.at(i) | (0x1<<(C-1)));
			bk.at(C-1).push_back(i);
		}
	}
	int Cost;
	Cost=CMin(pow(2, N)-1, 0, 0, a, cb, bk);
	if (100000001<=Cost)
		cout <<-1 <<endl;
	else
		cout <<Cost <<endl;
	return 0;
};


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
bool fun(vector <long long> a, vector <long long > b)
{
    if(a[0]<b[0])
        return true;
    return false;
}
int main()
{
    int n;
    int total_wt;
    cin>>n>>total_wt;
    vector <long long> temp(2);
    vector <vector <long long> >  v(n,temp);
    for(int i=0;i<n;i++)
    {
        cin>>v[i][0]>>v[i][1];
    }
    long long dp[n+1][total_wt+1];
    sort(v.begin(), v.end(), fun);
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int i=0;i<=total_wt;i++)
        dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=total_wt;j++)
        {
            if(j<v[i-1][0])
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j], dp[i-1][j-v[i-1][0]]+v[i-1][1] );
            }
        }
    }
    cout<<dp[n][total_wt]<<endl;
}


Measured memory_bytes: 79104
n = int(input())
hs = list(map(int, input().split(' ')))

dp = [0] * n
dp[0] = 0
dp[1] = abs(hs[1] - hs[0])

for i in range(2, n):
    step1 = dp[i - 1] + abs(hs[i - 1] - hs[i])
    step2 = dp[i - 2] + abs(hs[i - 2] - hs[i])
    dp[i] = min([step1, step2])

print(dp[-1])


Measured memory_bytes: 13980
fun main() {
    val n= readLine()!!.toInt()
    val h= readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var now=0
    for (i in 0 until h.size){
        if (i==0){now=h[0]-1}
        else{
            if (now<h[i]){now=h[i]-1}
            if (now==h[i]){continue}
            if (now>h[i]){now=-1;break}
        }
    }
    if (now==-1){
        println("No")
    }else{
        println("Yes")
    }
}

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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(ALL(v))
#define SORTD(v) sort(ALL(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<x<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

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

void debug_print() {}

template <class Head, class... Tail>
void debug_print(Head&& head, Tail&&... tail)
{
	cout << (head) << endl;

	debug_print(forward<Tail>(tail)...);
}


int i, j, k;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll x;
	cin >> n >> x;
	vl vx(n);
	readv(vx, n);
	vx.push_back(x);
	SORT(vx);
	ll g = vx[1] - vx[0];
	rep(i, n) {
		ll t = vx[i + 1] - vx[i];
		chmin(g, __gcd(g, t));
	}
	print(g);
	return 0;
}

Measured memory_bytes: 1792
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846

// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
// int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
// int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
// int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
// int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===

void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
   ll s;cin>>s;
   ll dp[2005];
   dp[0]=1;dp[1]=dp[2]=0;dp[3]=1;
   for(int i=4;i<=2000;i++)
   {
     ll temp=0;
     for(int j=3;j<=i;j++)
     {
       temp+=dp[i-j];temp%=mod;
     }
     dp[i]=temp;
   }
   cout<<dp[s];
} 

Measured memory_bytes: 3604
c = [list(map(int, input().split())) for i in range(3)]
if c[0][0]-c[0][1] == c[1][0]-c[1][1] == c[2][0]-c[2][1] and c[0][1]-c[0][2] == c[1][1]-c[1][2] == c[2][1]-c[2][2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9120
#include <iostream>
#include <iomanip>

int main()
{
	int A[100][100], b[100],n,m,c;
	std::cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		std::cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		c = 0;
		for (int j = 0; j < m; j++) {
			c += A[i][j] * b[j];
		}
		std::cout << c << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3128
n, m = map(int, input().split())
wa = [0] * n
ac = [False] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA' and not ac[p]:
        wa[p] += 1
    elif s == 'AC':
        ac[p] = True

wa_n = sum(wa[i] if ac[i] else 0 for i in range(n))
print("{} {}".format(sum(ac), wa_n))

Measured memory_bytes: 75932