akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		final int DICE = 6;
		int dice[] = new int[DICE];
		int question, front, upsurface, rightside = 0;
		
		
		for (int i = 0; i < DICE; i++) {
			dice[i] = scan.nextInt();
		}
		
		question = scan.nextInt();
		
		for (int i = 0; i < question; i++) {
			upsurface = scan.nextInt();
			front = scan.nextInt();
			for ( int j = 0; j < DICE; j++) {
				if ( dice[j] == front) {
					switch (j) {
					case 0:
						if (dice[1] == upsurface) {
							rightside = dice[3];
						} else if (dice[2] == upsurface) {
							rightside = dice[1];
						} else if (dice[3] == upsurface) {
							rightside = dice[4];
						} else {
							rightside = dice[2];
						}
						break;
					case 1:
						if (dice[0] == upsurface) {
							rightside = dice[2];
						} else if (dice[2] == upsurface) {
							rightside = dice[5];
						} else if (dice[3] == upsurface) {
							rightside = dice[0];
						} else {
							rightside = dice[3];
						}
						break;
					case 2:
						if (dice[0] == upsurface) {
							rightside = dice[4];
						} else if (dice[1] == upsurface) {
							rightside = dice[0];
						} else if (dice[4] == upsurface) {
							rightside = dice[5];
						} else {
							rightside = dice[1];
						}
						break;
					case 3:
						if (dice[0] == upsurface) {
							rightside = dice[1];
						} else if (dice[1] == upsurface) {
							rightside = dice[5];
						} else if (dice[4] == upsurface) {
							rightside = dice[0];
						} else {
							rightside = dice[4];
						}
						break;
					case 4:
						if (dice[0] == upsurface) {
							rightside = dice[3];
						} else if (dice[2] == upsurface) {
							rightside = dice[0];
						} else if (dice[3] == upsurface) {
							rightside = dice[5];
						} else {
							rightside = dice[2];
						}
						break;
					case 5:
						if (dice[1] == upsurface) {
							rightside = dice[2];
						} else if (dice[2] == upsurface) {
							rightside = dice[4];
						} else if (dice[3] == upsurface) {
							rightside = dice[1];
						} else {
							rightside = dice[3];
						}
						break;
					default:
						break;
						
					}
				}
			}
			System.out.println(rightside);
		}
		
		scan.close();
	}
}


Measured memory_bytes: 26216
h,w,n=map(int,input().split())
D=dict()
for i in range(n):
    a,b=map(int,input().split())
    for p in range(-1,2):
        for q in range(-1,2):
            aa=a+p
            bb=b+q
            if 2<=aa<=h-1 and 2<=bb<=w-1:
                aabb=str(aa)+"_"+str(bb)
                if aabb in D:
                    D[aabb]+=1
                else:
                    D[aabb]=1
ans=[0]*10
V=list(D.values())
for v in V:
    ans[v]+=1
ans[0]=(h-2)*(w-2)-sum(ans)
for i in range(10):
    print(ans[i])

Measured memory_bytes: 128532
import sys

X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)
    sys.exit()

for i in range(N + 1):
    if p.count(X - i) == 0:
        print(X - i)
        sys.exit()
    elif p.count(X + i) == 0:
        print(X + i)
        sys.exit()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	string str;
	getline(cin,str);
	rep(i,0,str.length()){
		if(islower(str[i])) str[i] = toupper(str[i]);
		else if(isupper(str[i])) str[i] = tolower(str[i]);
	}
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int W = 10000;

int dp[N+1][W+1];
vector<int> v,w;

