akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
static int binSearch(const LLONG& xpoint, const LLONG* container, int contCount, int& secondIdx)
{
	int startPoint = 0, endPoint = contCount;
	int bsTarget = 0, tmpTarget = 0;
	LLONG dist = 0, tmpDist = 0;
	while (1) {
		bsTarget = (startPoint + endPoint) / 2;

		if ((endPoint - startPoint) < 2) {
			secondIdx = -1;

			if ((container[bsTarget] < xpoint) && ((bsTarget + 1) < contCount)) {
				secondIdx = bsTarget + 1;
			}
			else if ((container[bsTarget] >= xpoint) && ((bsTarget - 1) >= 0)) {
				secondIdx = bsTarget - 1;
			}

			break;
		}
		else if (container[bsTarget] < xpoint) {
			startPoint = bsTarget;
		}
		else if (container[bsTarget] > xpoint) {
			endPoint = bsTarget;
		}
	}
	return bsTarget;
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}

typedef std::pair<int, int> IntPair;


static void ABC117A_EntranceExam();


#if 1
int main()
{
	ABC117A_EntranceExam();

	fflush(stdout);
	return 0;
}
#endif

static void ABC117A_EntranceExam()
{
	int T, X;
	get2int(T, X);
	printf("%.8lf\n", (double)T / (double)X);
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


pri = prime_factorize(N)
c = Counter(pri)
val = list(c.values())

count = 0
for v in val:
    for i in range(1, v+1):
        if v >= i:
            v -= i
            count += 1
        else:
            break
print(count)


Measured memory_bytes: 9468
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);

 
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1+a2+a3 >= 22) cout << "bust";
  else cout << "win";

    return 0;
}

Measured memory_bytes: 256
//JOI2010-2011本選問４歩くサンタクロース(Walking Santa)
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

	long long sum = 0LL, osum = 0LL;
	long long f1, f2, f3, w, h, L, HL, temp, oxy[2][2], *LXY[2], *XY[2], ox, oy, max = 0, dx, dy;
	scanf("%lld %lld",&w, &h);
	scanf("%lld",&L);
	for(f1 = 0; f1 < 2; f1++){
		LXY[f1] = new long long [L];
		XY[f1] = new long long [L];
	}
	//100k
	for(f1 = 0; f1 < L; f1++){
		scanf("%lld %lld",&LXY[0][f1], &LXY[1][f1]);
		XY[0][f1] = LXY[0][f1];
		XY[1][f1] = LXY[1][f1];
	}
	//1m
	sort( XY[0], XY[0] + L );
	sort( XY[1], XY[1] + L );
	HL = (L + 1) / 2;
	//x軸での最小値の点、y軸での最小値の点を探す
	//200k
	if(L == 1){
		printf("0\n");
		printf("%lld %lld\n",LXY[0][0],LXY[1][0]);
	}
	else{
		for(f1 = 0; f1 < 2; f1++){
			oxy[0][f1] = XY[f1][HL-1];
			oxy[1][f1] = XY[f1][HL];
		}
		dx = (oxy[0][0] == oxy[1][0]) ? 1 : 2;
		dy = (oxy[0][1] == oxy[1][1]) ? 1 : 2;
		//400k
		for(f2 = 0; f2 < dx; f2++){
			for(f3 = 0; f3 < dy; f3++){
				sum = 0LL;
				max = 0LL;
				for(f1 = 0; f1 < L; f1++){
					temp = (long long)abs(LXY[0][f1] - oxy[f2][0]) + abs(LXY[1][f1] - oxy[f3][1]);
					sum += temp;
					if(max < temp)
						max = temp;
				}
				sum *= 2;
				sum -= max;
				if(osum == 0 || osum > sum){
					osum = sum;
					ox = oxy[f2][0];
					oy = oxy[f3][1];
				}
			}
		}
		printf("%lld\n", osum);
		printf("%lld %lld\n", ox, oy);
	}
	return 0;
}

Measured memory_bytes: 4344
import math
def gcd (a,b):
    n = min(a,b)
    m = max(a,b)
    
    b = m % n
    
    while b > 0:
        m = n
        n = b
        b = m % n
    
    return n

