akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll 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;
}

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) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

template<typename T,typename Y>
struct Rerooting{

	using F =function<T(T,T)>;
	using G =function<T(T,Y)>;

	vector<vector<int>>g;
	vector<vector<T>>dp;
	vector<T>ans;
	const F merge;
	const G add_root;
	const T identity;

	Rerooting(int n,const F &merge,const G &add_root,const T &identity):merge(merge),add_root(add_root),identity(identity){
		g.resize(n);
		dp.resize(n);
		ans.resize(n,identity);
	}

	void add_edge(int u,int v){
		g[u].emplace_back(v);
	}

	void build(int root=0){
		dfs1(root);
		dfs2(root,identity);
	}

	T dfs1(int v,int par=-1){
		T cul = identity;
		dp[v].resize(g[v].size(),identity);
		for(int i=0;i<g[v].size();++i){
			int u =g[v][i];
			if(u==par)continue;
			dp[v][i]=dfs1(u,v);
			cul=merge(cul,dp[v][i]);
		}
		return add_root(cul,v);
	}

	void dfs2(int v,const T &val ,int par=-1){
		for(int i=0;i<g[v].size();++i){
			if(g[v][i]==par){
				dp[v][i]=val;
			}
		}
		vector<T>dp_l(g[v].size()+1,identity),dp_r(g[v].size()+1,identity);
		for(int i=0;i<g[v].size();++i){
			dp_l[i+1]=merge(dp_l[i],dp[v][i]);
		}
		for(int i=g[v].size()-1;i>=0;--i){
			dp_r[i]=merge(dp_r[i+1],dp[v][i]);
		}

		ans[v]=dp_l[g[v].size()];

		for(int i=0;i<g[v].size();++i){
			int u=g[v][i];
			if(u==par)continue;
			dfs2(u,add_root(merge(dp_l[i],dp_r[i+1]),v),v);
		}
	}
};

void solve()
{
	int n,m;
	cin>>n>>m;
	Rerooting<ll,ll>tree(n,[&](ll a,ll b){return a*b%m;},[&](ll a,ll b){return a+1;},1);
	rep(i,n-1){
		int x,y;
		cin>>x>>y;
		x--;y--;
		tree.add_edge(x,y);
		tree.add_edge(y,x);
	}
	tree.build();
	rep(i,n)cout<<tree.ans[i]<<"\n";
}

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


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

int main() {
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i+=2){
  int c=0;
  for(int j=1;j<=n;j++){
    if(i%j==0)c++;
  }
  if(c==8) ans++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;
const int mod=1e9+7;

const int N=2e5+100;

int qpow(int x,int y) {
	int ans=1;
	while (y) {
		if (y&1) ans=1LL*ans*x%mod;
		x=1LL*x*x%mod;y>>=1;
	}
	return ans;
}

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

namespace io {
	const int L=(1<<21)+1;
	char ibuf[L],*iS,*iT,obuf[L],*oS=obuf,*oT=obuf+L-1,c,st[55];int f,tp;
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,L,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush() {
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	inline void putc(char x) { *oS++=x; if (oS==oT) flush(); }
	template<class I> inline void gi(I&x) {
		for (f=1,c=gc();c<'0'||c>'9';c=gc()) if (c=='-') f=-1;
		for (x=0;c<='9'&&c>='0';c=gc()) x=x*10+(c&15); x*=f;
	}
	template<class I> inline void print(I x) {
		if (!x) putc('0');
		if (x<0) putc('-'),x=-x;
		while (x) st[++tp]=x%10+'0',x/=10;
		while (tp) putc(st[tp--]);
	}
	inline void gs(char*s, int&l) {
		for (c=gc();c<'a'||c>'z';c=gc());
		for (l=0;c<='z'&&c>='a';c=gc()) s[l++]=c;
		s[l]=0;
	}
	inline void ps(const char*s) { for (int i=0,n=strlen(s);i<n;i++) putc(s[i]); }
	struct IOFLUSHER{ ~IOFLUSHER() { flush(); } } _ioflusher_;
};
using io::putc;
using io::gi;
using io::gs;
using io::ps;
using io::print;

int a[N];
int main()
{
	LL ans=0;
	int n,i;
	gi(n);
	for (i=1;i<=n;i++) gi(a[i]);
	for (i=n;i;i--)
		if (a[i]!=a[i+1]-1) {
			if (a[i+1]-a[i]>1||a[i]>=i) {
				print(-1);
				return 0;
			}
			ans+=a[i];
		}
	print(ans);
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;

#define int long long
const int N = 1e5 + 9;
int x, n, m, s, ans;
map<int, int> mp;
main(){
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &x);
		x %= m;
		s += x;
		s %= m;
		ans += mp[s];
		mp[s]++;
		if (!s)
			ans++;
	}
	cout << ans << endl;


}

Measured memory_bytes: 4224
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        mut a_vec: [usize; n],
        mut b_vec: [usize; n],
        mut c_vec: [usize; n],
    }

    // max n ^ 3

    a_vec.sort();
    b_vec.sort();
    c_vec.sort();
    // dbg!(&a_vec, &b_vec, &c_vec);
    let mut cnt = 0;

    for b in b_vec.iter() {
        let a_idx = a_vec.lower_bound(b);
        let c_idx = c_vec.upper_bound(b);
        // dbg!(a_idx, c_idx);
        cnt += a_idx * (n - c_idx)
    }
    println!("{}", cnt);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 7764
