akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long MOD=1000000007;

int main(){
	int N,M;
	cin >> N >> M;
	vector<long long> dp(N+1,0LL);
	vector<int> a(M);
	for(auto &i:a)cin >> i;
	
	dp[0]=1;
	for(int i=0;i<=N;i++){
		if(binary_search(a.begin(),a.end(),i))dp[i]=0LL;
		if(dp[i]>=MOD)dp[i]%=MOD;
		if(i<N-1)dp[i+2]+=dp[i];
		if(i<N)dp[i+1]+=dp[i];
	}
	cout << dp[N] << endl;
	return 0;
}

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

#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
const long long LINF=1e18;

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  if(!v[0])fin(0);
  int a=1;
  for(int i=0;i<n;i++){
    if(LINF/a+100<v[i])fin(-1);
    a*=v[i];if(a>LINF)fin(-1);
  }
  fin(a);
}


Measured memory_bytes: 4416
#include <algorithm>
#include <cstring>
#include <cstdio>
struct point
{
	int x, y;
	inline bool operator <(const point& a) const
	{
		return x < a.x;
	}
} arr[300005], st1[300005], st2[300005];
int mx[1200005], lazy[1200005];
void modify(int u, int l, int r, int L, int R, int x)
{
	if (L <= l && r <= R)
	{
		mx[u] += x;
		lazy[u] += x;
		return;
	}
	int m = l + r >> 1;
	if (L <= m)
		modify(u << 1, l, m, L, R, x);
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R, x);
	mx[u] = std::max(mx[u << 1], mx[u << 1 | 1]) + lazy[u];
}
int work(int w, int h, int n)
{
	memset(mx, -0x3f, sizeof(mx));
	memset(lazy, 0, sizeof(lazy));
	std::sort(arr, arr + n);
	int tp1 = 0, tp2 = 0, ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int& tp = arr[i].y <= h / 2 ? tp1 : tp2, nxt = i - 1;
		auto* st = arr[i].y <= h / 2 ? st1 : st2;
		while (tp && ((st[tp - 1].y < arr[i].y) ^ (arr[i].y > h / 2)))
		{
			modify(1, 0, n - 1, st[tp - 1].x, nxt, (st[tp - 1].y - arr[i].y) * (arr[i].y <= h / 2 ? 1 : -1));
			nxt = st[--tp].x - 1;
		}
		if (nxt != i - 1)
			st[tp++] = { nxt + 1, arr[i].y };
		st1[tp1++] = { i, 0 };
		st2[tp2++] = { i, h };
		modify(1, 0, n - 1, i, i, h - arr[i].x - mx[0]);
		ans = std::max(ans, mx[1] + arr[i + 1].x);
	}
	return ans;
}
int main()
{
	int w, h, n;
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &arr[i].x, &arr[i].y);
	arr[n++] = { 0, 0 };
	arr[n++] = { w, h };
	int ans = work(w, h, n);
	for (int i = 0; i < n; i++)
		std::swap(arr[i].x, arr[i].y);
	ans = std::max(ans, work(h, w, n));
	printf("%d\n", ans << 1);
	return 0;
}

Measured memory_bytes: 16512
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))

#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;

int main(){
   
    LL A;
    SL(A);
    LL B;
    string S;
    cin>>S;
    B = 0;
    for(LL i = 0 ; i<S.size() ; i++){
        if(S[i]=='.') continue;
        B = B*10 + (S[i]-'0');
    }
    LL mul = A*B;
    mul = mul/100;
    cout<<mul<<endl;

return 0;}

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  int N;
  ll A[MAX_N];

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

  static ll dp[MAX_N][2] = {};
  dp[0][0] = A[0];
  dp[0][1] = - A[0];
  for(int i = 1; i < N; ++i) {
    dp[i][0] = std::max(dp[i - 1][0] + A[i], dp[i - 1][1] - A[i]);
    dp[i][1] = std::max(dp[i - 1][0] - A[i], dp[i - 1][1] + A[i]);
  }

  std::cout << dp[N - 1][0] << std::endl;
}


