akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vv;
int N,M,A,B,C,T;
inline void add(int& x,int y){
	x=(x+y)%M;
}
vv pro(vv a,vv b){
	vv c=vv(N,vi(N,0));
	rep(i,N) rep(j,N) rep(k,N) add(c[i][j],a[i][k]*b[k][j]);
	return c;
}
vv ex(vv a,int p){
	vv x=vv(N,vi(N,0));
	rep(i,N) x[i][i]=1;
	while(p){
		if(p%2) x=pro(x,a);
		a=pro(a,a);
		p/=2;
	}
	return x;
}
int s[50];
int main(){
	while(true){
		cin>>N>>M>>A>>B>>C>>T;
		if(N==0) break;
		vv c(N,vi(N,0));
		rep(i,N){
			if(i>0) c[i][i-1]=A;
			c[i][i]=B;
			if(i<N-1) c[i][i+1]=C;
		}
		c=ex(c,T);
		rep(i,N) cin>>s[i];
		rep(i,N){
			int a=0;
			rep(j,N) a+=s[j]*c[i][j];
			cout<<a%M<<(i==N-1?"\n":" ");
		}
	}
}

Measured memory_bytes: 1308
from collections import Counter
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
d=(-1,0,1)
c=Counter()
for a,b in ab:
    for da in d:
        for db in d:
            aa=a+da
            bb=b+db
            if 2<=aa<=h-1 and 2<=bb<=w-1:
                c[(aa,bb)]+=1
ans=Counter(c.values())
count_0=(h-2)*(w-2)-sum(ans.values())
print(count_0)
for i in range(1,10):
    print(ans[i])

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNo, nLeft, nRigt;
    cin >> nNo >> nLeft >> nRigt;

    rvoNod[nNo].m_nLeft = nLeft;
    rvoNod[nNo].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nNo;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nNo;
  }
}

void fnPreOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  cout << " " << nx;
  fnPreOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPreOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
}

void fnInOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  fnInOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  cout << " " << nx;
  fnInOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx)
{
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt);
  cout << " " << nx;
}

void fnTreeWalk(const vector<StNod> &cnrvoNod)
{
  int nx = 0;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  cout << "Preorder" << endl;
  fnPreOrder(cnrvoNod, nx);
  cout << endl;

  cout << "Inorder" << endl;
  fnInOrder(cnrvoNod, nx);
  cout << endl;

  cout << "Postorder" << endl;
  fnPostOrder(cnrvoNod, nx);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnTreeWalk(voNod);
  return 0;
}

Measured memory_bytes: 3172
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve(){
	string s, t; cin>>s>>t;
	int n = s.size(), m = t.size();
	s = " " + s;
	t = " " + t;
	int dp[n+1][m+1];
	string ans = "";

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

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

	for(int i = 1; i<n+1; i++){
		for(int j=1; j<m+1; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if(s[i] == t[j]){
				dp[i][j] = dp[i-1][j-1] + 1;
				// ans = ans + t[j];
			}

		}
	}
	int i, j;
	i = n; j=m;
	while(i > 0 && j>0){
		if(s[i] == t[j]){
			ans = s[i] + ans;
			--i;
			--j;
			

		}
		else{
			if(dp[i-1][j] >= dp[i][j-1]){
				i--;
			}
			else{
				j--;
			}
		}
	}

	// reverse(ans.begin(), ans.end());
	cout<<ans;
	
	
	return;

}

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

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		String N = scan.next();
		if(N.length()==3) {
			if(N.contains("7")) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}		
		}

	}
}


Measured memory_bytes: 26972
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl


