akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		try {
			BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
			String line;
			while ((line = stdReader.readLine()) != null){
				String[] temp = line.split(" ");
				put(Integer.parseInt(temp[0]), Integer.parseInt(temp[1]), Integer.parseInt(temp[2]));
			}
		} catch (Exception e) {
			e.getStackTrace();
			System.exit(0);
		}
	}

	private static void put(int a, int b, int c){
		if(a < b && b < c){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24324
#Warshall Floyd
H, W = map(int, input().split())

def solve():
    d = []
    for i in range(10): #ひとまず枝があるペアは枝の長さをセット
        d.append(list(map(int, input().split())))

    A=[0]*H
    for i in range(H):
        A[i] = list(map(int, input().split()))

    #三重ループ
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])

    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j]!=-1:
                ans += d[A[i][j]][1]
    return ans
print(solve())


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const int INF = 1000000000;
static int land_mat[200][200];
static int sea_mat[200][200];

int main(){
	ios_base::sync_with_stdio(false);;
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				land_mat[i][j] = sea_mat[i][j] = INF;
			}
			land_mat[i][i] = sea_mat[i][i] = 0;
		}
		for(int i = 0; i < m; ++i){
			int a, b, c;
			string t;
			cin >> a >> b >> c >> t;
			--a; --b;
			if(t[0] == 'S'){
				sea_mat[a][b] = min(sea_mat[a][b], c);
				sea_mat[b][a] = min(sea_mat[b][a], c);
			}else{
				land_mat[a][b] = min(land_mat[a][b], c);
				land_mat[b][a] = min(land_mat[b][a], c);
			}
		}
		for(int k = 0; k < n; ++k){
			for(int i = 0; i < n; ++i){
				for(int j = 0; j < n; ++j){
					land_mat[i][j] = min(
						land_mat[i][j], land_mat[i][k] + land_mat[k][j]);
					sea_mat[i][j] = min(
						sea_mat[i][j], sea_mat[i][k] + sea_mat[k][j]);
				}
			}
		}
		int r;
		cin >> r;
		vector<int> z(r);
		for(int i = 0; i < r; ++i){
			cin >> z[i];
			--z[i];
		}
		int answer = 0;
		vector<int> cur(n, INF);
		cur[z[0]] = 0;
		for(int i = 1; i < r; ++i){
			const int u = z[i - 1], v = z[i];
			vector<int> from_dist(n, INF);
			vector<int> to_dist(n, INF);
			for(int j = 0; j < n; ++j){
				from_dist[j] = land_mat[u][j];
				to_dist[j]   = land_mat[j][v];
			}
			vector<int> next(n, INF);
			if(land_mat[u][v] < INF){
				for(int j = 0; j < n; ++j){
					if(cur[j] >= INF){ continue; }
					next[j] = cur[j] + land_mat[u][v];
				}
			}
			for(int j = 0; j < n; ++j){
				if(cur[j] >= INF){ continue; }
				if(from_dist[j] >= INF){ continue; }
				for(int k = 0; k < n; ++k){
					if(to_dist[k] >= INF){ continue; }
					const int sea_dist = sea_mat[j][k];
					if(sea_dist >= INF){ continue; }
					next[k] = min(
						next[k], cur[j] + from_dist[j] + sea_dist + to_dist[k]);
				}
			}
			cur.swap(next);
		}
		cout << *min_element(cur.begin(), cur.end()) << endl;
	}
	return 0;
}