a, b = map(int,input().split())
c = math.floor(a * b / gcd(a,b))
print(c)

Measured memory_bytes: 3060
a,b,c,x,y=map(int, input().split())

#cのセット数の最大値
cmax=max(x,y)

t_list=[]

#cを何セット買うか
for i in range(cmax+1):
   total=i*2*c+max(0,x-i)*a+max(0,y-i)*b
   t_list.append(total)
    
print(min(t_list))
    

Measured memory_bytes: 12888
#include<iostream>
#define ll long long
using namespace std;
int main() {	
	int r,c;
	int buf;
	cin >> r >> c;
	int rsum[100]={};
	int csum[100]={};
	int sum=0;
	for (int i=0;i<r;i++) {
		cin >> buf;
		cout << buf;
		rsum[i]+=buf;
		csum[0]+=buf;
		for (int j=1;j<c;j++) {
			cin >> buf;
			cout << " "  << buf;
			rsum[i]+=buf;
			csum[j]+=buf;
		}
		cout << " " << rsum[i]<< endl;
		sum+=rsum[i];
	}
	cout << csum[0];
	for (int j=1;j<c;j++) {
		cout << " " << csum[j];
	}
	cout << " " <<sum << endl;
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int i, a[4], b[2], total = 0;
	for(i = 0; i < 4; i++) cin >> a[i];
	for(i = 0; i < 2; i++) cin >> b[i];
	sort(a, a + 4);
	for(i = 3; i >= 1; i--){
		total += a[i];
	}
	sort(b, b + 2);
	for(i = 1; i >= 1; i--){
		total += b[i];
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3148
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let mut a:Vec<i32> = (0..3).map(|_| read()).collect();

    a.sort();
    println!("{}", a[2]-a[0]);

}


Measured memory_bytes: 4352
def sum_of_gcd_tuples():
    from math import gcd
    K = int(input())
    total = 0

    for a in range(1, K + 1):
        for b in range(1, K + 1):
            for c in range(1, K + 1):
                total += gcd(gcd(a, b), c)

    print(total)


sum_of_gcd_tuples()

Measured memory_bytes: 9200
S = int(input())
a = S // 10 ** 9
b = S % 10 ** 9

if b == 0:
    print(0, 0, 0, a, 10 ** 9, 0)
else:
    print(0, 0, 10 ** 9 - b, a + 1, 10 ** 9, 1)

Measured memory_bytes: 3060
n,m = map(int, input().split())
h = list(map(int, input().split()))

ab = [0]*n
for _ in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

ans = 0
for i in range(n):
  if h[i] > ab[i]:
    ans += 1
print(ans)

Measured memory_bytes: 20116
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  map<long long,bool> m;
  int n;
  cin >> n;
  for(int i=0;i<n;++i){
    long long a;
    cin >> a;
    m[a] = !m[a];
  }
  int num=0;
  for(auto p:m){
    if(p.second){
      num++;
    }
  }
  cout << num << endl;
  return 0;
}

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

