akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M;
	string ans;
	if (N == M)
		ans = "Yes";
	else
		ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
ans=0
aa=list(set(a))
dict={}
for s in aa:
    dict[s]=0
for l in a:
    dict[l]+=1
for i in dict.items():
    num=i[0]
    amount=i[1]
    """                                                           
    cnt=a.count(i)                                                
    if cnt>i:                                                     
        ans+=cnt-i                                                
    elif cnt<i:                                                   
        ans+=cnt                                                  
    """
    if amount>num:
        ans+=amount-num
    elif amount<num:
        ans+=amount
print(str(ans))

Measured memory_bytes: 20464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_167
{
    class A
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            if(!T.Substring(0, T.Length - 1).Equals(S))
            {
                Console.WriteLine("No");
                return;
            }

            if(T.Length - 1 != S.Length)
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

typedef long long ll;

const int maxn = 1e5+5;
int N,M;
int fa[maxn];
int size[maxn];
ll ans[maxn];
int l[maxn];
int r[maxn];

int find(int x)
{
    return fa[x]==x?x:fa[x]=find(fa[x]); //这里一开始写错了，写成了x = find。。
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        size[a] += size[b];
        size[b] = 0;
       fa[b] = a;
    }
}
int main(){
	cin>>N>>M;

	for(int i=0;i<maxn;i++)
		fa[i] = i,size[i]=1;
	 memset(ans, 0, sizeof(ans));
		
	for(int i=1;i<=M;i++)
		scanf("%d%d", &l[i], &r[i]);
	ll cnt = N;
	ans[M+1] = cnt*(cnt-1)/2;
	for(int i = M;i>=2;i--){
		int x = find(l[i]);
		int y = find(r[i]);
		if(x!=y){
			ans[i] = ans[i+1]-size[x]*size[y];
			join(l[i],r[i]);
		}
		else 
			ans[i] = ans[i+1];
	}
	
	for(int i=2;i<=M+1;i++)
		  printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

#define rep(i, n) for (int i = 0; i < (int)(n)); i++)

using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    cout << n*n-a << endl;
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 10.07.2020 15:53:01
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  string s;
  cin>>s;

  int a,b,c;
  a=b=c=0;
  REP(i,SZ(s))
  {
    if(s[i]=='a')a++;
    else if(s[i]=='b')b++;
    else c++;
  }
  int _min;
  _min=min(a,min(b,c));

  a-=_min;
  b-=_min;
  c-=_min;
  
  if(a<=1 && b<=1 && c<=1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int ar[n];
  for(int i=0;i<n;i++){
    cin>>ar[i];
  }
  sort(ar,ar+n);
  int s=0;
  for(int j=0;j<k;j++)
    s=s+ar[j];
  cout<<s<<endl;
}


Measured memory_bytes: 3592
import java.io.IOException;

public class Main{
    public static void main(String[] a) throws IOException {
		int s1 = 0,s2 = 0,i= 0;
		String[] Set = new String[5];
		String[] stock = new String[5];
		String Input = null;
		java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		try{
			while((Input = in.readLine()) != null){
				stock = Input.split(" ");
				s1 = Integer.parseInt(stock[0]);
				s2 = Integer.parseInt(stock[1]);
				Set[0] = String.valueOf(s1 + s2);
				System.out.println(Set[0].length());
			}
			
		}catch(Exception e){
		}
    }
}

Measured memory_bytes: 17072
a, b, c, x, y = map(int, input().split())
#if a+b <= 2*c:  # aとbをそのまま買う
#    print(a*x + b*y)
#else:
#    if a >= 2*c and b >= 2*c:  # 全部ABピザにする
#        print(2*c * max(x, y))
#    else:
#        if x >= y:
#            print(2*c*y + a*(x-y))
#        else:
 #           print(2*c*x + b*(y-x))


ans = 0

if a+b <= 2*c:
    ans += (a+b) * min(x, y)
else:
    ans += 2*c * min(x, y)

if x >= y:
    if a >= 2*c:
        ans += 2*c*(x-y)
    else:
        ans += a*(x-y)
else:
    if b >= 2*c:
        ans += 2*c*(y-x)
    else:
        ans += b*(y-x)

print(ans)


# 10100 100 500 10 0

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>

#define LL  long long
using namespace std;
int N;

int main()
{
    scanf("%d", &N);
    int a1 = N%10;
    int a2 = (N/10)%10;
    int a3 = (N/100);
    if(a1 == 7 || a2 == 7 || a3 == 7) {
        printf("Yes\n");
    }else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define sot(a,b) sort(a+1,a+1+b)
#define rep1(i,a,b) for(int i=a;i<=b;++i)
#define rep0(i,a,b) for(int i=a;i<b;++i)
#define eps 1e-8
#define int_inf 0x3f3f3f3f
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lson curPos<<1
#define rson curPos<<1|1
using namespace std;
const int maxn = 2000000;
struct Edge
{
    int u,v,w;
}edge[maxn];
int n,cnt,ans[maxn],vis[maxn];
vector<int> g[maxn];
void addedge(int u, int v, int w)
{
  cnt++;
  edge[cnt].u=u;
  edge[cnt].v=v;
  edge[cnt].w=w;
  g[u].push_back(cnt);
}
void bfs()
{
  queue<int> Q;
  Q.push(1);
  while(!Q.empty())
  {
    int x=Q.front();
    Q.pop();
    if(vis[x]) continue;
    vis[x]=1;
    for(int i=0;i<g[x].size();i++)
    {
      int cur=g[x][i];
      if(!vis[edge[cur].v])
      {
        if (edge[cur].w%2==0) ans[edge[cur].v] = ans[x];
        else ans[edge[cur].v] = 1 - ans[x];
        Q.push(edge[cur].v);
      }
    }
  }
}
int main()
{
  cin>>n;
  for(int i=1;i<n;i++)
  {
    int u,v,w;
    cin>>u>>v>>w;
    addedge(u,v,w);
    addedge(v,u,w);
  }
  bfs();
  for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
  return 0;
}


Measured memory_bytes: 58880
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    int n;
    cin >> n;
    V<int> par(n); par[0] = -1;
    VV<int> g(n);
    for (int i = 1; i < n; i++) {
        cin >> par[i];
        g[par[i]].push_back(i);
    }
    V<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    V<int> hist;
    auto query = [&](int v) {
        if (v == 0) return;
        hist.push_back(v);
        int b = a[0];
        while (true) {
            swap(a[v], b);
            if (v == 0) break;
            v = par[v];
        }
    };

    V<bool> used(n), isLeaf(n);
    V<int> leafID(n);
    while (!used[0]) {
        for (int i = n-1; i >= 0; i--) {
            if (used[i]) continue;
            if (g[i].size() == 0) {
                isLeaf[i] = true;
                leafID[i] = i;
            }
            if (g[i].size() == 1 && isLeaf[g[i][0]]) {
                isLeaf[i] = true;
                leafID[i] = leafID[g[i][0]];
            }
        }

        V<bool> fix(n);
        int dust = n-1;
        while (true) {
            if (fix[a[0]]) break;
            if (isLeaf[a[0]]) {
                //leaf
                int v = leafID[a[0]];
                while (true) {
                    if (!fix[a[v]]) break;
                    if (a[v] < a[0]) break;
                    v = par[v];
                }
                fix[a[0]] = true;
                query(v);
            } else {
                while (0 <= dust && (used[dust] || fix[a[dust]])) dust--;
                if (dust < 0) break;
                query(dust); dust--;
            }
        }

        //ref graph
        for (int i = 0; i < n; i++) {
            if (isLeaf[i]) used[i] = true;
            else {
                V<int> ng;
                for (int d: g[i]) {
                    if (!isLeaf[d]) ng.push_back(d);
                }
                g[i] = ng;
            }
        }
    }
    cout << hist.size() << endl;
    for (int d: hist) {
        cout << d << endl;
    }
    return 0;
}


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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int ans = 0; 
    for(int i=1;i<=100;i++){
        if(A < i && i <= B && C < i && i <= D)
            ans++;
    }
    
    cout << ans << endl;
    
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) begin(v), end(v)