Measured memory_bytes: 1528
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1<<30;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    ll x, y;
    cin >> x >> y;
    int res = 0;
    while(x<=y){
        res += 1;
        x *= 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()
int n,ans;
string s;
//グローバル変数じゃないとWAに
void solve(){
    

    cin>>n>>s;
    rep(i,1000){
      int f[3]={i/100,(i/10)%10,i%10};
      int cur=0;
      rep(j,n){
        if(s[j]==('0'+f[cur]))cur++;
        if(cur==3)break;
      }
      if(cur==3)ans++;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 384
NOT_FREE = 1
FREE = 0
 
q = [0 for i in range(8)]
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dneg = [0 for i in range (16)]
dpos = [0 for i in range (16)]
 
 
def printBord():
    for r in range(8):
        for c in range(8):
            if q[r] == c:
                print("Q",end="")
            else: print(".",end="")
        print()
 
 
def putQueen(i):
    if i == 8:
        printBord()
        return
     
    if row[i]:
        if putQueen(i+1):return
 
    for j in range(8):
        if (row[i] or col[j] or dpos[i+j] or dneg[i-j+7]) == NOT_FREE :continue
        q[i] = j
        col[j] = dpos[i+j] = dneg[i-j+7] = NOT_FREE
        if putQueen(i+1) : return
        col[j] = dpos[i+j] = dneg[i-j+7] = FREE
    return
 
 
if __name__=='__main__':
    k = int(input())
    for i in range(k):
        r, c = (int(x) for x in input().split())
        q[r] = c
        row[r] = col[c] = dpos[r+c] = dneg[r-c+7] = NOT_FREE
    putQueen(0)


Measured memory_bytes: 5620
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// # pragma GCC optimize "-O3"
# define int long long
using namespace std;
  
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int cnt[N];

int binpow( int a, int b ) {
	int r = 1;
	while ( b ) {
		if ( b & 1 ) {
			r = r * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return r;
}

int32_t main() {
    speed;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for ( int i = k; i > 0; i-- ) {
    	cnt[i] = binpow( k / i, n );
    	for ( int j = i + i; j <= k; j += i ) {
    		cnt[i] = cnt[i] + mod - cnt[j];
    		if ( cnt[i] > mod ) {
    			cnt[i] -= mod;
    		}
    	}
    	// cout << i << ' ' << cnt[i] << '\n';
    	ans = (ans + cnt[i] * i % mod) % mod;
    }
    cout << ans;
}

Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>

using namespace std;

void reverseStr(string& str) 
{ 
    int n = str.length(); 
     
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    int tam_s = s.size();
    int tam_t = t.size();
    
    int mat[tam_s+1][tam_t+1][3];

    for(int i = 0; i<= tam_s; i++)
    {
        mat[i][0][0] = 0;
        mat[i][0][1] = 0;
        mat[i][0][2] = 0;
    }

    for(int j = 0; j<= tam_t; j++)
    {
        mat[0][j][0] = 0;
        mat[0][j][1] = 0;
        mat[0][j][2] = 0;
    }

    for(int i = 1; i <= tam_s; i++)
    {
        for(int j = 1; j <= tam_t; j++)
        {
            if(s[i-1] == t[j-1])
            {
                mat[i][j][0] = mat[i-1][j-1][0] + 1;
                mat[i][j][1] = -1;
                mat[i][j][2] = -1;
            }
            else 
            {
                if(mat[i-1][j][0] > mat[i][j-1][0])
                {
                    mat[i][j][0] = mat[i-1][j][0];
                    mat[i][j][1] = -1;
                    mat[i][j][2] = 0;
                }
                else 
                {
                    mat[i][j][0] = mat[i][j-1][0];
                    mat[i][j][1] = 0;
                    mat[i][j][2] = -1;
                }
            }
        }
    }
    string resposta = "";
    int i = tam_s;
    int j = tam_t;
    while(mat[i][j][0] != 0)
    {
        int i_mov = mat[i][j][1];
        int j_mov = mat[i][j][2];
        if(i_mov == j_mov)
        {
            resposta += s[i-1];
            i--;
            j--; 
        }
        else 
        {
            i+=i_mov;
            j+=j_mov;
        }
    }


    reverseStr(resposta);
    cout << resposta;
    
    return 0;
}

Measured memory_bytes: 105856
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"image"
	"os"
	"strconv"
)

func main() {
	H, _, K := readInt(), readInt(), readInt()
	y1, x1, y2, x2 := readInt(), readInt(), readInt(), readInt()

	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = read()
	}
	fmt.Println(solve(grid, K, x1, y1, x2, y2))
}

const Inf = 1e9

func solve(grid []string, K, x1, y1, x2, y2 int) int {
	H := len(grid)
	W := len(grid[0])

	start := Point{x1 - 1, y1 - 1}
	goal := Point{x2 - 1, y2 - 1}

	dist := make([][][]int, H)
	for i := 0; i < H; i++ {
		dist[i] = make([][]int, W)
		for j := 0; j < W; j++ {
			dist[i][j] = make([]int, 4)
			for k := 0; k < 4; k++ {
				dist[i][j][k] = Inf
			}
		}
	}

	h := Heap{}

	push := func(state State) {
		if dist[state.Point.Y][state.Point.X][state.Dir] <= state.Dist {
			// 短くなる場合だけpushする
			return
		}
		dist[state.Point.Y][state.Point.X][state.Dir] = state.Dist
		heap.Push(&h, state)
	}

	for i := 0; i < 4; i++ {
		push(State{Point: start, Dir: i, Dist: 0})
	}

	dirs := []Point{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}

	for len(h) > 0 {
		now := heap.Pop(&h).(State)
		if dist[now.Point.Y][now.Point.X][now.Dir] != now.Dist {
			continue
		}

		{
			// 同じ向きに1進むpush
			nextPoint := now.Point.Add(dirs[now.Dir])
			if 0 <= nextPoint.X && nextPoint.X < W && 0 <= nextPoint.Y && nextPoint.Y < H {
				if grid[nextPoint.Y][nextPoint.X] == '.' {
					push(State{
						Point: nextPoint,
						Dir:   now.Dir,
						Dist:  now.Dist + 1,
					})
				}
			}
		}
		for i := 0; i < 4; i++ {
			// 向きを変更するpush
			push(State{
				Point: now.Point,
				Dir:   i,
				Dist:  (now.Dist + K - 1) / K * K,
			})
		}
	}

	ans := Min(dist[goal.Y][goal.X]...)
	if ans == Inf {
		return -1
	}
	return (ans + K - 1) / K
}

type Point = image.Point

type State struct {
	Point Point
	Dir   int
	Dist  int
}

type HeapElement = State
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i].Dist < h[j].Dist }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

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

func readInt() int {
	a, _ := strconv.Atoi(read())
	return a
}


Measured memory_bytes: 187540
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll ;
typedef long double ld ;
typedef pair<ll, ll> pairs;
 
 
ll h[100009] ;
ll v[100009] ;
 
int main()
{
   //        freopen("milkorder.out", "w", stdout) ;
     //   freopen("milkorder.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll n , k = 2 ; cin >> n ;
    for ( ll i = 0 ; i < n ; i++ ) cin >> h[i] ;
    for ( ll i = 1 ; i < min( n , k ) ; i++ ) v[i] = abs( h[i] - h[0] ) ;
    for ( ll i = k ; i < n  ; i++ ){ v[i] = 1000000009 ;
        for ( ll j = i - k; j < i ; j++ ){
            v[i] = min( v[i] , ( v[j] + abs( h[i] - h[j] ) ) ) ;
            //cout << x << " " << y << " " << v[x] <<  "\n\n" ;
        }
    }  cout << v[n-1] ;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
string S[1000000];
typedef pair<int, int> P;
vector<P> p1, p2;
int all[1000000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> S[i];
    for(int i = 0; i < N; i++){
        int cnt = 0;
        int c_min = 0;
        for(char c : S[i]){
            if(c == '(') cnt++;
            else cnt--;
            c_min = min(c_min, cnt);
        }
        // cout << c_min << ' ' << cnt << endl;
        if(cnt >= 0) p1.push_back(P(c_min, cnt));
        else{
            int cnt = 0;
            int c_min = 0;
            int n = S[i].size();
            for(int j = n-1; j >= 0; j--){
                char c = S[i][j];
                if(c == ')') cnt++;
                else cnt--;
                c_min = min(c_min, cnt);
            }
            // cout << c_min << ' ' << cnt << endl;
            p2.push_back(P(c_min, cnt));
        }
    }
    sort(p1.begin(), p1.end(), greater<P>());
    sort(p2.begin(), p2.end(), greater<P>());
    int suml = 0;
    int sumr = 0;
    for(auto p : p1){
        if(suml+p.first < 0){
            cout << "No" << endl;
            return 0;
        }
        suml += p.second;
    }
    for(auto p : p2){
        if(sumr+p.first < 0){
            cout << "No" << endl;
            return 0;
        }
        sumr += p.second;
    }
    if(suml == sumr){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

const int N = 100010;
const int moder = 1e9 + 7;

int n, cnt[N];

int power_mod(int a, int index){
	int ans = 1;
	while (index){
		if (index & 1){
			ans = 1ll * a * ans % moder;
		}
		a = 1ll * a * a % moder;
		index >>= 1;
	}
	return ans;
}

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		++ cnt[x];
	}
	if (n & 1){
		if (cnt[0] != 1){
			return printf("0\n"), 0;
		}
		for (int i = 2; i < n; i += 2){
			if (cnt[i] != 2){
				return printf("0\n"), 0;
			}
		}
	}
	else{
		for (int i = 1; i < n; i += 2){
			if (cnt[i] != 2){
				return printf("0\n"), 0;
			}
		}
	}
	return printf("%d\n", power_mod(2, n >> 1)), 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int N=100005;
char s[N];
int n,a[N];
bool check(int x) {
  int r=x,l=n-x+1;
  if(((a[r]-a[l-1])==0) || ((a[r]-a[l-1])==(r-l+1))) return 1;
  return 0;
}
int main() {
  scanf("%s",s+1);
  n=strlen(s+1);
  for (int i=1;i<=n;++i) a[i]=a[i-1]+(s[i]&15);
  for (int i=n;i>=n/2;--i) {
    if(check(i)) {
      printf("%d\n",i);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

vi yakusu(int m){
    vi ret;
    for(int p=1; p*p<=m; p++){
        if(m%p!=0) continue;
        ret.pb(p);
        if(p!=m/p) ret.pb(m/p);
    }
    sort(all(ret));
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vi a=yakusu(n),  b=yakusu(n-1);
    int res=b.size()-1;
    rep(i,a.size()){
        if(a[i]==1) continue;
        int t=n;
        while(t%a[i]==0) t/=a[i];
        if(t%a[i]==1) res++;
    }
    cout<<res<<endl;

    
}

Measured memory_bytes: 3644
import sys
import collections


#https://python.ms/factorize/
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def main():
    input = sys.stdin.readline
    change_to_count_list = []
    for i in range(62):
        if i == 0:
            change_to_count_list.append(1)
        else:
            change_to_count_list.append(change_to_count_list[i-1]+i+1)
    N = int(input())
    yakusu_list = factorize(N)
    c = collections.Counter(yakusu_list)
    result = 0
    for count in c.values():
        for i in range(62):
            if change_to_count_list[i] == count:
                if i == 0:
                    result += 1
                    break
                else:
                    result += i + 1
                    break

            elif change_to_count_list[i-1] < count and change_to_count_list[i] > count:
                result += i
                break
    print(result)


if __name__ == '__main__':
    main()

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


def solve(S_A: str, S_B: str, S_C: str):
    hands = {
        'a': S_A,
        'b': S_B,
        'c': S_C,
    }
    turn = 'a'
    while True:
        if hands[turn] == "":
            print(turn.upper())
            return
        s = hands[turn]
        hands[turn] = s[1:]
        turn = s[0]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S_A = next(tokens)  # type: str
    S_B = next(tokens)  # type: str
    S_C = next(tokens)  # type: str
    solve(S_A, S_B, S_C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int six = 0;
		int nine = 0;
		int sum = 0;
		int count = 0;
		int ans = 10000;

		
		for(int i = 0;i <= N;i++){
			six = i;
			nine = N - i;

			while(six > 0){
				count += six % 6;
				six /= 6;
			}

			while(nine > 0){
				count += nine % 9;
				nine /= 9;
			}

			if(count < ans){
				ans = count;
			}
			count = 0;

		}

		System.out.println(ans);

	}
}



Measured memory_bytes: 22100
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int a,b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << LF;


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  A = (A+11)%13;
  B = (B+11)%13;
  if(A==B) {
    cout << "Draw" << endl;
  } else if(A>B) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)

int main() {
	double array[11];
	
	while (cin >> array[1]) {
		rep(i, 9) {
			if ((i + 2) % 2 == 0) {
				array[i + 2] = array[i + 1] * 2;
			}
			else {
				array[i + 2] = array[i + 1] / 3;
			}
		}

		double sum = 0;
		rep(i, 10) {
			sum += array[i + 1];
		}

		printf("%.7f\n",sum);
		
		
	}
}

Measured memory_bytes: 3152
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int vis[N];
int main()
{
    int n,k;
    read(n),read(k);
    for(re int i=1;i<=k;i++)
    {
        int tot;read(tot);
        for(re int j=1,x;j<=tot;j++)
        {
            read(x);
            vis[x]++;
        }
    }
    int ans=0;
    for(re int i=1;i<=n;i++) if(!vis[i]) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int sou=0;
    for(int i=0;i<s.size();i++){
        if((s[i]+i)%2!=0)sou++;//頭白とする
    }
    cout << min(sou,int(s.size()-sou)) << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, A, B);
  cout << min(N * A, B) << endl;

  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const int INF=111111111;
int n,k;
int a[111111];
const int N=5005;
const int K=5005;
bool dp[N][K];
int t[N];

void dynamic_programming(int x){
	rep(i,N)rep(j,K)dp[i][j]=0;
	int pos=0;
	rep(i,n)if(x!=i)t[pos++]=a[i];

	dp[0][0]=1;
	rep(i,pos){
		rep(j,K+1){
			if(dp[i][j]){
				if(j+t[i]<=K){dp[i+1][j+t[i]]=1;}
				dp[i+1][j]=1;
			}
		}
	}

	//rep(i,k+1)if(dp[pos][i])cout<<i<<" ";
}

int main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);

	int ans=0;
	int l=-1,r=n,mid=(l+r)/2;

	while(r-l>1){
		//cout<<mid<<endl;
		bool is=0;
		dynamic_programming(mid);
		if(k-a[mid]<=0)is=1;
		else for(int j=k-a[mid];j<k;j++)if(dp[n-1][j])is=1;
		if(!is)l=mid;//不要
		else r=mid;
		mid=(r+l)/2;
	}
	
	/*
	rep(i,n){
		dynamic_programming(i);//iをぬいたカードでdpをする
		bool is=0;
		if(k-a[i]<=0)is=1;
		else for(int j=k-a[i];j<k;j++)if(dp[n-1][j])is=1;
		if(!is)ans++;
		//if(!is)cout<<a[i]<<endl;
	}*/
	if(l+1!=r)while(true);
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 24832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int p;

int f(int yi, int xi, int yj, int xj, const vector<vector<int>> &r ){
    int ret = r[yj-1][xj-1];
    if(yj-1>=0 && xi-1>=0)ret -= r[yj-1][xi-1];
    if(yi-1>=0 && xj-1>=0)ret -= r[yi-1][xj-1];
    if(yi-1>=0 && xi-1>=0)ret += r[yi-1][xi-1];
    
    return ret;
}

pii merge(pii a, pii b){
    pii ret;
    ret.first = a.first+b.first;
    ret.second = min(a.second, b.second);
    if(ret.second>=p)return ret;
    else return pii(-INF, -INF);
}

pii dp[33][33][33][33];
pii dfs(int yi, int xi, int yj, int xj, const vector<vector<int>> &inp, const vector<vector<int>> &r){
    if(dp[yi][xi][yj][xj]!=pii(-INF, -INF)) return dp[yi][xi][yj][xj];
    pii ret = pii(-INF, -INF);
    
    int res = f(yi, xi, yj, xj, r);
    if(res>=p)ret = pii(1, res);
    else return dp[yi][xi][yj][xj] = pii(-INF, -INF);
    
    for(int i=yi+1;i<yj;i++){
        ret = max(ret, merge(dfs(yi,xi,i,xj,inp,r), dfs(i,xi,yj,xj,inp,r)));
    }

    for(int j=xi+1;j<xj;j++){
        ret = max(ret, merge(dfs(yi,xi,yj,j,inp,r), dfs(yi,j,yj,xj,inp,r)));
    }
    
    return dp[yi][xi][yj][xj] = ret;
}

int main(){
    int h,w,s;
    while(cin>>h>>w>>s&&(h||w||s)){
        rep(i,33)rep(j,33)rep(k,33)rep(l,33)dp[i][j][k][l] = pii(-INF, -INF);
        vector<vector<int>> inp(h, vector<int>(w));
        rep(i,h) rep(j,w) cin>>inp[i][j];
        int sum = 0;
        rep(i,h) rep(j,w) sum += inp[i][j];
        p = sum-s;

        vector<vector<int>> r = inp;
        for(int i=1;i<h;i++) rep(j,w) r[i][j] += r[i-1][j];
        for(int j=1;j<w;j++) rep(i,h) r[i][j] += r[i][j-1];
        
        
        int a,b;
        tie(a,b) = dfs(0,0,h,w,inp, r);
        cout<<a<<" "<<b-sum+s<<endl;
    }
    
}



Measured memory_bytes: 12432
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << a << " " << b << " " << 3*c-a-b << endl;
    cout << 4*c-2*a-b << " " << c << " " << 2*a+b-2*c << endl;
    cout << a+b-c << " " << 2*c-b << " " << 2*c-a << endl;
    return 0;
}

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

int main(){
    while(1) {
        int H,W;
    cin >> H>>W;
    if (H ==0 && W ==0) break;
    
    for (int i =0;i<H;i++){
         for (int j = 0 ;j<W;j++) {
         if (i ==0 || i== H-1 || j == 0 || j == W-1) cout <<"#";
         else cout<<".";
         }
         cout <<endl;
    }
     
    cout<<endl;
    
    }
}
    


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 305;
// const int MAX = 4;
/* global variables */
/* funciton */
/* main */
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    // dp[i] : i個, true - win, false - lose
    vector<bool> dp(K+1, false);
    dp[0] = false;
    for (int i = 0; i < K; i++) {
        for (int x : a) {
            int ne = i + x;
            if (ne > K) continue;
            if (dp[i] == false) dp[ne] = true;
        }
    }
    if (dp[K]) cout << "First" << '\n';
    else cout << "Second" << '\n';
}

Measured memory_bytes: 3672
import java.io.BufferedReader
import java.io.InputStreamReader

fun selectionSort(a: IntArray): Int {
    var cnt = 0
    for (i in 0 until a.size-1) {
        val minIdx = (i until a.size).minBy { a[it] }
        if (minIdx != i)
            minIdx?.let { cnt++; val t = a[i]; a[i] = a[minIdx]; a[minIdx] = t }
    }
    println(a.joinToString(separator = " "))
    return cnt
}

fun main(args: Array<String>) {
    val a = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())
            .map { it.toInt() }
            .drop(n = 1)
            .toIntArray()

    println(selectionSort(a))
}


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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
  int X,A;
  cin >> X >> A;
  if(X < A)
   cout << 0 << endl;
   else cout << 10 << endl;
}



