akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <typename T>
class imos2 {
	int n, m;
	vector<vector<T>> v;
public:
	imos2(int n, int m) : n(n), m(m), v(n + 1, vector<T>(m + 1)) {}
	T& val(int i, int j) { assert(0 <= i && i < n && 0 <= j && j < m); return v[i + 1][j + 1]; }
	void add(int li, int lj, int ri, int rj, T x) {
		assert(0 <= li && li <= ri && ri <= n);
		assert(0 <= lj && lj <= rj && rj <= m);
		val(li, lj) += x;
		if (ri < n) val(ri, lj) -= x;
		if (rj < m) val(li, rj) -= x;
		if (ri < n && rj < m) val(ri, rj) += x;
	}
	void build() {
		for (int i = 1; i <= n; i++) for (int j = 0; j <= m; j++) v[i][j] += v[i - 1][j];
		for (int i = 0; i <= n; i++) for (int j = 1; j <= m; j++) v[i][j] += v[i][j - 1];
	}
	T sum(int li, int lj, int ri, int rj) {
		assert(0 <= li && li <= ri && ri <= n);
		assert(0 <= lj && lj <= rj && rj <= m);
		return v[ri][rj] - v[ri][lj] - v[li][rj] + v[li][lj];
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}
	imos2<int> cnt(N, M), tate(N - 1, M), yoko(N, M - 1);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cnt.val(i, j) = s[i][j] == '1';
		}
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < M; j++) {
			tate.val(i - 1, j) = (s[i][j] == '1') && (s[i - 1][j] == '1');
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < M; j++) {
			yoko.val(i, j - 1) = (s[i][j] == '1') && (s[i][j - 1] == '1');
		}
	}
	cnt.build();
	tate.build();
	yoko.build();
	while (Q--) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2; x1--, y1--;
		printf("%d\n", cnt.sum(x1, y1, x2, y2) - tate.sum(x1, y1, x2 - 1, y2) - yoko.sum(x1, y1, x2, y2 - 1));
	}
	return 0;
}


Measured memory_bytes: 54400
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s = line.Trim().Split(' ');
            var a = int.Parse(s[0]);
            var b = int.Parse(s[1]);
            Console.WriteLine(a + b);
        }
    }
}

Measured memory_bytes: 9196
n=int(input())
s=input()
c=0
for i in range(10):
  a=s.find(str(i))
  if -1<a<n-2:
    
    for j in range(10):
      b=s[a+1:].find(str(j))
      if -1<b<len(s[a+1:])-1:
    
        for k in range(10):
          if s[a+b+2:].find(str(k))>-1:
            c+=1
print(c)

Measured memory_bytes: 9264
x, y = map(int,input().split())
A = [[0 for i in range(y)]for i in range(x)]
B = [0 for i in range(y)]

for i in range(x):
    a = list(map(int,input().split()))
    A[i] = a
        
for i in range(y):
    b = int(input())
    B[i] = b
   
ans = [0]*x
for i in range(x):
    for j in range(y):
        ans[i] += A[i][j] * B[j]
for ansi in ans:
    print(ansi)


Measured memory_bytes: 5968
a, b, c = map(int, input().split())
k = int(input())

while True:
    if a >= b:
        b *= 2
        # print(b)
        k -= 1
    else:
        break
while True:
    if b >= c:
        c *= 2
        # print(c)
        k -= 1
    else:
        break

