akhauriyash/Code-Regression huggingface dataset:
// Abhishek Chaturvedi- abhishekchaturvedi10oct //

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define inf             2e18+1
#define ninf            -2e18+1
#define mod             1000000007
#define eps             1e-9
#define ff              first
#define ss              second
#define int             long long 
#define ld              long double
#define str             string 
#define pb              emplace_back
#define mp              make_pair
#define vi              vector<int>
#define si              set<int>
#define pii             pair<int,int>
#define psi             pair<str,int>
#define mii             map<int,int>
#define msi             map<str,int>
#define vvi             vector<vector<int>>
#define maxheap         priority_queue<int>
#define minheap         priority_queue<int,vi,greater<int>>
#define sz(x)           (int)x.size()
#define all(x)          x.begin(),x.end()
#define allr(x)         x.rbegin(),x.rend()
#define gcd(x,y)        __gcd(x, y)
#define arrsz(x)        sizeof(x)/sizeof(x[0])
#define sp(x,y)         fixed<<setprecision(y)<<x
#define tc(x)           int x; cin>>x; while(x--)
#define loopf(i,x,y)    for(int i=x;i<=y;i++)
#define loopb(i,x,y)    for(int i=x;i>=y;i--)
#define in(x,n)         int x[n];loopf(i,0,n-1) cin>>x[i];
#define out(x)          for(auto i:x) cout<<i<<" "; cout<<endl;
#define init(x,n,y)     int x[n];loopf(i,0,n-1) x[i]=y;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool isPowerOfTwo(int x){
   return x&&(!(x&(x-1)));
}

int takemod(int x){ 
    return (x%mod + mod) % mod; 
}

int lcm(int x,int y) {
    return (x/gcd(x,y)) * y;
}

int fpow(int base,int power,int MOD) {
    int result = 1;
    base=base%MOD;
    while(power){
        if(power&1) 
            result = (result*base) % MOD;
        base = (base*base) % MOD;
        power = power>>1;
    }
    return result;
}

int modinv(int x){return fpow(x,mod-2,mod);}

void fastIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve(){
    int x,n; cin>>x>>n; int ans; mii m;
    loopf(i,0,n-1){
        int y; cin>>y;
        m[y]++;
    }
    int xx=x;
    while(m[xx]!=0) xx++;
    ans=xx;
    if(ans==x) {cout<<x; return;}
    xx=x-1;
    while(m[xx]!=0) {xx--; if(ans-x<x-xx) break;}
    if(m[xx]==0&&x-xx<=ans-x) ans=xx;
    cout<<ans;
}

int32_t main(){
    
    fastIO();
    
    //tc(t){ 
       solve();  
    //}
    
    return 0;
}


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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var pq = new int[h[1]].Select(_ => Read()).ToArray();
		var rs = new int[h[2]].Select(_ => Read()).ToArray();

		var uf1 = new UF(n);
		var uf2 = new UF(n);
		foreach (var x in pq) uf1.Unite(x[0], x[1]);
		foreach (var x in rs) uf2.Unite(x[0], x[1]);

		var q = Enumerable.Range(1, n).Select(i => (i, g: (uf1.GetRoot(i), uf2.GetRoot(i)))).GroupBy(x => x.g).Select(g => g.ToArray()).SelectMany(g => g.Select(x => (x.i, c: g.Length))).OrderBy(x => x.i).Select(x => x.c);
		Console.WriteLine(string.Join(" ", q));
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n + 1).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
	public int[][] ToGroups() => Enumerable.Range(0, p.Length).GroupBy(GetRoot).Select(g => g.ToArray()).ToArray();
}


Measured memory_bytes: 93388
n=int(input())
a=[0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
b=[0,1,1,0,1,0,0,1,1,0,0,1,0,1,1]
print(60*(n//15)+120*(n//15)*(n//15-1)//2+sum(b[:n%15+1])*(15*(n//15))+a[n%15])

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a+d-1)/d<(b+c-1)/b){ cout<< "No"<<"\n";}
	else { cout<<"Yes"<<"\n"; }
	return 0;
}

Measured memory_bytes: 3636
A = int(input())
B = int(input())

if (A==1 and B==2) or (A==2 and B==1) :
    print(3)
if (A==1 and B==3) or (A==3 and B==1) :
    print(2)
if (A==3 and B==2) or (A==2 and B==3) :
    print(1)