int main(){
    int n,m;

    cin >> n >> m;

    for(int i=0; i<n; i++){
        int s,t;
        cin >> s >> t;
        v.push_back(s);
        w.push_back(t);
    }

    for(int i=0; i<=m; i++){
        dp[0][i] = 0;
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<=m; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[n][m] << endl;
}

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

typedef long long ll;
using namespace std;

int main(void) {
  int r, D, x2; 
  cin >> r >> D >> x2;
  for (int i = 1; i <= 10; i++)
  {
    x2 = r * x2 - D;
    cout << x2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 6
#define INT(X) \
  ( (int)(X) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int r[ N ] = { 0 };
  int n, i;

  scanf ( "%d", &n );
  while ( n-- )
  {
    double d;

    scanf ( "%lf", &d );
    if      ( d <  165.0 ) ++r[ 0 ];
    else if ( d >= 185.0 ) ++r[ N - 1 ];
    else                   ++r[ 1 + ( INT( d ) - 165 ) / 5 ];
  }

  for ( n = 0; n < N; ++n )
  {
    printf ( "%d:", n + 1 );
    for ( i = 0; i < r[ n ]; ++i ) putchar ( '*' );
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
	int n,k;
	cin>>n>>k;
	int p=n/k;
	int val1=n-p*k;
	int val2=n-(p+1)*k;
	val1=abs(val1);
	val2=abs(val2);
	cout<<min(val1,val2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    vint P = input_to_vector(n);
    sort(all(P));
    P[n-1] = P[n-1] / 2;
    int ans = 0;
    ans = accumulate(all(P), 0);
    print(ans);
}


Measured memory_bytes: 256
def main():
    ss = list(input())
    n = len(ss)
    ans = [0] * n
    cnt = 0
    for i in range(n):
        if ss[i] == "R":
            cnt += 1
        else:
            even_num = cnt // 2
            odd_num = cnt - even_num
            ans[i] += even_num
            ans[i-1] += odd_num
            cnt = 0
    cnt = 0
    for i in range(n-1, -1, -1):
        if ss[i] == "L":
            cnt += 1
        else:
            even_num = cnt // 2
            odd_num = cnt - even_num
            ans[i] += even_num
            ans[i+1] += odd_num
            cnt = 0
    print(*ans)


if __name__ == "__main__":
    main()


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

int main()
{

   string s;
   cin>>s;
int sum=0,a[4],i;
   for(i=0;i<4;i++)
   {
        a[i] = (s[i] - '0');





   }

int x=a[0]*10+a[1];
int y=a[2]*10+a[3];


if(x<13 && x>0)
{
if(y<13 && y>0)
    {
        cout<<"AMBIGUOUS";
    }
    else
        cout<<"MMYY";

}
if(y<13 && y>0)
{
    if(x==0 || x>12)

    cout<<"YYMM";
}
if((x==0 ||x>12 )&&(y==0 ||y>12))
    cout<<"NA";






    }






Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7


N = int(readline())
SP = [list(readline().split()) + [i+1] for i in range(N)]
for i in range(N):
    SP[i][1] = int(SP[i][1])
SP.sort(key=lambda x: (x[0], -x[1]))
for i in range(N):
    print(SP[i][2])

Measured memory_bytes: 9332
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

ll lunlun[100000 + 5];
int lunlun_sz = 0;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	queue<ll> q;

	for (int i = 1; i <= 9; ++i) q.push(i);

	while (!q.empty() && lunlun_sz < 100000)
	{
		ll temp = q.front();
		q.pop();

		lunlun[lunlun_sz++] = temp;

		int last_digit = temp % 10;
		if (last_digit > 0) q.push(temp * 10 + last_digit - 1);
		q.push(temp * 10 + last_digit);
		if (last_digit < 9) q.push(temp * 10 + last_digit + 1);
	}

	int K;

	scanf("%d", &K);
	printf("%lld\n", lunlun[K - 1]);

	return 0;
}

Measured memory_bytes: 2560
from collections import defaultdict
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
    s.append(list(map(int,input().split())))
dic = defaultdict(int)
for i in range(1,d+1):
    maxscore = -10000000
    maxcontest = -1
    for k in range(26):
        score = 0
        score += s[i-1][k-1]
        for j in range(26):
            if j != k:
                score -= c[j]*(i-dic[j])
        if score > maxscore:
            maxscore = score
            maxcontest = k
    print(maxcontest+1)
    dic[maxcontest] = i


Measured memory_bytes: 69544
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

int n, m;
string ans[MXN];

vector <pair <int, int> > v[MXN];

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= m; i ++) {
        int p, y;
        cin >> p >> y;
        v[p].pb ({y, i});
    }
    for (int i = 1; i <= n; i ++) {
        sort (all(v[i]));
        for (int j = 1; j <= v[i].size (); j ++) {
            int sz = log10(i) + 1;
            string x = "";
            for (int k = 1; k <= 6 - sz; k ++) {
                x += '0';
            }
            x += to_string(i);
            sz = log10(j) + 1;
            for (int k = 1; k <= 6 - sz; k ++) {
                x += '0';
            }
            x += to_string(j);
            ans[v[i][j - 1].s] = x;
        }
    }
    for (int i = 1; i <= m; i ++) {
        cout << ans[i] << '\n';
    }
    return 0;
}


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

bool cmp1(char a, char b)
{
    return a<b;
}

bool cmp2(char a, char b)
{
    return a>b;
}
int main()
{
    char  a[105],b[105];
    cin >> a >> b;
   /* string a1[105];
    string b1[105];
    for(int i=0;i<a.length();i++)
    {
        a1[i]=a[i];
    }
    for(int i=0;i<b.length();i++)
    {
        b1[i]=b[i];
    }*/
    int sum1=0;
    int sum2=0;
    for(int i=0;;i++){
        if(a[i]!='\0') sum1++;
        else break;
    }
    for(int i=0;;i++){
        if(b[i]!='\0') sum2++;
        else break;
    }
   // int a1=a.size();
   //int b1=b.size();
    sort(a,a+sum1,greater<char>());
    sort(b,b+sum2,greater<char>());
    char c[105];
    string c1;
    for(int i=sum1-1,j=0;i>=0;i--,j++){
        c[j]=a[i];
    }
  // cout <<b <<endl<<a<<endl <<c<<endl;
    if(strcmp(c,b)<0)  cout <<"Yes";
    else cout << "No";
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll h, a;
    cin >> h >> a;
    MSG(ceil((double)h / a))
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;

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

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

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

using namespace std;


class D {
	int n;
	vector<int> a;
	vector<ll> cum;

public:
	D()
	{
		cin >> n;
		a.resize(n);
		cum.resize(n, 0);

		int ai;
		cin >> ai;
		a[0] = cum[0] = ai;

		REP(i, n - 1)
		{
			cin >> ai;
			a[i + 1] = ai;
			cum[i + 1] = cum[i] + ai;
		}
	}

	void solve()
	{
		ll ans{ 9223372036854775807 };
		ll tmp[4];

		int first{ 0 };
		int second{ 1 };
		int third{ 2 };
		ll mindiff;

		for (; second <= n - 3; second++)
		{

			mindiff = 9223372036854775807;
			for (int tmpfirst{ first }; tmpfirst < second; tmpfirst++)
			{
				ll left{ cum[tmpfirst] };
				ll right{ cum[second] - cum[tmpfirst] };

				if (chmin(mindiff, abs(left - right)))
				{
					tmp[0] = left;
					tmp[1] = right;
					first = tmpfirst;
				}
				else
					if (left > right)
						break;

			}

			mindiff = 9223372036854775807;
			for (int tmpthird{ third }; tmpthird <= n - 2; tmpthird++)
			{
				ll left{ cum[tmpthird] - cum[second] };
				ll right{ cum[n - 1] - cum[tmpthird] };

				if (chmin(mindiff, abs(left - right)))
				{
					tmp[2] = left;
					tmp[3] = right;
					third = tmpthird;
				}
				else
					if (left > right)
						break;
			}

			ll ma{ tmp[0] };
			chmax(ma, tmp[1]); chmax(ma, tmp[2]); chmax(ma, tmp[3]);
			ll mi{ tmp[0] };
			chmin(mi, tmp[1]); chmin(mi, tmp[2]); chmin(mi, tmp[3]);
			
			chmin(ans, abs(ma - mi));
		}

		cout << ans << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 2560
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

for a in A:
    if a % 2 == 0 and (a % 3 != 0 and a % 5 != 0):
        print('DENIED')
        exit()

print('APPROVED')


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>

using namespace std;
using ll = long long;

int main(){
    ll i;
    cin >> i;
    ll j = i % 500;
    cout << ((i / 500) * 1000 + (j / 5) * 5) << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define inp 200005
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

// Pick yourself up, 'cause...

string s,t;
vector<int> ans;
vector<vector<int>> dp(3001,vector<int>(3001,-1));

int lcs(int n,int m)
{
    if(n==0 || m==0) return 0;
    if(dp[n][m]!=-1) return dp[n][m];

    if(s[n-1]==t[m-1]) dp[n][m]=1+lcs(n-1,m-1);
    else dp[n][m]=max(lcs(n-1,m),lcs(n,m-1));
    return dp[n][m];
}

void func(int n,int m)
{
    if(n==0 || m==0) return ;

    if(s[n-1]==t[m-1]) 
    {
        ans.push_back(n);
        func(n-1,m-1);
        return ;
    }
    if(lcs(n-1,m)>lcs(n,m-1)) func(n-1,m);
    else func(n,m-1);
}

int main()
{
    jaldi

    cin>>s>>t;

    func(s.length(),t.length());
    
    for(auto it=ans.rbegin();it!=ans.rend();it++) cout<<s[*it-1];
    return 0;
}


Measured memory_bytes: 36096
#include<stdio.h>

int main(void){
  int n,ans=0,i;
  scanf("%d",&n);
  int h[n];
  for(i=0;i<n;i++) scanf("%d",&h[i]);
  for(i=0;i<n-1;i++){
    if(h[i]>h[i+1]) ans += h[i]-h[i+1];
  }
  ans += h[n-1];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
program sumitrust2019b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i

    read*, n
    do i=1,n
        if (int(i*1.08d0) == n) then
            print'(i0)', i
            stop
        end if
    end do
    print'(a)', ':('
end program sumitrust2019b

Measured memory_bytes: 256
Cij = [ list( map(int,input().split()) ) for _ in range(3)]

b  = Cij[0][0] + Cij[1][1] == Cij[0][1] + Cij[1][0]
b &= Cij[1][1] + Cij[2][2] == Cij[2][1] + Cij[1][2]
b &= Cij[2][2] + Cij[0][0] == Cij[2][0] + Cij[0][2]

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


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

string f(ll n) {
  if (n == 0) return "";
  n--;
  return f(n/26) + string(1, 'a'+n%26);
}

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

  ans = f(n);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
    int K,A,B;
    scanf("%d",&K);
    scanf("%d %d",&A,&B);
    int i;
    int flg=0;
    for(i=A; i<=B; i++){
        if(i%K==0)
          flg=1;
    }
    if(flg==1)
        printf("OK");
    else
        printf("NG");
    
    return 0;
}

Measured memory_bytes: 1732
import sys

input = sys.stdin.readline


def main():
    H, N = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    if sum(A) >= H:
        print("Yes")
    else:
        print("No")


    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 13588
n,m=map(int,input().split())
a=[input()for _ in range(n)]
b=[input()for _ in range(m)]
f=False
l=n-m+1
for i in range(l):
      for j in range(l):
            f1=True
            for  k in range(m):
                  if b[k]==a[i+k][j:j+m]:
                        continue
                  else:
                        f1=False
                        break
            if f1:
                  f=True
                  break                        
print('Yes' if f else 'No')


Measured memory_bytes: 3064
n, m = map(int, input().split())
s = [0] * 10
c = [0] * 10
for i in range(m):
    s[i], c[i] = map(int, input().split())
    if n > 1 and s[i] == 1 and c[i] == 0:
        print("-1")
        exit(0)

tb = {}
for i in range(m):
    if s[i] in tb:
        if tb[s[i]] != c[i]:
            print("-1")
            exit(0)
    tb[s[i]] = c[i]

ans = ''
for i in range(1, n + 1):
    if i in tb:
        ans += str(tb[i])
    else:
        if n > 1 and i == 1:
            ans += '1'
        else:
            ans += '0'
print(ans)


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll a, b;

vector<ll> store;

ll ans = 0;

/////////////////////////////////////////////////////////////
ll mypow_core(ll x, int n, ll result) {
  if (n == 0) {
    return result;
  }

  if (n % 2 == 0) {
    return mypow_core(x * x, n / 2, result);
  }
  else {
    return mypow_core(x, n - 1, x * result);
  }
}

ll mypow(ll x, int n) {
  return mypow_core(x, n, 1);
}
/////////////////////////////////////////////////////////////

ll count_one(int k, ll x) {
  ll band = mypow(2, k + 1);

  ll dude = mypow(2, k);;

  ll part = (x + 1) / band;

  ll num = dude * part;

  ll cut = (x + 1) % band;

  if (cut == 0) {
    return num;
  }
  else {
    if (cut >= (band / 2) + 1) {
      return num + cut - ((band / 2) + 1) + 1;
    }
    else {
      return num;
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%lld %lld", &a, &b);

  int size = log2(b) + 1;

  for (int i = 0; i <= size; ++i) {
    ll bottom = count_one(i, a - 1);
    ll top = count_one(i, b);

    ll num_one = top - bottom;

    if (num_one % 2 == 0) {
      store.push_back(0);
    }
    else {
      store.push_back(1);
    }
  }

  for (int i = 0; i < store.size(); ++i) {
    ll tmp = mypow(2, i);
    ll diff = tmp * store[i];
    ans += diff;
  }

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

  return 0;
}


Measured memory_bytes: 256
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(value => Number(value));

    var ans = 0;
    for (var i = 0; i < N; i++) {
        for (var j = i; j < N; j++) {
            var result = Math.abs(A[i] - A[j]);
            ans = Math.max(ans, result);
        }
    }
    console.log(ans);
});

Measured memory_bytes: 11724
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
    if(n<8){
        fill(ret, ret+n*2-1, 0);
        for(size_t i=0; i<n; ++i)
        for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
    }else
    if(n&1){
        go_karatsuba(a,b,ret,n-1);
        ret[n*2-3] = 0;
        for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
        ret[n*2-2] = a[n-1]*b[n-1];
    }else{
        auto ar = a, al = a+n/2, 
		     br = b, bl = b+n/2,
        	 asum = ret+n*5, bsum = asum+n/2,
        	 x1 = ret, x2 = x1+n, x3 = x2+n;
        for(size_t i=0; i<n/2; ++i){
            asum[i] = al[i] + ar[i];
            bsum[i] = bl[i] + br[i];
        }
        go_karatsuba(ar, br, x1, n/2);
        go_karatsuba(al, bl, x2, n/2);
        go_karatsuba(asum, bsum, x3, n/2);
        for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
        for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21876
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] score = new int[n];
        int sum = 0;

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

        for (int i = 0; i < n; i++) {
            sum += score[i];
        }

        if (sum % 10 != 0) {
            System.out.println(sum);
        } else {
            for (int i = 0; i < n; i++) {
                if(score[i] % 10 != 0) {
                    sum -= score[i];
                    System.out.println(sum);
                    break;
                }
            }
        }
        if(sum % 10 == 0)
            System.out.println(0);
    }
}

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

int main() {
	int n,x,t;
	scanf("%d %d %d", &n, &x, &t);
	int ans = (n / x + (n % x ? 1 : 0)) * t;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3840
N = gets.chomp.split("").map(&:to_i)

if N[0]==0 && N[1]!=0
  first = true
elsif (N[0]==1)&&(N[1]<=2)
  first = true
else
  first = false
end

if N[2]==0 && N[3]!=0
  second = true
elsif (N[2]==1)&&(N[3]<=2)
  second = true
else
  second = false
end

if first && second
  puts "AMBIGUOUS"
elsif first && !second
  puts "MMYY"
elsif !first && second
  puts "YYMM"
else
  puts "NA"
end

Measured memory_bytes: 1788
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;

lli keta(lli h)
{
    lli cnt = 0;
    while (h) {
        cnt++;
        h /= 10;
    }
    return cnt;
}
int main()
{
    lli ans = 1e10;
    lli n;
    cin >> n;
    for (lli i = 1; i * i <= n; i++) {
        if (n % i)
            continue;
        ans = min(max(keta(n / i), keta(i)), ans);
    }
    cout << ans << endl;
}


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

#define rep(i,a,n) for (int i = a;i<=n;++i)
#define per(i,a,n) for (int i = n;i>=a;--i)
#define all(x) (x).begin(), (x).end()     
#define SZ(x) ((int)x.size())

typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef long double ld;

mt19937 mrand(random_device{}());
ll rnd(ll a, ll b) { return a + mrand() % (b - a + 1); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
      ios::sync_with_stdio(false); cin.tie(0);
#ifdef arrias
      freopen("a.txt", "r", stdin);
#endif
      int n, m, s = 0;
      cin >> n >> m;
      while (m--) {
            int a; cin >> a;
            s += a;
      }
      cout << ((s <= n) ? n - s : -1);
      return 0;
}

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

int main(){
    int n , m;
    cin>>n>>m;
    vector<int> a(1000),b(1000),p(1000);
    for(int i=0;i<n;i++){
        p[i]=0;
    }
     for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>b[j];
            if(b[j]==a[i]){
                p[j]++;
            }
            else{
                p[a[i]-1]++;
            }
        }
        
    }

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


    return 0;
}










Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
long long n , x[300] , y , sol;
bool gen;
int main(){
	cin >> n >> y;
	gen = true;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
		if(x[i] % 2 != 0)gen = false;
	}
	
	if(gen && y == 0){
		cout << (1ll << n) << endl;
	}
	else if(gen && y == 1){
		cout << 0 << endl;
	}
	else{
		cout << (1ll << (n - 1)) << endl;
	}
}

Measured memory_bytes: 3556
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    var current = 1
    var result = 0

    for (i in 0 until N) {
        if (a[i] == current) {
            current++
            continue
        }
        result++
    }

    if (result == N) result = -1
    println(result)
}

Measured memory_bytes: 84572
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
int a[114514];
vector<int>V;
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);

	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) {
			V.push_back(a[i]);
			i++;
		}
	}
	if (V.size() < 2)puts("0");
	else cout << V[V.size() - 1] * V[V.size() - 2] << endl;
}