if k < 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 61684
#include<stdio.h>
int main(){

	int m,f,r,j,i=0;
	char c[100]={};

	while(1){
	scanf("%d %d %d",&m,&f,&r);
	
	
	if(m+f<30 || m==-1 || f==-1) c[i]='F';
	if(m+f>=80) c[i]='A';
	if(m+f>=65 && m+f<80) c[i]='B';
	if(m+f>=50 && m+f<65) c[i]='C';
	if(r>=50) c[i]='C';
	if(m+f>=30 && m+f<50 && r<50 && m!=-1 && f!=-1) c[i]='D';

	i++;
	if(m==-1 && f==-1 && r==-1) break;
	}

	for(j=0; j<i-1; j++){
		printf("%c\n",c[j]);
	}

	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n; cin >> n;
    unordered_map<string, ll> hashmap;
    string in;
    ll ans = 0;
    rep(i, n){
        cin >> in;
        sort(all(in));
        if(hashmap[in]==0){
            hashmap[in] = 1;
        }
        else{
            ans += hashmap[in];
            hashmap[in]++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10660
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const ll MOD = 1000000007LL;

vector<ll> as;

vector<ll> ss;

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

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

    ss.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        ss[i + 1] = (ss[i] + as[i]) % MOD;
    }

    ll ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        ll x = as[i];
        // printf("%lld * %lld\n", x, ss[i]);
        x = (x * ss[i]) % MOD;
        ans = (ans + x) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6364
package main

import (
	"fmt"
)

func main() {
	var card [3][3]int
	for row := 0; row < len(card); row++ {
      for column := 0; column < len(card[0]); column++ {
			fmt.Scan(&card[row][column])
		}
	}
  
	var n,b int
    fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b)
      	for row := 0; row < len(card); row++ {
          for column := 0; column < len(card[0]); column++ {
              if card[row][column] == b {
                card[row][column] = -1
              }
            }
        }
	}
  
    if card[0][0] == card[1][1] && card[1][1] == card[2][2] {
      fmt.Println("Yes")
      return
    }
  
  	if card[0][2] == card[1][1] && card[1][1] == card[2][0] {
      fmt.Println("Yes")
      return
    }
  	
 	
  	for row := 0; row < len(card); row++ {
      	check := true
	    for column := 0; column < len(card[0]); column++ {
          if card[row][column] != -1 {
				check = false
          }  		
        }
        if check {
          fmt.Println("Yes")
          return
        }
    }
    
    for column := 0; column < len(card[0]); column++ {
      	check := true
    	for row := 0; row < len(card); row++ {
            if card[row][column] != -1 {
                  check = false
            }  		
          }
          if check {
            fmt.Println("Yes")
            return
          }
     }
  	fmt.Println("No")
}

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

struct Edge {
	int a, b, cost;
	bool operator <(const Edge&e)const {
		return cost < e.cost;
	}
};

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};


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

	cin >> N >> M;
	vector<Edge>edge(M);
	for (auto &i : edge)cin >> i.a >> i.b >> i.cost;
	sort(edge.begin(), edge.end());
	UnionFind uf(N);
	vector<vector<Edge>>v(N + 1);
	long long int ans = 0;
	for (auto i : edge) {
		if (uf.Check_Same(i.a, i.b))continue;
		uf.Unite(i.a, i.b);
		v[i.a].push_back({ i.a,i.b,i.cost });
		v[i.b].push_back({ i.b,i.a,i.cost });
		ans += i.cost;
	}
	vector<vector<int>>minus(N + 1, vector<int>(N + 1));
	for (int i = 1; i <= N; i++) {
		vector<int>used(N + 1);
		queue<int>Q;
		Q.push(i);
		used[i] = 1;
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : v[cn]) {
				if (used[j.b])continue;
				//if (minus[i][j.b] < max(minus[i][j.a], j.cost)) {
				minus[i][j.b] = max(minus[i][cn], j.cost);
				used[j.b] = 1;
				Q.push(j.b);
				//}
			}
		}
	}
	cin >> K;
	while (K--) {
		cin >> L >> R;
		cout << ans - minus[L][R] << endl;
	}

	return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <cstdio>
#include <cctype>
#define il inline
#define vd void
#define rg register
#define mn 3004
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int p,a[mn],b[mn],y[mn],inv[mn],s[mn][mn];
il int Pow(int a,int b){int ans=1; for(a%=p;b;b&1?ans=1ll*ans*a%p:0,a=1ll*a*a%p,b>>=1); return ans;}
il vd Inc(int &a,int b){if((a+=b)>=p) a-=p;}
il vd Dec(int &a,int b){if((a-=b)<0) a+=p;}
int main(){
	p=rd(),s[0][0]=inv[0]=inv[1]=1;
	for(rg int i=2;i<p;++i) inv[i]=1ll*(p-p/i)*inv[p%i]%p;
	for(rg int i=1;i<=p;++i){
		for(rg int j=1;j<=i;++j){
			s[i][j]=s[i-1][j-1],Dec(s[i][j],1ll*(i-1)*s[i-1][j]%p);
		}
	}
	for(rg int i=0;i<p;++i) if(rd()){
		int t=1;
		for(rg int j=0;j<i;++j) t=1ll*t*inv[i-j]%p;
		for(rg int j=i+1;j<p;++j) t=(p-1ll*t*inv[j-i]%p)%p;
		for(rg int j=1;j<=p;++j) a[j]=s[p][j];
		for(rg int j=p;j;--j) y[j-1]=a[j],Dec(a[j-1],(p-1ll*y[j-1]*i%p)%p);
		for(rg int j=0;j<p;++j) Inc(b[j],1ll*y[j]*t%p);
	}
	for(rg int i=0;i<p;++i) rt(b[i]),pc(' ');
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 37888
#include <iostream>

using namespace std;

const int NMAX = 100000 + 5;

int N, L;
int v[NMAX];

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

    cin >> N >> L;

    for (int i = 1; i <= N; ++ i)
        cin >> v[i];

    int best = 0;
    int who = 0;
    for (int i = 1; i < N; ++ i)
        if (v[i] + v[i + 1] > best) {
            best = v[i] + v[i + 1];
            who = i;
        }

    if (best < L) {
        cout << "Impossible\n";
        return 0;
    }

    cout << "Possible\n";
    for (int i = 1; i < who; ++ i)
        cout << i << '\n';
    for (int i = N - 1; i > who; -- i)
        cout << i << '\n';
    cout << who << '\n';
    return 0;
}