int main() {
    int N, P;
    string S;
    cin >> N >> P >> S;

    ll ans = 0;
    if (P == 2 || P == 5) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> r(N);
    map<int, int> mp;
    mp[0] = 1;
    r[N - 1] = (S[N - 1] - '0') % P;
    ans += mp[r[N - 1]];
    mp[r[N - 1]]++;
    int base = 1;
    for (int i = N - 2; i >= 0; i--) {
        base = (base * 10) % P;
        int v = S[i] - '0';
        r[i] = (base * v + r[i + 1]) % P;
        ans += mp[r[i]];
        mp[r[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1668
import math
n = int(input())
#n, m = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
abc = [int(input()) for i in range(5)]
_min = min(abc)
min_idx = abc.index(min(abc))
count = math.ceil(n/_min)
count += min_idx+(4-min_idx)
print(count)


Measured memory_bytes: 2940
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<climits>
#include<set> 
#include<string> 
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 1000
#define E5 10000 
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;
/*  //prime sieve if needed 
//prime factors of number
int prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}
*/
lld gcd(lld a,lld b)
{
    if(a==0)
     return b; 
    return gcd(b%a,a); 
}
//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
int main()
{
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld a,b,c,k; 
    cin>>a>>b>>c>>k; 
    
    while(b<=a) 
      { b*=2; k--; 
     } 
    while(c<=b) 
     { c*=2; k--; 
     }

   if(k>=0)
   cout<<"Yes"<<endl; 
   else 
   cout<<"No"<<endl; 
	return 0;
}

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

int main()
{
	string s,t;cin>>s>>t;
    int ct=0;
    for(int i=0;i<s.length();i++)
    {
     if(s[i]!=t[i])ct++;
    
    }
    cout<<ct;
	return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <algorithm>
using namespace std;
long long INF = 1001001001001;

long long score(long long a, long long b, long long c) {
	return max({a, b, c}) - min({a, b, c});
}

int main() {
	long long h, w;
	cin >> h >> w;
	long long ans = INF;
	if (h >= 3) ans = min(ans, (h+2)/3*w - h/3*w);
	if (w >= 3) ans = min(ans, (w+2)/3*h - w/3*h);
	for (long long a = 1; a < w; a++) {
		long long now = score(h*a, h/2*(w-a), (h+1)/2*(w-a));
		ans = min(ans, now);
	}
	for (long long a = 1; a < h; a++) {
		long long now = score(a*w, w/2*(h-a), (w+1)/2*(h-a));
		ans = min(ans, now);
	}
	cout << ans << endl;
	return 0;
}

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

const int mod = 1000000007; 

int main() {
  int s;
  cin >> s;
  vector<ll> dp(s+1);

  dp[0] = 1;
  for (int i = 3; i <= s; i++) {
    dp[i] = dp[i-1] + dp[i-3];
    dp[i] %= mod;
  }
  cout << dp[s];
}


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

int main() {
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; i++) cin >> t[i];

	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (t[i] - t[i - 1] <= T) ans += t[i] - t[i - 1];
		else ans += T;
	}
	ans += T;

	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
      	int T = sc.nextInt();
        int sam = 0;
        int sam2 = 0;
      
      for(int i=1;i<T+1;i++){
        if(A*i<=T){
          sam +=B;
        }

      }
      
      System.out.print(sam);

    }
}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		long[] A = new long[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
		}
		long N = A[0];
		long K = A[1];

		long ans = K*(long)Math.pow(K-1, N-1);


		System.out.println(ans);
	}
}


Measured memory_bytes: 21076
def resolve():
    N, W = list(map(int, input().split()))
    WV = [list(map(int, input().split())) for _ in range(N)]
    wbase = WV[0][0]
    d = {
        wbase: [0],
        wbase+1: [0],
        wbase+2: [0],
        wbase+3: [0],
    }
    for w, v in WV:
        d[w].append(v)
    for v in d.values():
        v.sort(reverse=True)
    
    accs = {}
    for i in range(4):
        accs[wbase+i] = [0]
        for j in range(len(d[wbase+i])):
            accs[wbase+i].append(accs[wbase+i][j]+d[wbase+i][j])
    
    res = 0
    for i in range(len(d[wbase])):
        for j in range(len(d[wbase+1])):
            for k in range(len(d[wbase+2])):
                for l in range(len(d[wbase+3])):
                    if i*wbase+j*(wbase+1)+k*(wbase+2)+l*(wbase+3) <= W:
                        res = max(res, accs[wbase][i]+accs[wbase+1][j]+accs[wbase+2][k]+accs[wbase+3][l])
    print(res)


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 68228
#include <stdio.h>