// ref. https://img.atcoder.jp/agc020/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll f(ll x, ll a) {
  return x - (x%a);
}

// return true if n can be result in 2 or smaller.
bool checkSmall(vector<ll>& a, ll n) {
  ll now = n;
  rep(i, a.size()) {
    now = f(now, a[i]);
  }
  return now <= 2;
}

// return true if n can be result in 2 or larger.
bool checkLarge(vector<ll>& a, ll n) {
  ll now = n;
  rep(i, a.size()) {
    now = f(now, a[i]);
  }
  return now >= 2;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll k;
  cin >> k;
  vector<ll> a(k);
  rep(i, k) {
    cin >> a[i];
  }

  // l[i] = [ l[i+1]/a[i] ] * a[i]
  // r[i] = [ r[i+1]/a[i] ] * a[i] + a[i] - 1.

  // l[i]/a[i] = [ l[i+1]/a[i] ]
  // r[i]/a[i] = [ r[i+1]/a[i] ]
  vector<ll> l(k+1); // l[i+1] .. minimum possible number after i.
  vector<ll> r(k+1); // r[i+1] .. maximum possible number after i.
  l[k] = 2;
  r[k] = 2;
  for (int i = k-1; i >= 0; --i) {
    l[i] = ((l[i+1]+a[i]-1) / a[i]) * a[i];
    r[i] = (r[i+1] / a[i]) * a[i] + a[i] - 1;
  }
  // cout << "l: "; printvec(l);
  // cout << "r: "; printvec(r);

  if (l[0] > r[0]) { // invalid
    cout << -1 << endl;
  } else {
    cout << l[0] << " " << r[0] << endl;
  }
}


Measured memory_bytes: 2560
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, C, X;
  cin >> A >> B >> C >> X;

  ll ans = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (i * 500 + j * 100 + k * 50 == X) ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int r,c,a[101][101]={0},i,j;

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




Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <utility>

int main()
{
    int N, K;
    std::cin >> N >> K;
    if(K > (N-1)*(N-2)/2){
        std::cout << -1 << std::endl;
        return 0;
    }
    std::vector<std::pair<int, int> > edge;
    for(int i=2; i<=N; i++) edge.emplace_back(1, i);
    int count = (N-1)*(N-2)/2 - K;
    for(int i=2; i<N; i++){
        for(int j=i+1; j<=N; j++){
            if(count <= 0) break;
            count--;
            edge.emplace_back(i, j);
        }
        if(count <= 0) break;
    }
    std::cout << edge.size() << std::endl;
    for(auto &&itr = edge.begin(); itr != edge.end(); itr++)
        printf("%d %d\n", itr->first, itr->second);
}

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

int main(void){
    std::string s, t;

    std::cin >> s >> t;

    int c = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == t[i]){
            ++c;
        }
    }
    std::cout << c << std::flush;
    return 0;
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 510, M = 35;

