akhauriyash/Code-Regression huggingface dataset:
A,B = map(int,input().split())
array = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if array.index(A) > array.index(B):
    print('Alice')
elif array.index(A) == array.index(B):
    print('Draw')
else:
    print('Bob')

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    private static int check(int[] lines) {
	if(lines[0] + lines[1] <= lines[2]) {
	    return 0;
	}

	for(int i = 0, i_len = lines.length; i < i_len; i += 1) {
	    lines[i] *= lines[i];
	}

	if(lines[0] + lines[1] == lines[2]) {
	    return 1;
	} else if(lines[0] + lines[1] > lines[2]) {
	    return 2;
	}

	return 3;
    }

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int[] results = new int[4];
	int count = 0;

	while(sc.hasNext()) {
	    String[] inputs = (sc.nextLine()).split(" ");
	    int[] lines = new int[inputs.length];

	    for(int i = 0, i_len = lines.length; i < i_len; i += 1){
		lines[i] = Integer.parseInt(inputs[i]);
	    }

	    Arrays.sort(lines);

	    ++results[check(lines)];

	    if(results[0] == 1) {
		break;
	    }

	    ++count;
	}

	System.out.print(count + " ");
	for(int i = 1, i_len = results.length - 1; i < i_len; i += 1) {
	    System.out.print(results[i] + " ");
	}
	System.out.println(results[results.length - 1]);
    }
}

Measured memory_bytes: 17372
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<char,int>mp;
    rep(i,n)mp[s[i]]++;
    set<string>ans;
    set<char>st;
    mp[s[0]]--;
    st.insert(s[0]);
    for(int i=1;i<n-1;i++){
        mp[s[i]]--;
        for(auto itr=st.begin();itr!=st.end();itr++){
            for(auto it=mp.begin();it!=mp.end();it++){
                if(it->second<=0)continue;
                char t = *itr;
                char x = it->first;
                string now = "";
                now += t;
                now += s[i];
                now += x;
                ans.insert(now);
            }
        }
        st.insert(s[i]);
    }
    cout << ans.size() << endl;
    return 0;
}

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

int main() {
	vector<int> p[2];
	int tmp;
	for(int j=0;j<2;j++){
	for(int i=0;i<10;i++){
		cin >> tmp;
		p[j].push_back(tmp);
	}
	sort(p[j].begin(),p[j].end(),greater<int>());
	int sum=0;
	for(int i=0;i<3;i++)
	sum+=p[j][i];
	cout << sum;
	if(!j)
	cout << " ";
	else
	cout << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a-b>0){
		cout<<a+a-1;
	}
	else if(b-a>0){
		cout<<b+b-1;
	}
	else if(a-b==0){
		cout<<a+b;
	}
}
//FELAROSSO 2019

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int dist = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x < K - x) { // type A
      dist += 2 * x;
    } else {         // type B
      dist += 2 * (K - x);
    }
  }
  
  cout << dist << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <ios>
#include <iomanip>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

int N;
string S;
set<string> ans;

