akhauriyash/Code-Regression huggingface dataset:
// AOJ GRL_6_A: Network Flow - Maximum Flow
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

// Dinic: maximum flow
struct edge
{
  int to, capacity, rev, id, isrev;
  edge(){}
  edge(int to, int capacity, int rev):to(to), capacity(capacity), rev(rev){}
};

struct Dinic
{
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int sz):graph(sz), level(sz), iter(sz){};
  void add_edge(int from, int to, int capacity)
  {
    graph[from].push_back(edge(to, capacity, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, (int)graph[from].size()-1));
  }
  void bfs(int source)
  {
    fill(level.begin(), level.end(), -1);
    queue<int> que;
    level[source] = 0;
    que.push(source);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)graph[v].size(); i++) {
	edge& e = graph[v][i];
	if(e.capacity > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int sink, int f)
  {
    if(v == sink) return f;
    for(int &i = iter[v]; i < (int)graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.capacity > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, sink, min(f, e.capacity));
	if(d > 0) {
	  e.capacity -= d;
	  graph[e.to][e.rev].capacity += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int source, int sink)
  {
    int flow = 0;
    while(1) {
      bfs(source);
      if(level[sink] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      int f; while((f = dfs(source, sink, inf)) > 0) flow += f;
    }
  }
};


int main()
{
  int V, E; cin >> V >> E;
  Dinic mxf(V);
  while(E--) {
    int u, v, c;
    cin >> u >> v >> c;
    mxf.add_edge(u, v, c);
  }
  cout << mxf.max_flow(0, V-1) << endl;
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long int lli;

lli dfs(int v, int prev, vector<vector<pair<int,lli>>> &adj, vector<lli> &res){
    vector<lli> costs;
    for(auto next: adj[v]){
        if(next.first == prev) continue;
        costs.push_back(next.second + dfs(next.first, v, adj, res));
    }
    if(costs.empty()) return 0;
    sort(costs.begin(), costs.end(), greater<lli>());
    for(int i=1; i<(int)costs.size(); i++){
        res.push_back(costs[i]);
    }
    return costs[0];
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<pair<int,lli>>> adj(n);
    for(int i=0; i<n-1; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        adj[a].emplace_back(b, c);
        adj[b].emplace_back(a, c);
    }
    vector<lli> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }

    vector<lli> cost;
    for(int i=0; i<n; i++){
        vector<lli> dist;
        dist.push_back(dfs(i, -1, adj, dist));
        for(auto d: dist){
            cost.push_back(d*s[i]);
        }
    }
    sort(cost.begin(), cost.end(), greater<lli>());
    lli ans = 0;
    for(int i=0; i<min(m, (int)cost.size()); i++){
        ans += cost[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 36044
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

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

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var k, x int

func main() {
	sc.Split(bufio.ScanWords)
	k, x = nextInt(), nextInt()

	if k*500 >= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  string n;
  cin >> n;
  if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    print("Yes");
  else
    print("No");
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
int main(void)
{
  double a,b,c;
  double theta;
  double s,l,h;
  scanf("%lf%lf%lf",&a,&b,&theta);
  theta*=M_PI/180;
  s=a*b*sin(theta)/2;
  c=sqrt(a*a+b*b-2*a*b*cos(theta));
  l=a+b+c;
  h=2*s/a;
  printf("%f\n%f\n%f\n",s,l,h);
  return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<math.h>

using namespace std;
/*
double logn(double base, double antilog) {
    return log(antilog) / log((double)base);
}
*/
int main(){
    long long st=100;
    long long n=0,cnt=0;
    //double tmp1,tmp2;

    cin>>n;
    while(1){
        st=st+st/100;
        cnt++;
        if(st>=n){
            cout<<cnt<<"\n";
            break;
        }
    }
    /*
    tmp2=logn(1.01,tmp1);
    tmp2=(int)tmp2+1;
    */
    //cout<<cnt<<"\n";

    return 0;
}            

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1);
ll s[100500];
int flag;	
ll x;
int main()
{
	
	for(ll i=0;i<=1000;i++)
	{
		ll sum1=1;
		for(int j=0;j<5;j++)
		{
			sum1*=i;
		}
		s[i]=sum1;
	}
	cin>>x;
	for(int i=0;i<=1000;i++)
	{
		for(int j=0;j<=1000;j++)
		{
			if(s[i]-s[j]==x)
			{
				cout<<i<<" "<<j<<endl;
				flag=1;
				break;
			}else if(s[i]+s[j]==x)
			{
				cout<<i<<" "<<-j<<endl;
				flag=1;
				break;
			}
			
		}
		if(flag)
		{
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n,m,k,c,i,j,e,lst,r[302][302];
char s[302][302];
bool was;
int main() {
  scanf("%d%d%d",&n,&m,&k);
  for (i=c=0; i<n; i++) {
    scanf("%s",s[i]);
    lst=-1;
    for (j=0; j<m; j++) if (s[i][j]=='#') {
      c++;
      for (e=lst+1; e<=j; e++) r[i][e]=c;
      lst=j;
    }
    if (lst==-1) {
      for (j=0; j<m; j++) r[i][j]=r[i-1][j];
    } else {
      for (e=lst+1; e<m; e++) r[i][e]=c;
      if (!was) {
        was=true;
        for (e=i-1; e>=0; e--) for (j=0; j<m; j++) r[e][j]=r[e+1][j];
      }
    }
  }
  for (i=0; i<n; i++, puts("")) for (j=0; j<m; j++) printf("%d ",r[i][j]);
  return 0;
}


Measured memory_bytes: 1152
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
s = len(set(inputSL()))

if s == 3:
  print("Three")
else:
  print("Four")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using PII = pair<int, int>;
constexpr int maxn = 500000;
int P[maxn + 1], A[maxn + 1];
PII T[maxn << 2];
#define ls (v << 1)
#define rs (ls | 1)
#define tm ((tl + tr) >> 1)
void update(int v, int tl, int tr, int p, int x){
    if(tl == tr) T[v] = {x, p};
    else{
        if(p <= tm) update(ls, tl, tm, p, x);
        if(p > tm) update(rs, tm + 1, tr, p, x);
        T[v] = max(T[ls], T[rs]);
    }
}
PII get_max(int v, int tl, int tr, int L, int R){
    if(tl >= L and tr <= R) return T[v];
    PII res = {0, -1};
    if(L <= tm) res = max(res, get_max(ls, tl, tm, L, R));
    if(R > tm) res = max(res, get_max(rs, tm + 1, tr, L, R));
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, K;
    cin >> N >> K;
    for(int i = 1; i <= N; i += 1){
        cin >> P[i];
        update(1, 1, N, i, P[i]);
    }
    priority_queue<int> q;
    auto add = [&](const int& i){
        if(i <= 0 || (i - 1) * K >= N) return;
        PII p = get_max(1, 1, N, (i - 1) * K + 1, i * K);
        if(p.first == 0) return;
        if(get_max(1, 1, N, p.second - K + 1, p.second + K - 1) != p) return;
        q.push(p.second);

    };
    for(int i = 1; i <= N; i += K) add((i + K - 1) / K);
    for(int i = N; i; i -= 1){
        while(A[q.top()]) q.pop();
        int p = q.top();
        A[p] = i;
        update(1, 1, N, p, 0);
        for(int j = -1; j <= 1; j += 1) add((p + K - 1) / K + j);
    }
    for(int i = 1; i <= N; i += 1) cout << A[i] << "\n";
    return 0;
}

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

using namespace std;

int const N = 1e2 + 10;

int n, a[N];

long long get (int x)
{
	long long total = 0;

	for (int i = 1; i <= n; i++)
		total += (long long) (a[i] - x) * (long long) (a[i] - x);
	
	return total;
}

void solve ()
{
	long long ans = 1e18;

	for (int i = -100; i <= 100; i++)
		ans = min (ans, get (i));

	printf ("%lld\n", ans);
}

int main ()
{
		scanf ("%d", &n);

		for (int i = 1; i <= n; i++)
			scanf ("%d", &a[i]);

		solve ();

		return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String result = "No";
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i*j == n) {
                    result = "Yes";
                } 
            }
        }
        System.out.println(result);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    
    public boolean hasNext() { 
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin >>k;
	cin>>a>>b;
	int max=b/k;
	bool flag=false;
	for(int i=1;i<=max+2;i++){
		if(i*k<=b&&i*k>=a)flag=true;
	}
	if(flag)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.PriorityQueue;
import java.util.Comparator;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		PriorityQueue<Long> q=new PriorityQueue();
		PriorityQueue<Long> p=new PriorityQueue(Comparator.reverseOrder());
		long[] min=new long[n+1];
		long[] max=new long[n+1];
		long[] mid=new long[n];
		long sumn=0;
		long sumx=0;
		for(int i = 0; i<3*n; i++){
			long a = sc.nextLong();
			if(i<n){
				q.add(a);
				sumx+=a;
			}else if(i>=2*n){
				p.add(a);
				sumn+=a;
			}else{
				mid[i-n]=a;
			}
		}
		max[0]=sumx;
		min[0]=sumn;
		for(int i = 1; i<=n; i++){
			q.add(mid[i-1]);
			p.add(mid[n-i]);
			max[i]=max[i-1]+mid[i-1]-q.poll();
			min[i]=min[i-1]+mid[n-i]-p.poll();
		}
		long ans=Long.MIN_VALUE;
		for(int i = 0; i<=n; i++){
			ans=Math.max(ans,max[i]-min[n-i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 103288
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   int a[n];
   unordered_map<int,int> m;
   for(int i=0;i<n;i++){
    cin>>a[i];
   }
   int allgcd=a[0];
   for(int i=1;i<n;i++){
    allgcd=__gcd(a[i],allgcd);
   }
   const int N=1000001;
   vector<char> is_prime(N+1, true);
   is_prime[0] = is_prime[1] = false;
   for (int i = 2; i <= N; i++) {
    if (is_prime[i] && (long long)i * i <= N) {
        for (int j = i * i; j <= N; j += i)
            is_prime[j] = false;
    }
   }
   vector<int> c;
   for(int i=0;i<=N/2;i++){
       if(is_prime[i]){
           c.emplace_back(i);
       }
   }
  int g=1;
   for(int i=0;i<n;i++){
       int l=a[i];
       if(is_prime[l]){
           m[l]++;
           if(m[l]>1){
           	 g=0;
           	 i=n;
           }
       }else{
      for(int j=0;j<(int)c.size();j++){
          if(is_prime[l]){
              m[l]++;
              if(m[l]>1){
              	g=0;
              	i=n;
              }
              break;
          }
        if(l%c[j]==0){
          m[c[j]]++;
          if(m[c[j]]>1){
          	g=0;
          	i=n;
          	break;
          }
          while(l%c[j]==0){
               l=l/c[j];
          }
        }
        if(l<c[j]){
            break;
        }
      }
       }
   }
   
   if(g){
    cout<<"pairwise coprime"<<"\n";
    return 0;
   }
   if(allgcd==1){
      cout<<"setwise coprime"<<"\n";
      return 0;
   }
   cout<<"not coprime"<<"\n";
   return 0;


   
}


Measured memory_bytes: 8452
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 1000003
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll d,s,t;
    cin>>d>>s>>t;
    if(d>(t*s)){cout<<"No";}
    else cout<<"Yes";
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main() {
  char c;
  cin>>c;
  string j = "aiueo";
  for(int i = 0;i < 5;i++){
    if( c == j.at(i)){
      cout<<"vowel"<<endl;
      return 0;
    }
  }
  cout<<"consonant"<<endl;
  }

Measured memory_bytes: 3104
n = int(input())
c = input()
ans = 0
a = 0
b = n-1
while(a < b):
  while(a < n and c[a] == 'R'):
    a += 1
  while(b >= 0 and c[b] == 'W'):
    b -= 1
  if a < b:
    ans += 1
    a += 1
    b -= 1
print(ans)


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

int mas[300];
int memo[300];
int isGorl[300];

int Max;
int n;

void dfs(int i){
  if(i < 0) i = 0;
  if(i >= n) i = n-1;
  if(memo[i] != 0) return;
  memo[i] = 1;
  for(int j = 1;j <= Max;j++){
    int tmp = i+j;
    if(i+j < n) tmp += mas[i+j];
    dfs(tmp);
  }

  return;
}

bool flag;

void gorldfs(int i){
  if(i < 0) i = 0;
  if(i >= n) i = n-1;
  if(memo[i] != 0) return;
  if(isGorl[i] == 0){
    flag = true;
  }
  memo[i] = 1;
  for(int j = 1;j <= Max;j++){
    int tmp = i+j;
    if(tmp < n) tmp += mas[tmp];
    gorldfs(tmp);
  }

  return;
}

int main(){
  while(1){
    flag = false;

    cin >> Max;
    if(Max == 0) break;
    cin >> n;
    for(int i = 0;i < n;i++) scanf("%d",&mas[i+1]);
    n += 2;

    int i;
    for(i = n-1;i >= 0;i--){
      for(int x = 0;x < 300;x++) memo[x] = 0;
      dfs(i);
      if(memo[n-1] == 1){
        isGorl[i] = 1;
      }else{
        isGorl[i] = 0;
      }
    }

    for(int x = 0;x < 300;x++) memo[x] = 0;
    gorldfs(0);
    if(flag) cout << "NG" << endl; else cout << "OK" << endl;
  }



  return 0;
}



Measured memory_bytes: 3148
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			int n = sc.nextInt();
			long[] array = new long[n];
			for (int i=0; i<n; i++) array[i] = sc.nextLong();
			int times = sc.nextInt();  //queryの数
			for (int i=0; i<times; i++) {
				int start = sc.nextInt();
				int end = sc.nextInt();
				int target = sc.nextInt();
				//count(start,end,target)
				int count = 0;
				for (int j=start; j<end; j++) {
					if (array[j] == target) count++;
				}
				System.out.println(count);
			}
		}
	}
}



Measured memory_bytes: 37728
N=int(input())
dp=[float('inf') for i in range(N+1)]
dp[0]=0

for i in range(1,N+1):
    power=1
    while(power<=i):
        dp[i]=min(dp[i],dp[i-power]+1)
        power*=6
    
    power=1
    while(power<=i):
        dp[i]=min(dp[i],dp[i-power]+1)
        power*=9
print(dp[N])


Measured memory_bytes: 6296
///* BISMILLAH *///
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,f;
cin>>a;b=a%10;c=a%100/10;d=a%1000/100;e=a/1000;
if(e+d+c+b==7){
cout<<e<<"+"<<d<<"+"<<c<<"+"<<b<<"=7";}
else if(e-d+c+b==7)
{cout<<e<<"-"<<d<<"+"<<c<<"+"<<b<<"=7";}
else if(e+d-c+b==7)
{ cout<<e<<"+"<<d<<"-"<<c<<"+"<<b<<"=7";}
else if(e+d+c-b==7)
{ cout<<e<<"+"<<d<<"+"<<c<<"-"<<b<<"=7";}
else if(e+d-c-b==7)
{ cout<<e<<"+"<<d<<"-"<<c<<"-"<<b<<"=7";}
else if(e-d+c-b==7)
{ cout<<e<<"-"<<d<<"+"<<c<<"-"<<b<<"=7";}
else if(e-d-c-b==7)
{ cout<<e<<"-"<<d<<"-"<<c<<"-"<<b<<"=7";}
else if(e-d-c+b==7)
{ cout<<e<<"-"<<d<<"-"<<c<<"+"<<b<<"=7";}
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  int N = readln.chomp.to!int;
  int[] A = new int[N];
  foreach(ref a; A) {
    a = readln.chomp.to!int;
  }

  int[] pal = new int[0];
  foreach(a; A) {
    auto lb = assumeSorted!"a>b"(pal).upperBound(a);
    if(lb.empty) {
      pal ~= a;
    } else {
      lb.front = a;
    }
  }
  pal.length.writeln;
}


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

using namespace std;

int n, W, w[100];
long long v[100], dp[100][100001];

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> W;
	for (int i=0; i<n; ++i)
		cin >> w[i] >> v[i];
	for (int i=0; i<n; ++i)
		dp[i][0] = 0;
	for (int i=0; i<=W; ++i) {
		if (i < w[0])
			dp[0][i] = 0;
		else
			dp[0][i] = v[0];
	}
	for (int i=1; i<n; ++i) {
		for (int j=1; j<=W; ++j) {
			dp[i][j] = dp[i-1][j];
			if (j >= w[i])	
				dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
		}
	}
	cout << dp[n-1][W] << endl;
	return 0;
}


Measured memory_bytes: 78336
#include<stdio.h>

int rail[10], a, b, i, sum, s;

int main(){
  while(1){
    sum = 0;
    for(i = 0;i < 10;i++){
      scanf("%d,", rail + i);
      sum += rail[i];
    }
    if(scanf("%d,%d", &a, &b) == EOF)return 0;
    s = 0;
    for(i = 0;i < 10;i++){
      s += rail[i];
      if(s * b >= (sum - s) * a){
	printf("%d\n", i + 1);
	break;
      }
    }
  }
}

Measured memory_bytes: 596
k = int(input())

if k%2==0:
    print('-1')
    exit()

if k%7==0:
    k//=7

mod = 1
i=1
mod2 =1
while mod%k!=0 and i<=100000000:
    mod1 = mod2*10%k
    mod+=mod1
    mod%=k
    mod2=mod1
    i+=1
if i>=100000000:
    i=-1
print(i)


Measured memory_bytes: 63416
N = int(input())
A = [int(input()) for _ in range(N)]
AL = [A[0]]*N
AR = [A[-1]]*N
for i in range(1,N):
    AL[i] = max(AL[i-1], A[i])
    AR[N-i-1] = max(A[N-i-1], AR[N-i])
INF = float("inf")
AL = [-INF]+AL+[-INF]
AR = [-INF]+AR+[-INF]
for i in range(N):
    print(max(AL[i],AR[i+2]))

Measured memory_bytes: 17304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,k;
    cin>>n>>k;
    vector<vector<ll>>next(60,vector<ll>(n));
    rep(0,i,n){
        cin>>next[0][i];
        --next[0][i];
    }
    rep(0,d,60-1){
        rep(0,i,n){
            next[d+1][i]=next[d][next[d][i]];
        }
    }
    ll v=0;
    rep(0,d,60){
        if(k&(1LL<<d))v=next[d][v];
    }
    cout<<v+1<<endl;
}

Measured memory_bytes: 98548
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
vector<int> g[10005];
int deg[10005], c[10005], res[10005];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n-1;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }   
    for(int i=1;i<=n;i++) scanf("%d", &c[i]);
    sort(c+1, c+1+n);
    set<pii> cur;
    set<pii>::iterator its;
    for(int i=1;i<=n;i++) cur.insert(pii(deg[i], i));

    LL ans = 0;
    for(int i=1;i<=n;i++){
        its = cur.begin();
        int d = its->first, u = its->second;
        ans += d*1ll*c[i];
        cur.erase(its);

        res[u] = c[i];

        for(int i=0;i<g[u].size();i++){
            int v = g[u][i];
            if(cur.find(pii(deg[v], v)) != cur.end()){
                cur.erase(cur.find(pii(deg[v], v)));
                deg[v]--;
                cur.insert(pii(deg[v], v));
            }
        }
    }
    printf("%lld\n", ans);
    for(int i=1;i<=n;i++) printf("%d ", res[i]);
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, s;
vector<int> x;

int gcd(int a, int b);

int main(){
  ios_base::sync_with_stdio(false);

  int ans = 2147483647;

  cin >> n >> s;
  for(int i=0;i<n;i++){
    int in;
    cin >> in;
    x.push_back(in);
  }
  x.push_back(s);
  
  sort(x.begin(), x.end());  
  
  for(int i=x.size()-1;0<i;i--){
    x[i] -= x[i-1];
  }
  x[0] = 0;
  
  for(int i=1;i<x.size()-1;i++){
    ans = min(ans, gcd(x[i], x[i+1]));
  }  

  if(x.size() == 2)ans = x[1];

  cout << ans << endl;

  return 0;
}

int gcd(int a, int b){

  if(a < b)swap(a, b);
 
  int c = a % b;
  
  while(c){
    a = b;
    b = c;
    c = a % b;
  } 

  return b;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int length = Integer.parseInt(sc.next());
    String word = sc.next();

    if(word.length() % 2 == 0){

      if(word.substring(0,word.length()/2).equals(word.substring(word.length()/2, word.length())))
        System.out.println("Yes");
      else
        System.out.println("No");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21584
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a < c) 
		a = c;
	if (b > d) 
		b = d;
	if (b - a < 0)
		cout << "0" << endl;
	else
		cout << b - a << endl;
}

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

using namespace std;

int main(){

  int a , b , c;


  cin  >> a >> b >> c;

  if(a>b) swap(a,b);

  if(b>c) swap(b,c);

  if(a>b) swap(a,b);
 
  cout << a << " " << b << " " <<  c  << endl;

  return 0;

}

Measured memory_bytes: 1164
n, m = map(int, input().split())
mod = pow(10, 9)+7
ans = 0
a = 1
b = 1
c = 1
for i in range(m-n+1, m+1):
  b *= i
  b %= mod
for i in range(n+1):
  k = -1 if i%2 else 1
  ans += k*a*b**2*c
  ans %= mod
  a *= m-i
  a %= mod
  b *= pow(m-i, mod-2, mod)
  b %= mod
  c *= n-i
  c *= pow(i+1, mod-2, mod)
  c %= mod
print(ans)

Measured memory_bytes: 68556
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    crap;
    int N;
    cin >> N;
    vector<int> sub(N+1,0);
    forin(i, 2, N+1) {
        int a;
        cin >> a;
        sub[a]++;
    }
    forin(i, 1, N+1) {
        cout << sub[i] << endl;
    }
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register ll i=(a);i<(b);i++)
typedef long long ll;
inline ll read(){ll sign=1; ll x=0; char ch; while(!isdigit(ch=getchar())) if(ch=='-') sign=-1; while(isdigit(ch)) x=x*10+ch-'0',ch=getchar(); return x*sign;}
inline void write(ll k){ if(k<0) putchar('-'),k*=-1; char ch[20]; int num=0; while(k)ch[++num]=k%10,k/=10; if(num==0) ch[++num]=0; while(num)putchar(ch[num--]+'0');}
const ll INF=1ll<<62;
const ll MOD=1000000007;
ll n,x,a[2010],b[2010][2010],c[2010],ans;
int main() {
	n=read(); x=read();
	rep(i,0,n) a[i]=read(), b[i][0]=a[i], c[0]+=b[i][0];
	rep(i,0,n) rep(j,1,n) b[i][j]=min(b[i][j-1],a[(i-j+n)%n]), c[j]+=b[i][j];
	ans=c[0];
	rep(j,1,n) ans=min(ans,c[j]+x*j);
	write(ans);
    return 0;
}

Measured memory_bytes: 31744
using System;
using System.Collections.Generic;
using System.Linq;
 
 
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
{
Console.WriteLine(
Console.ReadLine()
.ToCharArray()
.Select((chars,index)=>new{chars,index})
.Where(v=>v.chars=='W')
.Select((v,toPos)=>new{v.index,toPos})
.Sum(v=>(long)(v.index-v.toPos))
);
}
}
}