signed main(){
    int H,W;
    char a[104][104];
    cin >>  H >> W;
    REP(i,H){
        REP(j,W){
            cin >> a[i][j];
        }
    }
    REP(i,H){
        bool f=true;
        REP(j,W){
            if(a[i][j]=='#'){
                f=false;
            }
        }
        if(f==true){
            REP(j,W){
                a[i][j]='t';
            }
        }
    }
    REP(j,W){
        bool f=true;
        REP(i,H){
            if(a[i][j]=='#'){
                f=false;
            }
        }
        if(f==true){
            REP(i,H){
                a[i][j]='t';
            }
        }
    }
    REP(i,H){
        bool f=true;
        REP(j,W){
            if(a[i][j]!='t'){
                f=false;
            }
        }
        if(f)continue;
        REP(j,W){
            if(a[i][j]!='t'){
                cout << a[i][j];
            }
        }cout <<endl;
    }cout << Endl;
    
    return 0;
}   


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi v(7);
    while (n--) {
      int a;
      cin >> a;
      v[0] += a < 10;
      v[1] += 10 <= a && a < 20;
      v[2] += 20 <= a && a < 30;
      v[3] += 30 <= a && a < 40;
      v[4] += 40 <= a && a < 50;
      v[5] += 50 <= a && a < 60;
      v[6] += 60 <= a;
    }
    for (auto &x : v) cout << x << endl;
  }
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll>A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}
	ll sum = 0;
	rep(i, N) {
		A[N - 1 - i] += sum;
		if(A[N - 1 - i] % B[N - 1 - i]!=0)
			sum += B[N - 1 - i] - A[N - 1 - i] % B[N - 1 - i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let s : String = read();
    println!("{}", s.chars().filter(|&c| c == '1').count());
}


Measured memory_bytes: 4352
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    # h0,w0h1,w1 = map(int, input().split())
    s = input()
    n = int(input())
    for _ in range(n):
        t = input().split()
        if t[0] == "print":
            a, b = int(t[1]), int(t[2])
            print(s[a:b + 1])
        if t[0] == "reverse":
            a, b = int(t[1]), int(t[2])
            s = s[:a] + s[a:b + 1][::-1] + s[b + 1:]
        if t[0] == "replace":
            a, b = int(t[1]), int(t[2])
            s = s[:a] + t[3] + s[b + 1:]

main()



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)

#define BR "\n"
#define SP " "
#define fcout cout << fixed << setprecision(18)

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int q; cin >> q;
  rep0(i, q) {
    double x, y;
    cin >> x >> y;

    double mx, my;
    if (x1 == x2) {
      mx = x1;
      my = y;
    } else if (y1 == y2) { 
      mx = x;
      my = y1;
    } else {
      double a1 = (y2 - y1) / (x2 - x1);
      double b1 = y1 - a1 * x1;
      double a2 = -1 / a1;
      double b2 = y - a2 * x;

      mx = -(b1 - b2) / (a1 - a2);
      my = mx * a1 + b1;
    }

    double ansx, ansy;
    ansx = mx - (x - mx);
    ansy = my - (y - my);
    fcout << ansx << SP << ansy << BR;
  }

  return 0;
}


Measured memory_bytes: 3268
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read() {}     template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){}     template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){put (arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here

void run() {
    /**
    7 3 4 10
       D   N   D
    7 -> 4 -> 14 -> 5 ->
    **/
    int t;
    get t;
    for (; t; t--) {
        int a, b, c, d;
        read(a, b, c, d);
        if (a < b || b > d)
            put "No";
        else {
            int g = __gcd(b, d);
            b /= g;
            d /= g;
            int ap = a / g, cp = c / g;
            int ar = a % g, cr = c % g;

            int needToRemove = ap - cp + (ar > cr);

            int daysNeeded = needToRemove / b + !!(needToRemove % b);
            int willRemove = daysNeeded * b;

            if (((cp + 1) % b == 0 || cp >= b) && ap >= willRemove)
                put "Yes";
            else
                put "No";
        }
        put '\n';
    }
}

int32_t main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); put fixed; put setprecision(15); run(); return 0;}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	// read one word/char/int separated by space(s).
	//sc.Split(bufio.ScanWords)

	// read one line.
	sc.Buffer(make([]byte, 10000), 404800)
	sc.Split(bufio.ScanLines)
}

func main() {
	S := nextStr()
	o := str{chrs: []byte(S), memo: make([][4]int64, len(S)+20)}
	if len(S) == 1 {
		fmt.Println(1)
		return
	}
	one := o.solve(0, 0)
	two := o.solve(0, 1)
	if one > two {
		fmt.Println(one)
		return
	}
	fmt.Println(two)
}

type str struct {
	chrs []byte
	memo [][4]int64
}

// prev
// 1: 前の文字列と、その前の文字列が異なる
// 2: 前の文字列と、その前の文字列が一致
// 3: 前の文字列が2文字