int n, m;
int f[M][M];
int c[3][M];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= m; j ++ )
			cin >> f[i][j];
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
		{
			int x;
			cin >> x;
			c[(i + j) % 3][x] ++ ;
		}
	
	int res = 0x3f3f3f3f;
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= m; j ++ )
			for (int k = 1; k <= m; k ++ )
				if (i == j || j == k || i == k) continue;
				else
				{
					int sum = 0;
					for (int v = 1; v <= m; v ++ )
					{
						sum += c[0][v] * f[v][i];
						sum += c[1][v] * f[v][j];
						sum += c[2][v] * f[v][k];
					}
					res = min(res, sum);
				}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>
#include <chrono>
#include <random>

using namespace std;
using ll = long long;
using ld = long double;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trav(x) for(auto& i: x)
#define sz(s) ((int)s.size())

int n, a, b;

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

	cin >> n >> a >> b;
	cout << min(n * a, b);
}

Measured memory_bytes: 256
def main():
  n = int(input())
  if n == 0:
    print('0')
    return

  bi = [0]*2 + list(map(int, bin(abs(n))[2:]))

  posi = True if n > 0 else False
  for i in range(len(bi))[::-1]:
    if bi[i] == 2:
      bi[i] = 0
      bi[i-1] += 1
    elif not posi and bi[i] == 1:
      bi[i-1] += 1
    posi ^= True
  print(''.join(map(str, bi)).lstrip('0'))
  return

main()

Measured memory_bytes: 3064
#include <stdio.h>
 
int sumOfDecimal(int n)
{
	int ret = 0;
	while(n != 0) { 
		ret += n % 10;
		n /= 10;
	}
 
	return ret;
}
 
int main(void)
{
	int N, A, B;
	int ans = 0;
  	int i;
  
	scanf("%d %d %d", &N, &A, &B);
	for(i = 1; i <= N; i++) {
		int tmp = sumOfDecimal(i);
		if(tmp >= A && tmp <= B) {
			ans += i;
		}
	}
 
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		if(a>=13)
		System.out.println(b);
		else {
			if(a>5)
			System.out.println(b/2);
			else {
				System.out.println(0);
			}
		}
	}

}


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

int main() {
    int N, K;
    cin >> N >> K;
    int p[N];
    rep(i, N) cin >> p[i];
    sort(p, p + N);
    cout << (accumulate(p, p + K, 0)) << endl;
}

Measured memory_bytes: 3648
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>

namespace adaptor = boost::adaptors;

bool run(std::map<int, int>const& count, int N)
{
	if (count.size() > 3)
	{
		return false;
	}
	std::vector<int> vals;
	for (auto&& p : count)
	{
		vals.emplace_back(p.first);
	}
	if (vals.size() == 1)
	{
		return vals[0] == 0;
	}
	else if (vals.size() == 2)
	{
		if (vals[0] == 0)
		{
			return 2 * count.at(vals[0]) == count.at(vals[1]);
		}
		else
		{
			return false;
		}
	}
	else
	{
		if (N % 3 != 0)
		{
			return false;
		}
		if ((vals[0] ^ vals[1]) == vals[2])
		{
			return count.at(vals[0]) == count.at(vals[1]) && count.at(vals[1]) == count.at(vals[2]);
		}
		return false;
	}
}