void solve() {
    cin >> N >> S;
    //000~999までパスワードを決め打ちし、それぞれがSから作成可能かを調べる
    set<string> creatable;
    rep(i,1000){
        ostringstream oss;
        oss << setfill('0') << setw(3) << i;
        string pass = oss.str();
        // print(pass);
        int idx = 0;
        for(char s:S){
            if(pass[idx]==s) idx++;
            if(idx==3) {
                creatable.insert(pass);
                break;
            }
        }
    }
    print(creatable.size());
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<string.h>
main(){
  int a,b,c,d,e;
  char f[1002];
  scanf("%d\n",&a);
  while(a--){
    gets(f);
    c=strlen(f);
    for(d=0;d+6<c+1;d++){
      if(((f[d]=='H'&&f[d+1]=='o')&&(f[d+2]=='s'&&f[d+3]=='h'))&&(f[d+4]=='i'&&f[d+5]=='n')&&(f[d+6]=='o')){
	  f[d+6]='a';
      }
    }
    puts(f);
  }
  return 0;
}

Measured memory_bytes: 576
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def scc(to,ot):
    n=len(to)
    def dfs(u):
        for v in to[u]:
            if com[v]:continue
            com[v]=1
            dfs(v)
        top.append(u)

    top=[]
    com=[0]*n
    for u in range(n):
        if com[u]:continue
        com[u]=1
        dfs(u)

    def rdfs(u,k):
        for v in ot[u]:
            if com[v]!=-1:continue
            com[v]=k
            rdfs(v,k)

    com=[-1]*n
    k=0
    for u in top[::-1]:
        if com[u]!=-1:continue
        com[u]=k
        rdfs(u,k)
        k+=1

    return k,com

n,m=MI()
to=[[] for _ in range(n)]
ot=[[] for _ in range(n)]
for _ in range(m):
    u,v=MI()
    to[u].append(v)
    ot[v].append(u)
k,com=scc(to,ot)
group=[[] for _ in range(k)]
for u,g in enumerate(com):
    group[g].append(u)
    
print(k)
for uu in group:
    print(len(uu),end=" ")
    print(*uu)


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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define Y first
#define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

	int N, M;
	VI first_card(2);
	cin >> N >> first_card[0] >> first_card[1] >> M;

	vector<map<int, PII>> num2pos(2);
	
	for (int i = 0; i < 2; i++) {
		for (int y = 0; y < N; y++) {
			for (int x = 0; x < N; x++) {
				int a;
				cin >> a;
				
				num2pos[i][a] = MP(y, x);
			}
		}
	}

	VI ms(M);
	for (auto &m : ms) cin >> m;

	// count
	vector<VI> cnts(2, VI(N * 2 + 2, 0));
	VI oks(2);
	for (int i = 0; i < M; i++) {
		int m = ms[i];

		for (int j = 0; j < 2; j++) {
			if (!num2pos[j].count(m)) continue;

			// find
			PII pos = num2pos[j][m];

			oks[j] += ++cnts[j][pos.Y] == N;
			oks[j] += ++cnts[j][N + pos.X] == N;

			if (pos.X == pos.Y) {
				oks[j] += ++cnts[j][N * 2] == N;
			}
			if (pos.X + pos.Y == N - 1) {
				oks[j] += ++cnts[j][N * 2 + 1] == N;
			}

			if (N == 1) {
				oks[j] = 1;
			}
		}

		// ????????????
		VB ends(2);
		for (int j = 0; j < 2; j++) {
			ends[j] = oks[j] >= first_card[j];
		}

		if (ends[0] ^ ends[1]) {
			cout << (ends[0] ? "USAGI" : "NEKO") << endl;
			return 0;
		}
		if (ends[0] && ends[1]) {
			cout << "DRAW" << endl;
			return 0;
		}
	}

	cout << "DRAW" << endl;

	return 0;
}

Measured memory_bytes: 19212
#include<stdio.h>
int main(){
 
int a,b;
char op;
 
while(scanf("%d %c %d",&a,&op,&b),op!='?'){

if(op=='+')printf("%d\n",a+b);
else if(op=='-')printf("%d\n",a-b);
else if(op=='*')printf("%d\n",a*b);
else printf("%d\n",a/b);

}

return 0;
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  int oturi;

  cin >> N;

  if (N >= 1 && N <= 1000) {
    oturi = 1000 - N;
    cout << oturi << endl;
  }

  if (N >= 1001 && N <= 2000) {
    oturi = 1000 - (N - 1000) ;
    cout << oturi << endl;
  }

  if (N >= 2001 && N <= 3000) {
    oturi = 1000 - (N - 2000) ;
    cout << oturi << endl;
  }

  if (N >= 3001 && N <= 4000) {
    oturi = 1000 - (N - 3000) ;
    cout << oturi << endl;
  }

  if (N >= 4001 && N <= 5000) {
    oturi = 1000 - (N - 4000) ;
    cout << oturi << endl;
  }

  if (N >= 5001 && N <= 6000) {
    oturi = 1000 - (N - 5000) ;
    cout << oturi << endl;
  }

  if (N >= 6001 && N <= 7000) {
    oturi = 1000 - (N - 6000) ;
    cout << oturi << endl;
  }

  if (N >= 7001 && N <= 8000) {
    oturi = 1000 - (N - 7000) ;
    cout << oturi << endl;
  }

  if (N >= 8001 && N <= 9000) {
    oturi = 1000 - (N - 8000) ;
    cout << oturi << endl;
  }

  if (N >= 9001 && N <= 10000) {
    oturi = 1000 - (N - 9000) ;
    cout << oturi << endl;
  }


}