func (s *str) solve(prev, idx int) int64 {
	if idx == len(s.chrs)-1 {
		if prev == 2 || prev == 3 {
			return 1
		}
		if s.chrs[idx] == s.chrs[idx-1] {
			return 0
		}
		return 1
	}
	if s.memo[idx][prev] != 0 {
		return s.memo[idx][prev]
	}
	var ans int64
	switch prev {
	case 1:
		if s.chrs[idx] == s.chrs[idx-1] {
			ans = s.solve(2, idx+1)
		} else {
			ans = s.solve(1, idx+1) + 1
		}
	case 2:
		ans = s.solve(3, idx+1) + 1
	case 3:
		ans = s.solve(1, idx+1) + 1
	default:
		ans = s.solve(1, idx+1) + 1
	}
	s.memo[idx][prev] = ans
	return ans
}


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

int main() {
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l=a+b;
  r=c+d;
  string res;
  if(l>r)res="Left";
  else if(l==r)res="Balanced";
  else res="Right";
  cout << res <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e5+10;
using namespace std;

ll quickqow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	ll h,n,sum=0;
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		ll x;cin>>x;
		sum+=x;
	}
	if(h>sum) cout<<"No"<<endl;
	else cout<<"Yes"<<endl; 
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

s = [input() for _ in range(H)]