using int64 = long long;
const int INF = 1 << 30;
const int mod = 1e9 + 7;


int main()
{
  int N, C[500], S[500], F[500];

  cin >> N;
  rep(i, N - 1) {
    cin >> C[i] >> S[i] >> F[i];
  }
  rep(i, N) {
    int cur = 0;
    for(int j = i; j < N - 1; j++) {
      cur = max(cur, S[j]);
      cur = (cur + F[j] - 1) / F[j] * F[j] + C[j];
    }
    cout << cur << endl;
  }
}

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

int main(){
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) a[i] = i+1;
    double ans = 0;
    rrep(i,n){
        double r = ceil((double)log2((double)k/i));
        if(r<0)r=0;
        ans += (double)pow(1/2.0,r)/n;
    }
    printf("%.12f", ans);
    return 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,d = na()
ans = 0

for i in range(n):
    x,y = na()
    if x**2+y**2 <= d**2:
        ans += 1

print(ans)

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

using namespace std;

int cnt[3];

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x <= a) cnt[0]++;
        else if (a + 1 <= x && x <= b) cnt[1]++;
        else cnt[2]++;
    }

    printf("%d\n", min(min(cnt[0], cnt[1]), cnt[2]));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N, D[1000];
  cin >> N;
  bool sss[1000] = {};
  for(int i = 0; i < N; i++) {
    cin >> D[i];
    sss[D[i]] = true;
    if(i > 0) sss[D[i - 1] * 10 + D[i]] = true;
    if(i > 1) sss[D[i - 2] * 100 + D[i - 1] * 10 + D[i]] = true;
  }
  for(int i = 0; true; i++) {
    if(!sss[i]) {
      cout << i << endl;
      exit(0);
    }
  }
}