Measured memory_bytes: 18528
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
using namespace std; 


int main()
{

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int m=max(x, y);
	vector<int> an(x+y);
	for (int i = 0; i <x+y; i++)
	{
		int xx = x - i;
		if (xx < 0)
		{
			xx = 0;
		}
		int yy = y - i;
		if (yy < 0)
		{
			yy = 0;
		}
		int n = 0;
		
		n = a * xx + b * yy + c * i * 2;
		an.at(i) = n;
	}
	sort(an.begin(), an.end());
	cout << an.at(0) << endl;

}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int[] size;
	public void run(){
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			calc(n);
		}
	}
	public void calc(int n){
		size = new int[n];
		for(int i = 0; i < n; i++){
			String s = sc.next();
			size[i] = s.length();
		}
		int ans = 0;
		while(true){
			int i = ans;
			i = check(i, n, 5);
			if(i != -1) {
				i = check(i, n, 7);
				if(i != -1){
					i = check(i, n, 5);
					if(i != -1){
						i = check(i, n, 7);
						if(i != -1){
							i = check(i, n, 7);
							if(i != -1) break;
						}
					}
				}
			}
			ans+=1;	
		}
		System.out.println(ans+1);
	}
	
	public int check(int start, int n, int s){
		int sum = 0;
		for(int i = start; i < n; i++){
			sum += size[i];
			if(sum == s) return i+1;
			else if(sum > s) return -1;
		}
		return -1;
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

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

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

    long long a[n];
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a, a + n);
    if (a[0] == 0) {
        cout << "0";
        return 0;
    }

    long long product = 1;
    for (auto elem: a) {
        if (elem > 1000000000000000000ULL / product) {
            cout << "-1";
            return 0;
        }
        product *= elem;
    }

    cout << product;
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;
int64 ans[N];
int add[N];
vector<int> g[N];

