akhauriyash/Code-Regression huggingface dataset:
S = list(input())

counter = 0

for num in range(len(S)-1):
  if num == len(S):
    break
  if S[num] == S[num+1]:
    counter += 1
    if S[num+1] == '0':
      S[num+1] = '1'
    else:
      S[num+1] = '0'

print(counter)

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main() {
  int n,t;
  scanf("%d %d",&n,&t);
  int ans = 1000 + 1;
  for (int i = 1, u, v; i <= n; ++i) {
    scanf("%d %d",&u,&v);
    if (v <= t && u < ans)
     ans = u; 
  }
  if (ans == 1001) 
    printf("TLE\n");
  else
    printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

const ll inf = 1LL<<59;
int n;
vector<ll> a(444, 0), cum(440, 0);
vector<vector<bool>> flg(440, vector<bool>(440, false));
vector<vector<ll>> memo(440, vector<ll>(440, 0));

ll rec(int l, int r){
    if(flg[l][r]) return memo[l][r];
    flg[l][r] = true;
    if(l==r) return 0;
    // どこで切るか全通り試す
    ll cost = inf;
    for(int i=l; i<r; ++i) chmin(cost, rec(l, i)+rec(i+1, r));
    return memo[l][r] = cost+cum[r]-cum[l-1];
}


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

    cin >> n;
    for(int i=1; i<=n; ++i) { cin >> a[i]; cum[i] = cum[i-1] + a[i]; }
    
    cout << rec(1, n) << endl;
    
	return 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::string str;
    std::cin >> str;
    bool good = true;
    if (str.length() % 2 == 0) {
        for (int i = 0; good && i < str.length(); i += 2) {
            if (str[i] != 'h' || str[i + 1] != 'i') {
                good = false;
            }
        }
    } else {
        good = false;
    }
    std::cout << (good ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int cnt = 0;
		
		for (int i = 1; i <= n; i += 2) {
			int tmp = 0;
			for (int j = 1; j <= i; j++) {
				if (i % j == 0) tmp++;
			}
			if (tmp == 8) cnt++;
		}
		
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


bool ok(string s){
    if(s[0]!='A')return false;
    if(count(s.begin()+2,s.end()-1, 'C')!=1)return false;
    for(char c : s){
        if(c!='A'&&c!='C'&&isupper(c))return false;
    }
    return true;
}

int main() {
    string s; cin>>s;
    cout<<((ok(s))?"AC":"WA")<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int h, w;
	cin >> h >> w;
	vector<vector<ll int>> dp(h, vector<ll int>(w, 1));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char c;
			cin >> c;
			dp[i][j] = (long long int)(c=='.');
		}
	}

	// for(int i = 0; i < h; i++){
	// 	for(int j = 0; j < w; j++){
	// 		cout << dp[i][j];
	// 	}
	// 	cout << endl;
	// }


	for(int i = 1; i < w; i++)
		dp[0][i] = (dp[0][i] == 1 && dp[0][i-1] == 1)?dp[0][i-1]:0;

	for(int i = 1; i < h; i++)
		dp[i][0] = (dp[i][0] == 1 && dp[i-1][0] == 1)?dp[i-1][0]:0;

	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){
			if (dp[i][j] == 1){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
			}
		}
	}

	cout << dp[h-1][w-1] << "\n";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int h = 0;
    int w = 0;
    vector<string>pic;
    string bufpic;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> bufpic;
        pic.push_back(bufpic);
    }
    for (int j = 0; j <h ; ++j) {
        for (int i = 0; i <2 ; ++i) {
            cout << pic[j] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
static const int N=100;
int main(){
  int A[N][N];
  int num,i,j;
  int u,k,v;
 
  scanf("%d",&num);
 
  for(i=0;i<num;i++){
    for(j=0;j<num;j++)A[i][j]=0;
  }
  for(i=0;i<num;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }
 
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      if(j)printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  rep(i, n) cin >> p[i];

  vector<double> sum(n);
  sum[0] = (p[0] + 1) / 2;
  for (int i = 1; i < n; i ++) {
    sum[i] = sum[i - 1] + (p[i] + 1) / 2;
  }

  double ans = sum[k - 1];
  for (int i = k; i < n; i ++) {
    ans = max(ans, sum[i] - sum[i - k]);
  }

  cout << setprecision(15) << ans << endl;
}


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

int main() {
	int n,m,x,arr[100],st[101],i,j,l,k,r,z,p;
	cin >> n >> m >> x;
	for (p = 0; p < m; p++){
		cin >> arr[p];
	}
	r = 0;
	k = 0;
	for (l = 0; l <= n; l++){
		st[l] = l;
	}
	for (i = 1; i < x; i++){
		for (j = 0; j < m; j++){
			if (st[i] == arr[j]){
				k++;
			}
		}
	}
	for (z = x; z < n; z++){
		for (j = 0; j < m; j++){
			if (st[z] == arr[j]){
				r++;
			}
		}
	}	
	if (k < r){
		cout << k;
	}
	else {
		cout << r;
	}
	return 0;
}

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

int main() {
  int i = 0;
  int N;
  int l, r;
  int n = 0;

  cin >> N;

  for(i = 0; i < N; i++){
    cin >> l >> r;

    n = n + r - l + 1;
  }
  cout << n << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[2*n - 1]; for (auto &ai:a) cin >> ai;
    int l = 1, r = 2*n;
    while (r - l > 1) {
        int m = (l + r) / 2;
        bool prev = (a[n-1] >= m);
        bool found = false;
        for (int i=1; i<n; i++) {
            bool left = (a[n-1-i] >= m), right = (a[n-1+i] >= m);
            if (left == prev || right == prev) {
                found = true;
                break;
            }
            prev = left;
        }
        if (prev) l = m;
        else r = m;
    }
    cout << l << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
    int h,m,s,S;
    scanf("%d",&S);
    
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2076
import fractions

def cnt(a, b, c):
    cnt = b // c - (a - 1) // c
    return cnt

a, b, c, d = map(int, input().split())
lcm = c * d // fractions.gcd(c, d)
c, d, lcm = cnt(a, b, c), cnt(a, b, d), cnt(a, b, lcm)
print(b - a + 1 - c - d + lcm)

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

using namespace std;

int N,a[500010],s[500010];
vector<int>pos[1<<20];
int sum0[500010];
const int MOD = 1e9 + 7;

int main() {
	scanf("%d",&N);
	for (int i=1;i<=N;i++) {
		scanf("%d",&a[i]);
		s[i] = s[i - 1] ^ a[i];
		pos[s[i]].push_back(i);
		sum0[i] = sum0[i - 1] + (s[i] == 0);
	}
	if (s[N] != 0) {
		int X = s[N];
		int s0 = 1, s1 = 0;
		for (int i=1;i<=N;i++) {
			if (s[i] == X) {
				int F = s0;
				s1 = (s1 + F) % MOD;
				if (i == N) {
					printf("%d\n",F);
					return 0;
				}
			} else if (s[i] == 0) {
				int F = s1;
				s0 = (s0 + F) % MOD;
			}
		}
	}
	int ans = 0;
	int p2 = 1;
	for (int i=1;i<=sum0[N-1];i++) {
		p2 = p2 * 2 % MOD;
	}
	ans = p2;
	for (int v=1;v<(1<<20);v++) {
		if (pos[v].size() == 0) {
			continue;
		}
		if (pos[v].size() == 1) {
			ans++;
			continue;
		}
		int lastF = 1, s0 = 1, s1 = 1;
		for (int i=1;i<pos[v].size();i++) {
			int bz = sum0[pos[v][i]] - sum0[pos[v][i-1]];
			s0 = (1LL * bz * s1 + s0) % MOD;
			int F = s0;
			s1 = (s1 + F) % MOD;
		}
		ans = (ans + s1) % MOD;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 40308
# 21:19
from collections import deque
n = int(input())
a = deque(list(map(int,input().split())))
ans = 0
count = 1
i = 0
while True:
    if a[i] != count:
        ans += 1
        a.popleft()
    else:
        count += 1
        i += 1
    if n == ans + i:
        break
if len(a) == 0:
    print(-1)
else:
    print(ans)

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

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

  uint64_t count = 0;
  uint64_t whine_num = 0;
  bool black = false;

  for (uint64_t i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      black = true;
    } else {
      count += i - whine_num;
      whine_num++;
    }
  }
  if (black) {
    std::cout << count << std::endl;
  } else {
    std::cout << 0 << std::endl;}
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, b, c;

int main() {
	while (cin >> a >> b >> c&&a + b + c) {
		P ans;
		ll bb = 0;
		ll buf = INF;
		ll buf2 = INF;
		rep(i, 50001) {
			if (c - a*i >= 0 && (c - a*i) % b == 0) {
				if (i + (c - a*i) / b <= buf) {
					if (c <= buf2) {
						buf = i + (c - a*i) / b;
						buf2 = c;
						ans = { i,(c - a*i) / b };
					}
				}
			}
			if ((c + a*i) % b == 0) {
				if (i + (c + a*i) / b <= buf) {
					if (c + 2 * a*i <= buf2) {
						buf = i + (c + a*i) / b;
						buf2 = c + 2 * a*i;
						ans = { i,(c + a*i) / b };
					}
				}
			}
			if (a*i - c >= 0 && (a*i - c) % b == 0) {
				if (i + (a*i - c) / b <= buf) {
					if (c + 2 * b*(a*i - c) / b <= buf2) {
						buf = i + (a*i - c) / b;
						buf2 = c + 2 * b*(a*i - c) / b;
						ans = { i,(a*i - c) / b };
					}
				}
			}
		}
		//cout << buf << " " << buf2 << endl;
		cout << ans.first << " " << ans.second << endl;
	}
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <deque>
#include <vector>
using namespace std;
int mt[200001],tmp[200001];
int main()
{
	int n;
	scanf("%d",&n);
	deque<int> dq;
	dq.push_back(1);
	int pos=1;
	for (int i=1;i<=(n-1)/2;++i)
		if (n%2)
		{
			dq.push_back(++pos);
			dq.push_front(++pos);
		}
		else
		{
			dq.push_front(++pos);
			dq.push_back(++pos);
		}
	if (n%2==0)
		dq.push_front(++pos);
	pos=0;
	for (deque<int>::iterator it=dq.begin();it!=dq.end();++it)
		mt[*it]=++pos;
	for (int i=1;i<=n;++i)
	{
		int c;
		scanf("%d",&c);
		tmp[mt[i]]=c;
	}
	for (int i=1;i<=n;++i)
		printf("%d ",tmp[i]);
	return 0;
}


Measured memory_bytes: 4608
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000000000;
//const ll MOD = 1000000000 + 7;
const int MAX_N = 400 + 2;
ll a[MAX_N];
ll dp[MAX_N][MAX_N];
ll suma[MAX_N];

ll rec(int l, int r) {

  if (l == r) return 0;
  if (dp[l][r] != INF) return dp[l][r];

  ll ans = INF;
  for (int k = 0; l + k + 1 <= r; k++) {
    ans = min(ans, rec(l, l + k) + rec(l + k + 1, r));
  }

  ans += (suma[r] - suma[l - 1]);
  dp[l][r] = ans;
  
  return dp[l][r];
}

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

  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> a[i];

  suma[0] = 0;
  for (int i = 1; i <= N; i++) suma[i] = suma[i - 1] + a[i];
  
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      dp[i][j] = INF;
    }
  }
  for (int k = 1; k <= N; k++) dp[k][k] = 0;
  
  rec(1, N);
  cout << dp[1][N] << endl;
  
  return 0;
}



Measured memory_bytes: 4444
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };


int main() {

	int n, m;
	cin >> n >> m;

	vector<int> a(n);

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

	for (int k = 1; k <= m; k++) {
		for (int i = 0; i < n - 1; i++) {

			if (a[i] % k > a[i + 1] % k) {
				swap(a[i], a[i + 1]);
			}

		}

	}

	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
(let* ((n (read))
       (m (make-hash-table :test 'equal :size n))
       (s (make-array (list n))))
  (loop :for i :from 0 :to (1- n)
        :do (let ((x (read-line)))
              (if (gethash x m)
                  (incf (gethash x m))
                  (setf (gethash x m) 1))
              (setf (aref s i) (cons x (gethash x m)))))
  (setf s (sort s (lambda (a b) (or (> (cdr a) (cdr b))
                                    (and (= (cdr a) (cdr b))
                                         (string< (car a) (car b)))))))
  (let ((f (cdr (aref s 0))))
    (loop :for x :across s
          :when (= (cdr x) f)
          :do (format t "~A~%" (car x)))))


Measured memory_bytes: 86380
use proconio::*;
use std::collections::HashMap;

fn main() {
    input! {
        n:i64,
        mut x:i64,
        m:i64,
    }

    let mut amari = HashMap::new();
    amari.insert(-1i64, 0i64);
    let mut res = 0i64;
    let mut ruiseki = vec![0i64; 100005];

    let mut ikkai = 0i64;
    let mut start = -1i64;
    let mut junban = 0i64;
    let mut syuuki = -1i64;
    loop {
        junban += 1;
        ruiseki[junban as usize] = ruiseki[(junban - 1) as usize] + x;

        if amari.contains_key(&x) {
            syuuki = junban - amari.get(&x).unwrap();
            ikkai = ruiseki[junban as usize] - ruiseki[(junban - syuuki) as usize];
            start = *amari.get(&x).unwrap();
            break;
        } else {
            amari.insert(x, junban);
            x = (x * x) % m;

            if junban == n {
                println!("{}", ruiseki[n as usize]);
                return;
            }
        }
    }

    res = ruiseki[(start - 1) as usize];
    res += (n - start + 1) / syuuki * ikkai;

    for _ in 0..((n - start + 1) % syuuki) {
        res += x;
        x = (x * x) % m;
    }

    println!("{}", res);
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;
#define LL long long

int main()
{

	vector<LL> P(0);
	vector<int> I(0);
	vector<LL> A(0);
	
	LL N;
	cin >> N;

	int i = 0;
	LL n = N;
	
	for (LL p = 2; p * p <= N; p++) {
		for (int j = 1; n % p == 0; j++) {

			if (j == 1) {
				P.push_back(p);
				I.push_back(j);
			}
			else {
				I.at(i)++;
			}
			n /= p;
			if (n % p)
				i++;
		}
	}

	if (n != 1) {
		P.push_back(n);
		I.push_back(1);
	}
	int size = P.size();
	for (int i = 0; i < size; i++) {
		for (int j = 0; j <= I.at(i); j++) {
			LL x;
			x = (LL)pow(P.at(i), j);
			if (x != 1)
				A.push_back(x);
		}
	}
	sort(A.begin(), A.end());
	
	int count = 0;
	for (int i = 0; i < A.size(); i++) {
		if (N % A.at(i) == 0) {
			N /= A.at(i);
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
	char x;
	scanf("%c",&x);
	if(x=='a'||x=='e'||x=='i'||x=='o'||x=='u')
	{
		printf("vowel\n");
	}
	else
	{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
# coding: utf8

if __name__ == '__main_sample__':
    """
        (A, B)と(A+1, B+1)の結果は同じになる.
        (0, 0), (0, 1) ... (0, N-1)をチェックすれば良くなる.
    """
    N = int(input())
    rows = [input() for _ in range(N)]
    ans = 0
    for n in range(N):
        flag = False
        for i in range(N):
            for j in range(N):
                num = j - n if j - n >= 0 else N + (j - n)
                a = i - n if i - n >= 0 else N + (i - n)
                if rows[i][num] != rows[j][a]:
                    flag = True
                    break
            if flag == True:
                break
        if flag == False:
            ans += 1
    print(ans * N)

if __name__ == '__main__':
    """
        高速化された開放
    """
    N = int(input())
    Sss = [input() for _ in range(N)]
    Sss_tr = list(map(''.join, zip(*Sss))) # 転置
    ans = 0
    for k in range(N):
        for i in range(N):
            if (Sss[i][-k:] + Sss[i][:-k]) != Sss_tr[i - k]:
                break
        else:
            ans += N
    
    print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define vll         vector<pll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

const int N=1e5+5;
ll par[N],in[N];
vl g[N];

void solve()
{
    ll n,m; cin>>n>>m;
    rep(i,1,n+m){
        ll x,y; cin>>x>>y;
        g[x].pb(y);
        in[y]++;
    }
    queue<ll>q;
    rep(i,1,n+1) if(in[i]==0) { q.push(i); par[i]=0;  }
    while(!q.empty()){
        ll s=q.front();
        q.pop();
        for(ll d:g[s]){
            in[d]--;
            par[d]=s;
            if(in[d]==0) q.push(d);
        }
    }
    rep(i,1,n+1) cout<<par[i]<<endl;
}

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


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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int n, m;
  cin >> n >> m;
  int mr[100] = {};
  repi(n) {
    int k;
    cin >> k;
    repj(k){
      int x;
      cin >> x;
      mr[x]++;
    }
  }
  int re = 0;
  repi(100) if (mr[i] == n) re++;
  cout << re << endl;
}


Measured memory_bytes: 256
s=input()
l=[]
for ak in range(len(s)):
    l.append(s[ak])
no=[]
s=l
no.append(s[0])
br=0
for i in range(1,len(s)):
    no.append(s[i])
   
    if len(no) >= 2 and no[-1]!=no[-2]:
        no.pop(-1)
        no.pop(-1)
        br+=2
print(br)


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

#define int long long

using namespace std;

long long n;
long long w[50000];
long long summ = 0;

signed main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> w[i];
    for (int i = 1; i <= n; i++) summ += w[i];
    long long s = 0, ans = 1e18;
    for (int i = 0; i < n; i++)
    {
        s = s + w[i];
        if (w[i] != w[i + 1])
        {
            ans = min(ans, abs(summ - s - s));
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++) cin >> H[i];
  vector<int> start; // 単調非増加となる区間の最初の添え字
  start.push_back(0);
  for (int i=1; i<N; i++) {
    if (H[i-1]<H[i]) start.push_back(i);
  }
  start.push_back(N);
  if (start.size()==2) cout << N-1 << endl;
  else {
    int ans = start[1]-1-start[0];
    for (int i=2; i<start.size(); i++) ans = max(ans, start[i]-1-start[i-1]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1276
/*Author : Harsh AKA Codula*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inp freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
 
//main class

class Solution
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
				string s;
				cin>>s;
				if(s[s.size()-1]!='S')
				{
					s+='S';
				}
				vector<ll> c;
				ll cache=0;
				for(char i: s)
				{
					if(i=='R')
					{
						cache++;
					}
					else
					{
						c.push_back(cache);
						cache=0;
					}
				}
				sort(c.rbegin(),c.rend());
				cout<<c[0];
				cout<<"\n";
			}
		}	
};
//driver func

int main()
{
	//fast;
	//inp;
	Solution MAIN1;
	MAIN1.run();
	return 0;
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
AC_q = [0] * N
WA_num = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "AC":
        AC_q[p - 1] = 1
    else:
        if AC_q[p - 1] == 0:
            WA_num[p - 1] += 1
AC = 0
WA = 0
for i in range(N):
    if AC_q[i] == 1:
        AC += 1
        WA += WA_num[i]
print(AC, WA)


Measured memory_bytes: 4596
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>



using namespace std;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
#define LL long long

LL N,K,mod=1000000007,dp[111111]={},ans=0ll;

LL pow(LL b,LL p){
	if(p==0)return p;
	LL now=1ll,x=b;
	while(p){
		if(p&1)now=(now*x)%mod;
		x=(x*x)%mod;
		p/=2ll;
	}
	return now%mod;
}


int main() {
	cin>>N>>K;
	for(int i=K;i>=1;i--){
		vector<int>dvi;
		for(int j=1;j*i<=K;j++)
			dvi.push_back(i*j);
		dp[i]=pow((LL)dvi.size(),N);
		for(int j=1;j<dvi.size();j++)
			dp[i]=(dp[i]+mod-dp[dvi[j]])%mod;
		ans=(ans+dp[i]*i)%mod;
	}
	cout<<ans<<endl;
	return 0;
}



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[2 * n];
        for (int i = 0; i < 2 * n; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for (int i = 0; i < 2 * n; i += 2) {
            sum += l[i];
        }
        System.out.println(sum);
    }

}


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

using namespace std;

const int mod = 998244353, N = 303;

long long dp[N][N][N];
long long tmp[N][N], tmp2[N][N];

void add(long long & var, long long val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

char s[N];

int main() {
  int k;
  scanf("%s %d", s, &k);
  int n = strlen(s);
  int cnt = 0;
  vector<int> ones;
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      ones.push_back(cnt);
      cnt = 0;
    } else {
      ++tot;
      ++cnt;
    }
  }
  ones.push_back(cnt);
  reverse(ones.begin(), ones.end());
  dp[0][0][0] = 1;
  k = min(k, tot);
  for (int i = 0; i < (int)ones.size(); ++i) {
    int cur = ones[i];
    for (int j = 0; j <= k; ++j) {
      for (int z = j; z <= k; ++z) {
        add(dp[i+1][j][z], dp[i][j][z]);

        if (j-cur > 0)
          add(tmp[i][z-j], mod - dp[i][j-cur-1][z-cur-1]);
        add(dp[i+1][j][z], tmp[i][z-j]);

        add(tmp[i][z-j], dp[i][j][z]);
      }
    }
    for (int j = k; j >= 0; --j) {
      for (int z = j; z <= k; ++z) {
        add(dp[i+1][j][z], tmp2[i][z]);

        add(tmp2[i][z], dp[i][j][z]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i <= k; ++i) {
    add(ans, dp[(int)ones.size()][0][i]);
  }
  ans %= mod;
  if (ans < 0)
    ans += mod;
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  int N,B;
  cin >> N >> B;
  string S;
  cin >> S;
  B--;
  if (S.at(B) == 'A') {
    S.at(B) = 'a';
    cout << S << endl;
  } else if (S.at(B) == 'B') {
    S.at(B) = 'b';
    cout << S << endl;
  } else if (S.at(B) == 'C') {
    S.at(B) = 'c';
    cout << S << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1ll<<60;
int n,q,a,b,x[210000];
ll Min1[810000],Min2[810000],tag[810000];
void pushup(int now){
    Min1[now]=min(Min1[now<<1],Min1[now<<1|1]);
    Min2[now]=min(Min2[now<<1],Min2[now<<1|1]);
}
void pushdown(int now){
    if (!tag[now]) return;
    tag[now<<1]+=tag[now]; Min1[now<<1]+=tag[now]; Min2[now<<1]+=tag[now];
    tag[now<<1|1]+=tag[now]; Min1[now<<1|1]+=tag[now]; Min2[now<<1|1]+=tag[now];
    tag[now]=0;
}
void build(int now,int l,int r){
	if (l==r){
		Min1[now]=INF; Min2[now]=INF;
		return;
	}
	int mid=(l+r)>>1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
	pushup(now);
}
ll querymin1(int now,int l,int r,int x,int y){
	if (l>r||x>y) return INF;
	if (l==x&&r==y) return Min1[now];
	pushdown(now); int mid=(l+r)>>1;
	if (y<=mid) return querymin1(now<<1,l,mid,x,y);
	else if (x>mid) return querymin1(now<<1|1,mid+1,r,x,y);
	else return min(querymin1(now<<1,l,mid,x,mid),querymin1(now<<1|1,mid+1,r,mid+1,y));
}
ll querymin2(int now,int l,int r,int x,int y){
	if (l>r||x>y) return INF;
	if (l==x&&r==y) return Min2[now];
	pushdown(now); int mid=(l+r)>>1;
	if (y<=mid) return querymin2(now<<1,l,mid,x,y);
	else if (x>mid) return querymin2(now<<1|1,mid+1,r,x,y);
	else return min(querymin2(now<<1,l,mid,x,mid),querymin2(now<<1|1,mid+1,r,mid+1,y));
}
void change(int now,int l,int r,int x,ll y){
    if (l==r){
        Min1[now]=min(Min1[now],y-l);
        Min2[now]=min(Min2[now],y+l);
        return;
    }
    pushdown(now); int mid=(l+r)>>1;
    if (x<=mid) change(now<<1,l,mid,x,y);
	else change(now<<1|1,mid+1,r,x,y);
	pushup(now);
}
ll querymin(int now,int l,int r){
    if (l==r) return Min1[now]+l;
    pushdown(now); int mid=(l+r)>>1;
    return min(querymin(now<<1,l,mid),querymin(now<<1|1,mid+1,r));
}
int main() {
	scanf("%d%d%d%d",&n,&q,&a,&b);
    x[0]=a; build(1,1,n); change(1,1,n,b,0);
    for (int i=1;i<=q;i++){
        scanf("%d",&x[i]);
        ll tmp=min(querymin1(1,1,n,1,x[i])+x[i],querymin2(1,1,n,x[i],n)-x[i]);
        int dis=abs(x[i]-x[i-1]);
		tag[1]+=dis; Min1[1]+=dis; Min2[1]+=dis;
        change(1,1,n,x[i-1],tmp);
    }
    printf("%lld\n",querymin(1,1,n));
    return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

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




int n,mi,ma,ans=INT_MAX;
vector<int> a;

signed main(){
	read(n);
	for(int i=1,x;i<=n;i++) a.push_back(read(x));
	mi=*min_element(all(a));
	ma=*max_element(all(a));
	for(int i=mi;i<=ma;i++){
		int cur=0;
		for(auto x:a) cur+=(x-i)*(x-i);
		if(cur<ans) ans=cur;
	}
	write(ans);
}

Measured memory_bytes: 256
a,b,c,d=input()

k=["+","-"]

for k1 in k:
    for k2 in k:
        for k3 in k:
                if eval(a+k1+b+k2+c+k3+d)==7:
                    print("{}=7".format(a+k1+b+k2+c+k3+d))
                    exit()

Measured memory_bytes: 3060
n=input()
a=map(int,raw_input().split())
b=[]
d={}
for i in range(n):
    b+=[i+a[i]]
    if i+a[i] in d:
        d[i+a[i]]+=1
    else:
        d[i+a[i]]=1

c=0
#print d
for j in range(n-1,-1,-1):
    if (j-a[j]) in d:
        c+=d[(j-a[j])]
        #print j
print c

Measured memory_bytes: 130808
#include<cstdio>
#include<cstring>
#include<algorithm>
const int M=1e5+7;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int n,k,v[M],s[M],cnt,ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++) v[i]=read();
	for(int i=1;i<=n;i++){
		if(v[i]==i) k++;
		else{
			if(k) s[++cnt]=k,k=0;
		}
	}
	if(k) s[++cnt]=k;
	for(int i=1;i<=cnt;i++) ans=(ans+(s[i]+1)/2);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int count = 0;
  for (int i = 1; i < N; i++) {
    if (s[i-1] != s[i]) count += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    int a[30][30];
    for(int i = 0; i < h; i ++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    int ans = 1e9;
    for(int x = 0; x < h; x++)for(int y = 0; y < w; y++){
        int sum = 0;
        for(int i = 0; i < h; i++)for(int j = 0; j < w; j++){
            sum += min(abs(i-x),abs(j-y))*a[i][j];
        }
        ans = min(ans, sum);
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 3116
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
a = inl()
if len(set(a)) <= 2:
    print(0)
else:
    b = {}
    for i in a:
        if i not in b:
            b[i] = 0
        b[i] += 1
    b = sorted(b.items(), key=lambda x: x[1])
    ans = 0
    for i in range(len(set(a))-k):
        ans += b[i][1]
    print(ans)

Measured memory_bytes: 49752
import java.util.*;
import static java.lang.Math.*;

public class Main {

	class Complex{
		int real, imag;
		Complex(int r, int i){
			this.real = r;
			this.imag = i;
		}
		Complex add(Complex x){
			return new Complex(this.real + x.real, this.imag + x.imag);
		}
		Complex sub(Complex x){
			return new Complex(this.real - x.real, this.imag - x.imag);
		}
		Complex multi(Complex x){
			return new Complex(this.real*x.real-this.imag*x.imag, this.real*x.imag+this.imag*x.real);
		}
		boolean isOverflow(){
			return abs(this.real)>10000 || abs(this.imag)>10000;
		}
	}
	

	String str;
	int p;

	void run(){
		Scanner in = new Scanner(System.in);
		while(in.hasNextLine()){
			str = in.nextLine();
			p = 0;
			Complex ans = expr();
			if(ans == null)System.out.println("overflow");
			else{
				if(ans.imag == 0){
					System.out.println(ans.real);
				}
				else if(ans.real == 0){
					System.out.println(ans.imag + "i");
				}
				else System.out.println(""+ans.real + (Integer.signum(ans.imag)>0?"+":"-") + abs(ans.imag)+"i");
			}
		}
	}

	Complex expr(){
		Complex t = term();
		if(t == null || t.isOverflow()) return null;
		while(p<str.length() && (str.charAt(p)=='+' || str.charAt(p)=='-')){
			boolean isAdd = str.charAt(p++) == '+';
			Complex tt = term();
			if(tt == null || tt.isOverflow()) return null;
			if(isAdd){
				t = t.add(tt);
			}
			else{
				t = t.sub(tt);
			}
			if(t == null || t.isOverflow()) return null;
		}
		return t;
	}
	
	Complex term(){
		Complex f = fact();
		if(f == null || f.isOverflow()) return null;
		while(p<str.length() && str.charAt(p)=='*'){
			p++;
			Complex ff = fact();
			if(ff == null || ff.isOverflow()) return null;
			f = f.multi(ff);
			if(f == null || f.isOverflow()) return null;
		}
		return f;
	}

	Complex fact(){
		if(str.charAt(p)=='('){
			p++;
			Complex e = expr();
			if(e == null || e.isOverflow()) return null;
			p++;
			return e;
		}
		Complex n = num();
		if(n == null || n.isOverflow()) return null;
		return n;
	}

	Complex num(){
		if(str.charAt(p)=='i'){
			p++;
			return new Complex(0,1);
		}
		int ret = str.charAt(p++) - '0';
		while(p<str.length() && Character.isDigit(str.charAt(p))){
			ret = ret*10 + str.charAt(p++) - '0';
			if(ret > 10000){
				return null;
			}
		}
		return new Complex(ret, 0);
	}

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

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

long long fact[100009], mod = 1000000007;

int main() {
	fact[0] = 1;
	for (int i = 1; i <= 100000; i++) fact[i] = (fact[i - 1] * 1LL * i) % mod;
	
	long long N, M; cin >> N >> M;
	if (N == M) cout << (2LL * fact[N] * fact[M]) % mod << endl;
	else if (abs(N - M) <= 1) cout << (fact[N] * fact[M]) % mod << endl;
	else cout << "0" << endl;
	return 0;
}

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

using namespace std;

constexpr int MAXN = 99;

char S[MAXN + 2];

int main() {
	cin >> S;
	int N = strlen(S), hn = N / 2;
	for(int i = 0; i < hn; i++)
		if(S[i] != S[N - 1 - i])
			goto no;
	for(int i = 0; i < hn / 2; i++)
		if(S[i] != S[hn - 1 - i])
			goto no;
	cout << "Yes" << '\n';
	return 0;
no:
	cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 2010
using namespace std;
bitset<N> dpl[N],dpr[N],a[N];
int n,x,ansn;
char ch;
int main(){
	cin>>n;
	for (int i=2;i<=n;i++){
		for (int j=1;j<i;j++){
			cin>>ch;x=ch-'0';
			a[i][j]=x;a[j][i]=1-x;
		}
	}
	for (int i=1;i<=n;i++)dpl[i][i]=dpr[i][i]=1;
	for (int l=2;l<=n;l++){
		for (int i=1;i+l-1<=n;i++){
			if ((a[i]&dpl[i+l-1]&dpr[i+1]).any())dpl[i+l-1][i]=1;
			if ((a[i+l-1]&dpl[i+l-2]&dpr[i]).any())dpr[i][i+l-1]=1;
		}
	}
	cout<<((dpr[1]&dpl[n]).count())<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.LinkedList;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int r=sc.nextInt();
        int g=sc.nextInt();
        int b=sc.nextInt();
        int ans=r*100+g*10+b;
        if(ans%4==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
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;}
// clang-format on

void solve(long long H, long long W, long long N, std::vector<long long> a) {
  vector<ll> c;
  rep(i, a.size()) rep(j, a[i]) c.pb(i + 1);
  rep(h, H) {
    if (h % 2 == 0) {
      rep(w, W) {
        cout << c[h * W + w];
        if (w < W - 1)
          cout << " ";
      }
      cout << endl;
    } else {
      string l;
      rrep(w, W) {
        l = to_string(c[h * W + (W - w - 1)]) + l;
        if (w != 0)
          l = " " + l;
      }
      cout << l << endl;
    }
  }
}

// clang-format off
int main() {
  long long H;
  scanf("%lld",&H);
  long long W;
  scanf("%lld",&W);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(H, W, N, std::move(a));
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}


int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		string s;
		cin>>s;
		ll tot = 0;
		rep(i,s.length()){
			tot+=s[i]-'0';
		}
		if(tot%9==0){
			cout<<"Yes";
		}
		else{
			cout<<"No";
		}
	}
	return 0;
}


Measured memory_bytes: 3776
A,B,C = map(int,input().split())
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
if A<B:
    x = B
    B = A
    A = x
if C%gcd(A,B)==0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
map<string,int> m;
int main(){
	m["MON"]=1;m["TUE"]=2;m["WED"]=3;m["THU"]=4;m["FRI"]=5;m["SAT"]=6;m["SUN"]=7;
	string s; cin>>s;
	if(s=="SUN") cout<<7;
	else cout<<(7-m[s]);

}


Measured memory_bytes: 3596
#include <iostream>
#include <map>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int C[500],S[500],F[500];
int ans[500];
int times;
void sull(int b){
    if(S[b] > times){
        times = S[b];
    }
    if(times % F[b] != 0){
        times = (times / F[b]+1)*F[b];
    }
    times += C[b];
}
int main()
{
    int N;
    cin >> N;
    for(int a = 0;a < N-1;a++){
        cin>>C[a]>>S[a]>>F[a];
    }
    for(int a = 0;a< N-1;a++){
        times = 0;
        for(int b = a;b<N-1;b++){
            sull(b);
        }
        ans[a] = times;
    }
    for(int a = 0;a < N-1;a++){
        cout<<ans[a]<<endl;
    }
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

AKB = 'AKIHABARA'
AKBL = list(AKB)

bits = []
for i in range(2 ** 4):
    b = format(i, 'b').zfill(4)
    bits.append(b)

# print(bits)

ss = []
for bi in bits:
    s = AKBL.copy()
    for i, b in enumerate(bi):
        if b == '1':
            if i == 0:
                s[0] = None
            elif i == 1:
                s[4] = None
            elif i == 2:
                s[6] = None
            elif i == 3:
                s[8] = None
    s = "".join([c for c in s if c is not None])
    ss.append(s)

if S in ss:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int n = 0, x = 0, i;
  int min = 1000, max = 0, sum = 0;
  
  while(1){
    scanf("%d",&n);
    if(n == 0){
      break;
    }
    sum = 0;
    max = 0;
    min = 1000;
    for(i = 0 ; i < n ; i++){
      scanf("%d",&x); 
      if(x < min){
	min = x;
      }
      if(x > max){
	max = x;
      }
      sum += x;
    }

  sum -= min;
  sum -= max;
  
  printf("%d\n",sum/(n - 2));
  }

  
  return 0;
}

Measured memory_bytes: 600
n,t = map(int,input().split(" "))

a = []
for i in range(n):
    check = list(map(int,input().split(" ")))
    if check[1] <= t:
        a.append(check)

if a == []:
    print("TLE")
else:
    ans = min(a,key = lambda x:x[0])[0]
    print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	char t; cin >> t;
	if (t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u')cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 262144+5;
int n, m, v, p[N], l[20][N], r[20][N];
int d[N], f[N], g[N];
void func(int v, int *l, int *r)
{
    l[1] = 1, r[n] = n;
    for(int i = 2; i <= n; ++i) l[i] = p[i]-p[i-1] <= v?l[i-1]:i;
    for(int i = n-1; i; --i) r[i] = p[i+1]-p[i] <= v?r[i+1]:i; 
    l[0] = 1, r[n+1] = n; 
}
void pusha(int l, int r) { if(l <= r) ++d[l], --d[r+1]; }
int main()
{
    n = read(), v = read();
    for(int i = 1; i <= n; ++i) p[i] = read();
    for( ; v; ++m, v >>= 1) func(v, l[m], r[m]); func(0, l[m], r[m]);
    g[0] = n+1;
    for(int s = 1; s < 1<<m; ++s)
    {
        g[s] = n;
        for(int i = 0; i < m; ++i)
            if(s>>i&1) f[s] = max(f[s], r[i+1][f[s^(1<<i)]+1]), g[s] = min(g[s], l[i+1][g[s^(1<<i)]-1]);
    }
    for(int s = 0; s < 1<<m; ++s) pusha(l[0][g[s^((1<<m)-1)]-1], r[0][f[s]+1]);
    for(int i = 1; i <= n; ++i) d[i] += d[i-1], puts(d[i]?"Possible":"Impossible");
    return 0;
}

Measured memory_bytes: 47360