Measured memory_bytes: 1660
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct Score{
  int c, s, t;
  
  Score(): c(0), s(0), t(0){}
  bool operator>(const Score& rhs) const{
	return c > rhs.c || (c == rhs.c &&
						 (s < rhs.s || (s == rhs.s && t < rhs.t)));
  }
};

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

  while(true){
	int T, P, R; cin >> T >> P >> R; if(T == 0) break;
	int table[51][11];
	fill((int*)table, (int*)table+51*11, 0);
	REP(r,R){
	  int tid, pid, t; string msg;
	  cin >> tid >> pid >> t >> msg;
	  if(msg == "CORRECT")
		table[tid][pid] = table[tid][pid] * -1200 + t;
	  else
		--table[tid][pid];
	}
	vector<Score> sc(T);
	for(int i=1;i<=T;++i){
	  sc[i-1].t = i;
	  for(int j=1;j<=P;++j)
		if(table[i][j] > 0){
		  ++sc[i-1].c;
		  sc[i-1].s += table[i][j];
		}
	}
	sort(ALL(sc), greater<Score>());
	for(int i=0;i<T;++i)
	  cout << sc[i].t << " " << sc[i].c << " " << sc[i].s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> p(n);
    vector<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
        for (int x = -2; x <= 0; x++) {
            for (int y = -2; y <= 0; y++) {
                st.emplace_back(p[i].first + x, p[i].second + y);
            }
        }
    }
    sort(p.begin(), p.end());
    sort(st.begin(), st.end());
    st.erase(unique(st.begin(), st.end()), st.end());
    vector<ll> ans(10);
    for (auto z : st) {
        int x, y;
        tie(x, y) = z;
        int s = 0;
        if (x <= 0 || y <= 0 || x > h - 2 || y > w - 2) continue;
        for (int i = x; i < x + 3; i++) {
            for (int j = y; j < y + 3; j++) {
                pair<int, int> t = {i, j};
                s += (int)binary_search(p.begin(), p.end(), t);
            }
        }
        ans[s]++;
    }
    ans[0] = (ll)(h - 2) * (ll)(w - 2);
    for (int i = 1; i < 10; i++) {
        ans[0] -= ans[i];
    }
    for (int i = 0; i < 10; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

#define ll long long

ll M = 998244353;

ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }

const int N = 5e5 + 5;
ll fact[N], inv[N];
 
void pre(int n){fact[0] = inv[0] = 1;for(ll i=1;i<=n;i++){fact[i] = (fact[i-1]*i)%M;inv[i] = powerm(fact[i],M-2);}}
 
ll C(ll n,ll r){ll ans = ((fact[n]*inv[r])%M + M)%M;ans = ((ans*inv[n-r])%M + M)%M;return ans;}

int calcMEX(vector<int> v){
    map<int,int> m;
    for(auto x:v) m[x]++;
    for(int i=0;i<v.size();i++){
        if(m.find(i)==m.end()) return i;
    }
    return v.size();
}

int main(){
    ll t=1;
    // cin>>t;
    //cout<<t<<endl;
    while(t--){
        int n;
        cin>>n;
        int ss=0;
        while(ss<n) ss+=1000;
        cout<<ss-n<<endl;

    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int N;
  while(scanf("%d", &N) && N){
    int r = sqrt(N);
    int sum = 0;
    for(int i = 1; i <= r; i++){
      if(i == N) continue;
      if(N%i == 0){
	sum += i;
	if(N/i == N || N/i == i) continue;
	sum += N/i;
      }
    }

    if(sum == N) puts("perfect number");
    else if(sum < N) puts("deficient number");
    else if(sum > N) puts("abundant number");
  }
  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include <functional>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int num(int n)
{
  int ans = 1;
  int N = n;
  for(int i=1;i <= 2;i++)
  {
    ans *= N;
    ans /= i;
    N--;
  }
  return ans;
}


int main()
{
  int n,m;
  cin >> n >> m;
  int ans = 0;
  ans += num(n);
  ans+= num(m);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <unordered_map>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
  string S;

  cin >> S;

  string codes;

  for(int i = 0; i < S.length(); i++) {
    if(S[i] == 'B') {
      if(codes.length() != 0) {
        codes.pop_back();  
      }
    } else {
      codes.push_back(S[i]);
    }
  }

  cout << codes << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  typedef vector<int> vi;
  typedef vector< vi > vvi;
  typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
  typedef long long ll;

  int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    string U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U){
      A--;
    }
    else if(T == U){
      B--;
    }
    cout << A << " " << B << endl;
  }

Measured memory_bytes: 256
import queue

n, m = map(int, input().split())
am_bm = []
side_map = dict()
for i in range(m):
    ai, bi = map(int, input().split())
    if ai not in side_map:
        side_map[ai] = set()
        side_map[ai].add(bi)
    else:
        side_map[ai].add(bi)
    if bi not in side_map:
        side_map[bi] = set()
        side_map[bi].add(ai)
    else:
        side_map[bi].add(ai)
    am_bm.append((ai, bi))

counter = 0
for i in range(m):
    a, b = am_bm[i]
    q = queue.Queue()
    q.put(1)
    node_passed = set()
    node_passed.add(1)
    while not q.empty():
        a_tmp = q.get()
        for b_tmp in side_map[a_tmp]:
            if a_tmp == a and b_tmp == b or a_tmp == b and b_tmp == a:
                pass
            elif b_tmp not in node_passed:
                q.put(b_tmp)
                node_passed.add(b_tmp)
    if len(node_passed) == n:
        counter += 1
print(m - counter)


Measured memory_bytes: 9716
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mo = 100002;
struct task{
    int day,price;
}p[mo];
bool cmp(task u,task v){
    return u.day<v.day;
    
}
int main(){
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>p[i].day>>p[i].price;
    }
    sort(p,p+n,cmp);
    priority_queue<int,vector<int>,less<int> > pp;
    int st = 0;
    int res = 0;
    for(int i=1;i<=m;i++){
        while(p[st].day<=i&&st<n){
            pp.push(p[st++].price);
        }
        if(!pp.empty()){
            res += pp.top();
            pp.pop();
        }
    }
    cout<<res<<endl;
    return 0;
}

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