void dfs(int v, int p, int64 val)
{
  val += add[v];
  ans[v] = val;
  for (auto u : g[v]) {
    if (u != p) {
      dfs(u, v, val);
    }
  }
}

void solve(int test)
{
  int q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    add[x] += y;
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 28288
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  char a,b,c;
  cin>>a>>b>>c;
  int ans = 0;
  char r = 'R';
  if(a==r&&b==r&&c==r)ans=3;
  else if(a==r&&b==r)ans=2;
  else if(b==r&&c==r)ans=2;
  else if(a==r||b==r||c==r)ans=1;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3628
N = int(input())                       
A = []                                 
B = []                                 
for _ in range(N):                     
    a, b = map(int, input().split())   
    A.append(a)                        
    B.append(b)                        
                                       
cnt = 0                                
A = A[::-1]                            
B = B[::-1]                            
for a, b in zip(A, B):                 
    if (a + cnt) % b == 0:             
        continue                       
    cnt += b - ((a + cnt) % b)         
print(cnt)                             
                                       

Measured memory_bytes: 17684
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	vi a(n);
	vi dp(n,0);
	rep(i,0,n) cin>>a[i];

	rep(i,1,n) dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]) , (i-2>=0?dp[i-2]+abs(a[i]-a[i-2]):inf));
	cout<<dp[n-1]<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1792
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    a,b = input().split()
    s = input()
    if s.count("-") == 1:
        c,d = s.split("-")
        if a == str(len(c)) and b == str(len(d)):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char field[51][51];
