akhauriyash/Code-Regression huggingface dataset:
program A324B
    implicit none
    integer(8)::N,M,ans,i,j,flg,X
    character(10),allocatable,dimension(:)::S,T
    read*,N
    allocate(S(N))
    read*,S
    read*,M
    allocate(T(M))
    read*,T
    ans=0

    do i=1,N
        flg=0
        X=0
        do j=1,N
            if(S(i)(1:len_trim(S(i)))==S(j)(1:len_trim(S(j))))X=X+1
        end do

        do j=1,M
            if(S(i)(1:len_trim(S(i)))==T(j)(1:len_trim(T(j))))X=X-1
        end do
        ans=max(ans,X)
    end do

    print'(i0)',ans
end program A324B

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second

const int maxn = 200000 + 100;
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
vector<int> g[maxn];
int s[maxn],fen,snuke;
int parent[maxn];
int n;
int dfs1(int u,int last){
    parent[u] = last;
    s[u] = 1;
    for (int v : g[u]){
        if (v == last) continue;
        dfs1(v,u);
        s[u] += s[v];
    }
}
int dfs2(int u ,int last,int d){
    if (u == n){
        int up = (d - 1) / 2;
        for (int i = 0;i < up;i++){
            u = parent[u];
        }
        fen = s[1] - s[u];
        snuke = s[u];

        return 0;
    }
    for (int v : g[u]){
        if (v == last) continue;
        dfs2(v,u,d + 1);
    }

}
int main(){

    cin >> n;
    int a,b;
    for (int i = 0 ;i < n - 1;i++){
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs1(1,0);
    dfs2(1,0,0);
    if (fen > snuke){
        cout << "Fennec\n";
    }else cout << "Snuke\n";
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000;
 
signed main()
{
    int n; cin >> n;
    int dp[101];
    rep(i,9) rep(j,9) {
        if (n==(i+1)*(j+1)) {
          cout << "Yes" << endl;
          return 0;
        }
        // dp[(i+1) * (j+1)] = 1;
    }
    cout << "No" << endl;
    return 0;
    string ans;
    if (dp[n] == 1) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;
#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        d: [usize; n]
    }
    let mut res = 0;
    for (i, j) in (0..n).tuple_combinations() {
        res += d[i] * d[j];
    }
    println!("{}", res);
}


Measured memory_bytes: 2168
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    int answer = A - B * 2;
    
    if(answer > 0) {
      System.out.println(answer);
    } else {
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 22996
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        double r = double.Parse(input);
        double S = r * r * Math.PI;
        double L = r * 2 * Math.PI;
        Console.WriteLine("{0:f6} {1:f6}", S, L);
    }
}

Measured memory_bytes: 5780
#include <stdio.h>
int main(){
    int a,b;
    char op;
    
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        
        if(op=='+') printf("%d\n",a+b);
        else if(op=='-') printf("%d\n",a-b);
        else if(op=='*') printf("%d\n",a*b);
        else if(op=='/') printf("%d\n",a/b);
        else if(op=='?') break;
    }
    return 0;
}