Measured memory_bytes: 38256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = getInt()
	}
	sort.Ints(l)
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			a := l[i]
			b := l[j]
			x := lowerBound(l, a+b)
			ans += x - (j + 1)
		}
	}
	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int h,w;
    cin>> h >> w;
    vector<bool>ok_h(200);
    vector<bool>ok_w(200);
    vector<string> a(h);
    rep(i,h){
        cin >> a[i];
    }
      

    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#'){
                ok_h[i] = true;
                ok_w[j] = true;
            }
        }
    }
    rep(i,h){
        if(ok_h[i]){
        rep(j,w){
           if(ok_w[j]) cout << a[i][j];
        }
        cout << endl;
    }
}
return 0;
}

Measured memory_bytes: 256
m = gets.chomp.to_i
n = gets.chomp.to_i

$g = {}

$has_prev = []
$all = (1..m).to_a
$reverse = {}

n.times do
  s, t = gets.chomp.split(' ').map(&:to_i)
  $g[s] ||= []
  $g[s] << t
  $has_prev << t

  $reverse[t] ||= []
  $reverse[t] << s
end

$free = $all - $has_prev

$res = []

until $free.empty?
  current = $free.pop
  $res << current

  next unless $g[current]

  $g[current].each do |p|
    $reverse[p].delete(current)
    $free << p if $reverse[p].empty?
  end
end

puts $res



Measured memory_bytes: 8928
#include<iostream>
using namespace std;
#define INF (1 << 30)

int main() {
	int n;
	cin >> n;
	int h[n], dp[n];
	for (int i=0; i<n; i++) {
		cin >> h[i];
		dp[i] = INF;
	}

	dp[0] = 0;
	for (int i = 0; i < n; i++) {
			dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]- h[i]));
			dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]- h[i]));
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N;
    cin >> N;
    string a = "", b = "";
    char c;
    rep(i, N){
        cin >> c;
        a += c;
    }
    rep(i, N){
        cin >> c;
        b += c;
    }
    if(a > b)swap(a, b);
    ll ans = 0;
    for(;a != b;ans++)next_permutation(a.begin(), a.end());
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	deque<char> ss(s.begin(), s.end());

	int q;
	cin >> q;

	int t, f;
	char c;
	int beg = 0;
	while (q--) {
		cin >> t;
		if (t == 1) {
			beg ^= 1;
		} else {	
			cin >> f >> c;
			if (beg == 1) {
				if (f == 1) {
					f = 2;
				} else {
					f = 1;
				}
			}

			if (f == 1) {
				ss.push_front(c);
			} else {
				ss.push_back(c);
			}
		}
	}

	if (beg) {
		reverse(ss.begin(), ss.end());
	}

	for (int i = 0; i < (int) ss.size(); ++i) {
		cout << ss[i];
	}

	cout << "\n";

	return 0;

}

Measured memory_bytes: 976
#!/usr/bin/env ruby

# time, x, y

plans = []

gets.to_i.times do
  t, x, y = gets.split
  plans << [t.to_i, x.to_i, y.to_i]
end

def is_reachable(t, dist_x, dist_y)
  rest_time = t - (dist_x + dist_y)
  return false if rest_time < 0
  return false if rest_time % 2 != 0
  return true
end

pos = [0, 0]
now = 0

res = true

plans.each do |plan|
  dist_t = plan[0] - now
  dist_x = (pos[0] - plan[1]).abs
  dist_y = (pos[1] - plan[2]).abs

  unless is_reachable(dist_t, dist_x, dist_y) then
    res = false
    break
  end

  now = plan[0]
  pos = [plan[1], plan[2]]
end

puts res ? "Yes" : "No"