Measured memory_bytes: 1280
use proconio::{fastout, input};
use std::vec::Vec;

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64, 
        d: i64,
    }

    let mut answers = Vec::<i64>::with_capacity(4);
    
    answers.push(a * c);
    answers.push(a * d);
    answers.push(b * c);
    answers.push(b * d);

    answers.sort();

    println!("{}", answers[3]);
}


Measured memory_bytes: 2204
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


int n;
vector<vector<int>> g;
int used[1000];

int func(int cur) {
	int res =  0;
			used[cur] = 1;
	for (auto itr : g[cur]) {
		if (!used[itr]) {
			res = max(res,1+func(itr));
		}
	}
			used[cur] = 0;
	return res;
}

signed main() {
	
	while (scnaf("%d", &n) != EOF) {
		if (!n)
			break;
		g.clear();
		g.resize(n*2);
		map<int, int> v;
		int vc = 0;
		REP(i, n) {
			int a, b;
			scanf("%d %d", &a, &b);
			if (!v.count(a))
				v[a] = v.size();
			if (!v.count(b))
				v[b] = v.size();
			g[v[a]].push_back(v[b]);
			g[v[b]].push_back(v[a]);
		}
		int ans = 0;
		REP(i, v.size()) {
			ans = max(ans, func(i));
		}
		printf("%d\n", ans+1);
	}
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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

	if (b > a)
	{
		if (a<c && b>c) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else
	{
		if (b<c && a>c) cout << "Yes" << endl;
		else cout << "No" << endl;
	}



}

Measured memory_bytes: 256
N = int(input())
W = [int(x) for x in input().split()]

ans = float('inf')

for i in range(N):
	for j in range(i + 1):
		tmp = abs(sum(W[0: j + 1]) - sum(W[j + 1:]))
		if tmp < ans:
			ans = tmp

print(ans)

Measured memory_bytes: 3060
import sys
from collections import defaultdict

import numpy as np

n = int(input())
appeared = defaultdict(lambda: 0)
ans = 0
for s in sys.stdin:
    p = tuple(np.bincount([ord(c) - 97 for c in s.strip()], minlength=26))
    ans += appeared[p]
    appeared[p] += 1
print(ans)


Measured memory_bytes: 130440
parseInt(x) = parse(Int, x)
parsemap(x::Array{SubString{String},1}) = map(parseInt, x)
using DataStructures

function main()
    n=parseInt(readline())
    a=sort(parsemap(split(readline())),rev=true)
    bet=Queue{Int}()
    enqueue!(bet,a[1])
    ans=0
    for i in a[2:end]
        ans+=dequeue!(bet)
        enqueue!(bet,i)
        enqueue!(bet,i)
    end
    println(ans)
end
main()

Measured memory_bytes: 217824
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    string c;
    cin >> c;
    int ans = 0;
    int left = 0, right = N - 1;
    while (left < right) {
        if (c[left] == 'R') {
            left ++;
        } else if (c[left] == 'W' && c[right] == 'R') {
            ans ++;
            left ++;
            right --;
        } else {
            right --;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

vector<int> divisor(int n){
    vector<int> res;
    for (int i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v = divisor(m);
    sort(v.begin(), v.end(), greater<int>());
    for (int i = 0; i < v.size(); i++){
        if (v[i] <= m / n){
            cout << v[i] << endl;
            return 0;
        }
    }
}

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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    
    vector<int> cnt(26);
    for (int i = 0; i < N; i += 2) {
        cnt[S[i] - 'a'] += 1;
    }
    
    vector<int> p(10);
    for (int i = 0; i < 26; i++) {
        p[cnt[i]] += 1;
    }

    int res = 2 * p[1];
    for (int i = 2; i <= 9; i++) {
        if (p[i] == 1) {
            res += 4;
        } else if (p[i] >= 2) {
            res += 5 + 2 * p[i] - 1;
        }
    }
    cout << res - 1 << endl;    
    return 0;
}

Measured memory_bytes: 3216
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
const int MAXN=1005;
const long double EPS=1e-13;
int n;
long double S[2],E[2];
long double d[MAXN];
bool vis[MAXN];
struct circle
{
	long double x,y,r;
}C[MAXN];
long double jl(int i,int j)
{
	long double o=sqrt((C[i].x-C[j].x)*(C[i].x-C[j].x)+(C[i].y-C[j].y)*(C[i].y-C[j].y));
	o=o-C[i].r-C[j].r;
	if(o<EPS)
		o=0.0;
	return o;
}
void dj(int s,int t)
{
	fill(d,d+MAXN,-1);
	int mi=s;
	vis[s]=1;
	d[s]=0.0;
	while(1)
	{
		int k=mi;
		mi=-1;
		if(k==t)
			break;
		vis[k]=1;
		for(int i=1;i<=n+2;i++)
		{
			if(vis[i])
				continue;
			long double o=jl(k,i);
			if((d[i]==-1)||d[k]+o<d[i])
			{
				d[i]=d[k]+o;
			}
			if(d[i]!=-1&&(mi==-1||d[mi]>d[i]))
				mi=i;
		}
	}
}
int main()
{
	scanf("%Lf %Lf %Lf %Lf",&S[0],&S[1],&E[0],&E[1]);
	scanf("%d",&n);
	C[1].x=S[0];
	C[1].y=S[1];
	C[1].r=0;
	C[n+2].x=E[0];
	C[n+2].y=E[1];
	C[n+2].r=0;
	for(int i=2;i<=n+1;i++)
	{
		scanf("%Lf %Lf %Lf",&C[i].x,&C[i].y,&C[i].r);
	}
	dj(1,n+2);
	cout<<setiosflags(ios::fixed)<<setprecision(10)<<d[n+2];
}

Measured memory_bytes: 384
n = int(input())

c, s, f = [], [], []
for _ in range(n-1):
    x,y,z = map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)

anss =[]
for i in range(n-1):
    tmp = 0
    for j in range(i, n-1):
        k = 0
        while 1:
            if tmp <= s[j] + f[j] * k:
                tmp = s[j] + f[j] * k + c[j]
                break
            else:
                k += 1
    else:
        anss.append(tmp)
else:
    anss += [0]

for ans in anss:
    print(ans)

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

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < N+1-i; j++) {
      int k = N - i - j;
      if (10000 * i + 5000 * j + 1000 * k == Y) {
        cout << i << ' ' << j << ' ' << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

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

using namespace std;

int main()
{
    int i,j,k,n,m,x=0,y=0,z;
    string s;
    char ch;
    char ss[100000];
    cin>>n;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]==s[i+1])
        {
            x++;
            y=0;
            for(j=i;j<n;j++)
            {
                if(s[j]==s[j+1])
                {
                    y++;

                }
                else
                {
                    i=i+y;
                    break;
                }
            }
        }
        else
        {
            x++;
        }
    }
    cout<<x<<endl;
}


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