Measured memory_bytes: 2080
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            if (s == "RRR")
                WriteLine(3);
            else if (s == "RRS")
                WriteLine(2);
            else if (s == "SRR")
                WriteLine(2);
            else if (s == "RSR")
                WriteLine(1);
            else if (s == "SSR")
                WriteLine(1);
            else if (s == "SRS")
                WriteLine(1);
            else if (s == "RSS")
                WriteLine(1);
            else if (s == "SSS")
                WriteLine(0);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 25952
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char>> a(H, vector<char>(W, '.'));
	for(int i = 0; i < H; i++)
		for(int j = 0; j < W; j++)
			cin >> a[i][j];

	vector<char> b(W, '.');
	for(int i = 0; i < a.size(); i++) {
		if(a[i] == b) {
			a.erase(a.begin() + i);
			i--;
		}
	}

	for(int i = 0; i < a[0].size(); i++){
		for(int j = 0; j < a.size(); j++) {
			if(a[j][i] != '.')
				break;
			else if(a[j][i] == '.' && j == a.size()-1){
				for(int k = 0; k < a.size(); k++)
					a[k].erase(a[k].begin() + i);
				i--;
			}
		}
	}

	for(int i = 0; i < a.size(); i++)
		for(int j = 0; j < a[0].size(); j++){
			cout << a[i][j];
			if(j == a[0].size() - 1)
				cout << endl;
		}

	return 0;
}

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

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

    int M, K;
    cin >> M >> K;

    if (K >= (1<<M)) {
        cout << -1 << endl;
        return 0;
    }

    if (M == 0) {
        cout << "0 0" << endl;
        return 0;
    } else if (M == 1) {
        cout << (K == 0 ? "0 0 1 1" : "-1") << endl;
        return 0;
    }

    vector<int> v(1, K);
    for (int i=0; i<(1<<M); ++i) {
        if (i == K) continue;
        v.push_back(i);
    }
    v.push_back(K);
    for (int i=(1<<M)-1; i>=0; --i) {
        if (i == K) continue;
        v.push_back(i);
    }

    for (int i=0; i<v.size(); ++i) {
        cout << (i == 0 ? "" : " ") << v[i];
    }
    cout << endl;

    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

ll f(int N, vector<ll>& y, ll ix){
    ll ans = 0;
    rep(i,N){
        ans += llabs(y[i] - y[ix]);
    }
    // cerr << y << y[ix] <<":"<< ans << endl;
    return ans;
}

ll solve(int N, vi& a) {
    vector<ll> y(N);
    rep(i,N) y[i] = a[i] - (1+i);
    sort(ALL(y));
    if (N % 2) {
        return f(N,y,N/2);
    } else {
        return min(f(N,y,N/2-1), f(N,y,N/2));
    }
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;

int ans = 1;
int N, K;

void dfs(const Graph &G, int pv, int v, int num){
	ans *= num;
	if(ans == 0) return;
	ans %= MOD;
	if(num == K) --num;
	else num = K-2;
	for(auto nv : G[v]){
		if(nv == pv) continue;
		dfs(G, v, nv, num);
		--num;
	}
}


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

	cin >> N >> K;
	Graph G(N);
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(G, -1, 0, K);
	cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
#define pb push_back
#define rez resize
#define fi first
#define se second
typedef long long ll;
typedef pair <int, int> pii;
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
const int N = 2e5 + 5;
struct E { int v, c, nxt; };
int n, a[N], b[N], col1[N], col2[N];
int ct = 0;
namespace Flow {
  int fst[N], cur[N], cnt, s, t, d[N];
  E e[N << 5];
  inline void init() {
    s = 0, t = ct + 1;
    for (ri i = s; i <= t; ++i) fst[i] = -1;
    cnt = -1;
  }
  inline void addedge(int u, int v, int c) { e[++cnt] = (E) { v, c, fst[u] }, fst[u] = cnt; }
  inline void _add(int u, int v, int c) { addedge(u, v, c), addedge(v, u, 0); }
  inline bool spfa() {
    for (ri i = s; i <= t; ++i) d[i] = -1, cur[i] = fst[i];
    queue <int> q;
    q.push(s), d[s] = 0;
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (ri i = fst[x]; ~i; i = e[i].nxt) if (e[i].c > 0 && d[e[i].v] == -1) {
        d[e[i].v] = d[x] + 1;
        q.push(e[i].v);
      }
    }
    return ~d[t];
  }
  inline int dfs(int x, int f) {
    if (!f || x == t) return f;
    int fl = f;
    for (ri &i = cur[x], v, tp; ~i; i = e[i].nxt) {
      if (!fl) return f;
      v = e[i].v;
      if (e[i].c && d[v] == d[x] + 1) {
        tp = dfs(v, min(fl, e[i].c));
        if (!tp) d[v] = -1;
        e[i].c -= tp, e[i ^ 1].c += tp, fl -= tp;
      }
    }
    return f - fl;
  }
  inline int solve() {
    int res = 0, tp;
    while (spfa()) while ((tp = dfs(s, inf)) > 0) res += tp;
    return res;
  }
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read();
  for (ri i = 1; i <= n; ++i) a[i] = read() + 1;
  for (ri i = 1; i <= n; ++i) b[i] = read() + 1;
  for (ri i = 1; i <= n; ++i) if (!col1[i]) {
    ++ct;
    for (ri x = a[i]; x != i; x = a[x]) col1[x] = ct;
    col1[i] = ct;
  }
  for (ri i = 1; i <= n; ++i) if (!col2[i]) {
    ++ct;
    for (ri x = b[i]; x != i; x = b[x]) col2[x] = ct;
    col2[i] = ct;
  }
  Flow:: init();
  int res = n;
  for (ri i = 1; i <= n; ++i) {
    if (a[i] == i && b[i] == i) --res;
    else if (a[i] == i) Flow:: _add(col2[i], Flow:: t, 1);
    else if (b[i] == i) Flow:: _add(Flow:: s, col1[i], 1);
    else if (a[i] != b[i]) Flow:: _add(col2[i], col1[i], 1);
    else Flow:: _add(col2[i], col1[i], 1), Flow:: _add(col1[i], col2[i], 1);
  }
  cout << res - Flow:: solve();
  return 0;
}