Measured memory_bytes: 2560
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	
    	if(a%2==0){
    		System.out.println("Even");
    	}
    	else if(b%2==0){
    		System.out.println("Even");	
    	}
    	else{
    		System.out.println("Odd");
    	}
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
#include <iostream>

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

int main() {
	char a[8], b[101], c[8]; cin >> a >> b >> c;

	cout << "A" << b[0] << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n,ans=INF;
int wa(int a){
  int tmp=0;
  while(a!=0){
    tmp+=a%10;
    a/=10;
  }
  return tmp;
}
int main(){
  cin>>n;
  for(int i=1;i<=n/2;i++){
    ans=min(ans,wa(i)+wa(n-i));
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

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

	string s, t;
	cin >> s;
	cin >> t;

	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n; cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++) {
        string inp; cin >> inp;
        s.insert(inp);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 15656
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)






























int main(){
    string s;
    cin >> s;
    ll k = 0;
    REP(i, s.size()){
        k += s[i] - '0';
        k %= 9;
    }
    cout << (k? "No" : "Yes") << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector< vector<char> > a((H+2), vector<char> ((W+2), '#'));
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      if (i!=0 && i!=H+1) {
        if (j!=0 && j!=W+1) {
          cin >> a.at(i).at(j);
        }
      }
    }
  }
  
  for (int i=0; i<H+2; i++) {
    for (int j=0; j<W+2; j++) {
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
  
  
  
  /*
  vector<char> a((H+2)*(W+2), "#");
  for (int i=0; i<(H+2)*(W+2); i++) {
    if ( (i !< W+2) || (i !> (H+2)*(W+2)-(W+2)-1 ) ) {
      if ( (i%(W-1)==0) || (i%*W==0) ) {
        cin >> a.at(i);
      }
    }
  }
  
  for (int i=0; i<(H+2)*(W+2); i++) {
    cout << a.at(i) << flush;
    if(i%(W-1)==0) cout << endl;
  }
  */
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n, m, q; cin>>n>>m>>q;
    list<int> lst;
    for(int i=0; i<n; i++){
        lst.emplace_back(i);
    }

    auto itr = lst.begin();
    for(int i=0; i<m; i++){
        int a; cin>>a;
        if(a % 2 == 0){
            for(int j=0; j<a; j++){
                itr++;

                if(itr == lst.end()){
                    itr = lst.begin();
                }
            }

            itr = lst.erase(itr);
            if(itr == lst.end()){
                itr = lst.begin();
            }
        }
        else{
            for(int j=0; j<a; j++){
                if(itr == lst.begin()){
                    itr = lst.end();
                }

                itr--;
            }

            itr = lst.erase(itr);
            if(itr == lst.end()){
                itr = lst.begin();
            }
        }
    }

    vector<bool> exist(n, false);
    for(auto i : lst){
        exist[i] = true;
    }

    while(q--){
        int Q; cin>>Q;
        cout << exist[Q] << endl;
    }
}


Measured memory_bytes: 9080
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    string wether[3] = {"Sunny", "Cloudy", "Rainy"};

    if(s == wether[0]) {
        cout << wether[1] << endl;
        return 0;
    }
    if(s == wether[1]) {
        cout << wether[2] << endl;
        return 0;
    }
    if(s == wether[2]) {
        cout << wether[0] << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <deque>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, m;

const int MAXN = 100005;
int visited[MAXN];

vector< vector<int> > adj;

deque<int> dq;

int unvisited(int u) {
    for (auto& v : adj[u]) {
        if (!visited[v]) {
            return v;
        }
    }
    return 0;
}

int main() {
    GI(n);
    GI(m);

    adj.resize(n+1);

    memset(visited, 0, sizeof visited);

    FOR1(i, m) {
        int u, v;
        GI(u);
        GI(v);

        adj[u].PB(v);
        adj[v].PB(u);

        if (i == 1) {
            dq.push_back(u);
            dq.push_back(v);
            visited[u] = visited[v] = 1;
        }
    }

    int next;

    while ((next = unvisited(dq.back()))) {
        dq.push_back(next);
        visited[next] = 1;
    }

    while ((next = unvisited(dq.front()))) {
        dq.push_front(next);
        visited[next] = 1;
    }

    printf("%d\n", (int)dq.size());

    for (auto& u : dq) {
        printf("%d ", u);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 7040
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  string s;
  int ret = 0;
  for(int i=0; i<N; ++i) {
    s = to_string(i+1);
    if (s.size() % 2 ) {
      ret++;
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int ans;
	int t;
	char op;
	
	scanf("%d%*c", &ans);
	while (scanf(" %c", &op), op != '='){
		int n;
		
		scanf("%d", &n);
		if (op == '+') ans += n;
		else if (op == '-') ans -= n;
		else if (op == '*') ans *= n;
		else ans /= n;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double
#define f(variable, start, end) for (int variable = start; variable < end; ++variable)
#define be(a) a.begin(), a.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nor cout << "NO\n"; return
#define yesr cout << "YES\n"; return
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>


using namespace std;


template<typename T, typename E>
vector<T> &operator>>(vector<T> &v, E a) {
    v.push_back(a);
    return v;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}

//vector<pair<T, E>> output
template<typename T, typename E>
ostream &operator<<(ostream &os, vector<pair<T, E>> &vec) {
    for (pair<T, E> i : vec) {
        os << i.first << ' ' << i.second << '\n';
    }
    return os;
}


int32_t main() {
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(10);
    ios_base::sync_with_stdio(false);
#ifdef TIME
    int32_t start = clock();
#endif

    string s, t;
    cin >> s;
    cin >> t;
    
    int ans = 0;
    
    f(i, 0, s.size()) {
        if (s[i] != t[i]) {
            ans += 1;
        }
    }

    cout << ans;
    
#ifdef TIME
    cout << "\ntime: " << (clock() - start) / (CLOCKS_PER_SEC * 1.0);
#endif

    return 0;
}

Measured memory_bytes: 3892
use std::io::{self, Read, Write};

#[rustfmt::skip] #[macro_use] #[allow(unused_macros)]
mod rwc {
    macro_rules! rd { ($buf:ident, $t:ty)       => { $buf.next().unwrap().parse::<$t>().ok().unwrap() }; }
    macro_rules! wt { ($out:ident, $($arg:tt)*) => { write!($out, $($arg)*).ok()                      }; }
    macro_rules! cv { ($n:expr, $fn:expr)       => { (0..$n).map($fn).collect::<Vec<_>>()             }; }
}

fn main() {
    let (mut _buf, mut _out) = (String::new(), io::stdout());
    let (mut _buf, mut _out) = {
        io::stdin().read_to_string(&mut _buf).ok();
        (_buf.split_whitespace(), io::BufWriter::new(_out.lock()))
    };

    let r = rd!(_buf, f64);
    wt!(_out, "{:.3}\n", 2.0 * 3.1415 * r);
    _out.flush().ok();
}


Measured memory_bytes: 2196
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int D[200][2];
	int now=0;
	int sai=0;
	scan(N);
	rep(i,N){
		rep(j,2){
			scan(D[i][j]);
		}
		if(D[i][0]==D[i][1]){
			now++;
			sai=max(sai,now);
		}
		else{
			now=0;
		}
	}
	if(sai>=3) prin("Yes");
	else prin("No");
	return 0;
}


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

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



int h, w;
string B[55];
int dx[4] = { -1,0,1,0 }, dy[4] = {0,1,0,-1};
int vis[55][55];
int dp[55][55];

int check() {
	queue<pair<int, int>>que;
	que.push({0,0});
	vis[0][0] = 1;

	while (!que.empty()) {
		auto q = que.front();
		que.pop();
		int x, y;
		tie(x, y) = q;

		if (y == h - 1 && x == w - 1)return dp[y][x];

		rep(d, 0, 4) {
			int xx = x + dx[d];
			int yy = y + dy[d];
			if (0 <= xx && xx <= w - 1 && 0 <= yy && yy <= h - 1) {
				if (B[yy][xx] == '.' && vis[yy][xx]==0) {
					vis[yy][xx] = 1;
					dp[yy][xx] = dp[y][x] + 1;
					que.push({xx,yy});
				}
			}
		}
	}
	return 0;
}



int main() {
	cin >> h >> w;
	rep(i, 0, h)cin >> B[i];

	int ans, res = check();

	if (!res)ans = -1;
	else{
		ans = h * w - res - 1;
		rep(i, 0, h)rep(j, 0, w)if (B[i][j] == '#')ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n,s,k,ans;
void dfs(int cnt,int sum,int beg){
    if(sum==s&&cnt==k){ans++; return;}
    else if(cnt >k || s<sum)return;
    for(int i=beg+1; i<=n;i++)dfs(cnt+1,sum+i,i);
    return ;
}
int main(){
    while(cin>>n>>k>>s,n+s+k){
        dfs(0,0,0);
        cout<<ans<<endl;
        ans=0;
    }
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;
int dp[100010];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int h[N]; rep(i,N) cin >> h[i];
    dp[0]=0; dp[1]=abs(h[1]-h[0]);
    rep(i,N-2){
        dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[N-1] << endl;
}

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

using namespace std;

vector<int> v;
int N;

int main(){
    int sum = 0;
    cin >> N;
    v.resize(N);
    for(int i=0;i<N;i++){
        cin >> v[i];
        sum += v[i];
    }
    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<N;i++){
        if(v[i] % 10 != 0){
            cout << sum - v[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(asd, fgh) for(ll asd = 0; asd < fgh; asd++)
 
struct P{
  ll pos;
  ll dir;
  bool stopped;
};
 
 
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  ll N, T, Q; cin >> N >> T >> Q;
  vector<P> p(N);
 
  REP(i, N){
    ll a, d;
    cin >> a >> d;
    p[i].pos = a;
    if(d == 1){
      p[i].dir = 1;
    }else{
      p[i].dir = -1;
    }
    p[i].stopped = false;
  }
 
  for(ll i = 0; i < N-1; i++){
    if(p[i].dir == 1 && p[i+1].dir == -1){
      if((p[i+1].pos - p[i].pos) / 2 <= T){
        p[i+1].pos = p[i].pos = (p[i+1].pos + p[i].pos)/2;
      }else{
        p[i+1].pos -= T;
        p[i].pos += T;
      }
      p[i+1].stopped = p[i].stopped = true;
    }
  }
 
  for(ll i = 0; i < N; i++){
    if(p[i].stopped) continue;
 
    if(p[i].dir == 1){
      bool flg = false;
      for(ll j = i+1; j < N; j++){
        if(p[j].pos - p[i].pos > T){
          p[i].pos += T;
          flg = true;
          break;
        }else if(p[j].stopped == true){
          p[i].pos = p[j].pos;
          flg = true;
          break;
        }
      }
      if(!flg){
        p[i].pos += T;
      }
 
    } else {
      bool flg = false;
      for(ll j = i-1; j >= 0; j--){
        if(p[i].pos - p[j].pos > T){
          p[i].pos -= T;
          flg = true;
          break;
        }else if(p[j].stopped == true){
          p[i].pos = p[j].pos;
          flg = true;
          break;
        }
      }
      if(!flg){
        p[i].pos -= T;
      }
    }
  }
 
  REP(i, Q){
    int q; cin >> q; q--;
    cout << p[q].pos << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3380
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <cmath>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define lowbit(x) (x &(-x))
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define rp(i, n) for(int i = 0, i < n; i ++)
using namespace std;
typedef long long ll;
const int  INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-10;
const ll   mod = 1e9 + 7;
const int  N = 2e5 + 5;
int n;
map<string, int> mp;
vector<string> a, c;
signed main(void)
{
   cin >> n;
   while(n --){
      string s;
      cin >> s;
      if(!mp[s]) a.push_back(s);
      mp[s] ++;
   }
   int tmp = 0;
   for(auto it : a) tmp = max(tmp, mp[it]);
   for(auto it : a) if(mp[it] == tmp) c.push_back(it);
   sort(c.begin(), c.end());
   for(auto it : c) cout << it << endl;
   return 0;
}


Measured memory_bytes: 28912
#include<iostream>
#include<string>
#include<vector>
#include<deque>
using namespace std;

int main() {

    int n;
    long debt = 100;
    cin >> n;

    for(int i = 1; i <= n; i++) {
        int r = 0;
        if (debt % 20) {    r = 1;  }

        debt = debt * 1.05 + r;
    }

    cout << debt << "000" << endl;
     
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i=1;i<=n;i++){
        ans *= i;
        ans = ans % 1000000007;
    }
    cout << ans << endl;


    
}

Measured memory_bytes: 256
s=list(input())
n = len(s)
#XXがあるか
for i in range(1,n):
    if s[i] == s[i-1]:
        print(i,i+1)
        exit()

#XYXがある場合
if n>=3:
    for i in range(2,n):
        if s[i]==s[i-2]:
            print(i-1,i+1)
            exit()
print(-1,-1)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n, q;
    string s;
    cin >> n >> s >> q;

    vector<set<int>> alp(26);
    rep(i,n) alp[s[i]-'a'].insert(i);

    int type, ind, l, r;
    char c;
    vector<int> ans;
    rep(i,q) {
        cin >> type;
        if (type == 1) {
            cin >> ind >> c; ind--;
            alp[s[ind]-'a'].erase(ind);
            alp[c-'a'].insert(ind);
            s[ind] = c;
        } else {
            cin >> l >> r; l--; r--;
            int ans_tmp = 0;
            rep(j,26) {
                auto lb = alp[j].lower_bound(l);
                if (*lb > r || lb == alp[j].end()) continue;
                ans_tmp++;
            }
            ans.push_back(ans_tmp);
        }
    }
    for (int a: ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 26360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}

void solve() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());
    
    int sum = 0;
    rep(i, n) sum += a[i];
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int a,b;
    cin >> a >> b;
    if(b < a){
        for(int i = 0; i < a; ++i)
            cout << b ;
    }
    else
        for(int i = 0; i < b; ++i)
            cout << a ;
    cout << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
typedef vector<ll>vec;
typedef vector<vector<ll>> mat;
vector<int>a[1000];
int b[5];
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=0;i<=n;i++)a[i].clear();
  int s,c;
  per(i,1,m){
    cin>>s>>c;
    a[s].push_back(c);
  }
  for(int i=1;i<=n;i++)
  {
          if(i==1){
             if(a[1].size()){
                for(auto v:a[1])
                if(v!=a[1][0]){cout<<-1<<endl;return 0;}
                sort(a[1].begin(),a[1].end());
                if(a[1][0]==0)
                {
                    if(n==1){cout<<0<<endl;return 0;}
                    else {cout<<-1<<endl;return 0;}
                }
                b[1]=a[1][0];
             }
             else{
            if(n==1)b[1]=0;
            else b[1]=1;
             }
          }
          else{
            if(a[i].size()){
                for(auto v:a[i])
                if(v!=a[i][0]){cout<<-1<<endl;return 0;}
                sort(a[i].begin(),a[i].end());
                b[i]=a[i][0];
             }
             else
                b[i]=0;
          }
    }
    for(int i=1;i<=n;i++)
        cout<<b[i];
  return 0;
}



Measured memory_bytes: 256
//ICPC B
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;

int main(){
    vector<int> answers;
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0&&w==0) break;
        string r;
        pair<int,int> pos[256];
        for(int i=0;i<h;i++){
            cin>>r;
            for(int j=0;j<w;j++){
                if(r[j]!='_') pos[r[j]]={i,j};
            }
        }
        string s;
        cin>>s;
        int x=0,y=0;
        int ans=s.length();
        for(int i=0;i<s.length();i++){
            ans+=abs(y-pos[s[i]].first)+abs(x-pos[s[i]].second);
            y=pos[s[i]].first;
            x=pos[s[i]].second;
        }
        answers.push_back(ans);
    }

    for(auto ans:answers){
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n, p, i, ans = 1,c[1111111],cp;
	cin >> n >> p;
  cp=p;
	for (i = 0; i < 1111111; i++)
		c[i] = 0;
	for (i = 2; i*i <= p; i++) {
		while (cp%i == 0) {
			c[i]++;
			cp /= i;
		}
	}
	for (i = 2; i*i <= p; i++) {
		while (c[i] >= n) {
			ans *= i;
			c[i] -= n;
		}
	}
	if (n == 1)
		ans = p;
	cout << ans << endl;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
//this code is written by Itst
using namespace std;

int read(){
	int a = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		a = a * 10 + c - 48; c = getchar();
	}
	return a;
}

bitset < 403 > dp[403];
int N , M , stp[100003][2];

int main(){
	N = read(); M = read();
	for(int i = 1 ; i <= M ; ++i){
		stp[i][0] = read(); stp[i][1] = read();
	}
	for(int i = 1 ; i <= N ; ++i){
		dp[i].set(i);
		for(int j = M ; j ; --j)
			if(dp[i][stp[j][0]] && dp[i][stp[j][1]]){
				dp[i].set(); break;
			}
			else
				if(dp[i][stp[j][0]] || dp[i][stp[j][1]]){
					dp[i].set(stp[j][0]); dp[i].set(stp[j][1]);
				}
	}
	int ans = 0;
	for(int i = 1 ; i <= N ; ++i)
		for(int j = i + 1 ; j <= N ; ++j)
			ans += (dp[i] & dp[j]).none();
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		List<int> times = new List<int>(5);
		List<int> times2 = new List<int>(5);
		
		for(int i = 0; i < 5; i++)
		{
			string input = Console.ReadLine();
			int o = int.Parse(input);
			if(o%10==0){
				times.Add(o);
			} else {
				times2.Add(o);
			}
		}
		
		times2.Sort((a,b) =>-(a%10) + (b%10));
		
		int time = 0;
		for(int i = 0; i < times.Count; i++)
		{
			time += times[i];
		}
		
		for(int i = 0; i < times2.Count; i++)
		{
			time += times2[i];
			if(time % 10!=0 && i < times2.Count - 1)
			{
				time = (int)(Math.Ceiling(time / 10f) * 10);
			}
		}
		Console.WriteLine(time);
	}
	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}


}

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main()
{
long long int n;
  cin>>n;
  long long int netways=1;
  for(int i=1;i<=n;i++)
  {
    netways*=10;
    netways%=1000000007;
  }
  long long int bad=1,bad1=1;
  for(int i=1;i<=n;i++)
  {
    bad*=8;
    bad1*=9;
    bad%=1000000007;
    bad1%=1000000007;
  }
  bad1*=2;
  bad1%=1000000007;
  long long int ans=netways-(bad1-bad);
  cout<<(ans+1000000007)%1000000007;
}
  
  

Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  char c;
  cin >> c;
  
  // cout << c << endl;
  char r = c + 1;
  cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll X;
  cin >> X;
  int y = 0;
  int i = 1;
  while(y<X){
    y+=i;
    i++;
  }

  cout << i-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e19
#define N 200005

using namespace std;

int n, a[N];

int main() {
    //freopen("txt.in", "r", stdin);
    //freopen("txt.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int c = 0;
    for (int i = n; i >= 1; i--) {
        if (i > 1 && a[i] == i && a[i - 1] == i - 1) c++, i--;
        else if (a[i] == i)c++;
    }
    cout << c << endl;

	return 0;
}


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

const long long mod = 1000000007;

int main() {
  long long n,k;
  cin >> n >> k;
  
  long long ans = 0;
  for(long long i=k; i<=n+1; i++){
    ans += (1 + i + n*i -i*i) % mod;
  }
  cout << ans%mod << endl;
}
  


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int dataCount = Integer.parseInt(scan.nextLine());
            for (int loopCount = 0; loopCount < dataCount; loopCount++) {
                String[] vertexStrList = scan.nextLine().split(" ");
                double[] vertexList = new double[6];
                for (int i = 0; i < 6; i++) {
                    vertexList[i] = Double.parseDouble(vertexStrList[i]);
                }
                double ax = vertexList[0];
                double ay = vertexList[1];
                double bx = vertexList[2];
                double by = vertexList[3];
                double cx = vertexList[4];
                double cy = vertexList[5];
                double abDX = bx - ax;
                double abDY = by - ay;
                double acDX = cx - ax;
                double acDY = cy - ay;
                double[] in = { abDX, abDY, getB(ax, ay, bx, by), acDX, acDY,
                        getB(ax, ay, cx, cy) };
                double[] pXY = getXY(in);
                for (int i = 0; i < 2; i++) {
                    if (pXY[i] == -0.0) {
                        pXY[i] = 0.0;
                    }
                }
                double r = Math.sqrt(Math.pow(ax - pXY[0], 2) + Math.pow(ay - pXY[1], 2));
                System.out.printf("%.3f %.3f %.3f\n", pXY[0], pXY[1], r);
            }
        } catch (Exception e) {
            System.exit(0);
        }
    }

    private static double[] getXY(double[] in) {
        double deno = (in[1] * in[3] - in[0] * in[4]);
        double[] xy = new double[2];
        xy[0] = (in[1] * in[5] - in[2] * in[4]) / deno;
        xy[1] = (in[0] * in[5] - in[2] * in[3]) / (deno * -1);
        return xy;
    }

    private static double getB(double ax, double ay, double bx, double by) {
        return (Math.pow(by, 2) - Math.pow(ay, 2) + Math.pow(bx, 2) - Math.pow(ax, 2)) / 2;
    }

}

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

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a%3==0||b%3==0||(a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int a[11][11];

int main() {
    int n, d;
    cin >> n >> d;
   // cout << n << d << endl;

    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> a[i][j];
        }
    }
    /*
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
           */

    int cnt = 0;

    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {

            int tmp=0;

            for(int k=0; k<d; k++) {

                //cout << i << " " << j << " " << k << endl;
                tmp+=pow((a[i][k]-a[j][k]), 2);
                //cout << a[i][k] << " " << a[j][k] << endl;
                //cout <<"tmp : " << tmp << endl;
            }

            if((int)sqrt(tmp)*(int)sqrt(tmp) == tmp)
                cnt++;


            //cout <<(int)sqrt(tmp)<< " " << (int)sqrt(tmp)*(int)sqrt(tmp) << " " << tmp << " " << cnt << endl;

        }

    }

    cout <<cnt <<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <utility>
#include <functional>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

using ll = long long;
using P = std::pair<int, int>;
using vi = std::vector<int>;
using namespace std;

constexpr int INF = 1000000000;			  // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vi a(n);
	REP(i, n) cin >> a[i];
	int ans = 0;
	REP(i, n){
		int cnt = 0;
		while(!(a[i] % 2)) a[i] /= 2, cnt++;
		ans += cnt;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 12;
const int M = 1001;

int km[M], a[M], n, m;
int dp[M][1 << N];

int solve(int i, int mask)
{
	if((1 << n) == mask+1)
		return 0;
	if(i == m)
		return INF;
	if(dp[i][mask] != -1)
		return dp[i][mask];
	int ret = INF;
	ret = min(ret, a[i] + solve(i+1, mask | km[i]));
	ret = min(ret, solve(i+1, mask));
	return dp[i][mask] = ret;
}

int main()
{
	fio;
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	for(int i=0; i<m; i++)
	{
		int b, mask = 0;
		cin >> a[i] >> b;
		for(int j=0; j<b; j++)
		{
			int x;
			cin >> x;
			mask |= (1 << x-1);
		}
		km[i] = mask;
	}
	int ans = solve(0, 0);
	if(ans >= INF)
		ans = -1;
	cout << ans << endl;
	return 0;
}

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



int main() {
	
	int d, n;
	cin >> d >> n;
	if(100 == n) n++; 
	cout << n * (int) pow(100, d) << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H1 = sc.nextInt();
    int M1 = sc.nextInt();
    int H2 = sc.nextInt();
    int M2 = sc.nextInt();
    int K = sc.nextInt();
    
    int ans = (H2-H1)*60+(M2-M1)-K;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35780
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4
1 2 3 5

output:
30
"""

import sys
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(_n_list):
    return reduce(lcm, _n_list)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    cnt = int(_input[0])
    n_list = tuple(map(int, _input[1].split()))
    print(solve(n_list))

Measured memory_bytes: 8260