#define int long long

using namespace std;

const int mod = 998244353;
int f[300001];
int inv[300001];

int bp (int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res = (res * a) % mod;
		}
		b >>= 1;
		a = (a * a) % mod;
	}
	return res;
}

int C (int n ,int k) {
	if (k > n) return 0;
	return (f[n] * ((inv[k] * inv[n - k]) % mod)) % mod;
}

int solve (int a, int b, int n) {
	return (C (n, a) * C (n, b)) % mod;
}

 main () {	
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	f[0] = 1;
	inv[0] = 1;
	for (int i = 1;i <= n;i ++) {
		f[i] = (f[i - 1] * i) % mod;
		inv[i] = bp (f[i], mod - 2);
	}
	int ans = 0;
	for (int i = 0;i <= n;i ++) {
		int first = i;
		int re = k - (first * a);
		if (re < 0) continue;
		if (re % b != 0) continue;
		int second = re / b;
		ans = (ans + solve (first, second, n)) % mod;
	}
	cout << ans;
	return 0;
}

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

const int mn=2e5+7;
int n;
struct node {
	int a,b;
}p[mn];

bool cmp(node x,node y)
{
	return x.b<y.b;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&p[i].a,&p[i].b);
	sort(p+1,p+n+1,cmp);
	int L=0,f=1;
	for(int i=1;i<=n;++i) {
		L+=p[i].a;
		if(L>p[i].b) f=0;
	}
	puts(f?"Yes":"No");
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int INF = 1001001001;
int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i];
		A[i]--;
	}
	int ans =0;	
	for (int i = 0; i < N-1; ++i) {
		if (i == A[i]) {
			int tmp = A[i];
			A[i] = A[i + 1];
			A[i + 1] = tmp;
			ans++;
		}
	}
	if (N-1 == A[N-1]) {
		ans++;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3732
n = int(input())
a = list(map(int, input().split()))
ans = 0
if a[0] == a[1]:
    ans = 1
    a[1] = -1000
for i in range(n-1):
    if a[i] == a[i+1]:
        ans += 1
        a[i+1] = -i
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
   public static void main(String[] args){
     int n = new Scanner(System.in).nextInt();
     int i, j;
     int ans=0, temp=0;
     for(i=1;i<=n;i+=2){
       for(j=1;j<=i;j++){
         if(i%j==0){
           temp++;
         }
       }
       if(temp==8){
         ans++;
       }
       temp=0;
     }
     System.out.println(ans);
   }
}


