akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int main() {
	VI v;
	VI _v;
	for (int i = 0; i < 5; i++) {
		int x; cin >> x; v.push_back(x);
		_v.push_back(x % 10);
	}
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		ans += (v[i] % 10 ? ((v[i] / 10) + 1) * 10 : v[i]);
	}
	sort(_v.begin(), _v.end());
	for (int i = 0; i < 5; i++) {
		if (_v[i]) {
			ans -= (10 - _v[i]);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

kuku=range(1,10)
n=int(input())
d=False
for i in kuku:
  if n%i==0 and n//i<10:
    d=True
if d:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll h, n, sum = 0;
  cin >> h >> n;
  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    sum += tmp;
  }
  if (sum >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

long long v[3100][3100], dp[3100][3100][5];
int main() {
    int R, C, K;
    cin >> R >> C >> K;
    memset(v, 0, sizeof(v));
    for (int i = 0; i < K; ++i) {
        long long r, c, t;
        cin >> r >> c >> t;
        v[r][c] = t;
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i <= R; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = 0; k <= 3; ++k) {
                // 上へ行く
                if (i-1 >= 0) {
                    chmax(dp[i][j][0], dp[i-1][j][k]);
                    chmax(dp[i][j][1], dp[i-1][j][k] + v[i][j]);
                }
 
                // 右へ行く
                if (j-1 >= 0) {
                    chmax(dp[i][j][k], dp[i][j-1][k]);
                    if (k-1 >= 0)
                        chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
                }
            }
        }
    }
    long long res = 0;
    for (int k = 0; k <= 3; ++k) chmax(res, dp[R][C][k]);
    cout << res << endl;
}

Measured memory_bytes: 453980
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)
		ans+=ans<k?ans:k;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime[10000001];