int main() {

   ios_base::sync_with_stdio(0);
   cin.tie(0); 
   // l + b + h = k
   // l * b * h
   int k;
   cin >> k;
   double a = k / 3.0;
   cout << fixed << setprecision(10) << endl;
   cout << a * a * a << endl;
   return 0;
}

Measured memory_bytes: 256
import sys


N,P = map(int,input().split())
S = list(input())

A = [0]*(N)
A[-1] = int(S[-1])
A[-1] %= P
base = 10 % P
for i in reversed(range(N-1)):
    A[i] = A[i+1] + base*int(S[i])
    A[i] %= P
    base *= 10
    base %= P


ans = 0
if P==2 or P==5:
    for i in reversed(range(N)):
        if int(S[i])%P==0:
            ans += i+1
else:
    nums = {}
    for a in A:
        if not (a in nums):
            nums[a] = 1
        else:
            nums[a] += 1
    
    for n in nums.keys():
        k = nums[n]
        if n==0:
            ans += k*(k+1)//2
        else:
            ans += k*(k-1)//2
    
print(ans)    



Measured memory_bytes: 13088
from collections import Counter
s = str(input())

si = [0] * (len(s)+1) #mod2019の累積和用に
tmp = 0
for i in range(1,len(s)+1): #累積和の作成
    tmp += int(s[len(s)-i])%2019 * pow(10,i-1,2019)
    si[i] = tmp % 2019