void Main()
{
	int N;
	std::cin >> N;
	std::map<int, int> count;
	for (auto i : boost::irange(0, N))
	{
		int v;
		std::cin >> v;
		++count[v];
	}
	if (run(count, N))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" " ;
#define pb(x) push_back(x)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int main()
{

	
	ll a,b;
	cin>>a>>b;
	ll mid=(a+b)/2;
	if(mid-a==b-mid){
		cout<<mid<<endl;
	}
	else cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int ans = N;
            int sopo = 0;
            int koti = 0;
            
            for(int i = 1; i < N; i++)
            {
                if (S[i] == 'W') koti++;
                else sopo++;
            }

            ans = sopo;

            for(int i = 1; i < N; i++)
            {
                if (S[i] == 'E') sopo--;
                else koti--;
                if (S[i - 1] == 'E') koti++;
                else sopo++;
                if (ans > sopo) ans = sopo;                
            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13156
#include<bits/stdc++.h>
using namespace std;
long long n,a[110],ans;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for (int i=0;i<n;i++)
		for (int j=i+1;j<n;j++)
			for (int k=j+1;k<n;k++)
				if (a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
					ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  	int K, X;
  	cin>>K>>X;
  	 int a=X-K+1;
  		while((X-a)<K&&(a-X)<K){ cout<<a<<' ';
                                
                       a=a+1;
                                
                      }
  		
  
  	
}

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

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

	if((a+b)>(c+d))
		printf("Left");
	else if((a + b)<(c + d))
		printf("Right"); 
	else if ((a + b)==(c + d))
		printf("Balanced");

	return 0;
}

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


int main() {

    ll k,a,b; cin >> k >> a >> b;
    ll d = b-a;
    if(k < a-1){
        cout << k + 1;
    } else if(d >= 2){
        cout << b + ((k-(a-1))/2 - 1)*(b-a) + (k-(a-1))%2;
    }else{
        cout << k + 1;
    }


    return 0;
}











Measured memory_bytes: 3544
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(cnt, fld)
  check = 8.times.map{ [false] * 14 }
  res = 0
  (1..6).each do |i|
    (1..12).each do |j|
      if !check[i][j] && fld[i][j] =~ /[^O.]/
        puyo_connector(i, j,fld){ |arr|
          if arr.size >= 4
            arr.each do |s, t|
              D.each do |x, y|
                p, q = s + x, t + y
                check[p][q] = true if fld[p][q] == 'O'
              end
              check[s][t] = true
            end
            res = 1
          end
        }
      end
    end
  end
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless check[i][j] }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  if res == 1 then puyo_rensa(cnt + 1, fld)
  else cnt
  end
end

def puyo_connector(i, j, fld)
  check = 8.times.map{ [false] * 14 }
  arr = [[i, j]]
  ret = [[i, j]]
  check[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !check[p][q] && fld[i][j] == fld[p][q]
        check[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret)
end

gets.to_i.times do
  fld = 8.times.map{ ['.'] * 14 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[j+1][i+1] = c
    end
  end
  p puyo_rensa(0, fld)
end

Measured memory_bytes: 9640
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  s=input()
  if s=="AC":
    ac+=1
  if s=="WA":
    wa+=1
  if s=="TLE":
    tle+=1
  if s=="RE":
    re+=1
print("AC","x",str(ac))
print("WA","x",str(wa))
print("TLE","x",str(tle))
print("RE","x",str(re))

    

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


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

    // 木の初期化
    vector<pair<vector<int>, int>> T(n);
    rep(i,n) {
        T[i].first = vector<int>();
        T[i].second = 0;
    }

    // 木の構成
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        T[a].first.push_back(b);
        T[b].first.push_back(a);
    }

    int parrent[n];
    rep(i,n) parrent[i] = -1;
    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int x  = que.front(); que.pop();
        for (auto c : T[x].first) {
            if (c == parrent[x]) continue;
            parrent[c] = x;
            que.push(c);
        }
    }

    rep(i,q) {
        int p, x;
        cin >> p >> x;
        p--;
        T[p].second += x;

    }

    ll score[n];
    rep(i,n) score[i] = 0;
    score[0] = T[0].second;
    queue<int> sque;
    sque.push(0);
    while(!sque.empty()) {
        int x = sque.front(); sque.pop();
        for (auto c : T[x].first) {
            if (c == parrent[x]) continue;
            score[c] = T[c].second + score[x];
            sque.push(c);
        }
    }

    rep(i,n) {
        printf("%lld%c", score[i], i==n-1? '\n' : ' ');
    }

    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  bool ok = true;
  rep(i, n) {
    ll x;
    cin >> x;
    if (x % 2 == 0) {
      bool ng = !(x % 3 == 0 || x % 5 == 0);
      if (ng) {
        ok = false;
        break;
      }
    }
  }
  string ans = ok ? "APPROVED" : "DENIED";
  cout << ans << endl;
}


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