Measured memory_bytes: 256
b = []
while True:
    a = input().split()
    if a[1] == "?":
        break
    elif a[1] == "+":
        b.append(int(a[0])+int(a[2]))
    elif a[1] == "-":
        b.append(int(a[0])-int(a[2]))
    elif a[1] == "*":
        b.append(int(a[0])*int(a[2]))
    else:
        b.append(int(a[0])//int(a[2]))

for i in b:
    print(i)


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

int main() {
    int n ;
    string s;
    int a=0,b=0,c=0,d=0;
    cin >> n;
  for(int i=0;i<n;i++){
     cin >> s;
     if(s=="AC") ++a;
     else if(s=="WA") ++b;
    else if(s =="TLE") ++c;
    else ++d;
    }
    cout << "AC x " << a <<endl;
  cout << "WA x " << b<<endl;
  cout << "TLE x " << c <<endl;
  cout << "RE x " << d<<endl;
    }

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

int main()
{
    int n;
    while(cin >> n)
    {
        int ans = 0;
        for(int i=0;i<=9;i++)
        {
            for(int j=0;j<=9;j++)
            {
                for(int k=0;k<=9;k++)
                {
                    int x = n - i - j - k;
//                    cout << i << ' ' << j << ' ' << k << ' ' << x << endl;
                    if(x >= 0 && x < 10) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;

}

Measured memory_bytes: 1160
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 100031;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	int n;
	cin>>n;
	if (n%10==9||n/10==9)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 764
r, c = map(int,input().split())
a=[]
for i in range(r):
    a.append(list(map(int,input().split())))
    a[i].append(0)
    aic = 0
    for k in range(c):
        aic = aic + a[i][k]
    a[i][c] = aic
a.append([0for i in range(c+1)])
for k in range(c):
    ark = 0
    for i in range(r):
        ark = ark + a[i][k]
    a[r][k] = ark
arc = 0
for i in range(r):
    arc = arc +a[i][c]
a[r][c] = arc

for i in range(r+1):
    for k in range(c+1):
        if k == c:
            print('{}'.format(a[i][k]), end = "")
        else:
            print('{} '.format(a[i][k]), end = "")
    print()


Measured memory_bytes: 6204
<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));
$str = trim(fgets(STDIN));

$b = 0;
if($str[0] == 0)$s[] = 0;
for($i = 0; $i < $n - 1; $i++){
    if($str[$i] != $str[$i+1]){
        $s[] = ($i+1) - $b;
        $b = $i+1;
    }
}
$s[] = $n - $b;
$len = count($s);
$sum = 0;
$max = 0;
for($i = -$k * 2 - 2; $i <= $len; $i+=2){
    $sum += @$s[$i + $k * 2 + 1] + @$s[$i + $k * 2 + 2];
    $sum -= @$s[$i] + @$s[$i + 1];
    $max = max($max, $sum);
}
echo $max;

Measured memory_bytes: 10744
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 900000
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int N, M, K, T, L, R, S, B[MAXN+5], fac[MAXN+5], efac[MAXN+5], ans;
inline int fastpow(int s, int n){int a = 1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
inline int C(int n, int k){return n<0||k<0||n<k?0:1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	N = read(), M = read(), K = read(), T = N+M+K, S = 1;
	B[0] = 1; for(rint i = 1; i <= T; B[i] = 3u*B[i-1]%MOD, i++);
	fac[0] = 1; for(rint i = 1; i <= T; fac[i] = 1ll*i*fac[i-1]%MOD, i++);
	efac[T] = fastpow(fac[T],MOD-2); for(rint i = T; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--);
	for(rint p = N; p <= T; )
	{
		ans = (ans+1ll*B[T-p]*C(p-1,N-1)%MOD*S)%MOD;
		S = (2ll*S+C(p-N,L-1)+C(p-N,R+1))%MOD, ++p, ++R;
		p-N-L > K ? S = (S+MOD-C(p-N,L)), S<MOD?:S-=MOD, ++L : 0;
		R > M ? S = (S+MOD-C(p-N,R)), S<MOD?:S-=MOD, --R : 0; if(L>R) break;
	}	printf("%d\n",ans); return 0;
}

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

signed main(){
	vector<char> S(4);
	for(int i = 0; i < 4; i++){
		scanf("%c", &S[i]);
	}
	sort(S.begin(), S.end());
	if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	for (int i = 0; i < N; i++) cin >> A[i];
	A[N] = 0;
	vector<int> B(N);
	int sum = 0, now = 0;
	for (int i = 0; i < N; i++) {
		sum += abs(A[i] - now);
		if ((A[i] - now > 0) == (A[i + 1] - A[i] > 0)) B[i] = 0;
		else B[i] = 2 * min(abs(A[i] - now), abs(A[i + 1] - A[i]));
		now = A[i];
	}
	sum += abs(A[N - 1]);
	for (int b : B) cout << sum - b << endl;
}


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

int main()
{
    float a,b,c;
    float counter_five=0,counter_seven=0;
    cin >>a;
    cin >>b;
    cin>>c;
    if(a==5)
    {
        counter_five++;
    }
    else if(a==7)
    {
        counter_seven++;
    }
    if(b==5)
    {
        counter_five++;
    }
    else if(b==7)
    {
        counter_seven++;
    }
    if(c==5)
    {
        counter_five++;
    }
    else if(c==7)
    {
        counter_seven++;
    }
    if(counter_five==2 && counter_seven==1)
    {
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


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

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  vector<vector<int>> c(H, vector<int>(W));
  int x = 0;
  int y = 0;
  for (int i = 0; i < N; ++i) {
    int cnt = 0;
    while (cnt < A[i]) {
      c[x][y] = i + 1;
      if (x % 2 == 0) {
        ++y;
        if (y >= W) {
          --y;
          ++x;
        }
      } else {
        --y;
        if (y < 0) {
          ++y;
          ++x;
        }
      }
      ++cnt;
    }
  }
  
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W - 1; ++j) cout << c[i][j] << " ";
    cout << c[i][W - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import scala.annotation.tailrec

object Main extends App {
  val Array(_, pointX) = io.StdIn.readLine().split(' ').map(_.toInt)
  val cities = io.StdIn.readLine().split(' ').map(_.toInt)
  val distance = new Distance
  println(distance.getD(cities, pointX))
}

class Distance {
  def getD(citiesPoInt : Seq[Int], startPoint : Int): Int = {
     // 都市と座標Xとの距離(絶対値を求める、距離0(座標X=都市)は含めない、最大公約数を求めやすいように降順ソート)
    val distance : Seq[Int] = citiesPoInt.filter(p => p != startPoint).map(f => (f - startPoint).abs).sorted(Ordering[Int].reverse)

    // 全ての距離の最大公約数を求める。
    distance.foldLeft(0) { (acc, x) => calcGCF(x, acc)}
  }

  /*
   * 2数の最大公約数を求める
   */
  @tailrec
  private def calcGCF(a : Int, b : Int): Int = b match{
    case 0 => a
    case _ if b < a => calcGCF(b, a % b)
    case _ => calcGCF(a, b % a)
  }
}


Measured memory_bytes: 42968
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (__typeof(a) i = (a); i < (b); ++i)
#define iter(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1 << 31);

#define sc second
#define fs first
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T>
T smod(T a, T b) {
  return (a % b + b) % b;
}
// vim: cc=60 ts=2 sts=2 sw=2:

int main() {
  // code

  int a, b;
  cin >> a >> b;

  rep(i, 0, 10000) {
    if (floor((float)i * 0.08) == a && floor((float)i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  // codend
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n,x;
    int d;
    cin >> n >> x;
    int a[n];
    rep(i,n){
        int b;
        cin >> b;
        a[i]=abs(x-b);
    }
    rep(i,n){
        if(i==0) d=a[i];
        else d=gcd(d,a[i]);
    }
    cout << d << endl;
}



Measured memory_bytes: 640
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
#define bolt ios::sync_with_stdio(false)
#define ull unsigned long long
#define ll long long
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
using namespace std;

bool ispalindrome(string st) {
	int l = st.size();
	int cnt = 0; int id = 0;
	while (id < l / 2) {
		if (st[id] == st[l - id - 1]) 
			cnt++;
		else 
			break;
		id++;
	}
	if (cnt == l / 2)
		return true;
	else return false;
}
int main() {

/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
#endif*/

	bolt;
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s; cin >> s;
	int n = s.size();
	if (ispalindrome(s)) {
		int y = n / 2;
		if (ispalindrome(s.substr(0, y)) && ispalindrome(s.substr(y + 1, n / 2))) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll a;
    cin>>a;
    ll res = a+a*a+(a*a*a);
    cout << res << "\n";
    return 0;
}


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

int main()
{
    long long N, K;
    cin >> N >> K;

    vector<long long> A(N, 0);
    for (long long &a : A)
    {
        cin >> a;
    }

    vector<long long> sum(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        sum[i + 1] = (sum[i] + A[i]) % K;
    }
    for (int i = 0; i < sum.size(); i++)
    {
        sum[i] -= i;
        sum[i] %= K;
        while (sum[i] < 0)
        {
            sum[i] += K;
        }
    }

    queue<long long> q;
    map<long long, long long> m;
    long long ans = 0;
    for (int i = 0; i < sum.size(); i++)
    {
        ans += m[sum[i]];
        m[sum[i]]++;
        q.push(sum[i]);
        while (q.size() >= K)
        {
            m[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17536
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


	public class Main {
		
		public static int n;
		public static int m;
		public static int q;
		public static int max;
		
		public static int[] a ;
		public static int[] b ;
		public static int[] c ; 
		public static int[] d ;
		public static int[] f ;

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			 n = sc.nextInt();
			 m = sc.nextInt();
			 q = sc.nextInt();
			 
			 a = new int[q];
			 b = new int[q];
			 c = new int[q];
			 d = new int[q];
			 f = new int[n];
			

			
			Map<Integer,Integer> map = new HashMap<Integer,Integer>();
			
			for(int i=0;i<q;i++) {
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
				c[i] = sc.nextInt();
				d[i] = sc.nextInt();
			}
			
			dfs(0,1);
			
			System.out.println(max);
			
		}
		
		private static void dfs(int inde, int num) {
			
			if(inde==n) {
				int count =0;
				
				for(int i=0;i<q;i++) {
					if(f[b[i]-1]-f[a[i]-1]==c[i]) {
						count+=d[i];
					}
				}
				
				max=Math.max(max, count);
				return;
			}
			
			
			for(int i=num;i<=m;i++) {
				f[inde] = i;
				dfs(inde+1,i);
				
			}
			
		}
		
	}


Measured memory_bytes: 37092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    //i番目の数字が最小値かつk番目の数字が最大値
    vector<ll> p(n);
    rep(i,n) cin>>p[i];
    priority_queue<ll, vector<ll>, greater<ll> > que;
    priority_queue<ll> que2;
    ll tmp=0;//単調増加何コンボ目か
    ll nat=0;
    rep(i,k){
        que.push(p[i]);
        que2.push(p[i]);
        if(i==k-1)continue;
        if(p[i+1]>p[i]){
            tmp++;
            if(tmp>=k-1){
                nat++;
            }
        }else tmp=0;
    }
    ll mini=que.top(),maxi=que2.top();
    ll res=0;//resは整列が入ってかつダブっている組、natは整列が入らなかった組
    
    vector<bool> used(n,false);
    for(int i=0;i<n-k;i++){
        if(p[i+k]>p[i+k-1]){
            tmp++;
            if(tmp>=k-1){
                nat++;
                goto OUT;
            }
        }else tmp=0;
        
        if(mini==p[i]&&maxi<p[i+k]) res++;
        OUT:
        used[p[i]]=true;//出ていく
        que.push(p[i+k]);
        que2.push(p[i+k]);
        while(true){
            mini=que.top();
            if(!used[mini])break;//まだ連続列の中にある
            que.pop();
        }
        
        while(true){
            maxi=que2.top();
            if(!used[maxi])break;//まだ連続列の中にある
            que2.pop();
        }
        mini=que.top();maxi=que2.top();
    }
    nat=max((ll)0,nat-1);
    res=(n-k+1)-res-nat;
    cout<<res<<endl;
}


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

int main(){
  string s;
  cin>>s;
  int A;
  A = s.size()-1;
  if(s.at(A)=='s'){
      cout<<s<<"es"<<endl;
  }else{
      cout<<s<<"s"<<endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
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;
}
const long long INF = 1LL << 60;

ll n;
int main()
{
    cin >> n;
    int a, ans = 0;
    rep(i, n)
    {
        cin >> a;
        if (a % 2 == 1 && i % 2 == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  double ans = 0;
  REP(i, n){
    ll d = i+1;
    ll m = 0;
    while(d < k){
      m++;
      d *= 2;
    }
    double p = 1.0/n * pow(0.5, m);
    ans += p;
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4072
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.next();
        
        Deque<Character> stack = new ArrayDeque<>();
        for (char ch : s.toCharArray()) {
            if (ch == 'B') {
                if (!stack.isEmpty()) {
                    stack.removeFirst();
                }
            } else {
                stack.addFirst(ch);
            }
        }
        
        StringBuilder ans = new StringBuilder();
        while (!stack.isEmpty()) {
            ans.append(stack.removeLast());
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972