c = Counter(si)
ans = 0
for b in list(c.values()):#aがb回出てきたよ
    ans += b*(b-1)//2

print(ans)


Measured memory_bytes: 16720
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
 int n;
 cin >> n;
 vector<ll> a(n);
 rep(i,n)cin >> a.at(i);
 ll ans=0;
 rep(i,n-1){
   if(a.at(i)>a.at(i+1)){
     ans+=a.at(i)-a.at(i+1);
     a.at(i+1)=a.at(i);
   }
 }
  cout << ans << endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  vector<int> ans;
  vector<P> ina;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a>1)ans.pb(i);
    if(a<0)ina.pb(P(a,i));
  }
  
  sort(all(ina));
  for(int i=0;i+1<ina.size();i+=2){
    if(ina[i].fi==-1)break;
    ans.pb(ina[i].se);
    ans.pb(ina[i+1].se);
  }

  sort(all(ans));
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[1001][1001];
char arr[1001][1001];
#define m 1000000007

ll np(ll n,ll w)
{
    if(n<1||w<1)
    {
        return 0;
    }
    else if(dp[n][w]!=-1)
    {
        return dp[n][w];
    }
    else
    {
        dp[n][w]=(np(n-1,w)%m+np(n,w-1)%m)%m;
        return dp[n][w];
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll h,w;
	cin>>h>>w;
	
	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    {
	        cin>>arr[i][j];
	    }
	}
	
	for(ll i=1;i<=h;i++)
	{
	    for(ll j=1;j<=w;j++)
	    {
	        if(arr[i][j]=='#')
	        {
	            dp[i][j]=0;
	        }
	        else {dp[i][j]=-1;}
	    }
	}
	
	dp[1][1]=1;
	
	ll x=np(h,w);
	cout<<x<<"\n";
}


Measured memory_bytes: 9216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num_max(p,q)((p)>(q)?(p):(q))
#define num_min(p,q)((p)<(q)?(p):(q))
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
	 //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int r;
	scanf("%d", &r);
	printf("%d", r*r);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var abc = Input.twodim(num);
        var dp = new long[num + 1, 3];
        for (var i = 1; i <= num; i++)
            for (var j = 0; j < 3; j++)
                dp[i, j] = int.MaxValue;
        for (var i = 1; i <= num; i++)
            for (var j = 0; j < 3; j++)
                dp[i, j] = abc[i - 1][j] + Max(dp[i - 1, (j + 1) % 3], dp[i - 1, (j + 2) % 3]);
        WriteLine(Max(Max(dp[num, 0], dp[num, 1]), dp[num, 2]));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 29116
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;

double fpx(double a, double b, double c, double d, double e, double f);
double fpy(double a, double b, double c, double d, double e, double f);
double  fr(double a, double b, double c, double d);
string toStr(double a);
string intToString(int a);

int main() {
  int n;
  double x1, y1, x2, y2, x3, y3;

  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double px = fpx(x1, y1, x2, y2, x3, y3);
    double py = fpy(x1, y1, x2, y2, x3, y3);
    double  r =  fr(x1, y1, px, py);

    cout << toStr(px) << " " << toStr(py) << " " << toStr(r) << endl;
  }
}


