akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
















int main(){
    ll n, x, y;
    cin >> n >> x >> y;
    for(ll k = 1; k < n; k++){
        ll s = 0;
        for(ll i = 1; i <= n - k; i++){
            if(i > x){
                ll t = i - x;
                if(k - t < 1){
                    s++;
                }
                else{
                    if(i + k > y){
                        if(y + k - t - 1 <= n){
                            s++;
                        }
                    }
                    else{
                        if(i + k < y - (k - t - 1)){
                            s += 2;
                        }
                        else if(i + k == y - (k - t - 1)){
                            s++;
                        }
                        
                        if(k - t - 1 > 0 && y + k - t - 1 <= n){
                            s++;
                        }
                    }
                }
            }
            else{
                if(i + k > x){
                    if(i + k <= y - (k - (x - i) - 1)){
                        if(i + k < y - (k - (x - i) - 1)){
                            s += 2;
                        }
                        else if(i + k == y - (k - (x - i) - 1)){
                            s++;
                        }
                        
                        if((k - (x - i) - 1) > 0 && y + (k - (x - i) - 1) <= n){
                            s++;
                        }
                    }
                    else{
                        if(y + (k - (x - i)) <= n + 1){
                            s++;
                        }
                    }
                }
                else{
                    s++;
                }
            }
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
    #include<cmath>
    using namespace std;
    int main(void){
        // Your code here!
        
        long long N;
        long M;
        long A[16448];
        long ans;
        
        cin >> N >> M;
        ans = N;
        
        for(int i=0;i<M;i++){
            
            cin >> A[i];
            ans = ans -A[i];
            
        }
        
        if(ans<0){
            ans = -1;
        }
     
        
        cout << ans <<endl;
        return 0;
    }

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mpr make_pair
#define MX 100010
#define ui unsigned int
#define ll long long
#define ld long double 
#define fi first
#define se second
#define endl '\n'
#define debug(bug) cout<<"akshat"<<" "<<bug<<endl
#define printarray(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define printvector(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define dd long double 
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
const ll inf=1000000000000;
const int mod=1000000007;
// priority_queue <int, vector<int>, greater<int> > pq; //minimum priority queue
int n;
vector<int> adj[MX];
ll dp[MX][2]; // 0 white 1 black

ll mul(ll x,ll y)
{
  return ((x%mod)*(y%mod))%mod;
}

ll add(ll x,ll y)
{
  return ((x%mod)+(y%mod))%mod;
}

void solve(int u,int p)
{
  if(adj[u].size()==1)
  {
    dp[u][1]=1;
    dp[u][0]=1;
  }
  ll mx1=1;
  ll mx2=1;
  for(int i=0;i<adj[u].size();i++)
  {
    int v=adj[u][i];
    if(v==p)
    {
      continue;
    }
    solve(v,u);
    mx1=mul(mx1,add(dp[v][0],dp[v][1]));
    mx2=mul(mx2,dp[v][0]);
  }

  dp[u][0]=mx1;
  dp[u][1]=mx2;

}

int main()
{
  fast_io;
  cin>>n;
  for(int i=0;i<n-1;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].pb(y);
    adj[y].pb(x);
  }

  solve(1,-1);

  //cout<<dp[2][1]<<endl;

  cout<<add(dp[1][0],dp[1][1])<<endl;
 
  return 0;
}


Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=0 and b>=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    int en = min(b,-1);
    int len = en-a+1;
    if(len%2){
        cout<<"Negative"<<endl;
    }
    else{
        cout<<"Positive"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def kai(n):
    a=""
    for i in reversed(range(len(n))):
        a+=(n[i])
    if n==a:
        return True

a,b=input().split()
cnt=0
for i in range(int(b)-int(a)+1):
    if kai(str(int(a)+i)):
        cnt+=1

print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int yoke = 0;
		int count = 0;
		for(int i = 0;i<3;i++) {
			count += a%10;
			a -= a%10;
			a /= 10;
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 23636
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
    lines.forEach(function(val){
        const dataStrings = val.split(' ');
        const a = Number(dataStrings[0]);
        const op = dataStrings[1];
        const b = Number(dataStrings[2]);
        let result;
        switch (op) {
            case '+':
                console.log(a + b);
                break;
            case '-':
                console.log(a - b);
                break;
            case '*':
                console.log(a * b);
                break;
            case '/':
                console.log(Math.floor(a / b));
                break;
            default:
            }
    });


Measured memory_bytes: 15408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC014
{
    public class C
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var H = int.Parse(input[0]);
            var W = int.Parse(input[1]);
            var K = int.Parse(input[2]);
            var field = Enumerable.Range(0, H).Select(_ => Console.ReadLine().Trim().ToCharArray()).ToArray();

            var beginY = Array.FindIndex(field, line => line.Contains('S'));
            var beginX = Array.IndexOf<char>(field[beginY], 'S');

            var q = new Queue<Tuple<int, int, int>>(); // [x, y, rest]
            q.Enqueue(Tuple.Create(beginX, beginY, K));
            field[beginY][beginX] = '#';

            var minX = beginX;
            var maxX = beginX;
            var minY = beginY;
            var maxY = beginY;

            var dist = new[] { 1, 0, -1, 0, 1 };
            while (q.Count > 0)
            {
                var t = q.Dequeue();
                var x = t.Item1;
                var y = t.Item2;
                var rest = t.Item3;
                minX = Math.Min(minX, x);
                maxX = Math.Max(maxX, x);
                minY = Math.Min(minY, y);
                maxY = Math.Max(maxY, y);

                if (rest == 0) { continue; }
                for (int i = 0; i < 4; i++)
                {
                    var nx = x + dist[i];
                    var ny = y + dist[i + 1];

                    if (nx < 0 || nx >= W || ny < 0 || ny >= H) { continue; }
                    if (field[ny][nx] == '#') { continue; }
                    field[ny][nx] = '#';
                    q.Enqueue(Tuple.Create(nx, ny, rest - 1));
                }
            }

            var d = int.MaxValue;
            d = Math.Min(d, minX);
            d = Math.Min(d, minY);
            d = Math.Min(d, W - 1 - maxX);
            d = Math.Min(d, H - 1 - maxY);

            Console.WriteLine(1 + (d + K - 1) / K);
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 21268
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B;
  cin >> A >> B;
  int N = A.size();
  int c = 0;
  for(int i = 0; i < N; i++) {
    if(A.at(i) != B.at(i)) {
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3908
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

class dd:
	def __init__(self, k):
		d='zzzzzz'
		self.v = [d]*k
		#self.v[0]='a'
		#pa(self.v)
		
	def add(self, v):
		if v in self.v:
			pass
		elif self.v[-1] <= v:
			pass
		else:
			for i,c in enumerate(self.v):
				if v < c:
					self.v = self.v[:i]+[v]+self.v[i:-1]
					break
		#pa((v, self.v))
				
	def get(self):
		return self.v[-1]


def main():
	#a = int(input())
	#b , c = IN()
	s = input()
	k = int(input())
	rs=dd(k)
	for i in range(1, 5+1):
		for j in range(len(s)-i+1):
			v = s[j:j+i]
			rs.add(v)
			
	r=rs.get()
	print(r)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int collatz(int n) {
    if(n%2 == 0) return n/2;
    else return n*3+1;
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    int a;
    cin>>a;
    set<int> s;
    s.insert(a);
    int i = 1;
    int last = a;
    while(true) {
        i++;
        int x = collatz(last);
        if(s.find(x) != s.end()) {cout<<i; return 0;}
        // cout<<x<<endl;
        s.insert(x);
        last = x;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	char S[10];
	int N,K,i;

	scanf("%d",&N);
	scanf("%s",&S);
	scanf("%d",&K);

	for(i=0;i<N;i++){
		if(S[i]!=S[K-1]){
			S[i]='*';
		}
	}

	printf("%s\n",S);

}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	map<int, int> m;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		m[A]++;
	}
	priority_queue<pair<int, int>> q;
	for (const auto& i : m) {
		q.push(make_pair(i.second, i.first));
	}
	while (!q.empty()) {
		auto a = q.top();
		if (a.first == 1)
			break;
		q.pop();
		if (a.first > 2) {
			a.first -= 2;
			q.push(a);
		} else {
			auto b = q.top(); q.pop();
			b.first -= 1;
			if (b.first > 0)
				q.push(b);
			a.first -= 1;
			q.push(a);
		}
	}
	cout << q.size() << endl;
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


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

    vector<P> ans;
    rep(i, n) {
        if (i == 0) continue;
        ans.emplace_back(0, i);
    }

    vector<P> bridge;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            bridge.emplace_back(i, j);
        }
    }

    assert(bridge.size() == (n - 1) * (n - 2) / 2);
    rep(i, (n - 1) * (n - 2) / 2 - k) {
        ans.push_back(bridge[i]);
    }

    if ((n - 1) * (n - 2) / 2 < k) {
        cout << -1 << endl;
        ret();
    }

    cout << ans.size() << endl;
    for (P p : ans) printf("%lld %lld\n", p.first + 1, p.second + 1);

}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    bool ok = false;
    if (s == "AKIHABARA") ok = true;
    if (s == "KIHABARA") ok = true;
    if (s == "AKIHBARA") ok = true;
    if (s == "KIHBARA") ok = true;
    if (s == "AKIHABRA") ok = true;
    if (s == "KIHABRA") ok = true;
    if (s == "AKIHBRA") ok = true;
    if (s == "KIHBRA") ok = true;
    if (s == "AKIHABAR") ok = true;
    if (s == "KIHABAR") ok = true;
    if (s == "AKIHBAR") ok = true;
    if (s == "KIHBAR") ok = true;
    if (s == "AKIHABR") ok = true;
    if (s == "KIHABR") ok = true;
    if (s == "AKIHBR") ok = true;
    if (s == "KIHBR") ok = true;

    cout << (ok ? "YES" : "NO") << endl;


    return 0;
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = int.Parse(Console.ReadLine());
            var W = int.Parse(Console.ReadLine());
            var N = int.Parse(Console.ReadLine());
            var max = Math.Max(H, W);
            var ret = (N + (max - 1)) / max;
            Console.WriteLine(ret);
        }

    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
      if(y==0){
            return x;
      }else{
            return gcd(y, x%y);
      }  
}

int main(void){
    // Your code here!
      int N , X; 
      cin >> N >> X;
      vector<int> x(N); 
      
      for(int i=0; i<N; i++){
            cin>> x.at(i); 
      }
      
      int answer =0;
      for(int i=0; i<N; i++){
            answer = gcd(answer, abs( X-x.at(i)) ); 
      }
      
      cout<< answer <<endl;        
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
#include<cstring>
#include<string>

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

int dx[6] = {1, 0, -1, 0, 1, -1};
int dy[6] = {0, 1, 0, -1, 1, -1};
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const int basex = 100;
const int basey = 100;

int depth;
int d[200][200];
typedef pair<int, int> P;

int bfs(int x, int y){
    int cnt = 1;
    queue<P> que;
    que.push(P(x,y));
    d[x][y] = 0;

    while(!que.empty()){
        P p = que.front(); que.pop();
        if(d[p.first][p.second]==depth) continue;
        REP(i,6){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(d[nx][ny] != -1) continue;
            cnt++;
            que.push(P(nx,ny));
            d[nx][ny] = d[p.first][p.second] + 1;
        }
    }
   return cnt;
}

int main(){
    int n;
    while(cin >> depth >> n){
        if(depth + n == 0) break;
        memset(d, -1, sizeof(d));
        int x, y;
        REP(i,n){
            cin >> x >> y;
            d[x+basex][y+basey] = 0;
        }
        cin >> x >> y;
        int res = bfs(x+basex,y+basey);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1380
from collections import deque

S = input()
q = int(input())

is_s0_head = True
tail = len(S)-1

queue = deque(S)

for _ in range(q):
    # print(queue)
    Q = list(input().split())
    if Q[0] == "1":
        is_s0_head = not is_s0_head
    else:
        if Q[1] == "1":
            if is_s0_head:
                queue.appendleft(Q[2])
            else:
                queue.append(Q[2])
        else:
            if is_s0_head:
                queue.append(Q[2])
            else:
                queue.appendleft(Q[2])

if is_s0_head:
    print("".join(list(queue)))
else:
    print("".join(list(queue)[::-1]))


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

int main(){
    int a,b;
    cin >> a >> b;
    string result;
    if (a == b)
    {
        result = "Draw";
    }
    else
    {
        if (a == 1 || b == 1)
        {
           result  = (a == 1)? "Alice" : "Bob";
        }else
        {
            result = (a> b)? "Alice" : "Bob";
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
ans=0
if n==1:
  print(a[0]//2)
  exit()
for i in range(n-1):
  if (a[i]+a[i+1])%2==0:
    ans+=(a[i]+a[i+1])//2
    a[i+1]=0
  else:
    ans+=(a[i]+a[i+1])//2
    a[i+1]=(0 if a[i+1]==0 else 1)
print(ans)

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

int getOrderTime(int x_time) {
    return (x_time + 9) / 10 * 10;
}

int getRestTime(int x_time) {
    return getOrderTime(x_time) - x_time;
}

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

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    sum = getOrderTime(a) + getOrderTime(b) + getOrderTime(c) + getOrderTime(d) + getOrderTime(e);
    cout << sum - max(getRestTime(a), max(getRestTime(b), max(getRestTime(c), max(getRestTime(d), getRestTime(e))))) << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i;
    int sum;

    while(scanf("%d", &n) != EOF)
    {
        sum = 2;
        for (i = 2; i <= n; i++){
            sum += i;
        }
        printf("%d\n", sum);
    }
    return (0);
}


Measured memory_bytes: 1980
package main

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

type node struct {
	v          int
	prev, next *node
}

var head, tail node
var cursor *node

func initList() {
	head.v = -1
	tail.v = -1
	head.next = &tail
	tail.prev = &head
	cursor = &tail
}
func insert(v int) {
	// cursorが指している要素の直前に挿入する
	var nn node
	nn.v = v
	cursor.prev.next = &nn
	nn.prev = cursor.prev
	nn.next = cursor
	cursor.prev = &nn
	cursor = &nn
}
func erase() {
	cursor.prev.next = cursor.next
	cursor.next.prev = cursor.prev
	cursor = cursor.next
}
func move(d int) {
	if d > 0 {
		for i := 0; i < d; i++ {
			if cursor.next != nil {
				cursor = cursor.next
			}
		}
	} else if d < 0 {
		for i := 0; i < -d; i++ {
			if cursor.prev != nil {
				cursor = cursor.prev
			}
		}
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

type query struct {
	op, x, d int
}

func showv() {
	fmt.Print("[")
	cnt := 0
	for lp := &head; lp != nil; lp = lp.next {
		if cnt > 0 {
			fmt.Print(" ")
		}
		cnt++
		fmt.Print(lp.v)
	}
	fmt.Printf("] c(%d)\n", cursor.v)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	initList()
	for i := 0; i < n; i++ {
		op := nextInt(sc)
		if op == 0 { // insert
			insert(nextInt(sc))
		} else if op == 1 { // move
			move(nextInt(sc))
		} else { // erase
			erase()
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for lp := head.next; lp != nil && lp != &tail; lp = lp.next {
		fmt.Fprintln(wtr, lp.v)
	}
	wtr.Flush()
}



Measured memory_bytes: 22328
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define mp make_pair
#define ll long long
#define reg register
#define inf 0x7fffffff
#define MOD 1000000007
#define clr(a) memset(a,sizeof(a),0);
#define rep(i,l,r) for(reg int i=l;i<=r;i++)
#define dow(i,l,r) for(reg int i=l;i>=r;i--)
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
template<class T>inline T power(T a,T b){T ans=1;while(b){if(b&1){ans=ans*a%MOD;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
bool cmp(int a,int b){return a<b;}
int main(){
	int n=read(),a[200005]={0};
	ll ans=0;
	rep(i,1,n) a[i]=read(),a[i]=a[i]-i;
	std::sort(a+1,a+n+1,cmp);
	rep(i,1,n) ans+=abs(a[i]-a[(n+1)/2]);
	writeln(ans);
}

Measured memory_bytes: 1152
program card;
	var a,b : integer;
begin
	readln (a,b);
	if a=b then
	writeln ('Draw')
	else if a = 1 then
	writeln ('Alice') 
	else if b = 1 then
	writeln ('Bob')
	else if a > b then
	writeln ('Alice')
	else writeln ('Bob');
end.

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    long n, a, b,i, e, p, q, m;
    q = 0;
    cin>>n>>a>>b;
    if((n>a*b) or (a+b-1>n)){
        cout<<"-1";
    }
    else{
        long v[n], v2[b+1];
        for(i=0;i<b;i++){
            v2[i] = a;
        }
        m = n-a;
        v2[0] = a;
        for(i=1;i<b;i++){
            v2[i] = ceil(m/(b-i));
            m = m-v2[i];
        }
        p = n-a+1;
        for(i=0;i<b;i++){
            for(e=1;e<v2[i]+1;e++){
                v[q]=p;
                p++;
                q++;
            }
            p = v[q-v2[i]]-v2[i+1];
        }
        for(i=0;i<n-1;i++){
            cout<<v[i]<<' ';
        }
        cout<<v[n-1];
    }
}

Measured memory_bytes: 5760
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {
    int N, ret = 1;
    cin >> N;
    while (ret * 2 <= N) {
        ret *= 2;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	ans := true
	cond2 := false
	for i := 0; i < len(chars); i++ {
		if i == 0 {
			if chars[i] != "A" {
				ans = false
				break
			}
			continue
		}
		if 2 <= i && i <= len(chars)-2 {
			if chars[i] == "C" && !cond2 {
				cond2 = true
				continue
			} else if chars[i] == "C" && cond2 {
				ans = false
				break
			}
		}
		if strings.ToLower(chars[i]) != chars[i] {
			ans = false
			break
		}
	}

	if ans && cond2 {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

def modFact(n, p): 
    if n >= p: 
        return 0    
  
    result = 1
    for i in range(1, n + 1): 
        result = (result * i) % p  
  
    return result 

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

n,m=mii()
if abs(n-m)>=2:
    print(0)
    exit()

n,m=max(n,m),min(n,m)

if n!=m:
    p = modFact(n,mod)
    q = modFact(m,mod)
    print(mul(p,q))

else:
    p = modFact(n,mod)
    q = modFact(m,mod)
    w = mul(p,q)
    print((2*w)%mod)





Measured memory_bytes: 64748
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    double d, t, s; cin >> d >> t >> s;
    if(d/s <= t) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


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

int	main()
{
	const int64_t	mod = 1000000000 + 7;
	int	N;
	cin >> N;
	int64_t	result = 1;
	for (int i = 0; i < N; ++i) {
		result *= (i + 1);
		result %= mod;
	}
	cout << result << endl;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	int z = -1;
	int sz = s.size();
	for (int i = sz-1; i >= 0; i--) 
	{
		if (s[i] == 'Z') {
			z = i;
			break;
		}
	}
	cout << z-a+1 << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;
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;}

#ifdef LOCAL
#define eprintf(...) printf(__VA_ARGS__)
#else 
#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))

template<class Abel> struct UnionFind{
	vector<int> par;
	vector<int> rank;

	UnionFind(int n = 1) {
		init(n);
	}
	void init(int n = 1) {
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int root(int x) {
		if (par[x] == x) {
			return x;
		} else {
			int r = root(par[x]);
			return par[x] = r;
		}
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) {
			swap(x,y);
		}
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		return true;
	}
};

const int INT_INF = 1000000007;
int main() {
	int N, K, L;
	cin >> N  >> K >> L;
	
	UnionFind<int> Load(N), Rail(N);
	for (int i = 0; i < K; i++) {
		int p,q;
		cin >> p >> q;
		Load.merge(p-1,q-1);
	}
	for (int j = 0; j < L; j++) {
		int r,s;
		cin >> r >> s;
		Rail.merge(r-1,s-1);
	}
	
	ii city[200009];
	for (int i = 0; i < N; i++) {
		city[i].first = Load.root(i);
		city[i].second = Rail.root(i);
	}

	vector<ii> pairlist;
	for (int i = 0; i < N; i++) {
		pairlist.push_back(ii(Load.par[i], Rail.par[i]));
	}
	sort(pairlist.begin(), pairlist.end());
	for (int i = 0; i < N; i++) {
		int s = lower_bound(pairlist.begin(), pairlist.end(), city[i]) - pairlist.begin();
		int t = upper_bound(pairlist.begin(), pairlist.end(), city[i]) - pairlist.begin();
		cout << t-s << " ";
	}
	cout << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	
	ll X,K,Q;cin >> X >> K;
	vector<pair<ll,ll>> v;
	REP(i,K){
		ll r;cin >> r;
		v.EB(r,-1);
	}
	cin >> Q;
	REP(i,Q){
		ll a, b;cin >> a >> b;
		v.EB(a,b);
	}
	
	sort(ALL(v));
	
	ll minX = 0;
	ll minY = 0;
	ll maxX = X;
	ll maxY = X;
	ll type = -1;
	ll nowT = 0;
	
	REP(i,v.size()){
		minY += type * (v[i].FI - nowT);
		if(minY < 0){
			minX -= minY;
			minY = 0;
		}
		if(minY > X)minY = X;
		maxY += type * (v[i].FI - nowT);
		if(maxY > X){
			maxX -= (maxY - X);
			maxY = X;
		}
		if(maxY < 0)maxY = 0;
		maxX = max(maxX,minX);
		
		if(v[i].SE == -1)type = -type;
		else {
			if(v[i].SE <= minX){
				cout << minY << endl;
			}
			else if(v[i].SE < maxX){
				cout << minY + (v[i].SE - minX) << endl;
			}
			else {
				cout << maxY << endl;
			}
		}
		nowT = v[i].FI;
	}
	
	return 0;
}


Measured memory_bytes: 2928
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while ( u != NIL && k != u->key ) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while ( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y;  // 削除する対象
  Node *x;  // yの子

  // 削除する節点を決める
  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if ( y->left != NIL )
    x = y->left;
  else
    x = y->right;

  if ( x != NIL )
    x->parent = y->parent;

  if ( y->parent == NIL ) {
    root = x;
  } else {
    if ( y == y->parent->left )
      y->parent->left = x;
    else
      y->parent->right = x;
  }

  if ( y != z )
    z->key = y->key;

  free(y);
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z->key < x->key )
      x = x->left;
    else
      x = x->right;
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key )
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com[0] == 'f' ) {
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com == "delete" ) {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}


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

int main(){
  char x,y;
  cin >>x >>y;
  if(x>y) cout << ">" << endl;
  if(x==y) cout << "=" << endl;
  if(x<y) cout << "<" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
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;}

int main() {
	int N;
	cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int mn = N+1, ans = 0;
    rep(i,N) {
        mn = min(mn, p[i]);
        if (p[i]==mn) ans++;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import numpy as np
x, n = [int(i) for i in input().split()]
if n != 0:
  ps = np.array([int(i) for i in input().split()])

  ps.sort()

  m = -1000
  ans = m
  di = 0
  while ans == m:
    if not x - di in ps:
      ans = x - di
    elif not x + di in ps:
      ans = x + di
    di += 1
else:
  ans = x
print(ans)




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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<ll,int> P;
ll dp[2010][2010]={};

int main(){
   int n; scanf("%d",&n);
   vector<P> a(n);
   rep(i,0,n)scanf("%lld",&a[i].first),a[i].second=i;
   sort(ALL(a),greater<P>());
   rep(i,0,n)rep(j,0,n){
      if(i+j>=n)continue;
      chmax(dp[i+1][j],dp[i][j]+a[i+j].first*abs(a[i+j].second-i));
      chmax(dp[i][j+1],dp[i][j]+a[i+j].first*abs(a[i+j].second-(n-1-j)));
   }
   ll res=0; rep(i,0,n)rep(j,0,n)chmax(res,dp[i][j]);
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 26428
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int n,x,t;

int main() {

    cin >> n >> x >> t;

    cout << (n/x)*t + (n%x>0)*t;

return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N;cin >> N;
  cout << (N-2)*180 << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque


def main():
    from sys import stdin
    readline = stdin.readline

    from builtins import max, min, range

    INF = 10 ** 6

    H, W = map(int, readline().split())
    Ch, Cw = map(lambda x: int(x) - 1, readline().split())
    Dh, Dw = map(lambda x: int(x) - 1, readline().split())
    S = [readline()[:-1] for _ in range(H)]

    t = [[INF] * W for _ in range(H)]
    for h in range(H):
        th = t[h]
        Sh = S[h]
        for w in range(W):
            if Sh[w] == '#':
                th[w] = -1

    t[Ch][Cw] = 0
    q = deque([(Ch, Cw)])
    a = 0
    while q:
        warpq = []
        while q:
            h, w = q.popleft()
            warpq.append((h, w))
            if h - 1 >= 0 and t[h - 1][w] > a:
                q.append((h - 1, w))
                t[h - 1][w] = a
            if h + 1 < H and t[h + 1][w] > a:
                q.append((h + 1, w))
                t[h + 1][w] = a
            if w - 1 >= 0 and t[h][w - 1] > a:
                q.append((h, w - 1))
                t[h][w - 1] = a
            if w + 1 < W and t[h][w + 1] > a:
                q.append((h, w + 1))
                t[h][w + 1] = a

        if t[Dh][Dw] != INF:
            break

        a += 1
        for h, w in warpq:
            for i in range(max(0, h - 2), min(H, h + 3)):
                ti = t[i]
                for j in range(max(0, w - 2), min(W, w + 3)):
                    if ti[j] > a:
                        ti[j] = a
                        q.append((i, j))

    if t[Dh][Dw] == INF:
        print(-1)
    else:
        print(t[Dh][Dw])


main()


Measured memory_bytes: 23380
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int s;
    cin >> s;
    set<int> S;
    S.insert(s);

    REP(i, 1000000 + 1){
        if(s % 2 == 0) s /= 2;
        else s = 3 * s + 1;
        if(S.count(s) > 0){
            cout << i + 2 << endl;
            return 0;
        }
        S.insert(s);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int MAX=1e5+5;
priority_queue<long long int> q1,q2;
long long int a[MAX*3],prefix[MAX*3],suffix[MAX*3];
long long int maxPlus[MAX],minMinus[MAX];
long long int ans=-1e18;
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=3*n;++i){
		cin>>a[i];
	}
	for(int i=1;i<=3*n;++i){
		prefix[i]=prefix[i-1]+a[i];
	}
	for(int i=3*n;i>=1;--i){
		suffix[i]=suffix[i+1]+a[i];
	}
	for(int i=1;i<=n;++i){
		q1.push(-a[i]);
	}
	for(int i=1;i<=n;++i){
		q1.push(-a[n+i]);
		long long int t=q1.top();
		q1.pop();
		maxPlus[i]=maxPlus[i-1]+t;
	}
	for(int i=3*n;i>=2*n+1;--i){
		q2.push(a[i]);
	}
	for(int i=n;i>=1;--i){
		q2.push(a[n+i]);
		long long int t=q2.top();
		q2.pop();
		minMinus[i]=minMinus[i+1]+t;
	}
	for(int i=0;i<=n;++i){
		ans=max(ans,prefix[i+n]-suffix[i+n+1]+maxPlus[i]+minMinus[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for ( int i = 0; i < n; i++ ) {
			String s = sc.next();
			int[] num = new int[8];
			for ( int j = 0; j < 8; j++ ) {
				num[j] = Integer.parseInt(s.charAt(j)+"");
			}
			Arrays.sort(num);
			int max = 0 , min = 0;
			for( int j = 7; j >= 0; j-- )
				max = max * 10 + num[j];
			for ( int j = 0; j < 8; j++ )
				min = min * 10 + num[j];
			System.out.println(max-min);
		}
	}
}

Measured memory_bytes: 12000
# copy
N = int(input())
A = list(map(int, input().split()))

cnt = 0
r = 0
tmp = 0
for l in range(N):
    while r < N and (tmp & A[r]) == 0:
        tmp |= A[r]
        r += 1
    cnt += (r - l)
    tmp ^= A[l]
print(cnt)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

vector<ll> TopologicalSort(ConnectNodeInfo& connect){
	int N=connect.size();
	stack<ll> vertex;
	vector<ll> input(N),sorted;
	REP(i,N){
		for(auto& x:connect[i]) input[x.first]++;
	}
	REP(i,N){
		if(input[i]==0) vertex.push(i);
	}
	while(!vertex.empty()){
		auto v=vertex.top();vertex.pop();
		sorted.push_back(v);
		for(auto& x:connect[v]){
			input[x.first]--;
			if(!input[x.first]) vertex.push(x.first);
		}
	}
	return sorted;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	ConnectNodeInfo connect(N);

	REP(i,M){
		int u=in()-1,v=in()-1;
		connect.AddDirectionalConnection(u,v,1);
	}
	auto T=TopologicalSort(connect);
	for(auto& x:T){
		out(x+1);
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <queue>
#include <vector>
#define pub push_back
#define vi vector<int>
#define ll long long
#define pii pair<int, int>
#define fst first
#define snd second
using namespace std;
queue<pii> q; 
int n, m;
vector<vi> adj;
int bt[100001] = {};
int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {adj.pub(vi()); bt[i] = -1;}
	for (int i = 0; i < m; i++)
	{
		int u, v; cin >> u >> v;
		adj[u - 1].pub(v - 1);
		adj[v - 1].pub(u - 1);
	}
	q.push({0, -2});
	while (!q.empty())
	{
		int cr = q.front().fst, pr = q.front().snd; q.pop();
		if (bt[cr] == -1)
		{
			bt[cr] = pr;
			for (auto v : adj[cr]) {q.push({v, cr});}
		}
	}
	cout << "Yes\n";
	for (int i = 1; i < n; i++)
	{
		cout << bt[i] + 1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 12244
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int a, b; cin >> a >> b;
    cout << (a+b)%24 << ln;
}


Measured memory_bytes: 3636