Measured memory_bytes: 3548
n = int(input())
A = list(map(int, input().split()))

flag = 1
i = 0
cnt = 0

while flag:
    flag = 0
    for j in range(n-1, i, -1):
        if A[j-1] > A[j]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1
            cnt += 1
    i += 1
    
for k in range(n-1):
    print(A[k], end=' ')
print(A[n-1])
print(cnt)


Measured memory_bytes: 5604
N,M,R = map(int,input().split())
r = list(map(int,input().split()))
ABC = []
for i in range(M):
    ABC.append(list(map(int,input().split())))

V = [ i for i in range(1,N+1)]
E =[[100000000 for j in range(N+1)] for i in range(N+1)]
for i in range(N+1):
    E[i][i] = 0

for i in range(M):
    E[ABC[i][0]][ABC[i][1]] = ABC[i][2]
    E[ABC[i][1]][ABC[i][0]] = ABC[i][2]


def warshall_floyd(V,E):
    d = E
    for k in V:
        for i in V:
            for j in V:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d

W = warshall_floyd(V,E)

import itertools
ans = 10000000000000
for val in list(itertools.permutations(r,len(r))):
    tmp = 0
    for i in range(len(val) - 1):
        tmp += W[val[i]][val[i+1]]
    if ans > tmp:
        ans = tmp
print(ans)



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

int gcd(int a, int b) {
    int r = a % b;
    return r ? gcd(b, r) : b;
}

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

    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<int> left(N), right(N);
    left[0] = A[0];
    right[N-1] = A[N-1];
    for (int i = 1; i < N; i++) {
        left[i] = gcd(left[i-1], A[i]);
        right[N-1-i] = gcd(right[N-i], A[N-1-i]);
    }

    int ans = max(left.back(), max(left[N-2], right[1]));
    for (int i = 0; i < N-2; i++)
        ans = max(ans, gcd(left[i], right[i+2]));
    cout << ans << "\n";
}

Measured memory_bytes: 1408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> A) {
  set<ll> s;
  for (ll i: A) s.insert(i);
  int res = s.size();
  if (res % 2 == 0) --res;
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	solve(N, A);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int h[100000];

int dp[100001];
void solve(){
	dp[1] = abs(h[1]-h[0]);
	rep(i,N - 2){
		dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]),
			dp[i] + abs(h[i + 2] - h[i]));
	}
	cout<<dp[N-1]<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N) {
		cin>>h[i];
	}
		solve();
	return 0;
}



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