int main(){
	int n;
	int mod = 1e9+7;
	scanf("%d",&n);
	//ACGT以外の文字を含まない
	//AGCを部分列として含まない
	//A=0 G = 1 C = 2 T=3と考えると
	//012,021,102,0?12,01?2の5つがダメ
	//dp[x][c3][c2][c1];は長さxで一番右からc3c2c1と並んでおり合計数
	//dp[3][0][0][0]は長さ3で末尾に000が並んでいるってわけ
	int dp[101][4][4][4]={};
	int i,j,k;
	//長さ3の文字の合計数を1にセットする
	for(i=0;i<4;i++)for(j=0;j<4;j++)for(k=0;k<4;k++)dp[3][i][j][k]=1;
	//条件を満たさない奴の数を0にセットする
	dp[3][0][1][2]=0;
	dp[3][0][2][1]=0;
	dp[3][1][0][2]=0;
	int a,b,c,d;
	//現在の状態から追加できるかどうかを調べる
	for(i=3;i<n;i++){
		//dpの[][a][b][c]から新たにdを追加できるかどうか調べる
		for(a=0;a<4;a++){
			for(b=0;b<4;b++){
				for(c=0;c<4;c++){
					for(d=0;d<4;d++){
						if(dp[i][a][b][c]==0)continue;
						if(b==0&&c==1&&d==2)continue;
						if(b==0&&c==2&&d==1)continue;
						if(a==0&&c==1&&d==2)continue;
						if(a==0&&b==1&&d==2)continue;
						if(b==1&&c==0&&d==2)continue;
						dp[i+1][b][c][d]+= dp[i][a][b][c];
						dp[i+1][b][c][d]%=mod;
					}
				}
			}
		}
	}
	int ans = 0;
	for(a=0;a<4;a++){
			for(b=0;b<4;b++){
				for(c=0;c<4;c++){
					ans+=dp[n][a][b][c];
					ans %=mod;
				}
			}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int a[n+1], b[n];
    fore(i,0,n+1) cin >> a[i];
    fore(i,0,n) cin >> b[i];
    ll ans = 0;
    fore(i,0,n) {
        if (b[i] > a[i]) {
            b[i] -= a[i];
            ans += a[i];
            int mn = min(b[i], a[i+1]);
            a[i+1] -= mn;
            ans += mn;
        } else {
            ans += b[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){ll N,A,B,C,D,E;cin>>N>>A>>B>>C>>D>>E;ll mi=min({A,B,C,D,E});cout<<5+(N-1)/mi<<endl;}


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

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;

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

    for(int i = 0; i < n-1; i++){
        if(i+1 == p[i]){
            int tmp = p[i];
            p[i] = p[i+1];
            p[i+1] = tmp;
            count++;
        }
    }
    if(p[n-1] == n) count++;

    cout << count << endl;
}

Measured memory_bytes: 640
import sys
import math

l=[]
for i in range(101):
    l.append(0)
while 1:
    try:
        a = int(raw_input())
        l[a] += 1
    except:
        flag = 0
        for i in range(101):
            flag = max(flag, l[i])
        for i in range(101):
            if l[i] == flag:
                print i
        break

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

constexpr int inf = 1e9;

class starry_sky_tree {
public:
    starry_sky_tree(int n_)
    : n(expand(n_)), data(n * 2, 0), lazy(n * 2, 0)
    {}

    void add(int l, int r, int val) {
        l += n, r += n;
        const int left = l, right = r;
        while(l != r) {
            if(l & 1) {
                lazy[l] += val;
                data[l++] += val;
            }
            if(r & 1) {
                lazy[--r] += val;
                data[r] += val;
            }
            l /= 2, r /= 2;
        }
        l = left, r = right - 1;
        while(l /= 2, r /= 2) {
            data[l] = min(data[l * 2], data[l * 2 + 1]) + lazy[l];
            data[r] = min(data[r * 2], data[r * 2 + 1]) + lazy[r];
        }
    }

    // min
    int query(int l, int r) const {
        l += n, r += n;
        int res1 = inf, res2 = inf;
        while(l != r) {
            if(l & 1) res1 = min(res1, data[l++]);
            if(r & 1) res2 = min(res2, data[--r]);
            l /= 2, r /= 2;
            res1 += lazy[l - 1];
            res2 += lazy[r];
        }
        --l;
        while(l /= 2, r /= 2) {
            res1 += lazy[l];
            res2 += lazy[r];
        }
        return min(res1, res2);
    }

private:
    int expand(int n) {
        return n == 1 ? n : expand((n + 1) / 2) * 2;
    }

private:
    const int n;
    vector<int> data, lazy;
};

int main() {
    int N, Q;
    string s;
    cin >> N >> Q >> s;

    starry_sky_tree sum(N);
    set<int> right_paren;
    for(int i = 0; i < N; ++i) {
        if(s[i] == '(') {
            sum.add(i, N, 1);
        } else {
            sum.add(i, N, -1);
            right_paren.insert(i);
        }
    }

    while(Q--) {
        int q;
        cin >> q;
        q--;

        int ans = q;
        if(s[q] == '(') {
            sum.add(q, N, -2);
            right_paren.insert(q);
            ans = *right_paren.begin();
            right_paren.erase(ans);
            sum.add(ans, N, 2);
        } else {
            sum.add(q, N, 2);
            int lb = 0, ub = N - 1;
            while(ub - lb > 1) {
                const int mid = (lb + ub) / 2;
                if(sum.query(mid, N) >= 2) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }
            ans = ub;
            sum.add(ans, N, -2);
            right_paren.erase(q);
            right_paren.insert(ans);
        }
        swap(s[q], s[ans]);

        cout << ans + 1 << endl;
    }
}


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

struct Node{
  int key;
  Node *right;
  Node *left;
  Node *parent;
};

Node *NIL;
Node *root;
void insert(int);
void inorder(Node*);
void preorder(Node*);
Node* find(Node*,int);

int main(){
  int i,n,x;
  string comment;
  Node* t;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> comment;
    if(comment[0] == 'f'){
      cin >> x;
      t = find(root, x);
      if( t != NIL){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
    if(comment == "insert"){
      cin >> x;
      insert(x);
    }
    else if(comment == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}//END main function


void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z = new Node;
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((z->key) < (x->key)){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if((z->key) < (y->key)){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}//END insert function


void inorder(Node *u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL){
    return;
  }
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}//END inorder function


Node* find(Node* u,int k){
  while(u != NIL && k != u->key){
    if(k < (u->key)){
      u = u->left;
    }
    else{
      u = u->right;
    }
  }
  return u;
}//END find function

Measured memory_bytes: 21960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    double n;cin>>n;
    priority_queue<double, vector<double>, greater<double>> q;
    rep(i,n){double tmp;cin>>tmp;q.push(tmp);}
    rep(i,n-1){
        double a = q.top();q.pop();
        double b = q.top();q.pop();
        q.push((a+b)/2);
    }
    co(q.top());
}

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

using namespace std ;

typedef long long LL ;
const int N=1e6+10 ;

LL f[N][2] ;
LL a[N] ;
int n ;

int main ()
{
	int i ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ )
		scanf("%lld",a+i);
	f[2][0]=a[1]+a[2],
	f[2][1]=-f[2][0];
	for ( i=3 ; i<=n ; i++ )
		f[i][0]=max(f[i-1][0]+a[i],f[i-1][1]+a[i]),
		f[i][1]=max(f[i-1][0]-2*a[i-1]-a[i],f[i-1][1]+2*a[i-1]-a[i]);
	printf("%lld\n",max(f[n][0],f[n][1]));
	return 0 ;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for (int i=0;i<n;i++){
        cin>>p.at(i);
    }
    for (int i=0;i<n;i++){
        cin>>q.at(i);
    }
    vector<int> a;
    for (int i=0;i<n;i++){
        a.push_back(i+1);
    }
    int num_p=0,num_q=0;
        int cnt =1;
    do{
        int p_cnt=0;
        int q_cnt=0;
        //この中に処理を書く
        for (int i=0;i<n;i++){
            if(a.at(i)==p.at(i)) p_cnt++;
            if(a.at(i)==q.at(i)) q_cnt++;
        }
        if(p_cnt==n) num_p = cnt;
        if(q_cnt==n) num_q = cnt;
        cnt++;
    }while(next_permutation(a.begin(),a.end()));
    
    cout << abs(num_q-num_p) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



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

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<ll,pair<ll,ll>>>pll(n);
  for(int i=0;i<n;i++){
    cin>>pll[i].S.F>>pll[i].S.S>>pll[i].F;
  }
  sort(ALL(pll),greater<pair<ll,pair<ll,ll>>>());
  for(ll i=0;i<=100;i++){
    for(ll j=0;j<=100;j++){
      ll high=pll[0].F+(abs(pll[0].S.F-i)+abs(pll[0].S.S-j));
      bool ans=true;
      for(int k=1;k<n;k++){
	ll x=pll[k].S.F,y=pll[k].S.S;
	ll hi=pll[k].F;
	if(max(0LL,high-abs(x-i)-abs(y-j)) != hi){
	  ans=false;
	}
      }
      if(ans){
	cout<<i<<" "<<j<<" "<<high<<endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
jobs = defaultdict(int)
for i in range(N):
    Ai, Bi = map(int, input().split())
    jobs[Bi] += Ai

acu = 0
able = True
for Bi in sorted(jobs.keys()):
    acu += jobs[Bi]
    if acu > Bi:
        able = False
        break

print('Yes' if able else 'No')


Measured memory_bytes: 74456
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int x;
    cin>>x;
    int max=0;
    vector<int> v;
    for(int i=2;i<x;i++){
        int d=i;
        while(d<x){
            d*=i;
            if(d<=x){
                v.push_back(d);
            }
        }
    }
    if(v.size()<1){
        cout<<1<<endl;
    }else{
        sort(v.begin(),v.end());
        cout<<v.back()<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.Bits
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap

main = do
  n <- readLn
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = IntMap.fromListWith (+) $ U.toList $ U.map (\x -> (x, 1 :: Int)) xs
  let result | IntMap.size m <= 3 = case IntMap.toList m of
                                      [(a0,_)] -> a0 == 0
                                      [(a0,n0),(a1,n1)] | n0 == 2 * n1 -> a1 == 0
                                                        | n1 == 2 * n0 -> a0 == 0
                                                        | otherwise -> False
                                      [(a0,n0),(a1,n1),(a2,n2)] -> n0 == n1 && n1 == n2 && a0 == a1 `xor` a2
             | otherwise = False
  putStrLn $ if result then "Yes" else "No"


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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define each(it,c) for(__typeof(c.begin()) it=c.begin(); it!=c.end(); it++)
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;

typedef long long ll;

void FMS(vi x, int &l, int &r, int &m){
    double ms = 0; //maxsofar
    double me = 0; //maxendinghere
    int tmp = -1;
    l = r = -1;
    rep(i,x.size()){
        if (me + x[i] > 0){
            me = me + x[i];
            if (tmp == -1){
                tmp = i;
            }
        }
        else{
            me = 0;
            tmp = -1;
        }

        if (ms < me){
            ms = me;
            l = tmp;
            r = i;
        }
    }
    m = ms;
}

int main(){
	string s; cin>>s;
	int sz = s.size();
	vi t(sz);
	rep(i,sz){
		t[i] = char(s[i]) - 'a';
	}

	rep(i,26){
		int left,right,max_;
		vi a(sz);
		rep(j,sz){
			if(t[j]==i) a[j] = 2;
			else a[j] = -1;
		}
		FMS(a,left,right,max_);
		int x = 0;
		if(left==-1 || right==-1) continue;
		if(left==right) continue;
		for(int k=left;k<right+1;k++){
			if(t[k]==i) x++;
		}
		if(x > (right-left)/2) {
			cout<<left+1<<" "<<right+1<<endl;
			return 0;
		}
		//cout<<char(i+'a')<<" "<<left<<" "<<right<<" "<<x<<endl;
	}
	cout<<"-1 -1"<<endl;
	return 0;
}


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

signed main(){

  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(auto& si:s)cin>>si;

  vector<vector<int>> a(h,vector<int>(w));
  for(int i=0;i<h;++i)for(int j=0;j<w;++j){
    if(s[i][j]=='#')continue;
    a[i][j] = (s[i][j]-'0');
  }

  struct dice{
    int sita,ue,migi,hidari,temae,oku;
    dice(){}
    dice order(int x){
      if(x==1){
        return to_migi();
      }
      if(x==4){
        return to_oku();
      }
      if(x==3){
        return to_hidari();
      }
      if(x==2){
        return to_temae();
      }
      return *this;
    }
    dice to_migi(){
      dice nxt = *this;
      nxt.sita = migi;
      nxt.ue = hidari;
      nxt.migi = ue;
      nxt.hidari = sita;
      return nxt;
    }
    dice to_hidari(){
      dice nxt = *this;
      nxt.sita = hidari;
      nxt.ue = migi;
      nxt.hidari = ue;
      nxt.migi = sita;
      return nxt;
    }
    dice to_oku(){
      dice nxt = *this;
      nxt.sita = oku;
      nxt.ue = temae;
      nxt.temae = sita;
      nxt.oku = ue;
      return nxt;
    }
    dice to_temae(){
      dice nxt = *this;
      nxt.sita = temae;
      nxt.ue = oku;
      nxt.temae = ue;
      nxt.oku = sita;
      return nxt;
    }
    
  };

  dice d;
  d.sita = 6;
  d.ue = 1;
  d.migi = 3;
  d.hidari = 4;
  d.temae = 2;
  d.oku = 5;

  using T = tuple<int,int,dice>;
  queue<T> que;
  que.emplace(0,0,d);
  vector<vector<int>> visited(h,vector<int>(w,0));
  constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
  constexpr int dy[]={0,1,0,-1,1,-1,1,-1};
  constexpr int dd[]={1,2,3,4};
  while(!que.empty()){
    int y,x;
    dice d;
    tie(y,x,d) = que.front();
    que.pop();
    if(visited[y][x])continue;
    visited[y][x] = 1;
    for(int i=0;i<4;++i){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny==h||nx==w||ny==-1||nx==-1)continue;
      if(s[ny][nx]=='#')continue;
      dice nxt = d.order(dd[i]);
      if(nxt.sita==a[ny][nx])que.emplace(ny,nx,nxt);
    }
  }
  cout<<(visited[h-1][w-1]?"YES":"NO")<<endl;

}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	double a, b, x; cin >> a >> b >> x;
	x /= a;

	const double d = 3.14159265358979 / 180.0;

	if (x >= b * a / 2) {
		double l = a * b - x;
		double rcosa = a;
		double rsina = 2 * l / a;
		double ans = atan(rsina / rcosa);
		cout << setprecision(10) << (ans / d) << endl;
	}
	else {
		double rcosa = 2 * x / b;
		double rsina = b;
		double ans = atan(rsina / rcosa);
		cout << setprecision(10) << (ans / d) << endl;
	}
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	cout << ( ( X - A ) % B ) << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s >> t;
  rep(i, Size(s)) {
    if (s[i] == t[i]) continue;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>


int main()
{

    int s,w;
    scanf("%d %d", &s,&w);
    int c, d;
    scanf("%d %d", &c, &d);

    while(s>=0&&c>=0){

        c = c - w;
        if (c <= 0)
        {
            printf("Yes");
            break;
        }

        s=s - d;
        if(s<=0){
            printf("No");
            break;
        }
    }


    printf("\n");
}

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

int main() {
    int n;
    long long ans;
    cin >> n;
    vector<int> kushi(n*2);
    for (int i=0; i<n*2; i++)
        cin >> kushi[i];
    sort(kushi.begin(), kushi.end());
    for (int i=0; i<n*2; i+=2)
        ans += kushi[i];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n;
string board[300];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> board[i];

  int count = 0;
  for (int b = 0; b < n; b++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (board[i][(j+b)%n] != board[j][(i+b)%n]) {
          ok = false;
          break;
        }
      }
      if (!ok) break;
    }
    if (ok) count++;
  }

  cout << count*n << endl;

  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    string s, t;
    cin >> s >> t;
    int s_len = s.size();
    int t_len = t.size();
    int num = -1;
    for (int i = s_len - t_len; 0 <= i; --i) {
        bool flag = true;
        for (int j = 0; j < t_len; ++j) {
            if (s[i + j] != '?' && s[i + j] != t[j]) {
                flag = false;
            }
        }
        if (flag) {
            num = i;
            break;
        }
    }

    
    if (num == -1) {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        rep(i,s_len) {
            if (num <= i && i < num + t_len) {
                cout << t[i - num];
            }
            else if (s[i] == '?') cout << 'a';
            else cout << s[i];
        }
        cout << endl;
    }


    
    return 0;
}






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

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

  sort(A, A + N);
  cout << A[N -1] - A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define f(a,b) a=(a+b)%mod;
typedef long long ll;

using namespace std;
ll h,w,k;
#define H 110
#define W 8
ll dp[H][W];
int main(){
    cin>>h>>w>>k;
    lol(i,H)lol(j,W)dp[i][j]=0;dp[0][0]=1;
    lol(f,h)lol(g,w){
	lol(i,(1<<(w-1))){
	    bool ok=1;
	    lol(j,w-1){
		if((i>>j)&1&&(i>>(j+1))&1)ok=0;
	    }
	    if(ok==0)continue;
	    bool L=0,R=0;
	    if(g>0){
		if((i>>(g-1))&1)L=1;
	    }
	    if(g<w-1){
		if((i>>g)&1)R=1;
	    }
	    if(L==1&&R==0){
		f(dp[f+1][g-1],dp[f][g]);
	    }
	    if(L==0&&R==1){
		f(dp[f+1][g+1],dp[f][g]);
	    }
	    if(L==0&&R==0){
		f(dp[f+1][g],dp[f][g]);
	    }
	}
    }
    cout<<dp[h][k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
color = {}
wild = 0
a = [int(i) for i in input().split()]
for i in range(n):
  if a[i] < 400:
    color[0] = 1
  elif a[i] < 800:
    color[1] = 1
  elif a[i] < 1200:
    color[2] = 1
  elif a[i] < 1600:
    color[3] = 1
  elif a[i] < 2000:
    color[4] = 1
  elif a[i] < 2400:
    color[5] = 1
  elif a[i] < 2800:
    color[6] = 1
  elif a[i] < 3200:
    color[7] = 1
  else:
    wild += 1

if(len(color) == 0):
  print(1, wild)
else:
  print(len(color), len(color)+wild)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll gcd(ll n, ll m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        ll r = n % m;
        n = m;
        m = r;
    }
    return n;
}

ll modinv(int n, int p) {
    int m = p, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + p : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a;
    x = 1;
    y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

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

    if (n == 1) {
        cout << 1 << endl;
        exit(0);
    } else if (n == 2) {
        cout << 3 << endl;
        exit(0);
    }

    n *= 2;

    ll r = n - 1;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ll j = n / i;
            if (gcd(i, j) == 1) {
                ll a, b;
                extgcd(i, j, a, b);
                if (a == 0 || b == 0) continue;
                if (a < 0) {
                    a *= -1;
                    r = min(r, a * i);
                } else {
                    b *= -1;
                    r = min(r, b * j);
                }
            }
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
//Cancel in interactive questions
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans;
const int N=3e3+10;
int f[N][N];
main()
{
    IOS
    int s,n,m;
    cin>>s>>t>>n>>m;
    f[s][t]=1;
    fu(i,s,n)
    {
        fu(j,t,m)
        {
            if(i==s && j==t)continue;
            f[i][j]=mod(mod(f[i-1][j]*j)+mod(f[i][j-1]*i)-mod(mod(f[i-1][j-1]*(i-1))*(j-1)));
            if(f[i][j]<0)while(1);
        }
    }
    out(f[n][m])

    return 0;
}

Measured memory_bytes: 74060
N = int(input())
a_list = list(map(int, input().split()))

#偶数のaだけ取り出す
a_even = []
for a in a_list:
	if a % 2 == 0:
		a_even.append(a)

times = 0

while len(a_even) > 0:
	a_even[0] /= 2
	times += 1

	if a_even[0] % 2 == 1:
		a_even.pop(0)

print(times)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  string S; cin >> S;
    
  int sol = 1;
  char now = S.at(0);

  for(int i=0; i<N-1; i++){
    if( S.at(i) != S.at(i+1) ){
      sol++;
      now = S.at(i+1);    
    }
  }
  
  cout << sol << endl;

}

Measured memory_bytes: 512