for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h > 0 and s[h-1][w] == "#":
                continue
            elif w < W-1 and s[h][w+1] == "#":
                continue
            elif h < H-1 and s[h+1][w] == "#":
                continue
            elif w > 0 and s[h][w-1] == "#":
                continue
            else:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  for (int i = 0; i < s.length(); ++i) {
    if ('a' <= s[i] && s[i] <= 'z') {
      s[i] -= 32;
    }
  }
  cout << s << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> nodes;
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        nodes.push_back(make_pair(b,a));
    }
    sort(all(nodes));

    int ans=1;
    int edge=nodes[0].first -1;
    for (int i = 1; i < m; i++) {
        int a = nodes[i].second;
        if (edge < a) {
            ans++;
            edge = nodes[i].first - 1;
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

#define FOR(i,a,b) for(ll i=a; i<b; i++)
#define IN(a) cin>>a
#define OUT(a) cout<<a<<endl

int main(){
  int n;
  IN(n);
  while(n>0){
    n -= 1000;
  }
  OUT(-n);
}

Measured memory_bytes: 3580
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;

int n,m,Dfn;
vector<int>G[N];
vector<pair<int,int>>edge1,edge2;
int du[N],dfn[N],dep[N];
bool vis[N],defeat=false;

void Dfs(int u,int fa) {
	vis[u]=true;
	dfn[u]=Dfn++;
	dep[u]=dep[fa]+1;
	for(int i=0;i<G[u].size();i++) {
		int v=G[u][i];
		if(vis[v]) {
			du[v]++;
			if(v!=fa&&dep[u]>dep[v])
				edge1.push_back(make_pair(v,u));
			continue;
		}
		edge2.push_back(make_pair(u,v));
		Dfs(v,u);
	}
	if(du[u]%2==1) {
		if(u==1) {defeat=true;return ;}
		du[u]++,du[fa]--;
		edge2[dfn[u]-1]=make_pair(u,fa);
	}
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1,u,v;i<=m;i++) {
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	Dfs(1,1);
	if(defeat) {
		printf("-1\n");
		return 0;
	}
	for(int i=0;i<edge1.size();i++)
		printf("%d %d\n",edge1[i].first,edge1[i].second);
	for(int i=0;i<edge2.size();i++)
		printf("%d %d\n",edge2[i].first,edge2[i].second);
	return 0;
}

Measured memory_bytes: 18420
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 1e5 + 10;
int a[MAXN];

void solve(){
    int n; cin>>n;
    FOR(i,1,n) cin>>a[i];

    string s;
    FOR(i,1,n) if(a[i] == i) s += '1'; else s += '0';

    int ans = 0;
    FOR(i,0,n-2){
        if(s[i] == '1'){
            ans++;
            s[i] = '0',s[i+1] = '0';
        }
    } 

    if(s[n-1] == '1') ans++;
    cout<<ans<<endl;
}

signed main(){

   FastRead;    
  
    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

using namespace std;

int main(){
  int n;
  char a;
  string ans="Three";
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a=='Y'){
      ans="Four";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, C = gets.split.map(&:to_i)
sushi_list = N.times.map { gets.split.map(&:to_i) }
reverse_sushi_list = sushi_list.map { |x, v| [C - x, v] }.sort_by(&:first)

def f(sl)
  tv = 0
  max_v = -Float::INFINITY
  d = -1

  sl.map do |x, v|
    tv += v

    if max_v < tv - x
      max_v = tv - x 
      d = x
    end

    [d, max_v]
  end
end

clock = [0] + f(sushi_list)
reverse_clock = [0] + f(reverse_sushi_list)

ans = 0

N.times do |i|
  c = clock[N - i][1] + reverse_clock[i][1] - reverse_clock[i][0]
  rc = reverse_clock[N - i][1] + clock[i][1] - clock[i][0]

  ans = [ans, c, rc].max
end

puts ans


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

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 DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#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);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int w,h;
    cin >> w >> h;
    vector<vector<int> > field;
    field.resize(w+1);
    REP(i,w+1) field[i].assign(h+1,0);
    REP(i,n){
      int x,y;
      cin >> x >> y;
      field[x][y]++;
    }
    REP(i,w+1) REP(j,h) field[i][j+1]+=field[i][j];
    REP(i,w) REP(j,h+1) field[i+1][j]+=field[i][j];
    int answer=0;
    int s,t;
    cin >> s >> t;
    REP(i,w+1-s) REP(j,h+1-t) answer=max(answer,field[i+s][j+t]-field[i+s][j]-field[i][j+t]+field[i][j]);
    cout << answer << endl;
  }
}

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

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

    int n = s.size();
    vector<int> v(n);
    rep(i, n) {
        v[i] = s[i] - '0';
    }

    int m = n - 1;
    long long ans = 0;
    rep(i, 1 << m) {
        long long sum = 0;
        rep(j, m) {
            sum += (long long)v[j];
            if ((i >> j) & 1) {
                ans += sum;
                sum = 0;
            } else {
                sum *= 10;
            }
        }
        ans += sum + v[m];
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  
  string S;
  cin >> S;
  bool hantei = false;
  bool hantei2 = false;
    
  if ( S.at(0) == '1' && ( S.at(1) == '0' 
                          || S.at(1) == '1' 
                          || S.at(1) == '2' )) hantei = true;
  if ( S.at(0) == '0' && S.at(1) != '0' ) hantei = true;
  
  if ( S.at(2) == '1' && ( S.at(3) == '0' 
                          || S.at(3) == '1' 
                          || S.at(3) == '2' )) hantei2 = true;
  if ( S.at(2) == '0' && S.at(3) != '0' ) hantei2 = true;
    
  if ( hantei && hantei2 ) cout << "AMBIGUOUS" << endl;
  if ( hantei && hantei2 == false ) cout << "MMYY" << endl;
  if ( hantei == false && hantei2 ) cout << "YYMM" << endl;
  if ( hantei == false && hantei2 == false ) cout << "NA" << endl;
    
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {

  val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
  if (b % a != 0) {
    val g = gcd(a, b)
    val small = a / g
    val large = b / g
    val inv = (1L to small).find(_ * large % small == 1).map(i ⇒ (large - (large * i / small) % large)).get
    println((1L to small).map { i ⇒ inv * i % large * small * g }.filter{sum ⇒ sum / a < sum % b / a + sum % b % a + sum / b}.minOption.getOrElse(-1))
  }else {
    println(-1)
  }
  @tailrec def gcd(a: Long, b: Long): Long = {
    b match {
      case 0 ⇒ a
      case _ ⇒ gcd(b, a % b)
    }
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(value)
    def also(@inline func: T ⇒ Unit): T = {func(value);value}
    def minOption[A](implicit ev: T ⇒ Iterable[A], ord: Ordering[A]): Option[A] = if (value.isEmpty) None else Some(value.min)
  }
}


Measured memory_bytes: 56384
#include <iostream>
using namespace std;
int main(void){
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int P[6]={a*c,a*d,b*c,b*d};
    long long int max=-1000000000000000000;
    for(int i=0;i<4;i++){
        if(P[i]>max)
         max=P[i];
    }
    cout<<max<<endl;
}


Measured memory_bytes: 3636
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = Array.new(n){|i|[k+1,a[i],i+1]}.sort
ans = []
while b[-1][0] > 0
    if b[-1][1] == 0
        puts "-1"
        exit
    end
    ans << b[-1][2]
    b[-1][0] -= 1
    b[-1][0] -= 1 if b[-1][0] == b[-2][0]
    b[-1][1] -= 1
    b.sort!
end
puts ans.size,ans.join(" ")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i_,k) {
    vector<ll> imos(n+1,0);
    rep(i,n) {
      imos[max(0LL, i-a[i])]++;
      imos[min(n, i+a[i]+1)]--;
    }
    bool end = true;
    rep(i,n) {
      imos[i+1] += imos[i];
      a[i] = imos[i];
      if (a[i] != n) end = false;
    }
    if (end) break;
  }
  rep(i,n) cout << a[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



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

	ll sum = 0;
	for (auto it = m.begin(); it != m.end(); it++) {
		ll num = it->second;
		sum += (num * (num - 1))/2;
	}

	for (int i = 0; i < n; i++) {
		ll s = sum;
		ll num = m[a[i]];
		s -= num - 1;
		cout << s << endl;
	}

	
}




Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie();cout.tie(0);
    int a[5];
    int sum=0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    sum=a[1]-a[0];
    sum+=(a[2]-a[1]);

    cout << sum;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}



int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  int n;
  cin >> n;
  vector<int> as(n);
  rep(i,n){
	  cin >> as[i];
  }
  ll m = 1000;
  ll k = 0;
  reps(i,n-1){
	  if(as[i] >= as[i-1]){
		  ll b = floor(m/as[i-1]);
		  k += b;
		  m -= b*as[i-1];
	  }else{
		  m += k*as[i-1];
		  k = 0;
	  }

  }
  m+=k*as[n-1];
  cout << m << endl;
  return 0;
}


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