int main() {
	
	char a[1000];
	char b[1000];
	scanf("%s %s",a ,b);
	int n = strlen(a);
	int m = strlen(b);
	if(n > m) {
		printf("%s\n", "GREATER");
	}else if(n < m) {
		printf("%s\n", "LESS");
	}else {
		for(int i = 0; i < n; i++) {
			if(a[i] - '0' > b[i] - '0'){
				printf("%s\n", "GREATER");
				break;
			}else if(a[i] - '0' < b[i] - '0') {
				printf("%s\n", "LESS");
				break;
			}else {
				if(i == n - 1) {
					printf("%s\n", "EQUAL");
				}else {
					continue;
				}
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    int i = 1;
    Scanner sc = new Scanner(System.in);
    while(true){
      int num = sc.nextInt();
      if(num == 0){
        break;
      }
      System.out.println("Case " + i + ": " + num);
      i++;
    }
  }
}

Measured memory_bytes: 45188
#include<cstdio>

int main(){
    double a, b, f;
    int r, x, c, d;
    
    scanf("%lf%lf",&a, &b);
    
    c = a;
    d = b;
    
    x = a / b;
    r = c % d;
    f = a / b;
    
    printf("%d %d %6f\n", x, r, f);
}

Measured memory_bytes: 1080
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
#include <list>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INFI 987654321
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
struct Node{
    int idx, x, y;
    Node(){};
    Node(int a, int b, int c)
    {
        idx = a;
        x= b;
        y = c;
    }
};
Node points[100001];
vector<pi> G[100001];
priority_queue<pi, vector<pi>, greater<pi>> pq;
bool visit[100001];
int N;
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        cin >> points[i].x >> points[i].y;
        points[i].idx = i;
    }
    sort(points + 1, points + N + 1, [](Node a, Node b) {
        return a.x < b.x;
    });
    for(int i = 2; i <= N; ++i)
    {
        int dist = points[i].x - points[i - 1].x;
        G[points[i].idx].push_back(pi(dist, points[i - 1].idx));
        G[points[i - 1].idx].push_back(pi(dist, points[i].idx));
    }
    sort(points + 1, points + N + 1, [](Node a, Node b) {
       return a.y < b.y;
    });
    for(int i = 2; i <= N; ++i)
    {
        int dist = points[i].y - points[i - 1].y;
        G[points[i].idx].push_back(pi(dist, points[i - 1].idx));
        G[points[i - 1].idx].push_back(pi(dist, points[i].idx));
    }
    pq.push(pi(0, 1));
    int ans = 0;
    while(pq.empty() == false)
    {
        pi ege = pq.top();
        pq.pop();
        int here = ege.second;
        int cost = ege.first;
        if(visit[here])
            continue;
        ans += cost;
        visit[here] = 1;
        for(pi there : G[here]) {
            if(!visit[there.second])
                pq.push(there);
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
  int n,i,ans=0;
  cin >> n;
  vector<int> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  for(i=n-1; i>=0; i--){
    if((n-i)%2==1){
      ans+=a[i];
    }else{
      ans-=a[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
n,c = map(int, input().split())
xv=[list(map(int,input().split())) for i in range(n)]

def solve(xv):
    lis = [0] * n # best score in x sushi
    now_v=0
    best=0

    for i in range(n):
        x,v = xv[i]
        now_v+=v
        best=max(best,now_v - x)
        lis[i] = best

    lis.insert(0,0)
    ans=max(lis)

    now_v=0
    for i in reversed(range(n)):
        x,v = xv[i]
        now_v+=v
        ans=max(ans,now_v-2*(c-x) + lis[i])

    return ans


xv2 = []
for i in reversed(range(n)):
    x,v = xv[i]
    x=c-x
    xv2.append([x,v])

ans = max(solve(xv),solve(xv2))

print(ans)

Measured memory_bytes: 104308
#include<stdio.h>

void swap(int *a,int *b){
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

void QuickSort(int *arr,int maxlen,int begin,int end){
	int i,j;
	
	if(begin < end){
		i = begin + 1;
		j = end;
		
		while(i < j){
			if(arr[i] > arr[begin]){
				swap(&arr[i],&arr[j]);
				j--;
			}else{
				i++;
			}
		}
		if(arr[i] >= arr[begin]){
			i--;
		}
		swap(&arr[begin],&arr[i]);
		QuickSort(arr,maxlen,begin,i);
		QuickSort(arr,maxlen,j,end);
	}
} 

void ShellSort(int *arr,int size){
	int i,j,tmp,increment;
	
	for(increment = size/2;increment > 0;increment /= 2){
		for(i = increment;i < size;i++){
			tmp = arr[i];
			for(j = i - increment;j >= 0 && tmp < arr[j]; j -= increment)
				arr[j + increment] = arr[j];
			arr[j+increment] = tmp;
		}
	}
}

int main(){
	int k,n;
	scanf("%d %d",&k,&n);
	int a[n],dis[n],i;
	int max = 0;
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	dis[0] = a[0] + k - a[n-1];
	int sum = dis[0];
	for(i = 1;i < n;i++){
		dis[i] = a[i] - a[i-1];	
		if(dis[i] >= max)
			max = dis[i];
		sum += dis[i];
	}
	

	if(dis[0] > max)
		max = dis[0];
	//排序 找出其中最小的n-1个边 加起来
	//QuickSort(dis,n,0,n-1);
	//ShellSort(dis,n);
		
	printf("%d",sum-max);
	
	
	return 0;
	 
}


Measured memory_bytes: 3288
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong)
    var tempMax = aList[0]
    var ans = 0L
    for (i in 1 until aList.size) {
        ans += Math.max(0, tempMax - aList[i])
        tempMax = Math.max(tempMax, aList[i])
    }
    println(ans)
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b and a != c) {
        print("Yes");
    } else if (a == c and a != b) {
        print("Yes");

    } else if (b == c and a != b) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
rd=[]
i=1#iが都市
j=0
while line= gets
  rd<< line.split.map(&:to_i)
end
while i<=n
  num=0
  while j<m
    if rd[j][0]==i or rd[j][1]==i
      num+=1
    end
    j+=1
  end
  puts num
  i+=1
  j=0
end

Measured memory_bytes: 1788
#include<stdio.h>

int main(){

  int sum = 0, min, sec, in, i;
  
  for(i = 0; i < 4; i++){
    scanf("%d",&in);
    sum += in;
  }

  min = sum / 60;
  sec = sum - min * 60;

  printf("%d\n",min);
  printf("%d\n",sec);

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n;
    cin>>n;
    double P[200000],dp[3001][3001]={0};
    rep(i,n) cin>>P[i];
    rep(i,n+1)dp[i][0]=1;
    rep(i,n)rep(j,n) dp[i+1][j+1]+=dp[i][j+1]+(dp[i][j]-dp[i][j+1])*P[i];
   cout<<setprecision(10)<<dp[n][n/2+1];
}

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

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define REP(i,a,b) for(int i = a ; i <= b ; ++i) 
# define Rep(i,a,b) for(int i = a ; i < b ; ++i) 
# define Rrep(i,a,b) for(int i = b ; i >= a ; --i) 
# define FOR(i,b) for(int i = 0 ; i <= b ; ++i)
# define For(i,b) for(int i = 0 ; i < b ; ++i)
# define Rfor(i,b) for(int i = b ; i >= 0 ; --i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

const ll inf = 1e18 ; 
const int MxN = 200005; 
const int mod = 1e9+7 ; 

void pe(int a) { cout << a << "\n" ; }
void pe(ll a) {	cout << a << "\n" ; }
void pe(string a) {	cout << a << "\n" ; }
void ps(int a) {	cout << a << ' ' ; }
void umax(int &a,int &b) { a = max(a,b); } ; 
void umax(ll &a , ll &b) {a = max(a,b);} ; 
void umin(int &a,int &b) { a = min(a,b);} ; 
void umin(ll &a , ll &b) {a = min(a,b);} ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 

	ll x,k,d ; 
	cin >> x >> k >> d ; 
	x = abs(x) ; 
	ll m = x / d ; 
	if(k <= m) {
		pe(x - k*d) ; 
	}
	else {
		ll rem = k - m ; 
		if(rem % 2 == 0) 
			pe(abs(x - m*d )) ; 
		else 
			pe(min(abs(x - m*d - d), abs(x-m*d+d) )) ; 
		
	}


	return 0 ; 	
}




Measured memory_bytes: 3644
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (T1, T2): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (A1, A2): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let (B1, B2): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    fn iceil(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    let (D1, D2) = if T1 * (A1 - B1) + T2 * (A2 - B2) >= 0 {
        (T1 * (A1 - B1), T2 * (A2 - B2))
    } else {
        (T1 * (B1 - A1), T2 * (B2 - A2))
    };

    let ans = if D1 + D2 == 0 {
        "infinity".to_string()
    } else if D1 > 0 {
        0.to_string()
    } else if D1 % (D1 + D2) == 0 {
        (-2 * D1 / (D1 + D2)).to_string()
    } else {
        (2 * iceil(-D1, D1 + D2) - 1).to_string()
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static int count = 0;

	public static void merge(List<Integer> numbers, int left, int mid, int right) {
		int num1 = mid - left;
		int num2 = right - mid;
		int[] leftArray = new int[num1+1];
		int[] rightArray = new int[num2+1];

		for(int i = 0; i < num1; i++) {
			leftArray[i] = numbers.get(left+i);
		}
		for(int i = 0; i < num2; i++) {
			rightArray[i] = numbers.get(mid+i);
		}
		leftArray[num1] = Integer.MAX_VALUE;
		rightArray[num2] = Integer.MAX_VALUE;

		int i = 0;
		int j = 0;
		for(int k = left; k < right; k++, count++) {
			if(leftArray[i] <= rightArray[j]) {
				numbers.set(k, leftArray[i]);
				i++;
			} else {
				numbers.set(k, rightArray[j]);
				j++;
			}

		}
	}

	public static void mergeSort(List<Integer> numbers, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(numbers, left, mid);
			mergeSort(numbers, mid, right);
			merge(numbers, left, mid, right);
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> numbers = new ArrayList<>();

		// 入力を受け取る
		int num = scan.nextInt();
		for(int i = 0; i < num; i++) {
			numbers.add(scan.nextInt());
		}

		// マージソートを行う
		mergeSort(numbers, 0, num);


		// 結果を出力する
		for(int i = 0; i < num; i++) {
			if(i == 0) {
				System.out.print(numbers.get(i));
			} else {
				System.out.print(" " + numbers.get(i));
			}
		}
		System.out.println("");
		System.out.println(count);
	}
}



Measured memory_bytes: 275980
from collections import deque
N, M = map(int, input().split())
#L = []
#R = []
#D = []
G = [[] for _ in range(N+1)]
for _ in range(M):
    tmpl, tmpr, tmpd = map(int, input().split())
    # L.append(tmpl)
    # R.append(tmpr)
    # D.append(tmpd)
    G[tmpl].append((tmpr, tmpd))
    G[tmpr].append((tmpl, -tmpd))

field = [None] * (N+1)


def dfs(i):
    q = deque()
    q.append(i)
    field[i] = 0
    #used = [False]*(N+1)
    #used[i] = True
    while q:
        tmp = q.pop()
        for elem in G[tmp]:
            if field[elem[0]] is not None:
                if field[elem[0]] != field[tmp]+elem[1]:
                    return False
                continue
            else:
                q.append(elem[0])
                field[elem[0]] = field[tmp]+elem[1]

            # if used[elem[0]]:
            #    if field[elem[0]] is not None:
            #        if field[elem[0]] != field[tmp]+elem[1]:
            #            return False
            #    continue
            # q.append(elem[0])
            # if field[elem[0]] == None:
            #    field[elem[0]] = field[tmp]+elem[1]
            #    used[elem[0]] = True
            # else:
            #    if field[elem[0]] != field[tmp]+elem[1]:
            #        return False

    return True


for i in range(1, N+1):
    if field[i] == None:
        if not dfs(i):
            print('No')
            exit()
print('Yes')


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  int x, y, a, b; cin >> x >> y;

  b = y - (x << 1);
  if (b & 1) {
    cout << "No\n";
    return 0;
  }
  b >>= 1;

  a = x - b;

  cout << (a < 0 || b < 0 ? "No" : "Yes") << '\n';

  return 0;
}

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

using namespace std;

constexpr int V_MAX = 100000;

vector<int> graph[V_MAX];

class LowestCommonAncestor {
    public:
    int root, n, LOG_V_MAX = 30;
    vector<int> depth;
    vector<vector<int>> parent;

    LowestCommonAncestor(int root=0, int n=V_MAX): root(root), n(n) {
        depth.resize(n);
        depth.assign(n, -1);
        parent.resize(n, vector<int>(LOG_V_MAX));
        parent.assign(n, vector<int>(LOG_V_MAX, -1));
        dfs(root, -1, 0);
        for(int i=0;i<n;++i) {
            for(int j=1;j<LOG_V_MAX;++j) {
                if(parent[i][j-1] == -1) break;
                parent[i][j] = parent[parent[i][j-1]][j-1];
            }
        }
    }

    void dfs(int node, int par, int d) {
        depth[node] = d;
        parent[node][0] = par;
        for(int child: graph[node]) {
            if(child == par) continue;
            dfs(child, node, d+1);
        }
    }

    int get_lca(int u, int v) {
        if(depth[u] > depth[v]) swap(u, v);
        int depth_diff = depth[v] - depth[u];
        for(int j=0;j<LOG_V_MAX&&depth_diff;++j) {
            if(depth_diff & (1 << j)) {
                v = parent[v][j];
            }
        }
        if(u == v) return u;
        for(int j=LOG_V_MAX-1;j>=0;--j) {
            if(parent[u][j] != -1 && parent[u][j] != parent[v][j]) {
                u = parent[u][j];
                v = parent[v][j];
            }
        }
        return parent[u][0];
    }
};

int main() {
    int n, k, c;
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> k;
        for(int j=0;j<k;++j) {
            cin >> c;
            graph[i].push_back(c);
            graph[c].push_back(i);
        }
    }

    LowestCommonAncestor lca = LowestCommonAncestor(0, n);

    int q, u, v;
    cin >> q;
    for(int i=0;i<q;++i) {
        cin >> u >> v;
        cout << lca.get_lca(u, v) << endl;
    }
}


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

using namespace std;

int main()
{
    int cnt[4] = {0};
    for (int i = 0; i < 3; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        cnt[a - 1]++;
        cnt[b - 1]++;
    }

    string ans = "YES";
    for (int i = 0; i < 4; i++)
    {
        if (cnt[i] >= 3)
        {
            ans = "NO";
            break;
        }
    }

    printf("%s\n", ans.c_str());

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);
const ll m[6] = {1,10,9,12,3,4};

int main() {
  string s; cin >> s;
  reverse(all(s));
  ll n = s.size();
  vl dp(13,0);
  if (s[0] == '?') {
    rep(i,10) dp[i] = 1;
  } else {
    dp[s[0]-'0'] = 1;
  }

  REP(i,1,n) {
    ll md = m[i%6];
    vl ndp(13,0);
    int x = s[i]=='?'? 0 : s[i]-'0';
    rep(j,13) {
      if (s[i] == '?') {
        rep(k,10) {
          ndp[(j+k*md)%13] += dp[j];
          ndp[(j+k*md)%13] %= MOD;
        }
      } else {
        ndp[(j+x*md)%13] += dp[j];
        ndp[(j+x*md)%13] %= MOD;
      }
    }
    dp = ndp;
  }
  // outa(dp,13);
  cout << dp[5] << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

ll f(ll i, ll o, ll j, ll l) {
	if (!i || !j || !l) return 0;
	i--, j--, l--;
	return 3 + o + 2*(j/2) + 2*(l/2) + 2*(i/2);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	
	ll res2 = o + 2*(j/2) + 2*(l/2) + 2*(i/2);
	
	ll res1 = f(i,o,j,l);
	
	cout << max(res2,res1) << endl;
}



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

ll solve() {
    ll N, K, a;
    cin >> N >> K;
    mcf_graph<ll, ll> g(2*N+2);
    int vs = 2*N, vt = 2*N+1;
    ll MA = 1e9;
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            cin >> a;
            g.add_edge(i, N+j, 1, MA-a);
        }
    }
    for ( int i = 0; i < N; i++ ) {
        g.add_edge(vs, i, K, 0);
        g.add_edge(N+i, vt, K, 0);
    }
    g.add_edge(vs, vt, N*K, MA);
    auto f = g.flow(vs, vt, N*K);
    vector<string> ans(N, string(N, '.'));
    for ( auto e : g.edges() ) {
        if ( e.from != vs && e.to != vt && e.flow > 0 ) {
            ans[e.from][e.to-N] = 'X';
        }
    }
    cout << (MA*K*N)-f.second << "\n";
    for ( auto ans1 : ans ) {
        cout << ans1 << "\n";
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100001;
ll dp[N][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,0,sizeof(dp));
    for(int i = 0; i <= N; ++i) dp[i][1] = 1e18;
    int n,w; ll m = 0; cin>>n>>w; int a[n+1][2]; dp[0][0] = 1, dp[0][1] = 0;
    for(int i = 1; i <= n; ++i) cin>>a[i][0]>>a[i][1];
    for(int i = 1; i <= n; ++i) {
        for(int j = N; j >= 1; --j) {
            if(j >= a[i][1] && dp[j-a[i][1]][0]) {
                dp[j][0] = 1;
                dp[j][1] = min(dp[j][1],dp[j-a[i][1]][1]+a[i][0]);
            }
        }
    }
    for(ll i = N; i >= 1; --i) {
        if(dp[i][1] <= w)
            m = max(m,i);
    }
    cout<<m<<"\n";
}

Measured memory_bytes: 1792
package main

import (
"fmt"
"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func main(){
	var n,k,num int
	var ashiba []int
	var DP []int

	//case when k == 2
	fmt.Scan(&n,&k)
	for i:=0;i<n;i++{
		fmt.Scan(&num)
		ashiba = append(ashiba,num)
		DP = append(DP,1000000000)
	}
	DP[0] = 0
	for i:=1;i<n;i++{
		for j:=0;j<min(i,k)+1;j++{
			DP[i] = min(DP[i-j] + abs(ashiba[i] - ashiba[i-j]),DP[i])
		}
	}
	fmt.Println(DP[n-1])
	//DP[3] = DP[3-2]+(3-(3-2))_move,DP[3-1]+(3-(3-1))_move
	// ...
	//DP[x] = DP[x-k]+abs(DP[x]-DP[x-k]) ... DP[x-3]+abs(DP[x]-DP[(x-3)-k]),DP[x-2]+abs(DP[x]-DP[(x-2)-k]),DP[x-1]+abs(DP[x]-DP[(x-1)-k])
}


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

#define pb push_back
     
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,a,b;
	cin>>a>>b;
	ll a1=ceil((float)a*25/2),a2=floor((a+1)*25/2);
	//cout<<a1<<" "<<a2<<" ";
	ll h=-1;
	for(ll i=a1-1;i<=a2+1;i++){
		if(i/10==b && i*2/25==a){
			h=i;
			break;
		}
	}
	cout<<h;

	return 0;
}

Measured memory_bytes: 256
//j 2 3 4 7 1 j
//? ? ? ? ? ?
//j 2 3 4 7 1 j
#include <iostream>
using namespace std;
int main()
{
	int n,total=0;
	cin>>n;
	int a[n+1],b[n];
	for (int i=2;i<=n;i++)  cin>>a[i];
	a[1]=0x3ffffff;
	a[n+1]=0x3ffffff;
	for (int i=1;i<=n;i++)
	{
		b[i]=min(a[i],a[i+1]);
	}
	for (int i=1;i<=n;i++)  total+=b[i];
	cout<<total<<endl;
	return 0;
}

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

const int maxn=1e5+10;

int n,A,B,D,cnt[maxn],f[maxn];
LL sz[maxn];

struct Point{
	int x,y,id;
	Point() {}
	Point(int x,int y,int id):x(x),y(y),id(id) {}
	bool operator < (const Point &p) const {return x==p.x?y<p.y:x<p.x;}
	bool operator <= (const Point &p) const {return x==p.x?y<=p.y:x<p.x;}
	bool operator == (const Point &p) const {return x==p.x&&y==p.y;}
}P[maxn];

int find(int x) {return x==f[x]?x:f[x]=find(f[x]);}

void Union(int x,int y,int times)
{
	x=find(x); y=find(y);
	if (x==y) {sz[x]+=times; return;}
	sz[x]+=times+sz[y];
	sz[y]=0; f[y]=x;
}

void solve(int flag)
{
	int i,L=1,R=0;
	memset(cnt,0,sizeof(cnt));
	for (i=1;i<=n;i++)
	{
		while (L<=n&&P[L]<Point(P[i].x-D,P[i].y-D+flag,0)) L++;
		while (R<n&&P[R+1]<=Point(P[i].x-D,P[i].y+D-flag,0)) R++;
		if (L<=R) Union(P[i].id,P[L].id,1),cnt[L]++,cnt[R]--;
	}
	for (i=1;i<n;i++)
		if (cnt[i]+=cnt[i-1]) Union(P[i].id,P[i+1].id,cnt[i]);
}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	scanf("%d%d%d",&n,&A,&B);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&P[i].x,&P[i].y);
		P[i]=Point(P[i].x-P[i].y,P[i].x+P[i].y,i);
	}
	D=max(abs(P[A].x-P[B].x),abs(P[A].y-P[B].y));
	for (i=1;i<=n;i++) f[i]=i,sz[i]=0;
	sort(P+1,P+n+1);
	solve(0);
	for (i=1;i<=n;i++)
		swap(P[i].x,P[i].y);
	sort(P+1,P+n+1);
	solve(1);
	printf("%lld\n",sz[find(A)]);
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n,k;
    cin>>n>>k;
    vb canuse(10,true);
    rep(i,0,k){
        int dis;
        cin>>dis;
        canuse[dis]=false;
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        rep(d,0,10){
            if(canuse[d]){
                int pv=v*10+d;
                if(pv>=n){
                    cout<<pv<<endl;
                    return 0;
                }
                if(pv!=v)q.push(pv);
            }
        }
    }
    return 0;
}




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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n, z, w;
  cin >> n >> z >> w;
  vec<ll> a(n);
  scan(a);

  ll ret = abs(a[n - 1] - w);
  rep(i, 0, n - 1) {
    ll min_diff = abs(a[i] - a[n - 1]);
    rep(j, i + 2, n) {
      if (min_diff < abs(a[j] - a[n - 1])) continue;
      min_diff = abs(a[j] - a[n - 1]);
    }

    ret = max(ret, min_diff);
  }

  put(ret);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int maxA = *max_element(a.begin(), a.end());
	int minA = *min_element(a.begin(), a.end());
	cout << maxA - minA << endl;
	
	return 0;
}


Measured memory_bytes: 256