double fpx(double x1, double y1, double x2, double y2, double x3, double y3) {
  double a1, a2, b1, b2, c1, c2;

  a1 = 2 * (x2 - x1);
  b1 = 2 * (y2 - y1);
  c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;

  a2 = 2 * (x3 - x1);
  b2 = 2 * (y3 - y1);
  c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

  return (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
}

double fpy(double x1, double y1, double x2, double y2, double x3, double y3) {
  double a1, a2, b1, b2, c1, c2;

  a1 = 2 * (x2 - x1);
  b1 = 2 * (y2 - y1);
  c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;

  a2 = 2 * (x3 - x1);
  b2 = 2 * (y3 - y1);
  c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

  return (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
}

double fr(double x1, double y1, double x2, double y2) {
  return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

string toStr(double d) {
  string pm = "", val = "";
  if (d < 0) {
    pm = "-";
    d = -d;
  }

  int ipart = (int)d;
  int fpart = (int)( (d - (double)ipart) * 10000) + 10005;

  val = pm + intToString(ipart) + "." + intToString(fpart).substr(1, 3);
  return val;
}

string intToString(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e18;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int x,n=100009;
	cin >> x;
	int a[n]={0};
	for(int i=2;i<n;i++){
		if(a[i])continue;
		for(int j=i*i;j<n;j+=i)
			a[j]=1;
	}
	a[0]=1,a[1]=1;
	for(int i=2;i<n;i++){
		if(i>=x and a[i]==0){
			cout << i;
			break;
		}
	}
}


Measured memory_bytes: 1024
int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
#include<stdlib.h>
#include<stdio.h>
int main(void)
{
    long int n,a[200001],i;
    scanf("%ld",&n);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%ld",&a[i]);
    }
    int j;
    qsort(a, n, sizeof(long), cmpnum);
    for(i = 0 ; i < n - 1 ; i++ )
    {
        if(a[i] == a[i+1])
        {
            printf("NO\n");
            return 0 ;
        }
    }
    printf("YES\n");
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i,s.size()){
		if(s[i] == 'R') ans++;
	}
	if(ans == 2 && s == "RSR") ans = 1;
	cout << ans << endl;
    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint k,s; cin >> k >> s;

  lint ans=0;

  for(lint x=0;x<=k;x++) {
    for(lint y=0;y<=k;y++) {
      lint z=s-x-y;
      if(0 <= z && z <= k) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(void){
    int n,m; cin>>n>>m;
    vector <long long> ans(n,INF);
    vector <int> finalanswer(n);
    vector <pair <int,int>> s(n);
    vector <pair<int,int>> p(m);
    for(int i=0;i<n;i++){
        int a,b;  cin>>a>>b;
        s[i]=make_pair(a,b);
    }
    for(int i=0;i<m;i++){
        int c,d ; cin>>c>>d;
        p[i]=make_pair(c,d);
        //cout<<c<<' ' <<d<<endl;
        //cout<<p[i].first<<endl;
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            //cout<<p[j].first<<endl;
            if(ans[i]> abs(s[i].first - p[j].first)+abs(s[i].second - p[j].second) ){
                
            ans[i]= abs(s[i].first - p[j].first)+abs(s[i].second - p[j].second);
            //cout<<ans[i]<<endl;
            finalanswer[i]= j +1;
            }
        }
    }
    //cout<<s[0].first<< '-' <<p[0].first<<endl;
    //cout<< abs(s[0].first - p[0].first)<<endl;
    for(int i=0;i<n;i++){
        
        cout<<finalanswer[i]<<endl;
    }
}

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

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 1, sum = 0;
  for (int i = 0; i < n; ++i) sum += a[i];
  for (int i = n - 2; i >= 0; --i) {
    sum -= a[i + 1];
    if (sum * 2 < a[i + 1]) break;
    ++res;
  }
  return res;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    ii(n); vector<lint> v(n);
    rep(i, n) cin >> v[i];
    lint m = 2, M = 2;
    repr(i, n){
        m = (m+v[i]-1) / v[i] * v[i];
        M = (M/v[i]+1) * v[i] - 1;
        if(m > M || M <= 0){
            out(-1); return 0;
        }
    }
    cout << m << " " << M << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string S,T; cin >>S >>T;
  T.pop_back();
  cout <<(S==T ? "Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int ac[100000] = {};
  int penalties[100000] = {};
  int penalty = 0;
  int corrects = 0;
  for (int i = 0; i < M; ++i) {
    int p;
    char s,_;
    scanf("%d %c%c\n", &p, &s, &_);
    if (ac[p - 1]) continue;
    if (s=='W') penalties[p-1] += 1;
    else {
      corrects += 1;
      penalty += penalties[p-1];
      ac[p - 1]=1;
    }
  }
  printf("%d %d\n", corrects, penalty);
}

Measured memory_bytes: 896
#include <iostream>

bool isSame(int* a, int* b, int n)
{
	for (int i=0; i<n; i++) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

void copy(int *a, int *b, int n)
{
	for (int i=0; i<n; i++) {
		a[i] = b[i];
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		
		int* s = new int[n];
		
		for (int i=0; i<n; i++) {
			std::cin >> s[i];
		}
		
		int* c = new int[n];
		int op_count = 0;
		
		while (true) {
			for (int i=0; i<n; i++) {
				int appearance = 0;
				for (int j=0; j<n; j++) {
					if (s[i] == s[j]) appearance++;
				}
				c[i] = appearance;
			}
			if (isSame(s,c,n)) break;
			copy(s,c,n);
			op_count++;
		}
		
		std::cout << op_count << std::endl;
		for (int i=0; i<n; i++) {
			if (i==0) std::cout << c[i];
			else std::cout << " " << c[i];
		}
		std::cout << std::endl;
		
		delete[] s;
		delete[] c;
	}
	
	return 0;
}




Measured memory_bytes: 3016
a = int(input())
b = int(input())
c = int(input())
d = int(input())
count =0

for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if (i*500+100*j+50*k==d):
				count = count + 1
	
print(count)
		

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> roop(n+1);
    for(int i = 0; i < n; i++) {
        cin >> a.at(i);
        a.at(i)--;
    }
    roop.at(0) = 0;//後で町を１インデックスに
  vector<int> num(n,0);
  num.at(0) = 0;
  int roopsn;
    int roops;//ループの終わり
    int roope;//ループの始まり
    for(int i = 1; i < n+1; i++) {
        roop.at(i) = a.at(roop.at(i-1));
      if(num.at(roop.at(i)) == 0) num.at(roop.at(i)) = 1;
      else {
            roope = i - 1;
            roopsn = roop.at(i);
            break;
      }
      
    }
    int l = 0;
    while(true) {
        if(roop.at(l) == roopsn) {
            roops = l;
            break;
        }
        l++;
    }
    if(k <= roope) cout << roop.at(k) + 1;
    else {
      long long div = k%(roope-roops+1);
      int divs = roops%(roope-roops+1);
      if(div - divs >= 0) {
        cout << roop.at(roops + div-divs) + 1;
    }
      else cout << roop.at(div-divs + roope +1) +1;
}
}

Measured memory_bytes: 5584
#include<iostream>//动态规划剪枝是么从dp0开始
#include<cmath>
#include<algorithm>
#include<string>//stl和数据结构应该一起训练
#include<memory.h>
using namespace std;
int dp[100001];
int n;

int main()
{
	int a;
	cin>>n;
	int len=0;//len不能初始化为0
	for(int i=1;i<=n;i++)
	{	
		cin>>a;
		if(i==1)
		{
			len=1;
			dp[0]=a;
			continue;
		}
		if(a>dp[len-1])//只出现a[i]等价于a,数组越界了到了-1坑爹。。
		dp[len++]=a;
		else
			*lower_bound(dp,dp+len,a)=a;//确定位置，就是一种最优化想法
	}
	cout<<len<<endl;
	return 0;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
 
using namespace std;
 
constexpr int INF = (1 << 29);
 
int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> a(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        int res = INF;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                res = min(res, abs(a[i] - a[j]));
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3028
import java.util.Arrays;
import java.util.Scanner;

//Sum of Consecutive prime Numbers
public class Main{

	void run(){
		int N = 10000;
		boolean[] p = new boolean[N+1];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		int[] s = new int[1229];
		int x = 0;
		for(int i=2;i<=N;i++)if(p[i]){
			s[x++] = i;
			for(int j=i+i;j<=N;j+=i)p[j]=false;
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int res = 0;
			for(int i=0;i<1229;i++){
				int sum = s[i];
				int j = i+1;
				while(sum<n&&j<1229){
					sum+=s[j++];
				}
				if(sum==n)res++;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define ll long long

string s;
bool ok=1;

int main()
{
//    freopen("a.in","r",stdin);
    cin>>s;
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            ok=0;
    }
    for(int i=0;i<n/4;i++)
    {
        if(s[i]!=s[n/2-1-i])
            ok=0;
    }
    cout<<(ok?"Yes":"No");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
const int mod=1e9+7;
#define N 1000005 
ll dp[N][4];
int n;
int main(){
	std::cin>>n;
	dp[0][0]=1;
	rep(i,1,n){
		rep(j,0,9){
			rep(k,0,3){
				int ty=k;
				if(j==0) ty|=1;
				if(j==9) ty|=2;
				(dp[i][ty]+=dp[i-1][k])%=mod;
			}
		}
	}
	std::cout<<dp[n][3]<<'\n';
	return 0;
}

Measured memory_bytes: 34868
def dist(n):
  if n==0:
    return 0
  if n==1:
    return d
  if n in memo:
    return memo[n]
  
  res=min(
    d*n,
    d*abs(n-n//5*5)+c+dist(n//5),
    d*abs(n-(n+4)//5*5)+c+dist((n+4)//5),
    d*abs(n-n//3*3)+b+dist(n//3),
    d*abs(n-(n+2)//3*3)+b+dist((n+2)//3),
    d*abs(n-n//2*2)+a+dist(n//2),
    d*abs(n-(n+1)//2*2)+a+dist((n+1)//2)
  )
  memo[n]=res
  return res

T=int(input())
for _ in range(T):
  n,a,b,c,d=map(int,input().split())
  memo={}
  print(dist(n))



Measured memory_bytes: 10732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m != 0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}

int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	a.push_back(x);
	sort(a.begin(), a.end(),greater<ll>());
	ll ans = 0;
	rep(i, n) {
		ans = gcd(a[i] - a[i + 1],ans);//0とaとのの最大公約数はa
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n,k=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
dic={}
for i in range(n):
    dic[a[i]]=dic.get(a[i],0)+1
count=list(dic.values())
count.sort(reverse=True)
if len(count) <= k:
    print(0)
else:
    print(sum(count[k:]))

Measured memory_bytes: 32184
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c;cin>>a>>b>>c;
  vector<pair<double,ll>>d(a);
  rep(i,a){
    ll e;cin>>e;
    d[i].first=fabs(c-(b-e*0.006));
    d[i].second=i+1;
  }
  sort(d.begin(),d.end());
  cout<<d[0].second;
}



Measured memory_bytes: 27000
#include <iostream>

using namespace std;

int main()
{
    int n,c1=0,c2=0,c3=0,c4=0;
    string s;
    cin>>n;
    while(n>0){
     cin>>s;
     if(s=="AC"){
        c1++;
     }
     else if(s=="WA"){
       c2++;
     }
     else if(s=="TLE"){
       c3++;
     }
       else if(s=="RE"){
       c4++;
     }
        n--;
    }
    cout<<"AC"<<" x "<<c1<<endl;
    cout<<"WA"<<" x "<<c2<<endl;
    cout<<"TLE"<<" x "<<c3<<endl;
    cout<<"RE"<<" x "<<c4<<endl;
    return 0;
}


Measured memory_bytes: 3616
N=int(input())
s=input()
t=input()
common=0

for start in range(N):
    point=0
    check=False
    for i in range(start,N):
        if s[i] != t[point]:
            check=True
            break
        point+=1
    if not check:
        common=N-start
        break

print(len(s)+len(t)-common)

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
void solve() {
int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << (ab * bc) / 2 << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  rep1(i,9)rep1(j,9){
  if(i*j==a){   
    cout<<"Yes";
    return 0;
  }
   
  }
  
  cout<<"No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int A = scanner.nextInt();
 		int B = scanner.nextInt();
 		int n = A * 4;
 		int m = (n - B) / 2;
 		int l = (n - B) % 2;
 		if (l == 0) {
 			if (m <= A && m >= 0) {
 				System.out.println("Yes");
 			} else {
 				System.out.println("No");
 			}
 		} else {
 			System.out.println("No");
 		}
 	}
 }

Measured memory_bytes: 35780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
 
                for(int row = 1; row <= H-2; row++){
                    System.out.printf("#");
                    for(int col = 1; col <= W-2; col++){
                        System.out.printf(".");
                    }
                    System.out.printf("#\n");
                }
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n\n");
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 55516
while vals = gets.split(' ')
  a = vals[0].to_i
  b = vals[2].to_i
  case vals[1]
  when '?' then
    break
  when '+' then
    puts a + b
  when '-' then
    puts a - b
  when '*' then
    puts a * b
  when '/' then
    puts a / b
  end 
end


Measured memory_bytes: 6872
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <regex>

using namespace std;

int main()
{
  string deck;
  while (cin >> deck, deck != "-") {
    int m;
    cin >> m;
    for (int sh = 0; sh < m; ++sh) {
      // put deck[0:m) on the back of deck
      int shamt;
      cin >> shamt;
      auto front = deck.substr(0, shamt);
      auto back  = deck.substr(shamt, deck.size() - shamt); 
      deck = back + front;
    }
    cout << deck << endl;
  }
}


Measured memory_bytes: 3132
class Solution:
    def solve(self, D: int, N: int) -> int:

        if N == 100:
            return (N+1) * (100**D)
        else:
            return N * (100**D)


if __name__ == '__main__':

    # standard input
    D, N = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(D, N))
    

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

int main( void )
{
    int a, b, x;
    cin >> a >> b >> x;
    if ( a <= x && ( a + b ) >= x )
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int count = 0;
	for (int i = 0; i < h * w; i++) {
		char c;
		cin >> c;
		if (c == '#') {
			count++;
		}
	}
	if (count == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}



Measured memory_bytes: 256