akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX 25
#define NIL -1

typedef struct Node_
{
    int parent;
    int left;
    int right;
} Node;

Node Tree[MAX];

static void preOrder(int i)
{
    if (i == NIL)
        return;
    printf(" %d", i);
    preOrder(Tree[i].left);
    preOrder(Tree[i].right);
}

static void inOrder(int i)
{
    if (i == NIL)
        return;
    inOrder(Tree[i].left);
    printf(" %d", i);
    inOrder(Tree[i].right);
}

static void postOrder(int i)
{
    if (i == NIL)
        return;
    postOrder(Tree[i].left);
    postOrder(Tree[i].right);
    printf(" %d", i);
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        Tree[i].parent = NIL;
    }

    for (int i = 0; i < n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        Tree[id].left = left;
        Tree[id].right = right;
        if (left != NIL)
            Tree[left].parent = id;
        if (right != NIL)
            Tree[right].parent = id;
    }

    int root = NIL;
    for (int i = 0; i < n; i++) {
        if (Tree[i].parent == NIL) {
            root = i;
            break;
        }
    }

    if (root != NIL) {
        printf("Preorder\n");
        preOrder(root);
        printf("\n");
        printf("Inorder\n");
        inOrder(root);
        printf("\n");
        printf("Postorder\n");
        postOrder(root);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2048
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  ll m = N;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i != 0) continue;
    ll M = max(N/i, i);
    m = min(m, M);
  }

  int ans = 0;
  while(m > 0){
    m /= 10LL;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
"""
ABC042 A 和風いろはちゃんイージー
https://atcoder.jp/contests/abc042/tasks/abc042_a
"""

l = list(map(int, input().split()))
l5 = l.count(5)
l7 = l.count(7)

if l5 == 2 and l7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9088
number_of_music=int(input())
music_counter=0
music_dict={}
dict_counter=number_of_music
while dict_counter > 0:
  music_counter+=1
  input_string=input().split()
  music_dict[music_counter]={input_string[0]:input_string[1]}
  dict_counter-=1
start_music=input()

counter_start=0
music_counter=0
dict_counter=number_of_music
while dict_counter > 0:
  music_counter+=1
  for key,value in music_dict[music_counter].items():
    if key==start_music:
      counter_start=music_counter
      break
  dict_counter-=1
result=0
dict_counter=number_of_music
while dict_counter > 0 and counter_start < number_of_music:
  counter_start+=1
  for key,value in music_dict[counter_start].items():
    result+=int(value)
  dict_counter-=1
print (result)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int n,p,ans,a[100001];
int calc(int k){
	return max(p-k,k-p-(a[n]&1));
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	ans=1000000000;
	p=a[n]/2;
	for(int i=1;i<=n;i++)
		if (calc(a[i])<calc(ans))ans=a[i];
	printf("%d %d\n",a[n],ans);
	return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        string s;
        int count = 0;

        int l = 0, r = 0;
        rep(i, n){
            cin >> s;
            if(s == "lu") l++;
            else if(s == "ru") r++;
            else if(s == "ld") l--;
            else r--;

            if(!(r^l)){
                if(!(count%2) && r) count++;
                else if(count%2 && !r) count++;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>

#define MIN(A,B) ((A) > (B) ? (B) : (A))

int main() {
	int a, b, i;
	scanf("%d %d", &a, &b);
	i = abs(a - b);
	if (i % 2 != 0) {
		puts("IMPOSSIBLE");
		return 0;
	}
	printf("%d\n", MIN(a, b) + i / 2);
	return 0;
}


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

using namespace std;

const int kInfinity = 0x3F3F3F3F;
const int kNil = -1;
const int kMaxV = 100010;

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
decltype(auto) Dijkstra(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num,
                 typename vector<Edge>::size_type source) {
  using size_type = typename vector<Edge>::size_type;
  using w_type = typename Edge::w_type;

  bitset<kMaxV> bs;
  vector<vector<Edge>> adjacency(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency[e.u].push_back(e);
  }
  vector<w_type> dist(node_num, kInfinity);
  vector<int> parent(node_num, kNil);
  dist[source] = 0;

  using Pair = pair<size_type, w_type>;
  auto compare = [](const Pair & x, const Pair & y) {
    return y.second < x.second || (!(x.second < y.second) && y.first < x.first);
  };
  priority_queue<Pair, vector<Pair>, decltype(compare)> que(compare);
  que.emplace(source, 0);

  while (!que.empty()) {
    auto top_no = que.top().first;
    auto top_dist = que.top().second;
    que.pop();
    bs.set(top_no);
    for (const auto & e: adjacency[top_no]) {
      const auto cost = dist[e.u] + e.w;
      if (dist[e.v] > cost && !bs.test(e.v)) {
        dist[e.v] = cost;
        parent[e.v] = e.u;
        que.emplace(e.v, cost);
      }
    }
  }

  return dist;
}

int main(int argc, char const *argv[]) {
  vector<Edge<int>> edges;
  unsigned V, E, r;
  cin >> V >> E >> r;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    unsigned w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
  }

  auto dist = Dijkstra(edges, V, r);
  for (unsigned i = 0; i < V; ++i) {
    if (dist[i] == kInfinity) {
      cout << "INF\n";
    } else {
      cout << dist[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 23512
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

S,T=input().split()
i,j=LI()
term = input()
if term == S:
    i -= 1
if term == T:
    j -= 1

print(i,j)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

namespace MyMod {
  typedef long long ll;
  constexpr ll mod = 1e9+7;

  ll power (ll e, ll x){
    if (x == 0) return 1LL; if (x % 2 != 0) return ((power(e, x-1) * e) % mod);
    ll temp = power(e, x / 2); return (temp * temp) % mod;
  }
  ll add ( ll a, ll b ) { return ((a%mod) + (b%mod))%mod; }
  ll sub ( ll a, ll b ) { return ( a%mod + mod - b%mod)%mod; }
  ll mul ( ll a, ll b ) { return ((a%mod) * (b%mod)) % mod; }
  ll div ( ll a, ll b ) { return ((a%mod) * power(b,mod-2)) % mod; }
};



int main (void) {

  std::string S; std::cin >> S;
  std::vector<long long> k(100001);
  k[0] = 3; k[1] = 5;
  for(int i=1; i<100001; i++) k[i+1] = MyMod::add(k[i], MyMod::mul(2,MyMod::power(3,i)));

  long long ans = k[S.size()-1];
  int cnt = 1;
  for(int i=1; i<S.size(); i++) {
    if ( S[i] == '1' ) {
      ans = MyMod::add(ans, MyMod::mul(MyMod::power(2, cnt),(k[S.size()-1-i]-1)));
      cnt++;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        int len = S.length();
        String s1 = S.substring(0, len/2);
        String s2 = "";
        if (len % 2 == 0) {
         s2 = new StringBuffer(S.substring(len/2, len)).reverse().toString();
        }else {
            s2 =   new StringBuffer(S.substring(len/2 +1, len)).reverse().toString();
        }
        if (!s1.equals(s2)) {
            System.out.println("No");
            return;
        }
        String s3 = S.substring(0, (len-1)/2);
        if (!s3.equals(new StringBuffer(s3).reverse().toString())) {
            System.out.println("No");
            return;
        }

        String s4 = S.substring((len+3)/2 -1);
        if (!s4.equals(new StringBuffer(s4).reverse().toString())) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int con = 0;

		con = H /A;
		if (H %A != 0 ) {
			con++;
		}
		System.out.println(con);
	}
}

Measured memory_bytes: 35480
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
using namespace std;


int main() {
  const long long M = pow(10, 18);
  int N;
  cin >> N;
  vector <unsigned long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) { cout << 0 << endl; return 0; }
  }

  unsigned long long ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans > M / A[i]) { cout << -1 << endl; return 0; }
    ans *= A[i];
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define PI 3.14159265358979323846
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    
    int n;
    cin >> n;
    vector< Pii > v(n);
    rep(n){
        cin >> v[i].first >> v[i].second;
        if(sx > gx) v[i].first = 100000000 - v[i].first;
        if(sy > gy) v[i].second = 100000000 - v[i].second;
    }
    if(sx > gx){
        sx = 100000000 - sx;
        gx = 100000000 - gx;
    }
    if(sy > gy){
        sy = 100000000 - sy;
        gy = 100000000 - gy;        
    }
    sort(all(v));

    vector<int> y, lis;
    rep(n){
        if(sx <= v[i].first && v[i].first <= gx && min(sy, gy) <= v[i].second && v[i].second <= max(sy, gy)){
            y.push_back(v[i].second);
        }
    }
    for(int yy: y){
        auto itr = lower_bound(all(lis), yy);
        if(itr == lis.end()){
            lis.push_back(yy);
        }else{
            *itr = yy;
        }
    }

    int m = (int)lis.size();
    long double ans = 100.0 * (long double)(gx-sx + abs(gy-sy)) - (long double)m * 20.0;
    if(m == min(gx-sx, abs(gy-sy)) + 1){
        ans += 10.0 * PI;
        m--;
    }
    ans += (long double)m * 5.0 * PI;

    printf("%.15Lf\n", ans);
    return 0;
}

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

int main(){
	int N;
	long long K;
	cin >> N >> K;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	for(int i=0;i<N;i++)A[i]--;
	
	long long c=0;
	int pos=0;
	vector<int> visited(N,-1);
	visited[0]=0;
	while(1){
		//cout << c << endl;
		if(c==K){
			cout << pos+1 << endl;
			return 0;
		}
		pos=A[pos];
		c++;
		if(visited[pos]==-1)visited[pos]=c;
		else{
			long long x=(c-visited[pos]);
			c=K/x*x+(c%x);
			if(c>K)c-=x;
			while(1){
				//cout << c << endl;
				if(c==K){
					cout << pos+1 << endl;
					return 0;
				}
				pos=A[pos];
				c++;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 200005
#define M 10005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-7
using namespace std;

ll s[N];
int mini[2][N];
int maxi[2][N];
ll dp[2][N];
ll sum[2][N];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    //freopen("in.txt", "r", stdin);
    //freopen("out_me.txt", "w", stdout);
    while(cin>>n>>a>>b)
    {
        FOR(i,1,n)cin>>s[i];
        s[0] = s[1];
        FOR(i,1,n)
        {
            mini[0][i] = lower_bound(s+1,s+i,s[i]-a+1)-(s+1);
            mini[1][i] = lower_bound(s+1,s+i,s[i]-b+1)-(s+1);

            if(s[i]-s[i-1]<a)maxi[0][i] = i-2;
            else maxi[0][i] = maxi[0][i-1];

            if(s[i]-s[i-1]<b)maxi[1][i] = i-2;
            else maxi[1][i] = maxi[1][i-1];

        }
        mini[0][n+1] = mini[1][n+1] = n-1;
        FOR(i,1,n+1)dp[0][i] = dp[1][i] = sum[0][i] = sum[1][i] = 0;
        dp[0][0] = dp[1][0] = 1;
        sum[0][0] = sum[1][0] = 1;

        FOR(i,1,n)
        {
            ll low = maxi[0][i]<0?0:sum[1][maxi[0][i]];
            ll high = sum[1][max(maxi[0][i],min(mini[1][i+1],i-1))];
            dp[0][i] = (high-low)%MOD;

            low = maxi[1][i]<0?0:sum[0][maxi[1][i]];
            high = sum[0][max(maxi[1][i],min(mini[0][i+1],i-1))];
            dp[1][i] = (high-low)%MOD;

            //cout<<i<<" "<<dp[0][i]<<" "<<dp[1][i]<<endl;

            sum[0][i] = (sum[0][i-1]+dp[0][i])%MOD;
            sum[1][i] = (sum[1][i-1]+dp[1][i])%MOD;
        }
        cout<<((dp[0][n]+dp[1][n]+MOD)%MOD+MOD)%MOD<<endl;
    }
    return 0;
}


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

int64_t mod = 1000000007;

int main()
{
	int64_t n, k;
	cin >> n >> k;

	int64_t ans = 0;
	for (int64_t i = k; i <= n + 1; i++) {
		// (最大-最小)+1個が個数
		int64_t mini = (0 + i - 1) * i / 2;
		int64_t maxi = (n - i + 1 + n) * i / 2;
		int64_t temp = maxi - mini + 1;
		ans += temp;
		ans %= mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int N, K;
	cin >> N >> K;

	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	multiset<ll> v;
	for(int k = 1; k <= N; k++){
		ll s = 0;
		for(int i = 0; i < k; i++){
			s += a[i];
		}
		v.insert(s);

		for(int i = k; i < N; i++){
			s += a[i];
			s -= a[i-k];
			v.insert(s);
		}
	}

	// for(auto itr = v.begin(); itr != v.end(); itr++){
	// 	cout << *itr << ",";
	// }
	// cout << endl;

	ll ans = 0LL;
	for(int i = 62; i >= 0; i--){
		ll t = 1LL << i;
		int cnt = 0;
		for(auto itr = v.begin(); itr != v.end(); itr++){
			if(*itr & t) {
				// cout << i << "," << *itr << "," << (*itr & t) << endl;
				cnt++;
			}
		}

		if(cnt >= K){
			// cout << i << "," << cnt << endl;
			for(auto itr = v.begin(); itr != v.end(); ){
				if((*itr & t) == 0) {
					itr = v.erase(itr);
				}else{
					itr++;
				}
			}
			ans += t;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 23680
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderA
{
    static void Main()
    {
        int a;
        int b;
        int c;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
            c = int.Parse(words[2]);
        }

        Console.WriteLine(Math.Max(0, c - (a - b)));
    }
}

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

const int mod = 1000000007, inv2 = mod + 1 >> 1;
int n, f[4010][4010], a[200010], b[200010], ans = 0, fac[8010], inv[8010];

int Pow(int x, int y)
{
    int ans = 1;
    for (; y; y >>= 1, x = 1LL * x * x % mod)
        if (y & 1) ans = 1LL * ans * x % mod;
    return ans;
}
int C(int x, int y)
{
    return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main()
{
    fac[0] = 1;
    for (int i = 1; i <= 8000; i++) fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[8000] = Pow(fac[8000], mod - 2);
    for (int i = 7999; i >= 0; i--) inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d%d", &a[i], &b[i]);
        f[2005 - a[i]][2005 - b[i]]++;
    }
    for (int i = 1; i <= 4005; i++)
        for (int j = 1; j <= 4005; j++)
            (f[i][j] += (f[i - 1][j] + f[i][j - 1]) % mod) %= mod;
    for (int i = 1; i <= n; i++)
    {
        ans = ((ans + f[a[i] + 2005][b[i] + 2005] - C((a[i] + b[i]) * 2, a[i] * 2)) % mod + mod) % mod;
    }
    printf("%lld\n", 1LL * ans * inv2 % mod);
}

Measured memory_bytes: 64640
S = input()
count = [0 for _ in range(len(S))]
for i, s_i in enumerate(S):
  if s_i in ['A', 'G', 'C', 'T']:
    if i == 0:
      count[i] = 1
    else:
      count[i] = count[i-1] + 1
  else:
    count[i] = 0
    
print(max(count))   

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nt = Reads();
            var n = nt[0];
            var t = nt[1];
            var tt = Reads();
            long ans = 0;
            for (int i = 0; i < n - 1; i++)
            {
                ans += Math.Min(tt[i + 1] - tt[i], t);
            }
            WriteLine(ans + t);
            

            Console.Out.Flush();
        }
    }
}



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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if ( A > C && B > C || A < C && B < C )
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    string s = to_string(n);
    if (s[0] == s[2]) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string a;
	cin >> a;

	cout << "ABC" + a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int dp[50];
int main() {
  int n;
	dp[0] = 1;
	for (int i = 1; i <= 30; i++) {
		dp[i] += dp[i - 1];
    //cout << dp[i] << " ";
		if (i >= 2)dp[i] += dp[i - 2];
    //cout << dp[i] << " ";
		if (i >= 3)dp[i] += dp[i - 3];
    //cout << dp[i] << " ";
    //cout << endl;
	}
  while (cin >> n,n) {
  cout << dp[n]/10/365+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 2996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		String suu=sc.next();
		String[] array=suu.split("");
		int[] fainalValue=new int[array.length];
		
		for(int i=0;i<array.length;i++) {
			fainalValue[i]=Integer.parseInt(array[i]);
		}
		int A=fainalValue[0];
		int B=fainalValue[1];
		int C=fainalValue[2];
		int D=fainalValue[3];
		
		
		if((A+B+C+D)==7) {
			System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
		}else if((A-B+C+D)==7) {
			System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
		}else if((A+B-C+D)==7) {
			System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
		}else if((A+B+C-D)==7){
			System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
		}else if((A-B-C+D)==7){
			System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
		}else if((A+B-C-D)==7){
			System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
		}else if((A-B+C-D)==7){
			System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
		}else if((A-B-C-D)==7){
			System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");
		}
	}

}


Measured memory_bytes: 21844
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll n;
    cin>>n;
    vector<ll> vec(n);
    ll ans = 1;
    for(int i = 0; i < n; i++){
        cin>>vec[i];
        if(vec[i] == 0){
            cout<<"0";
            return ;
        }
    }
    sort(vec.begin(), vec.end());
    for(ll k : vec){
        if(ans > INF/k){
            cout<<-1;
            return ;
        }
        ans *= k;
    }
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3968
//Bridge

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,m;cin>>n>>m;
    vector<p>q(m);
    rep(i,0,m){
        cin>>q[i].first>>q[i].second;
        q[i].first--;
        q[i].second--;
    }
    int ans = 0;
    stack<int>t;
    rep(i,0,m){
        graph g(n);
        rep(j,0,m){
            if(i==j)continue;
            g[q[j].first].pb(q[j].second);
            g[q[j].second].pb(q[j].first);
        }
        t.push(0);
        vector<bool>s(n,false);
        
        while(!t.empty()){
            int v=t.top();
            t.pop();
            s[v]=true;
            
            rep(j,0,g[v].size())if(!s[g[v][j]])t.push(g[v][j]);
        }
        rep(j,0,n){
            if(!s[j]){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
import sys


class UnionFind(object):
    __slots__ = ["nodes"]

    def __init__(self, n: int):
        self.nodes = [-1]*n # 親: -(属するノード数), それ以外: (親ノードindex)

    def find(self, x: int) -> int:
        if self.nodes[x] < 0:
            return x
        else:
            self.nodes[x] = self.find(self.nodes[x]) # compression
            return self.nodes[x]

    def has_same_root(self, x, y) -> bool:
        return self.find(x) == self.find(y)
    
    def size(self, x) -> int:
        return -self.nodes[self.find(x)]

    def unite(self, x: int, y: int) -> None:
        if self.has_same_root(x, y):
            return

        root_x, root_y = self.find(x), self.find(y)
        if self.nodes[root_x] < self.nodes[root_y]:
            bigroot, smallroot = (root_x, root_y)
        else: 
            bigroot, smallroot = (root_y, root_x)
        self.nodes[bigroot] += self.nodes[smallroot]
        self.nodes[smallroot] = bigroot


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    count = [0] # count[i]: 最後からi本目の橋が復活したときの互いに行き来できる島の組み合わせの数
    UFT = UnionFind(N)

    for i in range(1, M+1):
        a, b = A[-i], B[-i]
        if UFT.has_same_root(a, b):
            count.append(count[-1])
            continue
        count.append(count[-1] + UFT.size(a) * UFT.size(b))
        UFT.unite(a, b)

    for i in range(M):
        print(count[-1] - count[-(i+2)])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))-1
        B[i] = int(next(tokens))-1
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int a, b, c, d, sum = 0;

	cin >> a >> b >> c >> d;

	if (a > b)
		sum += b;
	else
		sum += a;

	if (c > d)
		sum += d;
	else
		sum += c;

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long  long int gcd(long long int m,long long int n){
    if(n==0)
        return m;
    else
        return gcd(n,m%n);
}

int main(void){
    long  long int a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld",a*b/gcd(a,b));
    return 0;
}

Measured memory_bytes: 128
program main
  
  implicit none
  integer,allocatable :: a(:)
  integer :: n, m ,num ,i, tol
  
  read(*,*) n, m
  allocate( a(n) )
  read(*,*) a
  
  num = 0
  tol = sum( a )
  do i = 1, n
    if( a(i) < 1e0/4e0/real(m)*real(tol)) then 
    else
      num = num + 1 
    end if
  end do

  if( num >= m ) then
    print*, "Yes" 
  else
    print*, "No" 
  end if
   
end program main


Measured memory_bytes: 640
while True:
	H, W = map(int, input().split())
	if H == W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end="")
			else:
				print(".", end="")
		print("")
	print("")
	


Measured memory_bytes: 7012
from collections import Counter as counter
#from collections import deque

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    n = ii()
    s = ix(n)
    judge = ["AC","WA","TLE","RE"]
    c = counter(s)
    for item in judge:
        print(item + " x " + str(c[item]))
    
if __name__ == "__main__":
    resolve()

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

int main(){
    long long x;
    cin>>x;

    for(long long i=-200;i<200;++i){
        for(long long j=-200;j<200;++j){
            long long a=i*i*i*i*i;
            long long b=j*j*j*j*j;
            if(a-b==x){
                cout<<i<<' '<<j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
X=list(map(int, input().split())) 
re=0
b=X[1]*X[1]
for i in range(X[0]):
  s=list(map(int, input().split())) 
  z=s[0]*s[0]+s[1]*s[1]
  if b>=z:
    re+=1
print(re)

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll h,w;

  cin>>h>>w;

  vector<string> v;

  string tmp;
  rep(i, h){
    cin>>tmp;
    v.push_back(tmp);
  }

  ll dh[4] = {1,0,-1,0};
  ll dw[4] = {0,1, 0, -1};
  
  rep(i, h){
    rep(j, w){
      if(v[i][j]=='#'){
	ll flug=0;
	rep(k, 4){
	  //cout <<i<<" "<<j<<" "<<i+dh[k]<<endl;
	  if(0<=i+dh[k] && i+dh[k]<h && 0<=j+dw[k] && j+dw[k]<w) {
	    //cout <<i<<" "<<j<<" "<<k<<endl;
	    if(v[i+dh[k]][j+dw[k]]=='#') flug=1;
	  }
	}
	if(flug==0){
	  cout<<"No"<<endl;
	  return 0;
	}
      }
    }
  }
  cout<<"Yes"<<endl;
  
}


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

const int maxn = 5005;

bool dp[maxn];

int v[maxn];
int n,k;

bool check(int idx)
{
	memset(dp,0,sizeof(dp));
	dp[0] = 1;
	for(int i = 1 ; i <= n; i++)
	{
		if(i == idx)
			continue;
		for(int j = k - v[i]; j >= 0; j--)
			dp[j+v[i]] |= dp[j];
	}
	for(int i = max(0,k-v[idx]); i < k; i++)
		if(dp[i])
			return true;
	return false;
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i = 1 ; i <= n ; i++)
	{
		scanf("%d",&v[i]);
	}

	sort(v+1,v+n+1);	
	
	int lo = 1;
	int hi = n;
	int ans = 0;
	while(lo <= hi)
	{
		int mid = (lo + hi) >> 1;
		if(check(mid))
		{
			hi = mid - 1;
		}
		else
		{
			ans = mid;
			lo = mid+1;
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
q = int(input())
kl = list(map(int, input().split()))
ansl = []
for k in kl:
    d_cnt = 0
    m_cnt = 0
    c_cnt = 0
    dm_cnt = 0
    dmc_cnt = 0
    for i in range(k):
        si = s[i]
        if si == 'D':
            d_cnt += 1
        elif si == 'M':
            m_cnt += 1
            dm_cnt += d_cnt
        elif si == 'C':
            c_cnt += 1
            dmc_cnt += dm_cnt   
    
    rem = n-k
    for i in range(rem):
        drop = s[i]
        new = s[i+k]
        if drop == 'D':
            d_cnt -= 1
            dm_cnt -= m_cnt
        elif drop == 'M':
            m_cnt -= 1
        elif drop == 'C':
            c_cnt -= 1
        
        if new == 'D':
            d_cnt += 1
        elif new == 'M':
            m_cnt += 1
            dm_cnt += d_cnt
        elif new == 'C':
            c_cnt += 1
            dmc_cnt += dm_cnt

    ansl.append(dmc_cnt)

for a in ansl: print(a)

Measured memory_bytes: 75112
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int[] sec = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      sec[i] = Integer.parseInt(S[i]);
      sum += sec[i];
    }
    
    int M = Integer.parseInt(sc.nextLine());
    for(int i = 0; i < M; i++){
      String[] T = sc.nextLine().split(" ");
      int a = Integer.parseInt(T[0]);
      int b = Integer.parseInt(T[1]);
      System.out.println(sum - (sec[a-1] - b));
    }
  }
}

Measured memory_bytes: 20692
#include<stdio.h>

int main(void){
  int A, B;
  scanf("%d %d", &A, &B);
  if(A <= 5){
    printf("0\n");
    return 0;
  }
  if(A <= 12){
    printf("%d\n", (int)(B/2));
    return 0;
  }
  printf("%d\n", B);
  return 0;
}

Measured memory_bytes: 128
N,M=list(map(int,input().split()))

bridge=[None]*M

for i in range(M):
    bridge[i]=tuple(map(int,input().split()))


bridge.sort()

brilist=[0]*(10**5)
brilist[bridge[0][0]]=bridge[0][1]
#print(brilist[:15])
for i in range(1,M):
    if bridge[i][0]==bridge[i-1][0]:
        brilist[bridge[i][0]]=min(bridge[i][1],brilist[bridge[i][0]])

    elif bridge[i][0]<brilist[bridge[i-1][0]]:

        brilist[bridge[i][0]]=min(bridge[i][1],brilist[bridge[i-1][0]])
        brilist[bridge[i-1][0]]=0
        

    else:

        brilist[bridge[i][0]]=bridge[i][1]

    #print(brilist[:15])


ANS=0
for i in range(10**5):
    if brilist[i]!=0:
        ANS+=1

print(ANS)
#print(brilist[:15])
        
    


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

int N, MA, MB;
int A[50],B[50],C[50];

int dp[410][410];

int NOT_FOUND = 888888;

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

	cin >> N >> MA >> MB;
	REP(i, 0, N)	cin >> A[i] >> B[i] >> C[i];
	
	REP(a, 0, 410)	REP(b, 0, 410)	dp[a][b] = INF;
	dp[0][0] = 0;
	
	for(int i = 0; i < N; i++) {
		for(int a = 400; a >= 0; a--) {
			if(a + A[i] > 400)	continue;
			for(int b = 400; b >= 0; b--) {
				if(b + B[i] > 400)	continue;
				if(dp[a][b] == INF)	continue;
//				cout << "dp[" << (a+A[i]) << "][" << (b+B[i]) << "] = min(" 
//				    << dp[ a + A[i] ][ b + B[i] ] << ", " << (dp[a][b] + C[i]) << ")" << endl;

				dp[ a + A[i] ][ b + B[i] ] = min( dp[ a + A[i] ][ b + B[i] ], dp[a][b] + C[i]);
			}
		}
	}

	int ans = INF;
	for(int a=1; a <= 400; a++)
		for(int b=1; b <= 400; b++)
			if(a * MB == b * MA)
				ans = min(ans, dp[a][b]);
	
	if(ans == INF)	ans = -1;
	cout << ans << endl;
	
	return 0;
}


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

class dice
{
	public:
		int face[6];
		void rotate(char c);
		void rotw();
		void rots();
		void rotn();
		void rote();
};

void dice::rotate(char c){
	     if(c=='S') rots();
	else if(c=='W') rotw();
	else if(c=='E') rote();
	else if(c=='N') rotn();
}

void dice::rotw(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[2]; t[2] = face[5]; t[3] = face[0]; t[5] = face[3];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rots(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[4]; t[1] = face[0]; t[4] = face[5]; t[5] = face[1];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rotn(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[1]; t[1] = face[5]; t[4] = face[0]; t[5] = face[4];
	for(int i=0;i<6;i++) face[i] = t[i];
}
void dice::rote(){
	int t[6];
	for(int i=0;i<6;i++) t[i] = face[i];
	t[0] = face[3]; t[2] = face[0]; t[3] = face[5]; t[5] = face[2];
	for(int i=0;i<6;i++) face[i] = t[i];
}

int main(){
	dice d;
	for(int i=0;i<6;i++) cin >> d.face[i];
	char t;
	while(cin >> t) d.rotate(t);
	cout << d.face[0] << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N - i - 1; j++) {
      int a = A.at(j);
      if (a < A.at(j + 1)) {
        A.at(j) = A.at(j + 1);
        A.at(j + 1) = a;
      }
    }
  }
  
  int P = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      P += A.at(i);
    }else{
      P -= A.at(i);
    }
  }
  cout << P;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if ( N * A <= B) {
    cout << N*A << endl;
  }
  else if (N*A > B) {
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main() {
	int n, k;
	cin >> n >> k;
	if (n%k == 0)puts("0");
	else puts("1");
	getchar(); getchar();
	return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;
    Vl a(n);
    REP(i, n) {
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(ALL(a));
    ll avg = a[n/2];
    ll res = 0;
    REP(i, n) {
        res += abs(a[i] - avg);
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 505
int n,a[maxn][maxn];
void work(int l,int r,int w){
  if(l == r) return;
  if(l + 1 == r){
    a[l][r] = w;
    return;
  }
  int mid = (l + r) >> 1;
  for(int i = l;i <= mid;i++){
    for(int j = mid + 1;j <= r;j++) a[i][j] = w;
  }
  work(l,mid,w + 1);
  work(mid + 1,r,w + 1);
}
int main(){
  n = getint();
  work(1,n,1);
  for(int i = 1;i <= n - 1;i++){
    for(int j = i + 1;j <= n;j++){
      putint(a[i][j],j == n ? '\n' : ' ');
    }
  }
  bufo.flush();
  return 0;
}


Measured memory_bytes: 1536
x, y = list(map(int, input().split()))

dif = abs(abs(x)-abs(y))

if (x >= 0 and y > 0) or (x < 0 and y <= 0):
    if x < y:
        print(dif)
    else:
        print(dif + 2)
else:
    print(dif + 1)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  ull n,a,b;cin>>n>>a>>b;
  ull diff=b-a;
  ull ans;
  if((diff%2ULL)==0){
    ans=diff/2ULL;
  }else{
    if(a-1<n-b){
      ans=a-1+1+(b-a-1)/2;
    }else{
      ans=n-b+1+(b-a-1)/2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))

M = 40000
A = []
B = []
for i in range(N):
  A.append(M*i)
  B.append(M*(N-i))
for i in range(N):
  A[P[i]-1] += i+1
print(*A)
print(*B)


Measured memory_bytes: 45572
import java.math.*;
import java.util.*;
object MainKt {
   fun solve(i:Int,j:Int,w:List<Int>,v:List<Int>,mem: HashMap<Pair<Pair<Int,Int>,Pair<List<Int>,List<Int>>>,Int>):Int=mem.getOrPut(Pair(Pair(i,j),Pair(w,v))){
    if(i==0) {
      0
    }
    else {
    Math.max(solve(i-1,j,w,v,mem),if(w[i-1] <=j) {solve(i-1,j-w[i-1],w,v,mem)+v[i-1]} else {0}) 
    }
   } 
   
    
  @JvmStatic fun main(args:Array<String>) {
    val (N,W)=readLine()!!.split(" ").map(String::toInt)
    val (weight,value)=(1..N).map {
      val (w,v)=readLine()!!.split(" ").map(String::toInt)
      Pair(w,v)
    }.unzip()
    val memo=hashMapOf<Pair<Pair<Int,Int>,Pair<List<Int>,List<Int>>>,Int>()
    println(solve(N,W,weight,value,memo))
  }
}


Measured memory_bytes: 65644
import java.util.*;
public class Main {
    public static void main(String[] args){
        Main main = new Main();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), D = sc.nextInt();
        long ans = 0;
        for(int d=22;d<=D;d++){
            int ten = d/10, one = d%10;
            if(one>=2&&ten>=2&&one*ten<=m) ans += 1;
        }
        return ans;
    }
}


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

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
}

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



int main() {
  
  int N, M;
  long long K;
  scanf("%d %d", &N, &M);
  scanf("%lld", &K);

  vector<int> A(N);
  for(int i=0;i<N;i++){ scanf("%d", &A[i]); }

  vector<int> B(M);
  for(int i=0;i<M;i++){ scanf("%d", &B[i]); }

  vector<long long> SA(N+1);
  SA[0] = 0;
  for(int i=0;i<N;i++){ 
    SA[i+1]=SA[i]+A[i]; 
  }

  vector<long long> SB(M+1);
  SB[0] = 0;
  for(int i=0;i<M;i++){ 
    SB[i+1]=SB[i]+B[i]; 
  }

  // for(int i=0;i<N;i++){ printf("%d ",SA[i]); } printf("\n");
  // for(int i=0;i<M;i++){ printf("%d ",SB[i]); } printf("\n");

  int j = M;
  int SK = 0;
  for(int i=0;i<N+1;i++){
    
    while (SA[i]+SB[j]>K && j>-1){ j--; }
    if(j==-1){ break; }
    SK = max(SK, i+j);
  }


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

  return 0;
}




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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;

  scanf("%d", &n);

  vector<int> origin(n);
  vector<int> v(n);

  REP (i, n) {
    int a;
    scanf("%d", &a);
    v[i] = a;
    origin[i] = a;
  }

  sort(v.begin(), v.end());

  int median = v[v.size() / 2];
  int small = v[v.size() / 2 - 1];

  REP (i, n) {
    if (origin[i] < median) printf("%d\n", median);
    else printf("%d\n", small);
  }
}


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

int main(void)
{
	unsigned long long x, y;
	cin >> x >> y;

	for (int i = 0; ; i++) {
		if (x > y) {
			cout << i << endl;
			return 0;
		}
		x *= 2;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, ans=0, tmp=0;
    cin >> N;	
    vector<int> a(1e5+1, 0);
    for(int i=0; i<N; i++){
	cin >> tmp;
	a[tmp]++;
    }

    for(int i=0; i<1e5+1-2; i++){
	tmp = a[i]+a[i+1]+a[i+2];
	ans = max(ans, tmp);
    }

    cout << ans << endl;

}



Measured memory_bytes: 640