akhauriyash/Code-Regression huggingface dataset:
H,W,K = map(int,input().split())
ans = 0
C = []
for i in range(H):
    c = list(input())
    C.append(c)
for Is in range(1<<H):
    for Js in range(1<<W):
        count = 0
        for i in range(H):
            for j in range(W):
                if Is>>i&1:
                    continue
                if Js >>j&1:
                    continue
                if C[i][j] == "#":
                    count +=1
        if count == K:
            ans += 1
print(ans)

Measured memory_bytes: 9192
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make2(ll,n,k);
    double ans=0;
    double maxi=0;
    makevec(double,a,n);
    fr(i,k) maxi+=(a[i]+1)/2;
    ans=maxi;
    for(ll i=k;i<n;i++){
        maxi+=(a[i]+1)/2; maxi-=(a[i-k]+1)/2;
        ans=max(ans,maxi);
    }
    cout<<setprecision(10)<<ans<<endl;

    return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e3 + 100, MAX_M = 2e3 + 100, LOG_N = 12, MOD = 1e9 + 7;

struct UF{
	vector<int> UNF;
	UF(int n) {
		UNF = vector<int>(n+10, 0);
		for(int i=0; i<n+10; i++) UNF[i] = i;
	}
	int F(int v) {return UNF[v] == v ? v : UNF[v] = F(UNF[v]);}
	bool U(int a, int b) {a = F(a), b = F(b); UNF[a] = b; return a != b;}
};
int N, M; ll X;
vector<pi> Ed[MAX_N];
using ti = tuple<int, int, int>;
vector<ti> EList;
bool Used[MAX_M];