int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0},ans=0;
int h,w,num=0;
/* 
void dfs(int x,int y){
    int n=0;
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<h&&0<=ny&&ny<w&&field[nx][ny]=='#')n++;
    }
    if(n>0){ans++;cout<<x<<" "<<y<<endl;}
    return;
}
 */
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>field[i][j];
            if(field[i][j]=='#')num++;
        }
    }
    for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j]=='#'){
                    int n=0;
                    for(int k=0;k<4;k++){
                        int nx=i+dx[k],ny=j+dy[k];
                        if(0<=nx&&nx<h&&0<=ny&&ny<w&&field[nx][ny]=='#')n++;
                    }
                    if(n>0)ans++;
                }
            }
        }
    //cout<<num<<" "<<ans<<endl;
    if(ans==num)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll =long long;
#define rep(i,n) ;for( int i =0; i < n ; i ++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> a(n);
  vector<ll> d(n);
  rep(i,n){
    cin>> a[i];
    d[i] =abs(a[i],x);
  }
  int ans=d[0];
  rep(i,n){
    ans = gcd11(ans,d[i]);
  }
  cout <<ans<<endl;
 
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

vector<lli> vis;
vector<vector<lli>> adj;

void dfs(lli a) {
    for (auto val : adj[a]) {
        if (vis[val] == 0) {
            vis[val] = 1;
            dfs(val);
        }
    }
}