Measured memory_bytes: 21716
#include <stdio.h>

int main(){

  int i;
  int N;
  int K;
  int count;

  scanf("%d %d", &N, &K);
  int h[N];

  for(i = 1; i <= N; i++){

    scanf("%d", &h[i - 1]);
  }

  count = 0;

  for(i = 1; i <= N; i++){

    if(h[i - 1] >= K){
      count = count + 1;
    }
  }

  printf("%d", count);

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a*b>c*d) cout << a*b << endl;
    else cout << c*d << endl; 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,K;
    cin >> N >> K;
    lint H[N];
    rep(i,N) cin >> H[i];
    sort(H,H+N,greater<lint>());
    lint ans=0;
    for(int i=K;i<N;i++) ans+=H[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val O = A.filterIndexed { index, a -> index < N && index % 2 != 0 }
    val E = A.filterIndexed { index, a -> index < N && index % 2 == 0 }
    fun same(v: List<Int>) = v.all { it == v[0] }
    if (same(O) && same(E) && O[0] != E[0]) {
        println(0)
        return
    }
    val Ov = Array(100001) { 0 to 0 }
    val Ev = Array(100001) { 0 to 0 }
    O.forEach { v -> Ov[v] = v to Ov[v].second + 1 }
    E.forEach { v -> Ev[v] = v to Ev[v].second + 1 }
    Ov.sortBy { -it.second }
    Ev.sortBy { -it.second }
    val e0 = E.size - Ev[0].second
    val e1 = E.size - Ev[1].second
    val o0 = O.size - Ov[0].second
    val o1 = O.size - Ov[1].second
    val ans = if (Ev[0].first != Ov[0].first) e0 + o0 else Math.min(e0 + o1, e1 + o0)
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 65216
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const double PI = 3.14159265358979323846;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll dp[100005][13];
int main(){
  int N;
  string S;
  cin >> S;
  N = S.size();
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  for(int i=0; i<N; i++){
    int c;
    if(S[i] == '?'){
      c = -1;
    }else{
      c = S[i]-'0';
    }
    for(int j=0; j<10; j++){
      if(c != -1 && c != j){
        continue;
      }
      for(int ki=0; ki<13; ki++){
        dp[i+1][(ki*10+j)%13] += dp[i][ki];
      }
    }
    for(int j=0; j<13; j++){
      dp[i+1][j] %= INF;
    }
  }
  cout << dp[N][5] << endl;
  return 0;
}


Measured memory_bytes: 10624
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll f, t, o;
  f = t = o = 0;
  rep(i, n){
    ll a;
    cin >> a;
    if(a%4 == 0) f++;
    else if(a%2 == 0) t++;
    else o++;
  }
  if((o <= f && t%2 == 0) || (o <= f+1 && t == 0) || (o <= f && t%2 != 0 && f-o >= 0)) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int p[20010];
    rep(i, N) cin >> p[i];
    int a[20010], b[20010];
    rep(i, N) a[i] = i * 45000 + 40000;
    rep(i, N) b[i] = (N - i - 1) * 45000 + 40000;
    rep(i, N) {
        a[p[i] - 1] += i;
        b[p[i] - 1] += i;
    }
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << b[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3792
import Data.List.Split
main = mapM_ (print . solve . map (map read . words)) . chunksOf 2 . lines =<< getContents
solve [[n,k],ds] = head $ filter (null . filter (flip elem ds) . f) [n..]
f 0 = []
f i = i`mod`10:f (i`div`10)

Measured memory_bytes: 1020
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int min = p[0];
        int ans = 1;
        for (int i = 1; i < n; i++)
        {
            if (p[i] <= min)
            {
                ans++;
            }
            min = Math.Min(min, p[i]);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 31068