int main() {
    for(long long int i=3;i<3162;i++)if(!prime[i])for(long long int j=i*2;j<10000001;j+=i)prime[j]=1;
    int n;
    while(cin>>n,n){
        if(!(n%2))n--;
        for(;;n-=2){
            if(!prime[n]&&!prime[n-2]&&!prime[n-6]&&!prime[n-8]){
                cout<<n<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 10928
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n,k;
vector<pair<ll,ll>> v;
stack<pair<ll,ll>> stk;
ll ty[100001]={0};//種類を管理.(boolじゃないのは要素数も管理するため)

int main(){
	cinit();
	cin>>n>>k;
	memset(ty,0,sizeof(ty));
	ll tt,dd;
	rep(i,n){
		cin>>tt>>dd;
		v.pb(mp(tt,dd));
	}
	sort(v.begin(),v.end(),[](pair<ll,ll> s,pair<ll,ll> t){return s.second>t.second;});
	ll tmp = 0;ll vary=0;
	rep(i,k){
		tmp += v[i].second;
		if(ty[v[i].first]!=0)stk.push(v[i]);
		else vary++;
		ty[v[i].first]++;
	}
	tmp += vary*vary;//仮の最大値の算出
	ll tmp2=tmp;//ここからは逐次当たる
	rep(i,n-k){
		if(ty[v[i+k].first]==0){
			if(stk.size()==0)break;
			tmp2 -= stk.top().second-v[i+k].second;
			tmp2 += 2*vary+1;
			vary++;
			ty[v[i+k].first]=1; 
			stk.pop();
			chmax(tmp,tmp2);
		}
	}
	cout<<tmp<<endl;
	return 0;
}


Measured memory_bytes: 3440
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int max,min;
    max=*max_element(a.begin(),a.end());
    min=*min_element(a.begin(),a.end());
    
    cout << max-min << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
long ans=0;
//入力
String s = sc.next();
//String Builderを用意
StringBuilder sb = new StringBuilder();
//n=文字列長
int n=s.length();
//文字間と末尾に+を挿入→後で消していき計算式として処理
String t="";
for (int i = 0; i < n; i++) {
    t+=Character.toString(s.charAt(i))+"+";
}

for (int i = 0; i < 1<<(n-1); i++) {
sb.append(t);
for (int j = 0; j < n-1; j++) {
    if((1 & i>>j)==1){
        sb.setCharAt(2*j+1, '-');
    }
}

String q=sb.toString();
q=q.replaceAll("-", "");

String temp="";
for (int j = 0; j < q.length(); j++) {
    if(q.charAt(j)=='+'){
        ans+=Long.parseLong(temp);
        temp="";
    }else{
        temp+=Character.toString(q.charAt(j));
    }
}
sb.delete(0, sb.length());
}
out.println(ans);
/*
//階乗
static long fact(long a){
    long b=1;
    for (long i = 1; i <= a; i++) {
        b*=i;
    }
    return b;
}
//最大公約数
static int gcd (int a, int b) {
    int temp;
    while((temp = a%b)!=0) {
        a = b;
        b = temp;
    }
    return b;
}
//※最小公倍数はa*b/gcd(a,b)である
//二項係数
static long combi (long a, long b) {
    return fact(a)/(fact(b)*fact(a-b));
}
*/
}
}

Measured memory_bytes: 27728
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<P> ba(n);
    rep(i, n) cin >> ba[i].second >> ba[i].first;
    sort(ba.begin(), ba.end());
    string ans = "Yes";
    ll sum = 0;
    rep(i, n) {
        sum += ba[i].second;
        if(sum > ba[i].first) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <set>

using namespace std;
int main()
{
   long long n, k ,h ,counter=0 ,sum=0;
   multiset<long long , greater<long long> >st;
   cin>>n>>k;
   for(int i=0 ;i<n ;i++)
   {
       cin>>h;
       sum+=h;
       st.insert(h);
   }
    multiset<long long , greater<long long> > ::iterator it;
     it=st.begin();

   while(it!=st.end())
   {
       if(k>0)
       {
           sum-=(*it);
           k--;
           it++;
       }
       else if(k==0)
       {
           break;
       }
   }
   cout<<sum;
 /*
   while(it!=st.end())
   {
       cout<<(*it)<<" " ;
       it++;
   }*/

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
 int K,S;
cin >> K >> S;

 int ans = 0;

 for(int x = 0; x <= K; ++x){
 for(int y = 0; y <= K; ++y){ int z = S - x - y;
 if(0 <= z and z <= K){
 ans = ans + 1;
 }
 }
 }

 cout << ans << endl;
return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>

#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
map<string, ll>a;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}
string num[10] = { "pon","pon","hon","bon","hon","hon","pon","hon","pon","hon" };

int main() {
	ll N;
	cin >> N;
		cout << num[N % 10];



}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    const int MAX_SIZE = 300000;
    int num[MAX_SIZE + 1] = {};
    num[1] = 1;
    for(int i = 2;i <= MAX_SIZE;i++){
        if(num[i])continue;
        if(i % 7 != 1 && i % 7 != 6){
            num[i] = 1;
            continue;
        }
        for(int j = i * 2;j <= MAX_SIZE;j += i){
            num[j] = 1;
        }
    }
    vector<int> prime;
    rep(i,2,MAX_SIZE){
        if(!num[i])prime.push_back(i);
    }
    //rep(i,0,15)cout << prime[i] << endl;

    int N;
    cin >> N;
    while(N != 1){
        cout << N << ":";
        for(auto i:prime){
            if(N % i == 0)cout << " " << i;
        }
        cout << endl;
        cin >> N;
    }
}


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

using namespace std;

#define INF 1e9

class Fraction{
public:;
  double numerator,denominator;
  double div();
};

double Fraction::div(){
  return numerator/denominator;
}

ostream &operator << (ostream &os,const Fraction &f){
  os << f.numerator << '/' << f.denominator;
  return os;
}

int main(){
  double p;
  int n;
  while(cin >> p >> n, p){
    p = sqrt(p);
    Fraction a = (Fraction){-1,1};
    Fraction b = (Fraction){INF,1};
    for(int den = 1 ; den <= n ; den++){
      int l = 0, r = n+1;
      for(int i = 0 ; i < 150 ; i++){
        double mid = (l + r) / 2;
        if(mid < p*den){
          if(mid/den > a.div()){
            a = (Fraction){mid,den};
          }
          l = mid;
        }else{
          r = mid;
        }
      }
      l = 0, r = n+1;
      for(int i = 0 ; i < 150 ; i++){
        double mid = (l + r) / 2;
        if(mid > p*den){
          if(mid/den < b.div()){
            b = (Fraction){mid,den};
          }
          r = mid;
        }else{
          l = mid;
        }
      }
    }
    cout << b << " " << a << endl;
  }
  return 0;
}

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

#define ll long long

int main() {
  int N;
  cin >> N;
  
  ll cost[N][N];
  
  ll ans = 0;
  
  for (int i = 0; i < N ;i++) {
    for (int j = 0; j < N; j++) {
      int x;
      cin >> x;
      ans += x;
      cost[i][j] = x;
    }
  }
  
  vector<vector<bool>> condflag(N, vector(N, true));
  
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (cost[i][j] > cost[i][k] + cost[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        
        if (cost[i][j] == cost[i][k] + cost[k][j] && (k != i) && (k != j) &&condflag[i][j]) {
          ans -= cost[i][j];
          condflag[i][j] = false;
        }
      } 
    }
  }
  
  cout << ans/ 2 << endl;
}

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

int main() {
    ll N; cin >> N;
    vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
    vector<ll> B(N); for (ll i = 0; i < N; i++) B[i] = A[i] - i;
    ll ans = 0;
    map<ll, ll> p;
    for (int i = 0; i < N; i++) {
        p[B[i]]++;
    }
    for (int i = 0; i < N; i++) {
        ans += p[-A[i]-i];
        p[B[i]]--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 29052
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

ll dp[212][212];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k;
  int n;
  ll MOD=1e9+7;
  cin>>n;
  vector<char> cs(n);
  rep(i,n)
    cin>>cs[i];
  dp[0][0]=1;
  rep(i,n){
    rep(j,n){
      if(cs[i]=='-'){
	dp[i+1][j]=dp[i][j];
      }else if(cs[i]=='U'){
	(dp[i+1][j]+=dp[i][j]*j%MOD)%=MOD;
	(dp[i+1][j+1]+=dp[i][j])%=MOD;
      }else{
	(dp[i+1][j]+=dp[i][j]*j%MOD)%=MOD;
	if(j)
	  (dp[i+1][j-1]+=dp[i][j]*j%MOD*j%MOD)%=MOD;
      }
    }
  }
  //  rep(i,n+1){rep(j,n+1)cout<<dp[i][j]<<",";cout<<endl;}
  cout<<dp[n][0]<<endl;
  return 0;
}

Measured memory_bytes: 1532
///////////////////////////////////////////////////////////
//どんな人生を選ぶかより、選んだ人生をどう生きるかが大切だ//
/////////////////////////////////////////////////////////
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int MAXN = 105;
int num[15]; bool flag;
void DFS(int index,int maxB, char maxC)
{
	if (index == 10)
	{
		flag = true;
		return;
	}
	if (flag)
	{
		return;
	}
	if (num[index] > maxB)
	{
		DFS(index + 1, num[index], maxC);
	}
	if (num[index] > maxC)
	{
		DFS(index + 1, maxB,num[index]);
	}
}
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		flag = false;
		for (int i = 0; i < 10; i++)
		{
			scanf("%d", &num[i]);
		}
		DFS(0, 0, 0);
		if (flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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

using namespace std;

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

const int N = 100010, mod = 1e9 + 7;

int tt = -1;
string s;
char stk[N];

int main()
{
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        if(tt == -1 || stk[tt] != s[i])
            stk[++tt] = s[i];

    cout << tt << endl;
    return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	map<int,long long> mp,mm;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]+i]++;
		mm[a[i]-i]++;
	}
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=mm[-i-a[i]];
	}

	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>

