akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
void fastio(){ios_base::sync_with_stdio(false); cin.tie(0);}

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 1024;

int n, x, y;
vector<pii> co;

ld dist(pii a, pii b){
	ld xi = ld(a.first);
	ld xf = ld(b.first);
	ld yi = ld(a.second);
	ld yf = ld(b.second);
	return sqrt(((xf-xi)*(xf-xi))+((yf-yi)*(yf-yi)));
}

int main() {
	ri(n);
	forn(i, n){
		rii(x, y);
		co.pb({x, y});
	}
	sort(all(co));
	ld ans = 0;
	forn(i, n-1){
		ans+= dist(co[i], co[i+1]);
	}
	ll div = 1;
	forr(i, 1, n+1) div*=i;
	while(next_permutation(all(co))){
		forn(i, n-1) ans+=dist(co[i], co[i+1]);
	}
	ans/=(ld(div));
	cout << setprecision(9) << fixed << ans;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main() {
  int X,Y,Z,K;
  cin >> X >> Y >> Z >>K;
  vector<ll> A(X);
  vector<ll> B(Y);
  vector<ll> C(Z);
  rep(i,X) cin >> A[i];
  rep(i,Y) cin >> B[i];
  rep(i,Z) cin >> C[i];

  sort(C.begin(),C.end(),greater<ll>());
  vector<ll> AB(X*Y);
  rep(i,X){
    rep(j,Y) AB[i*Y+j]=A[i]+B[j];
  }
  sort(AB.begin(),AB.end(),greater<ll>());

  vector<ll> ABK(min(K,X*Y));
  rep(i,min(K,X*Y)) ABK[i]=AB[i];
  
  vector<ll> ABC(min(K,X*Y)*Z);
  rep(i,min(K,X*Y)){
    rep(j,Z) ABC[i*Z+j]=ABK[i]+C[j];
  }

  sort(ABC.begin(),ABC.end(),greater<ll>());

  rep(i,K){
    cout << ABC[i] << endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 

using ll = long long;

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

constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll mod){ll r=1;while(e>0){if(e&1)r=(r%mod)*(b%mod)%mod;b=(b%mod)*(b%mod)%mod;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i < v.size()-1)s<<", ";}s<<']';return s;}

int main(){

    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    
    int cnt = 0;
    int now = 1;
    rep(i, n){
        if(a[i] == now){
            ++cnt;
            ++now;
        }
    }
    if(cnt == 0) {
        ppp(-1);
    }
    else {
        ppp(n-cnt);
    }


    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main(void){
  int a,i;
  char s[4];
  char S[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  scanf("%s", s);
  for(i=0; i < 7; i++){
    if(strcmp(s,S[i]) ==0){
      a = 7-i;
    }
  }
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int a, b, c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  cout << a + b + c + pow(2, k) * max({a, b, c}) - max({a, b, c}) << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

//コピペ用
//		int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '),i=>int.Parse(i));
//      int a = int.Parse(Console.ReadLine());


class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
        int n = int.Parse(Console.ReadLine());

        int c = 0;
        for(int i=1;i<=n;i++){
            if(i<=9) c++;
            else if(100<=i&&i<=999) c++;
            else if(10000<=i&&i<=99999) c++;
        }

        Console.WriteLine(c);
    }
}

Measured memory_bytes: 11092
def bubble_sort(a, n):
  for i in range(n-1, 0, -1):
    j = i
    while (j < n) and (a[j][1] < a[j-1][1]):
      tmp = a[j-1]
      a[j-1] =  a[j]
      a[j] = tmp
      j += 1
  return a

def selection_sort(a, n):
  for i in range(n):
    minj = i
    for j in range(i, n):
      if a[j][1] < a[minj][1]:
        minj = j
    if i != minj:
      a[minj], a[i] = a[i], a[minj]
  return a

n = int(input())
input1 = input().split()
a = list(input1)
b = a[:]
a = bubble_sort(a, n)
b = selection_sort(b, n)


#*をつけることでタプル（の中に入れた型）として実行が可能になる　タプルはオブジェクトの変更ができない
print(*a)
print("Stable")
print(*b)

if a == b:
  print("Stable")
else:
  print("Not stable")


#a = b[:]とは何か：リストのindexとobjectをまんまコピー
#print(*aとは) タプルとして出力



Measured memory_bytes: 5616
n,m = (int(i) for i in input().split())
x,y = [[] for i in range(n+1)],[0]*(n+1)
y[0] = 1
for i in range(n+m-1):
    a,b = (int(i) for i in input().split())
    x[a].append(b)
    y[b]+=1
ans,q = [0]*(n+1),[y.index(0)]
while q:
    p = q.pop()
    for i in x[p]:
        y[i]-=1
        if not y[i]:
            q.append(i)
            ans[i] = p
for i in ans[1:]: print(i)

Measured memory_bytes: 21204
def factorization(n):
    from collections import Counter
    arr = Counter()
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if len(arr.keys()) == 0 and n != 1:
        arr[n] = 1

    return arr


N = int(input())

primes = factorization(N)

cnt = 0
for p, n in primes.items():
    k = 1
    while n >= k:
        cnt += 1
        n -= k
        k += 1
print(cnt)


Measured memory_bytes: 9724
#include <stdio.h>

int main()
{
    int L, R, d;
    scanf("%d %d %d", &L, &R, &d);
    
    int search = L / d;
    int count = 0;
    for (int i = L; i <= R; i++){
        if (i%d == 0) count++;
    }
    printf("%d", count);
    return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World\n";
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char c1,c2,c3,c4,c5,c6,c7,c8,c9;
    cin>>c1>>c2>>c3;
    cout<<endl;
    cin>>c4>>c5>>c6;
    cout<<endl;
    cin>>c7>>c8>>c9;
    
    cout<<c1<<c5<<c9;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a[5], k;
  for(int i=0; i<5; i++){
    cin >> a[i];
  } 
  cin >> k;
  bool flag=true;
  for(int i=0; i<5; i++){
    for(int j=i+1; j<5; j++){
      if(abs(a[i]-a[j])>k) flag = false;
    }
  } 
  if(flag == false) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
} 

Measured memory_bytes: 256
import collections

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

# ap+aq == p-q (p>q)
# p-ap = q+aq

mp = {}
ans = 0
for p in range(N):
    if p-A[p]+1 in mp:
        ans += mp[p-A[p]+1]
    if p+A[p]+1 in mp:
        mp[p+A[p]+1] += 1
    else:
        mp[p + A[p] + 1] = 1

print(ans)




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

using namespace std;

int64_t n, s;

int64_t f(int64_t b, int64_t n)
{
  if (n < b) return n;
  return f(b, n/b) + (n % b);
}

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

  if (s > n) {
    cout << -1 << endl;
    return 0;
  }

  if (s == n) {
    cout << n+1 << endl;
    return 0;
  }

  for (int64_t b = 2; b*b <= n; b++) {
    if(f(b,n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  int64_t min_b = -1;
  for (int64_t p = 1; p*p < n; p++) {
    int64_t b = (n - s)/p + 1;
    if (b < 2) continue;
    if (f(b,n) == s) {
      min_b = b;
    }
  }

  cout << min_b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int h, w, map[1002][1002], ans = 0;
set<int>s[1000010];
vector<int>v[1000010];
bool b[1000007];
signed main() {
	cin >> h >> w;
	for1(i, h)for1(j, w)cin >> map[i][j];
	for1(i, h - 1)for1(j, w) {
		v[min(map[i][j], map[i + 1][j])].push_back(max(map[i][j], map[i + 1][j]));
		b[max(map[i][j], map[i + 1][j])] = 1;
	}
	for1(i, h)for1(j, w - 1) {
		v[min(map[i][j], map[i][j + 1])].push_back(max(map[i][j], map[i][j + 1]));
		b[max(map[i][j], map[i][j + 1])] = 1;
	}
	for1(i, h*w) {
		if (!b[i]) {
			for (int j : v[i])s[j].insert(i);
		}
		else {
			if (s[i].size() >= 2)ans++;
			for (int j : v[i])for (int k : s[i])s[j].insert(k);
		}
		s[i].clear();
	}
	cout << ans << endl;
}


Measured memory_bytes: 160036
import java.util.Scanner;

//Exit Survey
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long s = 0;
		for(int i=0;i<n;i++)s+=sc.nextLong();
		System.out.println(s/n);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef unsigned long long LL;
const int N = 100003;
int n;
LL a[N], b[61], sum, res;
inline void insert(LL x){
	for(Rint i = 60;~i;-- i)
		if((x >> i) & 1)
			if(!b[i]){
				b[i] = x; return;
			} else x ^= b[i];
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%llu", a + i), sum ^= a[i];
	for(Rint i = 1;i <= n;i ++) insert(a[i] &= ~sum);
	for(Rint i = 60;~i;-- i) res = max(res, res ^ b[i]);
	printf("%llu\n", res * 2 + sum);
}

Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func primeFactor(n int) map[int]int {
	m := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			m[i]++
			n /= i
		}
	}
	if n != 1 {
		m[n] = 1
	}
	return m
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	pf := primeFactor(n)

	ans := 0
	for k := range pf {
		for i := 1; pf[k] >= i; i++ {
			pf[k] -= i
			ans++
		}
	}

	puts(ans)
}


Measured memory_bytes: 1788
arr = Array.new
arr2 = Array.new
arr3 = Array.new
for i in 0..4 do
  arr[i] = gets.chomp.to_i
end
for j in 0..4 do
  arr2[j] = arr[j] % 10
  if arr2[j] == 0 then
    arr3[j] = arr[j]
  else
  arr3[j] = arr[j] - arr2[j] + 10
  end
end
arr2.delete(0)
m = arr2.min
if m == nil then
  puts arr3.inject(:+)
else
  puts arr3.inject(:+) + m - 10
end

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node
{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void delete(int);
void insert(int);

int main()
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ )
    {
      scanf("%s%d", com, &key);
      if ( com[0] == 'i' ) {insert(key); np++; size++;}
      else if ( com[0] == 'd' )
	{
	  if (strlen(com) > 6)
	    {
	      if ( com[6] == 'F' ) deleteFirst();
	      else if ( com[6] == 'L' ) deleteLast();
	    } else
	    {
	      delete(key); nd++; 
	    }
	  size--;
	  }
    }
  
  printList();
  return 0;
}

NodePointer listSearch(int key)/*x->keyがkeyと同じならそのポインタを返す*/
{
  NodePointer x;
  for(x=nil->next;x!=nil;x=x->next)
    {
      if(x->key==key)return x;
    }
  return NULL;
}

void init()/*nil（head）を定義している*/
{
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList()
{
  NodePointer cur = nil->next;
  int isf = 1;
  while(1)
    {
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
    }
  printf("\n");
}

void deleteNode(NodePointer t)
{
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst()
{
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast()
{
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key)
{
  NodePointer t = listSearch(key);
  if(t == NULL) return;
  deleteNode(t);
}


void insert(int key)
{
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}



Measured memory_bytes: 32992
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC170
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            for(int i = 0;i<5;i++){
                if(s[i]==0){
                    WriteLine(i+1);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 28032
#include <bits/stdc++.h>
	#define hell                         1000000007 
	#define M                            1000000007
	#define Maxi                      10000000000000000
	#define lcm(a,b)                     (a*b)/__gcd(a,b)
	#define ll                           long long

	#define vll                          vector<ll>
	#define vi                           vector<long long>
	#define pll                          vector< pair<ll,ll> >
	#define pb                           push_back
	//#define mp                           make_pair
	#define all(v)                       v.begin(),v.end()
	#define lbnd                         lower_bound
	#define ubnd                         upper_bound
	#define bs                           binary_search
	#define F                            first
	#define S                            second
	#define rep(i,a,b)                   for(i=a;i<b;i++)
	#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
	#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
	#define ret(x)                       return cout<<x,0;
	#define dbg(x)                       cout << #x << " is " << x << endl;
	//#define endl                           '\n'


	// Debug //

	#define trace(x)                 cerr << #x << ": " << x << endl;
	#define trace1(x)                cerr << #x << ": " << x << endl;
	#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
	#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
	#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
	#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
	#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


	using namespace std;
	

	
	int main()
	{

	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);cout.tie(NULL);
		

		
		
		ll n;
		cin>>n;
		cout<<((n-1)*(n))/2<<endl;

		return 0;
		}
	











Measured memory_bytes: 256
N, M = map(int, input().split())
A = [0] * N
cnt = 0
for i, x in enumerate(input().split()):
  A[i] = int(x) % M
sumA = 0
for i in range(N):
  sumA += A[i]
  sumA %= M
  A[i] = sumA
A += [0]
index = {}
for i in set(set(A)):
  index[i] = 0
for a in A:
  index[a] += 1
for i in index.values():
  cnt += i * (i - 1) // 2
print(cnt)

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

int main() {
    int n = 0;
    int max = -10000000;
    int min = 10000000;
    long sum = 0;

    cin >> n ;

    long long array[n];

    for(int i = 0 ; i < n ; i ++){
        cin >> array[i];
    }

    for(int maxCounter = 0 ; maxCounter < n ; maxCounter ++){
        if(max < array[maxCounter]){
            max = array[maxCounter];
        }
    }

    for(int minCounter = 0 ; minCounter < n ; minCounter ++){
        if(min > array[minCounter]){
            min = array[minCounter];
        }
    }

    for(int sumCounter = 0 ; sumCounter < n ; sumCounter ++){
        sum += array[sumCounter];
    }

    cout << min << " " << max << " " << sum << "\n";
}


Measured memory_bytes: 3136
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn._

object Main extends App {

  val Array(m, n, k) = readLine.trim.split(' ').map(_.toInt)
  val weight = Array.tabulate(n){_ ⇒ readLine.trim.toInt}
  val request = Array.tabulate(k){_ ⇒ readLine.trim.toInt - 1}
  val nodes = Array.fill(k + 1){ArrayBuffer[Edge]()}
  val prev = Array.fill(10001){k}
  for (i ← nodes.indices.tail) {
    nodes(i).append(Edge(i - 1, -10000, 0))
    nodes(i - 1).append(Edge(i, 10000, m))
    nodes(i).last.pair = nodes(i - 1).last
    nodes(i - 1).last.pair = nodes(i).last
  }
  var default = 0L
  for (i ← request.indices.reverse) {
    if (prev(request(i)) != k) {
      if (prev(request(i)) - 1 == i) {
        default += weight(request(i))
      } else {
        nodes(i).append(Edge(prev(request(i)) - 1, 10000 * (prev(request(i)) - 1 - i) - weight(request(i)), 1))
        nodes(prev(request(i)) - 1).append(Edge(i, weight(request(i)) - 10000 * (prev(request(i))  - 1 - i), 0))
        nodes(i).last.pair = nodes(prev(request(i)) - 1).last
        nodes(prev(request(i)) - 1).last.pair = nodes(i).last
      }
    }
    prev(request(i)) = i
  }
  println(pushFlow(nodes, m - 1) - 10000 * k * (m - 1) + request.map(weight).sum - default)
  def pushFlow[I <: Iterable[Edge]](nodes: Array[I], flow: Int): Long = {
    val potential = Array.fill(nodes.length){0L}
    val minCost = Array.fill(nodes.length){Long.MaxValue}
    val queue = mutable.PriorityQueue()(Ordering.by[(Int, Long), Long](_._2).reverse)
    val prev = nodes.map{_.head}
    var result = 0L
    for (_ ← 0 until flow) {
      minCost.indices.foreach(i ⇒ minCost(i) = Long.MaxValue)
      minCost(0) = 0L
      queue.enqueue((0, 0L))
      while(queue.nonEmpty) {
        val (current, currentCost) = queue.dequeue()
        if (current != nodes.length - 1 && minCost(current) == currentCost) {
          for (e@Edge(to, cost, flow) ← nodes(current) if flow > 0) {
            if (minCost(to) > potential(current) + cost - potential(to) + currentCost) {
              minCost(to) = potential(current) + cost - potential(to) + currentCost
              prev(to) = e
              queue.enqueue((to, minCost(to)))
            }
          }
        }
      }
      if (minCost.last != Long.MaxValue) {
        for (i ← nodes.indices if minCost(i) != Long.MaxValue) potential(i) += minCost(i)
        result += potential.last
        var last = nodes.length - 1
        while(last != 0){
          prev(last).flow -= 1
          prev(last).pair.flow += 1
          last = prev(last).pair.to
        }
      }
    }
    result
  }

}

case class Edge(to: Int, cost: Long, var flow: Int) {
  private var mPair: Option[Edge] = None
  def pair: Edge = mPair.get
  def pair_=(edge: Edge) = mPair = Some(edge)
}




Measured memory_bytes: 401548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll inf=1e6;
ll c0[20][20],c1[20][20][20][20];//c0は入力の値を保存、c1は開始地点を変えながらbfsをしたときそれぞれの座標のd（最短距離）を保存するための配列
ll dx[4]={0,0,1,-1},dy[4]={-1,1,0,0};//周辺を探索するときの座標変化
ll h,w;
ll bfs(ll sx,ll sy){
    if(c0[sx][sy]==-1)return 0;//開始地点が壁の時は0を返す。
    ll res=0;//最短距離の最大値の初期化
    ll d=0;//最短距離の値の初期化
    c1[sx][sy][sx][sy]=d;//スタート地点の初期化
    queue<P> que;//未探索の次に探索する座標を保存させるためのqueue
    que.push(P(sx,sy));//スタート地点の座標をqueueに保存
    while(!que.empty()){//bfsが終わったらqueueにはいる座標はなくなるので、queueになくなるまでループを繰り返す
        P p=que.front();que.pop();//queueを取り出す。
        rep(0,i,4){
            ll nx=p.first+dx[i],ny=p.second+dy[i];//多分now_xの略、今現在見ている座標を意味する。
            if(0<=nx && h>nx && 0<=ny && w>ny){//範囲内の座標の条件
                ll d=c1[sx][sy][nx][ny];
                if(d==inf){//未探索の条件
                    que.push(P(nx,ny));//次の探索範囲に追加
                    c1[sx][sy][nx][ny]=c1[sx][sy][p.first][p.second]+1;//最短距離をc1に入れる
                    res=max(c1[sx][sy][nx][ny],res);//ここまでの最大値を入力
                }
            }
        }
    }
    return res;
}
int main(void){
    cin>>h>>w;//座標の大きさの入力
    rep(0,i,h){
        string s0;
        cin>>s0;
        rep(0,j,w){
            string s1=s0.substr(j,1);//座標ごとの文字をs1に入力
            if(s1=="#"){
                c0[i][j]=-1;//壁があるとき、c0に-1を入力
            }else{
                c0[i][j]=inf;//未探索の印にc0にinfを入力
            }
        }
    }
    ll ans=0;//答えの初期化
    rep(0,i0,h){
        rep(0,j0,w){
            rep(0,i1,h){
                rep(0,j1,w){
                    c1[i0][j0][i1][j1]=c0[i1][j1];//c0によりc1を初期化、(i0,j0)は開始地点。
                }
            }
            ans=max(bfs(i0,j0),ans);//それぞれの開始地点においてbfsをし、最大値をとる。
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1536
N = int(input())
P = input().replace(" ","")
Q = input().replace(" ","")

from collections import deque
q = deque()
q.append("")

a = -1
b = -1
cnt = 0
while q:
  cnt += 1
  st = q.popleft()
  if len(st) == N:
    if st == P:
      a = cnt
    if st == Q:
      b = cnt
    continue
  for i in range(1, N + 1):
    if str(i) not in st:
      q.append(st + str(i))

print(abs(a - b))


Measured memory_bytes: 11848
#include <stdio.h>
#define S 1000000000
int N[500000], L[250001], R[250001], count=0;
 
int main(){
  int i, n;
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&N[i]);
 
  mergesort(0,n);
 
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",N[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(left, mid, right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++)
    L[i] = N[left + i];
  for(i = 0; i < n2; i++)
    R[i] = N[mid + i];
  L[n1] = S;
  R[n2] = S;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      N[k] = L[i];
      i = i + 1;
      count++;
    }
    else{
      N[k] = R[j];
      j = j + 1;
      count++;
    }  
  }
}
 
void mergesort(left, right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(left, mid);
    mergesort(mid, right);
    merge(left, mid, right);
  }
}

Measured memory_bytes: 4508
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = [0] + LI()
mod = 10**9+7

count = [0]*(N+1)
for i in range(1,N+2):
    if count[A[i]] != 0:
        a = count[A[i]]
        b = i
    else:
        count[A[i]] = i


kaijou = [1]
for i in range(1,N+2):
    kaijou.append((kaijou[-1]*i) % mod)


def nCr(n,r):
    if n < r:
        return 0
    return (kaijou[n]*pow(kaijou[r],mod-2,mod)*pow(kaijou[n-r],mod-2,mod)) % mod


for k in range(1,N+2):
    print((nCr(N+1,k)-nCr(N+a-b,k-1)) % mod)



Measured memory_bytes: 92136
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];
        sort(a.begin(), a.end());

        int m = 1;
        int ret = -1;
        for(int i=1; i<n; ++i){
            if(a[i] != a[i-1]){
                if(m > n / 2)
                    ret = a[i-1];
                m = 1;
            }else{
                ++ m;
            }
        }
        if(m > n / 2)
            ret = a[n-1];

        if(ret == -1)
            cout << "NO COLOR" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 4852
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;
    int mm = stoi(S.substr(5, 2));
    int dd = stoi(S.substr(8, 2));

    if (mm <= 4 and dd <= 30) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,x=0,y=0,p=0,q=0,r=0,d=0;
    cin>>n>>x>>y;
    int f[n]={0};
    for(int i=1;i<n;++i)
    {
        for(int j=i+1;j<=n;++j)
        {
            p=abs(j-i);
            q=abs(x-i)+1+abs(j-y);
            r=abs(y-i)+1+abs(j-x);
            d=min({p,q,r});
            f[d]++;
        }
    }
    for(int i=1;i<n;++i)
    {
        cout<<f[i]<<endl;
    }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
        a[i] -= i+1;
    }

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

    ll kijun;

    /*
    if(n % 2 == 0) {
        kijun = (a[n/2] + a[n/2-1])/2;
    } else {
        kijun = a[n/2];
    }
    */



    REP(i, n) {
        ans += abs(a[i] - a[n/2]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   string s;
   cin>>s;
   bool ok=false;
   for(int i=0;i<=2;i++){
      if(s[i]==s[i+1])ok=true;
   }
   if(ok){
      cout<<"Bad"<<endl;
   }else{
      cout<<"Good"<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
n = int(input())

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

cnt = 0
for i in range(0,len(A)-1):
  if A[i] > A[i+1]:
    d = (A[i]-A[i+1])
    cnt = cnt + d
    A[i+1] = A[i+1] + d

print(cnt)

Measured memory_bytes: 32156
#!/usr/bin/env python
import sys
f = sys.stdin
n = int(f.readline())

result = ':('
x2 = int(n / 1.08)
if int(x2 * 1.08) == n:
    result = x2
x1 = x2 - 1
if int(x1 * 1.08) == n:
    result = x1
x3 = x2 + 1
if int(x3 * 1.08) == n:
    result = x3

print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a + b + c >= 22) ? "bust" : "win");
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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; }

void Main(){
    int n;
    cin >> n;
    VI av(n);
    REP(i, n) cin >> av[i];
    int ans = 0;
    REP(i, n) ans ^= av[i];
    REP(i, n) {
        int j;
        j = ans^av[i];
        cout << j << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

int main(){
    int A,B;
    cin >> A >> B;
    vector<string>  S(100);
    string W(100,'.'), b(100,'#');
    for(int i=0;i<100;i++){
        if(i < 50) S[i] = W;
        else S[i] = b;
    }

    int h=0,w=0;
    while(B-1){
        S[h][w] = '#';
        w += 2;
        B--;
        if(w >= 100){
            h += 2;
            if(w == 100) w = 1;
            else w = 0;
        }
    }

    h = 99, w = 0;
    while(A-1){
        S[h][w] = '.';
        w += 2;
        A--;
        if(w >= 100){
            h -= 2;
            if(w == 100) w = 1;
            else w = 0;
        }
    }

    cout << 100 << " " << 100 << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << S[i][j];
        }
        cout << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int N = 45;
int fib[N];

int main()
{
    int n;
    scanf("%d", &n);
    fib[0] = fib[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        fib[i] = fib[i-1] + fib[i-2];
    }
    printf("%d\n", fib[n]);
    return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int N,A,B,C;
int l[8];
int dfs(int k,int a,int b,int c){
  while(k<=N){
  if(k==N){
    if(min(a,min(b,c))>0){
    return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
    else{
      return 9999999;
    }
  }
    else{
      int w=dfs(k+1,a,b,c);
      int x=dfs(k+1,a+l[k],b,c)+10;
      int y=dfs(k+1,a,b+l[k],c)+10;
      int z=dfs(k+1,a,b,c+l[k])+10;
      return min(min(w,x),min(y,z));
    }
  }
}
int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  cout<<dfs(0,0,0,0)<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    ret = 0
    print(sum((S[n:n+3] == 'ABC') for n in range(N-2)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>

int main (){
    int N,X;
    scanf("%d %d",&N,&X);
    int l[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&l[i]);
    }
    int bound=0;
    int count=0;
    while(bound<=X){
        bound+=l[count];
        count++;
        if(count==N+1) break;
    }
    printf("%d",count);
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		int[] r = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum = sum + (r[i] - l[i] + 1);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26724
//#include <cmath>
//#include <cstdio>
//#include <cstring>
//#include <cstdlib>
//#include <iostream>
//#include <algorithm>
//using namespace std;
//char s[3010];
//int n,i,a,b,j,p,q;
//int main () {
////	freopen ("队列变换.in","r",stdin);
////	freopen ("队列变换.out","w",stdout);
//	scanf ("%d",&n);
//	for (i=1;i<=n;i++)
//		cin>>s[i];
//	a=1;
//	b=n;
//	for (i=1;i<=n;i++) {
//		for (j=i;j<=i+79&&j<=n;j++) {
//			if (s[a]==s[b]) {
//				p=a;
//				q=b;
//				while (p<=q&&s[p]==s[q]){
//					p++;
//					q--;
//				}
//				if (s[p]<=s[q]) {
//					printf ("%c",s[a]);
//					a++;
//				} 
//				else {
//					printf ("%c",s[b]);
//					b--;
//				}
//			}
//			else {
//				if (s[a]>s[b]) {
//					printf ("%c",s[b]);
//					b--;
//				} 
//				else {
//					printf ("%c",s[a]);
//					a++;
//				}
//			}
//		}
//		i+=79;
//		puts ("");
//	}
//	return 0;
//}
#include <cstdio>
long long n,ans,b,c,s,i;
int fj(int n){
    int s=1;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            int a=0;
            while(n%i==0){
                n/=i;
                a++;
            }
            s=s*(a+1);
        }
    }
    if(n>1) s=s*2;
    return s;
}
int main () {
  scanf ("%lld",&n);
  for (i=1;i<n-1;i++) 
    s+=fj (n-i);
  printf ("%lld\n",s+1);
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tmp;
    for(int i=1;i<=5&&cin>>tmp;i++)
        if(tmp!=i)
            return cout<<i,0;
    return 0;
}


Measured memory_bytes: 3584
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    T = input()
    res = 0
    for s, t in zip(S, T):
        if s != t:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    }
  sort(v.begin(),v.end());
  string t = "";
  for(int i=0;i<n;i++){
    t+=v[i];
    }
  cout<<t<<endl;
  }


Measured memory_bytes: 3620
import heapq

N, M = map(int, input().split())

A = [[] for _ in range(M)]
Q = []

for _ in range(N):
	day, money = map(int, input().split())
	if day <= M:
		A[day - 1].append(money)

ans = 0

for i in range(0, M):
	for money in A[i]:
		heapq.heappush(Q, -money)
	# print(Q)
	if Q:
		ans += heapq.heappop(Q)
		
print(-ans)

Measured memory_bytes: 72352
/*BINH :))*/
#include<bits/stdc++.h>
#include <queue>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a,u,v;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL cout<<endl
#define maxn 1005
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#pragma GCC optimize("Ofast")
int n,m,k,kc,xa;
int a[100000],f[100000];
int main(){
    IO
    cin>>n;
    FOR(i,1,n){
        cin>>a[i];
    }
    a[0] = INT_MAX;
    FOR(i,2,n){
        f[i] = min(abs(a[i]-a[i-1])+f[i-1],abs(a[i]-a[i-2])+f[i-2]);
    }
    cout<<f[n];
}
    

Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;
int n;


/*----------------------------------------------------------------*/
signed main(){
	
	cin >> n;
	vll a(n);
	map<int,int> mp1,mp2;
	rep(i,n){
		cin >> a[i];
		mp1[i+1-a[i]]++;
		mp2[i+1+a[i]]++;
	}

	int ans = 0;
	rep(i,n){
		int a1 = i+1-a[i];
		if(mp2.find(a1) != mp2.end()){
			ans += mp2[a1];
		}
		int a2 = i+1+a[i];
		if(mp1.find(a2) != mp1.end()){
			ans += mp1[a2];
		}
	}

	cout << ans/2 << endl;





	
	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc166.contest.atcoder.jp/tasks/abc166_e

Measured memory_bytes: 28028
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

map<ll, ll> ans;

ll attack(ll n){
    if(n == 0) return 0;
    if(n == 1) return 1;
    if(ans[n] != 0) return ans[n];
    return ans[n] = 1 + 2 * attack(n / 2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ans[0] = 0;
    ans[1] = 1;
    ll h;
    cin >> h;
    cout << attack(h) << endl;

    return 0;
};


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int a, b;
  cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a > 5 && a < 13) cout << b/2 << endl;
  else cout << b << endl;
  return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, X, Y = map(int, readline().split())

    X -= 1
    Y -= 1

    ans = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            d = min(j - i, abs(i - X) + 1 + abs(Y - j))
            ans[d] += 1

    print('\n'.join(map(str, ans[1:])))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74464
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n,k;cin>>n>>k;
	int ans=0,x;
	rep(i,n) {cin>>x;ans+=2*min(x,k-x);}
	cout<<ans<<endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  int sum(A[0]);
  for(int i(1);i<N;i++){
    sum^=A[i]; 
  }
  if (sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 088 _ c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#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)

int main()
{
  int C[3][3];
  int b2,b3,a2,a3,t,d,t1,t2,t3;
  REP(i,3) {
    REP(j,3) {
      cin >> C[i][j];
    }
  }
  b2 = C[0][0] - C[0][1];
  b3 = C[0][0] - C[0][2];
  a2 = C[0][0] - C[1][0];
  a3 = C[0][0] - C[2][0];
  
  REP(i,3) {
    REP(j,3) {
      if (i == 1) C[i][j] += b2;
      if (i == 2) C[i][j] += b3;
      if (j == 1) C[i][j] += a2;
      if (j == 2) C[i][j] += a3;
    }
  }
  
  REP(i,3) {
    if (i == 0) {
      t = C[i][0];
      continue;
    }
    if (t != C[i][0]) {
      d = t - C[i][0];
      REP(j,3) {
        C[i][j] += d;
      }
    }
    
  }
  
  t1 = C[0][0];
  t2 = C[0][1];
  t3 = C[0][2];
  FOR(i,1,3) {
    if (t1 == C[i][0] && t2 == C[i][1] && t3 == C[i][2]) {
    } else {
      cout << "No" << endl;
      return 0;
     }
  }
  cout << "Yes" << endl;
  
  return 0;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int nowX = 0, nowY = 0, nowT = 0;
  bool ok = true;
  for(int i=0; i<n; i++){
    int t, x, y;
    cin >> t >> x >> y;
    int tmp = abs(nowX - x) + abs(nowY - y);
    // cout << "x:" << nowX << " y:" << nowY << " time:" << tmp << endl;
    if(tmp > t - nowT){
      ok = false;
    }else if(tmp < t - nowT){
      if((tmp % 2 != 0 && (t - nowT) % 2 == 0) || (tmp % 2 == 0 && (t - nowT) % 2 != 0)) ok = false;
    }
    nowX = x;
    nowY = y;
    nowT = t;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256