int main(void){
  int n,ans;
  cin >> n;
  
  ans = 0;
  for (int i=0; i<=n; i+=7){
    if ((n-i)%4==0) ans = 1;
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    map<string,ll> m;
    vector<ll> b;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        m[s]++;
    }
    for(auto x:m){
        b.pb(x.second);
    }
    sort(b.begin(),b.end(),greater<ll>());
    for(auto x:m){
        if(x.second == b[0]){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 26868
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    int K;
    cin >> n >> K;

    auto count = [&](int n, int m, int r) {
        if (r == 0) {
            return n;
        }
        ++n;
        int res = (n / m) * r;
        int rem = n % m;
        res += min(rem, r);
        res = n - res;
        // cout << n << " " << m << " " << r << " " << res << endl;
        return res;
    };

    long long res = 0;
    for (int i = K + 1; i <= n; ++i) {
        res += count(n, i, K);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

signed main()
{
    ll n, x;
    cin >> n >> x;
    
    ll ans = n;
    
    ll a = x;
    ll b = n-x;
    
    while(b){
        if(a>b) swap(a, b);
        ans += 2*(b/a)*a;
        b %= a;
    }
    ans -= a;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
alist = list(map(int, input().split()))

mlist=[0]*n
nlist=[0]*n

for i in range(n):
    for j in range(n):
        if alist[i]>alist[j] and i>j:
            mlist[i]+=1
        elif alist[i]>alist[j] and i<j:
            nlist[i]+=1

#print(mlist, nlist)
kotae=0
for i in range(n):
    if k%2==1:
        a1=k*int((k+1)/2)
        a2=k*int((k-1)/2)
    else:
        a1=int(k/2)*(k+1)
        a2=int(k/2)*(k-1)
    kotae+=nlist[i]*a1
    kotae+=mlist[i]*a2
    kotae=kotae%(10**9+7)

print(kotae%(10**9+7))

Measured memory_bytes: 42204
#include<stdio.h>
int main()
{
    int n, k, x, y, sum=0, i;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    if(n<k)
    {
        for(i=1; i<=n; i++)
        {
            sum += x;
        }
    }
    else
    {
        for(i=1; i<=k; i++)
        {
            sum += x;
        }
        for( ; i<=n; i++)
        {
            sum += y;
        }
    }
    printf("%d\n", sum);
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;
  VLL a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;

  ll modSum[n+1];
  modSum[0] = 0;
  rep(i,n) modSum[i+1] = (a[i] + modSum[i]) % k;

  map<int,int> mp;
  ll ans = 0;
  queue<int> que;
  rep(i,n+1){
    ans += mp[modSum[i]];
    mp[modSum[i]]++;
    que.push(modSum[i]);
    if(que.size() == k){
      mp[que.front()]--;
      que.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a == b){
        printf("a == b\n");
    }else{
        printf("a < b\n");
    }

    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m;
  cin >> n >> m;
  vector<int> ok(n), cnt(n);
  for (int i = 0; i < m; ++i) {
    int p; cin >> p; --p;
    string s; cin >> s;
    if (ok[p]) continue;
    cnt[p] += s == "WA";
    ok[p] |= s == "AC";
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += ok[i] * cnt[i];
  }
  cout << accumulate(ALL(ok), 0) << " " << ans << '\n';
}


Measured memory_bytes: 1024
package main

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

var (
	n, k int
	h    []int
	ans  int
)

func main() {
	n = nextInt()
	k = nextInt()
	h = make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	sort.Ints(h)
	for i := 0; i < n-k; i++ {
		ans += h[i]
	}
	fmt.Println(ans)
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}


Measured memory_bytes: 5120
S = input()

alphabets = set(chr(ord('a')+x) for x in range(26))

bl1 = (S[0] == 'A')
bl2 = (S[2:-1].count('C') == 1)
bl3 = (set(S) - set('AC') <= alphabets)

answer = 'AC' if bl1 and bl2 and bl3 else 'WA'
print(answer)


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

int main() {
	int n;
	string s, t, ans;
	cin >> n;
	cin >> s >> t;

	for (int i = 0; i < n; i++) {
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 1e5 + 10;
ll cnt[MAX_N], arr[MAX_N], ans[MAX_N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
        sum ^= arr[i];
    }
    for(int i = 0; i < n; i ++) {
        cout << (sum ^ arr[i]) << " ";
    }
    return 0;
}




Measured memory_bytes: 5212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp9
{   
    class Program
    {
        public static void Main(string[] args) {
            long a = int.Parse(Console.ReadLine()), c = 0;
            long[] sss = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Array.Sort(sss);
            Console.Write("{0} {1} ", sss[0], sss[a - 1]);
            for (int b = 0; b < a; b++)
            {
                c = c + sss[b];

            }
            Console.WriteLine(c);

        }
    }
    }

Measured memory_bytes: 10844
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    ss = ['.'*(w+2)]
    for i in range(h):
        s = '.'+IS()+'.'
        ss.append(s)
    ss.append('.'*(w+2))
    flag = True
    for i in range(1, h+1):
        for j in range(1, w+1):
            if ss[i][j]=='#':
                if ss[i-1][j]=='#' or ss[i+1][j]=='#' or ss[i][j-1]=='#' or ss[i][j+1]=='#':
                    continue
                else:
                    flag = False
                    break
    if flag: print('Yes')
    else: print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <stack>
typedef long long ll;

int main(void) {
  ll i, j, k, n, m;
  scanf("%lld%lld", &n, &m);
  char s[n + 10];
  scanf("%s", s);
  std::stack<ll> ans;
  for(i = n; i; ) {
    for(j = m; j; --j) if(i >= j && s[i - j] == '0') {
      i = i - j;
      ans.push(j);
      break;
    }
    if(!j) {
      printf("-1");
      return 0;
    }
  }
  while(ans.size()) printf("%lld ", ans.top()), ans.pop();
  return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == t[i]){
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	int seq = 0;
	for (int i = 0; S[i] == '1' && i < S.length(); ++i) {
		++seq;
	}

	long long K;
	cin >> K;
	char res = S[0];
	if (seq > 0 && seq < K) {
		res = S[seq];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool loop(string s){
	if(SIZE(s)%2) return false;
	bool b=true;
	for(ll i=0;i<SIZE(s)/2;++i){
		if(s[i]!=s[(SIZE(s)+1)/2+i]) b=false;
	}
	return b;
}

int main()
{
	string s;
	cin >> s;
	while(SIZE(s)!=1){
		Eback(s);
		if(loop(s)) break;
	}
	cout << SIZE(s) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

struct point{
    int x,y;
};

struct line{
    point s,t;
};
struct bec{
    int x,y;
};
struct circle{
    point p;
    int r;
};

void solve(circle c1,circle c2){
    bec p;
    double dp,cost,sint,qx, qy,ansx1,ansx2,ansy1,ansy2,cosa,sina;
    p.x = c2.p.x-c1.p.x;
    p.y = c2.p.y-c1.p.y;

    dp = sqrt((double)p.x*(double)p.x+(double)p.y*(double)p.y);
    cost = p.x/dp;
    sint = p.y/dp;
    cosa = (-c2.r*c2.r+c1.r*c1.r+dp*dp)/(2*dp*c1.r);
    sina = sqrt(1-cosa*cosa);

    ansx1 = c1.p.x + (double)c1.r*(cosa*cost - sint*sina);
    ansy1 = c1.p.y + (double)c1.r*(sint*cosa + cost*sina);
    ansx2 = c1.p.x + (double)c1.r*(cosa*cost + sint*sina);
    ansy2 = c1.p.y + (double)c1.r*(sint*cosa - cost*sina);
    if(ansx1<ansx2) printf("%.8f %.8f %.8f %.8f\n",ansx1,ansy1,ansx2,ansy2);
    else if(ansx1==ansx2){
        if(ansy1<ansy2) printf("%.8f %.8f %.8f %.8f\n",ansx1,ansy1,ansx2,ansy2);
        else printf("%.8f %.8f %.8f %.8f\n",ansx2,ansy2,ansx1,ansy1);
    }
    else printf("%.8f %.8f %.8f %.8f\n",ansx2,ansy2,ansx1,ansy1);
    

}

int main(){
    circle c1,c2;
    int c1x,c2x,c1y,c2y,c1r,c2r;
    cin>>c1x>>c1y>>c1r;
    c1.p.x =c1x; c1.p.y = c1y; c1.r = c1r;
    cin>>c2x>>c2y>>c2r;
    c2.p.x =c2x; c2.p.y = c2y; c2.r = c2r;
    solve(c1,c2);
    return 0;
}


Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	int i;
	for (i = 1; i <= n; i++)
	{
		if ((1 <= i && i <= 9) || (100 <= i && i <= 999) || (10000 <=i&&i<=99999))
			cnt++;
	}
	cout << cnt << endl;
}

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

int main() {
    
    string S, T;
    cin >> S >> T;
    vector<int> start(26, -1);
    vector<int> goal(26, -1);
    for (int i=0; i<S.size(); i++) {
        int a = S[i] - 'a';
        int b = T[i] - 'a';
        
        if (start[a] != -1 || goal[b] != -1) {
            if (start[a] != b || goal[b] != a) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            start[a] = b;
            goal[b] = a;
        }
    }
    
    cout << "Yes" << endl;
    
}

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

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
int n,k,x,y,z,t,a[100001],b,s=0;

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
vector<int> vec;
cin>>n>>x;
forr(i,0,n)cin>>a[i];
a[n++]=x;
sort(a,a+n);
forr(i,1,n)
vec.pb(a[i]-a[i-1]);
y=vec[0];
forr(i,0,n-1)
y=__gcd(y,vec[i]);
cout<<y<<endl;
return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

bool is_prime(int x)
{
	if (x == 2) {
		return true;
	}

	if (x % 2 == 0) {
		return false;
	}

	for (int i = 3; i * i <= x; i += 2) {
		if (x % i == 0) {
			return false;
		}
	}

	return true;
}

int num(int m, const unordered_map<int, int>& primes)
{
	return count_if(begin(primes), end(primes), [m](const auto & p) { return p.second >= m - 1; });
}


int main()
{
	//FASTIO
	/*
	//double start_time = clock();
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int T;
	//cin >> T;
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n;
		cin >> n;
		//dbg(n);
		unordered_map<int, int> primes;
		for (int i = 2; i <= 100; i ++) {
			if (is_prime(i)){
				primes[i] = 0;
				//dbg(i);
			}
		}

		for (int i = 1; i <= n; i++) {
			int x = i;
			for (auto && p : primes) {
				while (x % p.first == 0) {
					p.second++;
					x /= p.first;
					//dbg3(x, p.first, p.second);
				}
			}
		}




		int ans = 0;

		ans += num(75, primes);
		//dbg(ans);
		ans += num(25, primes) * (num(3,primes) - 1);
		//dbg(ans);
		ans += num(15, primes) * (num(5, primes) - 1);
		//dbg(ans);
		ans += num(5, primes) * (num(5,primes) - 1) * (num(3, primes) - 2)/2;
		//dbg(ans);
		cout << ans << endl;
	}

	//double end_time = clock();
	//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
	return 0;
}

Measured memory_bytes: 384
#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"

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N;
	for (int i = 1; i <= N; i+=2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0)cnt++;
		}
		if (cnt == 8)M++;
	}
	cout << M << endl;
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int a = S.at(0) - '0', b = S.at(1) - '0', c = S.at(2) -'0', d = S.at(3) - '0';
    if (a-b-c-d  == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    else if (a-b-c+d  == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if (a-b+c-d  == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if (a-b+c+d  == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if (a+b-c-d  == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if (a+b-c+d  == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if (a+b+c-d  == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if (a+b+c+d  == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  const ll h = min(H, 2 * Q);
  const ll s = min(S, 2 * h);
  const ll d = min(D, 2 * s);

  ll answer = 0;
  for (; N > 0; N -= 2) {
    answer += (N >= 2) ? d : s;
  }
  cout << answer << endl;
  return 0;
}


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

int main(){
    int n; 
    cin >> n;
    vector<int>frog(n);
    rep(i,n) cin >> frog[i];
    vector<int>dp(n);
    dp[0] = 0;
    dp[1] = abs(frog[1] - frog[0]);
	for(int i = 2; i < n; i++) dp[i] = min(dp[i-1] + abs(frog[i] - frog[i-1]),dp[i-2] + abs(frog[i] - frog[i-2]));
	cout << dp[n-1] <<endl;
    return 0;
}


Measured memory_bytes: 1152
from collections import deque
n=int(input())
a=[int(x) for x in input().rstrip().split()]

ans=deque()
for i in range(n):
  if (i+1)%2==1:
    ans.appendleft(str(a[i]))
  else:
    ans.append(str(a[i]))

ans=list(ans)
if n%2==0:
  print(*ans[::-1])
else:
  print(*ans)


Measured memory_bytes: 37136
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
P = list(map(int, input().split()))
T = [[] for _ in range(n)]
for i, p in enumerate(P, 1):
  T[p-1].append(i)
X = list(map(int, input().split()))
D = [[-1]*n for _ in range(2)]
def dfs(color, v):
  if D[color][v] != -1:
    return D[color][v]
  l = len(T[v])
  x = X[v]
  dp = [[float("inf")]*(x+1) for _ in range(l+1)]
  dp[0][0] = 0
  for i, nv in enumerate(T[v]):
    for j in range(x+1):
      if j >= X[nv]:
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-X[nv]]+dfs(color, nv))
      if j >= dfs(color^1, nv):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-dfs(color^1, nv)]+X[nv])
  res = min(dp[l])
  D[color][v] = res
  return res
ans = dfs(0, 0)
if ans == float("inf"):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 121692
n, k =map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9+7
N = 10**5+50
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod


A.sort()
ans = 0
for i, a in enumerate(A):
    M = n-1-i
    m = i
    if m >= 0:
        ans += a*cmb1(m, k-1, mod)
    if M >= 0:
        ans -= a*cmb1(M, k-1, mod)
ans %= mod
print(ans)


Measured memory_bytes: 84664
X, N = list(map(int, input().split()))
if N != 0:
    p = list(map(int, input().split()))
if N == 0:
    p = []
if X in p:
    Xp = X + 1
    Xm = X - 1
    while True:
        if Xm in p:
            Xm -= 1
        else:
            print(Xm)
            break
        if Xp in p:
            Xp += 1
        else:
            print(Xp)
            break
else:
    print(X)


Measured memory_bytes: 9064
package main

import (
	"fmt"
)

func max(a, b int) int {
	max := 0
	if a >= b {
		max = a
	} else {
		max = b
	}
	return max
}
func main() {
	var W, H, N, x, y, a int
	fmt.Scan(&W, &H, &N)
	M := max(W, H) + 1
	p := make([][]int, M)
	for i := 0; i < M; i++ {
		p[i] = make([]int, M)
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&x, &y, &a)
		p[x][y] = a
	}
	aX := 0
	aY := 0
	bX := W
	bY := H
	for x := 0; x <= W; x++ {
		for y := 0; y <= H; y++ {
			a := p[x][y]
			if a > 0 {
				switch a {
				case 1:
					if x > aX {
						aX = x
					}
				case 2:
					if bX > x {
						bX = x
					}
				case 3:
					if y > aY {
						aY = y
					}
				case 4:
					if bY > y {
						bY = y
					}

				}
			}
		}
	}
	if (bY-aY) < 0 || (bX-aX) < 0 {
		fmt.Println(0)
	} else {
		fmt.Println((bY - aY) * (bX - aX))
	}
}


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

int n;
vector<int> a(100001);
int main()
{
	cin >> n;

	int x;
	for (int i = 0; i < n; ++i) 
		cin >> x, a[x]++;

	int cnt = 0;
	bool f = false;
	for (int i = 0; i < 100000; ++i){
		if (a[i] == 0) continue;

		if (a[i] & 1) cnt++;
		else { if (f) { f = false; cnt += 2; } else { f = true; } }
	}

	cout << cnt << endl;
}


Measured memory_bytes: 768