using namespace std;
using ll = long long;

int main(){
    int h,w;cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int tmp=0;
            if(s[i][j]=='#') continue;
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(i+k<0||i+k>=h) continue;
                    if(j+l<0||j+l>=w) continue;
                    if(s[i+k][j+l]=='#') tmp++;
                }
            }
            s[i][j] = tmp +'0';
        }
    }

    for(int i=0;i<h;i++){
        cout<<s[i]<<endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,x,da;

struct jgt
{
	int b;
	int e;
}a[1000005];

bool cmp(jgt a,jgt b)
{
	if (a.e!=b.e)
	{
		return a.e<b.e;
	}
	else
	{
		return a.b<b.b;
	}
}

int main()
{
	
	cin>>n>>m;
	for (i=1;i<=m;i++)
	{
		cin>>a[i].b>>a[i].e;
	}
	sort(a+1,a+1+m,cmp);
	for (i=1;i<=m;i++)
	{
		if (a[i].b>=x) 
		{
			x=a[i].e;
			da+=1;
		}
	} 
	cout<<da;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

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

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



















int main(){
    ll r, g, b;
    cin >> r >> g >> b;
    cout << (((r * 100 + g * 10 + b) % 4 == 0)? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
/*
** 线性搜索
*/

# include <cstdio>

static const int maxn = 10000 + 5;

int line_search(int s[], int n, int t) {
	for (int i = 0; i < n; i++)
		if (s[i] == t)
			return 1;
	return 0;
}

int main() {
	// freopen("infile", "r", stdin);
	// freopen("outfile", "w", stdout);
	int n, q, s[maxn], t;
	while (scanf("%d", &n) != EOF) {
		for (int i = 0; i < n; i++) scanf("%d", &s[i]);
		scanf("%d", &q);
		int ans = 0;
		for (int i = 0; i < q; i++) {
			scanf("%d", &t);
			ans += line_search(s, n, t);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2748
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
    }
    let middle = (a + b) / 2;
    let impossible = (a + b) % 2 != 0;
    if impossible {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", middle);
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            else:
                values[i][cp] = values[i - 1][cp]
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    item_list = [Item(v=int(v), w=int(w)) for v, w in items]

    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

Measured memory_bytes: 27952
#include <iostream>
int main(void) {
    int N, K;
    std::cin >> N >> K;

    int ans = 0;
    for (long k = K; N / k > 0 || N % k > 0; ++ans) {
        N /= k;
    }

    std::cout << ans << '\n';
    return 0;
}


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

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

using namespace std;

int n, k;
string s;
vector<int> order;
vector<int> tmp;
vector<int> sa;

bool compare_sa(const int &i, const int &j)
{
  if(order[i] != order[j]) return order[i] < order[j];
  else
  {
    int ri = i + k <= n ? order[i+k] : -1;
    int rj = j + k <= n ? order[j+k] : -1;
    return ri < rj;
  }
}

void construct_sa()
{
  for(int i = 0; i <= n; i++)
  {
    sa[i] = i;
    order[i] = i < n ? s[i] : -1;
  }
  for(k = 1; k <= n; k*=2)
  {
    sort(sa.begin(),sa.end(),compare_sa);
    tmp[sa[0]] = 0;
    for(int i = 1; i <= n; i++)
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1],sa[i])?1:0);
    for(int i = 0; i <= n; i++)
      order[i] = tmp[i];
  }
}

void init()
{
  n = s.size();
  order.resize(n+1);
  tmp.resize(n+1);
  sa.resize(n+1);
  construct_sa();
}

bool contain(string t)
{
  int l=0, r=n;
  while(r-l>1)
  {
    int m = (l+r)/2;
    if(s.compare(sa[m],t.size(),t)<0) l = m;
    else r = m;
  }
  return s.compare(sa[r],t.size(),t) == 0;
}

int main()
{
  cin >> s;
  string t;
  int q; cin >> q;
  init();
  construct_sa();
  REP(i,q)
  {
     cin >> t;
     cout << contain(t) << endl;
  }
  return 0;
}

Measured memory_bytes: 15852
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, rd[N], ip, dfn[N], cnt, dclk;
int tot, fi[N], a[N << 1], ne[N << 1];
inline void Add(int x, int y) {
    a[++tot] = y; ne[tot] = fi[x]; fi[x] = tot;
}
inline void Dfs(int x) {
    dfn[x] = ++dclk;
    for (int i = fi[x]; i; i = ne[i]) if (!dfn[a[i]]) {
        if (x == ip) ++cnt;
        Dfs(a[i]);
    }
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1, x, y; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        ++rd[x]; ++rd[y];
        Add(x, y); Add(y, x);
    }
    for (int i = 1; i <= n; ++i) if (rd[i] & 1) return puts("No"), 0;
    for (int i = 1; i <= n; ++i) if (rd[i] >= 6) return puts("Yes"), 0;
    int ans = 0;
    for (int i = 1; i <= n; ++i) if (rd[i] == 4) ++ans;
    if (ans >= 3) puts("Yes");
    else if (ans == 2) {
        for (int x = 1; x <= n; ++x) if (rd[x] == 4) ip = x;
        Dfs(ip);
        puts(cnt == 2 ? "Yes" : "No");
    } else puts("No");
    return 0;
}

Measured memory_bytes: 3712
from collections import deque

s = input()
q = int(input())
d = deque(s)
reverseFlag = False


def getQuery():
    yield input().split()


for _ in range(q):
    for query in getQuery():
        if query[0] == "1":
            reverseFlag = not reverseFlag
        else:
            if query[1] == "1":
                if reverseFlag:
                    d.append(query[2])
                else:
                    d.appendleft(query[2])
            else:
                if reverseFlag:
                    d.appendleft(query[2])
                else:
                    d.append(query[2])

ans = "".join(d)
if reverseFlag:
    ans = ans[::-1]

print(ans)


Measured memory_bytes: 8564
local n, m = io.read("*n", "*n")
local a = {}
a[0] = 1
local tot = 0
for i = 1, n do
  tot = (tot + io.read("*n")) % m
  if(a[tot] == nil) then a[tot] = 1 else a[tot] = a[tot] + 1 end
end
local sum = 0
for k, v in pairs(a) do
  if(2 <= v) then
    sum = sum + v * (v - 1) // 2
  end
end
print(sum)


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s[7]={"sat","sun","mon","tue","wed","thu","fri"};
int x;

int main(){
	cin>>x;
	x=(x+5)%7;
	cout<<s[x]<<endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      puts("Bad");
      return 0;
    }
  }
  puts("Good");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = (int)1e5 * 2 + 100;
int a[maxn], b[maxn], sz;

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    if(x == 1 || x == 2 * n - 1){
        puts("No");
        return 0;
    }
    puts("Yes");
    int l = x - 1, r = x + 1;
    a[n] = x;
    if(x < n){
        int flag = 1;
        for(int i = n - 1; i >= 1; i--){
            if(l == 0){
                a[i] = r++;
                continue;
            }else if(r == 2 * n){
                a[i] = l--;
                continue;
            }
            if(flag) a[i] = l--;
            else a[i] = r++;
            flag ^= 1;
        }
        flag = 1;
        for(int i = n + 1; i < 2 * n; i++){
            if(l == 0){
                a[i] = r++;
                continue;
            }else if(r == 2 * n){
                a[i] = l--;
                continue;
            }
            if(flag) a[i] = r++;
            else a[i] = l--;
            flag ^= 1;
        }
    }else{
        int flag = 1;
        for(int i = n + 1; i < 2 * n; i++){
            if(l == 0){
                a[i] = r++;
                continue;
            }else if(r == 2 * n){
                a[i] = l--;
                continue;
            }
            if(flag) a[i] = r++;
            else a[i] = l--;
            flag ^= 1;
        }
        flag = 1;
        for(int i = n - 1; i >= 1; i--){
            if(l == 0){
                a[i] = r++;
                continue;
            }else if(r == 2 * n){
                a[i] = l--;
                continue;
            }
            if(flag) a[i] = l--;
            else a[i] = r++;
            flag ^= 1;
        }
    }
    for(int i = 1; i < 2 * n; i++){
        printf("%d\n", a[i]);
    }
    return 0;
}


Measured memory_bytes: 2304
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans=0;
		int sum=1;
		while(sum<B){
			ans=ans+1;
			sum=sum-1+A;
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 998244353;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll qsm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
ll n,m,k;
int jud[]={0,0,1,2,3,3,3,4,3,5,4,4,4,6,3,4,6,5,3,6,4,7,5,4,3,9,4,5,5,6,5,8,3,6,5,4,8,9,3,5,5,8,4,8,3,6,7,4,4,11,4};
int ok(ll x,ll k){
    m=x;
    while(m>=k){
        if(m%k==0) m/=k;
        else break;
    }
    if(m==1) return 1;
    if(m<k) return 0;
    return (m-1)%k==0;
}

int main(){
    cin>>n;
    if(n==2) return puts("1"),0;
    m=n-1;
    int ans=1, sz=sqrt(m+eps);
    rep(i,2,sz){
        if(m%i==0){
            ++ans;
            if(1ll*i*i!=m) ++ans;
        }
    }
    ++ans;
    sz=sqrt(n+eps);
    rep(i,2,sz){
        if(n%i==0&&ok(n,i)) ++ans;//,cout<<"i="<<i<<endl;
    }
    cout<< ans<<endl;
    return 0;
}
/*

*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, T, a[100010], dp[100010];
int main() {
	scanf("%d%d", &n, &T);
	int mn = 0x3f3f3f3f, ans = 0;
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		dp[i] = max(0, a[i] - mn);
		ans = max(ans, dp[i]);
		mn = min(mn, a[i]);
	}
	mn = 0x3f3f3f3f; int tot = 0;
	for (int i = 1; i <= n; ++ i) {if (a[i] - mn == ans) ++ tot; mn = min(mn, a[i]);}
	printf("%d\n", tot);
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    A = LI()

    x = Counter(A)

    for i in range(1,N+1):
        print(x[i])



if __name__ == "__main__":
	main()

Measured memory_bytes: 114392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int n,x[5]={195,189,165,135,105};
    cin>>n;
    
    rep(i,5)if(x[i]<=n)cout<<5-i<<endl,exit(0);
    cout<<"0\n";

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

int n,ans; 
string s,t; 
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	/*
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
	*/
#endif
	cin>>n>>s>>t; 
	rep(i,1,n){
		if(s.substr(n-i,i)==t.substr(0,i))ans=i;
	}
	printf("%d\n",n+n-ans);
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
oks = [1] * (N+1)
for i in range(M):
    a.append(int(input()))
    oks[a[i]] = 0

dp = [0] * (N+1)
dp[0] = 1

for now in range(N):
    for nex in range(now+1, min(N, now+2) + 1):
        if oks[nex] == 1:
            dp[nex] += dp[now]
            dp[nex] %= 10 ** 9 + 7

print(dp[N])

Measured memory_bytes: 14492
#include <iostream>

using namespace std;

static const int MAX = 100;

struct Card { char suit, value; };

void bubbleSort(struct Card A[], int N){
    bool flag = true;
    for (int i = 0; flag; i++){
        flag = false;
        for (int j = N - 1; j >= i + 1; j--){
            if (A[j].value < A[j - 1].value){
                Card tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = true;
            }
        }
    }
}

void selectionSort(struct Card A[], int N){
    for (int i = 0; i < N - 1; i++){
        int minj = i;
        for (int j = i + 1; j < N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        if (minj != i){
            Card tmp = A[minj];
            A[minj] = A[i];
            A[i] = tmp;
        }
    }
}

void trace(struct Card A[], int N){
    for (int i = 0; i < N; i++){
        if (i) cout << ' ';
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i = 0; i < N; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    int num;
    Card C1[MAX], C2[MAX];

    cin >> num;
    for (int i = 0; i < num; i++) cin >> C1[i].suit >> C1[i].value;
    for (int i = 0; i < num; i++) C2[i] = C1[i];

    bubbleSort(C1, num);
    selectionSort(C2, num);

    trace(C1, num);
    cout << "Stable" << endl;

    trace(C2, num);
    if (isStable(C1, C2, num)){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}

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

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  int passed = 0;
  int passedb = 0;
  for (int i = 0; i < n; i++) {
    int c = getchar();
    while (c <= 32) c = getchar();
    if (c == 'c') {
      puts("No");
      continue;
    }
    if ((c == 'a' && passed < a + b) || (c == 'b' && passed < a + b && passedb < b)) {
      ++passed;
      if (c == 'b') {
        ++passedb;
      }
      puts("Yes");
    } else {
      puts("No");
    }
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define MAX 17
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int bin[MAX],jc[1<<MAX],inv[1<<MAX],jv[1<<MAX];
int C(int n,int m){if(n<m)return 0;return 1ll*jc[n]*jv[m]%MOD*jv[n-m]%MOD;}
int a[MAX],n,m,ans,f[MAX+1][1<<MAX],cnt[1<<MAX];
int main()
{
    n=read();m=read();cnt[0]=jc[0]=bin[0]=jv[0]=inv[0]=inv[1]=1;
    for(int i=1;i<=n;++i)bin[i]=bin[i-1]<<1;
    for(int i=1;i<=bin[n];++i)jc[i]=1ll*jc[i-1]*i%MOD;
    for(int i=2;i<=bin[n];++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
    for(int i=1;i<=bin[n];++i)jv[i]=1ll*jv[i-1]*inv[i]%MOD;
    for(int i=1;i<=bin[n];++i)cnt[i]=(i&1)?MOD-cnt[i>>1]:cnt[i>>1];
    for(int i=1;i<=m;++i)a[i]=read();sort(&a[1],&a[m+1]);
    f[m+1][0]=1;
    for(int i=m;i;--i)
        for(int t=0;t<bin[n];++t)
            if(f[i+1][t])
            {
                add(f[i][t],f[i+1][t]);
                int p=bin[n]-1-t;
                for(int j=0;j<n;++j)
                    if(!(t&(1<<j)))
                        add(f[i][t|(1<<j)],1ll*C(p-a[i]+1,(1<<j)-1)*f[i+1][t]%MOD*jc[1<<j]%MOD);
            }
    for(int i=0;i<bin[n];++i)
        add(ans,1ll*f[1][i]*jc[bin[n]-1-i]%MOD*cnt[i]%MOD);
    ans=1ll*ans*bin[n]%MOD;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 9728
N, K = map(int, input().split())
S = input()

a = [0]
if S[0] == '0':
    a.append(0)
for i in range(N-1):
    if S[i] != S[i+1]:
        a.append(i+1)
a.append(N)
if S[N-1] == '0':
    a.append(N)
r = len(a) // 2 - 1
if K >= r:
    print(N)
else:
    print(max(a[2*(i+K)+1]-a[2*i] for i in range(r-K+1)))

Measured memory_bytes: 7156
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

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

  ll n, x;
  cin >> n >> x;
  ll ans = 0;
  rep(i, n)
  {
    ll a;
    cin >> a;
    ans = __gcd(ans, abs(x - a));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())
a = [[0] for i in range(n)]
b = [[0] for i in range(m)]
c = [[[0] for i in range(l)] for j in range(n)]
for i in range(n):
  a[i] = list(map(int,input().split()))  
for i in range(m):
  b[i] = list(map(int,input().split())) 
  
for i in range(n):
  for j in range(l):
    traial = 0
    for k in range(m):
      traial += a[i][k] * b[k][j]
    c[i][j] = traial
  c[i] = ' '.join(map(str,c[i]))
[print(i) for i in c]


Measured memory_bytes: 7088
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e15;
const ll MAXN=5200;
ll i,j,sizes=0;
vector<ll> v[MAXN],vis(MAXN),p(MAXN),c(MAXN);
void dfs(ll k)
{
    vis[k]=1;
    v[sizes].push_back(c[k]);
    if(vis[p[k]]==0)
    {
        dfs(p[k]);
    }
}
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n,k;
cin>>n>>k;
F(i,0,n)
{
    cin>>p[i];
    p[i]--;
}
F(i,0,n)
{
    cin>>c[i];
}
F(i,0,n)
{
    if(vis[i]==0)
    {
        dfs(i);
        sizes++;
    }
}
ll a[sizes+2][n+2];
ll ans=-mod;
F(i,0,sizes)
{
    ll sum=0,g=v[i].size();
    F(j,0,v[i].size())
    {
       sum+=v[i][j];
       a[i][j+1]=-mod;
    }
    F(j,0,v[i].size())
    {
        ll s=0;
       for(ll t=j;t<j+g;t++)
       {
           //cout<<v[i][t%g]<<" ";
           s+=v[i][t%g];
           a[i][t-j+1]=max(a[i][t-j+1],s);
       }

    }
    ll s=0,l=k;
    if(sum>0)
    {
      ll u=ceil((double)k/g);
      if(u!=0)
      {s+=sum*(u-1);
      l-=(u-1)*g;
      }
    }
    ll p=-mod;
    REP(j,1,min(g,l))
    {
        //cout<<a[i][j]<<" ";
        p=max(p,a[i][j]);
    }
    //nl
    s+=p;
    ans=max(s,ans);
}
cout<<ans;
return 0;
}


Measured memory_bytes: 7476
K,X   = map(int, input().split())
x_max=X+K-1
x_min=X-K+1
if x_max>1000000:
    x_max=1000000
if x_min<-1000000:
    x_min=-1000000
    
ans=[]
for i in range(x_min,x_max+1):
    ans.append(i)
print(*ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, char const* argv[]) {
    int b, s, j, k;
    while (1) {
        s = j = k = 1;
        scanf("%d", &b);
        if (!b) break;
        while (1) {
            if (s < b) {
                k++;
                s += k;
            } else if (s > b) {
                s -= j;
                j++;
            } else {
                printf("%d %d\n", j, k - j + 1);
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2040
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int M = GetInt();
		int[,] A = new int[N,N];
		int[,] B = new int[M,M];
		for(int i = 0; i < N; i++)
		{
			string str = GetString();
			for(int j = 0; j < N; j++)
				A[i,j] = (str[j] == '.') ? 0 : 1;
		}
		for(int i = 0; i < M; i++)
		{
			string str = GetString();
			for(int j = 0; j < M; j++)
				B[i,j] = (str[j] == '.') ? 0 : 1;
		}

		for(int left = 0; left < N - M + 1; left++)
		{
			for(int top = 0; top < N - M + 1; top++)
			{
				int sum = 0;
				for(int i = 0; i < M; i++)
				{
					for(int j = 0; j < M; j++)
					{
						sum += A[left + i, top + j]^B[i,j];
					}
				}
				if(sum == 0)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		Console.WriteLine("No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define INF 1e12

int main(void){
    ll N,ans = -INF;
    cin >> N;
    ll zmax=-INF,zmin=INF,wmax=-INF,wmin=INF;
    REP(i,N){
        ll x,y;
        cin >> x >> y;
        zmax = max(zmax,x+y);
        zmin = min(zmin,x+y);
        wmax = max(wmax,x-y);
        wmin = min(wmin,x-y);
    }
    ans = max({ans,zmax-zmin,wmax-wmin});
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n, m, x;
  int c1 = 0;
  int c2 = 0;
  cin >> n >> m >> x;
  vector<int> a(m);
  int i;
  for(i = 0; i < m; i++)
  {
    cin >> a.at(i);
  }
  for(i = 0; i < m; i++)
  {
    if(a.at(i) < x) c1++;
    else c2++;
  }
  cout << min(c1,c2) << endl;
}

Measured memory_bytes: 256
N = int(input())
c = []
for i in range(10):
    c.append([0] * 10)
for i in range(N):
    s = str(i+1)
    i1 = int(s[0])
    i2 = int(s[-1])
    c[i1][i2] += 1
total = 0
for i in range(10):
    for j in range(10):
        total += c[i][j] * c[j][i]
print(total)

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

ll X, Y, A, B, C;

int main() {
    cin >> X >> Y >> A >> B >> C;
    vector<ll> v_a;
    vector<ll> v_b;
    for (int i = 0; i < A; i++) {
        ll a;
        cin >> a;
        v_a.push_back(a);
    }
    for (int i = 0; i < B; i++) {
        ll b;
        cin >> b;
        v_b.push_back(b);
    }

    sort(v_a.begin(), v_a.end(), greater<>());
    sort(v_b.begin(), v_b.end(), greater<>());

    priority_queue<ll> pq_a;
    priority_queue<ll> pq_b;
    for (int i = 0; i < X; i++) {
        pq_a.push(-v_a[i]);
    }
    for (int i = 0; i < Y; i++) {
        pq_b.push(-v_b[i]);
    }

    vector<ll> v_c;
    for (int i = 0; i < C; i++) {
        ll c;
        cin >> c;
        v_c.push_back(c);
    }

    sort(v_c.begin(), v_c.end(), greater<>());

    for (int i = 0; i < C; i++) {
        ll tp_a = -pq_a.top();
        ll tp_b = -pq_b.top();
        if (tp_a > tp_b) {
            if (v_c[i] > tp_b) {
                pq_b.pop();
                pq_b.push(-v_c[i]);
            }
        }
        else {
            if (v_c[i] > tp_a) {
                pq_a.pop();
                pq_a.push(-v_c[i]);
            }
        }
    }

    ll ans = 0;
    while (!pq_a.empty()) {
        ans += pq_a.top();
        pq_a.pop();
    }
    while (!pq_b.empty()) {
        ans += pq_b.top();
        pq_b.pop();
    }

    cout << -ans << endl;
   
    return 0;
}

Measured memory_bytes: 4724
#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;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll modex(ll a, ll b)
{
    ll ans = 1;
    for(;b > 0; b >>= 1, a = (a * a) % mod)
        if(b & 1)
            ans = (a * ans) % mod;
    return ans;
}
ll dp[2005][2005];
ll ncr(ll n, ll r)
{
    if(n < r || r < 0 || n < 0)
        return 0;
    return dp[n][r];
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, j, ans = 0, k;
    cin >> n >> k;
    for(i = 0; i <= n; i++)
        dp[i][i] = dp[i][0] = 1;
    for(i = 2; i <= n; i++)
        for(j = 1; j < i; j++)
            dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod;
    for(i = 1; i <= k; i++)
        cout << (ncr(n - k + 1, i) * ncr(k - 1, i - 1)) % mod << endl;
    return 0;
}

Measured memory_bytes: 30208