Measured memory_bytes: 15116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353 
#define INF 1e9
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,i,j,k,t,l;
    cin>>n;
    ll a[n],b[n];
    map <ll,ll> m;
    for(i=0;i<n;i++){
    	cin>>a[i];
    	m[a[i]]++;
    	b[i] = a[i];
	}
	sort(a,a+n);
	ll one = a[0];
	ll two = a[0];
	for(i=0;i<n;i++){
    	if(a[i]>one){
    		two = one;
    		one = a[i];
		}
	}
	if(m[one] > 1){
		for(i=0;i<n;i++) cout<<one<<endl;
	}else{
	for(i=0;i<n;i++){
    	if(b[i] == one) cout<<two<<endl;
    	else cout<<one<<endl;
	  }
    }
	
 }

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

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

int ar[11];

int main()
{
    int t;
    for(int ctr1=0;ctr1<3;ctr1++)
        cin>>t,ar[t]++;
    if(ar[5]==2 && ar[7]==1)
        cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

// abc100d

int main() {
  int n,m; cin >> n >> m;
  vll x(n), y(n), z(n);
  rep(i,n) cin >> x[i] >> y[i] >> z[i];
  ll ans =0;
  rep(i, 2) {
    rep(j, 2) {
      rep(k, 2) {
        vll a(n);
        rep(l,n) {
          a[l] += i==0?x[l]:-x[l];
          a[l] += j==0?y[l]:-y[l];
          a[l] += k==0?z[l]:-z[l];
        }
        sort(a.rbegin(), a.rend());
        ll num = 0;
        rep(l,m) num+=a[l];
        chmax(ans, num);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

//sum_{c_i ... n} c[i]x[i] = ans (sum_{c_i ... n} x[i] == max) となるxを返す
vector<int> Solve(const vector<int> &c, int c_i, int max, int ans) {
	if (c_i > (int)c.size()) return{};
	if (c_i == c.size()-1) {
		if (ans % c[c_i] == 0 && ans/c[c_i]==max) return { max };
		else return{};
	}

	int i_first = (ans - c[c_i + 1] * max) / (c[c_i] - c[c_i + 1]);
	i_first = i_first > 0 ? i_first : 0;
	int i_end = ans / c[c_i];
	i_end = i_end < max ? i_end : max;
	ans -= c[c_i] * i_end;

	for (int i = i_end; i >= i_first; i--) {
		vector<int> sols = Solve(c, c_i + 1, max - i, ans);
		if (!sols.empty()) {
			sols.insert(sols.begin(), i);
			return sols;
		}
		ans += c[c_i];
	}
	return {};
}

int main() {
	int N, Y;
	cin >> N >> Y;
	vector<int> solution = Solve({ 10000,5000,1000 }, 0, N, Y);
	if (!solution.empty()) {
		for (int i = 0; i < 3; i++) {
			cout << solution[i] << " ";
		}
	}
	else {
		cout << "-1 -1 -1";
	}

}

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

#include <cassert>
using namespace std;

const int MOD = 1e9 + 7;

inline void ModMul(int& x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int GetModMul(int x, int y) {
    ModMul(x, y);
    return x;
}

inline void ModSum(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
    if (x < 0) {
        x += MOD;
    }
}

inline int GetModSum(int x, int y) {
    ModSum(x, y);
    return x;
}

vector<int> GetZ(const string& s) {
    const int n = s.length();
    vector<int> z(n);
    z[0] = 0;
    for (int i = 1, l = -1, r = -1; i < n; ++i) {
        if (i <= r) {
            z[i] = min(z[i - l], r - i + 1);
        } else {
            z[i] = 0;
        }
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
            ++z[i];
        }
        if (i + z[i] - 1 > r) {
            l = i;
            r = i + z[i] - 1;
        }
    }
    return z;
}

bool IsGoodString(const string& s) {
    const int n = s.length();
    if (n == 1) {
        return true;
    }
    vector<int> z = GetZ(s);
    for (int i = 1; i < n; ++i) {
        if (z[i] == n - i && (n % i == 0)) {
            return false;
        }
    }
    return true;
}

vector<bool> BuildGoodPrefix(const string& s) {
    const int n = s.length();
    vector<int> z = GetZ(s);
    vector<bool> result(n, true);

    for (int d = 1; d < n; ++d) {
        for (int k = 2 * d; k <= n; k += d) {
            if (z[d] >= k - d) {
                result[k - 1] = false;
            }
        }
    }

    return result;
}

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

    const int n = s.length();

    {
        bool ok = true;
        for (int i = 1; i < n; ++i) {
            if (s[i] != s[i - 1]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << n << endl << 1 << endl;
            return 0;
        }
    }

    if (IsGoodString(s)) {
        cout << 1 << endl << 1 << endl;
        return 0;
    }

    string rs = s;
    reverse(rs.begin(), rs.end());

    vector<bool> goodPrefix = BuildGoodPrefix(s);

    vector<bool> goodSuffix = BuildGoodPrefix(rs);
    reverse(goodSuffix.begin(), goodSuffix.end());

    int count = 0;
    for (int i = 0; i + 1 < n; ++i) {
        if (goodPrefix[i] && goodSuffix[i + 1]) {
            ++count;
        }
    }

    if (count > 0) {
        cout << 2 << endl << count << endl;
        return 0;
    }

    assert(false);

    return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){

    int N;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    int g = A[0];
    for(int i = 1; i < N; i++){
        g = gcd(g, A[i]);
    }
    cout << g << endl;

    return 0;
}


Measured memory_bytes: 640
#coding:utf-8
import math
A = [0] * 5
B = [0] * 5
for i in range(len(A)):
    A[i] = int(input())
    B[i] = ((A[i] - 1) % 10) + 1
    A[i] = math.ceil(A[i]/10)*10
min_b = min(B)
print(sum(A)-10+min_b)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  map<ll, ll> mp;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  mp[A[0]]++, mp[0]++;
  for(int i = 1; i < N; i++){
    A[i] += A[i - 1];
    mp[A[i]]++;
  }

  ll ans = 0;
  for(auto itr : mp){
    ans += itr.second * (itr.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int adj_mat[700][700];
bool used[700];
int grouping[700];
int dfs_pair[2];
bool dp[700][701];

bool dfs(int cur, int mod, int N){
  used[cur] = true;
  grouping[cur] = mod;
  dfs_pair[mod] ++;
  for(int i = 0; i < N; i++){
    if(adj_mat[cur][i] == 1 && used[i] && grouping[i] == mod){
      return false;
    }
    if(adj_mat[cur][i] == 1 && !used[i]){
      if(!dfs(i, (mod + 1) % 2, N)){
        return false;
      }
    }
  }
  return true;
}

int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i ++){
      for(int j = 0; j  <N; j++){
        if(i == j){
          continue;
        }
        adj_mat[i][j] = 1;
      }
    }

    for(int i = 0; i < M; i++){
      int A;
      int B;
      cin >> A >> B;
      adj_mat[A - 1][B - 1] = 0;
      adj_mat[B - 1][A - 1] = 0;
    }

    vector <pair <int, int> > bip_pairs;
    for(int i = 0; i < N; i++){
      if(!used[i]){
        dfs_pair[0] = 0;
        dfs_pair[1] = 0;
        if(dfs(i, 0, N)){
          bip_pairs.push_back(make_pair(dfs_pair[0], dfs_pair[1]));
        } else {
          cout << - 1 << endl;
          return 0;
        }
      }
    }

    dp[0][bip_pairs[0].first] = true;
    dp[0][bip_pairs[0].second] = true;
    for(int i = 1; i < bip_pairs.size(); i++){
      for(int j = 0; j <= N; j++){
        if(j - bip_pairs[i].first >= 0){
          dp[i][j] = dp[i - 1][j - bip_pairs[i].first] || dp[i][j];
        }
        if(j - bip_pairs[i].second >= 0){
          dp[i][j] = dp[i - 1][j - bip_pairs[i].second] || dp[i][j];
        }
      }
    }
    int ans = INT_MAX;
    for(int i = 1; i < N; i++){
      if(dp[bip_pairs.size() - 1][i]){
        ans = min(ans, (i * (i - 1)) / 2 +  ((N - i) * (N - i - 1)) / 2);
      }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    vector<vector<int>> v(H, vector<int>(W));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < W; j++){
            v[i][j] = 1;
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < w; j++){
            v[i][j] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(v[i][j] == 0) ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    if (500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long p[110000];

int main(){
	int a;scanf("%d",&a);
	// long long cur=0;
	for(int i=0;i<a;i++){
		scanf("%lld",p+i);
	}

	init_C(110000);
	long long ret=0;

	for(int i=1;i<=a-1;i++){
		ret=(ret+(p[a-1]-p[i-1])*inv[i])%mod;
	}
	ret=ret*fact[a-1]%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 5888
s=input()
t=list(map(int,input().split()))
u=list(map(int,input().split()))
v=list(map(int,input().split()))
a=len(t)
b=len(u)
d=0
for i in range(b):
  d=d+u[i]
for j in range(a-1):
  if t[j]+1==t[j+1]:
    e=t[j]-1
    d=d+v[e]
print(d)

Measured memory_bytes: 3064
s=str(input())
n=len(s)-1#間間なので-1
#print(s,n)
#print(xy)
bit=[]#1が＋入れる0がいれない
ans=0
c=0
count=[]
def bit_search(bit):
    #print("DFGHNM")
    count=[]#分けたやつを補完するやつ
    global ans
    c=0
    if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif
        for i in range(n):
            if bit[i]==1:
                #print(int(s[c:i+1]))
                count.append(int(s[c:i+1]))
                c=i+1#ここの＋１大事
        #print(int(s[c:n+1]))
        count.append(int(s[c:n+1]))
        ans+=sum(count)
        #print(ans,sum(count),bit,c)
        return 
    else:
       #再起化することによって最初にbitの配列を作る必要性をなくした
        #print(bit)
        bit_search(bit+[0])
        bit_search(bit+[1])

bit_search(bit)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] chars={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        String s=sc.next();
        for(int i=0;i<26;i++){
            if(s.length()-s.replaceAll(chars[i],"").length()==0){
                System.out.println(chars[i]);
                return;
            }
        }
        System.out.println("None");
    }
 
    
}

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

int main() {
  long int N , rootN;//ここでのroot Nは小数点以下切り上げ
  cin >> N;
  for(long int i=1; i<=N; i++) {
    if(i*i >= N) {
      rootN = i;
      break;
    }
  }
  //cout << rootN <<endl;
  long int big , answer , n10;
  n10 = 10;
  for(long int i=rootN; i>0; i--) {
    if(N % i == 0) {
      big = N / i;
      break;
    }
  }
  for(int i=0; i<10; i++) {
    if(big < n10) {
      answer = i+1;
      break;
    }
    n10 = n10 * 10;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int left_length,right_length,max,tmp,left_start,left_end,right_start,right_end,k;
	char left[4001],right[4001];

	while(scanf("%s",left) != EOF){
		scanf("%s",right);

		for(left_length = 0;left[left_length] != '\0';left_length++);
		for(right_length = 0; right[right_length] != '\0';right_length++);

		max = 0;
		if(right_length > left_length){

			//left???????????¨right???????????????????????§
			for(right_end = 1;right_end <= left_length;right_end++){
				tmp = 0;
				for(left_start = left_length-right_end,k=0; k < right_end; k++){
					if(left[left_start+k] == right[k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//left???????????¨right???????????????????????§
			for(right_end = left_length;right_end < right_length;right_end++){
				tmp = 0;
				for(right_start = right_end-left_length,k=0;right_start + k < right_end; k++){
					if(left[k] == right[right_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//left_end???0??????????????§
			for(left_end = left_length-1;left_end >= 1; left_end--){
				tmp = 0;
				for(right_start = right_length-left_end,k=0;k < left_end; k++){
					if(left[k] == right[right_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			printf("%d\n",max);

		}else{

			//right???????????¨left???????????????????????§
			for(left_end = 1;left_end <= right_length;left_end++){
				tmp = 0;
				for(right_start = right_length-left_end,k=0; k < left_end; k++){
					if(right[right_start+k] == left[k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//right???????????¨left???????????????????????§
			for(left_end = right_length;left_end < left_length;left_end++){
				tmp = 0;
				for(left_start = left_end-right_length,k=0;left_start + k < left_end; k++){
					if(right[k] == left[left_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			//right_end???0??????????????§
			for(right_end = right_length-1;right_end >= 1; right_end--){
				tmp = 0;
				for(left_start = left_length-right_end,k=0;left_start + k < left_length; k++){
					if(right[k] == left[left_start+k]){
						tmp++;
						max = (max >= tmp)?max:tmp;
					}else{
						tmp = 0;
					}
				}
			}

			printf("%d\n",max);
		}
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

vector<bool> isp;
vector<ll> prime;

void sieve(int x=pow(10,6)+10) {
  isp.resize(x,true); 
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=x; i++) {
    if (isp[i]) for(int j=2; i*j<=x; j++) isp[i*j] = false;
  }
  rep(i,x+1) if (isp[i]) prime.push_back(i);
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  sieve();
  int N; cin >> N;
  int tn = N%2==0 ? N+1 : N;
  ll result[tn][tn] = {}; rep(i,tn) fill_n(result[i],tn,1);
  rep(i,tn) rep(j,tn) if ((i+j)%2==0) result[i][j] = prime[(i+j)/2] * prime[tn+((tn-1-i)+j)/2];
  rep(i,tn) rep(j,tn) {
    if ((i+j)%2==1) {
      if (i!=0)    result[i][j] = lcm(result[i][j], result[i-1][j]);
      if (i!=tn-1) result[i][j] = lcm(result[i][j], result[i+1][j]);
      if (j!=0)    result[i][j] = lcm(result[i][j], result[i][j-1]);
      if (j!=tn-1) result[i][j] = lcm(result[i][j], result[i][j+1]);
      result[i][j]++;
    }
  }
  // ll r = 0; rep(i,N) rep(j,N) r = max(r, result[i][j]);
  // cout << r << endl;
  rep(i,N) debug(result[i],result[i]+N);
  return 0;
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll n = len(s);
    vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
    dp[0][0] = 1;
    rep(i, n) {
        if (s[i] == '0') {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = (dp[i][1] * 3) % mod;
        }
        else {
            dp[i + 1][0] = (dp[i][0] * 2) % mod;
            dp[i + 1][1] = (dp[i][0] + dp[i][1] * 3) % mod;
        }
    }
    cout << ((dp[n][0] + dp[n][1]) % mod) << endl;
    return 0;
}


Measured memory_bytes: 5840
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}

class UnionFind {
	vector<int> par;
public:
	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }
	lint root(int x) {//根を出す
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}
	bool same(int x, int y) {//同じ集合なのかを調べる
		return root(x) == root(y);
	}
	bool unite(int x, int y) {//xの根とyの根をつなげる
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};

int main(void) {
	speed();
	int n, m; cin >> n >> m;
	UnionFind d(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		d.unite(a, b);
	}
	vector<int> cnt(n);
	for (int i = 0; i < n; i++) {
		cnt[d.root(i)]++;
	}
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		if (cnt[i] != 0) ans++;
	}
	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 3992
// 2_abc133_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#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 SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int> (d));

    rep(i, n){
        rep(j, d){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            double dist = 0;
            for(int k = 0; k < d; k++){
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            dist = sqrt(dist);
            if(ceil(dist) == floor(dist)) ans++;
        }
    }

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


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    long k = nl();
    long[] a = nal(n);

    long[] b = new long[60];
    int[] cnt = new int[60];
    for (int j = 0; j < 60; j ++) {
      for (int i = 0; i < n; i++) {
        if (((a[i] >> j) & 1) != 0) {
          cnt[j]++;
        }
      }
      b[j] = Math.max(cnt[j], n - cnt[j]) * (1L << j);
    }
    for (int i = 1; i < 60; i ++) {
      b[i] += b[i - 1];
    }

    long ret = 0;
    long now = 0;
    for (int j = 55; j >= 0; j--) {
      if (((k >> j) & 1) != 0) {
        ret = Math.max(ret, now + cnt[j] * (1L << j) + (j > 0 ? b[j - 1] : 0));
      }
      now += (((k >> j) & 1) == 0 ? cnt[j] : n - cnt[j]) * (1L << j);
    }
    ret = Math.max(ret, now);
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 49820
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	ll n, m;
	cin >> n >> m;
	cout << (100 * n + 1800 * m)*(ll)pow(2, m) << endl;
}

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

const int MOD = 924844033;
const int N = 2001;

void update(int &x, int a) {
  x += a;
  if (x >= MOD) {
    x -= MOD;
  }
}

int fact[N], pack[N], ways[2][N], dp[2][1 << 3][N];

void prepare(int n, int ways[]) {
  memset(dp, 0, sizeof(dp));
  dp[0][4][0] = 1;
  for (int i = 0; i < n; ++i) {
    memset(dp[i + 1 & 1], 0, sizeof(dp[i + 1 & 1]));
    for (int pre_msk = 0; pre_msk < 1 << 3; ++pre_msk) {
      int msk = pre_msk >> 1;
      if (i + 1 < n) {
        msk |= 4;
      }
      for (int j = 0; j <= i; ++j) {
        int v = dp[i & 1][pre_msk][j];
        update(dp[i + 1 & 1][msk][j], v);
        if (msk & 1) {
          update(dp[i + 1 & 1][msk ^ 1][j + 1], v);
        }
        if (msk & 4) {
          update(dp[i + 1 & 1][msk ^ 4][j + 1], v);
        }
      }
    }
  }
  memset(ways, 0, sizeof(*ways) * (n + 1));
  for (int msk = 0; msk < 1 << 3; ++msk) {
    for (int j = 0; j <= n; ++j) {
      update(ways[j], dp[n & 1][msk][j]);
    }
  }
}

int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) == 2) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) {
      fact[i] = 1LL * fact[i - 1] * i % MOD;
    }
    int base = (n - 1) / k;
    prepare(base, ways[0]);
    prepare(base + 1, ways[1]);
    memset(pack, 0, sizeof(pack));
    pack[0] = 1;
    for (int r = 0; r < k && r < n; ++r) {
      int cnt = (n - r - 1) / k + 1;
      for (int i = n; i >= 0; --i) {
        int sum = 0;
        for (int j = 0; j <= i && j <= cnt; ++j) {
          update(sum, 1LL * ways[cnt - base][j] * pack[i - j] % MOD);
        }
        pack[i] = sum;
      }
    }
    int result = 0;
    for (int i = 0; i <= n; ++i) {
      int sum = 1LL * pack[i] * fact[n - i] % MOD;
      if (i & 1) {
        sum = MOD - sum;
      }
      update(result, sum);
    }
    printf("%d\n", result);
  }
}


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

const int maxn = 1e5 + 10, P = 1e9 + 7;
int n, dp[2][maxn]; vector <int> g[maxn];

//void dfs(int u, int f) {
//	bool flg = 0;
//	for (int v : g[u]) {
//		if (v != f) {
//			flg = 1, dfs(v, u);
//			dp[1][u] = (dp[1][u] + dp[0][v]) % P;
//			dp[0][u] = (dp[0][u] + (dp[0][v] + dp[1][v]) % P) % P;
//		}
//	}
//	if (!flg) dp[0][u] = dp[1][u] = 1;
//}

void dfs(int u, int f) {
	dp[0][u] = dp[1][u] = 1;
	for (int v : g[u]) {
		if (v != f) {
			dfs(v, u);
			dp[1][u] = 1ll * dp[1][u] * dp[0][v] % P;
			dp[0][u] = 1ll * dp[0][u] * (dp[0][v] + dp[1][v]) % P;
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d %d", &u, &v);
		g[u].push_back(v), g[v].push_back(u);
	}
	dfs(1, 0), printf("%d", (dp[0][1] + dp[1][1]) % P);
	return 0;
}

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

typedef long long ll;

#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define MOD 1000000007
#define pb push_back
#define vll vector<ll>
#define FOR(i,n) for(int i{0}; i < n; ++i)

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n < 1000) {
	  cout << 1000 - n << '\n';
  }
  else {
	  if ( n % 1000 == 0) {
		  cout << 0 << '\n';
	  }
	  else {
	  	cout << 1000 - (n % 1000) << '\n';
	  }
  }
  return 0;
}


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

using namespace std;

int main(void){

    int n,m;
    cin >> n >> m;
    
    vector<int> counts(n);
    for(int i=0; i<n; i++) counts[i] = 0;
    
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        counts[a-1]++;
        counts[b-1]++;
    }
    
    for(int i=0; i<n; i++) {
        cout << counts[i] << endl;
    }

    return 0;
    
}


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

void main_()
{
    string s;
    cin >> s;

    auto ans = numeric_limits<size_t>::max();
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        string ss = s;
        size_t i;
        for (i = 0; i < s.size() && ss.find_first_not_of(ch) != string::npos; ++i) {
            string next_s;
            adjacent_difference(
                begin(ss), end(ss), back_inserter(next_s),
                [ch](char a, char b) { return a == ch || b == ch ? ch : a; });
            ss = next_s.substr(1);
        }
        ans = min(i, ans);
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=18;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    multiset<int,greater<int>> s;
    for(int i=1;i<=1<<n;i++)
    {
        int x;
        cin>>x;
        s.insert(x);
    }
    multiset<int,greater<int>> cur{*s.begin()};
    s.erase(s.begin());
    while(n--)
    {
        multiset<int,greater<int>> nxt=cur;
        for(auto it=s.begin();it!=s.end()&&!cur.empty();)
            if(*it<*cur.begin())
            {
                nxt.insert(*it);
                s.erase(it++);
                cur.erase(cur.begin());
            }
            else
                it++;
        if(!cur.empty())
            cout<<"No",exit(0);
        cur=nxt;
    }
    cout<<"Yes";
}


Measured memory_bytes: 24832
n=int(input())
a=list(map(lambda x:int(x)-1,input().split()))

cnt=0
lis=set()
for i in range(n-1):
    if i in lis:
        continue
    if a[i]==i and a[i+1]==i+1:
        cnt+=1
        lis.add(i+1)
    elif a[i]==i:
        cnt+=1
if n-1 not in lis and a[n-1]==n-1:
    cnt+=1
print(cnt)

Measured memory_bytes: 14004