int main(){
	int a,b;
	char op;
	while(1){
		cin>>a>>op>>b;
		if(op=='?')break;
	
		
	switch(op){
		case '+':
			cout<<a+b<<endl;break;
		case '-':
			cout<<a-b<<endl;break; 
		case '/':
			cout<<a/b<<endl;break;
		case '*':
			cout<<a*b<<endl;break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void){
	int r, c, i, j;
	int h[101][101] = {0};
	
	scanf("%d %d", &r, &c );
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			scanf("%d", &h[i][j]);
		}
	}
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			h[i][c] += h[i][j];
		}
	}
	
	for(j = 0; j < c + 1; j++){
		for(i = 0; i < r; i++){
			h[r][j] += h[i][j];
		}
	}
	for(i = 0; i < r + 1; i++){
		for(j = 0; j < c + 1; j++){
			printf("%d", h[i][j]);
			if(j != c){
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, d; cin>>n>>d;
	cout << (n+(d*2))/(d*2+1) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
typedef long long LL;
using namespace std;
const int maxn=305;
typedef long long LL;
const LL inf=2333333333333333LL;
LL dist[maxn][maxn];
LL ju[maxn][maxn];
bool vis[maxn][maxn];
int main()
{
    int n;
    LL ans=0;
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
        {
            cin>>dist[i][j];
            ju[i][j]=dist[i][j];
            ans+=ju[i][j];
        }
    for(int k=0; k<n; ++k)
        for(int i=0; i<n; ++i)
            for(int j=0; j<n; ++j)
            {
                if(k==i||j==k) continue;
                LL z=dist[i][k]+dist[k][j];
                if(z<=dist[i][j])
                {
                    dist[i][j]=z;
                    vis[i][j]=true;
                }
            }
    int co=0;
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
        {
            if(ju[i][j]!=dist[i][j]) ++co;
            if(vis[i][j]) ans-=ju[i][j];
        }
    if(co)
    {
        puts("-1");
        return 0;
    }
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
mod=10**9+7
ans=0
def sum(x,y):
    return (x+y)*(y-x+1)//2
for i in range(k,n+2):
    l=sum(0,i-1)
    r=sum(n-i+1,n)
    t=r-l+1
    ans=(ans+t)%mod
print(ans)

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

int main(){
    int X;

    cin >> X;

    int x = X%100;

    int accum = 0;

    while(x >= 5){
        x -= 5;
        accum += 105;
    }

    while(x >= 4){
        x -= 4;
        accum += 104;
    }

    while(x >= 3){
        x -= 3;
        accum += 103;
    }

    while(x >= 2){
        x -= 2;
        accum += 102;
    }

    while(x >= 1){
        x -= 1;
        accum += 101;
    }

    if(accum <= X) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <tuple>

using namespace std;

vector<vector<int> > tr;
vector<int> dpth;

void dfs(int v) {
    if (tr[v].size() == 0)
        dpth[v] = 0;
    else {
        for (int i = 0; i < tr[v].size(); ++i) {
            dfs(tr[v][i]);
        }
        vector<int> buf(tr[v].size());
        for (int i = 0; i < tr[v].size(); ++i) {
            buf[i] = dpth[tr[v][i]];
        }
        sort(buf.begin(), buf.end());
        int mn = 0;
        for (int i = 0; i < tr[v].size(); ++i) {
            mn = max(mn, buf[i] + (int) tr[v].size() - i);
        }
        dpth[v] = mn;
    }
}

int main()
{
    int n;
    cin >> n;
    tr.resize(n);
    dpth.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int a;
        cin >> a;
        a--;
        tr[a].push_back(i + 1);
    }
    dfs(0);
    cout << dpth[0];
    return 0;
}


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

using namespace std;

int main(){

    int n;
    
    string s;
    map<string,int> m;

    m["AC"]=0;
    m["WA"]=0;
    m["TLE"]=0;
    m["RE"]=0;

    cin >> n;

    for(int i =1;i<=n;i++){
        cin >> s;
        m[s]++;
    }
    printf("AC x %d\n",m["AC"]);
    printf("WA x %d\n",m["WA"]);
    printf("TLE x %d\n",m["TLE"]);
    printf("RE x %d\n",m["RE"]);
    

    return 0;
}

Measured memory_bytes: 3740
import sys
from collections import deque, Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, K, L = map(int, input().split())
    Adj_r = [[] for i in range(N)]
    Adj_t = [[] for i in range(N)]

    for i in range(K):
        p, q = map(int, input().split())
        p, q = p-1, q-1
        Adj_r[p].append(q)
        Adj_r[q].append(p)

    for i in range(L):
        r, s = map(int, input().split())
        r, s = r-1, s-1
        Adj_t[r].append(s)
        Adj_t[s].append(r)

    col = 0
    cols_r = [None] * N
    cols_t = [None] * N

    for u in range(N):
        if cols_r[u] is None:
            bfs_color(N, Adj_r, cols_r, u, col)
            col += 1
        if cols_t[u] is None:
            bfs_color(N, Adj_t, cols_t, u, col)
            col += 1

    # debug(cols_r, locals())
    # debug(cols_t, locals())

    cnt = Counter((cols_r[u], cols_t[u]) for u in range(N))

    ans = [cnt[cols_r[u], cols_t[u]] for u in range(N)]

    print(*ans)


def bfs_color(N, Adj, v_cols, u, col):
    v_cols[u] = col
    nxts = deque([u])

    while nxts:
        v = nxts.popleft()

        for w in Adj[v]:
            if v_cols[w] is None:
                v_cols[w] = col
                nxts.append(w)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 89304
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 2e5 + 3; 

int n;
long long k;
int a[maxn]; 
void read()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	cin >> a[i];
}

bool used[maxn];
void solve()
{
	vector <int> v; 
	int curr = 1; 
	while (!used[curr])
	{
		used[curr] = true;
		v.push_back(curr);
		
		curr = a[curr]; 
	}
	
	for (int i = 0; i < (int)v.size(); i++)
	if (v[i] == curr)
	{
		if (k < i)
		cout << v[k] << endl; 
		
	    else 
	    {
			long long r = k - i; 
			int l = (int)v.size() - i; 
			
			r %= l;
			cout << v[i+r] << endl; 	
		}
		
		return;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


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

int main(){

    int n, x;
    cin >> n >> x;
    int d = 0;
    int count = 0;

    for(int i = 0; i < n+1; ++i){
        if(d <= x)++count;
        else break;
        int l;
        cin >> l;
        d += l;
    }

    cout << count << endl;

}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (auto&& b1 : graph[0])
		for (auto&& b2 : graph[b1])
		{
			if (b2 == n-1)
			{
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 12016
from collections import deque
k = int(input())

lunlun = deque([1,2,3,4,5,6,7,8,9])

p = 0

def generate_lunlun(p):
    last = p%10
    if last-1>=0:
        yield p*10+last-1
    yield p*10+last
    if last < 9:
        yield p*10+last+1

cnt = 1

while cnt < k:
    for i in generate_lunlun(lunlun.popleft()):
        lunlun.append(i)
    cnt += 1
print(lunlun[0])

Measured memory_bytes: 48092
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<=(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
  int n;
  cin >> n;
  
  int exp = log2(n);
  
  cout << (int)pow(2,exp);
  return 0;
}


Measured memory_bytes: 512
L,R=map(int,input().split())

x=[]
a=0
for i in range(L,R):
    for j in range(L+1,R+1):
        y=((i*j)%2019)
        x.append(y)
        if y==0:
            break
    if y==0:
            break

print(min(x))

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

#define MOD 1000000007
using namespace std;
int main() {
    IOS
    ll n, d;
    cin >> n >> d;
    ll cnt = 0;
    Fori(i, 0, n) {
        ll x, y;
        cin >> x >> y;
        ll ans;
        ans = pow(x, 2) + pow(y, 2);
        if(ans <= pow(d, 2))cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    c = LI()
    c.sort(reverse=True)
    ans = pow(4, n - 1, mod)
    tmp = 0
    for i in range(n):
        tmp += c[i] * (i + 2)
        tmp %= mod

    print(ans*tmp%mod)
        
    return


#main
if __name__ == '__main__':
    solve()


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL W, H, x, y;
	cin >> W >> H >> x >> y;

	double area = W * H / 2.0;

	bool centerX = false;
	if (W % 2 == 0 && W / 2 == x) {
		centerX = true;
	}
	bool centerY = false;
	if (H % 2 == 0 && H / 2 == y) {
		centerY = true;
	}

	bool multi = false;
	if (centerX && centerY) {
		multi = true;
	}

	cout << setprecision(20) << area << " " << (multi ? 1 : 0)  << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
    	ll a,b,n;
    	cin>>n>>a>>b;
    	if(n*a<b)
    		cout<<n*a;
    	else
    		cout<<b;
       return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> height;
    int k;
  for(int i=0;i<n;i++){
    cin>>k;
    height.push_back(k);
  }
  vector<int> X(n,0);
  X[1]=abs(height[0]-height[1]);
  for(int i=2;i<n;i++){
    X[i]=min(X[i-1]+abs(height[i]-height[i-1]),X[i-2]+abs(height[i]-height[i-2]));
  }
  cout<<X[n-1]<<"\n";
}

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

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nr: Vec<u32> = read_vec();
    let n = nr[0];
    let r = nr[1];
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


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

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String integers = br.readLine();
			System.out.println(compare(integers));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String compare(String integers) {
		String[] integerss = integers.split(" ");
		int a = Integer.parseInt(integerss[0]);
		int b = Integer.parseInt(integerss[1]);
		int c = Integer.parseInt(integerss[2]);
		if (a < b && b < c) {
			return "Yes";
		}
		return "No";
	}
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
#define PI acos(-1)

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(10001,0);
  int i,j,k;
  for(i=1;i<=100;i++)
  {
    for(j=1;j<=100;j++)
    {
      for(k=1;k<=100;k++)
      {
        int ks = i*i+j*j+k*k+i*j+j*k+k*i;
        if(ks <= 10000)
        {
          a[ks]++;
        }
        else continue;
      }
    }
  }
  for(i=1;i<=n;i++)
  {
    cout << a[i] << "\n";
  }
}


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

int main() {
	int a, b, x;
	int flag = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &x);
	
	for(int i = 0; i <= b; i++){
		if(a + i == x) flag = 1;
	}
	if(flag == 1) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  int count=0;
  for(int i=N-1;i>=0;i){
    if(i<=3){
      cout << "NO" << endl;
      return 0;
    }
    string T="";
    for(int j=0;j<5;j++){
      T=S[i-j]+T;
    }
    i-=5;
    if(T=="dream" || T=="erase"){
      continue;
    }
    T=S[i]+T;
    i-=1;
    if(T=="eraser"){
      continue;
    }
    T=S[i]+T;
    i-=1;
    if(T=="dreamer"){
      continue;
    }
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

ll a[100010];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  bool f = 0;
  int k = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] + a[i-1] >= l) {
      f = 1;
      k = i;
      break;
    }
  }
  if (f) {
    cout << "Possible\n";
  } else {
    puts("Impossible");
    return 0;
  }
  for (int i = 1; i < k; i++) {
    cout << i << "\n";
  }
  for (int j = n - 1; j >= k; j--) {
    cout << j << "\n";
  }
  return 0;
}


Measured memory_bytes: 1664