Measured memory_bytes: 1164
#include <cmath>
#include <cstdio>
int main(){
	long long int n, k, p = 1, ans = 1;
	scanf("%lld %lld",&k,&n);
	if (k == 1){
		printf("%lld\n",n);
		return 0;
	}
	while (n > 1 && p <= sqrt(n)){
		p++;
		if (n % p != 0){
			continue;
		}
		long long int c = 0;
		while (n % p == 0){
			n /= p;
			c++;
		}
		ans *= pow(p, c / k);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import itertools


n_even, n_odd = map(int, input().split())

# 偶数になるのは、(偶数+偶数) と (奇数+奇数)
count1 = len(list(itertools.combinations(range(n_even), r=2)))
count2 = len(list(itertools.combinations(range(n_odd), r=2)))

print(count1 + count2)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  int N,ans=0,a;
  cin >> N;
  vec A(N+1);
  for(int i=1;i<=N;i++)cin >> A.at(i);
  map<int,int>wa,sa;
  vec number;
  for(int i=1;i<=N;i++){
    wa[i+A.at(i)]++;
    sa[i-A.at(i)]++;
    if(wa[i+A.at(i)]==1)number.pb(i+A.at(i));
    if(sa[i-A.at(i)]==1)number.pb(i-A.at(i));
  }
  int siz=number.size();
  for(int i=0;i<siz;i++){
    a=number.at(i);
    ans+=wa[a]*sa[a];
    wa[a]=0;
    sa[a]=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 53056
def gcd(a,b):
  if a*b == 0:
    return max(a,b)
  if a<b:
    a,b = b,a
  return gcd(b,a%b)
n = int(input())
ls = list(map(int,input().split()))
length = 2**(n.bit_length())
calc = gcd
unit = 0
Seg = [unit for i in range(length*2-1)]
def init():
  for i in range(n):
    Seg[i+length-1] = ls[i]
  for i in range(length-2,-1,-1):
    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])
def update(i,x):
  i += length-1
  Seg[i] = x
  while i>0:
    i = (i-1)//2
    Seg[i] = calc(Seg[2*i+1],Seg[2*i+2])
def query(a,b,k,l,r):
  if r<=a or b<=l:
    return unit
  if l<=a and b<=r:
    return Seg[k]
  else:
    vl = query(a,b,2*k+1,l,(l+r)//2)
    vr = query(a,b,2*k+2,(l+r)//2,r)
    return calc(vl,vr)

init()
ans = []
for i in range(n):
  update(i,0)
  ans.append(query(0,n,0,0,length))
  update(i,ls[i])
print(max(ans))

Measured memory_bytes: 143880
use std::io::stdin;

fn main() {
    let nq: Vec<u64> = read().split(" ").map(|n| n.parse().unwrap()).collect();
    let s = read();
    let mut vec: Vec<u64> = vec![0];
    let mut count = 0;
    for i in 1..s.len() {
        let t = &(&s)[i - 1 .. i + 1];
        if t == "AC" {
            count = count + 1;
        }
        vec.push(count);
    }
    
    for _ in 0..nq[1] {
        let lr: Vec<usize> = read().split(" ").map(|n| n.parse().unwrap()).collect();
        let t = vec[lr[1] - 1] - vec[lr[0] - 1];
        println!("{}", t);
    }
}

fn read() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

Measured memory_bytes: 4860
gets
s=gets.split.map(&:to_i)
gets
t=gets.split.map(&:to_i)

# Array#bsearch
#p t.count{|n|s.bsearch{|m| m >= n} == n}

def bsearch(arr, n)
  return false if arr.empty?

  start_pos = 0
  end_pos = arr.length - 1

  while start_pos <= end_pos
    i = (end_pos + start_pos) / 2
    elem = arr[i]

    break if n == elem
    
    if n < elem
      end_pos = i - 1
    else
      start_pos = i + 1
    end
  end

  return elem == n
end

p t.count{|n| bsearch(s,n)}



Measured memory_bytes: 15356
#include<bits/stdc++.h>
using namespace std;
#define int long long 

const int M = 1e9+7;

vector<vector<int>>dp;

void solve(){
	int n;
	cin>>n;
	dp.assign(n+2,vector<int>(4,0));
	dp[0][0] = 1;

	for(int i=1;i<=n;++i){
		dp[i][3] = ((dp[i-1][1]+dp[i-1][2])%M+10*dp[i-1][3]%M)%M;
		dp[i][2] = (dp[i-1][0] + 9*dp[i-1][2]%M)%M;
		dp[i][1] = (dp[i-1][0] + 9*dp[i-1][1]%M)%M;
		dp[i][0] = 8*dp[i-1][0]%M;
	}

	cout << dp[n][3] << endl;
	return;
}

int32_t main(){
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 73320
N = int(input())
z = []
for i in range(N):
    xi, yi = map(int, input().split())
    z.append([xi + yi, xi - yi])

parity = z[0][1] % 2
for i in range(1, N):
    if z[i][0] % 2 != parity:
        print(-1)
        exit()
m = 32
def sign(n):
    pm = []
    diff = (((1 << m) - 1) - n) // 2
    for i in range(m):
        if (diff >> i) & 1 == 1:
            pm.append(-1)
        else:
            pm.append(1)
    return pm

ans = [''] * N
if parity == 0:
    arm = [1] + [1 << k for k in range(m)]
    for i in range(N):
        z[i][0] -= 1
        z[i][1] -= 1
        ans[i] += 'R'
if parity == 1:
    arm = [1 << k for k in range(m)]

for i in range(N):
    ui = sign(z[i][0])
    vi = sign(z[i][1])
    for k in range(m):
        if ui[k] == 1:
            if vi[k] == 1:
                ans[i] += 'R'
            else:
                ans[i] += 'U'
        else:
            if vi[k] == 1:
                ans[i] += 'D'
            else:
                ans[i] += 'L'
print(len(arm))
print(' '.join(map(str, arm)))
for i in range(N):
    print(ans[i])

Measured memory_bytes: 44144
package main

import (
	"fmt"
	"math"
)

func main() {
	var X, n, p int
	var P [103]int
	var tmp float64
	tmp = 10000
	ans := 0

	fmt.Scan(&X, &n)

	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		P[p+1] = 1
	}

	for i := 0; i < 103; i++ {
		if P[i] == 0 {
			if float64(tmp) > math.Abs(float64(X - i + 1)) {
				ans = i - 1
				tmp = math.Abs(float64(X - i + 1))
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1840
$primes = [2,3]

def is_prime(n)
	i = 0
	while $primes[i] <= n/2
		return false if n % $primes[i] == 0
		i += 1
	end
	return true
end

def next_prime(n)
	n += 1 if n % 2 == 0
	loop do
		return n if is_prime(n)
		n += 2
	end
end

def make_prime(n)
	while $primes[-1] <= n
		$primes << next_prime($primes[-1]+1)
	end
end

def print_prime(n)
	if is_prime(n)
		i = $primes.index(n)
		print $primes[i-1], " ", $primes[i+1]
	else
		i = 0
		i += 1 while $primes[i] < n
		print $primes[i-1], " ", $primes[i]
	end
	puts ""
end

while gets
	n = $_.to_i
	if n < 3 || 50000 < n
		puts "n must be in the range (3..50000)"
		next
	end
	make_prime(n) if $primes[-2] < n
	print_prime(n)
end

Measured memory_bytes: 6144
n,a=map(int,input().split())

l=[a+i-1 for i in range(1,n+1)]

import numpy as np
b=min(np.abs(l))

if b==0:
  l.remove(0)
elif b in l:
  l.remove(b)
elif -b in l:
  l.remove(-b)
  
print(sum(l))

Measured memory_bytes: 12500
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, l[200],sum=0;
	cin >> n;
	for (int i = 0; i < 2 * n; ++i) cin >> l[i];
	sort(l, l + 2 * n);
	for (int i = 0; i < 2 * n; i += 2) sum += l[i];
	cout << sum << endl;
	return 0;
}

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

int main(){
  char a, b;
  cin >> a >> b;
  if(a == 'H'){
    cout << b << endl;
  }else if(b == 'H'){
    cout << 'D' << endl;
  }else{
    cout << 'H' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
while True:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        if n>=m:
            x,y=n,m
        else:
            x,y=m,n
        s=0
        while True:
            if y!=0:
                x=x%y
                x,y=y,x
                s+=1
            else:
                break
    print(x,s)


Measured memory_bytes: 5608
#include "stdio.h"

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if(a-b == b-c && c-b == b-a){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return (0);
}

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

int n;
int euc(int a,int b){
    if(a<b) euc(b,a);
    else{
        while(a%b){
            int r=a%b;
            a=b,b=r;
        }
        return b;
    }
}
int main(){
    scanf("%d",&n);
    vector<ll> a(n);
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    ll gcd=a[0];
    rep(i,n){
        ll k=gcd;
        gcd = euc(k,a[i]);
    }
    printf("%lld\n",gcd);
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;


int main() {
  int N;cin >> N;
  //debug(N);
  int M = 1<<N;

  vector<pair<ll,ll> > dp(M,make_pair(-1,-1));
  vector<ll> A(M);
  repeat(s,M){
    cin >> A[s];
    dp[s].first = A[s];
  }
  repeat(i,N){
    repeat(s,M){
      if((s&(1<<i))==0){
        if(dp[s|(1<<i)].second < dp[s].first){
          dp[s|(1<<i)].second = dp[s].first;
          if(dp[s|(1<<i)].first < dp[s|(1<<i)].second){
            swap(dp[s|(1<<i)].first,dp[s|(1<<i)].second);
          }
          if(dp[s|(1<<i)].second < dp[s].second){
            dp[s|(1<<i)].second = dp[s].second;
          }
        }
      }
    }
  }
  repeat(s,M){
    cerr << "dp["<<s<<"] "<< dp[s].first<<" "<<dp[s].second <<endl;
  }
  vector<ll> ans(M,0);
  for(int K=1;K<M;K++){
    ans[K] = max(ans[K-1],dp[K].first+dp[K].second);
    cout << ans[K] << endl;
  }

  return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int num, ber, Max = 0, Min = 10000;
	vector<int> point;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		cin >> ber;
		point.emplace_back(ber);
		Max = max(Max, ber);
		Min = min(Min, ber);
	}

	cout << Max - Min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
//const int maxn=;
const int maxV=1e5+10;
const int maxE=1e5+10;
vector<int> son[maxV];
template<typename T> void read(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=x*10+s-'0';s=getchar();}
	x*=f;
}
int n,m,ans,dist[maxV];
bool ind[maxV];
int dfs(int st){
	if(dist[st]) return dist[st];
	if(!son[st].size()){
		return 0;
	}
	int m=0;
	for(re int i=0;i<son[st].size();i++){
		m=max(m,dfs(son[st][i])+1);
	}
	return dist[st]=m;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);read(m);
	for(re int i=1;i<=m;i++){
		int x,y;
		read(x);read(y);
		son[x].push_back(y);
		ind[y]++;
	}
	for(re int i=1;i<=n;i++){
		if(!ind[i] && !dist[i]){
			ans=max(ans,dfs(i));
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k - 1] += 32;
    cout << s << endl;
    
    return 0;
}

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

vector<int> f(1000001, 0);

void getf(int a) {
  for (int i = 2; i * i <= a; i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    if (cnt > f.at(i)) f.at(i) = cnt;
  }
  if (a > 1) f.at(a) = max(f.at(a), 1);
}

ll modinv(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

// ll modinv(ll a, ll m) {
//   ll b = m;
//   ll u = 1;
//   ll v = 0;

//   while (b > 0) {
//     ll t = a / b;
//     a -= t * b;
//     swap(a, b);
//     u -= t * v;
//     swap(u, v);
//   }

//   u %= m;
//   if (u < 0) u += m;
//   return u;
// }

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    getf(A.at(i));
  }

  ll lcm = 1LL;
  for (int i = 2; i <= 1000000; i++) {
    if (f.at(i) == 0) continue;
    lcm = (lcm * (ll)pow(i, f.at(i)) % mod) % mod;
  }

  ll ans = 0LL;
  for (int i = 0; i < N; i++) {
    ans = (ans + lcm * modinv(A.at(i), mod - 2) % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}

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

// APG4b
int main() {
  int N,temp,Max,sum;
  cin >> N; // 12, 57, 148
  temp = N;

  sum = 0;
  Max = 1; // Nの桁
  while(Max*10 < N) { // Max=10, 10, 100
    Max = Max * 10;
  }
  
  // 上位の桁からsumに入れていく
  /*while (Max >= 1) {
    sum += temp / Max; // それぞれの桁の数字を取り出して和を計算
    temp %= Max; // 桁を1/10
    Max /= 10; // それに合わせて割る数も1/10
  }*/

  // 下位の桁からsumに入れていく
  while (temp > 0) {
    sum += temp % 10;
    temp /= 10;
  }

  if (!(N%sum)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,k;
int d[10];
bool f(int x){
    while(x){
        if(d[x%10])return false;
        x/=10;
    }
    return true;
}
int main(void){
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int a;
        cin>>a;
        d[a]=1;
    }
    while(1){
        if(f(n)){cout<<n<<endl;return 0;}
        n++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
ll chk (ll n) {
    ll p = 0 ;
    while(n/10) {
        p++ ;
        n/=10 ;
    }
    return p ;

}

int main() {
    ll a , b ;
    cin >> a>> b ;
    cout<< a*b ; 

    return 0 ;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

struct Edge {
    int to;
    int weight;

    Edge(int to, int weight) : to(to), weight(weight) {}
};

using Graph = vector<vector<Edge>>;
vector<int> colors;
vector<bool> seen;

Graph graph;

void dfs(int v, int p, int c) {
    colors[v] = c;
    for (auto e : graph[v]) {
        if (e.to == p) continue;
        if (e.weight & 1) dfs(e.to, v, 1-c);
        else dfs(e.to, v, c);
    }
}

int main() {

    int N;
    cin >> N;

    graph.assign(N,vector<Edge>());

    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        u -= 1;
        v -= 1;
        graph[u].push_back(Edge(v, w));
        graph[v].push_back(Edge(u, w));
    }
    colors.assign(N,0);

    dfs(0,-1,1);

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

}

Measured memory_bytes: 11536
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
    exit()
a=[300000,200000,100000,0]
if x>3:
    x=0
if y>3:
    y=0
if x==0 and y==0:
    print(0)
    exit()
print(a[x-1]+a[y-1])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << min(b/a, c) << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

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


//ai  3224----a[i][j]
//an  1211----a[n][n]
bool exist=false;

for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
if(i+m-1>=n) continue;

    bool match=true;
    for(int y=0;y<m;y++){
        for(int x=0;x<m;x++){
            if(a[i+y][j+x]!=b[y][x])match=false;
        }
    }
    if(match) exist=true;


    }
}

if(exist)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;


return 0;
}

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

int main()
{
	int N;
	cin >> N;

	long long rez = 1;
	long long L0 = 2;
	long long L1 = 1;

	for (int i = 2; i <= N; i++)
	{
		rez += L0;
		L0 = L1;
		L1 = rez;
	}

	cout << endl << rez << endl;
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

void    chmin(int *left, int right)
{
        if (*left > right)
        {
                *left = right;
        }
}

int             main(void)
{
        int             n;
        int             k;
        int             height[100000];
        int             answer[100000];
        int             i;
        int             j;

        scanf("%d%d", &n, &k);
        for (i = 0; i < n; i++)
        {
                scanf("%d", &height[i]);
                answer[i] = INT_MAX;
        }
        answer[0] = 0;
        for (i = 0; i < n - 1; i++)
        {
                for (j = 1; j <= k; j++)
                {
                        if (i + j < n)
                                chmin(&answer[i + j], answer[i] + abs(height[i + j] - height[i]));
                }
        }
        printf("%d\n", answer[n - 1]);
        return (0);
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
string s;
int n,nxt[200100][26],dp[200100];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	n=s.size();
	for(int i=0;i<26;i++) nxt[n][i]=n;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;j++)
			nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]-'a']=i;
		dp[i]=1e9;
	}
	dp[n]=1;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;j++){
			dp[i]=min(dp[i],dp[nxt[i][j]+1]+1);
		}
	}
	int idx=0;
	for(int i=dp[0];i>=0;i--){
		for(int j=0;j<26;j++){
			if(dp[idx]==dp[nxt[idx][j]+1]+1){
				cout<<(char)(j+'a');
				idx=nxt[idx][j]+1;
				break;
			}
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 21652
import collections
N=int(input())
B=[]
g=10**9+7
A=[int(i) for i in input().split()]
for i in A:
 B.append(((N-1+i)/2,(N-1-i)/2))
c= collections.Counter(B)
d=1
for i,j in c.items():
 d*=j
 if j==1 and i[0]!=i[1]:
   d=0
   break
 if d>g:
   d=d%g
print(d%g)

Measured memory_bytes: 25572
h, w = map(int, input().split())
s = [input() for _ in range(h)]

INF = 10**9
dp = [[INF]*w for _ in range(h)]

dp[0][0] = 0 if s[0][0] == "." else 1

for i in range(h):
    for j in range(w):
        d, r = INF, INF

        if i != 0:
            d = dp[i - 1][j] + (s[i - 1][j] == "." and s[i][j] == "#")
        if j != 0:
            r = dp[i][j - 1] + (s[i][j - 1] == "." and s[i][j] == "#")

        dp[i][j] = min(r, d, dp[i][j])

print(dp[h-1][w-1])


Measured memory_bytes: 68384
#include<iostream>

int main(void){
	int i=0;
	int x[10000];
	while(1){
		std::cin >> x[i];
		if(x[i]==0) break;
		i=i+1;
	}
	for(int j=0;j<i;j++) std::cout << "Case " << j+1 << ": " << x[j] << std::endl;
	return 0;
}

Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_5_B_MergeSort
{
    class Program
    {
        const int INF = int.MaxValue;
        const int MAX = 500000;
        public static int[] L = new int[MAX / 2 + 2], R = new int[MAX / 2 + 2];

        static int count = 0;
        static void Main(string[] args)
        {
            int[] A = new int[MAX];
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for (int i = 0; i < n; i++)
            {
                A[i] = S[i];
            }
            A = MergeSort(A, n, 0, n);
            for (int i = 0; ; i++)
            {
                if (i == n - 1)
                {
                    Console.Write(A[i] + "\r\n");
                    break;
                }
                Console.Write(A[i] + " ");
            }
            Console.WriteLine(count);
        }

        static int[] MergeSort(int[] Array, int n, int left, int right)
        {
            if (left + 1 < right)
            {
                int mid = (left + right) / 2;
                Array = MergeSort(Array, n, left, mid);
                Array = MergeSort(Array, n, mid, right); //もっとも小さい配列に分解していく(要素数1まで)
                Array = Merge(Array, n, left, mid, right); //大小を比べて併合していく
            }
            return Array;
        }

        static int[] Merge(int[] Array, int n, int left, int mid, int right)
        {
            var n1 = mid - left;
            var n2 = right - mid;

            for (int i = 0; i < n1; i++)
            {
                L[i] = Array[left + i];
            }
            for (int i = 0; i < n2; i++)
            {
                R[i] = Array[mid + i];
            }
            L[n1] = R[n2] = INF;
            int o = 0;
            int p = 0;
            for (int k = left; k < right; k++)
            {
                count++;
                if (L[o] <= R[p])
                {
                    Array[k] = L[o++];
                }
                else
                {
                    Array[k] = R[p++];
                }
            }
            return Array;
        }
    }
}


Measured memory_bytes: 63100
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1], Q = ip[2];
	auto arr = new int[](N);
	foreach(i; 0..Q) {
		auto A = ri;
		arr[A-1]++;
	}
	foreach(i; 0..N) {
		if(K + arr[i] - Q > 0) writeln("Yes");
		else writeln("No");
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 3964
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

//  void y(void){cout << "yes"<< endl;}
  void Y(void){cout << "YES" << endl;}
  void y(void){cout << "Yes" << endl;}
//  void n(void){cout << "no"<< endl;}
  void N(void){cout << "NO" << endl;}
  void n(void){cout << "No" << endl;}
  
  
  
	int A,B,C,D,E,F,G,H,ans=0,res=0;
//	char A,B,C,D,E,F,G,H;
//	string A,B,C,D,E,F,G,H;
//	double A,B,C,D,E,F,G,H;
	
void take(int x){
	if(x==1)
		cin >> A;
	else if(x==2)
		cin >> A >> B;
	else if(x==3)
		cin >> A >> B >> C;
	else if(x==4)
		cin >> A >> B >> C >> D;
	else if(x==5)
		cin >> A >> B >> C >> D >> E;
	else if(x==6)
		cin >> A >> B >> C >> D >> E >> F;
	else if(x==7)
		cin >> A >> B >> C >> D >> E >> F >> G;
	else if(x==8)
		cin >> A >> B >> C >> D >> E >> F >> G >> H;
	return ;
}
  
int main(void){
	take(1);//数
	
	
	
	if(A==7 || A==5){
		
		
	//	y();	//Yes
		Y();	//YES
	//	n();	//No
	//	N();	//NO
	}
	
	else if(A==3){
		
		
	//	y();
		Y();
	//	n();
	//	N();
		
	}/*
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}*/
	
	else{
		
		
	//	y();
	//	Y();
	//	n();
		N();
		
	}
//	cout << ans << endl;
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int x = 0;
    int a = 0;

    scanf("%d %d", &x, &a);
    
    if(x < a){printf("0\n");}
    if(x >= a){printf("10\n");}
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c,x;
	cin >> a >> b >> c;
	if (a != b && a != c && b != c) {
		cout << 3 << endl;
	}
	else if (a == b && a != c && b != c){
		cout << 2 << endl;
	}
	else if (a != b && a == c && b != c) {
		cout << 2 << endl;
	}
	else if (a != b && a != c && b == c) {
		cout << 2 << endl;
	}
	else if (a == b && a == c && b == c) {
		cout << 1 << endl;
	}
	else if (a == b && a != c && b != c) {
		cout << 2 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	string c1, c2;

	cin >> c1 >> c2;

	int i = 0;
	int x = 0;

	while(c1[i] != '\0') {
		if (c1[i] != c2[i])
		{
			x = x + 1;
		}
		i = i + 1;
	}

	cout << x << endl;
}


Measured memory_bytes: 3916
""" AtCoder """

N = int(input())
A = list(map(int, input().split()))

if N ==1:
    print(0)
    exit()

for i in range(N):
    A[i] -= i + 1

A.sort()

b = A[N//2]
bb = A[N//2 + 1]

ans = 0
ansans = 0

for a in A:
    ans += abs(a - b)
    ansans += abs(a - bb)

print(min(ans, ansans))


Measured memory_bytes: 26180
#include <bits/stdc++.h>
//#include "stdc++.h"
#define llint long long int
#define ldouble long double

using namespace std;

int main() {
    int N;
    cin>>N;
    int b[N+1];
    for(int i=0;i<N;i++){
        cin>>b[i];
    }
    int rlt[N];
    b[N]=110; //for文での例外除去

    bool je=true;
    for(int i=0;i<N;i++){
        if(b[i]>i+1){
            je=false; //i番目がiより大きい数なら無理
            break;
        }
    }

    int lm=N; //探す上限

    if(je==true){
        for(int j=0;j<N;j++){ //消す操作をN回繰り返す
            for(int k=lm-1;k>=0;k--){ //同じ奴を探す　後ろからやる
                if(b[k]==k+1 && b[k+1]!=k+2){ //同じかつ階段状になってないか
                    rlt[N-1-j]=k+1;
                    for(int l=k;l<N;l++){
                        b[l]=b[l+1]; //前に詰める
                    }
                    lm--;
                    break;
                }
            }
        }
    }

    if(je==true){
        for(int i=0;i<N;i++){
            cout<<rlt[i];
            if(i!=N-1){
                cout<<" ";
            }   
        }
        cout<<endl;
    }
    else{
        cout<< "-1"<<endl;
    }

return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s; cin >> s;
  vector<int> d(4);
  for (int i = 0; i < (int)s.size(); ++i) {
    d[i] = s[i] - '0';
  }
  int pat = 0;
  for (int i = 0; i < 8; ++i) {
    int sum = d[0];
    for (int j = 0; j < 3; ++j) {
      if (i & (1 << (2 - j))) { sum += d[j + 1]; }
      else { sum -= d[j + 1]; }
    }
    if (sum == 7) {
      pat = i;
      break;
    }
  }
  printf("%d", d[0]);
  for (int i = 0; i < 3; ++i) {
    char c = (pat & (1 << (2 - i))) ? '+' : '-';
    printf("%c%d", c, d[i + 1]);
  }
  printf("=7\n");

  // for (int i = 0; i < 2; ++i) {
  //   for (int j = 0; j < 2; ++j) {
  //     for (int k = 0; k < 2; ++k) {
  //       int sum = d[0];
  //       if (i == 0) { sum += d[1]; }
  //       else { sum -= d[1]; }
  //       if (j == 0) { sum += d[2]; }
  //       else { sum -= d[2]; }
  //       if (k == 0) { sum += d[3]; }
  //       else { sum -= d[3]; }
  //       if (sum == 7) {
  //         char op1 = (i == 0) ? '+' : '-';
  //         char op2 = (j == 0) ? '+' : '-';
  //         char op3 = (k == 0) ? '+' : '-';
  //         printf("%d%c%d%c%d%c%d=7\n", d[0], op1, d[1], op2, d[2], op3, d[3]);
  //         return 0;
  //       }
  //     }
  //   }
  // }
  return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> t(q);
  vector<char> d(q);
  for(int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }

  auto check = [&](int i) {
    for(int j = 0; j < q; j++) {
      if(s[i] == t[j]) {
        if(d[j] == 'L') i--;
        else i++;
      }
      if(i == -1 || i == n) break;
    }
    return i;
  };

  int ans = 0;

  int ok, ng;
  ok = -1, ng = n;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid) == -1) ok = mid;
    else ng = mid;
  }
  ans = ok + 1;

  ok = n, ng = -1;
  while(abs(ok - ng) > 1) {
    int mid = (ok + ng) >> 1;
    if(check(mid) == n) ok = mid;
    else ng = mid;
  }

  ans += n - ok;

  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 1e5 + 5;
const int md2 = 998244353;
const int md = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

void solve() {
    int x; cin >> x;
    cout << (x ^ 1) << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int mn[n];
	mn[0]=arr[0];
	for(int i=1;i<n;i++){
		mn[i]=min(mn[i-1],arr[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(mn[i]==arr[i]){
			ans+=1;
		}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 6756
/*
[agc036] A - Triangle
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const ll MAX_X = 1e9;

ll S;
ll ans[2][3];

void solve() {
    ans[0][0] = 0;
    ans[1][0] = 0;
    ans[0][1] = MAX_X;
    ans[1][1] = 1;
    ans[0][2] = MAX_X - (S + MAX_X - 1) % MAX_X - 1;
    ans[1][2] = (S + MAX_X - 1) / MAX_X;

    for (int j = 0; j < 3; j++) {
        for (int i = 0; i < 2; i++) {
            cout << ans[i][j] << " ";
        }
    }
    cout << endl;
}

int main() {
    cin >> S;

    solve();

    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
flg = True
i = 0
while i <= (N-3)/2:
    if S[i]!=S[int((N-3)/2-i)]:
        flg = False
    i += 1
i = N-1
while i >= (N+1)/2:
    if S[i]!=S[int((3*N-1)/2-i)]:
        flg = False
    i -= 1
i = 0
while i <= N-1:
    if S[i]!=S[N-1-i]:
        flg = False
    i += 1
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

vector<vector<int>> g;

const int N = 1e5 + 100;
vector<vector<int>> lang(N);
vector<bool> visited(N, false);

void dfs(int v) {
  visited[v] = true;
  for (auto &u : g[v]) {
    if (!visited[u]) {
      dfs(u);
    }
  }
}

void add_edge(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      lang[x].push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j < sz(lang[i]); j++) {
      add_edge(lang[i][j], lang[i][j - 1]);
    }
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}



Measured memory_bytes: 12020