int Dep[MAX_N], Par[LOG_N][MAX_N], Max[LOG_N][MAX_N];
void dfs(int v, int p, int c) {
	Par[0][v] = p; Max[0][v] = c;
	for(int o=1; o<LOG_N; o++) Par[o][v] = Par[o-1][Par[o-1][v]], Max[o][v] = max(Max[o-1][Par[o-1][v]], Max[o-1][v]);
	Dep[v] = Dep[p] + 1;
	for(pi &val : Ed[v]) {
		int w, c; tie(w, c) = val;
		if(w == p) continue;
		dfs(w, v, c);
	}
}
pi getLCA(int a, int b) {
	if(Dep[a] > Dep[b]) swap(a, b);
	int maxV = 0;
	for(int p=0; p<LOG_N; p++) if( (1<<p) & (Dep[b] - Dep[a]) ) {
		maxV = max(maxV, Max[p][b]);
		b = Par[p][b];
	}
	if(a == b) return pi(a, maxV);
	for(int p=LOG_N-1; p>=0; p--) if(Par[p][a] != Par[p][b]) {
		maxV = max(maxV, Max[p][a]);
		maxV = max(maxV, Max[p][b]);
		a = Par[p][a]; b = Par[p][b];
	}
	int p = 0;
	maxV = max(maxV, Max[p][a]);
	maxV = max(maxV, Max[p][b]);
	a = Par[p][a]; b = Par[p][b];
	return pi(a, maxV);
}
int main() {
	cin >> N >> M >> X;
	for(int i=0; i<M; i++) {
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		EList.emplace_back(c, x, y);
	}
	UF uf = UF(N+1);
	sort(ALL(EList));
	ll mst = 0; int cnts = 0;
	for(int m=0; m<M; m++) {
		int c, x, y; tie(c, x, y) = EList[m];
		if(uf.F(x) != uf.F(y)) {
			cnts++;
			mst += c;
			uf.U(x, y);
			Used[m] = true;
			Ed[x].emplace_back(y, c);
			Ed[y].emplace_back(x, c);
		}
	}
	if(cnts < N-1 || mst > X) {
		puts("0");
		return 0;
	}
	dfs(1, 0, 0);
	ll limit = X-mst;
	int cnt[3] = {0, 0, 0}; // <L, =L, >L
	for(int m=0; m<M; m++) if(!Used[m]) {
		int c, x, y; tie(c, x, y) = EList[m];
		int lca, maxV; tie(lca, maxV) = getLCA(x, y);
		cnt[ (c-maxV > limit) - (c-maxV < limit) + 1 ]++;
	}
	vector<ll> pows = vector<ll>(M+10, 1ll);
	for(int i=1; i<=M; i++) pows[i] = pows[i-1] * 2 % MOD;

	ll ans = 0;
	if(limit == 0) ans += 1ll * (pows[N-1] + MOD - 2) * pows[(M-N+1)] % MOD;
	ans += 1ll * 2 * (pows[cnt[1]] - 1) * pows[cnt[2]] % MOD;
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}


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

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

  int s[N];
  for (int i=0; i<N; i++){
    cin >> s[i];
  }

  bool dp[110][10010];
  dp[0][0] = true;

  for (int i=0; i<N; i++){
    for (int j=0; j<10001; j++){
      if (dp[i][j]==true){
        dp[i+1][j]=true;
        dp[i+1][j+s[i]]=true;
      }
    }
  }

  for (int i=10000; i>=0; i--){
    if (dp[N][i]==true && i%10!=0){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
s=[i for i in input()]
x=0 ; st=[[],[]]
for _ in range(int(input())):
    inp=list(map(str,input().split()))
    if len(inp)==1: x^=1
    else: st[(int(inp[1])-1)^x].append(inp[2])
if x==0:
    st[0].reverse()
    ans=st[0]+s+st[1]
elif x==1:
    st[1].reverse()
    s.reverse()
    ans=st[1]+s+st[0]
print(''.join(ans))
    
    
        
            
        
        
        

Measured memory_bytes: 83064
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter
from collections import deque

def main():
    N,D,A = map(int,input().split())
    X = [tuple(map(int,input().split())) for _ in range(N)]
    
    X.sort(key=itemgetter(0))
    aldam = 0
    count = 0
    q = deque([])
    for now,dam in X:
        while q:
            if now <= q[0][0]:
                break
            aldam -= q[0][1]
            q.popleft()
        dam -= aldam
        if dam < 0:
            continue
        c = -(-dam//A)
        count += c
        aldam += c*A
        q.append((now+2*D,c*A))

    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 44528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        String S = scan.next();
        String T = scan.next();
        char[] chars_s = S.toCharArray();
        char[] chars_t = T.toCharArray();
        if (chars_s[0] != chars_t[0]) {
            System.out.println(-1);
            return;
        }
        if (N == M) {
            if (S.equals(T)) {
                System.out.println(N);
                return;
            } else {
                System.out.println(-1);
                return;
            }
        }
        long gcd = gcd(N, M);
        long lcm = N / gcd * M;
        HashMap<Long, Character> map = new HashMap<>();
        long ds = lcm / N;
        for (int i = 0; i < N; i++) {
            long x = 1 + i * ds;
            map.put(x, chars_s[i]);
        }
        long dt = lcm / M;
        for (int i = 0; i < M; i++) {
            long y = 1 + i * dt;
            if (map.containsKey(y) && map.get(y) != chars_t[i]) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(lcm);
    }
    private long gcd(long x, long y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
}


Measured memory_bytes: 32844
// atcoder/abc167/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int a, b, c, k;
  while (cin >> a >> b >> c >> k) {
    int x = 0;
    x += min(a, k);
    k -= min(a, k);

    k -= min(b, k);

    x -= min(c, k);
    k -= min(c, k);

    cout << x << endl;
  }

  return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<pair<int,int>> BA(N);
	for(int i=0;i<N;i++)	cin >> BA.at(i).second >> BA.at(i).first;

	sort(BA.begin(),BA.end());
	bool ans=true;
	long long ti=0;
	for(int i=0;i<N;i++){
		ti+=BA.at(i).second;
		if(ti>BA.at(i).first)	ans=false;
	}
	if(ans)	cout << "Yes" << endl;
	else	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	long long n, m, x;
	cin >> n >> m >> x;
	vector<long long> c(n);
	vector<vector<long long>> a(n, vector<long long>(m));
	for (long long i = 0; i < n; i++) {
		cin >> c[i];
		for (long long j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	const long long INF = 1e18;
	long long ans = INF;
	for (long long s = 0; s < (1 << n); s++) {
		long long val = 0;
		vector<long long> alg(m, 0);
		for (long long i = 0; i < n; i++) if (s & (1 << i)) {
			val += c[i];
			for (long long j = 0; j < m; j++) {
				alg[j] += a[i][j];
			}
		}
		bool ok = true;
		for (long long i = 0; i < m; i++) {
			ok &= (alg[i] >= x);
		}
		if (ok) chmin(ans, val);
	}
	
	if (ans == INF) cout << -1 << '\n';
	else cout << ans << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a, b, c;
	//string s="error";
	cin >> a; cin >> b; cin >> c;
	if (b-a == c-b)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

const ll MOD =1000000007;
ll H,W,K;
ll S[9],cnt[10][10],dp[101][9];

bool check(ll* S){
    for(ll i=1;i<=W-2;i++)if(S[i]==1 && S[i+1] == 1)return false;
    return true;
}

void dfs(ll i){
    if(i==W){
        if(check(S)){
            for(ll j=1;j<=W;j++){
                if(S[j-1] == 1)cnt[j][j-1]++;
                else if(S[j] == 1 )cnt[j][j+1]++;
                else cnt[j][j]++;
            }
        }
        return ;
    }
    S[i] = 0;
    dfs(i+1);
    S[i] = 1;
    dfs(i+1);
}


int main(void){
    cin >> H >> W >> K;
    S[0] = S[8] = 0;
    dfs(1);

    
    dp[0][1] = 1;
    for(ll i=0;i<H;i++){
        for(ll j=1;j<=W;j++){
            dp[i+1][j] = ((dp[i][j-1]*cnt[j][j-1])%MOD + (dp[i][j]*cnt[j][j])%MOD +(dp[i][j+1]*cnt[j][j+1])%MOD)%MOD;
        }
    }
    

    cout << dp[H][K] << endl;
   
}


Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll n,a[3005],dp[3005][3005][2]={0},vis[3005][3005][2]={0};
ll fun(ll i,ll j,ll k){
	if(vis[i][j][k])return dp[i][j][k];
	vis[i][j][k]=1;
	if(k==1&&i==j){
		dp[i][j][k]=a[i];
		return a[i];
	}
	else if(k==0&&i==j){
		dp[i][j][k]=-a[i];
		return -a[i];
	}
	if(k){
		dp[i][j][k]=max(fun(i+1,j,0)+a[i],fun(i,j-1,0)+a[j]);
	}
	else{
		dp[i][j][k]=min(fun(i+1,j,1)-a[i],fun(i,j-1,1)-a[j]);
	}
	return dp[i][j][k];
}
int main(){
	cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	cout<<fun(0,n-1,1);
}

Measured memory_bytes: 281088
#include<bits/stdc++.h>
    #define N 2009
    using namespace std;
     
    int m,n,ans,a[N][N],b[N][N],c[N],q[N],lf[N],rg[N];
    char s[N];
    int main(){
    	scanf("%d%d",&m,&n);
    	int i,j,k;
    	for (i=1; i<=m; i++){
    		scanf("%s",s+1);
    		for (j=1; j<=n; j++) a[i][j]=(s[j]=='#');
    	}
    	for (i=1; i<=m; i++)
    		for (j=2; j<=n; j++)
    			b[i][j]=(a[i][j]^a[i+1][j])==(a[i][j-1]^a[i+1][j-1])?b[i-1][j]+1:0;
    	for (i=1; i<=m; i++)
		{
    		for (j=2; j<=n; j++) c[j]=1+b[i-1][j];
//if (i==2) for (j=2; j<=n; j++) cout<<c[j]<<' ';puts("");
    		q[k=1]=1; c[1]=-2; c[n+1]=-1;
    		for (j=2; j<=n+1; j++){
    			for (; c[j]<=c[q[k]]; k--) rg[q[k]]=j;
    			lf[j]=q[k]; q[++k]=j;
    		}
    		for (j=2; j<=n; j++){
    			//cout<<j<<' '<<lf[j]<<' '<<rg[j]<<endl;
    			ans=max(ans,c[j]*(rg[j]-lf[j]));
    		}
    	}
    	printf("%d\n",max(ans,max(m,n)));
    	return 0;
    }

Measured memory_bytes: 31744
#include <stdio.h>

int main(void){
  int abc[3], sum=0, max=0, i;
  for(i=0; i<3; ++i){
    scanf("%d", &abc[i]);
    sum += abc[i];
    if(max < abc[i]) max=abc[i];
  }
  printf("%d\n", sum-max);
  return 0;
}
    
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {
	int d;
	cin>>d;
	if(d==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}

	if(d==23){
		cout<<"Christmas Eve Eve"<<endl;
	}
	if(d==24){
		cout<<"Christmas Eve"<<endl;
	}
	if(d==25){
		cout<<"Christmas"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
int N,A,B,C,l[8];

int main(){
  string s;
  int a[100000]={0};
  cin>>s;
  for (int i(0);i<s.size()-1;i++){
    if (s[i]=='R' && s[i]=='L') {
      a[i]=1;
      a[i+1]=2;
    }
  }
  int ri(1),li(1);
  for (int i(0);i<s.size();i++){
    if (s[i]=='R'&&s[i+1]=='L'){
      a[i]=ri;
      ri=1;
    }else if (s[i]=='R'&&s[i+1]=='R')ri++;
  }
  for (int i(s.size());i>=0;i--){
    if (s[i]=='L'&&s[i-1]=='R'){
      a[i]=li;
      li=1;
    }else if (s[i]=='L'&&s[i-1]=='L') li++;
  }
  // for (int i(0);i<s.size();i++) cerr << a[i] << " ";
  // cerr << endl;
  int cnt(0);
  int ans[100000]={0};
  for (int i(0);i<s.size();i++){
    if (a[i]!=0) cnt++; 
    if (cnt%2==1){
      if (a[i]%2==0) {
        ans[i]+=a[i]/2;
        ans[i+1]+=a[i]/2;
      }else{
        ans[i]+=a[i]/2+1;
        ans[i+1]+=a[i]/2;
      }
      if (a[i+1]%2==0) {
        ans[i+1]+=a[i+1]/2;
        ans[i]+=a[i+1]/2;
      }else{
        ans[i+1]+=a[i+1]/2+1;
        ans[i]+=a[i+1]/2;
      }
    } 
  }
  // cerr << endl;
  for (int i(0);i<s.size();i++) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) for (int j = 0; j < i; j++) if (s[i] == s[j]) {
        cout << "no";
        return 0;
    }
    cout << "yes";
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
 
using namespace std;
typedef long long ll;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
 
const ll mod = 1e9 + 7;
const ll inf = 1e18;
 
int timeline[200010];
int useline[200010]; // 使っていれば1
int neednum[200010] = {}; // その時間に求められる録画機の数（ラインの数）
 
void resetTimeline(){
    FOR(i, 0, 200010){
        timeline[i] = 0;
        useline[i] = 0;   
    }
}
 
void printArray(int *a, int num){
    FOR(i, 0, num){
        cout << a[i] << " ";
    }
    cout << endl;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    // input
    int N, channelNum;
    cin >> N >> channelNum;
 
    vector<int> S(N);
    vector<int> T(N);
    vector<int> C(N);
 
    // タイムスケールを2倍にして整数で考える
    FOR(i, 0, N){
        int s, t, c;
        cin >> s >> t >> c;
        s *= 2;
        t *= 2;
        S[i] = s;
        T[i] = t;
        C[i] = c;
    }
 
    // 各チャンネル毎に占有したい時間帯を求める
    FOR(c, 1, channelNum+1){
        resetTimeline();
        FOR(i, 0, N){
            if(C[i]==c){
                timeline[S[i]-1] = 1;
                timeline[T[i]] = -1;
            }
        }
        // いもす
        useline[0] = timeline[0];
        FOR(i, 1, 200010){
            useline[i] = useline[i-1] + timeline[i];
        }
        //
        FOR(i, 0, 200010){
            if(useline[i]>0){
                neednum[i]++;
            }
        }
    }
 
    int answer = neednum[0];
    FOR(i, 0, 200010){
        answer = max(answer, neednum[i]);
    }
 
    p(answer);
    
    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  vector<int> num ;
  REP(i,9){
    REP(j,9){
      num.push_back((i+1)*(j+1)) ;
    }
  }
  REP(i,81){
    if(num.at(i)==n){
      cout << "Yes" <<endl ;
      return 0 ;
    }
  }
  
  cout << "No"<<endl ;


  return 0 ;
}





Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n=int(input())
a=list(map(int,input().split()))
a.sort()

lst=[]

flag=0
for i in range(n-1):
    if a[i+1]>0:
        flag=i+1
        break
if flag==0:
    flag=n-1
tmp=a[0]
for i in range(flag,n-1):
    lst.append([tmp,a[i]])
    tmp-=a[i]
a[0]=tmp
tmp=a[-1]
for i in range(flag):
    lst.append([tmp,a[i]])
    tmp-=a[i]

print(tmp)
for i in range(n-1):
    print(*lst[i])
    
# print(lst)

Measured memory_bytes: 93496
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int k, a, b;
    cin >> k;
    cin >> a >> b;

    int f = 0;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            f = 1;
            break;
        }
    }
    if(f)cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

void quicksort(int a[], int l, int r){
  int s, t, i, j;
  if (l<r) {
    s=a[(l+r)/2]; i=l; j=r;
    while (1) {
      while (a[i]<s) i++;
      while (a[j]>s) j--;
      if (i>=j) break;
      t=a[i]; a[i]=a[j]; a[j]=t;
      i++; j--;
    }
    quicksort(a,l,i-1);
    quicksort(a,j+1,r);
  }
}

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

  int i,a[n];
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  quicksort(a,0,n-1);
  int max=0,submax=0,k=0;
  for(i=n-1;i>=0;i--){
    k=a[i];
    //printf("%d ",k);
    if(a[i-1]==k){
      if(max==0){
        max=k;
        i--;
      }
      else{
        submax=k;
        break;
      }
    }

  }
  printf("%ld\n",(long)max*submax);
}


Measured memory_bytes: 512
w,h,x,y = map(int,input().split())
a = w*h/2
if w%2 == 0 and h%2 == 0:
    if x == int(w/2) and y == int(h/2):
        print(a, 1)
    else:
        print(a, 0)
else:
    print(a, 0)

Measured memory_bytes: 3060
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = 0
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i,mod)
    T = (T+s)%mod
    ans += D[T]
    D[T]+=1
print(ans)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

const ll U = 1000000000;

signed main() {
  ll s, a, b, c, d;
  cin>>s;
  a = sqrt(s);
  b = s/a;
  if (a*b < s) a++;
  if (a*b < s) b++;
  ll diff = abs(a*b - s);
  if (diff != 0) {
    for (ll i=1; i*i<=diff; i++) {
      if (i <= U && (diff/i) <= U && i * (diff/i) == diff) {
        c = i;
        d = diff/i;
      }
    }
  } else {
    c = d = 0;
  }
  printf("%d %d %d %d 0 0\n", a, d, c, b);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int count[26] = {0};
    int i;
    char ch;
    
    while(scanf("%c", &ch) != EOF) {
        if (ch >= 'A' && ch <= 'Z') {
            count[ch - 'A']++;
        } else if (ch >= 'a' && ch <= 'z') {
            count[ch - 'a']++;
        }
    }
    for(i='a'; i<='z'; i++) {
            printf("%c : %d\n", i, count[i - 'a']);
    }
    return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+10,0);
    vector<ll> b(n+10,0);
    vector<ll> c(n+10,0);
    c[0]=1;
    rep1(i,n){
        c[i]=c[i-1]*8;
        c[i]%=mod;
        b[i]=b[i-1]*9+c[i-1]*2;
        b[i]%=mod;
        a[i]=a[i-1]*10+b[i-1];
        a[i]%=mod;
    }
    cout<<a[n]<<endl;
}

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

#define ll long long
#define pll pair<ll,ll> 

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

	string s, w;
	cin>>s>>w;
	ll ans=0;
	for(ll i=0;i<s.size();i++)
		ans+=s[i]!=w[i];
	cout<<ans<<endl;
}



Measured memory_bytes: 3788
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def lcs(X, Y):
    dp = []
    for y in Y:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            # 既に探索済みの最長文字列を更新
            chr_idx = X.find(y, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(chr_idx, cur_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = X.find(y, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    for _ in range(N):
        X, Y = iss(), iss()
        print(lcs(X, Y))


if __name__ == '__main__':
    main()



Measured memory_bytes: 7132
def lcm(a, b):
	return a // gcd(a, b) * b

def gcd(a, b):
	while b != 0:
		r = a % b
		a = b
		b = r
	return a

while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break


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

    /**************************************
      Writter Torisuto 2020/8/15
      [考え]
      数字がとても大きいため、愚直にやると時間が
      かかるためできない。
      最終的に原点に最も近づく場合を考えると良い。
      以下のように考える。
      (i)
      K回以内で最も原点に近づく座標まで動く。
      (ii)
      残った回数が、偶数ならその場所、奇数なら
      原点を越えた先が最小値の場所になるはずである。

    　スタートはX座標マイナスとプラスの２つあるが、
      上の方法を使えば、関係なく最小値が出せる。
      よって、Xの符号はどちらかに揃えるようにすれば
      解くことができる。
      今回、Xを正に揃えて行った場合を示す。
    ***************************************/

int main(){

  ll X,K,D;
  cin >> X >> K >> D;
  if(X<0)
  X = -X;
  ll ans = X;

  //原点に近づく作業
  if(X/D < K){
    K -= X/D;
    ans = X - D*(X/D);
  } else {
    cout << X-D*K << endl;
    return 0;
  }

  //偶数奇数の場合分け
  //偶数ならその場、奇数なら原点をまたいだ座標。
  if(K%2==0){
    cout << ans << endl;
  } else {
    cout << D-ans << endl;
  }


  return 0;
}


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

int main()
{
	int a, b;
	std::cin >> a >> b;
	std::string str;
	std::cin >> str;
	
	int count = 0, oneCount = 0, twoCount = 0;
	bool flag = false;
	for (int i = 0; i < str.length(); ++i)
	{
		if (str[i] == '-')
		{
			flag = true;
			++count;
		}
		if (flag && str[i] != '-')
			++twoCount;
		if (!flag)
			++oneCount;
	}
	
	if (a == oneCount && b == twoCount && count == 1)
	{
		std::cout << "Yes";
	}
	else
	{
		std::cout << "No";
	}
	
}

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


#define ll long long
#define ull unsigned long long
#define pb push_back

#define fr(i,a,b)   for(i=a;i<=b;i++)
#define frn(i,a,b)  for(i=a;i>=b;i--)
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
int frq[600];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    string s;
    set<char> st;

    int i,j,fl=0;

    cin>>s;
    fr(i,0,s.size()-1)
     {
         st.insert(s[i]);
         frq[s[i]]++;
     }

    set<char>::iterator it;

    for(it=st.begin();it!=st.end();it++)
    {
        //cout<<*it<<" "<<frq[*it]<<endl;
        if(frq[*it]%2==1)
        {
            fl=1;
            break;
        }
    }

    if(fl==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";



    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,d;
    while(cin>>n>>d, n){
        vvl a(n);
        rep(i,n){
            ll l;cin>>l;
            a[i].resize(l+1,0);
            rep(j,l)cin>>a[i][j+1];
            partial_sum(all(a[i]),a[i].begin());
        }
        bool ans=true;
        rep(i,n){
            rep(j,a[i].size()-1){
                ll l=max(a[i][j+1]-d,0);
                ll r=a[i][j]+d;
                bool ok=true;
                rep(k,n)if(k!=i){
                    ll lp = lower_bound(all(a[k]),l)-a[k].begin();
                    ll rp = upper_bound(all(a[k]),r)-a[k].begin();
                    ok &= (rp>lp);
                }
                if(!ok){
                    ans=false;
                    goto fin;
                }
            }
        }
        fin:
        Yn(ans);
    }
    return 0;
}


Measured memory_bytes: 3052
#include<stdio.h>
int main(void) {
	int n, m;
	int i, j;
	int a[100][100], b[100], c[100] = { 0 };

	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (j = 0; j < m; j++) {
		scanf("%d", &b[j]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			c[i] += a[i][j] * b[j];
		}
	}
	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}


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

int main() {
  int n, m, i;
  cin >> n >> m;
  
  vector<int> a(n);
  vector<vector<int>> bc(m, vector<int>(2));
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for(i = 0; i < m; i++){
    cin >> bc.at(i).at(1) >> bc.at(i).at(0);
  }
  
  sort(a.begin(), a.end());
  sort(bc.begin(), bc.end());
  
  int pointa = n - 1, pointbc = m - 1, count = 0, out = 0;
  long ans = 0;
  while(count < n){
    if(out == 1){
      ans += a.at(pointa);
      pointa--;
      count++;
    }
    else if(pointa >= 0 && a.at(pointa) > bc.at(pointbc).at(0)){
      ans += a.at(pointa);
      pointa--;
      count++;
    }
    else if(out != 1 && bc.at(0).at(1) > 0 && a.at(pointa) <= bc.at(pointbc).at(0)){
      ans += bc.at(pointbc).at(0);
      bc.at(pointbc).at(1)--;
      count++;
      if(pointbc == 0 && bc.at(pointbc).at(1) == 0){
        out = 1;
      }
      else if(bc.at(pointbc).at(1) == 0){
        pointbc--;
      }
    }
  }
  
  cout << ans << endl;
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int gd[222][222];
int main()
{
	int k;
	cin >> k;
	for(int i = 1; i <= k; i ++)
	for(int j = 1; j <= k; j ++)
		gd[i][j] = __gcd(i, j);
	ll s=  0;
	for(int i = 1; i <= k; i ++)
		for(int j = 1; j <= k; j ++)
			for(int q = 1; q <= k; q ++)
			{
				int g = gd[i][gd[j][q]];
				s += g;
			}
	cout << s;




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3792
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 21
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int f[1<<N][N];
int n,m;
char s[1<<N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read();
	for(register int i=0;i<=n;i++)
	{
		scanf("%s",s);
		for(register int j=0;j<(1<<i);j++)
		{
			f[(1<<i)|j][i]=(s[j]-'0');
		}
	}
	for(register int i=n;i>=0;i--)
	{
		for(register int j=0;j<(1<<i);j++)
		{
			for(register int k=i;k;k--)
			{
				if(!f[(1<<i)|j][k])continue;
				int v=f[(1<<i)|j][k],S=(j>>k),T=(j&((1<<k)-1));
				f[(1<<(i-k))|S][0]+=v;
				int u1=(k-1),u2=(k-1);
				while((u1>=0)&&((T>>u1)&1))u1--;
				while((u2>=0)&&(!((T>>u2)&1)))u2--;
				if(u2>=0){f[(T&((1<<u2)-1))|(S<<(u2+1))|(1<<(i-k+u2+1))|(1<<u2)][u2]+=v;}
				if(u1>=0){f[(T&((1<<u1)-1))|(S<<(u1+1))|(1<<(i-k+u1+1))][u1]+=v;}
			}
		}
	}
	for(register int i=n;i>=0;i--)
	{
		for(register int j=0;j<(1<<i);j++)
		{
			if(f[(1<<i)|j][0]>=m)
			{
				for(register int k=i-1;k>=0;k--)printf("%d",(j>>k)&1);printf("\n");
				return 0;
			}
		}
	}
	puts("");
	return 0;
}


Measured memory_bytes: 176892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, x;
	cin>>n>>x;
	int ar[n+1];
	fore(i, 0 , n) cin>>ar[i];
	ar[n] = x;
	sort(ar, ar + n+1);
	int g = 0;
	fore(i, 0, n)
	{
		g = __gcd(g, ar[i+1] - ar[i]);
	}
	cout<<g<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 640
n, m, X = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
    
for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)
        
    


Measured memory_bytes: 9272
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int H, W, N;
	cin >> H >> W >> N;

	if (H >= W) {
		if (N % H == 0) {
			cout << N / H << endl;
		}
		else {
			cout << N / H + 1 << endl;
		}
	}
	else {
		if (N % W == 0) {
			cout << N / W << endl;
		}
		else {
			cout << N / W + 1 << endl;
		}
	}
}






Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n,d; cin>>n>>d;
    int x[n][d]; rep(i,n) rep(j,d) cin>>x[i][j];
    int cnt=0;

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            int curr = 0;
            rep(k,d){
                int xx = x[i][k]-x[j][k];
                curr += xx*xx;
            }
            int now = sqrt(curr);
            if(now*now == curr) cnt++;
        }
    }
    cout << cnt << ln;
    return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>

using namespace std;

#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int X, Y; cin >> X >> Y;

    cout << X + (0.5 * Y) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,i,ans;
    cin>>N;
    long long V[N],C[N];
    for(i=0;i<N;i++){
        cin>>V[i];
    }
    for(i=0;i<N;i++){
        cin>>C[i];
    }
    ans=0;
    for(i=0;i<N;i++){
        if(V[i]>C[i]){
            ans+=V[i]-C[i];
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

vector<bool> d(11, false);

bool hasBannedDigit(int n) {
	while (n) {
		int x = n % 10;
		if (d[x])
			return true;
		n /= 10;
	}
	return false;
}

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

	int n, k, x;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		cin >> x;
		d[x] = true;
	}
	while (hasBannedDigit(n)) {
		n++;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int n,u,k,v,graph[106][106]={{}};

  cin >> n ;

  for(int i = 0; i < n; i++){
    cin >> u >> k ;
    for(int j = 0; j < k ; j++){
      cin >> v;
      graph[u][v] = 1;
    }
  }

  for(int i = 1; i<= u; i++){
    for(int j = 1; j<= u; j++){
      if(j != 1) cout <<  ' '<< graph[i][j] ;
      else cout << graph[i][j] ;
    }
    cout << endl;
  }


  return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

char decode(char c, int k){
    if('a' <= c && c <= 'z'){
        if(c - k >= 'a') return c - k;
        return decode('Z', k - (c - 'a') - 1);
    }
    if(c - k >= 'A') return c - k;
    return decode('z', k - (c - 'A') - 1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> k(n);
        string s;
        for(int i = 0; i < n; ++i){
            cin >> k[i];
        }
        cin >> s;
        for(int i = 0; i < s.size(); ++i){
            cout << decode(s[i], k[i % n]);
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
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 ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int A,B;
  cin>>A>>B;
  if(B%A ==0){
    cout<< A+B<<endl;
  }
  else{
    cout<< B-A<<endl;
  }

}


Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
    int n;
    cin>>n;
    int c1 = 0 ,c2 = 0 ,c3 = 0 ,c4 = 0 ;
    rep(i , n){
    	string s ; 
    	cin>>s ;
    	if(s=="AC"){
    		c1++;
    	}
    	if(s=="WA"){
    		c2++;
    	}
    	if(s=="TLE"){
    		c3++;
    	}
    	if(s=="RE"){
    		c4++;
    	}
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int N;
string S;

int main()
{

	cin >> N;
	cin >> S;

	int ans = N;

	int cur = -1;

	for (int i = 0; i < N; i++) {
		int tgt = S.at(i) - 'a';

		if (tgt == cur) { ans--; }
		cur = tgt;
	}



	cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 512
def filter(a,b):
    if a<=b:
        print(str(a)+" "+str(b))
    else:
        print((str(b)+" "+str(a)))


flg=0
i=1
in_data=input()
in_list=in_data.split(" ")
in_list[0]=int(in_list[0])
in_list[1]=int(in_list[1])

while flg==0:
    if in_list[0]==0 and in_list[1]==0:
        flg=1
    else:
        filter(in_list[0],in_list[1])
        in_data=input()
        in_list=in_data.split(" ")
        in_list[0]=int(in_list[0])
        in_list[1]=int(in_list[1])



Measured memory_bytes: 5624
from collections import defaultdict

H,W=map(int,input().split())
dp=[[float("inf") for _ in range(10)] for _ in range(10)]
cnt = defaultdict(lambda:0)
ans=0

for i in range(10):
    tmp=tuple(map(int,input().split()))
    for k in range(10):
        dp[i][k]=tmp[k]
    dp[i][i]=0

for k in range(10):
    for i in range(10):
        for j in range(10):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])

for _ in range(H):
    cn=list(map(int,input().split()))
    for x in cn:
            cnt[x]+=1

for n in range(10):
    ans+=cnt[n]*dp[n][1]
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");         
    else if(b>=0)puts("Zero");           
    else if((a&1)^(b&1))puts("Positive"); 
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128