void solve() {
    lli n, a, m, b;
    cin >> n >> m;

    adj.resize(n + 2);
    for (lli i = 0; i < m; i++) {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    vis.resize(n + 2, 0);

    lli ans = 0;

    for (lli i = 1; i <= n; i++) {
        if (vis[i] == 0) {
            vis[i] = 1;
            dfs(i);
            ans++;
        }
    }

    cout << ans - 1 << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 10588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#include<numeric>
using namespace std;
int main() {
	int n;
	cin >> n;
	cout << n << ":";
	int i = 2;
	int k = n;
	while (n != 1) {
		if (i > sqrt(k)) {
			cout << " " << n << endl;
			break;
		}
		if (n % i == 0) {
			cout << " " << i;
			n = n / i;
			if(n==1)cout << endl;
			i--;
		}
		i++;
	}
}


Measured memory_bytes: 3120
package main

import "fmt"

func main() {
	var day string
	fmt.Scan(&day)
	if day == "SAT" {
		fmt.Println(1)
	} else if day == "FRI" {
		fmt.Println(2)
	} else if day == "THU" {
		fmt.Println(3)
	} else if day == "WED" {
		fmt.Println(4)
	} else if day == "TUE" {
		fmt.Println(5)
	} else if day == "MON" {
		fmt.Println(6)
	} else {
		fmt.Println(7)
	}
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,x=map(int,input().split())
    A=list(map(lambda y:int(y)-x,input().split()))
    if n==1:
        print(abs(A[0]))
        return
    from fractions import gcd
    from functools import reduce
    print(abs(reduce(gcd,A)))
resolve()

Measured memory_bytes: 75284
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#define M 1010
#define N 1000000
#define D double
#define LL long long
#pragma GCC optimize(2)
using namespace std;
LL n,sum,k=1e9+7;
LL powr(LL x,LL y)
{
	if(y==0) return 1;
    if(y==1) return x%k;
    LL res=powr(x,y>>1);
    res=res*res%k;
    if(y%2==1) res=res*x%k; 
    return res%k;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	sum=(powr(10,n)-2*powr(9,n)%k+powr(8,n)+k)%k;
	cout<<sum;
	return 0;
}
/*
*/


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 300010

vector<int> g[maxn];
int first[maxn], second[maxn], bit[maxn];
vector<int> euler;

void update(int idx, int val) {
    while (idx <= euler.size()) {
        bit[idx] += val;
        idx += idx & -idx;
    }
}

int pref(int idx) {
    int ans = 0;
    while (idx > 0) {
        ans += bit[idx];
        idx -= idx & -idx;
    }
    return ans;
}

void dfs(int u, int p = -1) {
    first[u] = euler.size() + 1;
    euler.push_back(u);
    for (auto x : g[u]) {
        if (x != p) {
            dfs(x, u);
        }
    }
    second[u] = euler.size() + 1;
    euler.push_back(u);
}

void solve() {
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;

        for (int j = 0; j < k; j++) {
            int tp;
            cin >> tp;

            g[i].push_back(tp);
            g[tp].push_back(i);
        }
    }

    dfs(0, 0);
    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;

        if (!type) {
            int v, w;
            cin >> v >> w;

            update(first[v], w);
            update(second[v], -w);
        } else {
            int u;
            cin >> u;

            cout << pref(first[u]) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 22664
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n;
	cin>>n;
	cout<<n/500*1000+n%500/5*5<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n, m, dist[N], vis[N];
vector < pl > g[N];
void dijkstra(ll s)
{
    f(i, n + 1) vis[i] = 0, dist[i] = inf;
    dist[s] = 0;
    priority_queue < pl > q;
    q.push({0, s});
    while(!q.empty())
    {
        ll u = q.top().S;
        q.pop();
        if(vis[u]) continue;
        vis[u] = 1;
        for(pl x : g[u])
        {
            ll v = x.F;
            ll w = x.S;
            if(dist[v] > dist[u] + w)
            {
                dist[v] = dist[u] + w;
                q.push({-dist[v], v});
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    f(i, m)
    {
        ll a, b;
        cin >> a >> b;
        g[a].pb({b, 1});
        g[b].pb({a, 1});
    }
    dijkstra(1);
    if(dist[n] == 2)
    {
        cout << "POSSIBLE\n";
    }
    else
    {
        cout << "IMPOSSIBLE\n";
    }
    return 0;
}


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

int main(){

    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<(a[0]==5&&a[1]==5&&a[2]==7?"YES":"NO")<<endl;








    return 0;
}

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

int main(void){
  int a,b;
  cin >> a >> b;

  if (a == b) cout << "a == b" <<"\n";
  else if (a > b) cout << "a > b" << "\n";
  else if (a < b) cout << "a < b" << "\n";

  return 0;
}

Measured memory_bytes: 1124