Measured memory_bytes: 9596
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    string S;
    cin >> N >> S;
    int cnt = 0;
    rep(i, N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<char>> d(h,vector<char>(w));
  rep(i,h)rep(j,w) cin >> d.at(i).at(j);
  int ans = 0;
  for(ll tmp = 0; tmp < (1 << (h+w)); tmp++){
  vector<vector<char>> c = d;
    bitset<36> a(tmp);
    rep(i,h){
      if(a.test(0)){
        rep(j,w) c.at(i).at(j) = '@';
      }
      a >>= 1;
    }
    rep(i,w){
      if(a.test(0)){
        rep(j,h) c.at(j).at(i) = '@';
      }
      a >>= 1;
    }
    
    int cnt = 0;
    rep(i,h)rep(j,w)if(c.at(i).at(j) == '#') cnt++;
    if(cnt == k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}

vector<int> sosu(0);
bool sosuu[100001]={false};
void erast(){
  REP(i,100001)sosuu[i] = true;
  for(int i=2;i<=100000;i++){
    if(sosuu[i]){
      sosu.push_back(i);
      for(int j=i;j<=100000;j+=i){
        sosuu[j] = false;
      }
    }
  }
  return;
}
vector<ll> v(0);
void solve(ll N,ll n,bool s,bool f,bool t){
  if(N == 10){
    return;
  }else{
    if(s && f && t){
      v.push_back(n);
    }
    solve(N+1,n*10+7,true,f,t);
    solve(N+1,n*10+5,s,true,t);
    solve(N+1,n*10+3,s,f,true);
  }
}

int main()
{
  int N;
  cin >> N;
  solve(0,0,false,false,false);
  sort(v.begin(),v.end());
  cout << (upper_bound(v.begin(),v.end(),N)- v.begin()) << endl;
  return 0;
}



Measured memory_bytes: 640
n = int(input())
p_ls = list(map(int, input().split()))
count = 0
for i in range(n-2):
    p1 = p_ls[i]
    p2 = p_ls[i+1]
    p3 = p_ls[i+2]
    if (p1 < p2 and p2 < p3) or (p1 > p2 and p2 > p3):
        count = count + 1
print(count)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var K = LnInt();
        var _ = LnInts();
        var A = _[0];
        var B = _[1];
        for(int i = A; i <= B; i++)
        {
            if (i % K == 0) { print("OK"); return; }
        }
        print("NG");
    }



    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}

Measured memory_bytes: 27488
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    int k, sup = 0;
    cin >> k;
    rep(i, k) {
        int b;
        cin >> b;
        sup |= 1 << b;
    }
    vector<int> ans;
    int sub = sup;
    do {
        ans.pb(sub);
        sub = (sub - 1) & sup;
    } while (sub != sup);
    reverse(all(ans));
    rep(i, sz(ans)) {
        cout << ans[i] << ":";
        rep(j, n) if (ans[i] >> j & 1) cout << " " << j;
        cout << endl;
    }
}



Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;;
	cin>>n;
	if(n<=999){
		cout<<"ABC"<<endl;
	}else{
		cout<<"ABD"<<endl;
	}

	return 0;
}


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

using namespace std;

inline int read() {
  int f = 1;
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    f = (ch == '-') ? -1 : 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}

const int N = 2e5 + 5;

map <long long, int> s;

int main() {
  int n = read();
  long long ans = 0;
  long long nw = 0;
  for (int i = 1; i <= n; ++i) {
    nw += read();
    ans += s[nw];
    ans += nw == 0;
    ++s[nw];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(0, n):
    a.append(A[i] + a[i])
for i in range(0, m):
    b.append(B[i] + b[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k-a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 47612
#include <stdio.h>
int main(){
    int N, K, d[101], A[101][101], sunuke[101] = {0}, ans = 0;

    scanf("%d %d\n", &N, &K);
    for( int i = 0; i < K; i++ ){
        scanf("%d\n", &d[i]);
        for( int j = 0; j < d[i]; j++ ){
            scanf("%d ", &A[i][j]);
            for( int k = 0; k < N; k++ ){
                if( A[i][j] == k+1  ){
                    sunuke[k]++;
                }
            }
        }
    }
    for( int l = 0; l < N; l++ ){
        if( sunuke[l] == 0 ){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(rng(A));
  vector<int>b(1000001,true);
  int ans=0;
  for(int i=0;i<N;i++){
    if(!b[A[i]])continue;
    if(i+1<N&&A[i]==A[i+1])for(int j=A[i];j<=1000000;j+=A[i])b[j]=false;
    if(b[A[i]]){
      ans++;
      for(int j=A[i];j<=1000000;j+=A[i])b[j]=false;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12668
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    int64_t res = 0;
    for(int i=0; i<s.size()/2; i++){
        if(s.at(i) != s.at(s.size()-1-i)){
            res++;
        }
    }
    cout << res << endl;
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var K_S = Console.ReadLine().Split(' ').Select(x => int.Parse(x.ToString())).ToArray();
            var K = K_S[0];
            var S = K_S[1];
            int counter = 0;
            for (int X = 0; X <= K; X++)
            {
                for (int Y = 0; Y <= K; Y++)
                {
                    var Z = S - X - Y;
                    if (0 <= Z && Z <= K)
                    {
                        counter++;
                    }
                }
            }

            Console.WriteLine(counter);


            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <array>
#include <vector>
#include <utility>
#include <limits>

constexpr int MAX_A = 1'000'000;
std::array<int, MAX_A + 1> minPrime;

int main(void){
    std::fill(minPrime.begin(), minPrime.end(), std::numeric_limits<int>::max());
    minPrime[0] = 1; minPrime[1] = 1;
    for(int p = 2; p <= MAX_A; ++p) if(minPrime[p] == std::numeric_limits<int>::max()){
        minPrime[p] = p; for(int q = 2 * p; q <= MAX_A; q += p) if(minPrime[q] == std::numeric_limits<int>::max()) minPrime[q] = p;
    }
  
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    int n; std::cin >> n;
    std::vector<int> A(n); for(auto& itr : A) std::cin >> itr;
  
    // all GCD 
    for(int p = 2; p <= MAX_A and p <= A[0]; ++p) if(minPrime[p] == p and A[0] % p == 0){
        bool dividable = true;
        for(int j = 1; j < n; ++j) if(A[j] % p != 0){ dividable = false; break; }
        if(dividable){ std::cout << "not coprime\n"; return 0; }
    }
    std::array<bool, MAX_A + 1> Found; std::fill(Found.begin(), Found.end(), false);
    for(int i = 0; i < n; ++i){
        int a = A[i]; 
        while(a > 1){
            if(Found[minPrime[a]]){ std::cout << "setwise coprime\n"; return 0; }
             a /= minPrime[a];
        }
        a = A[i]; while(a > 1){ Found[minPrime[a]] = true; a /= minPrime[a]; }
    }
    std::cout << "pairwise coprime\n";
    return 0;
}


Measured memory_bytes: 11868
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		if(A > B) {
			ans += A;
			A--;
			if(A > B) {
				ans += A;
			} else {
				ans += B;
			}
		} else {
			ans += B;
			B--;
			if(A > B) {
				ans += A;
			} else {
				ans += B;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
int main() {
	int k = 0;
	int a, b, c;
	int x, y;
	std::cin >> a >> b >> c >> x >> y;
	k+=std::min(c, std::min(a, b));
	k += std::min(x, y);
	std::cout << k - 50 << std::endl;
}

Measured memory_bytes: 3072
fun main(args: Array<String>) {
    val 行数 = readLine()!!.toInt()
    val riList = mutableListOf<Double>()

    repeat((0 until 行数).count()) {
        riList.add(readLine()!!.toDouble())
    }
    var minv = riList[0]
    var maxv = Math.pow(10.0, 9.0) * -1.0
    for( j in 1 until 行数) {
        maxv = Math.max(maxv, riList[j] - minv)
        minv = Math.min(minv, riList[j])
    }
    println(maxv.toInt())
}


Measured memory_bytes: 69052
import java.util.Scanner;
public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 35964
from collections import Counter
n = int(input())
lst = list(map(int, input().split()))
mclst = Counter(lst).most_common()
sqlst = []
rclst = []
for tpl in mclst:
  if tpl[1] >= 2:
    rclst.append(tpl[0])
  if tpl[1] >= 4:
    sqlst.append(tpl[0])
sqmax, rcmax = 0, 0
if len(sqlst) >= 1:
  sqmax = max(sqlst) ** 2
if len(rclst) >= 2:
  rclst.sort(reverse=True)
  rcmax = rclst[0] * rclst[1]
print(max(sqmax, rcmax))

Measured memory_bytes: 26212
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s,t = 0,0
for i in range(n):
    if a[i]>b[i]:
        s+=a[i]-b[i]
    else:
        t+=(b[i]-a[i])//2+(b[i]-a[i])%2
        s += (b[i] - a[i])%2
if s<=t:
    print('Yes')
else:
    print('No')


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

int const siz=305;
double dp[siz][siz][siz];
int n;

double F(int x,int y,int z) {
    if (x<0 || y<0 || z<0)
        return 0.0; //wont happen so p=0 
    if (x==0 && y==0 && z==0)
        return 0.0; //no need to perform any move
    if (dp[x][y][z]>=-0.5)
        return dp[x][y][z];
    dp[x][y][z]= (1.0/(1.0*(x+y+z)))* (n+x*F(x-1,y,z)+y*F(x+1,y-1,z)+z*F(x,y+1,z-1));
    return dp[x][y][z];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    int a,b,c; cin>>n; a=b=c=0;
    for (int i=0;i<n;i++) {
        int r; cin>>r;
        if (r==1) a++;
        else if (r==2) b++;
        else c++;
    }
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<F(a,b,c);
    return 0;
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
//#define DEBUG
#define REP( i , nn ) for(int i = 0 ; i < (int) nn; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    int n;
    cin >> n;
    int current = 1;
    int ans = 0;
    for(int i = 0 ; i< n; i++){
        int a;
        cin >> a;
        if( a == current){
            current++;
        }else{
            ans++;
        }
    }
    if( current > 1){
        cout << ans << "\n";
    }else{
        cout << "-1\n";
    }
    
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    int K =sc.nextInt();
    int P[]=new int[N];
    for(int i=0;i<N;i++){
      P[i]=sc.nextInt();}
    Arrays.sort(P);
    int ans =0;
    for(int j=0;j<K;j++){
      ans =ans +P[j];}
    System.out.println(ans);
  }
}

Measured memory_bytes: 30360
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 20, mod = 1e9 + 7;
long long n, s, d, w[N], cnt[N], fc[N], ifc[N], r[N];
bool mark[N];
vector<long long> gr[N], c[N], mm;
pair<long long, long long> mn = {mod, mod}, smn = {mod, mod};
long long ans = 1;
long long power(long long a, long long b) {
	if (!b)
		return 1;
	long long rtr = power(a, b / 2) % mod;
	if (b % 2)
		return rtr * rtr % mod * a % mod;
	return rtr * rtr % mod;
}
void getFC() {
	fc[0] = ifc[0] = 1;
	for (long long i = 1; i < N - 5; i++) {
		fc[i] = 1ll * fc[i - 1] * i % mod;
		ifc[i] = 1ll * ifc[i - 1] * power(i, mod - 2) % mod;
	}
	return;
}
void dfs(int v) {
	mm.push_back(v);
	mark[v] = 1;
	for (long long u : gr[v])
		if (!mark[u])
			dfs(u);
	return;
}
int main() {
	getFC();
	cin >> n >> s >> d;
	for (long long i = 0; i < n; i++) {
		cin >> r[i] >> w[i];
		r[i]--;
		c[r[i]].push_back(i);
		mn = min(mn, {w[i], i});
	}
	for (int i = 0; i < n; i++) 
		sort(c[i].begin(), c[i].end(), [] (long long x, long long y) { return (w[x] < w[y]); });
	for (int i = 0; i < n; i++) {
		if (r[i] != r[mn.second]) {
			smn = min(smn, {w[i], i});
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < c[i].size(); j++) {
			if (w[c[i][j]] + w[c[i][0]] <= s) {
				gr[c[i][0]].push_back(c[i][j]);
				gr[c[i][j]].push_back(c[i][0]);
			}
			long long u = c[i][j], v = mn.second;
			if (i != r[v]) {
				if (w[u] + w[v] <= d) {
					gr[u].push_back(v);
					gr[v].push_back(u);
				}
			}
			else {
				if (smn.first + w[u] <= d) {
					gr[u].push_back(smn.second);
					gr[smn.second].push_back(u);
				}
			}
		}
	}
	for (long long i = 0; i < n; i++) {
		if (!mark[i]) {
			dfs(i);
			long long rtr = 1ll * fc[(int) mm.size()] % mod;
			for (auto u : mm) {
				rtr = 1ll * rtr * fc[cnt[r[u]]] % mod;
				cnt[r[u]]++;
				rtr = 1ll * rtr * ifc[cnt[r[u]]] % mod;
			}
			for (long long u : mm)
				cnt[r[u]] = 0;
			mm.clear();
			ans = 1ll * (ans * rtr) % mod;
		}
	}
	cout << (ans + mod) % mod;
	return 0;
}


Measured memory_bytes: 34032
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;


const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b=10){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

struct unionFind{
  vector<int> par,sz;
  unionFind(int n):par(n),sz(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      sz[i]=1;
    }
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
    sz[ry]+=sz[rx];
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x){
    return sz[root(x)];
  }
};

int main(){
  int i,j,k,cnt=0;
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  for(i=0;i<m;i++){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  unionFind u(n);
  ll ans[m];
  ans[m-1]=(ll)n*(n-1)/2;
    for(i=m-1;i>=1;i--){
    if(!u.same(a[i],b[i])){
      ans[i-1]=ans[i]-(ll)u.size(a[i])*u.size(b[i]);
      u.unite(a[i],b[i]);
    }else{
      ans[i-1]=ans[i];
    }
  }
  for(i=0;i<m;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int a,b,n;
	while(~scanf("%d%d%d",&n,&a,&b))
	{
		if((b-a)%2) puts("Borys");
		else puts("Alice");
	}
	return 0;
}


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


int N, v[100], w[100], W;
int V[101][10001] {0};
int main(){
  cin >> N >> W;
  for(int i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  for(int i = 0; i < N; i++){
    for(int k = 1; k <= 10000; k++){
      if(k >= w[i]){
	V[i+1][k] = max(v[i] + V[i][max(0,k - w[i])], V[i][k]);
      }else{
	V[i+1][k] = V[i][k];
      }
      
    }
  }

  cout << V[N][W] << endl;
  
}

Measured memory_bytes: 6980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    string s,t;
    cin >> s >> t;
    int cnt = 0;
    rep(i,3)
    	if(s[i]==t[i])
    		cnt++;
    cout << cnt << '\n';
}
	
	

Measured memory_bytes: 256
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
    LL n;
    cin >> n;
    n--;
    string ans("");
    while (n > 0) {
        LL mod = n % 26;
        char x;
        x = 'a' + mod;
        ans = x + ans;
        n = n / 26 - 1;
    } 
    if (n == 0) {
        ans = 'a' + ans;
    }

    col(ans);
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main()
{	IOS;
    ll r,d,x,temp; cin>>r>>d>>x;
    for(int i=1;i<=10;i++){
        temp=(x*r)-d;
        cout<<temp<<"\n";
        x=temp;
    }
	return 0;
}

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

using namespace std;

vector<int>g[1000005];
int dp[1000005];

int func(int u){
    if (dp[u] != -1){
        return dp[u];
    }else{
        int ans = 0;
        for (auto i : g[u]){
            ans = max(ans,  1+func(i));
        }
        dp[u] = ans;
        return ans;
    }
    
}

int main(void){
    int n, m;
    cin >> n >> m;
    for (int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    int ans = 0;
    memset(dp, -1, sizeof(dp));
    for (int i=1;i<=n;i++){
        ans = max (ans, func(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32768
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <functional>

constexpr int INF=1<<28;

struct Edge {
  size_t src, dst;
  int cost;
  Edge() {}
  Edge(size_t src, size_t dst, int cost): src(src), dst(dst), cost(cost) {}
};

template <class T>
using iqueue=std::priority_queue<T, std::vector<T>, std::greater<T>>;

std::vector<int> shortest(const std::vector<std::vector<Edge>> &g, size_t s) {
  std::vector<int> d(g.size(), INF);
  d[s] = 0;
  iqueue<std::pair<int, size_t>> q;
  q.emplace(0, s);
  while (!q.empty()) {
    int w=q.top().first;
    size_t v=q.top().second;
    q.pop();
    if (w > d[v])
      continue;
 
    for (const Edge &e: g[v]) {
      if (d[e.dst] > d[e.src] + e.cost) {
	// fprintf(stderr, "src: d[%zu] = %d\n", e.src, d[e.src]);
	// fprintf(stderr, "dst: d[%zu] = %d\n", e.dst, d[e.dst]);
	d[e.dst] = d[e.src] + e.cost;
	q.emplace(d[e.dst], e.dst);
      }
    }
  }

  return d;
}

int main() {
  int N;
  scanf("%d", &N);

  std::vector<std::vector<Edge>> g(N);
  for (int i=0; i<N; ++i) {
    int p;
    scanf("%d", &p);
    if (p) {
      // fprintf(stderr, "%d -> %d\n", i, i+p);
      g[i].emplace_back(i, i+p, 0);
    } else {
      for (int j=1; j<=6; ++j) {
	if (i+j > N-1)
	  continue;

	// fprintf(stderr, "%d -> %d\n", i, i+j);
	g[i].emplace_back(i, i+j, 1);
      }
    }
  }

  std::vector<int> d=shortest(g, 0);
  // for (int i=0; i<N; ++i)
  //   fprintf(stderr, "%d%c", d[i], i+1<N? ' ':'\n');

  printf("%d\n", d.back());
  return 0;
}

Measured memory_bytes: 13992
n, k = map(int, input().split())
r = 0
for i in range(1, n + 1):
    if i >= k:
        print((r + (n - k + 1))/ n)
        break
    a = i
    c = 0
    while a < k:
        a *= 2
        c += 1
    r += (1 / 2) ** c
else:
    print(r / n)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    set<string> S;
    int N; cin >> N;
    rep(i,N){
        string Si; cin >> Si;
        S.insert(Si);
    }
    cout << S.size() << endl;
}

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

int main()
{
  int64_t N, K, ans = 0;
  string S;
  cin >> N >> K >> S;
  vector<int64_t> Count(1, 0);
  S.at(0) == '0' ? Count[0]-- : Count[0]++; // 0なら-1, iなら+1
  for (int i = 1; i < N; i++)
  {
    if (S.at(i) != S.at(i - 1))
      Count.push_back(0);
    S.at(i) == '0' ? Count.at(Count.size() - 1)-- : Count.at(Count.size() - 1)++;
  }

  for (int i = 0; i < Count.size(); i++)
    ans = max(ans, abs(Count.at(i)));

  vector<int64_t> Sum(Count.size() + 1, 0);
  for (int i = 0; i < Count.size(); i++)
    Sum.at(i + 1) = Sum.at(i) + abs(Count.at(i));

  int64_t length = Count.size(), zero = 0;
  for (int64_t i = 0; i < length; i++)
  {
    if ((K % 2 == 1 && Count.at(i) > 0) || (K % 2 == 0 && Count.at(i) < 0))
      continue;
    int64_t sum = 0;
    int64_t r = min(length - 1, i + K) + 1;
    int64_t l = max(zero, i - K);
    sum += Sum.at(r) - Sum.at(l);
    ans = max(ans, sum);
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

string D;
char ana[] = {"IDUYNA"};

int main(){
  cin >> D;
  rep(i, (int)D.size()-7){
    map<char, int>m;
    rep(p, 8){
      m[D[p+i]]++;
    }
    int f = 1;
    rep(i, 4) if(m[ana[i]] != 1) f = 0;
    REP(i, 4, 6) if(m[ana[i]] != 2) f = 0;
    if(f){
      D.erase(i, 8);
      D.insert(i, "AIZUNYAN");
      i += 7;
    }
  }
  cout << D << endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  vector<ll> A(N);
  for (auto& a : A) { cin >> a; }
  

  int x{}; // 4 no baisu
  int y{}; // 2 no baisu
  int z{}; // igai
  for (const auto& a : A) {
    if (a % 4 == 0) {
      ++x;
    } else if (a % 2 == 0) {
      ++y;
    } else {
      ++z;
    }
  }
  if (y > 0) {
    ++z;
  }
  auto ans = x >= z - 1;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
   
    while(true){
        ll h,w; cin>>h>>w;
        if(h==0&&w==0) break;
        vector<vector<char>> rect(h,vector<char>(w,'.'));
        
        rep(i,h)rep(j,w){
            rect[i][0]='#';
            rect[i][w-1]='#';
            rect[0][j]='#';
            rect[h-1][j]='#';
        }

        rep(i,h)rep(j,w){
            cout<<rect[i][j];
            if(j==w-1) cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  vi s;
  int n, m;
  int a, b;
 
  cin>> n;
  for(int i=0;i<n;i++){
    cin>> a>> b;
    s.pb(60*a+b);
  }

  cin>> m;
  for(int i=0;i<m;i++){
    cin>> a>> b;
    s.pb(60*a+b);
  }

  sort(s.begin(),s.end());
  //配列の中で重複している値を消去
  s.erase(unique(s.begin(),s.end()),s.end()); 
  for(int i=0;i<s.size();i++){
    if( i ) cout<< " ";
    printf("%d:%02d",s[i]/60,s[i]%60);
  }
  cout<< endl;
}

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

using namespace std;

int main(void)
{
   int n;
   cin>>n;
   vector<int> A;
   vector<int> B;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       A.push_back(x);
   }
   B=A;
   sort(B.begin(),B.end());
   int diff=0;
   for(int i=0;i<n;i++)
   {
       if(A[i]!=B[i])
       {
           diff++;

       }
       if(diff>2)
       {
           break;
       }
   }
   if(diff<=2)
   {
       cout<<"YES"<<endl;
   }
   else
   {
       cout<<"NO"<<endl;
   }

}


Measured memory_bytes: 256